aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/NSNotificationAdditions.m47
-rw-r--r--Source/SPAlertSheets.m6
-rw-r--r--Source/SPDataAdditions.m18
-rw-r--r--Source/SPExportFileUtilities.m13
-rw-r--r--Source/SPExportFilenameUtilities.m2
-rw-r--r--Source/SPExportInitializer.m2
-rw-r--r--Source/SPKeychain.m56
-rw-r--r--Source/SPSSHTunnel.h8
-rw-r--r--Source/SPSSHTunnel.m4
-rw-r--r--Source/SPStringAdditions.h4
-rw-r--r--Source/SPStringAdditions.m23
-rw-r--r--Source/xibLocalizationPostprocessor.m4
12 files changed, 109 insertions, 78 deletions
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/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/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/SPExportFileUtilities.m b/Source/SPExportFileUtilities.m
index b4d31d67..d39aee17 100644
--- a/Source/SPExportFileUtilities.m
+++ b/Source/SPExportFileUtilities.m
@@ -138,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 ed60846f..f1868210 100644
--- a/Source/SPExportInitializer.m
+++ b/Source/SPExportInitializer.m
@@ -280,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/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/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 ceed74b4..16d0c590 100644
--- a/Source/SPSSHTunnel.m
+++ b/Source/SPSSHTunnel.m
@@ -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/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 21059ba2..421ef4c1 100644
--- a/Source/SPStringAdditions.m
+++ b/Source/SPStringAdditions.m
@@ -164,7 +164,7 @@
{
NSMutableString *holder = [[NSMutableString alloc] init];
unichar theChar;
- int i;
+ NSUInteger i;
for(i = 0; i < [self length]; i++) {
theChar = [self characterAtIndex:i];
@@ -492,7 +492,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];
@@ -504,7 +504,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];
@@ -673,12 +673,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 @"";
@@ -694,7 +694,7 @@
NSBeep();
}
if(status > SPBundleRedirectActionNone && status <= SPBundleRedirectActionLastCode)
- return stdout;
+ return stdoutContent;
else
return @"";
}
@@ -702,12 +702,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/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
+}