diff options
130 files changed, 951 insertions, 755 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h index 61ce1261..6364add8 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h @@ -66,9 +66,9 @@ typedef struct { NSString *connectionLogin; NSString *connectionPassword; NSString *connectionHost; - NSInteger connectionPort; + NSUInteger connectionPort; NSString *connectionSocket; - NSInteger maxAllowedPacketSize; + NSUInteger maxAllowedPacketSize; unsigned long connectionThreadId; BOOL useSSL; @@ -136,7 +136,7 @@ typedef struct { @property (readwrite, assign) CGFloat keepAliveInterval; // Initialisation -- (id)initToHost:(NSString *)host withLogin:(NSString *)login usingPort:(NSInteger)port; +- (id)initToHost:(NSString *)host withLogin:(NSString *)login usingPort:(NSUInteger)port; - (id)initToSocket:(NSString *)socket withLogin:(NSString *)login; // Delegate @@ -145,7 +145,7 @@ typedef struct { - (MCPConnectionCheck)delegateDecisionForLostConnection; // Connection details -- (BOOL)setPort:(NSInteger)thePort; +- (BOOL)setPort:(NSUInteger)thePort; - (BOOL)setPassword:(NSString *)thePassword; - (void) setSSL:(BOOL)shouldUseSSL usingKeyFilePath:(NSString *)keyFilePath certificatePath:(NSString *)certificatePath certificateAuthorityCertificatePath:(NSString *)caCertificatePath; @@ -169,7 +169,7 @@ typedef struct { - (BOOL)pingConnectionUsingLoopDelay:(NSUInteger)loopDelay; void backgroundPingTask(void *ptr); void forceThreadExit(int signalNumber); -void pingThreadCleanup(); +void pingThreadCleanup(void *pingDetails); - (void)keepAlive:(NSTimer *)theTimer; - (void)threadedKeepAlive; @@ -189,7 +189,7 @@ void pingThreadCleanup(); + (void)setTruncateLongFieldInLogs:(BOOL)iTruncFlag; + (BOOL)truncateLongField; - (BOOL)setConnectionOption:(NSInteger)option toValue:(BOOL)value; -- (BOOL)connectWithLogin:(NSString *)login password:(NSString *)pass host:(NSString *)host port:(NSInteger)port socket:(NSString *)socket; +- (BOOL)connectWithLogin:(NSString *)login password:(NSString *)pass host:(NSString *)host port:(NSUInteger)port socket:(NSString *)socket; - (BOOL)selectDB:(NSString *)dbName; @@ -266,9 +266,9 @@ void pingThreadCleanup(); // Packet size - (BOOL)fetchMaxAllowedPacket; -- (NSInteger)getMaxAllowedPacket; +- (NSUInteger)getMaxAllowedPacket; - (BOOL)isMaxAllowedPacketEditable; -- (NSInteger)setMaxAllowedPacketTo:(NSInteger)newSize resetSize:(BOOL)reset; +- (NSUInteger)setMaxAllowedPacketTo:(NSUInteger)newSize resetSize:(BOOL)reset; // Data conversion - (const char *)cStringFromString:(NSString *)theString; diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m index 3556e9d7..7efe4499 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m @@ -32,6 +32,7 @@ #import "MCPNull.h" #import "MCPStreamingResult.h" #import "MCPConnectionProxy.h" +#import "MCPConnectionDelegate.h" #import "MCPStringAdditions.h" #import "SPStringAdditions.h" #import "RegexKitLite.h" @@ -133,7 +134,7 @@ static BOOL sTruncateLongFieldInLogs = YES; lastKeepAliveTime = 0; pingThread = NULL; connectionProxy = nil; - connectionStartTime = -1; + connectionStartTime = 0; lastQueryExecutedAtTime = CGFLOAT_MAX; lastDelegateDecisionForLostConnection = NSNotFound; queryCancelled = NO; @@ -195,7 +196,7 @@ static BOOL sTruncateLongFieldInLogs = YES; /** * Inialize connection using the supplied host details. */ -- (id)initToHost:(NSString *)host withLogin:(NSString *)login usingPort:(NSInteger)port +- (id)initToHost:(NSString *)host withLogin:(NSString *)login usingPort:(NSUInteger)port { if ((self = [self init])) { if (!host) host = @""; @@ -213,19 +214,19 @@ static BOOL sTruncateLongFieldInLogs = YES; /** * Inialize connection using the supplied socket details. */ -- (id)initToSocket:(NSString *)socket withLogin:(NSString *)login +- (id)initToSocket:(NSString *)aSocket withLogin:(NSString *)login { if ((self = [self init])) { - if (!socket || ![socket length]) { - socket = [self findSocketPath]; - if (!socket) socket = @""; + if (!aSocket || ![aSocket length]) { + aSocket = [self findSocketPath]; + if (!aSocket) aSocket = @""; } if (!login) login = @""; connectionHost = nil; connectionLogin = [[NSString alloc] initWithString:login]; - connectionSocket = [[NSString alloc] initWithString:socket]; + connectionSocket = [[NSString alloc] initWithString:aSocket]; connectionPort = 0; } @@ -298,7 +299,7 @@ static BOOL sTruncateLongFieldInLogs = YES; /** * Sets or updates the connection port - for use with tunnels. */ -- (BOOL)setPort:(NSInteger)thePort +- (BOOL)setPort:(NSUInteger)thePort { connectionPort = thePort; @@ -456,7 +457,7 @@ static BOOL sTruncateLongFieldInLogs = YES; } // Connect - theRet = mysql_real_connect(mConnection, theHost, theLogin, thePass, NULL, connectionPort, theSocket, mConnectionFlags); + theRet = mysql_real_connect(mConnection, theHost, theLogin, thePass, NULL, (unsigned int)connectionPort, theSocket, mConnectionFlags); thePass = NULL; if (theRet != mConnection) { @@ -558,12 +559,12 @@ static BOOL sTruncateLongFieldInLogs = YES; // Check whether a reconnection attempt is already being made - if so, wait and return the status of that reconnection attempt. if (isReconnecting) { - NSDate *reconnectLoopStartdate = [NSDate date], *eventLoopStartDate; + NSDate *eventLoopStartDate; while (isReconnecting) { eventLoopStartDate = [NSDate date]; [[NSRunLoop currentRunLoop] runMode:NSModalPanelRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; if ([[NSDate date] timeIntervalSinceDate:eventLoopStartDate] < 0.1) { - usleep(100000 - (1000000 * [[NSDate date] timeIntervalSinceDate:eventLoopStartDate])); + usleep((useconds_t)(100000 - (1000000 * [[NSDate date] timeIntervalSinceDate:eventLoopStartDate]))); } } [reconnectionPool drain]; @@ -624,7 +625,7 @@ static BOOL sTruncateLongFieldInLogs = YES; eventLoopStartDate = [NSDate date]; [[NSRunLoop currentRunLoop] runMode:NSModalPanelRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.25]]; if ([[NSDate date] timeIntervalSinceDate:eventLoopStartDate] < 0.25) { - usleep(250000 - (1000000 * [[NSDate date] timeIntervalSinceDate:eventLoopStartDate])); + usleep((useconds_t)(250000 - (1000000 * [[NSDate date] timeIntervalSinceDate:eventLoopStartDate]))); } } @@ -653,7 +654,7 @@ static BOOL sTruncateLongFieldInLogs = YES; [[NSRunLoop mainRunLoop] runMode:NSModalPanelRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.25]]; //[[NSRunLoop currentRunLoop] runMode:NSModalPanelRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.25]]; if ([[NSDate date] timeIntervalSinceDate:interfaceInteractionTimer] < 0.25) { - usleep(250000 - (1000000 * [[NSDate date] timeIntervalSinceDate:interfaceInteractionTimer])); + usleep((useconds_t)(250000 - (1000000 * [[NSDate date] timeIntervalSinceDate:interfaceInteractionTimer]))); } if ([connectionProxy state] == PROXY_STATE_WAITING_FOR_AUTH) { proxyStartDate = [proxyStartDate addTimeInterval:[[NSDate date] timeIntervalSinceDate:interfaceInteractionTimer]]; @@ -844,7 +845,7 @@ static BOOL sTruncateLongFieldInLogs = YES; */ - (double)timeConnected { - if (connectionStartTime == -1) return -1; + if (connectionStartTime == 0) return -1; uint64_t currentTime_t = mach_absolute_time() - connectionStartTime; Nanoseconds elapsedTime = AbsoluteToNanoseconds(*(AbsoluteTime *)&(currentTime_t)); @@ -901,7 +902,7 @@ static BOOL sTruncateLongFieldInLogs = YES; // Loop until the ping completes do { - usleep(loopDelay); + usleep((useconds_t)loopDelay); // If the ping timeout has been exceeded, force a timeout; double-check that the // thread is still active. @@ -959,9 +960,10 @@ void forceThreadExit(int signalNumber) pthread_exit(NULL); } -void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) +void pingThreadCleanup(void *pingDetails) { - *(pingDetails->pingActivePointer) = NO; + MCPConnectionPingDetails *pingDetailsStruct = pingDetails; + *(pingDetailsStruct->pingActivePointer) = NO; } /** @@ -1348,12 +1350,12 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) * The socket is used if the host is set to !{@"localhost"}, to an empty or a !{nil} string * For the moment the implementation might not be safe if you have a nil pointer to one of the NSString* variables (underestand: I don't know what the result will be). */ -- (BOOL)connectWithLogin:(NSString *)login password:(NSString *)pass host:(NSString *)host port:(NSInteger)port socket:(NSString *)socket +- (BOOL)connectWithLogin:(NSString *)login password:(NSString *)pass host:(NSString *)host port:(NSUInteger)port socket:(NSString *)aSocket { const char *theLogin = [self cStringFromString:login]; const char *theHost = [self cStringFromString:host]; const char *thePass = [self cStringFromString:pass]; - const char *theSocket = [self cStringFromString:socket]; + const char *theSocket = [self cStringFromString:aSocket]; void *theRet; // Disconnect if it was already connected @@ -1394,7 +1396,7 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) kMCPSSLCipherList); } - theRet = mysql_real_connect(mConnection, theHost, theLogin, thePass, NULL, port, theSocket, mConnectionFlags); + theRet = mysql_real_connect(mConnection, theHost, theLogin, thePass, NULL, (unsigned int)port, theSocket, mConnectionFlags); if (theRet != mConnection) { return mConnected = NO; } @@ -1758,7 +1760,7 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) } else { - NSString *errorMessage = [NSString stringWithFormat:NSLocalizedString(@"The query length of %ld bytes is larger than max_allowed_packet size (%ld).", + NSString *errorMessage = [NSString stringWithFormat:NSLocalizedString(@"The query length of %lu bytes is larger than max_allowed_packet size (%lu).", @"error message if max_allowed_packet < query size"), (unsigned long)theCQueryLength, maxAllowedPacketSize]; @@ -1836,7 +1838,7 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) queryErrorMessage = [[NSString alloc] initWithString:@""]; queryErrorId = 0; - if (streamResultType == MCPStreamingNone && queryAffectedRows == -1) { + if (streamResultType == MCPStreamingNone && queryAffectedRows == (my_ulonglong)~0) { queryAffectedRows = mysql_affected_rows(mConnection); } @@ -1983,7 +1985,7 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) } // Connect - connectionSetupStatus = mysql_real_connect(killerConnection, theHost, theLogin, thePass, NULL, connectionPort, theSocket, mConnectionFlags); + connectionSetupStatus = mysql_real_connect(killerConnection, theHost, theLogin, thePass, NULL, (unsigned int)connectionPort, theSocket, mConnectionFlags); thePass = NULL; if (connectionSetupStatus) { @@ -2153,7 +2155,7 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) [self lockConnection]; if ((dbsName == nil) || ([dbsName isEqualToString:@""])) { - if (theResPtr = mysql_list_dbs(mConnection, NULL)) { + if ((theResPtr = mysql_list_dbs(mConnection, NULL))) { theResult = [[MCPResult alloc] initWithResPtr: theResPtr encoding:stringEncoding timeZone:mTimeZone]; } else { @@ -2163,7 +2165,7 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) else { const char *theCDBsName = (const char *)[self cStringFromString:dbsName]; - if (theResPtr = mysql_list_dbs(mConnection, theCDBsName)) { + if ((theResPtr = mysql_list_dbs(mConnection, theCDBsName))) { theResult = [[MCPResult alloc] initWithResPtr:theResPtr encoding:stringEncoding timeZone:mTimeZone]; } else { @@ -2210,7 +2212,7 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) [self lockConnection]; if ((tablesName == nil) || ([tablesName isEqualToString:@""])) { - if (theResPtr = mysql_list_tables(mConnection, NULL)) { + if ((theResPtr = mysql_list_tables(mConnection, NULL))) { theResult = [[MCPResult alloc] initWithResPtr: theResPtr encoding:stringEncoding timeZone:mTimeZone]; } else { @@ -2219,7 +2221,7 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) } else { const char *theCTablesName = (const char *)[self cStringFromString:tablesName]; - if (theResPtr = mysql_list_tables(mConnection, theCTablesName)) { + if ((theResPtr = mysql_list_tables(mConnection, theCTablesName))) { theResult = [[MCPResult alloc] initWithResPtr: theResPtr encoding:stringEncoding timeZone:mTimeZone]; } else { @@ -2263,7 +2265,7 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) // NSLog(@"num of fields: %@; num of rows: %@", [theResult numOfFields], [theResult numOfRows]); if ([theResult numOfRows] > 0) { - int i; + my_ulonglong i; for ( i = 0 ; i < [theResult numOfRows] ; i++ ) { theTableName = [[theResult fetchRowAsArray] objectAtIndex:0]; [theDBTables addObject:theTableName]; @@ -2440,7 +2442,7 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) // Do not parse more than 2000 tables/views per db if([tablesAndViews count] > 2000) { - NSLog(@"%ld items in database %@. Only 2000 items can be parsed. Stopped parsing.", [tablesAndViews count], currentDatabase); + NSLog(@"%lu items in database %@. Only 2000 items can be parsed. Stopped parsing.", (unsigned long)[tablesAndViews count], currentDatabase); [queryPool release]; return; } @@ -2507,7 +2509,7 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) } // Connect - connectionSetupStatus = mysql_real_connect(structConnection, theHost, theLogin, thePass, NULL, connectionPort, theSocket, mConnectionFlags); + connectionSetupStatus = mysql_real_connect(structConnection, theHost, theLogin, thePass, NULL, (unsigned int)connectionPort, theSocket, mConnectionFlags); thePass = NULL; if (connectionSetupStatus) { MYSQL_RES *theResult; @@ -2558,12 +2560,12 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) if(![aTableName isKindOfClass:[NSString class]]) continue; if(![aTableName length]) continue; // Retrieve the column details - NSString *query = [NSString stringWithFormat:@"SHOW FULL COLUMNS FROM `%@` FROM `%@`", + query = [NSString stringWithFormat:@"SHOW FULL COLUMNS FROM `%@` FROM `%@`", [aTableName stringByReplacingOccurrencesOfString:@"`" withString:@"``"], currentDatabaseEscaped]; - NSData *encodedQueryData = NSStringDataUsingLossyEncoding(query, theConnectionEncoding, 1); - const char *queryCString = [encodedQueryData bytes]; - unsigned long queryCStringLength = [encodedQueryData length]; + encodedQueryData = NSStringDataUsingLossyEncoding(query, theConnectionEncoding, 1); + queryCString = [encodedQueryData bytes]; + queryCStringLength = [encodedQueryData length]; if (mysql_real_query(structConnection, queryCString, queryCStringLength) != 0) { // NSLog(@"error %@", aTableName); continue; @@ -2579,7 +2581,7 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) NSMutableDictionary *tableStructure = [databaseStructure objectForKey:table_id]; // Loop through the fields, extracting details for each - while (row = mysql_fetch_row(theResult)) { + while ((row = mysql_fetch_row(theResult))) { NSString *field = [self stringWithCString:row[0] usingEncoding:theConnectionEncoding] ; NSString *type = [self stringWithCString:row[1] usingEncoding:theConnectionEncoding] ; NSString *type_display = [type stringByReplacingOccurrencesOfRegex:@"\\(.*?,.*?\\)" withString:@"(…)"]; @@ -2627,10 +2629,9 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) queryCStringLength = [encodedQueryData length]; if (mysql_real_query(structConnection, queryCString, queryCStringLength) == 0) { theResult = mysql_use_result(structConnection); - NSUInteger numberOfFields = mysql_num_fields(theResult); // Loop through the rows and extract the function details - while(row = mysql_fetch_row(theResult)) { + while ((row = mysql_fetch_row(theResult))) { // If cancelled, abort without saving the new structure if(cancelQueryingDbStructure) { @@ -2643,7 +2644,7 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) NSString *type = ([[self stringWithUTF8CString:row[4]] isEqualToString:@"FUNCTION"]) ? @"3" : @"2"; NSString *dtd = [self stringWithUTF8CString:row[5]]; NSString *det = [self stringWithUTF8CString:row[11]]; - NSString *access = [self stringWithUTF8CString:row[12]]; + NSString *dataaccess = [self stringWithUTF8CString:row[12]]; NSString *security_type = [self stringWithUTF8CString:row[14]]; NSString *definer = [self stringWithUTF8CString:row[19]]; @@ -2659,7 +2660,7 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) // Add the "field" details [[[queriedStructure valueForKey:db_id] valueForKey:table_id] setObject: - [NSArray arrayWithObjects:dtd, access, det, security_type, definer, [NSNumber numberWithUnsignedLongLong:uniqueCounter], nil] forKey:field_id]; + [NSArray arrayWithObjects:dtd, dataaccess, det, security_type, definer, [NSNumber numberWithUnsignedLongLong:uniqueCounter], nil] forKey:field_id]; [[[queriedStructure valueForKey:db_id] valueForKey:table_id] setObject:type forKey:@" struct_type "]; uniqueCounter++; } @@ -2802,7 +2803,7 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) [self lockConnection]; if (mConnected && (mConnection != NULL)) { - if (theResPtr = mysql_list_processes(mConnection)) { + if ((theResPtr = mysql_list_processes(mConnection))) { result = [[MCPResult alloc] initWithResPtr:theResPtr encoding:stringEncoding timeZone:mTimeZone]; } else { @@ -2850,7 +2851,7 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) @"/opt/local/lib/mysql/mysql.sock", // Alternate fedora nil]; - for (NSInteger i = 0; i < [possibleSocketLocations count]; i++) + for (NSUInteger i = 0; i < [possibleSocketLocations count]; i++) { if ([fileManager fileExistsAtPath:[possibleSocketLocations objectAtIndex:i]]) return [possibleSocketLocations objectAtIndex:i]; @@ -3091,9 +3092,9 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) /** * Retrieves max_allowed_packet size set as global variable. - * It returns -1 if it fails. + * It returns NSNotFound if it fails. */ -- (NSInteger)getMaxAllowedPacket +- (NSUInteger)getMaxAllowedPacket { MCPResult *r; r = [self queryString:@"SELECT @@global.max_allowed_packet" usingEncoding:stringEncoding streamingResult:NO]; @@ -3105,13 +3106,13 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) else NSRunAlertPanel(@"Error", errorMessage, @"OK", nil, nil); } - return -1; + return NSNotFound; } NSArray *a = [r fetchRowAsArray]; if([a count]) return [[a objectAtIndex:0] integerValue]; - return -1; + return NSNotFound; } /* @@ -3120,21 +3121,22 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) * if the maximal size was reached (e.g. set it to 4GB it'll return 1GB up to now). * If something failed it return -1; */ -- (NSInteger)setMaxAllowedPacketTo:(NSInteger)newSize resetSize:(BOOL)reset +- (NSUInteger)setMaxAllowedPacketTo:(NSUInteger)newSize resetSize:(BOOL)reset { if(![self isMaxAllowedPacketEditable] || newSize < 1024) return maxAllowedPacketSize; [self lockConnection]; - mysql_query(mConnection, [[NSString stringWithFormat:@"SET GLOBAL max_allowed_packet = %ld", newSize] UTF8String]); + mysql_query(mConnection, [[NSString stringWithFormat:@"SET GLOBAL max_allowed_packet = %lu", newSize] UTF8String]); [self unlockConnection]; // Inform the user via a log entry about that change according to reset value - if(delegate && [delegate respondsToSelector:@selector(queryGaveError:connection:)]) + if(delegate && [delegate respondsToSelector:@selector(queryGaveError:connection:)]) { if(reset) - [delegate queryGaveError:[NSString stringWithFormat:@"max_allowed_packet was reset to %ld for new session", newSize] connection:self]; + [delegate queryGaveError:[NSString stringWithFormat:@"max_allowed_packet was reset to %lu for new session", newSize] connection:self]; else - [delegate queryGaveError:[NSString stringWithFormat:@"Query too large; max_allowed_packet temporarily set to %ld for the current session to allow query to succeed", newSize] connection:self]; - + [delegate queryGaveError:[NSString stringWithFormat:@"Query too large; max_allowed_packet temporarily set to %lu for the current session to allow query to succeed", newSize] connection:self]; + } + return maxAllowedPacketSize; } diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnectionDelegate.h b/Frameworks/MCPKit/MCPFoundationKit/MCPConnectionDelegate.h index 3cbba325..0e162875 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnectionDelegate.h +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnectionDelegate.h @@ -26,7 +26,7 @@ // More info at <http://mysql-cocoa.sourceforge.net/> // More info at <http://code.google.com/p/sequel-pro/> -@protocol MCPConnectionDelegate +@protocol MCPConnectionDelegate <NSObject> /** * diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnectionProxy.h b/Frameworks/MCPKit/MCPFoundationKit/MCPConnectionProxy.h index 6d03137c..f4edbfd8 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnectionProxy.h +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnectionProxy.h @@ -60,7 +60,7 @@ enum PROXY_TUNNEL_STATES /** * Get the local port being used by the proxy. */ -- (NSInteger)localPort; +- (NSUInteger)localPort; /** * Sets the method the proxy should call whenever the state of the connection changes. diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPGeometryData.h b/Frameworks/MCPKit/MCPFoundationKit/MCPGeometryData.h index cca59b30..9af3fcfe 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPGeometryData.h +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPGeometryData.h @@ -42,7 +42,7 @@ typedef struct st_point_2d_ double y; } st_point_2d; -@interface MCPGeometryData : NSObject <NSCoding, NSCopying> +@interface MCPGeometryData : NSObject { // Holds the WKB bytes coming from SQL server Byte *geoBuffer; @@ -52,8 +52,8 @@ typedef struct st_point_2d_ } -- (id)initWithBytes:(Byte*)geoData length:(NSUInteger)length; -+ (id)dataWithBytes:(Byte*)geoData length:(NSUInteger)length; +- (id)initWithBytes:(const void *)geoData length:(NSUInteger)length; ++ (id)dataWithBytes:(const void *)geoData length:(NSUInteger)length; - (NSString*)description; - (NSUInteger)length; - (NSData*)data; diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPGeometryData.m b/Frameworks/MCPKit/MCPFoundationKit/MCPGeometryData.m index 00d7d44f..b7a3fd09 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPGeometryData.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPGeometryData.m @@ -47,7 +47,7 @@ /** * Initialize the MCPGeometryData object with the WKB data */ -- (id)initWithBytes:(Byte*)geoData length:(NSUInteger)length +- (id)initWithBytes:(const void *)geoData length:(NSUInteger)length { if ((self = [self init])) { bufferLength = length; @@ -60,7 +60,7 @@ /** * Return an autorelease MCPGeometryData object */ -+ (id)dataWithBytes:(Byte*)geoData length:(NSUInteger)length ++ (id)dataWithBytes:(const void *)geoData length:(NSUInteger)length { return [[[MCPGeometryData alloc] initWithBytes:geoData length:length] autorelease]; } @@ -370,10 +370,10 @@ uint32_t i, j, k, n; // Loop counter for numberOf...Items uint32_t ptr = BUFFER_START; // pointer to geoBuffer while parsing - double x_min = 1e998; - double x_max = -1e998; - double y_min = 1e998; - double y_max = -1e998; + double x_min = DBL_MAX; + double x_max = -DBL_MAX; + double y_min = DBL_MAX; + double y_max = -DBL_MAX; NSMutableArray *coordinates = [NSMutableArray array]; NSMutableArray *subcoordinates = [NSMutableArray array]; @@ -406,7 +406,7 @@ x_max = aPoint.x; y_min = aPoint.y; y_max = aPoint.y; - [coordinates addObject:NSStringFromPoint(NSMakePoint(aPoint.x, aPoint.y))]; + [coordinates addObject:NSStringFromPoint(NSMakePoint((CGFloat)aPoint.x, (CGFloat)aPoint.y))]; return [NSDictionary dictionaryWithObjectsAndKeys: [NSArray arrayWithObjects: [NSNumber numberWithDouble:x_min], @@ -429,7 +429,7 @@ x_max = (aPoint.x > x_max) ? aPoint.x : x_max; y_min = (aPoint.y < y_min) ? aPoint.y : y_min; y_max = (aPoint.y > y_max) ? aPoint.y : y_max; - [coordinates addObject:NSStringFromPoint(NSMakePoint(aPoint.x, aPoint.y))]; + [coordinates addObject:NSStringFromPoint(NSMakePoint((CGFloat)aPoint.x, (CGFloat)aPoint.y))]; ptr += POINT_DATA_SIZE; } return [NSDictionary dictionaryWithObjectsAndKeys: @@ -456,7 +456,7 @@ x_max = (aPoint.x > x_max) ? aPoint.x : x_max; y_min = (aPoint.y < y_min) ? aPoint.y : y_min; y_max = (aPoint.y > y_max) ? aPoint.y : y_max; - [subcoordinates addObject:NSStringFromPoint(NSMakePoint(aPoint.x, aPoint.y))]; + [subcoordinates addObject:NSStringFromPoint(NSMakePoint((CGFloat)aPoint.x, (CGFloat)aPoint.y))]; ptr += POINT_DATA_SIZE; } [coordinates addObject:[[subcoordinates copy] autorelease]]; @@ -484,7 +484,7 @@ x_max = (aPoint.x > x_max) ? aPoint.x : x_max; y_min = (aPoint.y < y_min) ? aPoint.y : y_min; y_max = (aPoint.y > y_max) ? aPoint.y : y_max; - [coordinates addObject:NSStringFromPoint(NSMakePoint(aPoint.x, aPoint.y))]; + [coordinates addObject:NSStringFromPoint(NSMakePoint((CGFloat)aPoint.x, (CGFloat)aPoint.y))]; ptr += POINT_DATA_SIZE+WKB_HEADER_SIZE; } return [NSDictionary dictionaryWithObjectsAndKeys: @@ -512,7 +512,7 @@ x_max = (aPoint.x > x_max) ? aPoint.x : x_max; y_min = (aPoint.y < y_min) ? aPoint.y : y_min; y_max = (aPoint.y > y_max) ? aPoint.y : y_max; - [subcoordinates addObject:NSStringFromPoint(NSMakePoint(aPoint.x, aPoint.y))]; + [subcoordinates addObject:NSStringFromPoint(NSMakePoint((CGFloat)aPoint.x, (CGFloat)aPoint.y))]; ptr += POINT_DATA_SIZE; } ptr += WKB_HEADER_SIZE; @@ -547,7 +547,7 @@ x_max = (aPoint.x > x_max) ? aPoint.x : x_max; y_min = (aPoint.y < y_min) ? aPoint.y : y_min; y_max = (aPoint.y > y_max) ? aPoint.y : y_max; - [subcoordinates addObject:NSStringFromPoint(NSMakePoint(aPoint.x, aPoint.y))]; + [subcoordinates addObject:NSStringFromPoint(NSMakePoint((CGFloat)aPoint.x, (CGFloat)aPoint.y))]; ptr += POINT_DATA_SIZE; } [coordinates addObject:[[subcoordinates copy] autorelease]]; @@ -591,7 +591,7 @@ x_max = (aPoint.x > x_max) ? aPoint.x : x_max; y_min = (aPoint.y < y_min) ? aPoint.y : y_min; y_max = (aPoint.y > y_max) ? aPoint.y : y_max; - [pointcoordinates addObject:NSStringFromPoint(NSMakePoint(aPoint.x, aPoint.y))]; + [pointcoordinates addObject:NSStringFromPoint(NSMakePoint((CGFloat)aPoint.x, (CGFloat)aPoint.y))]; ptr += POINT_DATA_SIZE; break; @@ -604,7 +604,7 @@ x_max = (aPoint.x > x_max) ? aPoint.x : x_max; y_min = (aPoint.y < y_min) ? aPoint.y : y_min; y_max = (aPoint.y > y_max) ? aPoint.y : y_max; - [linesubcoordinates addObject:NSStringFromPoint(NSMakePoint(aPoint.x, aPoint.y))]; + [linesubcoordinates addObject:NSStringFromPoint(NSMakePoint((CGFloat)aPoint.x, (CGFloat)aPoint.y))]; ptr += POINT_DATA_SIZE; } [linecoordinates addObject:[[linesubcoordinates copy] autorelease]]; @@ -623,7 +623,7 @@ x_max = (aPoint.x > x_max) ? aPoint.x : x_max; y_min = (aPoint.y < y_min) ? aPoint.y : y_min; y_max = (aPoint.y > y_max) ? aPoint.y : y_max; - [polygonsubcoordinates addObject:NSStringFromPoint(NSMakePoint(aPoint.x, aPoint.y))]; + [polygonsubcoordinates addObject:NSStringFromPoint(NSMakePoint((CGFloat)aPoint.x, (CGFloat)aPoint.y))]; ptr += POINT_DATA_SIZE; } [polygoncoordinates addObject:[[polygonsubcoordinates copy] autorelease]]; @@ -640,7 +640,7 @@ x_max = (aPoint.x > x_max) ? aPoint.x : x_max; y_min = (aPoint.y < y_min) ? aPoint.y : y_min; y_max = (aPoint.y > y_max) ? aPoint.y : y_max; - [pointcoordinates addObject:NSStringFromPoint(NSMakePoint(aPoint.x, aPoint.y))]; + [pointcoordinates addObject:NSStringFromPoint(NSMakePoint((CGFloat)aPoint.x, (CGFloat)aPoint.y))]; ptr += POINT_DATA_SIZE+WKB_HEADER_SIZE; } ptr -= WKB_HEADER_SIZE; @@ -658,7 +658,7 @@ x_max = (aPoint.x > x_max) ? aPoint.x : x_max; y_min = (aPoint.y < y_min) ? aPoint.y : y_min; y_max = (aPoint.y > y_max) ? aPoint.y : y_max; - [linesubcoordinates addObject:NSStringFromPoint(NSMakePoint(aPoint.x, aPoint.y))]; + [linesubcoordinates addObject:NSStringFromPoint(NSMakePoint((CGFloat)aPoint.x, (CGFloat)aPoint.y))]; ptr += POINT_DATA_SIZE; } [linecoordinates addObject:[[linesubcoordinates copy] autorelease]]; @@ -683,7 +683,7 @@ x_max = (aPoint.x > x_max) ? aPoint.x : x_max; y_min = (aPoint.y < y_min) ? aPoint.y : y_min; y_max = (aPoint.y > y_max) ? aPoint.y : y_max; - [polygonsubcoordinates addObject:NSStringFromPoint(NSMakePoint(aPoint.x, aPoint.y))]; + [polygonsubcoordinates addObject:NSStringFromPoint(NSMakePoint((CGFloat)aPoint.x, (CGFloat)aPoint.y))]; ptr += POINT_DATA_SIZE; } [polygoncoordinates addObject:[[polygonsubcoordinates copy] autorelease]]; @@ -728,7 +728,7 @@ NSUInteger ptr = BUFFER_START; // pointer to geoBuffer while parsing if (bufferLength < WKB_HEADER_SIZE) - return @"-1"; + return -1; byteOrder = geoBuffer[ptr]; diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPNumber.m b/Frameworks/MCPKit/MCPFoundationKit/MCPNumber.m index 3dab0e07..de035ee8 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPNumber.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPNumber.m @@ -246,12 +246,12 @@ - (int)intValue { - return [number integerValue]; + return [number intValue]; } - (unsigned int)unsignedIntValue { - return [number unsignedIntegerValue]; + return [number unsignedIntValue]; } - (long)longValue @@ -276,7 +276,7 @@ - (float)floatValue { - return [number doubleValue]; + return [number floatValue]; } - (double)doubleValue diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m b/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m index 24d14193..53066c14 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m @@ -227,7 +227,7 @@ const OUR_CHARSET our_charsets60[] = */ + (void)initialize { - if (self = [MCPResult class]) { + if ((self = [MCPResult class])) { [self setVersion:030001]; // Ma.Mi.Re -> MaMiRe MCPYear0000 = [NSCalendarDate dateWithTimeIntervalSinceReferenceDate:-63146822400.0]; [MCPYear0000 setCalendarFormat:@"%Y"]; @@ -367,7 +367,7 @@ const OUR_CHARSET our_charsets60[] = */ - (void)dataSeek:(my_ulonglong)row { - my_ulonglong theRow = (row < 0)? 0 : row; + my_ulonglong theRow = (row < 1)? 0 : row; theRow = (theRow < [self numOfRows]) ? theRow : ([self numOfRows] - 1); mysql_data_seek(mResult,theRow); } @@ -380,7 +380,7 @@ const OUR_CHARSET our_charsets60[] = MYSQL_ROW theRow; unsigned long *theLengths; MYSQL_FIELD *theField; - NSInteger i; + NSUInteger i; id theReturn; if (mResult == NULL) { @@ -405,7 +405,7 @@ const OUR_CHARSET our_charsets60[] = theReturn = [NSMutableDictionary dictionaryWithCapacity:mNumOfFields]; break; default : - NSLog (@"Unknown type : %d, will return an Array!\n", aType); + NSLog (@"Unknown type : %d, will return an Array!\n", (int)aType); theReturn = [NSMutableArray arrayWithCapacity:mNumOfFields]; break; } @@ -474,7 +474,7 @@ const OUR_CHARSET our_charsets60[] = break; default: - NSLog (@"in fetchRowAsType : Unknown type : %ld for column %ld, send back a NSData object", (NSInteger)theField[i].type, (NSInteger)i); + NSLog (@"in fetchRowAsType : Unknown type : %d for column %lu, send back a NSData object", (int)theField[i].type, (unsigned long)i); theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]]; break; } @@ -542,7 +542,7 @@ const OUR_CHARSET our_charsets60[] = */ - (NSArray *)fetchFieldNames { - NSInteger i; + NSUInteger i; NSUInteger theNumFields; NSMutableArray *theNamesArray; MYSQL_FIELD *theField; @@ -581,7 +581,7 @@ const OUR_CHARSET our_charsets60[] = */ - (id)fetchTypesAsType:(MCPReturnType)aType { - NSInteger i; + NSUInteger i; id theTypes; MYSQL_FIELD *theField; @@ -601,7 +601,7 @@ const OUR_CHARSET our_charsets60[] = theTypes = [NSMutableDictionary dictionaryWithCapacity:mNumOfFields]; break; default : - NSLog (@"Unknown type : %d, will return an Array!\n", aType); + NSLog (@"Unknown type : %d, will return an Array!\n", (int)aType); theTypes = [NSMutableArray arrayWithCapacity:mNumOfFields]; break; } @@ -686,7 +686,7 @@ const OUR_CHARSET our_charsets60[] = break; default: theType = @"unknown"; - NSLog (@"in fetchTypesAsArray : Unknown type for column %ld of the MCPResult, type = %ld", (NSInteger)i, (NSInteger)theField[i].type); + NSLog (@"in fetchTypesAsArray : Unknown type for column %lu of the MCPResult, type = %d", (unsigned long)i, (int)theField[i].type); break; } @@ -843,7 +843,7 @@ const OUR_CHARSET our_charsets60[] = /** * Return the MySQL flags of the column at the given index... Can be used to check if a number is signed or not... */ -- (NSUInteger)fetchFlagsAtIndex:(NSUInteger)index +- (NSUInteger)fetchFlagsAtIndex:(NSUInteger)anIndex { NSUInteger theRet; NSUInteger theNumFields; @@ -857,12 +857,12 @@ const OUR_CHARSET our_charsets60[] = theNumFields = [self numOfFields]; theField = mysql_fetch_fields(mResult); - if (index >= theNumFields) { + if (anIndex >= theNumFields) { // Out of range... should raise an exception theRet = 0; } else { - theRet = theField[index].flags; + theRet = theField[anIndex].flags; } return theRet; @@ -874,7 +874,7 @@ const OUR_CHARSET our_charsets60[] = - (NSUInteger)fetchFlagsForKey:(NSString *)key { NSUInteger theRet; - NSUInteger index; + NSUInteger anIndex; MYSQL_FIELD *theField; if (mResult == NULL) { @@ -893,9 +893,9 @@ const OUR_CHARSET our_charsets60[] = theRet = 0; } else { - index = [mNames indexOfObject:key]; + anIndex = [mNames indexOfObject:key]; - theRet = theField[index].flags; + theRet = theField[anIndex].flags; } return theRet; @@ -911,7 +911,7 @@ const OUR_CHARSET our_charsets60[] = * #{NOTE} That the current version handles properly TEXT, and returns those as NSString (and not NSData as * it used to be). */ -- (BOOL)isBlobAtIndex:(NSUInteger)index +- (BOOL)isBlobAtIndex:(NSUInteger)anIndex { BOOL theRet; NSUInteger theNumFields; @@ -925,17 +925,17 @@ const OUR_CHARSET our_charsets60[] = theNumFields = [self numOfFields]; theField = mysql_fetch_fields(mResult); - if (index >= theNumFields) { + if (anIndex >= theNumFields) { // Out of range... should raise an exception theRet = NO; } else { - switch(theField[index].type) { + switch(theField[anIndex].type) { case FIELD_TYPE_TINY_BLOB: case FIELD_TYPE_BLOB: case FIELD_TYPE_MEDIUM_BLOB: case FIELD_TYPE_LONG_BLOB: - theRet = (theField[index].flags & BINARY_FLAG); + theRet = (theField[anIndex].flags & BINARY_FLAG); break; default: theRet = NO; @@ -959,7 +959,7 @@ const OUR_CHARSET our_charsets60[] = - (BOOL)isBlobForKey:(NSString *)key { BOOL theRet; - NSUInteger index; + NSUInteger anIndex; MYSQL_FIELD *theField; if (mResult == NULL) { @@ -978,14 +978,14 @@ const OUR_CHARSET our_charsets60[] = theRet = NO; } else { - index = [mNames indexOfObject:key]; + anIndex = [mNames indexOfObject:key]; - switch(theField[index].type) { + switch(theField[anIndex].type) { case FIELD_TYPE_TINY_BLOB: case FIELD_TYPE_BLOB: case FIELD_TYPE_MEDIUM_BLOB: case FIELD_TYPE_LONG_BLOB: - theRet = (theField[index].flags & BINARY_FLAG); + theRet = (theField[anIndex].flags & BINARY_FLAG); break; default: theRet = NO; @@ -1043,10 +1043,10 @@ const OUR_CHARSET our_charsets60[] = } else { NSMutableString *theString = [NSMutableString stringWithCapacity:0]; - NSInteger i; + NSUInteger i; NSArray *theRow; MYSQL_ROW_OFFSET thePosition; - BOOL trunc = [MCPConnection truncateLongField]; + BOOL shouldTruncateFields = [MCPConnection truncateLongField]; // First line, saying we are displaying a MCPResult [theString appendFormat:@"MCPResult: (encoding : %ld, dim %ld x %ld)\n", (long)mEncoding, (long)mNumOfFields, (long)[self numOfRows]]; @@ -1063,11 +1063,11 @@ const OUR_CHARSET our_charsets60[] = thePosition = mysql_row_tell(mResult); [self dataSeek:0]; - while (theRow = [self fetchRowAsArray]) + while ((theRow = [self fetchRowAsArray])) { id theField = [theRow objectAtIndex:i]; - if (trunc) { + if (shouldTruncateFields) { if (([theField isKindOfClass:[NSString class]]) && (kLengthOfTruncationForLog < [(NSString *)theField length])) { theField = [theField substringToIndex:kLengthOfTruncationForLog]; } diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPResultPlus.m b/Frameworks/MCPKit/MCPFoundationKit/MCPResultPlus.m index c171dc7f..dbf9d070 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPResultPlus.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPResultPlus.m @@ -42,7 +42,7 @@ */ - (NSArray *)fetchColAtIndex:(NSUInteger)col { - NSMutableArray *theCol = [NSMutableArray arrayWithCapacity:[self numOfRows]]; + NSMutableArray *theCol = [NSMutableArray arrayWithCapacity:(NSUInteger)[self numOfRows]]; MYSQL_ROW_OFFSET thePosition; NSArray *theRow; @@ -61,7 +61,7 @@ [self dataSeek:0]; // One might want to have optimized code here. Maybe in later versions - while (theRow = [self fetchRowAsType:MCPTypeArray]) + while ((theRow = [self fetchRowAsType:MCPTypeArray])) { [theCol addObject:[theRow objectAtIndex:col]]; } @@ -131,9 +131,9 @@ switch (type) { case MCPTypeArray : - theTable = [NSMutableArray arrayWithCapacity:[self numOfRows]]; + theTable = [NSMutableArray arrayWithCapacity:(NSUInteger)[self numOfRows]]; - while (theVect = [self fetchRowAsArray]) + while ((theVect = [self fetchRowAsArray])) { [theTable addObject:theVect]; } @@ -141,9 +141,9 @@ theTable = [NSArray arrayWithArray:theTable]; break; case MCPTypeDictionary : - theTable = [NSMutableArray arrayWithCapacity:[self numOfRows]]; + theTable = [NSMutableArray arrayWithCapacity:(NSUInteger)[self numOfRows]]; - while (theVect = [self fetchRowAsDictionary]) + while ((theVect = [self fetchRowAsDictionary])) { [theTable addObject:theVect]; } @@ -175,7 +175,7 @@ theTable = [NSDictionary dictionaryWithDictionary:theTable]; break; default : - NSLog (@"Unknown MCPReturnType : %ld; return nil\n", (NSInteger)type); + NSLog (@"Unknown MCPReturnType : %d; return nil\n", (int)type); theTable = nil; break; } diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m b/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m index c15db6c6..465221fe 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m @@ -164,7 +164,7 @@ void _bytes2bin(Byte *n, NSUInteger nbytes, NSUInteger len, char *buf); MYSQL_ROW theRow; char *theRowData, *buf; unsigned long *fieldLengths; - NSInteger i, copiedDataLength; + NSUInteger i, copiedDataLength; NSMutableArray *returnArray; // Retrieve the next row according to the mode this result set is in. @@ -290,7 +290,7 @@ void _bytes2bin(Byte *n, NSUInteger nbytes, NSUInteger len, char *buf); // Get a binary representation of the data buf = malloc(fieldDefinitions[i].length + 1); - _bytes2bin(theData, fieldLengths[i], fieldDefinitions[i].length, buf); + _bytes2bin((Byte *)theData, fieldLengths[i], fieldDefinitions[i].length, buf); cellData = (theData != NULL) ? [NSString stringWithUTF8String:buf] : @""; @@ -323,7 +323,7 @@ void _bytes2bin(Byte *n, NSUInteger nbytes, NSUInteger len, char *buf); break; default: - NSLog(@"in fetchNextRowAsArray : Unknown type : %ld for column %ld, sending back a NSData object", (NSInteger)fieldDefinitions[i].type, (NSInteger)i); + NSLog(@"in fetchNextRowAsArray : Unknown type : %d for column %lu, sending back a NSData object", (int)fieldDefinitions[i].type, (unsigned long)i); cellData = [NSData dataWithBytes:theData length:fieldLengths[i]]; break; } @@ -435,10 +435,10 @@ void _bytes2bin(Byte *n, NSUInteger nbytes, NSUInteger len, char *buf); void _bytes2bin(Byte *n, NSUInteger nbytes, NSUInteger len, char *buf) { - int i = 0; + NSUInteger i = 0; nbytes--; - while (i < len) - buf[len - ++i] = ( (n[nbytes - (i >> 3)] >> (i & 0x7)) & 1 ) ? '1' : '0'; + while (++i <= len) + buf[len - i] = ( (n[nbytes - (i >> 3)] >> (i & 0x7)) & 1 ) ? '1' : '0'; buf[len] = '\0'; } @@ -451,14 +451,14 @@ void _bytes2bin(Byte *n, NSUInteger nbytes, NSUInteger len, char *buf) NSAutoreleasePool *downloadPool = [[NSAutoreleasePool alloc] init]; MYSQL_ROW theRow; unsigned long *fieldLengths; - NSInteger i, dataCopiedLength, rowDataLength; + NSUInteger i, dataCopiedLength, rowDataLength; LOCAL_ROW_DATA *newRowStore; size_t sizeOfLocalRowData = sizeof(LOCAL_ROW_DATA); size_t sizeOfDataLengths = (size_t)(sizeof(unsigned long) * mNumOfFields); // Loop through the rows until the end of the data is reached - indicated via a NULL - while ( (BOOL)(*isConnectedPtr)(parentConnection, isConnectedSEL) && (theRow = mysql_fetch_row(mResult))) { + while ((*isConnectedPtr)(parentConnection, isConnectedSEL) && (theRow = mysql_fetch_row(mResult))) { // Retrieve the lengths of the returned data fieldLengths = mysql_fetch_lengths(mResult); diff --git a/Frameworks/MCPKit/Support files/NSNotificationAdditions.m b/Frameworks/MCPKit/Support files/NSNotificationAdditions.m index d615231e..9991c999 100644 --- a/Frameworks/MCPKit/Support files/NSNotificationAdditions.m +++ b/Frameworks/MCPKit/Support files/NSNotificationAdditions.m @@ -26,6 +26,12 @@ #import "NSNotificationAdditions.h" #import "pthread.h" +@interface NSNotificationCenter (NSNotificationCenterAdditions_PrivateAPI) ++ (void)_postNotification:(NSNotification *)notification; ++ (void)_postNotificationName:(NSDictionary *)info; ++ (void)_postNotificationForwarder:(NSDictionary *)info; +@end + @implementation NSNotificationCenter (NSNotificationCenterAdditions) - (void)postNotificationOnMainThread:(NSNotification *)notification @@ -35,16 +41,11 @@ [self postNotificationOnMainThread:notification waitUntilDone:NO]; } -- (void)postNotificationOnMainThread:(NSNotification *)notification waitUntilDone:(BOOL)wait +- (void)postNotificationOnMainThread:(NSNotification *)notification waitUntilDone:(BOOL)shouldWaitUntilDone { if (pthread_main_np()) return [self postNotification:notification]; - [[self class] performSelectorOnMainThread:@selector(_postNotification:) withObject:notification waitUntilDone:wait]; -} - -+ (void)_postNotification:(NSNotification *)notification -{ - [[self defaultCenter] postNotification:notification]; + [self performSelectorOnMainThread:@selector(_postNotification:) withObject:notification waitUntilDone:shouldWaitUntilDone]; } - (void)postNotificationOnMainThreadWithName:(NSString *)name object:(id)object @@ -61,7 +62,7 @@ [self postNotificationOnMainThreadWithName:name object:object userInfo:userInfo waitUntilDone:NO]; } -- (void)postNotificationOnMainThreadWithName:(NSString *)name object:(id)object userInfo:(NSDictionary *)userInfo waitUntilDone:(BOOL)wait +- (void)postNotificationOnMainThreadWithName:(NSString *)name object:(id)object userInfo:(NSDictionary *)userInfo waitUntilDone:(BOOL)shouldWaitUntilDone { if (pthread_main_np()) return [self postNotificationName:name object:object userInfo:userInfo]; @@ -71,11 +72,20 @@ if (object) [info setObject:object forKey:@"object"]; if (userInfo) [info setObject:userInfo forKey:@"userInfo"]; - [[self class] performSelectorOnMainThread:@selector(_postNotificationName:) withObject:info waitUntilDone:wait]; + [[self class] performSelectorOnMainThread:@selector(_postNotificationName:) withObject:info waitUntilDone:shouldWaitUntilDone]; [info release]; } +@end + +@implementation NSNotificationCenter (NSNotificationCenterAdditions_PrivateAPI) + ++ (void)_postNotification:(NSNotification *)notification +{ + [[self defaultCenter] postNotification:notification]; +} + + (void)_postNotificationName:(NSDictionary *)info { NSString *name = [info objectForKey:@"name"]; @@ -87,4 +97,15 @@ [[self defaultCenter] postNotificationName:name object:object userInfo:userInfo]; } ++ (void)_postNotificationForwarder:(NSDictionary *)info +{ + NSString *name = [info objectForKey:@"name"]; + + id object = [info objectForKey:@"object"]; + + NSDictionary *userInfo = [info objectForKey:@"userInfo"]; + + [[self defaultCenter] postNotificationName:name object:object userInfo:userInfo]; +} + @end diff --git a/Frameworks/PSMTabBar/NSBezierPath_AMShading.m b/Frameworks/PSMTabBar/NSBezierPath_AMShading.m index 73213f3b..b878688d 100755 --- a/Frameworks/PSMTabBar/NSBezierPath_AMShading.m +++ b/Frameworks/PSMTabBar/NSBezierPath_AMShading.m @@ -23,7 +23,7 @@ static void linearShadedColor(void *info, const CGFloat *in, CGFloat *out) static void bilinearShadedColor(void *info, const CGFloat *in, CGFloat *out) { CGFloat *colors = (CGFloat *)info; - CGFloat factor = (*in)*2.0; + CGFloat factor = (*in)*2.0f; if (*in > 0.5) { factor = 2-factor; } @@ -87,7 +87,7 @@ static void bilinearShadedColor(void *info, const CGFloat *in, CGFloat *out) // draw gradient colorspace = CGColorSpaceCreateDeviceRGB(); size_t components = 1 + CGColorSpaceGetNumberOfComponents(colorspace); - static const CGFloat domain[2] = {0.0, 1.0}; + static const CGFloat domain[2] = {0.0f, 1.0f}; static const CGFloat range[10] = {0, 1, 0, 1, 0, 1, 0, 1, 0, 1}; //static const CGFunctionCallbacks callbacks = {0, &bilinearShadedColor, NULL}; diff --git a/Frameworks/PSMTabBar/PSMOverflowPopUpButton.h b/Frameworks/PSMTabBar/PSMOverflowPopUpButton.h index 19ce95f1..b513865e 100644 --- a/Frameworks/PSMTabBar/PSMOverflowPopUpButton.h +++ b/Frameworks/PSMTabBar/PSMOverflowPopUpButton.h @@ -22,6 +22,14 @@ - (BOOL)animatingAlternateImage; - (void)setAnimatingAlternateImage:(BOOL)flag; +// Notifications +- (void)notificationReceived:(NSNotification *)notification; + +// Animations +- (void)setAnimatingAlternateImage:(BOOL)flag; +- (BOOL)animatingAlternateImage; +- (void)animateStep:(NSTimer *)timer; + // archiving - (void)encodeWithCoder:(NSCoder *)aCoder; - (id)initWithCoder:(NSCoder *)aDecoder; diff --git a/Frameworks/PSMTabBar/PSMOverflowPopUpButton.m b/Frameworks/PSMTabBar/PSMOverflowPopUpButton.m index cc96b910..8ce50464 100644 --- a/Frameworks/PSMTabBar/PSMOverflowPopUpButton.m +++ b/Frameworks/PSMTabBar/PSMOverflowPopUpButton.m @@ -16,7 +16,7 @@ - (id)initWithFrame:(NSRect)frameRect pullsDown:(BOOL)flag { - if (self = [super initWithFrame:frameRect pullsDown:YES]) { + if ((self = [super initWithFrame:frameRect pullsDown:YES])) { [self setBezelStyle:NSRegularSquareBezelStyle]; [self setBordered:NO]; [self setTitle:@""]; @@ -63,7 +63,7 @@ drawPoint.y += altImageSize.height; } - [[self alternateImage] compositeToPoint:drawPoint operation:NSCompositeSourceOver fraction:sin(_animationValue * M_PI)]; + [[self alternateImage] compositeToPoint:drawPoint operation:NSCompositeSourceOver fraction:sinf(_animationValue * (float)M_PI)]; } } diff --git a/Frameworks/PSMTabBar/PSMProgressIndicator.h b/Frameworks/PSMTabBar/PSMProgressIndicator.h index 8f56bd73..8c34e444 100644 --- a/Frameworks/PSMTabBar/PSMProgressIndicator.h +++ b/Frameworks/PSMTabBar/PSMProgressIndicator.h @@ -20,4 +20,4 @@ - (void)update; -@end
\ No newline at end of file +@end diff --git a/Frameworks/PSMTabBar/PSMRolloverButton.h b/Frameworks/PSMTabBar/PSMRolloverButton.h index d78b47c2..3c175119 100644 --- a/Frameworks/PSMTabBar/PSMRolloverButton.h +++ b/Frameworks/PSMTabBar/PSMRolloverButton.h @@ -24,6 +24,7 @@ - (NSImage *)rolloverImage; // tracking rect for mouse events +- (void)rolloverFrameDidChange:(NSNotification *)inNotification; - (void)addTrackingRect; - (void)removeTrackingRect; -@end
\ No newline at end of file +@end diff --git a/Frameworks/PSMTabBar/PSMTabBarCell.m b/Frameworks/PSMTabBar/PSMTabBarCell.m index 7ecaa183..809d9061 100644 --- a/Frameworks/PSMTabBar/PSMTabBarCell.m +++ b/Frameworks/PSMTabBar/PSMTabBarCell.m @@ -28,7 +28,7 @@ _cellTrackingTag = 0; _closeButtonOver = NO; _closeButtonPressed = NO; - _indicator = [[PSMProgressIndicator alloc] initWithFrame:NSMakeRect(0.0,0.0,kPSMTabBarIndicatorWidth,kPSMTabBarIndicatorWidth)]; + _indicator = [[PSMProgressIndicator alloc] initWithFrame:NSMakeRect(0.0f,0.0f,kPSMTabBarIndicatorWidth,kPSMTabBarIndicatorWidth)]; [_indicator setStyle:NSProgressIndicatorSpinningStyle]; [_indicator setAutoresizingMask:NSViewMinYMargin]; _hasCloseButton = YES; @@ -48,9 +48,9 @@ _isPlaceholder = YES; if (!value) { if ([controlView orientation] == PSMTabBarHorizontalOrientation) { - frame.size.width = 0.0; + frame.size.width = 0.0f; } else { - frame.size.height = 0.0; + frame.size.height = 0.0f; } } [self setFrame:frame]; @@ -348,7 +348,7 @@ { if (_isPlaceholder) { if (![_controlView usesSafariStyleDragging]) { - [[NSColor colorWithCalibratedWhite:0.0 alpha:0.2] set]; + [[NSColor colorWithCalibratedWhite:0.0f alpha:0.2f] set]; NSRectFillUsingOperation(cellFrame, NSCompositeSourceAtop); } return; @@ -373,7 +373,7 @@ // scrubtastic if ([_controlView allowsScrubbing] && ([theEvent modifierFlags] & NSAlternateKeyMask)) - [_controlView performSelector:@selector(tabClick:) withObject:self]; + [_controlView tabClick:self]; // tell the control we only need to redraw the affected tab [_controlView setNeedsDisplayInRect:NSInsetRect([self frame], -2, -2)]; @@ -410,7 +410,13 @@ // Draw the tab into a new image NSImage *image = [[[NSImage alloc] initWithSize:cellFrame.size] autorelease]; + +#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1060 + [image setFlipped:YES]; + [image lockFocus]; +#else [image lockFocusFlipped:YES]; +#endif [self setFrame:tabDrawFrame]; [(id <PSMTabStyle>)[(PSMTabBarControl *)_controlView style] drawTabCell:self]; [self setFrame:oldFrame]; @@ -418,12 +424,12 @@ // Add the indicator if appropriate if (![[self indicator] isHidden]) { - NSImage *pi = [[NSImage alloc] initByReferencingFile:[[PSMTabBarControl bundle] pathForImageResource:@"pi"]]; + NSImage *pieImage = [[NSImage alloc] initByReferencingFile:[[PSMTabBarControl bundle] pathForImageResource:@"pi"]]; [image lockFocus]; NSPoint indicatorPoint = NSMakePoint([self frame].size.width - MARGIN_X - kPSMTabBarIndicatorWidth, MARGIN_Y); - [pi compositeToPoint:indicatorPoint operation:NSCompositeSourceOver fraction:1.0]; + [pieImage compositeToPoint:indicatorPoint operation:NSCompositeSourceOver fraction:1.0f]; [image unlockFocus]; - [pi release]; + [pieImage release]; } return image; @@ -528,7 +534,7 @@ - (void)accessibilityPerformAction:(NSString *)action { if ([action isEqualToString:NSAccessibilityPressAction]) { // this tab was selected - [_controlView performSelector:@selector(tabClick:) withObject:self]; + [_controlView tabClick:self]; } } diff --git a/Frameworks/PSMTabBar/PSMTabBarControl.h b/Frameworks/PSMTabBar/PSMTabBarControl.h index 2ac8474a..cd2b5025 100644 --- a/Frameworks/PSMTabBar/PSMTabBarControl.h +++ b/Frameworks/PSMTabBar/PSMTabBarControl.h @@ -23,9 +23,9 @@ #define kPSMTabBarCellPadding 4 // fixed size objects #define kPSMMinimumTitleWidth 30 -#define kPSMTabBarIndicatorWidth 16.0 -#define kPSMTabBarIconWidth 16.0 -#define kPSMHideAnimationSteps 3.0 +#define kPSMTabBarIndicatorWidth 16.0f +#define kPSMTabBarIconWidth 16.0f +#define kPSMHideAnimationSteps 3.0f // Value used in _currentStep to indicate that resizing operation is not in progress #define kPSMIsNotBeingResized -1 @@ -185,9 +185,13 @@ enum { - (PSMRolloverButton *)addTabButton; - (PSMOverflowPopUpButton *)overflowPopUpButton; +// actions +- (void)tabClick:(id)sender; +- (void)overflowMenuAction:(id)sender; + // tab information - (NSMutableArray *)representedTabViewItems; -- (NSInteger)numberOfVisibleTabs; +- (NSUInteger)numberOfVisibleTabs; - (PSMTabBarCell *)lastVisibleTab; // special effects @@ -221,6 +225,7 @@ enum { - (BOOL)tabView:(NSTabView *)aTabView shouldAllowTabViewItem:(NSTabViewItem *)tabViewItem toLeaveTabBar:(PSMTabBarControl *)tabBarControl; - (void)tabView:(NSTabView*)aTabView didDropTabViewItem:(NSTabViewItem *)tabViewItem inTabBar:(PSMTabBarControl *)tabBarControl; - (void)draggingEvent:(id <NSDraggingInfo>)dragEvent enteredTabBar:(PSMTabBarControl *)tabBarControl tabView:(NSTabViewItem *)tabViewItem; +- (void)tabViewDragWindowCreated:(NSWindow *)dragWindow; //Tear-off tabs methods - (NSImage *)tabView:(NSTabView *)aTabView imageForTabViewItem:(NSTabViewItem *)tabViewItem offset:(NSSize *)offset styleMask:(NSUInteger *)styleMask; diff --git a/Frameworks/PSMTabBar/PSMTabBarControl.m b/Frameworks/PSMTabBar/PSMTabBarControl.m index 8debd774..231f3e3c 100644 --- a/Frameworks/PSMTabBar/PSMTabBarControl.m +++ b/Frameworks/PSMTabBar/PSMTabBarControl.m @@ -44,15 +44,14 @@ - (void)_checkWindowFrame; // actions -- (void)overflowMenuAction:(id)sender; - (void)closeTabClick:(id)sender; -- (void)tabClick:(id)sender; - (void)tabNothing:(id)sender; // notification handlers - (void)frameDidChange:(NSNotification *)notification; - (void)windowDidMove:(NSNotification *)aNotification; - (void)windowDidUpdate:(NSNotification *)notification; +- (void)windowStatusDidChange:(NSNotification *)notification; // NSTabView delegate - (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem; @@ -68,6 +67,8 @@ - (void)_bindPropertiesForCell:(PSMTabBarCell *)cell andTabViewItem:(NSTabViewItem *)item; - (id)cellForPoint:(NSPoint)point cellFrame:(NSRectPointer)outFrame; +- (void)fireSpring:(NSTimer *)timer; +- (void)animateShowHide:(NSTimer *)timer; - (void)_animateCells:(NSTimer *)timer; @end @@ -105,7 +106,7 @@ { NSRect aRect=[self frame]; aRect.origin.x = [style leftMarginForTabBarControl]; - aRect.origin.y = 0.0; + aRect.origin.y = 0.0f; aRect.size.width = [self availableCellWidth]; aRect.size.height = [style tabCellHeight]; return aRect; @@ -153,7 +154,7 @@ [self _positionOverflowMenu]; // new tab button - NSRect addTabButtonRect = NSMakeRect([self frame].size.width - [style rightMarginForTabBarControl] + 1, 3.0, 16.0, 16.0); + NSRect addTabButtonRect = NSMakeRect([self frame].size.width - [style rightMarginForTabBarControl] + 1, 3.0f, 16.0f, 16.0f); _addTabButton = [[PSMRolloverButton alloc] initWithFrame:addTabButtonRect]; if (_addTabButton) { NSImage *newButtonImage = [style addTabButtonImage]; @@ -682,7 +683,7 @@ // add to collection [_cells addObject:cell]; [cell release]; - if ([_cells count] == [tabView numberOfTabViewItems]) { + if ((NSInteger)[_cells count] == [tabView numberOfTabViewItems]) { [self update]; // don't update unless all are accounted for! } } @@ -714,7 +715,7 @@ } if ([item identifier] != nil) { - if ([[item identifier] respondsToSelector:@selector(objectCount)]) { + if ([[item identifier] respondsToSelector:@selector(count)]) { [[item identifier] removeObserver:cell forKeyPath:@"objectCount"]; } } @@ -947,10 +948,10 @@ // moves the frame of the tab bar and window (or partner view) linearly to hide or show the tab bar NSRect myFrame = [self frame]; NSDictionary *userInfo = [timer userInfo]; - CGFloat myCurrentOrigin = ([[userInfo objectForKey:@"myOriginalOrigin"] doubleValue] + (([[userInfo objectForKey:@"myTargetOrigin"] doubleValue] - [[userInfo objectForKey:@"myOriginalOrigin"] doubleValue]) * (_currentStep/kPSMHideAnimationSteps))); - CGFloat myCurrentSize = ([[userInfo objectForKey:@"myOriginalSize"] doubleValue] + (([[userInfo objectForKey:@"myTargetSize"] doubleValue] - [[userInfo objectForKey:@"myOriginalSize"] doubleValue]) * (_currentStep/kPSMHideAnimationSteps))); - CGFloat partnerCurrentOrigin = ([[userInfo objectForKey:@"partnerOriginalOrigin"] doubleValue] + (([[userInfo objectForKey:@"partnerTargetOrigin"] doubleValue] - [[userInfo objectForKey:@"partnerOriginalOrigin"] doubleValue]) * (_currentStep/kPSMHideAnimationSteps))); - CGFloat partnerCurrentSize = ([[userInfo objectForKey:@"partnerOriginalSize"] doubleValue] + (([[userInfo objectForKey:@"partnerTargetSize"] doubleValue] - [[userInfo objectForKey:@"partnerOriginalSize"] doubleValue]) * (_currentStep/kPSMHideAnimationSteps))); + CGFloat myCurrentOrigin = ([[userInfo objectForKey:@"myOriginalOrigin"] floatValue] + (([[userInfo objectForKey:@"myTargetOrigin"] floatValue] - [[userInfo objectForKey:@"myOriginalOrigin"] floatValue]) * (_currentStep/kPSMHideAnimationSteps))); + CGFloat myCurrentSize = ([[userInfo objectForKey:@"myOriginalSize"] floatValue] + (([[userInfo objectForKey:@"myTargetSize"] floatValue] - [[userInfo objectForKey:@"myOriginalSize"] floatValue]) * (_currentStep/kPSMHideAnimationSteps))); + CGFloat partnerCurrentOrigin = ([[userInfo objectForKey:@"partnerOriginalOrigin"] floatValue] + (([[userInfo objectForKey:@"partnerTargetOrigin"] floatValue] - [[userInfo objectForKey:@"partnerOriginalOrigin"] floatValue]) * (_currentStep/kPSMHideAnimationSteps))); + CGFloat partnerCurrentSize = ([[userInfo objectForKey:@"partnerOriginalSize"] floatValue] + (([[userInfo objectForKey:@"partnerTargetSize"] floatValue] - [[userInfo objectForKey:@"partnerOriginalSize"] floatValue]) * (_currentStep/kPSMHideAnimationSteps))); NSRect myNewFrame; if ([self orientation] == PSMTabBarHorizontalOrientation) { @@ -1053,7 +1054,7 @@ { // make sure all of our tabs are accounted for before updating, // or only proceed if a drag is in progress (where counts may mismatch) - if ([[self tabView] numberOfTabViewItems] != [_cells count] && ![[PSMTabDragAssistant sharedDragAssistant] isDragging]) { + if ([[self tabView] numberOfTabViewItems] != (NSInteger)[_cells count] && ![[PSMTabDragAssistant sharedDragAssistant] isDragging]) { return; } @@ -1082,7 +1083,7 @@ if (animate) { NSMutableArray *targetFrames = [NSMutableArray arrayWithCapacity:[_cells count]]; - for (NSInteger i = 0; i < [_cells count]; i++) { + for (NSUInteger i = 0; i < [_cells count]; i++) { currentCell = [_cells objectAtIndex:i]; //we're going from NSRect -> NSValue -> NSRect -> NSValue here - oh well @@ -1104,7 +1105,7 @@ [self _animateCells:_animationTimer]; } else { - for (NSInteger i = 0; i < [_cells count]; i++) { + for (NSUInteger i = 0; i < [_cells count]; i++) { currentCell = [_cells objectAtIndex:i]; [currentCell setFrame:[_controller cellFrameAtIndex:i]]; @@ -1124,11 +1125,11 @@ NSAnimation *animation = [[timer userInfo] objectAtIndex:1]; NSArray *targetFrames = [[timer userInfo] objectAtIndex:0]; PSMTabBarCell *currentCell; - NSInteger cellCount = [_cells count]; + NSUInteger cellCount = (NSUInteger)[_cells count]; if ((cellCount > 0) && [animation isAnimating]) { //compare our target position with the current position and move towards the target - for (NSInteger i = 0; i < [targetFrames count] && i < cellCount; i++) { + for (NSUInteger i = 0; i < [targetFrames count] && i < cellCount; i++) { currentCell = [_cells objectAtIndex:i]; NSRect cellFrame = [currentCell frame], targetFrame = [[targetFrames objectAtIndex:i] rectValue]; CGFloat sizeChange; @@ -1164,8 +1165,8 @@ } else { //put all the cells where they should be in their final position if (cellCount > 0) { - for (NSInteger i = 0; i < [targetFrames count] && i < cellCount; i++) { - PSMTabBarCell *currentCell = [_cells objectAtIndex:i]; + for (NSUInteger i = 0; i < [targetFrames count] && i < cellCount; i++) { + currentCell = [_cells objectAtIndex:i]; NSRect cellFrame = [currentCell frame], targetFrame = [[targetFrames objectAtIndex:i] rectValue]; if ([self orientation] == PSMTabBarHorizontalOrientation) { @@ -1196,7 +1197,7 @@ [_animationTimer invalidate]; [_animationTimer release]; _animationTimer = nil; - for (NSInteger i = 0; i < cellCount; i++) { + for (NSUInteger i = 0; i < cellCount; i++) { currentCell = [_cells objectAtIndex:i]; //we've hit the cells that are in overflow, stop setting up tracking rects @@ -1217,8 +1218,9 @@ // Skip tracking rects for placeholders - not required. if ([cell isPlaceholder]) return; - NSInteger tag, index = [_cells indexOfObject:cell]; - NSRect cellTrackingRect = [_controller cellTrackingRectAtIndex:index]; + NSInteger tag; + NSUInteger anIndex = [_cells indexOfObject:cell]; + NSRect cellTrackingRect = [_controller cellTrackingRectAtIndex:anIndex]; NSPoint mousePoint = [self convertPoint:[[self window] mouseLocationOutsideOfEventStream] fromView:nil]; BOOL mouseInCell = NSMouseInRect(mousePoint, cellTrackingRect, [self isFlipped]); @@ -1232,7 +1234,7 @@ [cell setHighlighted:mouseInCell]; if ([cell hasCloseButton] && ![cell isCloseButtonSuppressed]) { - NSRect closeRect = [_controller closeButtonTrackingRectAtIndex:index]; + NSRect closeRect = [_controller closeButtonTrackingRectAtIndex:anIndex]; BOOL mouseInCloseRect = NSMouseInRect(mousePoint, closeRect, [self isFlipped]); //set the close button tracking rect @@ -1390,9 +1392,9 @@ return; } - CGFloat dx = fabs(currentPoint.x - trackingStartPoint.x); - CGFloat dy = fabs(currentPoint.y - trackingStartPoint.y); - CGFloat distance = sqrt(dx * dx + dy * dy); + CGFloat dx = fabsf(currentPoint.x - trackingStartPoint.x); + CGFloat dy = fabsf(currentPoint.y - trackingStartPoint.y); + CGFloat distance = sqrtf(dx * dx + dy * dy); if (distance >= 10 && !_didDrag && ![[PSMTabDragAssistant sharedDragAssistant] isDragging] && [self delegate] && [[self delegate] respondsToSelector:@selector(tabView:shouldDragTabViewItem:fromTabBar:)] && @@ -1815,7 +1817,7 @@ // message, thus I can end up updating when there are no cells, if no tabs were (yet) present NSInteger tabIndex = [aTabView indexOfTabViewItem:tabViewItem]; - if ([_cells count] > 0 && tabIndex < [_cells count]) { + if ([_cells count] > 0 && tabIndex < (NSInteger)[_cells count]) { PSMTabBarCell *thisCell = [_cells objectAtIndex:tabIndex]; if (_alwaysShowActiveTab && [thisCell isInOverflowMenu]) { @@ -2002,12 +2004,12 @@ - (NSSize)minimumFrameSizeFromKnobPosition:(NSInteger)position { - return NSMakeSize(100.0, 22.0); + return NSMakeSize(100.0f, 22.0f); } - (NSSize)maximumFrameSizeFromKnobPosition:(NSInteger)knobPosition { - return NSMakeSize(10000.0, 22.0); + return NSMakeSize(10000.0f, 22.0f); } - (void)placeView:(NSRect)newFrame @@ -2056,7 +2058,7 @@ // bind for the existence of a counter [cell setCount:0]; if ([item identifier] != nil) { - if ([[[cell representedObject] identifier] respondsToSelector:@selector(objectCount)]) { + if ([[[cell representedObject] identifier] respondsToSelector:@selector(count)]) { [cell bind:@"count" toObject:[item identifier] withKeyPath:@"objectCount" options:nil]; [[item identifier] addObserver:cell forKeyPath:@"objectCount" options:0 context:nil]; } @@ -2138,9 +2140,9 @@ return [_cells objectAtIndex:(cellCount - 1)]; } -- (NSInteger)numberOfVisibleTabs +- (NSUInteger)numberOfVisibleTabs { - NSInteger i, cellCount = 0; + NSUInteger i, cellCount = 0; PSMTabBarCell *nextCell; for (i = 0; i < [_cells count]; i++) { diff --git a/Frameworks/PSMTabBar/PSMTabBarController.h b/Frameworks/PSMTabBar/PSMTabBarController.h index c675b981..3f8b4787 100644 --- a/Frameworks/PSMTabBar/PSMTabBarController.h +++ b/Frameworks/PSMTabBar/PSMTabBarController.h @@ -22,12 +22,22 @@ - (NSRect)addButtonRect; - (NSMenu *)overflowMenu; -- (NSRect)cellTrackingRectAtIndex:(NSInteger)index; -- (NSRect)closeButtonTrackingRectAtIndex:(NSInteger)index; -- (NSRect)cellFrameAtIndex:(NSInteger)index; +- (NSRect)cellTrackingRectAtIndex:(NSUInteger)anIndex; +- (NSRect)closeButtonTrackingRectAtIndex:(NSUInteger)anIndex; +- (NSRect)cellFrameAtIndex:(NSUInteger)anIndex; - (void)setSelectedCell:(PSMTabBarCell *)cell; - (void)layoutCells; @end + +@interface NSObject (TabRepresentedObjectIdentifierMethods) + +// Method for generating a tooltip for a tab +- (NSString *)tabTitleForTooltip; + +// Retrieving whether a tab is working +- (BOOL)isProcessing; + +@end diff --git a/Frameworks/PSMTabBar/PSMTabBarController.m b/Frameworks/PSMTabBar/PSMTabBarController.m index 04e1ec69..4ab2c1ef 100644 --- a/Frameworks/PSMTabBar/PSMTabBarController.m +++ b/Frameworks/PSMTabBar/PSMTabBarController.m @@ -83,13 +83,13 @@ @returns The tracking rect of the cell at the requested index. */ -- (NSRect)cellTrackingRectAtIndex:(NSInteger)index +- (NSRect)cellTrackingRectAtIndex:(NSUInteger)anIndex { NSRect rect; - if (index > -1 && index < [_cellTrackingRects count]) { - rect = [[_cellTrackingRects objectAtIndex:index] rectValue]; + if (anIndex < [_cellTrackingRects count]) { + rect = [[_cellTrackingRects objectAtIndex:anIndex] rectValue]; } else { - NSLog(@"cellTrackingRectAtIndex: Invalid index (%ld)", (long)index); + NSLog(@"cellTrackingRectAtIndex: Invalid index (%lu)", (unsigned long)anIndex); rect = NSZeroRect; } return rect; @@ -103,13 +103,13 @@ @returns The close button tracking rect of the cell at the requested index. */ -- (NSRect)closeButtonTrackingRectAtIndex:(NSInteger)index +- (NSRect)closeButtonTrackingRectAtIndex:(NSUInteger)anIndex { NSRect rect; - if (index > -1 && index < [_closeButtonTrackingRects count]) { - rect = [[_closeButtonTrackingRects objectAtIndex:index] rectValue]; + if (anIndex < [_closeButtonTrackingRects count]) { + rect = [[_closeButtonTrackingRects objectAtIndex:anIndex] rectValue]; } else { - NSLog(@"closeButtonTrackingRectAtIndex: Invalid index (%ld)", (long)index); + NSLog(@"closeButtonTrackingRectAtIndex: Invalid index (%lu)", (unsigned long)anIndex); rect = NSZeroRect; } return rect; @@ -123,14 +123,14 @@ @returns The frame of the cell at the requested index. */ -- (NSRect)cellFrameAtIndex:(NSInteger)index +- (NSRect)cellFrameAtIndex:(NSUInteger)anIndex { NSRect rect; - if (index > -1 && index < [_cellFrames count]) { - rect = [[_cellFrames objectAtIndex:index] rectValue]; + if (anIndex < [_cellFrames count]) { + rect = [[_cellFrames objectAtIndex:anIndex] rectValue]; } else { - NSLog(@"cellFrameAtIndex: Invalid index (%ld)", (long)index); + NSLog(@"cellFrameAtIndex: Invalid index (%lu)", (unsigned long)anIndex); rect = NSZeroRect; } return rect; @@ -169,7 +169,7 @@ [cell setTabState:PSMTab_SelectedMask]; if (![cell isInOverflowMenu]) { - NSInteger cellIndex = [cells indexOfObject:cell]; + NSUInteger cellIndex = [cells indexOfObject:cell]; if (cellIndex > 0) { nextCell = [cells objectAtIndex:cellIndex - 1]; @@ -214,10 +214,10 @@ _addButtonRect.size = [[_control addTabButton] frame].size; if ([_control orientation] == PSMTabBarHorizontalOrientation) { _addButtonRect.origin.y = MARGIN_Y; - _addButtonRect.origin.x += [[cellWidths valueForKeyPath:@"@sum.floatValue"] doubleValue] + MARGIN_X; + _addButtonRect.origin.x += [[cellWidths valueForKeyPath:@"@sum.floatValue"] floatValue] + MARGIN_X; } else { _addButtonRect.origin.x = 0; - _addButtonRect.origin.y = [[cellWidths lastObject] doubleValue]; + _addButtonRect.origin.y = [[cellWidths lastObject] floatValue]; } } @@ -241,7 +241,7 @@ NSInteger q = 0; for (q = (count - 1); q >= 0; q--) { - CGFloat cellWidth = [[newWidths objectAtIndex:q] doubleValue]; + CGFloat cellWidth = [[newWidths objectAtIndex:q] floatValue]; if (cellWidth - 1 >= minimum) { cellWidth--; totalWidths--; @@ -296,7 +296,7 @@ static NSInteger potentialMinimumForArray(NSArray *array, NSInteger minimum) NSInteger cellCount = [cells count], i, numberOfVisibleCells = ([_control orientation] == PSMTabBarHorizontalOrientation) ? 1 : 0; NSMutableArray *newWidths = [NSMutableArray arrayWithCapacity:cellCount]; id <PSMTabStyle> style = [_control style]; - CGFloat availableWidth = [_control availableCellWidth], currentOrigin = 0, totalOccupiedWidth = 0.0, width; + CGFloat availableWidth = [_control availableCellWidth], currentOrigin = 0, totalOccupiedWidth = 0.0f, width; NSRect cellRect = [_control genericCellRect], controlRect = [_control frame]; PSMTabBarCell *currentCell; @@ -329,7 +329,7 @@ static NSInteger potentialMinimumForArray(NSArray *array, NSInteger minimum) width = [_control cellOptimumWidth]; } - width = ceil(width); + width = ceilf(width); //check to see if there is not enough space to place all tabs as preferred if (totalOccupiedWidth + width >= availableWidth) { @@ -498,11 +498,11 @@ static NSInteger potentialMinimumForArray(NSArray *array, NSInteger minimum) cellWidth = [NSNumber numberWithDouble:[cell1 desiredWidthOfCell] < availableWidth * 0.5f ? [cell1 desiredWidthOfCell] : availableWidth * 0.5f]; [newWidths addObject:cellWidth]; - totalOccupiedWidth += [cellWidth doubleValue]; + totalOccupiedWidth += [cellWidth floatValue]; cellWidth = [NSNumber numberWithDouble:[cell2 desiredWidthOfCell] < (availableWidth - totalOccupiedWidth) ? [cell2 desiredWidthOfCell] : (availableWidth - totalOccupiedWidth)]; [newWidths addObject:cellWidth]; - totalOccupiedWidth += [cellWidth doubleValue]; + totalOccupiedWidth += [cellWidth floatValue]; if (totalOccupiedWidth < availableWidth) { [newWidths replaceObjectAtIndex:0 withObject:[NSNumber numberWithDouble:availableWidth - [cellWidth doubleValue]]]; @@ -523,7 +523,7 @@ static NSInteger potentialMinimumForArray(NSArray *array, NSInteger minimum) - (void)_setupCells:(NSArray *)cells withWidths:(NSArray *)widths { - NSInteger i, tabState, cellCount = [cells count]; + NSUInteger i, tabState, cellCount = [cells count]; NSRect cellRect = [_control genericCellRect]; PSMTabBarCell *cell; NSTabViewItem *selectedTabViewItem = [[_control tabView] selectedTabViewItem]; @@ -539,10 +539,10 @@ static NSInteger potentialMinimumForArray(NSArray *array, NSInteger minimum) // set cell frame if ([_control orientation] == PSMTabBarHorizontalOrientation) { - cellRect.size.width = [[widths objectAtIndex:i] doubleValue]; + cellRect.size.width = [[widths objectAtIndex:i] floatValue]; } else { cellRect.size.width = [_control frame].size.width; - cellRect.origin.y = [[widths objectAtIndex:i] doubleValue]; + cellRect.origin.y = [[widths objectAtIndex:i] floatValue]; cellRect.origin.x = 0; } @@ -589,7 +589,7 @@ static NSInteger potentialMinimumForArray(NSArray *array, NSInteger minimum) } // next... - cellRect.origin.x += [[widths objectAtIndex:i] doubleValue]; + cellRect.origin.x += [[widths objectAtIndex:i] floatValue]; } else { [cell setState:NSOffState]; [cell setIsInOverflowMenu:YES]; @@ -625,7 +625,7 @@ static NSInteger potentialMinimumForArray(NSArray *array, NSInteger minimum) } } -- (BOOL)menu:(NSMenu *)menu updateItem:(NSMenuItem *)menuItem atIndex:(NSInteger)index shouldCancel:(BOOL)shouldCancel +- (BOOL)menu:(NSMenu *)menu updateItem:(NSMenuItem *)menuItem atIndex:(NSInteger)anIndex shouldCancel:(BOOL)shouldCancel { if (menu == _overflowMenu) { if ([[[menuItem representedObject] identifier] respondsToSelector:@selector(icon)]) { diff --git a/Frameworks/PSMTabBar/PSMTabDragAssistant.h b/Frameworks/PSMTabBar/PSMTabDragAssistant.h index 2f42c573..92a8d4d8 100644 --- a/Frameworks/PSMTabBar/PSMTabDragAssistant.h +++ b/Frameworks/PSMTabBar/PSMTabDragAssistant.h @@ -70,6 +70,9 @@ - (void)draggingBeganAt:(NSPoint)aPoint; - (void)draggingMovedTo:(NSPoint)aPoint; +- (void)fadeInDragWindow:(NSTimer *)timer; +- (void)fadeOutDragWindow:(NSTimer *)timer; + // Animation - (void)animateDrag:(NSTimer *)timer; - (void)calculateDragAnimationForTabBar:(PSMTabBarControl *)control; @@ -88,7 +91,7 @@ - (void)setControlView:(id)view; - (id)cellForPoint:(NSPoint)point cellFrame:(NSRectPointer)outFrame; - (PSMTabBarCell *)lastVisibleTab; -- (NSInteger)numberOfVisibleTabs; +- (NSUInteger)numberOfVisibleTabs; @end diff --git a/Frameworks/PSMTabBar/PSMTabDragAssistant.m b/Frameworks/PSMTabBar/PSMTabDragAssistant.m index 2b670b67..5d5b7fcc 100644 --- a/Frameworks/PSMTabBar/PSMTabDragAssistant.m +++ b/Frameworks/PSMTabBar/PSMTabDragAssistant.m @@ -21,6 +21,7 @@ - (NSImage *)_imageForViewOfCell:(PSMTabBarCell *)cell styleMask:(NSUInteger *)outMask; - (NSImage *)_miniwindowImageOfWindow:(NSWindow *)window; - (void)_expandWindow:(NSWindow *)window atPoint:(NSPoint)point; +- (void)_expandWindowTimerFired:(NSTimer *)timer; @end @implementation PSMTabDragAssistant @@ -284,7 +285,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; } [self setDestinationTabBar:nil]; - [self setCurrentMouseLoc:NSMakePoint(-1.0, -1.0)]; + [self setCurrentMouseLoc:NSMakePoint(-1.0f, -1.0f)]; if (_fadeTimer) { [_fadeTimer invalidate]; @@ -297,7 +298,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; NSImage *viewImage = [self _imageForViewOfCell:[self draggedCell] styleMask:&styleMask]; _draggedView = [[PSMTabDragWindowController alloc] initWithImage:viewImage styleMask:styleMask tearOffStyle:PSMTabBarTearOffAlphaWindow initialAlpha:[control usesSafariStyleDragging]?1:kPSMTabDragWindowAlpha]; - [[_draggedView window] setAlphaValue:0.0]; + [[_draggedView window] setAlphaValue:0.0f]; // Inform the delegate a new drag window was created to allow any changes if ([control delegate] && [[control delegate] respondsToSelector:@selector(tabViewDragWindowCreated:)]) { @@ -335,12 +336,13 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; //don't fade out the old window if the delegate doesn't respond to the new tab bar method, just to be safe if ([[[self sourceTabBar] tabView] numberOfTabViewItems] == 1 && [self sourceTabBar] == control && [[[self sourceTabBar] delegate] respondsToSelector:@selector(tabView:newTabBarForDraggedTabViewItem:atPoint:)]) { - [[[self sourceTabBar] window] setAlphaValue:0.0]; + [[[self sourceTabBar] window] setAlphaValue:0.0f]; if ([_sourceTabBar tearOffStyle] == PSMTabBarTearOffAlphaWindow) { [[_draggedView window] setAlphaValue:kPSMTabDragWindowAlpha]; } else { - #warning fix me - what should we do when the last tab is dragged as a miniwindow? + [_draggedTab switchImages]; + _centersDragWindows = YES; } } else { if ([_sourceTabBar tearOffStyle] == PSMTabBarTearOffAlphaWindow) { @@ -356,7 +358,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; - (void)performDragOperation { // move cell - NSInteger destinationIndex = [[[self destinationTabBar] cells] indexOfObject:[self targetCell]]; + NSUInteger destinationIndex = [[[self destinationTabBar] cells] indexOfObject:[self targetCell]]; //there is the slight possibility of the targetCell now being set properly, so avoid errors if (destinationIndex >= [[[self destinationTabBar] cells] count]) { @@ -374,7 +376,8 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; [[self sourceTabBar] removeTrackingRect:[[self draggedCell] cellTrackingTag]]; [[self sourceTabBar] removeTabForCell:[self draggedCell]]; - NSInteger i, insertIndex; + NSUInteger i; + NSInteger insertIndex; NSArray *cells = [[self destinationTabBar] cells]; //find the index of where the dragged cell was just dropped @@ -409,25 +412,25 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; NSTabView *tabView = [[self sourceTabBar] tabView]; NSTabViewItem *item = [[self draggedCell] representedObject]; BOOL reselect = ([tabView selectedTabViewItem] == item); - NSInteger index; + NSUInteger anIndex; NSArray *cells = [[self sourceTabBar] cells]; //find the index of where the dragged cell was just dropped - for (index = 0; index < [cells count] && [cells objectAtIndex:index] != [self draggedCell]; index++); + for (anIndex = 0; anIndex < [cells count] && [cells objectAtIndex:anIndex] != [self draggedCell]; anIndex++); //temporarily disable the delegate in order to move the tab to a different index id tempDelegate = [tabView delegate]; [tabView setDelegate:nil]; [item retain]; [tabView removeTabViewItem:item]; - [tabView insertTabViewItem:item atIndex:index]; + [tabView insertTabViewItem:item atIndex:anIndex]; if (reselect) { [tabView selectTabViewItem:item]; } [tabView setDelegate:tempDelegate]; } - if (([self sourceTabBar] != [self destinationTabBar] || [[[self sourceTabBar] cells] indexOfObject:[self draggedCell]] != _draggedCellIndex) && [[[self sourceTabBar] delegate] respondsToSelector:@selector(tabView:didDropTabViewItem:inTabBar:)]) { + if (([self sourceTabBar] != [self destinationTabBar] || (NSInteger)[[[self sourceTabBar] cells] indexOfObject:[self draggedCell]] != _draggedCellIndex) && [[[self sourceTabBar] delegate] respondsToSelector:@selector(tabView:didDropTabViewItem:inTabBar:)]) { [[[self sourceTabBar] delegate] tabView:[[self sourceTabBar] tabView] didDropTabViewItem:[[self draggedCell] representedObject] inTabBar:[self destinationTabBar]]; } @@ -504,7 +507,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; // Restore the window alpha if appropriate if ([[[self sourceTabBar] tabView] numberOfTabViewItems]) { - [[[self sourceTabBar] window] setAlphaValue:1.0]; + [[[self sourceTabBar] window] setAlphaValue:1.0f]; } } @@ -562,7 +565,9 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; if ([[[self sourceTabBar] tabView] numberOfTabViewItems] == 1) { [self draggingExitedTabBar:[self sourceTabBar]]; - [[_draggedTab window] setAlphaValue:0.0]; + if ([_sourceTabBar tearOffStyle] == PSMTabBarTearOffAlphaWindow) { + [[_draggedTab window] setAlphaValue:0.0f]; + } } } } @@ -633,7 +638,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; float tabWindowAlphaValue = [[self destinationTabBar] usesSafariStyleDragging]?1:kPSMTabDragWindowAlpha; if (value <= 0.0) { - [viewWindow setAlphaValue:0.0]; + [viewWindow setAlphaValue:0.0f]; [tabWindow setAlphaValue:tabWindowAlphaValue]; [timer invalidate]; @@ -711,12 +716,12 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; { NSRect frame = [window frame]; [window setFrameTopLeftPoint:NSMakePoint(point.x - frame.size.width / 2, point.y + frame.size.height / 2)]; - [window setAlphaValue:0.0]; + [window setAlphaValue:0.0f]; [window makeKeyAndOrderFront:nil]; NSAnimation *animation = [[NSAnimation alloc] initWithDuration:0.25 animationCurve:NSAnimationEaseInOut]; [animation setAnimationBlockingMode:NSAnimationNonblocking]; - [animation setCurrentProgress:0.1]; + [animation setCurrentProgress:0.1f]; [animation startAnimation]; NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:1.0 / 30.0 target:self selector:@selector(_expandWindowTimerFired:) userInfo:[NSDictionary dictionaryWithObjectsAndKeys:window, @"Window", animation, @"Animation", nil] repeats:YES]; [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSEventTrackingRunLoopMode]; @@ -730,10 +735,10 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; NSPoint translation; NSRect winFrame = [window frame]; - translation.x = (winFrame.size.width / 2.0); - translation.y = (winFrame.size.height / 2.0); + translation.x = (winFrame.size.width / 2.0f); + translation.y = (winFrame.size.height / 2.0f); transform = CGAffineTransformMakeTranslation(translation.x, translation.y); - transform = CGAffineTransformScale(transform, 1.0 / [animation currentValue], 1.0 / [animation currentValue]); + transform = CGAffineTransformScale(transform, 1.0f / [animation currentValue], 1.0f / [animation currentValue]); transform = CGAffineTransformTranslate(transform, -translation.x, -translation.y); translation.x = -winFrame.origin.x; @@ -781,8 +786,8 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; NSRect controlWindowFrame = [[control window] contentRectForFrameRect:[[control window] frame]]; NSPoint tabTopLeftInWindowCoords = NSMakePoint(draggedTabWindowFrame.origin.x - controlWindowFrame.origin.x, controlWindowFrame.origin.y + (2*controlWindowFrame.size.height) - draggedTabWindowFrame.origin.y); targetPoint = [control convertPoint:tabTopLeftInWindowCoords fromView:nil]; - targetPoint.x += (draggedTabWindowFrame.size.width / 2.0); - targetPoint.y = 0 - (draggedTabWindowFrame.size.height / 2.0) - targetPoint.y; + targetPoint.x += (draggedTabWindowFrame.size.width / 2.0f); + targetPoint.y = 0 - (draggedTabWindowFrame.size.height / 2.0f) - targetPoint.y; } else { targetPoint = [self currentMouseLoc]; } @@ -926,7 +931,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; - (void)distributePlaceholdersInTabBar:(PSMTabBarControl *)control { - NSInteger i, numVisibleTabs = [control numberOfVisibleTabs]; + NSUInteger i, numVisibleTabs = [control numberOfVisibleTabs]; for (i = 0; i < numVisibleTabs; i++) { PSMTabBarCell *pc = [[[PSMTabBarCell alloc] initPlaceholderWithFrame:[[self draggedCell] frame] expanded:NO inControlView:control] autorelease]; [[control cells] insertObject:pc atIndex:(2 * i)]; diff --git a/Frameworks/PSMTabBar/PSMTabDragView.m b/Frameworks/PSMTabBar/PSMTabDragView.m index 259116ae..5be56b10 100644 --- a/Frameworks/PSMTabBar/PSMTabDragView.m +++ b/Frameworks/PSMTabBar/PSMTabDragView.m @@ -13,7 +13,7 @@ - (id)initWithFrame:(NSRect)frame { if ( (self = [super initWithFrame:frame]) ) { - _alpha = 1.0; + _alpha = 1.0f; } return self; } diff --git a/Frameworks/PSMTabBar/PSMTabDragWindowController.h b/Frameworks/PSMTabBar/PSMTabDragWindowController.h index babfb1a7..380a2bab 100644 --- a/Frameworks/PSMTabBar/PSMTabDragWindowController.h +++ b/Frameworks/PSMTabBar/PSMTabDragWindowController.h @@ -9,8 +9,8 @@ #import <Cocoa/Cocoa.h> #import "PSMTabBarControl.h" -#define kPSMTabDragWindowAlpha 0.75 -#define kPSMTabDragAlphaInterval 0.15 +#define kPSMTabDragWindowAlpha 0.75f +#define kPSMTabDragAlphaInterval 0.15f @class PSMTabDragView; @@ -30,4 +30,5 @@ - (void)setAlternateImage:(NSImage *)image; - (BOOL)isAnimating; - (void)switchImages; +- (void)animateTimer:(NSTimer *)timer; @end diff --git a/Frameworks/PSMTabBar/Styles/PSMSequelProTabStyle.m b/Frameworks/PSMTabBar/Styles/PSMSequelProTabStyle.m index 48db93c3..ece10a76 100644 --- a/Frameworks/PSMTabBar/Styles/PSMSequelProTabStyle.m +++ b/Frameworks/PSMTabBar/Styles/PSMSequelProTabStyle.m @@ -28,9 +28,9 @@ #import "NSBezierPath_AMShading.h" #import "PSMTabDragAssistant.h" -#define kPSMSequelProObjectCounterRadius 7.0 +#define kPSMSequelProObjectCounterRadius 7.0f #define kPSMSequelProCounterMinWidth 20 -#define kPSMSequelProTabCornerRadius 4.5 +#define kPSMSequelProTabCornerRadius 4.5f #define MARGIN_X 6 @implementation PSMSequelProTabStyle @@ -58,8 +58,8 @@ _addTabButtonPressedImage = [[NSImage alloc] initByReferencingFile:[[PSMTabBarControl bundle] pathForImageResource:@"AddTabButtonPushed"]]; _addTabButtonRolloverImage = [[NSImage alloc] initByReferencingFile:[[PSMTabBarControl bundle] pathForImageResource:@"AddTabButtonRollover"]]; - _objectCountStringAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:[[NSFontManager sharedFontManager] convertFont:[NSFont fontWithName:@"Helvetica" size:11.0] toHaveTrait:NSBoldFontMask], NSFontAttributeName, - [[NSColor whiteColor] colorWithAlphaComponent:0.85], NSForegroundColorAttributeName, + _objectCountStringAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:[[NSFontManager sharedFontManager] convertFont:[NSFont fontWithName:@"Helvetica" size:11.0f] toHaveTrait:NSBoldFontMask], NSFontAttributeName, + [[NSColor whiteColor] colorWithAlphaComponent:0.85f], NSForegroundColorAttributeName, nil, nil]; } return self; @@ -134,13 +134,13 @@ if ([cell tabState] & PSMTab_SelectedMask) { if (tabOrientation == PSMTabBarHorizontalOrientation) { - dragRect.origin.x -= 5.0; - dragRect.size.width += 10.0; + dragRect.origin.x -= 5.0f; + dragRect.size.width += 10.0f; } else { - dragRect.size.height += 1.0; - dragRect.origin.y -= 1.0; - dragRect.origin.x += 2.0; - dragRect.size.width -= 3.0; + dragRect.size.height += 1.0f; + dragRect.origin.y -= 1.0f; + dragRect.origin.x += 2.0f; + dragRect.size.width -= 3.0f; } } else if (tabOrientation == PSMTabBarVerticalOrientation) { dragRect.origin.x--; @@ -158,7 +158,7 @@ NSRect result; result.size = [sequelProCloseButton size]; result.origin.x = cellFrame.origin.x + MARGIN_X; - result.origin.y = cellFrame.origin.y + MARGIN_Y + 2.0; + result.origin.y = cellFrame.origin.y + MARGIN_Y + 2.0f; return result; } @@ -208,7 +208,7 @@ } CGFloat countWidth = [[self attributedObjectCountValueForTabCell:cell] size].width; - countWidth += (2 * kPSMSequelProObjectCounterRadius - 6.0); + countWidth += (2 * kPSMSequelProObjectCounterRadius - 6.0f); if (countWidth < kPSMSequelProCounterMinWidth) { countWidth = kPSMSequelProCounterMinWidth; } @@ -216,7 +216,7 @@ NSRect result; result.size = NSMakeSize(countWidth, 2 * kPSMSequelProObjectCounterRadius); // temp result.origin.x = cellFrame.origin.x + cellFrame.size.width - MARGIN_X - result.size.width; - result.origin.y = cellFrame.origin.y + MARGIN_Y + 1.0; + result.origin.y = cellFrame.origin.y + MARGIN_Y + 1.0f; if (![[cell indicator] isHidden]) { result.origin.x -= kPSMTabBarIndicatorWidth + kPSMTabBarCellPadding; @@ -228,7 +228,7 @@ - (CGFloat)minimumWidthOfTabCell:(PSMTabBarCell *)cell { - CGFloat resultWidth = 0.0; + CGFloat resultWidth = 0.0f; // left margin resultWidth = MARGIN_X; @@ -258,12 +258,12 @@ // right margin resultWidth += MARGIN_X; - return ceil(resultWidth); + return ceilf(resultWidth); } - (CGFloat)desiredWidthOfTabCell:(PSMTabBarCell *)cell { - CGFloat resultWidth = 0.0; + CGFloat resultWidth = 0.0f; // left margin resultWidth = MARGIN_X; @@ -292,7 +292,7 @@ // right margin resultWidth += MARGIN_X; - return ceil(resultWidth); + return ceilf(resultWidth); } - (CGFloat)tabCellHeight @@ -317,22 +317,22 @@ NSRange range = NSMakeRange(0, [contents length]); // Add font attribute - [attrStr addAttribute:NSFontAttributeName value:[NSFont boldSystemFontOfSize:11.0] range:range]; - [attrStr addAttribute:NSForegroundColorAttributeName value:[[NSColor textColor] colorWithAlphaComponent:0.75] range:range]; + [attrStr addAttribute:NSFontAttributeName value:[NSFont boldSystemFontOfSize:11.0f] range:range]; + [attrStr addAttribute:NSForegroundColorAttributeName value:[[NSColor textColor] colorWithAlphaComponent:0.75f] range:range]; // Add shadow attribute - NSShadow* shadow; - shadow = [[[NSShadow alloc] init] autorelease]; + NSShadow* textShadow; + textShadow = [[[NSShadow alloc] init] autorelease]; CGFloat shadowAlpha; if (([cell state] == NSOnState) || [cell isHighlighted]) { - shadowAlpha = 0.8; + shadowAlpha = 0.8f; } else { - shadowAlpha = 0.5; + shadowAlpha = 0.5f; } - [shadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0 alpha:shadowAlpha]]; - [shadow setShadowOffset:NSMakeSize(0, -1)]; - [shadow setShadowBlurRadius:1.0]; - [attrStr addAttribute:NSShadowAttributeName value:shadow range:range]; + [textShadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0f alpha:shadowAlpha]]; + [textShadow setShadowOffset:NSMakeSize(0, -1)]; + [textShadow setShadowBlurRadius:1.0f]; + [attrStr addAttribute:NSShadowAttributeName value:textShadow range:range]; // Paragraph Style for Truncating Long Text static NSMutableParagraphStyle *TruncatingTailParagraphStyle = nil; @@ -365,13 +365,13 @@ // no tab view == not connected if (![bar tabView]) { NSRect labelRect = rect; - labelRect.size.height -= 4.0; - labelRect.origin.y += 4.0; + labelRect.size.height -= 4.0f; + labelRect.origin.y += 4.0f; NSMutableAttributedString *attrStr; NSString *contents = @"PSMTabBarControl"; attrStr = [[[NSMutableAttributedString alloc] initWithString:contents] autorelease]; NSRange range = NSMakeRange(0, [contents length]); - [attrStr addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:11.0] range:range]; + [attrStr addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:11.0f] range:range]; NSMutableParagraphStyle *centeredParagraphStyle = nil; if (!centeredParagraphStyle) { @@ -404,42 +404,42 @@ [NSGraphicsContext saveGraphicsState]; [[NSGraphicsContext currentContext] setShouldAntialias:NO]; - float backgroundCalibratedWhite = 0.495; + float backgroundCalibratedWhite = 0.495f; float lineCalibratedWhite = [[NSColor darkGrayColor] whiteComponent]; - float shadowAlpha = 0.4; + float shadowAlpha = 0.4f; // When the window is in the background, tone down the colours if (![[tabBar window] isMainWindow] || ![NSApp isActive]) { - backgroundCalibratedWhite = 0.73; - lineCalibratedWhite = 0.49; - shadowAlpha = 0.3; + backgroundCalibratedWhite = 0.73f; + lineCalibratedWhite = 0.49f; + shadowAlpha = 0.3f; } // fill in background of tab bar - [[NSColor colorWithCalibratedWhite:backgroundCalibratedWhite alpha:1.0] set]; + [[NSColor colorWithCalibratedWhite:backgroundCalibratedWhite alpha:1.0f] set]; NSRectFillUsingOperation(rect, NSCompositeSourceAtop); // Draw horizontal line across bottom edge, with a slight bottom glow - [[NSColor colorWithCalibratedWhite:lineCalibratedWhite alpha:1.0] set]; + [[NSColor colorWithCalibratedWhite:lineCalibratedWhite alpha:1.0f] set]; [NSGraphicsContext saveGraphicsState]; - NSShadow *shadow = [[NSShadow alloc] init]; - [shadow setShadowBlurRadius:1]; - [shadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.2]]; - [shadow setShadowOffset:NSMakeSize(0,1)]; - [shadow set]; - [NSBezierPath strokeLineFromPoint:NSMakePoint(rect.origin.x, rect.origin.y + rect.size.height - 0.5) toPoint:NSMakePoint(rect.origin.x + rect.size.width, rect.origin.y + rect.size.height - 0.5)]; - [shadow release]; + NSShadow *lineGlow = [[NSShadow alloc] init]; + [lineGlow setShadowBlurRadius:1]; + [lineGlow setShadowColor:[NSColor colorWithCalibratedWhite:1.0f alpha:0.2f]]; + [lineGlow setShadowOffset:NSMakeSize(0,1)]; + [lineGlow set]; + [NSBezierPath strokeLineFromPoint:NSMakePoint(rect.origin.x, rect.origin.y + rect.size.height - 0.5f) toPoint:NSMakePoint(rect.origin.x + rect.size.width, rect.origin.y + rect.size.height - 0.5f)]; + [lineGlow release]; [NSGraphicsContext restoreGraphicsState]; // Add a shadow before drawing the top edge [NSGraphicsContext saveGraphicsState]; - shadow = [[NSShadow alloc] init]; - [shadow setShadowBlurRadius:4]; - [shadow setShadowColor:[NSColor colorWithCalibratedWhite:0.0 alpha:shadowAlpha]]; - [shadow setShadowOffset:NSMakeSize(0,0)]; - [shadow set]; - [NSBezierPath strokeLineFromPoint:NSMakePoint(rect.origin.x, rect.origin.y + 0.5) toPoint:NSMakePoint(rect.origin.x + rect.size.width, rect.origin.y + 0.5)]; - [shadow release]; + NSShadow *edgeShadow = [[NSShadow alloc] init]; + [edgeShadow setShadowBlurRadius:4]; + [edgeShadow setShadowColor:[NSColor colorWithCalibratedWhite:0.0f alpha:shadowAlpha]]; + [edgeShadow setShadowOffset:NSMakeSize(0,0)]; + [edgeShadow set]; + [NSBezierPath strokeLineFromPoint:NSMakePoint(rect.origin.x, rect.origin.y + 0.5f) toPoint:NSMakePoint(rect.origin.x + rect.size.width, rect.origin.y + 0.5f)]; + [edgeShadow release]; [NSGraphicsContext restoreGraphicsState]; [NSGraphicsContext restoreGraphicsState]; @@ -456,7 +456,6 @@ NSColor *shadowColor = nil; NSBezierPath *outlineBezier = [NSBezierPath bezierPath]; NSBezierPath *fillBezier = [NSBezierPath bezierPath]; - NSPoint center = NSZeroPoint; NSPoint topLeftArcCenter, bottomLeftArcCenter, topRightArcCenter, bottomRightArcCenter; BOOL drawRightEdge = YES; BOOL drawLeftEdge = YES; @@ -503,20 +502,20 @@ if ([[tabBar window] isMainWindow] && [NSApp isActive]) { lineColor = [NSColor darkGrayColor]; if ([cell state] == NSOnState) { - fillColor = [NSColor colorWithCalibratedWhite:0.59 alpha:1.0]; - shadowColor = [NSColor colorWithCalibratedWhite:0.0 alpha:0.7]; + fillColor = [NSColor colorWithCalibratedWhite:0.59f alpha:1.0f]; + shadowColor = [NSColor colorWithCalibratedWhite:0.0f alpha:0.7f]; } else { - fillColor = [NSColor colorWithCalibratedWhite:0.495 alpha:1.0]; - shadowColor = [NSColor colorWithCalibratedWhite:0.0 alpha:1.0]; + fillColor = [NSColor colorWithCalibratedWhite:0.495f alpha:1.0f]; + shadowColor = [NSColor colorWithCalibratedWhite:0.0f alpha:1.0f]; } } else { - lineColor = [NSColor colorWithCalibratedWhite:0.49 alpha:1.0]; + lineColor = [NSColor colorWithCalibratedWhite:0.49f alpha:1.0f]; if ([cell state] == NSOnState) { - fillColor = [NSColor colorWithCalibratedWhite:0.81 alpha:1.0]; - shadowColor = [NSColor colorWithCalibratedWhite:0.0 alpha:0.4]; + fillColor = [NSColor colorWithCalibratedWhite:0.81f alpha:1.0f]; + shadowColor = [NSColor colorWithCalibratedWhite:0.0f alpha:0.4f]; } else { - fillColor = [NSColor colorWithCalibratedWhite:0.73 alpha:1.0]; - shadowColor = [NSColor colorWithCalibratedWhite:0.0 alpha:0.7]; + fillColor = [NSColor colorWithCalibratedWhite:0.73f alpha:1.0f]; + shadowColor = [NSColor colorWithCalibratedWhite:0.0f alpha:0.7f]; } } @@ -531,10 +530,10 @@ } // Set up the corner bezier paths arc centers - topLeftArcCenter = NSMakePoint(aRect.origin.x - kPSMSequelProTabCornerRadius + 0.5, aRect.origin.y + kPSMSequelProTabCornerRadius); - topRightArcCenter = NSMakePoint(aRect.origin.x + aRect.size.width + kPSMSequelProTabCornerRadius + 0.5, aRect.origin.y + kPSMSequelProTabCornerRadius); - bottomLeftArcCenter = NSMakePoint(aRect.origin.x + kPSMSequelProTabCornerRadius + 0.5, aRect.origin.y + aRect.size.height - kPSMSequelProTabCornerRadius); - bottomRightArcCenter = NSMakePoint(aRect.origin.x + aRect.size.width - kPSMSequelProTabCornerRadius + 0.5, aRect.origin.y + aRect.size.height - kPSMSequelProTabCornerRadius); + topLeftArcCenter = NSMakePoint(aRect.origin.x - kPSMSequelProTabCornerRadius + 0.5f, aRect.origin.y + kPSMSequelProTabCornerRadius); + topRightArcCenter = NSMakePoint(aRect.origin.x + aRect.size.width + kPSMSequelProTabCornerRadius + 0.5f, aRect.origin.y + kPSMSequelProTabCornerRadius); + bottomLeftArcCenter = NSMakePoint(aRect.origin.x + kPSMSequelProTabCornerRadius + 0.5f, aRect.origin.y + aRect.size.height - kPSMSequelProTabCornerRadius); + bottomRightArcCenter = NSMakePoint(aRect.origin.x + aRect.size.width - kPSMSequelProTabCornerRadius + 0.5f, aRect.origin.y + aRect.size.height - kPSMSequelProTabCornerRadius); // Construct the outline path if (drawLeftEdge) { @@ -551,21 +550,21 @@ // If one edge is missing, apply a local fill to the other edge if (drawRightEdge && !drawLeftEdge) { - [fillBezier lineToPoint:NSMakePoint(aRect.origin.x + aRect.size.width - kPSMSequelProTabCornerRadius + 0.5, aRect.origin.y)]; - [fillBezier lineToPoint:NSMakePoint(aRect.origin.x + aRect.size.width - kPSMSequelProTabCornerRadius + 0.5, aRect.origin.y + aRect.size.height)]; + [fillBezier lineToPoint:NSMakePoint(aRect.origin.x + aRect.size.width - kPSMSequelProTabCornerRadius + 0.5f, aRect.origin.y)]; + [fillBezier lineToPoint:NSMakePoint(aRect.origin.x + aRect.size.width - kPSMSequelProTabCornerRadius + 0.5f, aRect.origin.y + aRect.size.height)]; } else if (!drawRightEdge && drawLeftEdge) { - [fillBezier lineToPoint:NSMakePoint(aRect.origin.x + 0.5 + kPSMSequelProTabCornerRadius, aRect.origin.y)]; + [fillBezier lineToPoint:NSMakePoint(aRect.origin.x + 0.5f + kPSMSequelProTabCornerRadius, aRect.origin.y)]; } // Set the tab outer shadow and draw the shadow [NSGraphicsContext saveGraphicsState]; - NSShadow *shadow = [[NSShadow alloc] init]; - [shadow setShadowBlurRadius:4]; - [shadow setShadowColor:shadowColor]; - [shadow setShadowOffset:NSMakeSize(0, 0)]; - [shadow set]; + NSShadow *cellShadow = [[NSShadow alloc] init]; + [cellShadow setShadowBlurRadius:4]; + [cellShadow setShadowColor:shadowColor]; + [cellShadow setShadowOffset:NSMakeSize(0, 0)]; + [cellShadow set]; [outlineBezier stroke]; - [shadow release]; + [cellShadow release]; [NSGraphicsContext restoreGraphicsState]; // Fill the tab with a solid colour @@ -582,20 +581,20 @@ if (drawLeftEdge) { [outlineBezier appendBezierPathWithArcWithCenter:bottomLeftArcCenter radius:kPSMSequelProTabCornerRadius startAngle:145 endAngle:90 clockwise:YES]; } else { - [outlineBezier moveToPoint:NSMakePoint(aRect.origin.x, aRect.origin.y + aRect.size.height - 0.5)]; + [outlineBezier moveToPoint:NSMakePoint(aRect.origin.x, aRect.origin.y + aRect.size.height - 0.5f)]; } if (drawRightEdge) { [outlineBezier appendBezierPathWithArcWithCenter:bottomRightArcCenter radius:kPSMSequelProTabCornerRadius startAngle:90 endAngle:35 clockwise:YES]; } else { - [outlineBezier lineToPoint:NSMakePoint(aRect.origin.x + aRect.size.width, aRect.origin.y + aRect.size.height - 0.5)]; + [outlineBezier lineToPoint:NSMakePoint(aRect.origin.x + aRect.size.width, aRect.origin.y + aRect.size.height - 0.5f)]; } - shadow = [[NSShadow alloc] init]; - [shadow setShadowBlurRadius:1]; - [shadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.4]]; - [shadow setShadowOffset:NSMakeSize(0, 1)]; - [shadow set]; + cellShadow = [[NSShadow alloc] init]; + [cellShadow setShadowBlurRadius:1]; + [cellShadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0f alpha:0.4f]]; + [cellShadow setShadowOffset:NSMakeSize(0, 1)]; + [cellShadow set]; [outlineBezier stroke]; - [shadow release]; + [cellShadow release]; // Add the shadow over the tops of background tabs } else if (drawLeftEdge || drawRightEdge) { @@ -604,37 +603,37 @@ CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; CGContextSaveGState(context); NSPoint topLeft, topRight; - CGFloat drawAlpha = ([[tabBar window] isMainWindow] && [NSApp isActive])? 1.0 : 0.7; + CGFloat drawAlpha = ([[tabBar window] isMainWindow] && [NSApp isActive])? 1.0f : 0.7f; outlineBezier = [NSBezierPath bezierPath]; // Calculate the endpoints of the line if (drawLeftEdge) { - topLeft = NSMakePoint(aRect.origin.x + 0.5 - kPSMSequelProTabCornerRadius + 2, aRect.origin.y + 0.5); + topLeft = NSMakePoint(aRect.origin.x + 0.5f - kPSMSequelProTabCornerRadius + 2, aRect.origin.y + 0.5f); } else { - topLeft = NSMakePoint(aRect.origin.x + aRect.size.width - kPSMSequelProTabCornerRadius + 0.5, aRect.origin.y + 0.5); + topLeft = NSMakePoint(aRect.origin.x + aRect.size.width - kPSMSequelProTabCornerRadius + 0.5f, aRect.origin.y + 0.5f); } if (drawRightEdge) { - topRight = NSMakePoint(aRect.origin.x + aRect.size.width + kPSMSequelProTabCornerRadius + 0.5 - 2, aRect.origin.y + 0.5); + topRight = NSMakePoint(aRect.origin.x + aRect.size.width + kPSMSequelProTabCornerRadius + 0.5f - 2, aRect.origin.y + 0.5f); } else { - topRight = NSMakePoint(aRect.origin.x + 0.5 + kPSMSequelProTabCornerRadius, aRect.origin.y + 0.5); + topRight = NSMakePoint(aRect.origin.x + 0.5f + kPSMSequelProTabCornerRadius, aRect.origin.y + 0.5f); } // Set up the line and clipping point CGContextClipToRect(context, CGRectMake(topLeft.x, topLeft.y, topRight.x-topLeft.x, aRect.size.height)); - [[NSColor colorWithCalibratedWhite:0.2 alpha:drawAlpha] set]; + [[NSColor colorWithCalibratedWhite:0.2f alpha:drawAlpha] set]; [outlineBezier moveToPoint:topLeft]; [outlineBezier lineToPoint:topRight]; // Set up the shadow - shadow = [[NSShadow alloc] init]; - [shadow setShadowBlurRadius:4]; - [shadow setShadowColor:[NSColor colorWithCalibratedWhite:0.2 alpha:drawAlpha]]; - [shadow setShadowOffset:NSMakeSize(0,0)]; - [shadow set]; + cellShadow = [[NSShadow alloc] init]; + [cellShadow setShadowBlurRadius:4]; + [cellShadow setShadowColor:[NSColor colorWithCalibratedWhite:0.2f alpha:drawAlpha]]; + [cellShadow setShadowOffset:NSMakeSize(0,0)]; + [cellShadow set]; // Draw, and then restore the previous graphics state [outlineBezier stroke]; - [shadow release]; + [cellShadow release]; CGContextRestoreGState(context); } @@ -679,7 +678,7 @@ closeButtonRect.origin.y += closeButtonRect.size.height; } - [closeButton compositeToPoint:closeButtonRect.origin operation:NSCompositeSourceOver fraction:1.0]; + [closeButton compositeToPoint:closeButtonRect.origin operation:NSCompositeSourceOver fraction:1.0f]; } // icon @@ -693,13 +692,13 @@ // center in available space (in case icon image is smaller than kPSMTabBarIconWidth) if ([icon size].width < kPSMTabBarIconWidth) { - iconRect.origin.x += (kPSMTabBarIconWidth - [icon size].width)/2.0; + iconRect.origin.x += (kPSMTabBarIconWidth - [icon size].width)/2.0f; } if ([icon size].height < kPSMTabBarIconWidth) { - iconRect.origin.y -= (kPSMTabBarIconWidth - [icon size].height)/2.0; + iconRect.origin.y -= (kPSMTabBarIconWidth - [icon size].height)/2.0f; } - [icon compositeToPoint:iconRect.origin operation:NSCompositeSourceOver fraction:1.0]; + [icon compositeToPoint:iconRect.origin operation:NSCompositeSourceOver fraction:1.0f]; // scoot label over insetLabelWidth += iconRect.size.width + kPSMTabBarCellPadding; @@ -720,7 +719,7 @@ // object counter if ([cell count] > 0) { - [[cell countColor] ?: [NSColor colorWithCalibratedWhite:0.3 alpha:0.6] set]; + [[cell countColor] ?: [NSColor colorWithCalibratedWhite:0.3f alpha:0.6f] set]; NSBezierPath *path = [NSBezierPath bezierPath]; NSRect myRect = [self objectCounterRectForTabCell:cell]; if ([cell state] == NSOnState) { @@ -728,17 +727,17 @@ } [path moveToPoint:NSMakePoint(myRect.origin.x + kPSMSequelProObjectCounterRadius, myRect.origin.y)]; [path lineToPoint:NSMakePoint(myRect.origin.x + myRect.size.width - kPSMSequelProObjectCounterRadius, myRect.origin.y)]; - [path appendBezierPathWithArcWithCenter:NSMakePoint(myRect.origin.x + myRect.size.width - kPSMSequelProObjectCounterRadius, myRect.origin.y + kPSMSequelProObjectCounterRadius) radius:kPSMSequelProObjectCounterRadius startAngle:270.0 endAngle:90.0]; + [path appendBezierPathWithArcWithCenter:NSMakePoint(myRect.origin.x + myRect.size.width - kPSMSequelProObjectCounterRadius, myRect.origin.y + kPSMSequelProObjectCounterRadius) radius:kPSMSequelProObjectCounterRadius startAngle:270.0f endAngle:90.0f]; [path lineToPoint:NSMakePoint(myRect.origin.x + kPSMSequelProObjectCounterRadius, myRect.origin.y + myRect.size.height)]; - [path appendBezierPathWithArcWithCenter:NSMakePoint(myRect.origin.x + kPSMSequelProObjectCounterRadius, myRect.origin.y + kPSMSequelProObjectCounterRadius) radius:kPSMSequelProObjectCounterRadius startAngle:90.0 endAngle:270.0]; + [path appendBezierPathWithArcWithCenter:NSMakePoint(myRect.origin.x + kPSMSequelProObjectCounterRadius, myRect.origin.y + kPSMSequelProObjectCounterRadius) radius:kPSMSequelProObjectCounterRadius startAngle:90.0f endAngle:270.0f]; [path fill]; // draw attributed string centered in area NSRect counterStringRect; NSAttributedString *counterString = [self attributedObjectCountValueForTabCell:cell]; counterStringRect.size = [counterString size]; - counterStringRect.origin.x = myRect.origin.x + ((myRect.size.width - counterStringRect.size.width) / 2.0) + 0.25; - counterStringRect.origin.y = myRect.origin.y + ((myRect.size.height - counterStringRect.size.height) / 2.0) + 0.5; + counterStringRect.origin.x = myRect.origin.x + ((myRect.size.width - counterStringRect.size.width) / 2.0f) + 0.25f; + counterStringRect.origin.y = myRect.origin.y + ((myRect.size.height - counterStringRect.size.height) / 2.0f) + 0.5f; [counterString drawInRect:counterStringRect]; // shrink label width to make room for object counter diff --git a/Resources/English.lproj/BundleEditor.strings b/Resources/English.lproj/BundleEditor.strings Binary files differindex 17be5976..56496dce 100644 --- a/Resources/English.lproj/BundleEditor.strings +++ b/Resources/English.lproj/BundleEditor.strings diff --git a/Resources/English.lproj/DBView.strings b/Resources/English.lproj/DBView.strings Binary files differindex 35f47990..aa6a0a4d 100644 --- a/Resources/English.lproj/DBView.strings +++ b/Resources/English.lproj/DBView.strings diff --git a/Resources/English.lproj/FieldEditorSheet.strings b/Resources/English.lproj/FieldEditorSheet.strings Binary files differindex d2995a33..ebd17ce7 100644 --- a/Resources/English.lproj/FieldEditorSheet.strings +++ b/Resources/English.lproj/FieldEditorSheet.strings diff --git a/Resources/English.lproj/Localizable.strings b/Resources/English.lproj/Localizable.strings Binary files differindex 101f45e3..dac7c145 100644 --- a/Resources/English.lproj/Localizable.strings +++ b/Resources/English.lproj/Localizable.strings diff --git a/Source/DMLocalizedNib.m b/Source/DMLocalizedNib.m index 93c37bd5..c675e110 100644 --- a/Source/DMLocalizedNib.m +++ b/Source/DMLocalizedNib.m @@ -8,7 +8,6 @@ #import <Cocoa/Cocoa.h> #import <objc/runtime.h> - @interface NSNib (DMLocalizedNib) - (id)deliciousInitWithNibNamed:(NSString *)nibName bundle:(NSBundle *)bundle; - (id)deliciousInitWithContentsOfURL:(NSURL *)nibFileURL; diff --git a/Source/DMLocalizedNibBundle.m b/Source/DMLocalizedNibBundle.m index f4922be6..b9cbec28 100644 --- a/Source/DMLocalizedNibBundle.m +++ b/Source/DMLocalizedNibBundle.m @@ -177,13 +177,13 @@ static NSMutableArray *deliciousBindingKeys = nil; } } else if ([view isKindOfClass:[NSTableView class]]) { - for (NSTableColumn *column in [view tableColumns]) { + for (NSTableColumn *column in [(NSTableView*)view tableColumns]) { [self _localizeStringValueOfObject:[column headerCell] table:table]; } } else if ([view isKindOfClass:[NSTextField class]]) { NSDictionary *vb; - if (vb = [view infoForBinding:@"value"]) { + if ((vb = [view infoForBinding:@"value"])) { NSMutableDictionary *lvb = [NSMutableDictionary dictionaryWithDictionary:[vb objectForKey:NSOptionsKey]]; for (NSString *bindingKey in deliciousBindingKeys) { if ([lvb objectForKey:bindingKey] == [NSNull null]) continue; @@ -255,4 +255,4 @@ DM_DEFINE_LOCALIZE_BLAH_OF_OBJECT(placeholderString, PlaceholderString) DM_DEFINE_LOCALIZE_BLAH_OF_OBJECT(toolTip, ToolTip) DM_DEFINE_LOCALIZE_BLAH_OF_OBJECT(label, Label) -@end
\ No newline at end of file +@end diff --git a/Source/GeneratePreviewForURL.m b/Source/GeneratePreviewForURL.m index 349837ff..6c779859 100644 --- a/Source/GeneratePreviewForURL.m +++ b/Source/GeneratePreviewForURL.m @@ -30,6 +30,11 @@ #import "SPDataAdditions.h" #import "SPEditorTokens.h" +OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maxSize); +OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options); +void CancelPreviewGeneration(void* thisInterface, QLPreviewRequestRef preview); + + /* ----------------------------------------------------------------------------- Generate a preview for file @@ -256,7 +261,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, } // Get info.plist data as dictionary NSDictionary *sessionSpf; - NSData *pData = [NSData dataWithContentsOfFile:spfPath options:NSUncachedRead error:&readError]; + pData = [NSData dataWithContentsOfFile:spfPath options:NSUncachedRead error:&readError]; sessionSpf = [[NSPropertyListSerialization propertyListFromData:pData mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&convError] retain]; @@ -338,7 +343,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, { NSNumber *filesize = [fileAttributes objectForKey:NSFileSize]; - NSUInteger kMaxSQLFileSize = (0.7 * 1024 * 1024); + NSUInteger kMaxSQLFileSize = (0.7f * 1024 * 1024); // compose the html and perform syntax highlighting @@ -372,7 +377,6 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, truncatedString = [[NSString alloc] initWithString:@"\n ✂ ..."]; } - NSRange textRange = NSMakeRange(0, [sqlText length]); NSString *tokenColor; size_t token; NSRange tokenRange; @@ -385,7 +389,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, // now loop through all the tokens NSUInteger poolCount = 0; NSAutoreleasePool *loopPool = [[NSAutoreleasePool alloc] init]; - while (token=yylex()){ + while ((token=yylex())){ skipFontTag = NO; switch (token) { case SPT_SINGLE_QUOTED_TEXT: @@ -490,7 +494,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, props = [[NSMutableDictionary alloc] initWithCapacity:6]; imgProps = [[NSMutableDictionary alloc] initWithCapacity:2]; - [props setObject:[NSNumber numberWithInt:previewHeight] forKey:(NSString *)kQLPreviewPropertyHeightKey]; + [props setObject:[NSNumber numberWithInteger:previewHeight] forKey:(NSString *)kQLPreviewPropertyHeightKey]; [props setObject:[NSNumber numberWithInt:600] forKey:(NSString *)kQLPreviewPropertyWidthKey]; if(image) { diff --git a/Source/GenerateThumbnailForURL.m b/Source/GenerateThumbnailForURL.m index dbc1f42c..8251cb5e 100644 --- a/Source/GenerateThumbnailForURL.m +++ b/Source/GenerateThumbnailForURL.m @@ -26,6 +26,9 @@ #include <CoreServices/CoreServices.h> #include <QuickLook/QuickLook.h> +void CancelThumbnailGeneration(void* thisInterface, QLThumbnailRequestRef thumbnail); +OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maximumSize); + /* ----------------------------------------------------------------------------- Generate a thumbnail for file @@ -38,7 +41,7 @@ void CancelThumbnailGeneration(void* thisInterface, QLThumbnailRequestRef thumbn // implement only if supported } -OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maxSize) +OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maximumSize) { return noErr; @@ -54,7 +57,7 @@ OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thum // return noErr; // } // - // NSSize canvasSize = NSMakeSize((NSInteger)(maxSize.height/1.3f), maxSize.height); + // NSSize canvasSize = NSMakeSize((NSInteger)(maximumSize.height/1.3f), maximumSize.height); // // // Thumbnail will be drawn with maximum resolution for desired thumbnail request // // Here we create a graphics context to draw the Quick Look Thumbnail in. @@ -85,4 +88,4 @@ OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thum // [pool release]; // return noErr; -}
\ No newline at end of file +} diff --git a/Source/ICUTemplateMatcher.m b/Source/ICUTemplateMatcher.m index 8fcdb73c..84b8259a 100644 --- a/Source/ICUTemplateMatcher.m +++ b/Source/ICUTemplateMatcher.m @@ -20,7 +20,7 @@ - (id)initWithTemplateEngine:(MGTemplateEngine *)theEngine { - if (self = [super init]) { + if ((self = [super init])) { self.engine = theEngine; // weak ref } diff --git a/Source/MGTemplateEngine.m b/Source/MGTemplateEngine.m index 89ea3a1d..17acae65 100644 --- a/Source/MGTemplateEngine.m +++ b/Source/MGTemplateEngine.m @@ -60,7 +60,7 @@ - (id)init { - if (self = [super init]) { + if ((self = [super init])) { _openBlocksStack = [[NSMutableArray alloc] init]; _globals = [[NSMutableDictionary alloc] init]; _markers = [[NSMutableDictionary alloc] init]; @@ -249,7 +249,7 @@ // Attempt to find firstVar in stack variables. NSEnumerator *stack = [_openBlocksStack reverseObjectEnumerator]; NSDictionary *stackFrame = nil; - while (stackFrame = [stack nextObject]) { + while ((stackFrame = [stack nextObject])) { NSDictionary *vars = [stackFrame objectForKey:BLOCK_VARIABLES_KEY]; if (vars && [vars objectForKey:firstVar]) { currObj = vars; diff --git a/Source/MGTemplateStandardMarkers.m b/Source/MGTemplateStandardMarkers.m index 0cbc8c66..184dab48 100644 --- a/Source/MGTemplateStandardMarkers.m +++ b/Source/MGTemplateStandardMarkers.m @@ -76,7 +76,7 @@ - (id)initWithTemplateEngine:(MGTemplateEngine *)theEngine { - if (self = [super init]) { + if ((self = [super init])) { engine = theEngine; forStack = [[NSMutableArray alloc] init]; sectionStack = [[NSMutableArray alloc] init]; diff --git a/Source/NSNotificationAdditions.m b/Source/NSNotificationAdditions.m index 53917dae..ae949347 100644 --- a/Source/NSNotificationAdditions.m +++ b/Source/NSNotificationAdditions.m @@ -24,7 +24,13 @@ // More info at <http://code.google.com/p/sequel-pro/> #import "NSNotificationAdditions.h" -#import <pthread.h> +#import "pthread.h" + +@interface NSNotificationCenter (NSNotificationCenterAdditions_PrivateAPI) ++ (void)_postNotification:(NSNotification *)notification; ++ (void)_postNotificationName:(NSDictionary *)info; ++ (void)_postNotificationForwarder:(NSDictionary *)info; +@end @implementation NSNotificationCenter (NSNotificationCenterAdditions) @@ -35,16 +41,11 @@ [self postNotificationOnMainThread:notification waitUntilDone:NO]; } -- (void)postNotificationOnMainThread:(NSNotification *)notification waitUntilDone:(BOOL)wait +- (void)postNotificationOnMainThread:(NSNotification *)notification waitUntilDone:(BOOL)shouldWaitUntilDone { if (pthread_main_np()) return [self postNotification:notification]; - [[self class] performSelectorOnMainThread:@selector(_postNotification:) withObject:notification waitUntilDone:wait]; -} - -+ (void)_postNotification:(NSNotification *)notification -{ - [[self defaultCenter] postNotification:notification]; + [self performSelectorOnMainThread:@selector(_postNotification:) withObject:notification waitUntilDone:shouldWaitUntilDone]; } - (void)postNotificationOnMainThreadWithName:(NSString *)name object:(id)object @@ -61,21 +62,30 @@ [self postNotificationOnMainThreadWithName:name object:object userInfo:userInfo waitUntilDone:NO]; } -- (void)postNotificationOnMainThreadWithName:(NSString *)name object:(id)object userInfo:(NSDictionary *)userInfo waitUntilDone:(BOOL)wait +- (void)postNotificationOnMainThreadWithName:(NSString *)name object:(id)object userInfo:(NSDictionary *)userInfo waitUntilDone:(BOOL)shouldWaitUntilDone { if (pthread_main_np()) return [self postNotificationName:name object:object userInfo:userInfo]; - + NSMutableDictionary *info = [[NSMutableDictionary allocWithZone:nil] initWithCapacity:3]; if (name) [info setObject:name forKey:@"name"]; if (object) [info setObject:object forKey:@"object"]; if (userInfo) [info setObject:userInfo forKey:@"userInfo"]; - - [[self class] performSelectorOnMainThread:@selector(_postNotificationName:) withObject:info waitUntilDone:wait]; - + + [[self class] performSelectorOnMainThread:@selector(_postNotificationName:) withObject:info waitUntilDone:shouldWaitUntilDone]; + [info release]; } +@end + +@implementation NSNotificationCenter (NSNotificationCenterAdditions_PrivateAPI) + ++ (void)_postNotification:(NSNotification *)notification +{ + [[self defaultCenter] postNotification:notification]; +} + + (void)_postNotificationName:(NSDictionary *)info { NSString *name = [info objectForKey:@"name"]; @@ -83,7 +93,18 @@ id object = [info objectForKey:@"object"]; NSDictionary *userInfo = [info objectForKey:@"userInfo"]; + + [[self defaultCenter] postNotificationName:name object:object userInfo:userInfo]; +} + ++ (void)_postNotificationForwarder:(NSDictionary *)info +{ + NSString *name = [info objectForKey:@"name"]; + id object = [info objectForKey:@"object"]; + + NSDictionary *userInfo = [info objectForKey:@"userInfo"]; + [[self defaultCenter] postNotificationName:name object:object userInfo:userInfo]; } diff --git a/Source/NoodleLineNumberView.m b/Source/NoodleLineNumberView.m index 1d44c939..15296c8e 100644 --- a/Source/NoodleLineNumberView.m +++ b/Source/NoodleLineNumberView.m @@ -175,8 +175,8 @@ typedef NSRange (*RangeOfLineIMP)(id object, SEL selector, NSRange range); if ((aView != nil) && [aView isKindOfClass:[NSTextView class]]) { - layoutManager = [aView layoutManager]; - container = [aView textContainer]; + layoutManager = [(NSTextView*)aView layoutManager]; + container = [(NSTextView*)aView textContainer]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textDidChange:) name:NSTextStorageDidProcessEditingNotification object:[(NSTextView *)aView textStorage]]; [self invalidateLineIndices]; @@ -204,7 +204,7 @@ typedef NSRange (*RangeOfLineIMP)(id object, SEL selector, NSRange range); - (NSUInteger)lineNumberForLocation:(CGFloat)location { - NSUInteger line, count, rectCount, i; + NSUInteger line, count, rectCount; NSRectArray rects; NSRect visibleRect; NSRange nullRange; @@ -252,7 +252,7 @@ typedef NSRange (*RangeOfLineIMP)(id object, SEL selector, NSRange range); - (NSUInteger)lineNumberForCharacterIndex:(NSUInteger)index { NSUInteger left, right, mid, lineStart; - NSMutableArray *lines; + NSArray *lines; lines = [self lineIndices]; @@ -302,7 +302,7 @@ typedef NSRange (*RangeOfLineIMP)(id object, SEL selector, NSRange range); NSString *labelText; NSUInteger rectCount, index, line, count; NSRectArray rects; - CGFloat ypos, yinset; + CGFloat yinset; NSSize stringSize; NSArray *lines; diff --git a/Source/SPActivityTextFieldCell.m b/Source/SPActivityTextFieldCell.m index f97101b4..10194466 100644 --- a/Source/SPActivityTextFieldCell.m +++ b/Source/SPActivityTextFieldCell.m @@ -24,8 +24,9 @@ // More info at <http://code.google.com/p/sequel-pro/> #import "SPActivityTextFieldCell.h" +#import "SPTableInfo.h" -#define FAVORITE_NAME_FONT_SIZE 12.0 +#define FAVORITE_NAME_FONT_SIZE 12.0f @interface SPActivityTextFieldCell (PrivateAPI) @@ -120,21 +121,21 @@ static inline NSRect SPTextLinkRectFromCellRect(NSRect inRect) NSAttributedString *mainString = [self attributedStringForFavoriteName]; NSAttributedString *subString = [self constructSubStringAttributedString]; - NSRect subFrame = NSMakeRect(0.0, 0.0, [subString size].width, [subString size].height); + NSRect subFrame = NSMakeRect(0.0f, 0.0f, [subString size].width, [subString size].height); // Total height of both strings with a 2 pixel separation space - CGFloat totalHeight = [mainString size].height + [subString size].height + 1.0; + CGFloat totalHeight = [mainString size].height + [subString size].height + 1.0f; - cellFrame.origin.y += (cellFrame.size.height - totalHeight) / 2.0; - cellFrame.origin.x += 10.0; // Indent main string from image + cellFrame.origin.y += (cellFrame.size.height - totalHeight) / 2.0f; + cellFrame.origin.x += 10.0f; // Indent main string from image // Position the sub text's frame rect - subFrame.origin.y = [mainString size].height + cellFrame.origin.y + 1.0; + subFrame.origin.y = [mainString size].height + cellFrame.origin.y + 1.0f; subFrame.origin.x = cellFrame.origin.x; cellFrame.size.height = totalHeight; - NSInteger i; + NSUInteger i; CGFloat maxWidth = cellFrame.size.width - 30; CGFloat mainStringWidth = [mainString size].width; CGFloat subStringWidth = [subString size].width; @@ -288,10 +289,10 @@ static inline NSRect SPTextLinkRectFromCellRect(NSRect inRect) // 15 := indention 10 from image to string plus 5 px padding CGFloat theWidth = MAX([mainString size].width, [subString size].width) + (([self image] != nil) ? [[self image] size].width : 0) + 15; - CGFloat totalHeight = [mainString size].height + [subString size].height + 1.0; + CGFloat totalHeight = [mainString size].height + [subString size].height + 1.0f; cellSize.width = theWidth; - cellSize.height = totalHeight + 13.0; + cellSize.height = totalHeight + 13.0f; return cellSize; } diff --git a/Source/SPAlertSheets.m b/Source/SPAlertSheets.m index 3299c351..b9ac1136 100644 --- a/Source/SPAlertSheets.m +++ b/Source/SPAlertSheets.m @@ -22,6 +22,8 @@ // // More info at <http://code.google.com/p/sequel-pro/> +#import "SPAlertSheets.h" + /** * Provide a simple alias of NSBeginAlertSheet, with a few differences: * - printf-type format strings are no longer supported within the "msg" @@ -101,7 +103,7 @@ void SPBeginWaitingAlertSheet( // Initialize returnCode with a value which can't be returned as // returnCode in the didEndSelector method NSInteger initialReturnCode = -5; - returnCode = initialReturnCode; + returnCode = &initialReturnCode; // Set up an NSAlert with the supplied details NSAlert *alert = [[[NSAlert alloc] init] autorelease]; @@ -141,7 +143,7 @@ void SPBeginWaitingAlertSheet( // Since the returnCode can only be -1, 0, or 1 // run the session until returnCode was changed in // the didEndSelector method of the calling class - if(returnCode != initialReturnCode) + if(returnCode != &initialReturnCode) break; // Execute code on DefaultRunLoop diff --git a/Source/SPAppController.m b/Source/SPAppController.m index ba65df6f..4424e9a9 100644 --- a/Source/SPAppController.m +++ b/Source/SPAppController.m @@ -695,7 +695,7 @@ YY_BUFFER_STATE yy_scan_string (const char *); NSString *statusFileName = [NSString stringWithFormat:@"%@%@", SPURLSchemeQueryResultStatusPathHeader, anUUID]; NSError *inError = nil; - NSString *query = [NSString stringWithContentsOfFile:queryFileName encoding:NSUTF8StringEncoding error:inError]; + NSString *query = [NSString stringWithContentsOfFile:queryFileName encoding:NSUTF8StringEncoding error:&inError]; NSString *result = @""; NSString *status = @"0"; @@ -838,84 +838,77 @@ YY_BUFFER_STATE yy_scan_string (const char *); */ - (NSString*)doSQLSyntaxHighlightForString:(NSString*)sqlText cssLike:(BOOL)cssLike { + NSMutableString *sqlHTML = [[[NSMutableString alloc] initWithCapacity:[sqlText length]] autorelease]; + + NSString *tokenColor; + NSString *cssId; + size_t token; + NSRange tokenRange; + + // initialise flex + yyuoffset = 0; yyuleng = 0; + yy_switch_to_buffer(yy_scan_string([sqlText UTF8String])); + BOOL skipFontTag; + + while ((token=yylex())) { + skipFontTag = NO; + switch (token) { + case SPT_SINGLE_QUOTED_TEXT: + case SPT_DOUBLE_QUOTED_TEXT: + tokenColor = @"#A7221C"; + cssId = @"sp_sql_quoted"; + break; + case SPT_BACKTICK_QUOTED_TEXT: + tokenColor = @"#001892"; + cssId = @"sp_sql_backtick"; + break; + case SPT_RESERVED_WORD: + tokenColor = @"#0041F6"; + cssId = @"sp_sql_keyword"; + break; + case SPT_NUMERIC: + tokenColor = @"#67350F"; + cssId = @"sp_sql_numeric"; + break; + case SPT_COMMENT: + tokenColor = @"#265C10"; + cssId = @"sp_sql_comment"; + break; + case SPT_VARIABLE: + tokenColor = @"#6C6C6C"; + cssId = @"sp_sql_variable"; + break; + case SPT_WHITESPACE: + skipFontTag = YES; + cssId = @""; + break; + default: + skipFontTag = YES; + cssId = @""; + } - NSMutableString *sqlHTML = [[[NSMutableString alloc] initWithCapacity:[sqlText length]] autorelease]; - - NSRange textRange = NSMakeRange(0, [sqlText length]); - NSString *tokenColor; - NSString *cssId; - size_t token; - NSRange tokenRange; - - // initialise flex - yyuoffset = 0; yyuleng = 0; - yy_switch_to_buffer(yy_scan_string([sqlText UTF8String])); - BOOL skipFontTag; - - while (token=yylex()){ - skipFontTag = NO; - switch (token) { - case SPT_SINGLE_QUOTED_TEXT: - case SPT_DOUBLE_QUOTED_TEXT: - tokenColor = @"#A7221C"; - cssId = @"sp_sql_quoted"; - break; - case SPT_BACKTICK_QUOTED_TEXT: - tokenColor = @"#001892"; - cssId = @"sp_sql_backtick"; - break; - case SPT_RESERVED_WORD: - tokenColor = @"#0041F6"; - cssId = @"sp_sql_keyword"; - break; - case SPT_NUMERIC: - tokenColor = @"#67350F"; - cssId = @"sp_sql_numeric"; - break; - case SPT_COMMENT: - tokenColor = @"#265C10"; - cssId = @"sp_sql_comment"; - break; - case SPT_VARIABLE: - tokenColor = @"#6C6C6C"; - cssId = @"sp_sql_variable"; - break; - case SPT_WHITESPACE: - skipFontTag = YES; - cssId = @""; - break; - default: - skipFontTag = YES; - cssId = @""; - } - - tokenRange = NSMakeRange(yyuoffset, yyuleng); - - if(skipFontTag) - [sqlHTML appendString:[[sqlText substringWithRange:tokenRange] HTMLEscapeString]]; - else { - if(cssLike) - [sqlHTML appendFormat:@"<span class=\"%@\">%@</span>", cssId, [[sqlText substringWithRange:tokenRange] HTMLEscapeString]]; - else - [sqlHTML appendFormat:@"<font color=%@>%@</font>", tokenColor, [[sqlText substringWithRange:tokenRange] HTMLEscapeString]]; - } + tokenRange = NSMakeRange(yyuoffset, yyuleng); + if(skipFontTag) + [sqlHTML appendString:[[sqlText substringWithRange:tokenRange] HTMLEscapeString]]; + else { + if(cssLike) + [sqlHTML appendFormat:@"<span class=\"%@\">%@</span>", cssId, [[sqlText substringWithRange:tokenRange] HTMLEscapeString]]; + else + [sqlHTML appendFormat:@"<font color=%@>%@</font>", tokenColor, [[sqlText substringWithRange:tokenRange] HTMLEscapeString]]; } - // Wrap lines, and replace tabs with spaces - [sqlHTML replaceOccurrencesOfString:@"\n" withString:@"<br>" options:NSLiteralSearch range:NSMakeRange(0, [sqlHTML length])]; - [sqlHTML replaceOccurrencesOfString:@"\t" withString:@" " options:NSLiteralSearch range:NSMakeRange(0, [sqlHTML length])]; + } - if(sqlHTML) - return sqlHTML; - else - return @""; + // Wrap lines, and replace tabs with spaces + [sqlHTML replaceOccurrencesOfString:@"\n" withString:@"<br>" options:NSLiteralSearch range:NSMakeRange(0, [sqlHTML length])]; + [sqlHTML replaceOccurrencesOfString:@"\t" withString:@" " options:NSLiteralSearch range:NSMakeRange(0, [sqlHTML length])]; + return (sqlHTML) ? sqlHTML : @""; } - (IBAction)executeBundleItemForApp:(id)sender { - NSInteger idx = [sender tag] - 1000000; NSString *infoPath = nil; NSArray *bundleItems = [[NSApp delegate] bundleItemsForScope:SPBundleScopeGeneral]; @@ -1859,11 +1852,7 @@ YY_BUFFER_STATE yy_scan_string (const char *); NSLocalizedString(@"Data Table", @"data table menu item label"), NSLocalizedString(@"General", @"general menu item label"),nil]; - NSArray *scopeSelector = [NSArray arrayWithObjects:@"executeBundleItemForInputField:", - @"executeBundleItemForDataTable:", - @"executeBundleItemForApp:", nil]; - - NSInteger k = 0; + NSUInteger k = 0; BOOL bundleOtherThanGeneralFound = NO; for(NSString* scope in scopes) { @@ -2084,7 +2073,6 @@ YY_BUFFER_STATE yy_scan_string (const char *); */ - (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender { - // Manually open a table document [self newWindow:self]; diff --git a/Source/SPAppleScriptSupport.m b/Source/SPAppleScriptSupport.m index ea390ab9..44d99352 100644 --- a/Source/SPAppleScriptSupport.m +++ b/Source/SPAppleScriptSupport.m @@ -25,6 +25,9 @@ #import "SPAppleScriptSupport.h" #import "SPWindowController.h" +#import "SPAppController.h" +#import "SPPrintController.h" +#import "SPDatabaseDocument.h" @implementation SPAppController (SPAppleScriptSupport) diff --git a/Source/SPArrayAdditions.h b/Source/SPArrayAdditions.h index 5e22ac42..a8f55c8a 100644 --- a/Source/SPArrayAdditions.h +++ b/Source/SPArrayAdditions.h @@ -24,7 +24,7 @@ static inline id NSArrayObjectAtIndex(NSArray *self, NSUInteger i) { - return (id)CFArrayGetValueAtIndex((CFArrayRef)self, i); + return (id)CFArrayGetValueAtIndex((CFArrayRef)self, (long)i); } static inline void NSMutableArrayAddObject(NSArray *self, id anObject) diff --git a/Source/SPBundleCommandTextView.h b/Source/SPBundleCommandTextView.h index 119121da..4b16a3fc 100644 --- a/Source/SPBundleCommandTextView.h +++ b/Source/SPBundleCommandTextView.h @@ -45,4 +45,8 @@ - (void)commentOut; - (BOOL)wrapSelectionWithPrefix:(unichar)prefix; +- (void)dragAlertSheetDidEnd:(NSAlert *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo; + +- (void)boundsDidChangeNotification:(NSNotification *)notification; + @end diff --git a/Source/SPBundleCommandTextView.m b/Source/SPBundleCommandTextView.m index d9aae0f7..59bebadc 100644 --- a/Source/SPBundleCommandTextView.m +++ b/Source/SPBundleCommandTextView.m @@ -35,6 +35,7 @@ [prefs removeObserver:self forKeyPath:SPCustomQueryEditorTabStopWidth]; [prefs release]; [lineNumberView release]; + [super dealloc]; } - (void)awakeFromNib @@ -373,7 +374,7 @@ paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; [paragraphStyle setTabStops:myArrayOfTabs]; // Soft wrapped lines are indented slightly - [paragraphStyle setHeadIndent:4.0]; + [paragraphStyle setHeadIndent:4.0f]; NSMutableDictionary *textAttributes = [[[NSMutableDictionary alloc] initWithCapacity:1] autorelease]; [textAttributes setObject:paragraphStyle forKey:NSParagraphStyleAttributeName]; @@ -668,14 +669,14 @@ { NSUInteger glyphIndex; NSLayoutManager *layoutManager = [self layoutManager]; - CGFloat fraction; + CGFloat partialFraction; NSRange range; range = [layoutManager glyphRangeForTextContainer:[self textContainer]]; glyphIndex = [layoutManager glyphIndexForPoint:aPoint inTextContainer:[self textContainer] - fractionOfDistanceThroughGlyph:&fraction]; - if( fraction > 0.5 ) glyphIndex++; + fractionOfDistanceThroughGlyph:&partialFraction]; + if( partialFraction > 0.5 ) glyphIndex++; if( glyphIndex == NSMaxRange(range) ) return [[self textStorage] length]; @@ -697,20 +698,20 @@ // Make usage of the UNIX command "file" to get an info // about file type and encoding. - NSTask *task=[[NSTask alloc] init]; - NSPipe *pipe=[[NSPipe alloc] init]; + NSTask *aTask=[[NSTask alloc] init]; + NSPipe *aPipe=[[NSPipe alloc] init]; NSFileHandle *handle; NSString *result; - [task setLaunchPath:@"/usr/bin/file"]; - [task setArguments:[NSArray arrayWithObjects:aPath, @"-Ib", nil]]; - [task setStandardOutput:pipe]; - handle=[pipe fileHandleForReading]; - [task launch]; + [aTask setLaunchPath:@"/usr/bin/file"]; + [aTask setArguments:[NSArray arrayWithObjects:aPath, @"-Ib", nil]]; + [aTask setStandardOutput:aPipe]; + handle=[aPipe fileHandleForReading]; + [aTask launch]; result=[[NSString alloc] initWithData:[handle readDataToEndOfFile] encoding:NSASCIIStringEncoding]; - [pipe release]; - [task release]; + [aPipe release]; + [aTask release]; // UTF16/32 files are detected as application/octet-stream resp. audio/mpeg if( [result hasPrefix:@"text/plain"] diff --git a/Source/SPBundleEditorController.m b/Source/SPBundleEditorController.m index 279002f4..8f1f6bab 100644 --- a/Source/SPBundleEditorController.m +++ b/Source/SPBundleEditorController.m @@ -480,7 +480,6 @@ } if(selectedTag != kDisabledScopeTag && ![[currentDict objectForKey:SPBundleFileScopeKey] isEqualToString:oldScope]) { - NSString *newScope = [currentDict objectForKey:SPBundleFileScopeKey]; NSUInteger newScopeIndex = [self _arrangedScopeIndexForScopeIndex:selectedTag]; NSString *currentCategory = [currentDict objectForKey:SPBundleFileCategoryKey]; if(!currentCategory) currentCategory = @""; @@ -578,7 +577,6 @@ - (IBAction)addCommandBundle:(id)sender { NSMutableDictionary *bundle; - NSUInteger insertIndex; // Store pending changes in Query [[self window] makeFirstResponder:nameTextField]; @@ -1015,7 +1013,6 @@ NSString *thePath = [NSString stringWithFormat:@"%@/%@.%@", bundlePath, bundleName, SPUserBundleFileExtension]; if([[NSFileManager defaultManager] fileExistsAtPath:thePath isDirectory:nil]) { NSError *error = nil; - NSString *trashDir = [NSHomeDirectory() stringByAppendingPathComponent:@".Trash"]; // Use a AppleScript script since NSWorkspace performFileOperation or NSFileManager moveItemAtPath // have problems probably due access rights. @@ -1148,8 +1145,6 @@ draggedFilePath = nil; } if(oldBundleName) [oldBundleName release], oldBundleName = nil; - - return YES; } #pragma mark - diff --git a/Source/SPBundleHTMLOutputController.m b/Source/SPBundleHTMLOutputController.m index 4b1567bb..6e5ffedd 100644 --- a/Source/SPBundleHTMLOutputController.m +++ b/Source/SPBundleHTMLOutputController.m @@ -25,6 +25,7 @@ #import "SPBundleHTMLOutputController.h" #import "SPAlertSheets.h" #import "SPPrintAccessory.h" +#import "SPAppController.h" @class WebScriptCallFrame; @@ -42,7 +43,7 @@ - (id)init { - if (self = [super initWithWindowNibName:@"BundleHTMLOutput"]) { + if ((self = [super initWithWindowNibName:@"BundleHTMLOutput"])) { [[self window] setReleasedWhenClosed:YES]; @@ -113,9 +114,7 @@ - (void)keyDown:(NSEvent *)theEvent { long allFlags = (NSShiftKeyMask|NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask); - NSString *characters = [theEvent characters]; NSString *charactersIgnMod = [theEvent charactersIgnoringModifiers]; - unichar insertedCharacter = [characters characterAtIndex:0]; long curFlags = ([theEvent modifierFlags] & allFlags); if(curFlags & NSCommandKeyMask) { diff --git a/Source/SPCSVExporter.m b/Source/SPCSVExporter.m index c874e9aa..e5d945c3 100644 --- a/Source/SPCSVExporter.m +++ b/Source/SPCSVExporter.m @@ -29,6 +29,7 @@ #import "SPFileHandle.h" #import "SPTableData.h" #import "SPExportUtilities.h" +#import "SPExportFile.h" @implementation SPCSVExporter @@ -394,7 +395,7 @@ } // Write data to disk - [[[self exportOutputFile] exportFileHandle] synchronizeFile]; + [[(SPExportFile*)[self exportOutputFile] exportFileHandle] synchronizeFile]; // Mark the process as not running [self setExportProcessIsRunning:NO]; diff --git a/Source/SPCSVParser.m b/Source/SPCSVParser.m index f1e63c72..f19c2d55 100644 --- a/Source/SPCSVParser.m +++ b/Source/SPCSVParser.m @@ -48,7 +48,7 @@ totalLengthParsed = 0; // Loop through the results fetching process - while (csvRowArray = [self getRowAsArrayAndTrimString:NO stringIsComplete:YES]) + while ((csvRowArray = [self getRowAsArrayAndTrimString:NO stringIsComplete:YES])) { CFArrayAppendValue((CFMutableArrayRef)csvArray, csvRowArray); } @@ -603,7 +603,7 @@ #pragma mark - - (id) init { - if (self = [super init]) { + if ((self = [super init])) { csvString = [[NSMutableString alloc] init]; [self _initialiseCSVParserDefaults]; } @@ -611,14 +611,14 @@ } - (id) initWithString:(NSString *)aString { - if (self = [super init]) { + if ((self = [super init])) { csvString = [[NSMutableString alloc] initWithString:aString]; [self _initialiseCSVParserDefaults]; } return self; } - (id) initWithContentsOfFile:(NSString *)path encoding:(NSStringEncoding)encoding error:(NSError **)error { - if (self = [super init]) { + if ((self = [super init])) { csvString = [[NSMutableString alloc] initWithContentsOfFile:path encoding:encoding error:error]; [self _initialiseCSVParserDefaults]; } diff --git a/Source/SPChooseMenuItemDialog.m b/Source/SPChooseMenuItemDialog.m index 8be639e3..d57abe94 100644 --- a/Source/SPChooseMenuItemDialog.m +++ b/Source/SPChooseMenuItemDialog.m @@ -37,7 +37,7 @@ } - (id)init; { - if(self = [super initWithFrame:NSMakeRect(1,1,2,2)]) + if((self = [super initWithFrame:NSMakeRect(1,1,2,2)])) { ; } @@ -65,8 +65,8 @@ - (id)init; { - if(self = [super initWithContentRect:NSMakeRect(1,1,2,2) - styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]) + if((self = [super initWithContentRect:NSMakeRect(1,1,2,2) + styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO])) { waitForChoice = YES; selectedItemIndex = -1; @@ -86,7 +86,7 @@ [self setLevel:NSNormalWindowLevel]; [self setHidesOnDeactivate:YES]; [self setHasShadow:YES]; - [self setAlphaValue:0.0]; + [self setAlphaValue:0.0f]; dummyTextView = [[SPChooseMenuItemDialogTextView alloc] init]; [dummyTextView setDelegate:self]; @@ -138,7 +138,7 @@ context:[NSGraphicsContext currentContext] eventNumber:0 clickCount:1 - pressure:0.0]; + pressure:0.0f]; [[NSApplication sharedApplication] sendEvent:theEvent]; diff --git a/Source/SPColorWellCell.m b/Source/SPColorWellCell.m index ce47ef83..ca466e98 100644 --- a/Source/SPColorWellCell.m +++ b/Source/SPColorWellCell.m @@ -29,7 +29,7 @@ - (void) drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { // Set initial inset from cellFrame - NSRect rect = NSInsetRect (cellFrame, 0.5, 0.5); + NSRect rect = NSInsetRect (cellFrame, 0.5f, 0.5f); // General inset for colored rect shown inside rect CGFloat insetFactor = 2.0f; @@ -38,7 +38,7 @@ [[NSColor darkGrayColor] set]; [NSBezierPath strokeRect: rect]; [[NSColor grayColor] set]; - [NSBezierPath fillRect: NSInsetRect (rect, 1.0, 1.0)]; + [NSBezierPath fillRect: NSInsetRect (rect, 1.0f, 1.0f)]; // The following rectangle and triangle are needed for displaying color with alpha values // Draw black rectangle diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index d3c75e16..b5ab8010 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -35,6 +35,9 @@ #import "SPTableTextFieldCell.h" #import "SPFavoritesController.h" #import "SPFavoriteNode.h" +#import "SPGeneralPreferencePane.h" +#import "SPDatabaseViewController.h" +#import "SPTreeNode.h" // Constants static const NSString *SPRemoveNode = @"RemoveNode"; @@ -101,7 +104,7 @@ static NSComparisonResult compareFavoritesUsingKey(id favorite1, id favorite2, v */ - (id)initWithDocument:(SPDatabaseDocument *)document { - if (self = [super init]) { + if ((self = [super init])) { // Weak reference dbDocument = document; @@ -533,7 +536,7 @@ static NSComparisonResult compareFavoritesUsingKey(id favorite1, id favorite2, v // Perform re-sorting [self _sortFavorites]; - [sender setState:reverseFavoritesSort]; + [(NSMenuItem *)sender setState:reverseFavoritesSort]; } /** @@ -1039,8 +1042,6 @@ static NSComparisonResult compareFavoritesUsingKey(id favorite1, id favorite2, v NSString *favoriteSSHHost = [favorite objectForKey:SPFavoriteSSHHostKey]; NSString *favoriteID = [favorite objectForKey:SPFavoriteIDKey]; - NSInteger favoriteType = [[favorite objectForKey:SPFavoriteTypeKey] integerValue]; - // Remove passwords from the Keychain [keychain deletePasswordForName:[keychain nameForFavoriteName:favoriteName id:favoriteID] account:[keychain accountForUser:favoriteUser host:((type == SPSocketConnection) ? @"localhost" : favoriteHost) database:favoriteDatabase]]; @@ -1351,16 +1352,18 @@ static NSComparisonResult compareFavoritesUsingKey(id favorite1, id favorite2, v */ - (SPTreeNode *)_favoriteNodeForFavoriteID:(NSInteger)favoriteID { - SPTreeNode *node = nil; + SPTreeNode *favoriteNode = nil; - if (!favoritesRoot) return; + if (!favoritesRoot) return favoriteNode; - for (node in [favoritesRoot allChildLeafs]) + for (SPTreeNode *node in [favoritesRoot allChildLeafs]) { if ([[[[node representedObject] nodeFavorite] objectForKey:SPFavoriteIDKey] integerValue] == favoriteID) { - return node; + favoriteNode = node; } } + + return favoriteNode; } /** diff --git a/Source/SPConnectionControllerDataSource.m b/Source/SPConnectionControllerDataSource.m index 9249d65d..766b04f0 100644 --- a/Source/SPConnectionControllerDataSource.m +++ b/Source/SPConnectionControllerDataSource.m @@ -24,6 +24,10 @@ // More info at <http://code.google.com/p/sequel-pro/> #import "SPConnectionControllerDataSource.h" +#import "SPFavoritesController.h" +#import "SPFavoriteNode.h" +#import "SPGroupNode.h" +#import "SPTreeNode.h" @implementation SPConnectionController (SPConnectionControllerDataSource) diff --git a/Source/SPConnectionControllerDelegate.m b/Source/SPConnectionControllerDelegate.m index 4bff297a..31ec4099 100644 --- a/Source/SPConnectionControllerDelegate.m +++ b/Source/SPConnectionControllerDelegate.m @@ -27,6 +27,7 @@ #import "SPTableTextFieldCell.h" #import "SPFavoriteNode.h" #import "SPGroupNode.h" +#import "SPTreeNode.h" #define CELL(cell) (SPTableTextFieldCell *)cell diff --git a/Source/SPConnectionDelegate.h b/Source/SPConnectionDelegate.h index deb28e68..c1d3bb5e 100644 --- a/Source/SPConnectionDelegate.h +++ b/Source/SPConnectionDelegate.h @@ -29,4 +29,6 @@ @interface SPDatabaseDocument (SPConnectionDelegate) <MCPConnectionDelegate> +- (void) closeAndDisconnect; + @end diff --git a/Source/SPConstants.m b/Source/SPConstants.m index df1d71dc..6e8f8b2d 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -26,7 +26,7 @@ #import "SPConstants.h" // Long running notification time for Growl messages -const CGFloat SPLongRunningNotificationTime = 3.0; +const CGFloat SPLongRunningNotificationTime = 3.0f; // Narrow down completion max rows const NSUInteger SPNarrowDownCompletionMaxRows = 15; diff --git a/Source/SPContentFilterManager.m b/Source/SPContentFilterManager.m index cf71b741..d08bb241 100644 --- a/Source/SPContentFilterManager.m +++ b/Source/SPContentFilterManager.m @@ -29,6 +29,7 @@ #import "SPQueryController.h" #import "SPTableContent.h" #import "SPConnectionController.h" +#import <BWToolkitFramework/BWToolkitFramework.h> #define SP_MULTIPLE_SELECTION_PLACEHOLDER_STRING NSLocalizedString(@"[multiple selection]", @"[multiple selection]") #define SP_NO_SELECTION_PLACEHOLDER_STRING NSLocalizedString(@"[no selection]", @"[no selection]") diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m index 3b84d867..b69f23a1 100644 --- a/Source/SPCopyTable.m +++ b/Source/SPCopyTable.m @@ -23,6 +23,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #import <MCPKit/MCPKit.h> +#import "MCPGeometryData.h" #import "SPCopyTable.h" #import "SPTableContent.h" @@ -35,6 +36,8 @@ #import "SPAlertSheets.h" #import "SPBundleHTMLOutputController.h" #import "SPGeometryDataView.h" +#import "SPBundleEditorController.h" +#import "SPAppController.h" NSInteger MENU_EDIT_COPY = 2001; NSInteger MENU_EDIT_COPY_WITH_COLUMN = 2002; @@ -157,7 +160,6 @@ NSInteger kBlobAsImageFile = 4; // Loop through the rows, adding their descriptive contents NSUInteger rowIndex = [selectedRows firstIndex]; NSString *nullString = [prefs objectForKey:SPNullValue]; - NSStringEncoding connectionEncoding = [mySQLConnection encoding]; Class mcpGeometryData = [MCPGeometryData class]; NSUInteger rowCounter = 0; @@ -296,7 +298,6 @@ NSInteger kBlobAsImageFile = 4; // Loop through the rows, adding their descriptive contents NSUInteger rowIndex = [selectedRows firstIndex]; NSString *nullString = [prefs objectForKey:SPNullValue]; - NSStringEncoding connectionEncoding = [mySQLConnection encoding]; Class mcpGeometryData = [MCPGeometryData class]; NSUInteger rowCounter = 0; @@ -699,7 +700,7 @@ NSInteger kBlobAsImageFile = 4; NSUInteger allColumnWidths = 0; // Determine the available size - NSScrollView *parentScrollView = [[self superview] superview]; + NSScrollView *parentScrollView = (NSScrollView*)[[self superview] superview]; CGFloat visibleTableWidth = [parentScrollView bounds].size.width - [NSScroller scrollerWidth] - [columnDefinitions count] * 3.5; for (NSDictionary *columnDefinition in columnDefinitions) { @@ -1147,7 +1148,6 @@ NSInteger kBlobAsImageFile = 4; NSString *cmd = [cmdData objectForKey:SPBundleFileCommandKey]; NSString *inputAction = @""; NSString *inputFallBackAction = @""; - NSString *withBlobHandling = @""; NSError *err = nil; NSString *uuid = [NSString stringWithNewUUID]; NSString *bundleInputFilePath = [NSString stringWithFormat:@"%@_%@", SPBundleTaskInputFilePath, uuid]; diff --git a/Source/SPCustomQuery.h b/Source/SPCustomQuery.h index 317db0c9..26d0a60c 100644 --- a/Source/SPCustomQuery.h +++ b/Source/SPCustomQuery.h @@ -63,7 +63,7 @@ IBOutlet NSWindow *queryFavoritesSheet; IBOutlet NSButton *saveQueryFavoriteButton; IBOutlet NSTextField *queryFavoriteNameTextField; - IBOutlet id saveQueryFavoriteGlobal; + IBOutlet NSButton *saveQueryFavoriteGlobal; IBOutlet id queryHistoryButton; IBOutlet NSMenuItem *queryHistorySearchMenuItem; @@ -239,6 +239,9 @@ - (void) startDocumentTaskForTab:(NSNotification *)aNotification; - (void) endDocumentTaskForTab:(NSNotification *)aNotification; +// Tableview interaction +- (void)tableSortCallback; + // Other - (void)setConnection:(MCPConnection *)theConnection; - (void)doPerformQueryService:(NSString *)query; diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m index c43df1cd..7005e690 100644 --- a/Source/SPCustomQuery.m +++ b/Source/SPCustomQuery.m @@ -167,7 +167,7 @@ // If carriage returns were found, normalise the queries if ([queryParser containsCarriageReturns]) { NSMutableArray *normalisedQueries = [NSMutableArray arrayWithCapacity:[queries count]]; - for (NSString *query in queries) { + for (query in queries) { [normalisedQueries addObject:[SPSQLParser normaliseQueryForExecution:query]]; } queries = normalisedQueries; @@ -534,7 +534,7 @@ SEL callbackMethod = NULL; NSString *taskButtonString; - NSInteger i, totalQueriesRun = 0, totalAffectedRows = 0; + NSUInteger i, totalQueriesRun = 0, totalAffectedRows = 0; double executionTime = 0; NSInteger firstErrorOccuredInQuery = -1; BOOL suppressErrorSheet = NO; @@ -633,7 +633,7 @@ } // Record any affected rows - if ( [mySQLConnection affectedRows] != -1 ) + if ( [mySQLConnection affectedRows] >= 0 ) totalAffectedRows += [mySQLConnection affectedRows]; else if ( [streamingResult numOfRows] ) totalAffectedRows += [streamingResult numOfRows]; @@ -893,7 +893,7 @@ dataLoadingPool = [[NSAutoreleasePool alloc] init]; // Loop through the result rows as they become available - while (tempRow = [theResult fetchNextRowAsArray]) { + while ((tempRow = [theResult fetchNextRowAsArray])) { pthread_mutex_lock(&resultDataLock); SPDataStorageAddRow(resultData, tempRow); @@ -937,8 +937,8 @@ NSCharacterSet *whitespaceAndNewlineSet = [NSCharacterSet whitespaceAndNewlineCharacterSet]; NSCharacterSet *whitespaceSet = [NSCharacterSet whitespaceCharacterSet]; - // If the supplied position is negative or beyond the end of the string, return nil. - if (position < 0 || position > [[textView string] length]) + // If the supplied position is beyond the end of the string, return nil. + if (position > [[textView string] length]) return NSMakeRange(NSNotFound, 0); // Split the current text into ranges of queries @@ -1054,8 +1054,8 @@ SPSQLParser *customQueryParser; NSArray *queries; - // If the supplied position is negative or beyond the end of the string, return nil. - if (position < 0 || position > [[textView string] length]) + // If the supplied position beyond the end of the string, return nil. + if (position > [[textView string] length]) return NSMakeRange(NSNotFound,0); // Split the current text into ranges of queries @@ -1314,7 +1314,7 @@ */ - (void) initQueryLoadTimer { - if (queryLoadTimer) [self clearTableLoadTimer]; + if (queryLoadTimer) [self clearQueryLoadTimer]; queryLoadInterfaceUpdateInterval = 1; queryLoadLastRowCount = 0; queryLoadTimerTicksSinceLastUpdate = 0; @@ -1750,7 +1750,7 @@ [database backtickQuotedString], [tableForColumn backtickQuotedString]]]; [theResult setReturnDataAsStrings:YES]; if ([theResult numOfRows]) [theResult dataSeek:0]; - NSInteger i; + NSUInteger i; for ( i = 0 ; i < [theResult numOfRows] ; i++ ) { theRow = [theResult fetchRowAsDictionary]; if ( [[theRow objectForKey:@"Key"] isEqualToString:@"PRI"] ) { @@ -2056,7 +2056,7 @@ // Remove all quoted strings as a temp string to match the correct clauses NSRange matchedRange; - NSInteger i; + NSUInteger i; NSMutableString *tmpString = [NSMutableString stringWithString:queryString]; NSMutableString *qq = [NSMutableString string]; matchedRange = [tmpString rangeOfRegex:@"\"(?:[^\"\\\\]*+|\\\\.)*\""]; @@ -2333,7 +2333,7 @@ isFieldEditable = ([[editStatus objectAtIndex:0] integerValue] == 1) ? YES : NO; NSString *fieldType = nil; - NSUInteger *fieldLength = 0; + NSUInteger fieldLength = 0; NSString *fieldEncoding = nil; BOOL allowNULL = YES; @@ -3158,9 +3158,11 @@ // Remove all needless default menu items NSEnumerator *itemEnumerator = [defaultMenuItems objectEnumerator]; NSMenuItem *menuItem = nil; - while (menuItem = [itemEnumerator nextObject]) + + while ((menuItem = [itemEnumerator nextObject])) { NSInteger tag = [menuItem tag]; + switch (tag) { case 2000: // WebMenuItemTagOpenLink @@ -3639,7 +3641,7 @@ */ - (IBAction)filterQueryFavorites:(id)sender { - NSUInteger i; + NSInteger i; NSMenu *menu = [queryFavoritesButton menu]; NSString *searchPattern = [queryFavoritesSearchField stringValue]; @@ -3723,8 +3725,6 @@ shouldBeginEditing = NO; } - NSString *fieldType; - BOOL isBlob = NO; // Check if current field is a blob diff --git a/Source/SPDataAdditions.m b/Source/SPDataAdditions.m index b0a4e6d2..805692c6 100644 --- a/Source/SPDataAdditions.m +++ b/Source/SPDataAdditions.m @@ -57,8 +57,8 @@ static char base64encodingTable[64] = { NSUInteger lentext = [self length]; NSInteger ctremaining = 0; unsigned char inbuf[3], outbuf[4]; - short i = 0; - short charsonline = 0, ctcopy = 0; + NSUInteger i = 0; + NSUInteger charsonline = 0, ctcopy = 0; NSUInteger ix = 0; NSMutableString *base64 = [NSMutableString stringWithCapacity:lentext]; @@ -111,7 +111,7 @@ static char base64encodingTable[64] = { - (NSData *)dataEncryptedWithPassword:(NSString *)password { // Create a random 128-bit initialization vector - srand(time(NULL)); + srand((unsigned int)time(NULL)); NSInteger ivIndex; unsigned char iv[16]; for (ivIndex = 0; ivIndex < 16; ivIndex++) @@ -131,7 +131,7 @@ static char base64encodingTable[64] = { memcpy(paddedBytes, [self bytes], dataLength); // The last 32-bit chunk is the size of the plaintext, which is encrypted with the plaintext - NSInteger bigIntDataLength = NSSwapHostIntToBig(dataLength); + NSInteger bigIntDataLength = NSSwapHostIntToBig((unsigned int)dataLength); memcpy(paddedBytes + (paddedLength - 4), &bigIntDataLength, 4); // Create the key from first 128-bits of the 160-bit password hash @@ -180,7 +180,7 @@ static char base64encodingTable[64] = { // Get the size of the data from the last 32-bit chunk NSInteger bigIntDataLength = *((UInt32*)decryptedBytes + ((encryptedLength / 4) - 1)); - NSInteger dataLength = NSSwapBigIntToHost(bigIntDataLength); + NSInteger dataLength = NSSwapBigIntToHost((unsigned int)bigIntDataLength); return [NSData dataWithBytesNoCopy:decryptedBytes length:dataLength]; } @@ -198,7 +198,7 @@ static char base64encodingTable[64] = { z_stream zlibStream; zlibStream.next_in = (Bytef *)[self bytes]; - zlibStream.avail_in = [self length]; + zlibStream.avail_in = (uInt)[self length]; zlibStream.total_out = 0; zlibStream.zalloc = Z_NULL; zlibStream.zfree = Z_NULL; @@ -210,7 +210,7 @@ static char base64encodingTable[64] = { if (zlibStream.total_out >= [unzipData length]) [unzipData increaseLengthBy: half_length]; zlibStream.next_out = [unzipData mutableBytes] + zlibStream.total_out; - zlibStream.avail_out = [unzipData length] - zlibStream.total_out; + zlibStream.avail_out = (uInt)([unzipData length] - zlibStream.total_out); status = inflate (&zlibStream, Z_SYNC_FLUSH); if (status == Z_STREAM_END) done = YES; @@ -238,7 +238,7 @@ static char base64encodingTable[64] = { zlibStream.opaque = Z_NULL; zlibStream.total_out = 0; zlibStream.next_in=(Bytef *)[self bytes]; - zlibStream.avail_in = [self length]; + zlibStream.avail_in = (uInt)[self length]; if (deflateInit(&zlibStream, Z_DEFAULT_COMPRESSION) != Z_OK) return nil; @@ -251,7 +251,7 @@ static char base64encodingTable[64] = { [zipData increaseLengthBy: 16384]; zlibStream.next_out = [zipData mutableBytes] + zlibStream.total_out; - zlibStream.avail_out = [zipData length] - zlibStream.total_out; + zlibStream.avail_out = (uInt)([zipData length] - zlibStream.total_out); deflate(&zlibStream, Z_FINISH); diff --git a/Source/SPDataCellFormatter.h b/Source/SPDataCellFormatter.h index a2ba23b1..c5d9cd99 100644 --- a/Source/SPDataCellFormatter.h +++ b/Source/SPDataCellFormatter.h @@ -29,7 +29,7 @@ NSString *fieldType; } -@property NSInteger textLimit; -@property NSString* fieldType; +@property(readwrite, assign) NSInteger textLimit; +@property(readwrite, retain) NSString* fieldType; @end diff --git a/Source/SPDataCellFormatter.m b/Source/SPDataCellFormatter.m index 515bf2a7..0180227b 100644 --- a/Source/SPDataCellFormatter.m +++ b/Source/SPDataCellFormatter.m @@ -91,4 +91,11 @@ return YES; } +- (void)dealloc +{ + if (fieldType) [fieldType release], fieldType = nil; + + [super dealloc]; +} + @end diff --git a/Source/SPDataImport.m b/Source/SPDataImport.m index bfde3a26..0667ac07 100644 --- a/Source/SPDataImport.m +++ b/Source/SPDataImport.m @@ -39,6 +39,7 @@ #import "SPFileHandle.h" #import "SPEncodingPopupAccessory.h" +#import <MCPKit/MCPKit.h> #import <UniversalDetector/UniversalDetector.h> #define SP_FILE_READ_ERROR_STRING NSLocalizedString(@"File read error", @"File read error title (Import Dialog)") @@ -363,7 +364,6 @@ NSInteger dataBufferPosition = 0; NSInteger dataBufferLastQueryEndPosition = 0; BOOL fileIsCompressed; - BOOL importSQLAsUTF8 = YES; BOOL allDataRead = NO; BOOL ignoreSQLErrors = ([importSQLErrorHandlingPopup selectedTag] == SPSQLImportIgnoreErrors); NSStringEncoding sqlEncoding = NSUTF8StringEncoding; diff --git a/Source/SPDataStorage.m b/Source/SPDataStorage.m index f03fbd7a..26bcc79e 100644 --- a/Source/SPDataStorage.m +++ b/Source/SPDataStorage.m @@ -379,7 +379,7 @@ static inline void SPDataStorageEnsureCapacityForAdditionalRowCount(SPDataStorag #pragma mark - - (id) init { - if (self = [super init]) { + if ((self = [super init])) { numColumns = 0; columnPointerByteSize = 0; numRows = 0; diff --git a/Source/SPDatabaseCopy.m b/Source/SPDatabaseCopy.m index 40192156..66b6ba1b 100644 --- a/Source/SPDatabaseCopy.m +++ b/Source/SPDatabaseCopy.m @@ -99,6 +99,7 @@ - (void)dealloc { [dbInfo release], dbInfo = nil; + [super dealloc]; } -@end
\ No newline at end of file +@end diff --git a/Source/SPDatabaseDocument.h b/Source/SPDatabaseDocument.h index 3459b9b8..efc3f25e 100644 --- a/Source/SPDatabaseDocument.h +++ b/Source/SPDatabaseDocument.h @@ -35,7 +35,7 @@ SPWindowController, SPServerSupport; -@protocol SPConnectionControllerDelegateProtocol; +#import "SPConnectionControllerDelegateProtocol.h" /** * The SPDatabaseDocument class controls the primary database view window. @@ -305,6 +305,8 @@ - (IBAction)showUserManager:(id)sender; - (IBAction)copyChecksumFromSheet:(id)sender; - (void)setIsSavedInBundle:(BOOL)savedInBundle; +- (void)setFileURL:(NSURL *)fileURL; +- (void)connect; - (void)showConsole:(id)sender; - (IBAction)showNavigator:(id)sender; @@ -321,6 +323,8 @@ - (NSString *)connectionID; - (NSString *)tabTitleForTooltip; - (BOOL)isSaveInBundle; +- (NSURL *)fileURL; +- (NSString *)displayName; // Notification center methods - (void)willPerformQuery:(NSNotification *)notification; diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index 4bc82a21..af639127 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -56,7 +56,10 @@ #import "SPDatabaseRename.h" #import "SPServerSupport.h" #import "SPTooltip.h" - +#import "SPDatabaseViewController.h" +#import "SPBundleHTMLOutputController.h" +#import "SPConnectionDelegate.h" +#import "SPWindowController.h" @interface SPDatabaseDocument (PrivateAPI) @@ -2787,15 +2790,19 @@ [alert setAlertStyle:NSCriticalAlertStyle]; [alert runModal]; - return NO; + + return; } NSError *error = nil; + [plist writeToFile:[NSString stringWithFormat:@"%@/info.plist", fileName] options:NSAtomicWrite error:&error]; + if(error != nil){ NSAlert *errorAlert = [NSAlert alertWithError:error]; [errorAlert runModal]; - return NO; + + return; } [[NSApp delegate] setSessionURL:fileName]; @@ -3306,7 +3313,6 @@ */ - (void) updateWindowTitle:(id)sender { - // Ensure a call on the main thread if (![NSThread isMainThread]) return [[self onMainThread] updateWindowTitle:sender]; @@ -4721,7 +4727,7 @@ BOOL isDir; if([fm fileExistsAtPath:queryFileName isDirectory:&isDir] && !isDir) { NSError *inError = nil; - NSString *query = [NSString stringWithContentsOfFile:queryFileName encoding:NSUTF8StringEncoding error:inError]; + NSString *query = [NSString stringWithContentsOfFile:queryFileName encoding:NSUTF8StringEncoding error:&inError]; [fm removeItemAtPath:queryFileName error:nil]; if(inError == nil && query && [query length]) { [tableContentInstance filterTable:query]; @@ -4741,7 +4747,6 @@ NSString *statusFileName = [NSString stringWithFormat:@"%@%@", SPURLSchemeQueryResultStatusPathHeader, docProcessID]; NSFileManager *fm = [NSFileManager defaultManager]; NSString *status = @"0"; - BOOL isDir; BOOL userTerminated = NO; BOOL doSyntaxHighlighting = NO; BOOL doSyntaxHighlightingViaCSS = NO; @@ -4890,7 +4895,7 @@ if([fm fileExistsAtPath:queryFileName isDirectory:&isDir] && !isDir) { NSError *inError = nil; - NSString *query = [NSString stringWithContentsOfFile:queryFileName encoding:NSUTF8StringEncoding error:inError]; + NSString *query = [NSString stringWithContentsOfFile:queryFileName encoding:NSUTF8StringEncoding error:&inError]; [fm removeItemAtPath:queryFileName error:nil]; [fm removeItemAtPath:resultFileName error:nil]; diff --git a/Source/SPDatabaseRename.m b/Source/SPDatabaseRename.m index dc5a8967..b7aa3f73 100644 --- a/Source/SPDatabaseRename.m +++ b/Source/SPDatabaseRename.m @@ -25,6 +25,7 @@ #import "SPDBActionCommons.h" #import "SPDatabaseRename.h" #import "SPTableCopy.h" +#import "SPDatabaseInfo.h" @implementation SPDatabaseRename @@ -111,6 +112,7 @@ - (void)dealloc { [dbInfo release], dbInfo = nil; + [super dealloc]; } -@end
\ No newline at end of file +@end diff --git a/Source/SPDatabaseViewController.h b/Source/SPDatabaseViewController.h index 14dd5e88..f7d795ca 100644 --- a/Source/SPDatabaseViewController.h +++ b/Source/SPDatabaseViewController.h @@ -29,7 +29,6 @@ @interface SPDatabaseDocument (SPDatabaseViewController) // Getters -- (NSView *)parentView; - (NSString *)table; - (NSInteger)tableType; - (BOOL)structureLoaded; @@ -50,4 +49,6 @@ // Table control - (void)loadTable:(NSString *)aTable ofType:(NSInteger)aTableType; +- (NSView *)databaseView; + @end diff --git a/Source/SPDatabaseViewController.m b/Source/SPDatabaseViewController.m index a6600d3f..88928897 100644 --- a/Source/SPDatabaseViewController.m +++ b/Source/SPDatabaseViewController.m @@ -23,8 +23,15 @@ // // More info at <http://code.google.com/p/sequel-pro/> +#import "SPAppController.h" +#import "SPBundleHTMLOutputController.h" +#import "SPCopyTable.h" #import "SPDatabaseViewController.h" +#import "SPHistoryController.h" +#import "SPTableContent.h" #import "SPTableData.h" +#import "SPTablesList.h" +#import "SPTableTriggers.h" @interface SPDatabaseDocument (SPDatabaseViewControllerPrivateAPI) @@ -490,7 +497,7 @@ // For HTML output check if corresponding window already exists BOOL stopTrigger = NO; - if([[data objectAtIndex:2] length]) { + if([(NSString*)[data objectAtIndex:2] length]) { BOOL correspondingWindowFound = NO; NSString *uuid = [data objectAtIndex:2]; for(id win in [NSApp windows]) { @@ -522,4 +529,4 @@ [loadPool drain]; } -@end
\ No newline at end of file +@end diff --git a/Source/SPEditSheetTextView.m b/Source/SPEditSheetTextView.m index 95fcd51d..7a4fb37c 100644 --- a/Source/SPEditSheetTextView.m +++ b/Source/SPEditSheetTextView.m @@ -30,9 +30,8 @@ - (id)init { - if(self = [super init]) + if((self = [super init])) { - ; } return self; } diff --git a/Source/SPEditorPreferencePane.h b/Source/SPEditorPreferencePane.h index d7cb1eb4..6e94d9eb 100644 --- a/Source/SPEditorPreferencePane.h +++ b/Source/SPEditorPreferencePane.h @@ -63,7 +63,6 @@ } - (IBAction)showCustomQueryFontPanel:(id)sender; -- (IBAction)showGlobalResultTableFontPanel:(id)sender; - (IBAction)setDefaultColors:(id)sender; - (IBAction)exportColorScheme:(id)sender; - (IBAction)importColorScheme:(id)sender; diff --git a/Source/SPEditorPreferencePane.m b/Source/SPEditorPreferencePane.m index 50388e8a..0cae1217 100644 --- a/Source/SPEditorPreferencePane.m +++ b/Source/SPEditorPreferencePane.m @@ -30,14 +30,14 @@ #import "SPCategoryAdditions.h" // Constants -static const NSString *SPImportColorScheme = @"ImportColorScheme"; -static const NSString *SPExportColorScheme = @"ExportColorScheme"; -static const NSString *SPSaveColorScheme = @"SaveColorScheme"; -static const NSString *SPDefaultColorSchemeName = @"Default"; -static const NSString *SPDefaultColorSchemeNameLC = @"default"; -static const NSString *SPCustomColorSchemeName = @"User-defined"; -static const NSString *SPCustomColorSchemeNameLC = @"user-defined"; -static const NSString *SPDefaultExportColourSchemeName = @"MyTheme"; +static NSString *SPImportColorScheme = @"ImportColorScheme"; +static NSString *SPExportColorScheme = @"ExportColorScheme"; +static NSString *SPSaveColorScheme = @"SaveColorScheme"; +static NSString *SPDefaultColorSchemeName = @"Default"; +static NSString *SPDefaultColorSchemeNameLC = @"default"; +static NSString *SPCustomColorSchemeName = @"User-defined"; +static NSString *SPCustomColorSchemeNameLC = @"user-defined"; +static NSString *SPDefaultExportColourSchemeName = @"MyTheme"; @interface SPEditorPreferencePane (PrivateAPI) @@ -517,7 +517,7 @@ static const NSString *SPDefaultExportColourSchemeName = @"MyTheme"; } } -- (void)panelDidEnd:(NSSavePanel *)panel returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo +- (void)panelDidEnd:(NSOpenPanel *)panel returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo { if ([contextInfo isEqualToString:SPExportColorScheme]) { if (returnCode == NSOKButton) { @@ -546,7 +546,7 @@ static const NSString *SPDefaultExportColourSchemeName = @"MyTheme"; return [editThemeListItems count]; } - return nil; + return 0; } - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex @@ -806,11 +806,7 @@ static const NSString *SPDefaultExportColourSchemeName = @"MyTheme"; NSMutableDictionary *scheme = [NSMutableDictionary dictionary]; NSMutableDictionary *mainsettings = [NSMutableDictionary dictionary]; NSMutableArray *settings = [NSMutableArray array]; - - CGFloat red, green, blue, alpha; - NSInteger redInt, greenInt, blueInt, alphaInt; - NSString *redHexValue, *greenHexValue, *blueHexValue, *alphaHexValue; - + [prefs synchronize]; NSColor *aColor = [NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorBackgroundColor]]; diff --git a/Source/SPEditorTokens.l b/Source/SPEditorTokens.l index 7b19804a..67491351 100644 --- a/Source/SPEditorTokens.l +++ b/Source/SPEditorTokens.l @@ -41,12 +41,11 @@ size_t utf8strlen(const char * _s); size_t yyuoffset, yyuleng; -#define YY_NO_UNPUT - //keep track of the current utf-8 character (not byte) offset and token length #define YY_USER_ACTION { yyuoffset += yyuleng; yyuleng = utf8strlen(yytext); } %} %option noyywrap +%option nounput %option case-insensitive s [ \t\n\r]+ diff --git a/Source/SPExportController.m b/Source/SPExportController.m index 9081b942..04138c75 100644 --- a/Source/SPExportController.m +++ b/Source/SPExportController.m @@ -33,6 +33,8 @@ #import "SPGrowlController.h" #import "SPExportFile.h" #import "SPAlertSheets.h" +#import "SPExportFilenameUtilities.h" +#import "SPDatabaseDocument.h" // Constants static const NSUInteger SPExportUIPadding = 20; @@ -775,7 +777,6 @@ static const NSString *SPTableViewDropColumnID = @"drop"; NSUInteger padding = (2 * SPExportUIPadding); CGFloat width = (!display) ? (windowFrame.size.width - (padding + 2)) : (windowFrame.size.width - ([exportOptionsTabBar frame].size.width + (padding + 4))); - CGFloat width2 = (!display) ? (windowFrame.size.width - (padding + 2)) : (windowFrame.size.width - ([exportTableListButtonBar frame].size.width + (padding + 4))); [NSAnimationContext beginGrouping]; [[NSAnimationContext currentContext] setDuration:0.3]; @@ -803,7 +804,6 @@ static const NSString *SPTableViewDropColumnID = @"drop"; BOOL isXML = (exportType == SPXMLExport); BOOL isHTML = (exportType == SPHTMLExport); BOOL isPDF = (exportType == SPPDFExport); - BOOL isDot = (exportType == SPDotExport); BOOL structureEnabled = [[uiStateDict objectForKey:@"SQLExportStructureEnabled"] integerValue]; BOOL contentEnabled = [[uiStateDict objectForKey:@"SQLExportContentEnabled"] integerValue]; diff --git a/Source/SPExportControllerDelegate.m b/Source/SPExportControllerDelegate.m index 575bb0f9..8f4977a6 100644 --- a/Source/SPExportControllerDelegate.m +++ b/Source/SPExportControllerDelegate.m @@ -24,6 +24,15 @@ // More info at <http://code.google.com/p/sequel-pro/> #import "SPExportControllerDelegate.h" +#import "SPExportFilenameUtilities.h" + +// Defined to suppress warnings +@interface SPExportController (SPExportControllerPrivateAPI) + +- (void)_toggleExportButtonOnBackgroundThread; +- (void)_switchTab; + +@end @implementation SPExportController (SPExportControllerDelegate) diff --git a/Source/SPExportFile.m b/Source/SPExportFile.m index 7e77d5de..4ccfa16c 100644 --- a/Source/SPExportFile.m +++ b/Source/SPExportFile.m @@ -24,6 +24,7 @@ // More info at <http://code.google.com/p/sequel-pro/> #import "SPExportFile.h" +#import "SPFileHandle.h" @interface SPExportFile (PrivateAPI) diff --git a/Source/SPExportFileUtilities.m b/Source/SPExportFileUtilities.m index 5a9d16ee..d39aee17 100644 --- a/Source/SPExportFileUtilities.m +++ b/Source/SPExportFileUtilities.m @@ -26,6 +26,9 @@ #import "SPExportFileUtilities.h" #import "SPExporter.h" #import "SPAlertSheets.h" +#import "SPExportFile.h" +#import "SPDatabaseDocument.h" +#import "SPCustomQuery.h" @implementation SPExportController (SPExportFileUtilities) @@ -135,8 +138,17 @@ } } } - - + + // Compare the count of exported files to the count of failed files + NSUInteger totalFilesExported = [exportFiles count]; + + // If all the files failed, show a simplified export dialog + + + // If only some of the files failed, show an export dialog with the option to ignore the failed files. + + + // For single files, show a dialog very close to the OS dialog if (i > 0) { NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Error creating export files", @"export file handle creation error message") diff --git a/Source/SPExportFilenameUtilities.m b/Source/SPExportFilenameUtilities.m index 0695d29e..7ce7b3a2 100644 --- a/Source/SPExportFilenameUtilities.m +++ b/Source/SPExportFilenameUtilities.m @@ -78,7 +78,7 @@ filename = @"query_result"; break; case SPTableExport: - filename = [tableDocumentInstance database]; + filename = [NSString stringWithFormat:@"%@_%@", [tableDocumentInstance database], [[NSDate date] descriptionWithCalendarFormat:@"%Y-%m-%d" timeZone:nil locale:nil]]; break; } diff --git a/Source/SPExportInitializer.m b/Source/SPExportInitializer.m index db951b5f..f1868210 100644 --- a/Source/SPExportInitializer.m +++ b/Source/SPExportInitializer.m @@ -38,6 +38,10 @@ #import "SPSQLExporter.h" #import "SPXMLExporter.h" #import "SPDotExporter.h" +#import "SPConnectionControllerDelegateProtocol.h" +#import "SPExportFile.h" +#import "SPExportFileUtilities.h" +#import "SPExportFilenameUtilities.h" @implementation SPExportController (SPExportInitializer) @@ -174,7 +178,6 @@ */ - (void)exportTables:(NSArray *)exportTables orDataArray:(NSArray *)dataArray { - NSUInteger i; BOOL singleFileHandleSet = NO; SPExportFile *singleExportFile = nil, *file = nil; @@ -277,7 +280,7 @@ [sqlExporter setSqlExportTables:exportTables]; // Create custom filename if required - [exportFilename setString:(createCustomFilename) ? [self expandCustomFilenameFormatFromString:[exportCustomFilenameTokenField stringValue] usingTableName:nil] : [NSString stringWithFormat:@"%@_%@", [tableDocumentInstance database], [[NSDate date] descriptionWithCalendarFormat:@"%Y-%m-%d" timeZone:nil locale:nil]]]; + [exportFilename setString:(createCustomFilename) ? [self expandCustomFilenameFormatFromString:[exportCustomFilenameTokenField stringValue] usingTableName:nil] : [self generateDefaultExportFilename]]; [exportFilename setString:[exportFilename stringByAppendingPathExtension:[self currentDefaultExportFileExtension]]]; diff --git a/Source/SPExporter.m b/Source/SPExporter.m index e0e862fa..3be120b0 100644 --- a/Source/SPExporter.m +++ b/Source/SPExporter.m @@ -24,6 +24,7 @@ // More info at <http://code.google.com/p/sequel-pro/> #import "SPExporter.h" +#import "SPExportFile.h" @implementation SPExporter diff --git a/Source/SPFieldEditorController.h b/Source/SPFieldEditorController.h index 568ba629..b7e499cf 100644 --- a/Source/SPFieldEditorController.h +++ b/Source/SPFieldEditorController.h @@ -183,9 +183,9 @@ - (IBAction)setToNull:(id)sender; - (void)updateBitSheet; -- (id)editWithObject:(id)data fieldName:(NSString*)fieldName usingEncoding:(NSStringEncoding)anEncoding - isObjectBlob:(BOOL)isFieldBlob isEditable:(BOOL)isEditable withWindow:(NSWindow *)theWindow - withSender:(id)sender contextInfo:(NSDictionary*)theContextInfo; +- (void)editWithObject:(id)data fieldName:(NSString*)fieldName usingEncoding:(NSStringEncoding)anEncoding + isObjectBlob:(BOOL)isFieldBlob isEditable:(BOOL)isEditable withWindow:(NSWindow *)theWindow + sender:(id)sender contextInfo:(NSDictionary*)theContextInfo; - (void)setTextMaxLength:(NSUInteger)length; - (void)setFieldType:(NSString*)aType; diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m index b77ca98e..7079cc13 100644 --- a/Source/SPFieldMapperController.m +++ b/Source/SPFieldMapperController.m @@ -30,17 +30,18 @@ #import "SPTableView.h" #import "SPCategoryAdditions.h" #import "RegexKitLite.h" +#import "SPDatabaseData.h" #define SP_NUMBER_OF_RECORDS_STRING NSLocalizedString(@"%ld of %@%lu records", @"Label showing the index of the selected CSV row") // Constants -static const NSString *SPTableViewImportValueColumnID = @"import_value"; -static const NSString *SPTableViewTypeColumnID = @"type"; -static const NSString *SPTableViewTargetFieldColumnID = @"target_field"; -static const NSString *SPTableViewOperatorColumnID = @"operator"; -static const NSString *SPTableViewValueIndexColumnID = @"value_index"; -static const NSString *SPTableViewGlobalValueColumnID = @"global_value"; -static const NSString *SPTableViewSqlColumnID = @"sql"; +static NSString *SPTableViewImportValueColumnID = @"import_value"; +static NSString *SPTableViewTypeColumnID = @"type"; +static NSString *SPTableViewTargetFieldColumnID = @"target_field"; +static NSString *SPTableViewOperatorColumnID = @"operator"; +static NSString *SPTableViewValueIndexColumnID = @"value_index"; +static NSString *SPTableViewGlobalValueColumnID = @"global_value"; +static NSString *SPTableViewSqlColumnID = @"sql"; @implementation SPFieldMapperController @@ -55,7 +56,7 @@ static const NSString *SPTableViewSqlColumnID = @"sql"; */ - (id)initWithDelegate:(id)managerDelegate { - if (self = [super initWithWindowNibName:@"DataMigrationDialog"]) { + if ((self = [super initWithWindowNibName:@"DataMigrationDialog"])) { fieldMappingCurrentRow = 0; if(managerDelegate == nil) { @@ -1388,8 +1389,6 @@ static const NSString *SPTableViewSqlColumnID = @"sql"; NSInteger i,j; NSMutableArray *distMatrix = [NSMutableArray array]; for(i=0; i < [tableHeaderNames count]; i++) { - CGFloat minDist = 1e6; - NSInteger minIndex = 0; CGFloat dist = 1e6; for(j=0; j < [fileHeaderNames count]; j++) { id fileHeaderName = NSArrayObjectAtIndex(fileHeaderNames,j); diff --git a/Source/SPFileManagerAdditions.m b/Source/SPFileManagerAdditions.m index 2ea9fb71..22becf92 100644 --- a/Source/SPFileManagerAdditions.m +++ b/Source/SPFileManagerAdditions.m @@ -120,7 +120,7 @@ NSString* const DirectoryLocationDomain = @"DirectoryLocationDomain"; if(create) { // Create the path if it doesn't exist - NSError *error = nil; + error = nil; BOOL success = [self createDirectoryAtPath:resolvedPath withIntermediateDirectories:YES attributes:nil error:&error]; if (!success) { if (errorOut) { diff --git a/Source/SPFontPreviewTextField.m b/Source/SPFontPreviewTextField.m index 1c4e4b02..90e9f93f 100644 --- a/Source/SPFontPreviewTextField.m +++ b/Source/SPFontPreviewTextField.m @@ -35,7 +35,7 @@ _actualFont = [font retain]; - [super setFont:[[NSFontManager sharedFontManager] convertFont:font toSize:11.]]; + [super setFont:[[NSFontManager sharedFontManager] convertFont:font toSize:11.0f]]; NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:[_actualFont displayName]]; NSMutableParagraphStyle *paraStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; diff --git a/Source/SPGeometryDataView.m b/Source/SPGeometryDataView.m index 10cf5b4a..d68bb57b 100644 --- a/Source/SPGeometryDataView.m +++ b/Source/SPGeometryDataView.m @@ -79,9 +79,8 @@ x_min*=zoom_factor; y_min*=zoom_factor; - if ( self = [super initWithFrame:NSMakeRect(0,0,width+margin_offset*2,height+margin_offset*2)] ) + if ( (self = [super initWithFrame:NSMakeRect(0,0,width+margin_offset*2,height+margin_offset*2)]) ) { - ; } lineColor = [NSColor blackColor]; @@ -263,7 +262,6 @@ { if(!type || ![type length] || !coordinates || ![coordinates count]) return nil; - NSSize mySize = self.bounds.size; NSRect myBounds = [self bounds]; return [self dataWithPDFInsideRect:myBounds]; diff --git a/Source/SPGrowlController.m b/Source/SPGrowlController.m index 71f93053..a3d42526 100644 --- a/Source/SPGrowlController.m +++ b/Source/SPGrowlController.m @@ -24,6 +24,8 @@ // More info at <http://code.google.com/p/sequel-pro/> #import "SPGrowlController.h" +#import "SPDatabaseDocument.h" +#import "SPWindowController.h" #include <mach/mach_time.h> diff --git a/Source/SPHistoryController.m b/Source/SPHistoryController.m index 107c24cb..9b810a00 100644 --- a/Source/SPHistoryController.m +++ b/Source/SPHistoryController.m @@ -26,6 +26,7 @@ #import "SPTableContent.h" #import "SPTablesList.h" #import "SPHistoryController.h" +#import "SPDatabaseViewController.h" @implementation SPHistoryController diff --git a/Source/SPIndexesController.m b/Source/SPIndexesController.m index 49ac8594..f1cce967 100644 --- a/Source/SPIndexesController.m +++ b/Source/SPIndexesController.m @@ -26,6 +26,10 @@ #import "SPIndexesController.h" #import "SPAlertSheets.h" #import "SPServerSupport.h" +#import "SPTableContent.h" +#import "SPTableData.h" +#import <MCPKit/MCPKit.h> +#import "SPDatabaseDocument.h" // Constants static const NSString *SPNewIndexIndexName = @"IndexName"; diff --git a/Source/SPKeychain.m b/Source/SPKeychain.m index 335c0a0b..bb010d3b 100644 --- a/Source/SPKeychain.m +++ b/Source/SPKeychain.m @@ -66,7 +66,7 @@ NSArray *trustedApps = [NSArray arrayWithObjects:(id)sequelProRef, (id)sequelProHelperRef, nil]; status = SecAccessCreate((CFStringRef)name, (CFArrayRef)trustedApps, &passwordAccessRef); if (status != noErr) { - NSLog(@"Error (%i) while trying to create access list for name: %@ account: %@", status, name, account); + NSLog(@"Error (%i) while trying to create access list for name: %@ account: %@", (int)status, name, account); passwordAccessRef = NULL; } } @@ -77,13 +77,13 @@ attributes[0].length = 20; attributes[1].tag = kSecLabelItemAttr; attributes[1].data = (unichar *)[label UTF8String]; - attributes[1].length = strlen([label UTF8String]); + attributes[1].length = (UInt32)strlen([label UTF8String]); attributes[2].tag = kSecAccountItemAttr; attributes[2].data = (unichar *)[account UTF8String]; - attributes[2].length = strlen([account UTF8String]); + attributes[2].length = (UInt32)strlen([account UTF8String]); attributes[3].tag = kSecServiceItemAttr; attributes[3].data = (unichar *)[name UTF8String]; - attributes[3].length = strlen([name UTF8String]); + attributes[3].length = (UInt32)strlen([name UTF8String]); attList.count = 4; attList.attr = attributes; @@ -91,7 +91,7 @@ status = SecKeychainItemCreateFromContent( kSecGenericPasswordItemClass, // Generic password type &attList, // The attribute list created for the keychain item - strlen([password UTF8String]), // Length of password + (UInt32)strlen([password UTF8String]), // Length of password [password UTF8String], // Password data NULL, // Default keychain passwordAccessRef, // Access list for this keychain @@ -100,7 +100,7 @@ if (passwordAccessRef) CFRelease(passwordAccessRef); if (status != noErr) { - NSLog(@"Error (%i) while trying to add password for name: %@ account: %@", status, name, account); + NSLog(@"Error (%i) while trying to add password for name: %@ account: %@", (int)status, name, account); SPBeginAlertSheet(NSLocalizedString(@"Error adding password to Keychain", @"error adding password to keychain message"), NSLocalizedString(@"OK", @"OK button"), @@ -127,15 +127,15 @@ if (!account) account = @""; status = SecKeychainFindGenericPassword( - NULL, // default keychain - strlen([name UTF8String]), // length of service name (bytes) - [name UTF8String], // service name - - strlen([account UTF8String]), // length of account name (bytes) - [account UTF8String], // account name - &passwordLength, // length of password - &passwordData, // pointer to password data - &itemRef // the item reference + NULL, // default keychain + (UInt32)strlen([name UTF8String]), // length of service name (bytes) + [name UTF8String], // service name + + (UInt32)strlen([account UTF8String]), // length of account name (bytes) + [account UTF8String], // account name + &passwordLength, // length of password + &passwordData, // pointer to password data + &itemRef // the item reference ); if (status == noErr) { @@ -171,21 +171,21 @@ // Check if password already exists before deleting if ([self passwordExistsForName:name account:account]) { status = SecKeychainFindGenericPassword( - NULL, // default keychain - strlen([name UTF8String]), // length of service name - [name UTF8String], // service name - strlen([account UTF8String]), // length of account name - [account UTF8String], // account name - nil, // length of password - nil, // pointer to password data - &itemRef // the item reference + NULL, // default keychain + (UInt32)strlen([name UTF8String]), // length of service name + [name UTF8String], // service name + (UInt32)strlen([account UTF8String]), // length of account name + [account UTF8String], // account name + nil, // length of password + nil, // pointer to password data + &itemRef // the item reference ); if (status == noErr) { status = SecKeychainItemDelete(itemRef); if (status != noErr) { - NSLog(@"Error (%i) while trying to delete password for name: %@ account: %@", status, name, account); + NSLog(@"Error (%i) while trying to delete password for name: %@ account: %@", (int)status, name, account); } } @@ -209,12 +209,12 @@ if (!account) account = @""; attributes[0].tag = kSecAccountItemAttr; - attributes[0].data = (void *)[account UTF8String]; // Account name - attributes[0].length = strlen([account UTF8String]); // Length of account name (bytes) + attributes[0].data = (void *)[account UTF8String]; // Account name + attributes[0].length = (UInt32)strlen([account UTF8String]); // Length of account name (bytes) attributes[1].tag = kSecServiceItemAttr; - attributes[1].data = (void *)[name UTF8String]; // Service name - attributes[1].length = strlen([name UTF8String]); // Length of service name (bytes) + attributes[1].data = (void *)[name UTF8String]; // Service name + attributes[1].length = (UInt32)strlen([name UTF8String]); // Length of service name (bytes) list.count = 2; list.attr = attributes; diff --git a/Source/SPMainThreadTrampoline.m b/Source/SPMainThreadTrampoline.m index 5f25e174..1277c760 100644 --- a/Source/SPMainThreadTrampoline.m +++ b/Source/SPMainThreadTrampoline.m @@ -58,7 +58,7 @@ */ - (id) initWithObject:(id)theObject { - if (self = [super init]) { + if ((self = [super init])) { trampolineObject = theObject; } return self; @@ -149,4 +149,4 @@ return self; } -@end
\ No newline at end of file +@end diff --git a/Source/SPMenuAdditions.m b/Source/SPMenuAdditions.m index 45bde232..d653f71a 100644 --- a/Source/SPMenuAdditions.m +++ b/Source/SPMenuAdditions.m @@ -31,7 +31,7 @@ - (void)compatibleRemoveAllItems { if ([self respondsToSelector:@selector(removeAllItems)]) { - [self removeAllItems]; + [(id)self removeAllItems]; } else { while ([self numberOfItems]) [self removeItemAtIndex:0]; } diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m index abc00d9a..ca7f7f7d 100644 --- a/Source/SPNarrowDownCompletion.m +++ b/Source/SPNarrowDownCompletion.m @@ -112,7 +112,7 @@ maxWindowWidth = 450; - if(self = [super initWithContentRect:NSMakeRect(0,0,maxWindowWidth,0) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]) + if((self = [super initWithContentRect:NSMakeRect(0,0,maxWindowWidth,0) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES])) { mutablePrefix = [NSMutableString new]; originalFilterString = [NSMutableString new]; @@ -217,7 +217,7 @@ selectedDb:(NSString*)selectedDb caretMovedLeft:(BOOL)caretMovedLeft autoComplete:(BOOL)autoComplete oneColumn:(BOOL)oneColumn alias:(NSString*)anAlias isQueryingDBStructure:(BOOL)isQueryingDBStructure { - if(self = [self init]) + if((self = [self init])) { // Set filter string diff --git a/Source/SPNavigatorController.m b/Source/SPNavigatorController.m index aeb5af8c..25eccbc8 100644 --- a/Source/SPNavigatorController.m +++ b/Source/SPNavigatorController.m @@ -30,8 +30,10 @@ #import "SPTablesList.h" #import "SPLogger.h" #import "SPTooltip.h" +#import "SPAppController.h" +#import "SPDatabaseViewController.h" -#import <objc/runtime.h> +#import <objc/message.h> static SPNavigatorController *sharedNavigatorController = nil; diff --git a/Source/SPNotLoaded.m b/Source/SPNotLoaded.m index 9ce0fec2..4e2925a7 100644 --- a/Source/SPNotLoaded.m +++ b/Source/SPNotLoaded.m @@ -52,7 +52,7 @@ static SPNotLoaded *notLoaded = nil; Class notLoadedClass = [self class]; @synchronized(notLoadedClass) { if (notLoaded == nil) { - if (self = [super init]) { + if ((self = [super init])) { notLoaded = self; } } diff --git a/Source/SPOutlineView.m b/Source/SPOutlineView.m index 256090e2..4e8f0f0a 100644 --- a/Source/SPOutlineView.m +++ b/Source/SPOutlineView.m @@ -28,8 +28,7 @@ - (id)init { - if(self = [super init]){ - ; + if((self = [super init])){ } return self; } diff --git a/Source/SPPreferenceController.h b/Source/SPPreferenceController.h index 7b0e0cc3..2af3271e 100644 --- a/Source/SPPreferenceController.h +++ b/Source/SPPreferenceController.h @@ -42,12 +42,12 @@ @interface SPPreferenceController : NSWindowController { // Preference pane controllers - IBOutlet SPGeneralPreferencePane *generalPreferencePane; - IBOutlet SPTablesPreferencePane *tablesPreferencePane; - IBOutlet SPNotificationsPreferencePane *notificationsPreferencePane; - IBOutlet SPEditorPreferencePane *editorPreferencePane; - IBOutlet SPAutoUpdatePreferencePane *autoUpdatePreferencePane; - IBOutlet SPNetworkPreferencePane *networkPreferencePane; + IBOutlet SPGeneralPreferencePane <SPPreferencePaneProtocol> *generalPreferencePane; + IBOutlet SPTablesPreferencePane <SPPreferencePaneProtocol> *tablesPreferencePane; + IBOutlet SPNotificationsPreferencePane <SPPreferencePaneProtocol> *notificationsPreferencePane; + IBOutlet SPEditorPreferencePane <SPPreferencePaneProtocol> *editorPreferencePane; + IBOutlet SPAutoUpdatePreferencePane <SPPreferencePaneProtocol> *autoUpdatePreferencePane; + IBOutlet SPNetworkPreferencePane <SPPreferencePaneProtocol> *networkPreferencePane; NSToolbar *toolbar; NSArray *preferencePanes; diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m index 7592319a..01d39e25 100644 --- a/Source/SPPreferenceController.m +++ b/Source/SPPreferenceController.m @@ -25,6 +25,9 @@ #import "SPPreferenceController.h" #import "SPPreferencesUpgrade.h" +#import "SPTablesPreferencePane.h" +#import "SPEditorPreferencePane.h" +#import "SPGeneralPreferencePane.h" @interface SPPreferenceController (PrivateAPI) @@ -85,13 +88,13 @@ - (IBAction)displayPreferencePane:(id)sender { - SPPreferencePane *preferencePane = nil; + SPPreferencePane <SPPreferencePaneProtocol> *preferencePane = nil; if (!sender) { preferencePane = generalPreferencePane; } else { - for (SPPreferencePane *prefPane in preferencePanes) + for (SPPreferencePane <SPPreferencePaneProtocol> *prefPane in preferencePanes) { if ([[prefPane preferencePaneIdentifier] isEqualToString:[sender itemIdentifier]]) { preferencePane = prefPane; diff --git a/Source/SPPreferencesUpgrade.m b/Source/SPPreferencesUpgrade.m index 51bcd1b4..5894e397 100644 --- a/Source/SPPreferencesUpgrade.m +++ b/Source/SPPreferencesUpgrade.m @@ -72,17 +72,17 @@ void SPApplyRevisionChanges(void) databaseEnumerator = [[prefs objectForKey:SPTableColumnWidths] keyEnumerator]; - while (databaseKey = [databaseEnumerator nextObject]) + while ((databaseKey = [databaseEnumerator nextObject])) { newDatabase = [[NSMutableDictionary alloc] init]; tableEnumerator = [[[prefs objectForKey:SPTableColumnWidths] objectForKey:databaseKey] keyEnumerator]; - while (tableKey = [tableEnumerator nextObject]) + while ((tableKey = [tableEnumerator nextObject])) { newTable = [[NSMutableDictionary alloc] init]; columnEnumerator = [[[[prefs objectForKey:SPTableColumnWidths] objectForKey:databaseKey] objectForKey:tableKey] keyEnumerator]; - while (columnKey = [columnEnumerator nextObject]) + while ((columnKey = [columnEnumerator nextObject])) { columnWidth = [[[[[prefs objectForKey:SPTableColumnWidths] objectForKey:databaseKey] objectForKey:tableKey] objectForKey:columnKey] doubleValue]; @@ -132,7 +132,7 @@ void SPApplyRevisionChanges(void) keyEnumerator = [keysToUpgrade keyEnumerator]; - while (newKey = [keyEnumerator nextObject]) + while ((newKey = [keyEnumerator nextObject])) { oldKey = [keysToUpgrade objectForKey:newKey]; diff --git a/Source/SPProcessListController.m b/Source/SPProcessListController.m index d6b5c186..fdef96bb 100644 --- a/Source/SPProcessListController.m +++ b/Source/SPProcessListController.m @@ -26,6 +26,7 @@ #import "SPProcessListController.h" #import "SPDatabaseDocument.h" #import "SPAlertSheets.h" +#import "SPAppController.h" // Constants static const NSString *SPKillProcessQueryMode = @"SPKillProcessQueryMode"; @@ -77,7 +78,7 @@ static const NSString *SPTableViewIDColumnIdentifier = @"Id"; */ - (void)awakeFromNib { - [[self window] setTitle:[NSString stringWithFormat:@"%@ %@", [[[NSApp delegate] frontDocument] name], NSLocalizedString(@"Server Processes", @"server processes window title")]]; + [[self window] setTitle:[NSString stringWithFormat:@"%@ %@", [[(SPAppController*)[NSApp delegate] frontDocument] name], NSLocalizedString(@"Server Processes", @"server processes window title")]]; [self setWindowFrameAutosaveName:@"ProcessList"]; @@ -647,7 +648,7 @@ static const NSString *SPTableViewIDColumnIdentifier = @"Id"; } // If a match wasn't found then a custom value is set - if (!found) [[items objectAtIndex:([items count] - 1)] setState:NSOnState]; + if (!found) [(NSMenuItem*)[items objectAtIndex:([items count] - 1)] setState:NSOnState]; } /** diff --git a/Source/SPQueryController.m b/Source/SPQueryController.m index 480d3e9e..ad9653ce 100644 --- a/Source/SPQueryController.m +++ b/Source/SPQueryController.m @@ -32,9 +32,9 @@ #define MESSAGE_TRUNCATE_CHARACTER_LENGTH 256 // Table view column identifier constants -static const NSString *SPTableViewMessageColumnID = @"message"; -static const NSString *SPTableViewDateColumnID = @"messageDate"; -static const NSString *SPTableViewConnectionColumnID = @"messageConnection"; +static NSString *SPTableViewMessageColumnID = @"message"; +static NSString *SPTableViewDateColumnID = @"messageDate"; +static NSString *SPTableViewConnectionColumnID = @"messageConnection"; @interface SPQueryController (PrivateAPI) diff --git a/Source/SPSQLExporter.m b/Source/SPSQLExporter.m index d999cc2b..f6760468 100644 --- a/Source/SPSQLExporter.m +++ b/Source/SPSQLExporter.m @@ -95,7 +95,7 @@ SPTableType tableType = SPTableTypeTable; id createTableSyntax = nil; - NSUInteger i, j, k, t, s, rowCount, queryLength, lastProgressValue; + NSUInteger j, k, t, s, rowCount, queryLength, lastProgressValue; BOOL sqlOutputIncludeStructure; BOOL sqlOutputIncludeContent; diff --git a/Source/SPSQLTokenizer.l b/Source/SPSQLTokenizer.l index 61fb3b8a..1964c94d 100644 --- a/Source/SPSQLTokenizer.l +++ b/Source/SPSQLTokenizer.l @@ -29,8 +29,6 @@ int utf8strlenfortoken(const char * _s); int yyuoffset, yyuleng; -#define YY_NO_UNPUT - //keep track of the current utf-8 character (not byte) offset and token length #define YY_USER_ACTION { yyuoffset += yyuleng; yyuleng = utf8strlenfortoken(yytext); } //ignore the output of unmatched characters @@ -38,6 +36,7 @@ int yyuoffset, yyuleng; %} %option prefix="to" %option noyywrap +%option nounput %option case-insensitive %option nostdinit @@ -135,5 +134,5 @@ int utf8strlenfortoken(const char * _s) } done: - return ((s - _s) - count); + return (int)((s - _s) - count); } diff --git a/Source/SPSSHTunnel.h b/Source/SPSSHTunnel.h index 4afec738..bf7fd8a4 100644 --- a/Source/SPSSHTunnel.h +++ b/Source/SPSSHTunnel.h @@ -48,8 +48,8 @@ NSLock *debugMessagesLock; NSInteger sshPort; NSInteger remotePort; - NSInteger localPort; - NSInteger localPortFallback; + NSUInteger localPort; + NSUInteger localPortFallback; NSInteger connectionState; NSLock *answerAvailableLock; @@ -81,8 +81,8 @@ - (NSInteger)state; - (NSString *)lastError; - (NSString *)debugMessages; -- (NSInteger)localPort; -- (NSInteger)localPortFallback; +- (NSUInteger)localPort; +- (NSUInteger)localPortFallback; - (void)connect; - (void)launchTask:(id)dummy; - (void)disconnect; diff --git a/Source/SPSSHTunnel.m b/Source/SPSSHTunnel.m index e112e624..16d0c590 100644 --- a/Source/SPSSHTunnel.m +++ b/Source/SPSSHTunnel.m @@ -425,7 +425,7 @@ if ([notificationText length]) { messages = [notificationText componentsSeparatedByString:@"\n"]; enumerator = [messages objectEnumerator]; - while (message = [[enumerator nextObject] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]) { + while ((message = [[enumerator nextObject] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]])) { if (![message length]) continue; [debugMessagesLock lock]; [debugMessages addObject:[NSString stringWithString:message]]; @@ -488,7 +488,7 @@ /* * Returns the local port assigned for use by the tunnel */ -- (NSInteger)localPort +- (NSUInteger)localPort { return localPort; } @@ -496,7 +496,7 @@ /* * Returns the local port assigned for fallback use by the tunnel, if any */ -- (NSInteger)localPortFallback +- (NSUInteger)localPortFallback { if (!useHostFallback) return 0; diff --git a/Source/SPServerSupport.m b/Source/SPServerSupport.m index 6f8213d6..1aebc0d4 100644 --- a/Source/SPServerSupport.m +++ b/Source/SPServerSupport.m @@ -205,7 +205,7 @@ - (NSString *)description { unsigned int i; - NSString *description = [NSMutableString stringWithFormat:@"<%@: Server is MySQL version %d.%d.%d. Supports:\n", [self className], serverMajorVersion, serverMinorVersion, serverReleaseVersion]; + NSMutableString *description = [NSMutableString stringWithFormat:@"<%@: Server is MySQL version %d.%d.%d. Supports:\n", [self className], serverMajorVersion, serverMinorVersion, serverReleaseVersion]; Ivar *vars = class_copyIvarList([self class], &i); diff --git a/Source/SPServerVariablesController.m b/Source/SPServerVariablesController.m index e0796454..dedda57b 100644 --- a/Source/SPServerVariablesController.m +++ b/Source/SPServerVariablesController.m @@ -25,6 +25,7 @@ #import "SPServerVariablesController.h" #import "SPDatabaseDocument.h" +#import "SPAppController.h" @interface SPServerVariablesController (PrivateAPI) @@ -166,7 +167,7 @@ { if (returnCode == NSOKButton) { if ([variablesFiltered count] > 0) { - NSMutableString *variablesString = [NSMutableString stringWithFormat:@"# MySQL server variables for %@\n\n", [[[NSApp delegate] frontDocument] host]]; + NSMutableString *variablesString = [NSMutableString stringWithFormat:@"# MySQL server variables for %@\n\n", [[(SPAppController*)[NSApp delegate] frontDocument] host]]; for (NSDictionary *variable in variablesFiltered) { diff --git a/Source/SPStringAdditions.h b/Source/SPStringAdditions.h index 042e69f0..16841a34 100644 --- a/Source/SPStringAdditions.h +++ b/Source/SPStringAdditions.h @@ -46,12 +46,12 @@ static inline void NSMutableAttributedStringAddAttributeValueRange (NSMutableAtt return; } -static inline id NSMutableAttributedStringAttributeAtIndex (NSMutableAttributedString* self, NSString* aStr, NSUInteger index, NSRangePointer range) +static inline id NSMutableAttributedStringAttributeAtIndex (NSMutableAttributedString* self, NSString* aStr, NSUInteger anIndex, NSRangePointer aRange) { typedef id (*SPMutableAttributedStringAttributeAtIndexMethodPtr)(NSMutableAttributedString*, SEL, NSString*, NSUInteger, NSRangePointer); static SPMutableAttributedStringAttributeAtIndexMethodPtr SPMutableAttributedStringAttributeAtIndex; if (!SPMutableAttributedStringAttributeAtIndex) SPMutableAttributedStringAttributeAtIndex = (SPMutableAttributedStringAttributeAtIndexMethodPtr)[self methodForSelector:@selector(attribute:atIndex:effectiveRange:)]; - id r = SPMutableAttributedStringAttributeAtIndex(self, @selector(attribute:atIndex:effectiveRange:), aStr, index, range); + id r = SPMutableAttributedStringAttributeAtIndex(self, @selector(attribute:atIndex:effectiveRange:), aStr, anIndex, aRange); return r; } diff --git a/Source/SPStringAdditions.m b/Source/SPStringAdditions.m index a8346399..a762fe61 100644 --- a/Source/SPStringAdditions.m +++ b/Source/SPStringAdditions.m @@ -25,6 +25,22 @@ #import "SPStringAdditions.h" #import "RegexKitLite.h" +#import "SPDatabaseDocument.h" + +// Defined to suppress warnings +@interface NSObject (SPBundleMethods) + +- (NSString *)lastBundleBlobFilesDirectory; +- (void)setLastBundleBlobFilesDirectory:(NSString *)path; + +@end + +// Defined to suppress warnings +@interface NSObject (SPWindowControllerTabMethods) + +- (id)selectedTableDocument; + +@end @interface NSString (PrivateAPI) @@ -39,7 +55,7 @@ */ + (NSString *)stringForByteSize:(long long)byteSize { - CGFloat size = byteSize; + double size = byteSize; NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease]; @@ -48,7 +64,7 @@ if (size < 1023) { [numberFormatter setFormat:@"#,##0 B"]; - return [numberFormatter stringFromNumber:[NSNumber numberWithInteger:size]]; + return [numberFormatter stringFromNumber:[NSNumber numberWithDouble:size]]; } size = (size / 1024); @@ -163,7 +179,7 @@ { NSMutableString *holder = [[NSMutableString alloc] init]; unichar theChar; - int i; + NSUInteger i; for(i = 0; i < [self length]; i++) { theChar = [self characterAtIndex:i]; @@ -406,7 +422,7 @@ return distance; } - return 0.0; + return 0.0f; } /** @@ -491,7 +507,7 @@ if([scriptPath hasPrefix:@"/"] && [fm fileExistsAtPath:scriptPath isDirectory:&isDir] && !isDir) { NSString *script = [self substringWithRange:NSMakeRange(NSMaxRange(firstLineRange), [self length] - NSMaxRange(firstLineRange))]; NSError *writeError = nil; - [script writeToFile:scriptFilePath atomically:YES encoding:NSUTF8StringEncoding error:writeError]; + [script writeToFile:scriptFilePath atomically:YES encoding:NSUTF8StringEncoding error:&writeError]; if(writeError == nil) { redirectForScript = YES; [scriptHeaderArguments addObject:scriptFilePath]; @@ -503,7 +519,7 @@ } else { [scriptHeaderArguments addObject:@"/bin/sh"]; NSError *writeError = nil; - [self writeToFile:scriptFilePath atomically:YES encoding:NSUTF8StringEncoding error:writeError]; + [self writeToFile:scriptFilePath atomically:YES encoding:NSUTF8StringEncoding error:&writeError]; if(writeError == nil) { redirectForScript = YES; [scriptHeaderArguments addObject:scriptFilePath]; @@ -672,12 +688,12 @@ // Read STDOUT saved to file if([fm fileExistsAtPath:stdoutFilePath isDirectory:nil]) { - NSString *stdout = [NSString stringWithContentsOfFile:stdoutFilePath encoding:NSUTF8StringEncoding error:nil]; - if(bashTask) [bashTask release]; + NSString *stdoutContent = [NSString stringWithContentsOfFile:stdoutFilePath encoding:NSUTF8StringEncoding error:nil]; + if(bashTask) [bashTask release], bashTask = nil; [fm removeItemAtPath:stdoutFilePath error:nil]; - if(stdout != nil) { + if(stdoutContent != nil) { if (status == 0) { - return stdout; + return stdoutContent; } else { if(theError != NULL) { if(status == 9 || userTerminated) return @""; @@ -693,7 +709,7 @@ NSBeep(); } if(status > SPBundleRedirectActionNone && status <= SPBundleRedirectActionLastCode) - return stdout; + return stdoutContent; else return @""; } @@ -701,12 +717,11 @@ NSLog(@"Couldn't read return string from “%@” by using UTF-8 encoding.", self); NSBeep(); } - } else { - if(bashTask) [bashTask release]; - [fm removeItemAtPath:stdoutFilePath error:nil]; - return @""; } + if (bashTask) [bashTask release]; + [fm removeItemAtPath:stdoutFilePath error:nil]; + return @""; } /** diff --git a/Source/SPTableContent.h b/Source/SPTableContent.h index 0b33146b..4510d9be 100644 --- a/Source/SPTableContent.h +++ b/Source/SPTableContent.h @@ -70,9 +70,9 @@ IBOutlet NSButton *filterTableFilterButton; IBOutlet NSButton *filterTableClearButton; IBOutlet SPTextView *filterTableWhereClause; - IBOutlet id filterTableNegateCheckbox; + IBOutlet NSButton *filterTableNegateCheckbox; IBOutlet NSMenuItem *filterTableDistinctMenuItem; - IBOutlet id filterTableLiveSearchCheckbox; + IBOutlet NSButton *filterTableLiveSearchCheckbox; IBOutlet NSMenuItem *filterTableGearLookAllFields; IBOutlet NSPanel *filterTableSetDefaultOperatorSheet; IBOutlet NSComboBox* filterTableSetDefaultOperatorValue; diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index a0b184dd..4e107570 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -45,6 +45,13 @@ #import "SPAlertSheets.h" #import "SPHistoryController.h" #import "SPGeometryDataView.h" +#import "SPTextView.h" +#import "SPDatabaseViewController.h" +#import "SPAppController.h" + +@interface SPTableContent (Private) +- (BOOL)cancelRowEditing; +@end @implementation SPTableContent @@ -826,7 +833,7 @@ // Loop through the result rows as they become available tableRowsCount = 0; - while (tempRow = [theResult fetchNextRowAsArray]) { + while ((tempRow = [theResult fetchNextRowAsArray])) { pthread_mutex_lock(&tableValuesLock); if (tableRowsCount < previousTableRowsCount) { @@ -1764,9 +1771,8 @@ /** * Perform the requested row deletion action. */ -- (void)removeRowSheetDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo +- (void)removeRowSheetDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo { - NSMutableIndexSet *selectedRows = [NSMutableIndexSet indexSet]; NSString *wherePart; NSInteger i, errors; @@ -1776,8 +1782,8 @@ // Order out current sheet to suppress overlapping of sheets [[alert window] orderOut:nil]; - if ( [contextInfo isEqualToString:@"removeallrows"] ) { - if ( returnCode == NSAlertDefaultReturn ) { + if ([contextInfo isEqualToString:@"removeallrows"]) { + if (returnCode == NSAlertDefaultReturn) { // Check if the user is currently editing a row, and revert to ensure a somewhat // consistent state if deletion fails. @@ -1809,8 +1815,9 @@ afterDelay:0.3]; } } - } else if ( [contextInfo isEqualToString:@"removerow"] ) { - if ( returnCode == NSAlertDefaultReturn ) { + } + else if ([contextInfo isEqualToString:@"removerow"]) { + if (returnCode == NSAlertDefaultReturn) { [selectedRows addIndexes:[tableContentView selectedRowIndexes]]; //check if the user is currently editing a row @@ -2382,9 +2389,12 @@ [menu addItem:item]; [item release]; - // Attempt to reselect the previously selected title, falling back to the first item - [compareField selectItemWithTitle:titleToRestore]; - if (![compareField selectedItem]) [compareField selectItemAtIndex:0]; + // Attempt to reselect the previously selected title, falling back to the first + // item on failure, as long as there is no filter selection to be restored. + if (!filterFieldToRestore) { + [compareField selectItemWithTitle:titleToRestore]; + if (![compareField selectedItem]) [compareField selectItemAtIndex:0]; + } // Update the argumentField enabled state [self performSelectorOnMainThread:@selector(toggleFilterField:) withObject:self waitUntilDone:YES]; @@ -3471,11 +3481,10 @@ */ - (NSString *)tableView:(NSTableView *)aTableView toolTipForCell:(id)aCell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)row mouseLocation:(NSPoint)mouseLocation { - - if(aTableView == filterTableView) { + if (aTableView == filterTableView) { return nil; } - else if(aTableView == tableContentView) { + else if (aTableView == tableContentView) { if([[aCell stringValue] length] < 2 || [tableDocumentInstance isWorking]) return nil; @@ -3542,26 +3551,29 @@ return nil; } + + return nil; } - (NSInteger)numberOfRowsInTableView:(SPCopyTable *)aTableView { - if(aTableView == filterTableView) { - if(filterTableIsSwapped) + if (aTableView == filterTableView) { + if (filterTableIsSwapped) return [filterTableData count]; else return [[[filterTableData objectForKey:[NSNumber numberWithInteger:0]] objectForKey:@"filter"] count]; } - else if(aTableView == tableContentView) { + else if (aTableView == tableContentView) { return tableRowsCount; } + + return 0; } - (id)tableView:(SPCopyTable *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex { - - if(aTableView == filterTableView) { - if(filterTableIsSwapped) + if (aTableView == filterTableView) { + if (filterTableIsSwapped) // First column shows the field names if([[aTableColumn identifier] integerValue] == 0) { NSTableHeaderCell *c = [[[NSTableHeaderCell alloc] initTextCell:[[filterTableData objectForKey:[NSNumber numberWithInteger:rowIndex]] objectForKey:@"name"]] autorelease]; @@ -3572,7 +3584,7 @@ return NSArrayObjectAtIndex([[filterTableData objectForKey:[aTableColumn identifier]] objectForKey:@"filter"], rowIndex); } } - else if(aTableView == tableContentView) { + else if (aTableView == tableContentView) { NSUInteger columnIndex = [[aTableColumn identifier] integerValue]; id theValue = nil; @@ -3607,6 +3619,8 @@ return theValue; } + + return nil; } /** @@ -4441,9 +4455,6 @@ // Trap the escape key if ( [[control window] methodForSelector:command] == [[control window] methodForSelector:@selector(cancelOperation:)] ) { - - NSUInteger row = [control editedRow]; - // Abort editing [control abortEditing]; if(control == tableContentView) @@ -4527,7 +4538,6 @@ NSString *re1 = @"^\\s*(<[=>]?|>=?|!?=|≠|≤|≥)\\s*(.*?)\\s*$"; NSString *re2 = @"^\\s*(.*)\\s+(.*?)\\s*$"; - NSCharacterSet *whiteSpaceCharSet = [NSCharacterSet whitespaceAndNewlineCharacterSet]; NSInteger editedRow = [filterTableView editedRow]; diff --git a/Source/SPTableData.h b/Source/SPTableData.h index 4503bd03..1c3fa8f0 100644 --- a/Source/SPTableData.h +++ b/Source/SPTableData.h @@ -46,7 +46,6 @@ BOOL tableHasAutoIncrementField; } -@property (readwrite, assign) BOOL isWorking; @property (readonly, assign) BOOL tableHasAutoIncrementField; - (void) setConnection:(MCPConnection *)theConnection; diff --git a/Source/SPTableData.m b/Source/SPTableData.m index 7ae8f563..7180dc6a 100644 --- a/Source/SPTableData.m +++ b/Source/SPTableData.m @@ -32,7 +32,9 @@ #import "SPServerSupport.h" @interface SPTableData (PrivateAPI) + - (void)_loopWhileWorking; + @end @implementation SPTableData diff --git a/Source/SPTableInfo.m b/Source/SPTableInfo.m index af5d4474..6c7c216d 100644 --- a/Source/SPTableInfo.m +++ b/Source/SPTableInfo.m @@ -319,7 +319,7 @@ [aTableColumn setDataCell:c]; return NSLocalizedString(@"ACTIVITIES", @"header for activities pane"); } - else if(!_activitiesWillBeUpdated && rowIndex > 0 && rowIndex < [activities count]) { + else if(!_activitiesWillBeUpdated && rowIndex > 0 && rowIndex < (NSInteger)[activities count]) { NSDictionary *dict = NSArrayObjectAtIndex(activities,rowIndex); SPActivityTextFieldCell *c = [[[SPActivityTextFieldCell alloc] init] autorelease]; [c setActivityName:[[dict objectForKey:@"contextInfo"] objectForKey:@"name"]]; diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m index 1cd5ca4e..ebcb2bc6 100644 --- a/Source/SPTableStructure.m +++ b/Source/SPTableStructure.m @@ -189,7 +189,6 @@ { NSArray *theTableIndexes; NSMutableDictionary *theTableEnumLists = [NSMutableDictionary dictionary]; - NSInteger i; // Check whether a save of the current row is required. if ( ![[self onMainThread] saveRowOnDeselect] ) return; @@ -252,7 +251,6 @@ // Set up the encoding PopUpButtonCell NSArray *encodings = [databaseDataInstance getDatabaseCharacterSetEncodings]; if ([encodings count]) { - NSString *selectedTitle = @""; [encodingPopupCell removeAllItems]; [encodingPopupCell addItemWithTitle:@""]; @@ -874,7 +872,6 @@ if (alertSheetOpened) return NO; - NSInteger code; NSMutableString *queryString; BOOL fieldDefIncludesLen = NO; diff --git a/Source/SPTableStructureDelegate.m b/Source/SPTableStructureDelegate.m index 729091d6..3a46b763 100644 --- a/Source/SPTableStructureDelegate.m +++ b/Source/SPTableStructureDelegate.m @@ -25,6 +25,10 @@ #import "SPTableStructureDelegate.h" #import "SPAlertSheets.h" +#import "SPDatabaseData.h" +#import "SPDatabaseViewController.h" +#import "SPTableData.h" +#import "SPTableFieldValidation.h" @implementation SPTableStructure (SPTableStructureDelegate) @@ -94,7 +98,7 @@ currentlyEditingRow = rowIndex; } - NSDictionary *currentRow = [tableFields objectAtIndex:rowIndex]; + NSMutableArray *currentRow = [tableFields objectAtIndex:rowIndex]; // Reset collation if encoding was changed if([[aTableColumn identifier] isEqualToString:@"encoding"]) { @@ -498,7 +502,7 @@ // validate cell against current field type NSDictionary *theRow = NSArrayObjectAtIndex(tableFields, rowIndex); NSString *theRowType = @""; - if(theRowType = [theRow objectForKey:@"type"]) + if((theRowType = [theRow objectForKey:@"type"])) theRowType = [[theRowType stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString]; // Only string fields allow encoding settings diff --git a/Source/SPTableView.m b/Source/SPTableView.m index 6e19c335..f1fccb09 100644 --- a/Source/SPTableView.m +++ b/Source/SPTableView.m @@ -25,6 +25,7 @@ #import "SPTableView.h" #import "SPQueryFavoriteManager.h" #import "SPDatabaseDocument.h" +#import "SPWindowController.h" @implementation SPTableView diff --git a/Source/SPTablesList.h b/Source/SPTablesList.h index 7729ed1d..e82903b2 100644 --- a/Source/SPTablesList.h +++ b/Source/SPTablesList.h @@ -55,7 +55,7 @@ IBOutlet id copyTableButton; IBOutlet id copyTableNameField; IBOutlet id copyTableMessageField; - IBOutlet id copyTableContentSwitch; + IBOutlet NSButton *copyTableContentSwitch; IBOutlet id tableSheet; IBOutlet id tableNameField; IBOutlet id tableEncodingButton; @@ -119,6 +119,9 @@ - (IBAction)openTableInNewTab:(id)sender; - (IBAction)togglePaneCollapse:(id)sender; +// Alert sheet callbacks +- (void)sheetDidEnd:(id)sheet returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo; + // Additional methods - (void)setConnection:(MCPConnection *)theConnection; - (void)doPerformQueryService:(NSString *)query; diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m index a0a9bf92..cc840e30 100644 --- a/Source/SPTablesList.m +++ b/Source/SPTablesList.m @@ -25,6 +25,7 @@ #import "SPTablesList.h" #import "SPDatabaseDocument.h" +#import "SPDatabaseViewController.h" #import "SPTableStructure.h" #import "SPTableContent.h" #import "SPTableData.h" @@ -62,18 +63,21 @@ { MCPResult *theResult; NSArray *resultRow; - NSInteger i; + NSUInteger i; NSString *previousSelectedTable = nil; + NSString *previousFilterString = nil; BOOL previousTableListIsSelectable = tableListIsSelectable; BOOL changeEncoding = ![[mySQLConnection encoding] isEqualToString:@"utf8"]; if (selectedTableName) previousSelectedTable = [[NSString alloc] initWithString:selectedTableName]; if (isTableListFiltered) { + previousFilterString = [[NSString alloc] initWithString:[listFilterField stringValue]]; if (filteredTables) [filteredTables release]; filteredTables = tables; if (filteredTableTypes) [filteredTableTypes release]; filteredTableTypes = tableTypes; isTableListFiltered = NO; + [[self onMainThread] clearFilter]; } tableListContainsViews = NO; @@ -256,11 +260,17 @@ selectedTableType = SPTableTypeNone; } - // Determine whether or not to show the list filter based on the number of tables, and clear it - [[self onMainThread] clearFilter]; - - if ([tables count] > 20) [self showFilter]; - else [self hideFilter]; + // Determine whether or not to preserve the existing filter, and whether to + // show or hide the list filter based on the number of tables + if ([tables count] > 20) { + [self showFilter]; + if (previousFilterString) { + [[listFilterField onMainThread] setStringValue:previousFilterString]; + [[self onMainThread] updateFilter:self]; + } + } else { + [self hideFilter]; + } // Set the filter placeholder text if ([tableDocumentInstance database]) { @@ -268,6 +278,7 @@ } if (previousSelectedTable) [previousSelectedTable release]; + if (previousFilterString) [previousFilterString release]; // Query the structure of all databases in the background if (sender == self) @@ -1219,7 +1230,6 @@ - (BOOL)selectItemsWithNames:(NSArray *)theNames { NSInteger i, tableType; - NSInteger itemIndex = NSNotFound; NSMutableIndexSet *selectionIndexSet = [NSMutableIndexSet indexSet]; // Loop through the unfiltered tables/views to find the desired item diff --git a/Source/SPTextView.m b/Source/SPTextView.m index 705f2a8a..769d4be8 100644 --- a/Source/SPTextView.m +++ b/Source/SPTextView.m @@ -33,6 +33,7 @@ #import "SPAlertSheets.h" #import "RegexKitLite.h" #import "SPBundleHTMLOutputController.h" +#import "SPDatabaseViewController.h" #pragma mark - #pragma mark lex init @@ -415,8 +416,6 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) continue; } - NSString *dbpath = [db substringFromIndex:[db rangeOfString:SPUniqueSchemaDelimiter].location]; - NSMutableArray *sortedTables = [NSMutableArray array]; if(aTableNameExists) { [sortedTables addObject:aTableName_id]; @@ -2675,7 +2674,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) BOOL allowToCheckForUpperCase; // now loop through all the tokens - while (token=yylex()){ + while ((token=yylex())){ allowToCheckForUpperCase = YES; diff --git a/Source/SPTextViewAdditions.m b/Source/SPTextViewAdditions.m index 9cefa758..e3f8b714 100644 --- a/Source/SPTextViewAdditions.m +++ b/Source/SPTextViewAdditions.m @@ -26,6 +26,7 @@ #import "SPTooltip.h" #import "SPBundleHTMLOutputController.h" #import "SPCustomQuery.h" +#import "SPAppController.h" @implementation NSTextView (SPTextViewAdditions) @@ -635,7 +636,7 @@ NSString *output = [cmd runBashCommandWithEnvironment:env atCurrentDirectoryPath:nil - callerInstance:[[NSApp delegate] frontDocument] + callerInstance:[(SPAppController*)[NSApp delegate] frontDocument] contextInfo:[NSDictionary dictionaryWithObjectsAndKeys: ([cmdData objectForKey:SPBundleFileNameKey])?:@"-", @"name", NSLocalizedString(@"Input Field", @"input field menu item label"), @"scope", diff --git a/Source/SPTooltip.m b/Source/SPTooltip.m index b0344d52..5a0a2a2e 100644 --- a/Source/SPTooltip.m +++ b/Source/SPTooltip.m @@ -229,10 +229,9 @@ static CGFloat slow_in_out (CGFloat t) - (id)init; { - if(self = [self initWithContentRect:NSMakeRect(1,1,1,1) - styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]) + if((self = [self initWithContentRect:NSMakeRect(1,1,1,1) + styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO])) { - ; } return self; } @@ -393,7 +392,7 @@ static CGFloat slow_in_out (CGFloat t) [keyWindow setAcceptsMouseMovedEvents:YES]; NSEvent* event = nil; NSInteger eventType; - while(event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantFuture] inMode:NSDefaultRunLoopMode dequeue:YES]) + while((event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantFuture] inMode:NSDefaultRunLoopMode dequeue:YES])) { eventType = [event type]; if(eventType == NSKeyDown || eventType == NSLeftMouseDown || eventType == NSRightMouseDown || eventType == NSOtherMouseDown || eventType == NSScrollWheel) diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m index 9118d8a9..5a673389 100644 --- a/Source/SPUserManager.m +++ b/Source/SPUserManager.m @@ -173,7 +173,7 @@ static const NSString *SPTableViewNameColumnID = @"NameColumn"; } if (result && [result numOfRows]) { - while (privRow = [result fetchRowAsArray]) + while ((privRow = [result fetchRowAsArray])) { privKey = [NSMutableString stringWithString:[[privRow objectAtIndex:0] lowercaseString]]; @@ -192,7 +192,7 @@ static const NSString *SPTableViewNameColumnID = @"NameColumn"; [result setReturnDataAsStrings:YES]; - while (privRow = [result fetchRowAsArray]) + while ((privRow = [result fetchRowAsArray])) { privKey = [NSMutableString stringWithString:[privRow objectAtIndex:0]]; diff --git a/Source/SPWindow.m b/Source/SPWindow.m index 8f2354db..22a096c3 100644 --- a/Source/SPWindow.m +++ b/Source/SPWindow.m @@ -23,7 +23,7 @@ // More info at <http://code.google.com/p/sequel-pro/> #import "SPWindow.h" - +#import "SPWindowController.h" @implementation SPWindow @@ -62,7 +62,7 @@ context:[NSGraphicsContext currentContext] eventNumber:0 clickCount:1 - pressure:0.0]; + pressure:0.0f]; [NSMenu popUpContextMenu:[firstResponder menuForEvent:theEvent] withEvent:anEvent forView:firstResponder]; diff --git a/Source/SPWindowAdditions.m b/Source/SPWindowAdditions.m index 9d99de4f..676019ee 100644 --- a/Source/SPWindowAdditions.m +++ b/Source/SPWindowAdditions.m @@ -25,6 +25,7 @@ #import "SPWindowAdditions.h" #import "SPDatabaseDocument.h" +#import "SPWindowController.h" @implementation NSWindow (SPWindowAdditions) diff --git a/Source/SPWindowController.m b/Source/SPWindowController.m index b22248fe..7fdb76e6 100644 --- a/Source/SPWindowController.m +++ b/Source/SPWindowController.m @@ -25,6 +25,8 @@ #import "SPWindowController.h" #import "SPDatabaseDocument.h" #import "PSMTabDragAssistant.h" +#import "SPDatabaseViewController.h" +#import "SPAppController.h" #import <PSMTabBar/PSMTabBarControl.h> #import <PSMTabBar/PSMTabStyle.h> @@ -160,7 +162,7 @@ { // Return if the selected tab shouldn't be closed - if (![selectedTableDocument parentTabShouldClose]) return NO; + if (![selectedTableDocument parentTabShouldClose]) return; // If there are multiple tabs, close the front tab. if ([tabView numberOfTabViewItems] > 1) { diff --git a/Source/xibLocalizationPostprocessor.m b/Source/xibLocalizationPostprocessor.m index a6379aa7..ad2e152d 100644 --- a/Source/xibLocalizationPostprocessor.m +++ b/Source/xibLocalizationPostprocessor.m @@ -51,7 +51,7 @@ int main(int argc, const char *argv[]) } } - NSLog(@"Warning: skipped garbage input line %d, contents: \"%@\"", lineCount, line); + NSLog(@"Warning: skipped garbage input line %lu, contents: \"%@\"", (unsigned long)lineCount, line); } if (outputStrings.length && ![outputStrings writeToFile:[NSString stringWithUTF8String:argv[2]] atomically:NO encoding:usedEncoding error:&error]) { @@ -59,4 +59,4 @@ int main(int argc, const char *argv[]) exit (-1); } } [autoreleasePool release]; -}
\ No newline at end of file +} diff --git a/sequel-pro.xcodeproj/project.pbxproj b/sequel-pro.xcodeproj/project.pbxproj index 8d7db6c0..f216a722 100644 --- a/sequel-pro.xcodeproj/project.pbxproj +++ b/sequel-pro.xcodeproj/project.pbxproj @@ -3897,29 +3897,29 @@ GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO; GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; - GCC_WARN_INHIBIT_ALL_WARNINGS = YES; + GCC_WARN_INHIBIT_ALL_WARNINGS = NO; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = NO; - GCC_WARN_PROTOTYPE_CONVERSION = YES; + GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; - GCC_WARN_STRICT_SELECTOR_MATCH = YES; - GCC_WARN_UNDECLARED_SELECTOR = NO; + GCC_WARN_STRICT_SELECTOR_MATCH = NO; + GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; - GCC_WARN_UNUSED_PARAMETER = YES; + GCC_WARN_UNUSED_PARAMETER = NO; GCC_WARN_UNUSED_VALUE = YES; GCC_WARN_UNUSED_VARIABLE = YES; IBC_WARNINGS = YES; PREBINDING = NO; SDKROOT = macosx10.5; VALID_ARCHS = "i386 ppc x86_64"; - WARNING_CFLAGS = ""; + WARNING_CFLAGS = "-Wmost"; }; name = Distribution; }; @@ -4222,22 +4222,22 @@ GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO; GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; - GCC_WARN_INHIBIT_ALL_WARNINGS = YES; + GCC_WARN_INHIBIT_ALL_WARNINGS = NO; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = NO; - GCC_WARN_PROTOTYPE_CONVERSION = YES; + GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; - GCC_WARN_STRICT_SELECTOR_MATCH = YES; - GCC_WARN_UNDECLARED_SELECTOR = NO; + GCC_WARN_STRICT_SELECTOR_MATCH = NO; + GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; - GCC_WARN_UNUSED_PARAMETER = YES; + GCC_WARN_UNUSED_PARAMETER = NO; GCC_WARN_UNUSED_VALUE = YES; GCC_WARN_UNUSED_VARIABLE = YES; IBC_FLATTEN_NIBS = NO; @@ -4251,7 +4251,7 @@ SDKROOT = macosx10.5; STRIP_INSTALLED_PRODUCT = NO; VALID_ARCHS = "i386 ppc x86_64"; - WARNING_CFLAGS = ""; + WARNING_CFLAGS = "-Wmost"; }; name = Debug; }; @@ -4275,29 +4275,29 @@ GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO; GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; - GCC_WARN_INHIBIT_ALL_WARNINGS = YES; + GCC_WARN_INHIBIT_ALL_WARNINGS = NO; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_PEDANTIC = NO; - GCC_WARN_PROTOTYPE_CONVERSION = YES; + GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; - GCC_WARN_STRICT_SELECTOR_MATCH = YES; - GCC_WARN_UNDECLARED_SELECTOR = NO; + GCC_WARN_STRICT_SELECTOR_MATCH = NO; + GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; - GCC_WARN_UNUSED_PARAMETER = YES; + GCC_WARN_UNUSED_PARAMETER = NO; GCC_WARN_UNUSED_VALUE = YES; GCC_WARN_UNUSED_VARIABLE = YES; IBC_WARNINGS = YES; PREBINDING = NO; SDKROOT = macosx10.5; VALID_ARCHS = "i386 ppc x86_64"; - WARNING_CFLAGS = ""; + WARNING_CFLAGS = "-Wmost"; }; name = Release; }; |