From: <joh...@us...> - 2006-12-28 15:18:19
|
Revision: 734 http://svn.sourceforge.net/vienna-rss/?rev=734&view=rev Author: johnson1234 Date: 2006-12-28 07:18:19 -0800 (Thu, 28 Dec 2006) Log Message: ----------- Don't show dialog when exporting subscriptions by AppleScript, because it can hang script. Patch from Darren Kulp. Modified Paths: -------------- trunk/2.1.0/CHANGES trunk/2.1.0/Export.h trunk/2.1.0/Export.m trunk/2.1.0/ViennaApp.m Modified: trunk/2.1.0/CHANGES =================================================================== --- trunk/2.1.0/CHANGES 2006-12-27 16:04:22 UTC (rev 733) +++ trunk/2.1.0/CHANGES 2006-12-28 15:18:19 UTC (rev 734) @@ -27,6 +27,7 @@ - Fix bug: subscriptions duplicated when exporting by AppleScript. (Thanks to Darren Kulp.) - Support blogging with Pukka. - Email page link from browser tab. +- Don't show dialog when exporting subscriptions by AppleScript. (Thanks to Darren Kulp.) 2.1.0.2108 ---------- Modified: trunk/2.1.0/Export.h =================================================================== --- trunk/2.1.0/Export.h 2006-12-27 16:04:22 UTC (rev 733) +++ trunk/2.1.0/Export.h 2006-12-28 15:18:19 UTC (rev 734) @@ -24,5 +24,5 @@ @interface AppController (Export) -(IBAction)exportSubscriptions:(id)sender; - -(void)exportToFile:(NSString *)exportFileName from:(NSArray *)foldersArray withGroups:(BOOL)groupFlag; + -(int)exportToFile:(NSString *)exportFileName from:(NSArray *)foldersArray withGroups:(BOOL)groupFlag; @end Modified: trunk/2.1.0/Export.m =================================================================== --- trunk/2.1.0/Export.m 2006-12-27 16:04:22 UTC (rev 733) +++ trunk/2.1.0/Export.m 2006-12-28 15:18:19 UTC (rev 734) @@ -70,7 +70,23 @@ [panel orderOut:self]; NSArray * foldersArray = ([exportSelected state] == NSOnState) ? [foldersTree selectedFolders] : [db arrayOfFolders:MA_Root_Folder]; - [self exportToFile:[panel filename] from:foldersArray withGroups:([exportWithGroups state] == NSOnState)]; + int countExported = [self exportToFile:[panel filename] from:foldersArray withGroups:([exportWithGroups state] == NSOnState)]; + + if (countExported < 0) + { + NSBeginCriticalAlertSheet(NSLocalizedString(@"Cannot open export file message", nil), + NSLocalizedString(@"OK", nil), + nil, + nil, [NSApp mainWindow], self, + nil, nil, nil, + NSLocalizedString(@"Cannot open export file message text", nil)); + } + else + { + // Announce how many we successfully imported + NSString * successString = [NSString stringWithFormat:NSLocalizedString(@"%d subscriptions successfully exported", nil), countExported]; + NSRunAlertPanel(NSLocalizedString(@"RSS Subscription Export Title", nil), successString, NSLocalizedString(@"OK", nil), nil, nil); + } } } @@ -121,8 +137,9 @@ /* exportToFile * Export a list of RSS subscriptions to the specified file. If onlySelected is set then only those * folders selected in the folders tree are exported. Otherwise all RSS folders are exported. + * Returns the number of subscriptions exported, or -1 on error. */ --(void)exportToFile:(NSString *)exportFileName from:(NSArray *)foldersArray withGroups:(BOOL)groupFlag +-(int)exportToFile:(NSString *)exportFileName from:(NSArray *)foldersArray withGroups:(BOOL)groupFlag { XMLParser * newTree = [[XMLParser alloc] initWithEmptyTree]; XMLParser * opmlTree = [newTree addTree:@"opml" withAttributes:[NSDictionary dictionaryWithObject:@"1.0" forKey:@"version"]]; @@ -143,14 +160,8 @@ NSString * fqFilename = [exportFileName stringByExpandingTildeInPath]; if (![[NSFileManager defaultManager] createFileAtPath:fqFilename contents:nil attributes:nil]) { - NSBeginCriticalAlertSheet(NSLocalizedString(@"Cannot open export file message", nil), - NSLocalizedString(@"OK", nil), - nil, - nil, [NSApp mainWindow], self, - nil, nil, nil, - NSLocalizedString(@"Cannot open export file message text", nil)); [newTree release]; - return; + return -1; // Indicate an error condition (impossible number of exports) } // Put some newlines in for readability @@ -160,12 +171,9 @@ [xmlString writeToFile:fqFilename atomically:YES]; [xmlString release]; - - // Announce how many we successfully imported - NSString * successString = [NSString stringWithFormat:NSLocalizedString(@"%d subscriptions successfully exported", nil), countExported]; - NSRunAlertPanel(NSLocalizedString(@"RSS Subscription Export Title", nil), successString, NSLocalizedString(@"OK", nil), nil, nil); // Clean up at the end [newTree release]; + return countExported; } @end Modified: trunk/2.1.0/ViennaApp.m =================================================================== --- trunk/2.1.0/ViennaApp.m 2006-12-27 16:04:22 UTC (rev 733) +++ trunk/2.1.0/ViennaApp.m 2006-12-28 15:18:19 UTC (rev 734) @@ -172,9 +172,10 @@ id argObject = [args objectForKey:@"Folder"]; NSArray * argArray = argObject ? [self evaluatedArrayOfFolders:argObject withCommand:cmd] : [[Database sharedDatabase] arrayOfFolders:MA_Root_Folder]; + int countExported = 0; if (argArray != nil) - [[self delegate] exportToFile:[args objectForKey:@"FileName"] from:argArray withGroups:YES]; - return nil; + countExported = [[self delegate] exportToFile:[args objectForKey:@"FileName"] from:argArray withGroups:YES]; + return [NSNumber numberWithInt:countExported]; } /* handleNewSubscription This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |