From: Michael J. Rubinsky Date: Tue, 31 Aug 2010 23:39:32 +0000 (-0400) Subject: plug small memory leak, ws, file headers X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b63bc3a168f95e80f59e004ed0f32382537b8e0c;p=horde.git plug small memory leak, ws, file headers --- diff --git a/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.h b/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.h index 3bbf920b2..33be5eee0 100644 --- a/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.h +++ b/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.h @@ -1,11 +1,12 @@ -// -// ApertureToAnselExportPlugin.h -// ApertureToAnselExportPlugin -// -// Created by Michael Rubinsky on 8/29/09. -// Copyright __MyCompanyName__ 2009. All rights reserved. -// - +/** + * ApertureToAnselExportPlugin.h + * ApertureToAnselExportPlugin + * + * Copyright 2009-2010 The Horde Project (http://www.horde.org) + * + * @license http://opensource.org/licenses/bsd-license.php + * @author Michael J. Rubinsky + */ #import #import @@ -20,46 +21,46 @@ #endif { // The cached API Manager object, as passed to the -initWithAPIManager: method. - id _apiManager; - + id _apiManager; + // The cached Aperture Export Manager object - you should fetch this from the API Manager during -initWithAPIManager: - NSObject *_exportManager; - + NSObject *_exportManager; + // The lock used to protect all access to the ApertureExportProgress structure NSLock *_progressLock; - + // Top-level objects in the nib are automatically retained - this array // tracks those, and releases them NSArray *_topLevelNibObjects; - + // The structure used to pass all progress information back to Aperture ApertureExportProgress exportProgress; // TURAnsel objects TURAnselGallery *_currentGallery; TURAnsel *_anselController; - + // Outlets to your plug-ins user interface IBOutlet NSView *settingsView; IBOutlet NSView *firstView; IBOutlet NSView *lastView; - + IBOutlet NSComboBox *galleryCombo; IBOutlet NSTextField *statusLabel; IBOutlet NSProgressIndicator *spinner; IBOutlet NSImageView *defaultImageView; IBOutlet NSButton *mNewGalleryButton; IBOutlet NSPopUpButton *mServersPopUp; - + // New Server sheet IBOutlet NSWindow *newServerSheet; IBOutlet NSTextField *mServerSheetHostURL; - IBOutlet NSTextField *mServerSheetUsername; + IBOutlet NSTextField *mServerSheetUsername; IBOutlet NSSecureTextField *mServerSheetPassword; IBOutlet NSTextField *mServerSheetServerNickName; IBOutlet NSButton *mMakeNewServerDefault; IBOutlet NSPopUpButton *mAnselVersion; - + // Server list IBOutlet NSPanel *serverListPanel; IBOutlet NSTableView *serverTable; @@ -74,11 +75,11 @@ IBOutlet NSButton *closeGalleryView; IBOutlet IKImageBrowserView *browserView; NSMutableArray *_browserData; - + // Flags, counters etc... BOOL cancelExport; int _currentImageCount; - + BOOL isExporting; } diff --git a/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.m b/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.m index 600100879..cae05609e 100644 --- a/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.m +++ b/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.m @@ -1,11 +1,12 @@ -// -// ApertureToAnselExportPlugin.m -// ApertureToAnselExportPlugin -// -// Created by Michael Rubinsky on 8/29/09. -// Copyright __MyCompanyName__ 2009. All rights reserved. -// - +/** + * ApertureToAnselExportPlugin.m + * ApertureToAnselExportPlugin + * + * Copyright 2009-2010 The Horde Project (http://www.horde.org) + * + * @license http://opensource.org/licenses/bsd-license.php + * @author Michael J. Rubinsky + */ #import "ApertureToAnselExportPlugin.h" #import "TURAnselKit.h" #import "NSStringAdditions.h" @@ -58,36 +59,36 @@ NSString * const TURAnselServerVersionKey = @"version"; if (!_exportManager) { return nil; } - + _progressLock = [[NSLock alloc] init]; - + // Register Application Defaults NSMutableDictionary *defaultValues = [NSMutableDictionary dictionary]; [defaultValues setObject: [NSNumber numberWithInt: 2] - forKey: TURAnselExportSize]; - + forKey: TURAnselExportSize]; + [defaultValues setObject: [[NSArray alloc] init] forKey: TURAnselServersKey]; - + [defaultValues setObject: [[NSDictionary alloc] init] forKey: TURAnselDefaultServerKey]; - + NSUserDefaults *userPrefs = [NSUserDefaults standardUserDefaults]; [userPrefs registerDefaults: defaultValues]; [self setStatusText: @"Not Connected" withColor: [NSColor redColor]]; [spinner stopAnimation: self]; - + // See if we have any configured servers (need a mutable array, hence the extra step here) _anselServers = [[NSMutableArray alloc] initWithArray: [userPrefs objectForKey:TURAnselServersKey]]; - + // Wait until Aperture's export window is fully loaded before attempting a sheet [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(exportWindowDidBecomeKey:) - name: NSWindowDidBecomeKeyNotification + name: NSWindowDidBecomeKeyNotification object :nil]; - - // Holds gallery's images info for the gallery preview + + // Holds gallery's images info for the gallery preview _browserData = [[NSMutableArray alloc] init]; - + [self lockProgress]; exportProgress.currentValue = 0; exportProgress.totalValue = 0; @@ -103,24 +104,24 @@ NSString * const TURAnselServerVersionKey = @"version"; NSLog(@"ApertureToAnselExportPlugin: dealloc called"); [_anselServers release]; _anselServers = nil; - + [_anselController setDelegate:nil]; [_anselController release]; _anselController = nil; - + [_browserData release]; _browserData = nil; - + // Release the top-level objects from the nib. [_topLevelNibObjects makeObjectsPerformSelector:@selector(release)]; [_topLevelNibObjects release]; - + [_progressLock release]; _progressLock = nil; - + [_exportManager release]; _exportManager = nil; - + [super dealloc]; } @@ -142,7 +143,7 @@ NSString * const TURAnselServerVersionKey = @"version"; } [myNib release]; } - + return settingsView; } @@ -171,22 +172,22 @@ NSString * const TURAnselServerVersionKey = @"version"; - (BOOL)allowsOnlyPlugInPresets { - return NO; + return NO; } - (BOOL)allowsMasterExport { - return NO; + return NO; } - (BOOL)allowsVersionExport { - return YES; + return YES; } - (BOOL)wantsFileNamingControls { - return NO; + return NO; } - (void)exportManagerExportTypeDidChange @@ -218,7 +219,7 @@ NSString * const TURAnselServerVersionKey = @"version"; #pragma mark Export Process Methods - (void)exportManagerShouldBeginExport -{ +{ NSLog(@"exportManagerShouldBeginExport: %@", _currentGallery); if (_currentGallery == nil) { NSLog(@"No gallery selected."); @@ -234,7 +235,7 @@ NSString * const TURAnselServerVersionKey = @"version"; [_exportManager shouldBeginExport]; } -- (void)exportManagerWillBeginExportToPath:(NSString *)path +- (void)exportManagerWillBeginExportToPath:(NSString *)path { // noop } @@ -259,7 +260,7 @@ NSString * const TURAnselServerVersionKey = @"version"; index + 1, [_exportManager imageCount]] retain]; [self unlockProgress]; - NSString *base64ImageData = [NSString base64StringFromData: imageData + NSString *base64ImageData = [NSString base64StringFromData: imageData length: [imageData length]]; NSDictionary *properties = [_exportManager propertiesWithoutThumbnailForImageAtIndex: index]; NSArray *keys = [[NSArray alloc] initWithObjects: @@ -276,7 +277,7 @@ NSString * const TURAnselServerVersionKey = @"version"; fileType = @"image/png"; } else if ([format isEqual: [NSNumber numberWithInt: kApertureImageFormatTIFF8]] || [format isEqual: [NSNumber numberWithInt: kApertureImageFormatTIFF16]]) { - + // Ansel can handle converting the tiff - it is obviously unable to display the original TIFF file. fileType = @"image/tiff"; } else { @@ -286,7 +287,7 @@ NSString * const TURAnselServerVersionKey = @"version"; } NSLog(@"Image Type: %@", fileType); - + NSArray *values = [[NSArray alloc] initWithObjects: path, [properties objectForKey: kExportKeyVersionName], @@ -298,14 +299,14 @@ NSString * const TURAnselServerVersionKey = @"version"; NSDictionary *imageDataDict = [[NSDictionary alloc] initWithObjects:values forKeys:keys]; NSDictionary *params = [[NSDictionary alloc] initWithObjectsAndKeys: - imageDataDict, @"data", + imageDataDict, @"data", [NSNumber numberWithBool:NO], @"default", nil]; - + //Start upload with current gallery. NSLog(@"Uploading photo %d out of %d", index, [_exportManager imageCount]); - + // Make sure we are around for all callbacks to return even if Aperture cancelled. [self retain]; [_currentGallery uploadImageObject: params]; @@ -314,10 +315,10 @@ NSString * const TURAnselServerVersionKey = @"version"; [imageDataDict release]; [params release]; - + // Returning NO informs Aperture that the plugin is handling the export, // and NOT Aperture. - return NO; + return NO; } // Basically just a success callback @@ -331,10 +332,10 @@ NSString * const TURAnselServerVersionKey = @"version"; // You must call [_exportManager shouldFinishExport] before Aperture will put away the progress window and complete the export. // NOTE: You should assume that your plug-in will be deallocated immediately following this call. Be sure you have cleaned up // any callbacks or running threads before calling. - [[NSNotificationCenter defaultCenter] removeObserver: self + [[NSNotificationCenter defaultCenter] removeObserver: self name: @"NSPopUpButtonWillPopUpNotification" object: nil]; - + [_exportManager shouldFinishExport]; } @@ -343,7 +344,7 @@ NSString * const TURAnselServerVersionKey = @"version"; // You must call [_exportManager shouldCancelExport] here or elsewhere before Aperture will cancel the export process // NOTE: You should assume that your plug-in will be deallocated immediately following this call. Be sure you have cleaned up // any callbacks or running threads before calling. - [[NSNotificationCenter defaultCenter] removeObserver: self + [[NSNotificationCenter defaultCenter] removeObserver: self name: @"NSPopUpButtonWillPopUpNotification" object: nil]; [_anselController cancel]; @@ -360,7 +361,7 @@ NSString * const TURAnselServerVersionKey = @"version"; } - (void)lockProgress -{ +{ if (!_progressLock) { _progressLock = [[NSLock alloc] init]; } @@ -383,7 +384,7 @@ NSString * const TURAnselServerVersionKey = @"version"; // The ansel controller is initialized, populate the gallery data // and update the UI. - (void)TURAnselDidInitialize -{ +{ NSLog(@"TURAnselDidInitialize"); // Release now that the callback has completed. [self release]; @@ -400,7 +401,7 @@ NSString * const TURAnselServerVersionKey = @"version"; { NSLog(@"method: %@", method); NSLog(@"results: %@", results); - + } //@TODO - need to add a flag to indicate if we have a UI or not @@ -410,7 +411,7 @@ NSString * const TURAnselServerVersionKey = @"version"; // Stop the spinner [spinner stopAnimation: self]; [mServersPopUp setEnabled: true]; - + NSAlert *alert; // For some reason, this method doesn't pick up our userInfo dictionary... if ([[error userInfo] valueForKey:@"NSLocalizedDescriptionKey"] == nil) { @@ -423,7 +424,7 @@ NSString * const TURAnselServerVersionKey = @"version"; [alert setInformativeText: [[error userInfo] valueForKey: @"NSLocalizedRecoverySuggestionErrorKey"]]; } } - + [alert beginSheetModalForWindow:[self window] modalDelegate:nil didEndSelector:nil @@ -447,7 +448,7 @@ NSString * const TURAnselServerVersionKey = @"version"; #pragma mark - #pragma mark comboBoxDelegate - (void)comboBoxSelectionDidChange:(NSNotification *)notification -{ +{ [spinner startAnimation: self]; [self setStatusText: @"Loading gallery data..."]; int row = [galleryCombo indexOfSelectedItem]; @@ -455,11 +456,11 @@ NSString * const TURAnselServerVersionKey = @"version"; [_currentGallery autorelease]; _currentGallery = [[_anselController getGalleryByIndex:row] retain]; [_currentGallery setDelegate: self]; - + // Obtain and properly size the image for screen NSImage *theImage = [[NSImage alloc] initWithContentsOfURL: [_currentGallery galleryKeyImageURL]]; NSSize imageSize; - + // [NSImage bestRepresentationForDevice] is deprecated in 10.6, use bestRepresentationForRect:context:hints: instead if // we are compiling for a TARGET of 10.6 #if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5 @@ -471,10 +472,10 @@ NSString * const TURAnselServerVersionKey = @"version"; #endif [theImage setScalesWhenResized:YES]; [theImage setSize:imageSize]; - + // Show it [defaultImageView setImage: theImage]; - + [theImage release]; [self canExport]; [viewGallery setEnabled: YES]; @@ -488,9 +489,9 @@ NSString * const TURAnselServerVersionKey = @"version"; [[NSNotificationCenter defaultCenter] removeObserver: self name: NSWindowDidBecomeKeyNotification object: nil]; - + [self updateServersPopupMenu]; - + if ([_anselServers count] == 0) { [self showNewServerSheet]; } else { @@ -500,7 +501,7 @@ NSString * const TURAnselServerVersionKey = @"version"; if ([defaultServer count]) { _currentServer = [defaultServer retain]; int itemCount = [mServersPopUp numberOfItems]; - + // C99 mode is off by default in Apple's gcc. int i; for (i = 0; i < itemCount; i++) { @@ -510,7 +511,7 @@ NSString * const TURAnselServerVersionKey = @"version"; break; } } - + [self doConnect]; } } @@ -546,16 +547,16 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn [newServerSheet orderOut: nil]; _currentServer = [newServer retain]; [self doConnect]; - + // Save it to the userdefaults NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; - [prefs setObject:_anselServers forKey:TURAnselServersKey]; - + [prefs setObject:_anselServers forKey:TURAnselServersKey]; + int defaultState = [mMakeNewServerDefault state]; if (defaultState == NSOnState) { [prefs setObject: _currentServer forKey: TURAnselDefaultServerKey]; } - + [prefs synchronize]; [self updateServersPopupMenu]; [newServer release]; @@ -606,18 +607,18 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn [self setStatusText: @"Connected" withColor: [NSColor greenColor]]; return; } - + for (NSDictionary *image in images) { // The CF Web Services library can return NSNull objects for values that // were returned as empty or null, so we need to check for that. - // (Even if caption is nil, caption.length will still be zero, so we + // (Even if caption is nil, caption.length will still be zero, so we // don't need a seperate case for that). NSLog(@"Image: %@", image); NSString *caption = [image objectForKey:@"caption"]; if (caption == (NSString *)[NSNull null] || [caption length] == 0) { caption = [image objectForKey:@"name"]; } - + NSDate *theDate = [NSDate dateWithTimeIntervalSince1970: [[image objectForKey:@"original_date"] doubleValue]]; AnselGalleryViewItem *item = [[AnselGalleryViewItem alloc] initWithURL: [NSURL URLWithString: [image objectForKey:@"url"]] withTitle: caption @@ -625,18 +626,18 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn [_browserData addObject: item]; [item release]; } - + [NSApp beginSheet: mviewGallerySheet modalForWindow: [self window] modalDelegate: nil didEndSelector: nil contextInfo: nil]; - + [spinner stopAnimation: self]; [self setStatusText: @"Connected" withColor: [NSColor greenColor]]; - + [browserView reloadData]; - + } - (IBAction) closeGalleryView: (id)sender @@ -657,24 +658,24 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn - (IBAction)removeServer: (id)sender { NSTableColumn *theCol = [serverTable tableColumnWithIdentifier:@"nickname"]; - - // We are deleting the entry for the currently selected server - make sure + + // We are deleting the entry for the currently selected server - make sure // we disconnect. if ([_currentServer objectForKey:TURAnselServerNickKey] == [[theCol dataCell] stringValue]) { [self disconnect]; } - - NSUserDefaults *userPrefs = [NSUserDefaults standardUserDefaults]; - + + NSUserDefaults *userPrefs = [NSUserDefaults standardUserDefaults]; + // See if the removed server is the current default. if ([[userPrefs objectForKey:TURAnselDefaultServerKey] objectForKey: TURAnselServerNickKey] == [[theCol dataCell] stringValue]) { [userPrefs setObject: nil forKey:TURAnselDefaultServerKey]; } - + // Remove it from the servers dictionary [_anselServers removeObjectAtIndex: [serverTable selectedRow]]; [userPrefs setObject:_anselServers forKey:TURAnselServersKey]; - + [userPrefs synchronize]; [serverTable reloadData]; [self updateServersPopupMenu]; @@ -686,10 +687,10 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn NSLog(@"showNewGallery:"); TURAnselGalleryPanelController *newGalleryController; //NSString *albumName; - + // Make sure we're not doing this for nothing if ([_anselController state] == TURAnselStateConnected) { - + //albumName = [mExportMgr albumNameAtIndex: 0]; newGalleryController = [[TURAnselGalleryPanelController alloc] initWithController: _anselController]; [newGalleryController setDelegate: self]; @@ -708,8 +709,8 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn [galleryCombo setEnabled: YES]; //} else { if (1 == 2) { - - + + [mNewGalleryButton setEnabled: NO]; [galleryCombo setEnabled: NO]; [viewGallery setEnabled: NO]; @@ -739,14 +740,14 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn [menuItem setRepresentedObject: server]; [[mServersPopUp menu] addItem: menuItem]; } - + // add separator [[mServersPopUp menu] addItem:[NSMenuItem separatorItem]]; - + // add Add Gallery... and Edit List... options [mServersPopUp addItemWithTitle:@"Add Server..."]; [mServersPopUp addItemWithTitle:@"Edit Server List..."]; - + // fix selection [mServersPopUp selectItemAtIndex:0]; } @@ -758,7 +759,7 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn modalDelegate: nil didEndSelector: nil contextInfo: nil]; - + // Make sure these are cleared. [mServerSheetHostURL setStringValue: @""]; [mServerSheetUsername setStringValue: @""]; @@ -802,15 +803,15 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn [_anselController autorelease]; _anselController = [[TURAnsel alloc] initWithConnectionParameters:p]; [_anselController setDelegate:self]; - + // Set up the galleryCombo [galleryCombo setDataSource:_anselController]; [galleryCombo setDelegate:self]; [spinner startAnimation:self]; - + // Detach to a new thread and do the actual login/retrieval of gallery list [NSApplication detachDrawingThread: @selector(connect) - toTarget: self + toTarget: self withObject: nil]; [p release]; @@ -845,14 +846,14 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn [_anselController setDelegate: nil]; [_anselController release]; _anselController = nil; - + [self setStatusText:@"Not logged in" withColor: [NSColor redColor]]; } #pragma mark - #pragma mark IKImageBrowserView Datasource methods - (NSUInteger)numberOfItemsInImageBrowser:(IKImageBrowserView *) aBrowser -{ +{ return [_browserData count]; } diff --git a/ApertureToAnselExportPlugin/TURAnselKit/AnselGalleryViewItem.h b/ApertureToAnselExportPlugin/TURAnselKit/AnselGalleryViewItem.h index 91cbd8433..8a9803d78 100644 --- a/ApertureToAnselExportPlugin/TURAnselKit/AnselGalleryViewItem.h +++ b/ApertureToAnselExportPlugin/TURAnselKit/AnselGalleryViewItem.h @@ -2,7 +2,7 @@ * AnselGalleryViewItem * * Copyright 2009-2010 The Horde Project (http://www.horde.org) - * + * * @implements IKImageBrowserItem * @license http://opensource.org/licenses/bsd-license.php * @author Michael J. Rubinsky @@ -10,7 +10,7 @@ #import #import -@interface AnselGalleryViewItem: NSObject +@interface AnselGalleryViewItem: NSObject { NSURL *image; NSString *imageID; diff --git a/ApertureToAnselExportPlugin/TURAnselKit/AnselGalleryViewItem.m b/ApertureToAnselExportPlugin/TURAnselKit/AnselGalleryViewItem.m index 42edf5b21..15aed58cc 100644 --- a/ApertureToAnselExportPlugin/TURAnselKit/AnselGalleryViewItem.m +++ b/ApertureToAnselExportPlugin/TURAnselKit/AnselGalleryViewItem.m @@ -5,7 +5,7 @@ * remote Ansel gallery in an IKImageBrowser. * * Copyright 2009-2010 The Horde Project (http://www.horde.org) - * + * * @implements IKImageBrowserItem * @license http://opensource.org/licenses/bsd-license.php * @author Michael J. Rubinsky @@ -25,7 +25,7 @@ imageID = [[theURL absoluteString] retain]; imageTitle = [theTitle retain]; imageDate = [theDate retain]; - return self; + return self; } - (void)dealloc { diff --git a/ApertureToAnselExportPlugin/TURAnselKit/TURAnsel.h b/ApertureToAnselExportPlugin/TURAnselKit/TURAnsel.h index 03e09a673..c3ea089c9 100644 --- a/ApertureToAnselExportPlugin/TURAnselKit/TURAnsel.h +++ b/ApertureToAnselExportPlugin/TURAnselKit/TURAnsel.h @@ -40,7 +40,7 @@ typedef enum { NSString *username; NSString *password; NSString *version; - + NSMutableArray *galleryList; TURAnselState state; id delegate; diff --git a/ApertureToAnselExportPlugin/TURAnselKit/TURAnsel.m b/ApertureToAnselExportPlugin/TURAnselKit/TURAnsel.m index a03f300c8..506cfacb5 100644 --- a/ApertureToAnselExportPlugin/TURAnselKit/TURAnsel.m +++ b/ApertureToAnselExportPlugin/TURAnselKit/TURAnsel.m @@ -78,7 +78,7 @@ { NSArray *apiparams; NSArray *order; - + if ([[self valueForKey: @"version"] intValue] == 2) { apiparams = [NSArray arrayWithObjects: params, nil]; order = [NSArray arrayWithObjects: kTURAnselAPIParamGalleryParams, nil]; @@ -86,7 +86,7 @@ apiparams = [NSArray arrayWithObjects: @"ansel", params, nil]; order = [NSArray arrayWithObjects: kTURAnselAPIParamScope, kTURAnselAPIParamGalleryParams, nil]; } - + NSDictionary *response = [self callRPCMethod: @"images.createGallery" withParams: apiparams withOrder: order]; @@ -156,17 +156,14 @@ NSLog(@"Results adding credentials to request: %d", success); if (!success) { NSLog(@"Unable to authenticate"); - if ([[self delegate] respondsToSelector: @selector(TURAnselHadError:)]) { NSError *error = [NSError errorWithDomain:@"TURAnsel" code: 1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys: @"Authentication failure.", @"message", nil]]; - [[self delegate] TURAnselHadError: error]; } return nil; - } else { // Build a new invocation [self setState:TURAnselStateWaiting]; @@ -214,25 +211,31 @@ [[self delegate] TURAnselHadError: error]; } [result autorelease]; - return nil; + return nil; } CFHTTPMessageRef response = (CFHTTPMessageRef)[result objectForKey:(id)kWSHTTPResponseMessage]; int resStatusCode = CFHTTPMessageGetResponseStatusCode(response); NSLog(@"ResponseCode: %d", resStatusCode); [self setState:TURAnselStateConnected]; + return [result autorelease]; } } - NSLog(@"No authentication information present."); - return nil; + return nil; } #pragma mark - #pragma mark Setters/Getters -// Fetch a gallery by id +/** + * Fetch a gallery by it's id. + * + * @param NSString galleryId The gallery's id. + * + * @return TURAnselGallery Then gallery object. + */ - (TURAnselGallery *)getGalleryById: (NSString *)galleryId { for (TURAnselGallery *g in galleryList) { @@ -247,6 +250,10 @@ /** * Return the gallery at the specified position in the internal storage array. * Needed for when we are using this class as a datasource for a UI element. + * + * @param NSInteger index The index into the storage array. + * + * @return TURAnselGallery The galley obejct located at the specified index. */ - (TURAnselGallery *)getGalleryByIndex: (NSInteger)index { @@ -260,7 +267,6 @@ { return [galleryList count]; } - - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)index { @@ -278,11 +284,9 @@ { state = newstate; } - - (id)delegate { return delegate; } - - (void)setDelegate:(id)newDelegate { delegate = newDelegate; } @@ -298,35 +302,32 @@ { NSArray *params; NSArray *order; - + if ([[self valueForKey: @"version"] intValue] == 2) { - params = [[NSArray alloc] initWithObjects: [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithInt: PERMS_EDIT], @"perm", - [self valueForKey:@"username"], @"filter", - nil] ,nil]; + params = [NSArray arrayWithObjects: [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt: PERMS_EDIT], @"perm", + [self valueForKey:@"username"], @"filter", + nil], + nil]; order = [NSArray arrayWithObjects: kTURAnselAPIParamSingleParameter, nil]; } else { // Assume it's version 1.x - params = [[NSArray alloc] initWithObjects: + params = [NSArray arrayWithObjects: @"ansel", // Scope [NSNumber numberWithInt: PERMS_EDIT], // Perms @"", // No parent [NSNumber numberWithBool:YES], // allLevels [NSNumber numberWithInt: 0], // Offset [NSNumber numberWithInt: 0], // Count - [self valueForKey:@"username"], nil]; // Restrict to user (This should be an option eventually). + [self valueForKey:@"username"], nil]; // Restrict to user. order = [NSArray arrayWithObjects: kTURAnselAPIParamScope, kTURAnselAPIParamPerms, kTURAnselAPIParamParent, kTURAnselAPIParamAllLevels, kTURAnselAPIParamOffset, kTURAnselAPIParamCount, kTURAnselAPIParamUserOnly, nil]; } - - NSDictionary *results = [self callRPCMethod: @"images.listGalleries" withParams: params withOrder: order]; - if (results) { NSDictionary *galleries = [results objectForKey: (id)kWSMethodInvocationResult]; for (NSString *gal in galleries) { @@ -345,7 +346,5 @@ } } - - [params release]; } @end diff --git a/ApertureToAnselExportPlugin/TURAnselKit/TURAnselConstants.h b/ApertureToAnselExportPlugin/TURAnselKit/TURAnselConstants.h index c27f94fd3..757bdeaab 100644 --- a/ApertureToAnselExportPlugin/TURAnselKit/TURAnselConstants.h +++ b/ApertureToAnselExportPlugin/TURAnselKit/TURAnselConstants.h @@ -2,7 +2,7 @@ * TURAnselConstants * * Copyright 2009-2010 The Horde Project (http://www.horde.org) - * + * * @license http://opensource.org/licenses/bsd-license.php * @author Michael J. Rubinsky */ diff --git a/ApertureToAnselExportPlugin/TURAnselKit/TURAnselConstants.m b/ApertureToAnselExportPlugin/TURAnselKit/TURAnselConstants.m index 626443609..a0162b925 100644 --- a/ApertureToAnselExportPlugin/TURAnselKit/TURAnselConstants.m +++ b/ApertureToAnselExportPlugin/TURAnselKit/TURAnselConstants.m @@ -1,10 +1,12 @@ -// -// TURAnselConstants.m -// ApertureToAnselExportPlugin -// -// Created by Michael Rubinsky on 9/22/09. -// Copyright 2009 __MyCompanyName__. All rights reserved. -// +/** + * TURAnselConstants.m + * ApertureToAnselExportPlugin + * + * Copyright 2009-2010 The Horde Project (http://www.horde.org) + * + * @license http://opensource.org/licenses/bsd-license.php + * @author Michael J. Rubinsky + */ #import "TURAnselConstants.h" diff --git a/ApertureToAnselExportPlugin/TURAnselKit/TURAnselGallery.h b/ApertureToAnselExportPlugin/TURAnselKit/TURAnselGallery.h index 8c89d98db..e077773cc 100644 --- a/ApertureToAnselExportPlugin/TURAnselKit/TURAnselGallery.h +++ b/ApertureToAnselExportPlugin/TURAnselKit/TURAnselGallery.h @@ -2,7 +2,7 @@ * TURAnselGallery * * Copyright 2009-2010 The Horde Project (http://www.horde.org) - * + * * @license http://opensource.org/licenses/bsd-license.php * @author Michael J. Rubinsky */ diff --git a/ApertureToAnselExportPlugin/TURAnselKit/TURAnselGallery.m b/ApertureToAnselExportPlugin/TURAnselKit/TURAnselGallery.m index 6bb27d7f7..5506a001b 100644 --- a/ApertureToAnselExportPlugin/TURAnselKit/TURAnselGallery.m +++ b/ApertureToAnselExportPlugin/TURAnselKit/TURAnselGallery.m @@ -23,7 +23,7 @@ #pragma mark - #pragma mark init/dealloc /** - * Init a gallery object + * Initialize a gallery object */ - (id)initWithObject:(id)galleryData controller:(TURAnsel *)controller { @@ -67,6 +67,8 @@ * Requests the gallery's key image url to be fetched from the server * (This information is not present in the gallery definition array returned * from the images.listGalleries call). + * + * @return NSURL The url object */ - (NSURL *)galleryKeyImageURL { @@ -75,7 +77,6 @@ } else { NSArray *params; NSArray *order; - if ([[anselController valueForKey:@"version"] intValue] == 2) { // Version 2 API params = [NSArray arrayWithObjects: @@ -122,7 +123,7 @@ if (![imageList count]) { NSArray *params; NSArray *order; - + // if ([[anselController valueForKey:@"version"] intValue] == 2) { // listImages hasn't been refactored yet in version 2 API // } else { @@ -205,7 +206,7 @@ NSArray *params; NSArray *order; - + if ([[anselController valueForKey:@"version"] intValue] == 2) { params = [NSArray arrayWithObjects: [NSNumber numberWithInt: _galleryId], [imageParameters valueForKey: @"data"], @@ -231,7 +232,7 @@ kTURAnselAPIParamAdditionalData, kTURAnselAPIParamEncoding, nil]; } - + // Send the request up to the controller NSDictionary *result = [anselController callRPCMethod: @"images.saveImage" withParams: params diff --git a/ApertureToAnselExportPlugin/TURAnselKit/TURAnselGalleryPanelController.h b/ApertureToAnselExportPlugin/TURAnselKit/TURAnselGalleryPanelController.h index 2def0264e..d11d39fa1 100644 --- a/ApertureToAnselExportPlugin/TURAnselKit/TURAnselGalleryPanelController.h +++ b/ApertureToAnselExportPlugin/TURAnselKit/TURAnselGalleryPanelController.h @@ -2,7 +2,7 @@ * TURAnselGalleryPanelController * * Copyright 2009-2010 The Horde Project (http://www.horde.org) - * + * * @license http://opensource.org/licenses/bsd-license.php * @author Michael J. Rubinsky */ @@ -19,7 +19,7 @@ IBOutlet NSTextField *gallerySlugTextField; IBOutlet NSTextField *galleryDescTextField; IBOutlet NSPanel *newGallerySheet; - + // Instance members TURAnsel *_anselController; NSWindow *_controllerWindow; diff --git a/ApertureToAnselExportPlugin/TURAnselKit/TURAnselGalleryPanelController.m b/ApertureToAnselExportPlugin/TURAnselKit/TURAnselGalleryPanelController.m index 988d1b137..e7c375669 100644 --- a/ApertureToAnselExportPlugin/TURAnselKit/TURAnselGalleryPanelController.m +++ b/ApertureToAnselExportPlugin/TURAnselKit/TURAnselGalleryPanelController.m @@ -4,7 +4,7 @@ * Controller for handling the form that creates new remote Ansel galleries. * * Copyright 2009-2010 The Horde Project (http://www.horde.org) - * + * * @license http://opensource.org/licenses/bsd-license.php * @author Michael J. Rubinsky */ @@ -20,23 +20,23 @@ _anselController = [theController retain]; [NSBundle loadNibNamed: @"AnselGalleryPanel" owner: self]; - + return self; } - (id)initWithController: (TURAnsel *)theController - withGalleryName: (NSString *)galleryName + withGalleryName: (NSString *)galleryName { - + [super init]; _anselController = [theController retain]; [NSBundle loadNibNamed: @"AnselGalleryPanel" owner: self]; - + [galleryNameTextField setStringValue: galleryName]; - - return self; + + return self; } -- (void)dealloc +- (void)dealloc { [_anselController release]; [_controllerWindow release]; @@ -48,7 +48,7 @@ - (IBAction)cancelNewGallery: (id)sender { [NSApp endSheet: newGallerySheet]; - [newGallerySheet orderOut: nil]; + [newGallerySheet orderOut: nil]; } - (IBAction)doNewGallery: (id)sender @@ -57,17 +57,17 @@ NSString *galleryName = [galleryNameTextField stringValue]; NSString *gallerySlug = [gallerySlugTextField stringValue]; NSString *galleryDescription = [galleryDescTextField stringValue]; - + if (!galleryName) { - + [NSApp endSheet: newGallerySheet]; [newGallerySheet orderOut: nil]; - + NSAlert *alert = [[NSAlert alloc] init]; [alert setMessageText:@"Gallery names cannot be empty"]; [alert setAlertStyle: NSCriticalAlertStyle]; [alert beginSheetModalForWindow: _controllerWindow - modalDelegate: nil + modalDelegate: nil didEndSelector: nil contextInfo: nil]; [alert release]; @@ -77,12 +77,12 @@ galleryName, @"name", gallerySlug, @"slug", galleryDescription, @"desc", nil]; - + NSDictionary *results = [[_anselController createNewGallery: params] retain]; - + [NSApp endSheet: newGallerySheet]; [newGallerySheet orderOut: nil]; - + if ([_anselController state] != TURAnselStateError) { NSAlert *alert = [[NSAlert alloc] init]; [alert setMessageText: @"Gallery successfully created."]; @@ -95,7 +95,7 @@ [_delegate TURAnselGalleryPanelDidAddGallery]; } } - + [results release]; }