From: Michael J. Rubinsky Date: Tue, 31 Aug 2010 15:46:09 +0000 (-0400) Subject: First round of initial support for Ansel version 2 API. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=18697cef118d02c5938ae351de0d449c6c24551f;p=horde.git First round of initial support for Ansel version 2 API. Adds support for indicating which version a server exposes, and fixes api call for the listGalleries call. --- diff --git a/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.h b/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.h index 16ed66b49..3bbf920b2 100644 --- a/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.h +++ b/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.h @@ -58,6 +58,7 @@ IBOutlet NSSecureTextField *mServerSheetPassword; IBOutlet NSTextField *mServerSheetServerNickName; IBOutlet NSButton *mMakeNewServerDefault; + IBOutlet NSPopUpButton *mAnselVersion; // Server list IBOutlet NSPanel *serverListPanel; @@ -82,8 +83,6 @@ } - (IBAction) showNewGallery: (id)sender; -- (IBAction) doAddServer: (id)sender; -- (IBAction) doCancelAddServer: (id)sender; - (IBAction) clickServer: (id)sender; - (IBAction) clickViewGallery: (id)sender; - (IBAction) closeGalleryView: (id)sender; @@ -92,4 +91,8 @@ - (IBAction) closeServerList: (id)sender; - (IBAction) removeServer: (id)sender; - (NSWindow *)window; + +// New Server View +- (IBAction) doAddServer: (id)sender; +- (IBAction) doCancelAddServer: (id)sender; @end \ No newline at end of file diff --git a/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.m b/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.m index 7212b2283..cef3bb41b 100644 --- a/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.m +++ b/ApertureToAnselExportPlugin/ApertureToAnselExportPlugin.m @@ -36,6 +36,7 @@ NSString * const TURAnselServerNickKey = @"nickname"; NSString * const TURAnselServerEndpointKey = @"endpoint"; NSString * const TURAnselServerUsernameKey = @"username"; NSString * const TURAnselServerPasswordKey = @"password"; +NSString * const TURAnselServerVersionKey = @"version"; @implementation ApertureToAnselExportPlugin @@ -538,6 +539,7 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn [mServerSheetHostURL stringValue], TURAnselServerEndpointKey, [mServerSheetUsername stringValue], TURAnselServerUsernameKey, [mServerSheetPassword stringValue], TURAnselServerPasswordKey, + [NSNumber numberWithInt: [mAnselVersion indexOfSelectedItem] + 1] , TURAnselServerVersionKey, nil]; [_anselServers addObject: newServer]; [NSApp endSheet: newServerSheet]; @@ -584,6 +586,7 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn [self disconnect]; } _currentServer = [[mServersPopUp selectedItem] representedObject]; + NSLog(@"Current Server: %@", _currentServer); [self doConnect]; } } @@ -755,6 +758,11 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn didEndSelector: nil contextInfo: nil]; + // Populate the version popup + //[mAnselVersion addItemWithTitle:@"1.x"]; + //[mAnselVersion addItemWithTitle:@"2.x"]; + //[mAnselVersion setTitle:@"1.x"]; + // Make sure these are cleared. [mServerSheetHostURL setStringValue: @""]; [mServerSheetUsername setStringValue: @""]; @@ -786,8 +794,9 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn [_currentServer objectForKey:TURAnselServerEndpointKey], [_currentServer objectForKey:TURAnselServerUsernameKey], [_currentServer objectForKey:TURAnselServerPasswordKey], + [_currentServer objectForKey:TURAnselServerVersionKey], nil] - forKeys: [NSArray arrayWithObjects:@"endpoint", @"username", @"password", nil]]; + forKeys: [NSArray arrayWithObjects:TURAnselServerEndpointKey, TURAnselServerUsernameKey, TURAnselServerPasswordKey, TURAnselServerVersionKey, nil]]; // Create our controller [_anselController autorelease]; _anselController = [[TURAnsel alloc] initWithConnectionParameters:p]; diff --git a/ApertureToAnselExportPlugin/English.lproj/ApertureToAnselExportPlugin.nib/designable.nib b/ApertureToAnselExportPlugin/English.lproj/ApertureToAnselExportPlugin.nib/designable.nib index 69a386acc..c9f3f05a3 100644 --- a/ApertureToAnselExportPlugin/English.lproj/ApertureToAnselExportPlugin.nib/designable.nib +++ b/ApertureToAnselExportPlugin/English.lproj/ApertureToAnselExportPlugin.nib/designable.nib @@ -2,19 +2,17 @@ 1050 - 10B504 - 732 - 1038.2 - 437.00 + 10F569 + 762 + 1038.29 + 461.00 - 732 + 762 1.1 - - + - com.apple.imagekit.ibplugin @@ -32,7 +30,7 @@ NSApplication - + 268 @@ -115,11 +113,11 @@ 1048576 2147483647 1 - + NSImage NSMenuCheckmark - + NSImage NSMenuMixedState @@ -447,13 +445,12 @@ {528, 309} - NSView 23 2 - {{196, 315}, {455, 195}} + {{196, 280}, {455, 230}} -1543503872 Add Server NSPanel @@ -466,7 +463,7 @@ 268 - {{124, 124}, {311, 22}} + {{124, 159}, {311, 22}} YES @@ -488,7 +485,7 @@ 268 - {{17, 126}, {102, 17}} + {{17, 161}, {102, 17}} YES @@ -504,7 +501,7 @@ 268 - {{124, 92}, {311, 22}} + {{124, 127}, {311, 22}} YES @@ -521,7 +518,7 @@ 268 - {{124, 60}, {311, 22}} + {{124, 95}, {311, 22}} YES @@ -541,7 +538,7 @@ 268 - {{17, 94}, {67, 17}} + {{17, 129}, {67, 17}} YES @@ -557,7 +554,7 @@ 268 - {{17, 62}, {67, 17}} + {{17, 97}, {67, 17}} YES @@ -573,7 +570,7 @@ 268 - {{17, 158}, {102, 17}} + {{17, 193}, {102, 17}} YES @@ -589,7 +586,7 @@ 268 - {{124, 156}, {311, 22}} + {{124, 191}, {311, 22}} YES @@ -643,8 +640,79 @@ 25 + + + 268 + {{17, 69}, {67, 17}} + + YES + + 68288064 + 272630784 + Version + + + + + + + + + 268 + {{121, 63}, {100, 26}} + + YES + + -2076049856 + 2048 + + + 109199615 + 129 + + + 400 + 75 + + + 2.x + + 1048576 + 2147483647 + 1 + + + _popUpItemAction: + + + YES + + OtherViews + + + + 1.x + + 1048576 + 2147483647 + + + _popUpItemAction: + + + + + + + 1 + 1 + YES + YES + 2 + + - {455, 195} + {455, 230} {{0, 0}, {1920, 1178}} @@ -668,6 +736,7 @@ 268 {{568, 28}, {96, 28}} + YES 67239424 @@ -696,12 +765,14 @@ 256 {626, 247} + YES 256 {626, 17} + @@ -709,6 +780,7 @@ 256 {{627, 0}, {16, 17}} + @@ -823,6 +895,7 @@ {{1, 17}, {626, 247}} + @@ -833,6 +906,7 @@ 256 {{627, 17}, {15, 247}} + _doScroller: 1 @@ -843,6 +917,7 @@ 256 {{1, 264}, {626, 15}} + 1 _doScroller: @@ -856,6 +931,7 @@ {{1, 0}, {626, 17}} + @@ -865,6 +941,7 @@ {{20, 60}, {643, 280}} + 50 @@ -879,6 +956,7 @@ 268 {{15, 28}, {96, 28}} + YES 67239424 @@ -897,6 +975,7 @@ {679, 358} + {{0, 0}, {1920, 1178}} {1.79769e+308, 1.79769e+308} @@ -944,7 +1023,7 @@ - 274 + 18 Apple PDF pasteboard type Apple PICT pasteboard type @@ -1028,6 +1107,7 @@ NSTypedFilenamesPboardType:SGI NSTypedFilenamesPboardType:SR2 NSTypedFilenamesPboardType:SRF + NSTypedFilenamesPboardType:SRW NSTypedFilenamesPboardType:TARGA NSTypedFilenamesPboardType:TGA NSTypedFilenamesPboardType:TIF @@ -1090,6 +1170,7 @@ NSTypedFilenamesPboardType:sgi NSTypedFilenamesPboardType:sr2 NSTypedFilenamesPboardType:srf + NSTypedFilenamesPboardType:srw NSTypedFilenamesPboardType:targa NSTypedFilenamesPboardType:tga NSTypedFilenamesPboardType:tif @@ -1158,6 +1239,9 @@ {{0, 0}, {1920, 1178}} {1.79769e+308, 1.79769e+308} + + ApertureToAnselExportPlugin + @@ -1385,6 +1469,22 @@ 373 + + + mAnselVersion + + + + 422 + + + + anselVersionClick: + + + + 423 + @@ -1442,8 +1542,6 @@ 129 - - @@ -1452,6 +1550,10 @@ + + + + @@ -1922,14 +2024,67 @@ + + 404 + + + + + + + + 405 + + + + + 414 + + + + + 416 + + + + + + + + 417 + + + + + + + + 418 + + + + + + + + + 419 + + + + + 420 + + + com.apple.InterfaceBuilder.CocoaPlugin - {{63, 887}, {455, 195}} + {{529, 852}, {455, 230}} com.apple.InterfaceBuilder.CocoaPlugin - {{63, 887}, {455, 195}} + {{529, 852}, {455, 230}} com.apple.InterfaceBuilder.CocoaPlugin @@ -1993,11 +2148,47 @@ com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{639, 898}, {110, 43}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin {{531, 790}, {528, 309}} com.apple.InterfaceBuilder.CocoaPlugin @@ -2034,7 +2225,7 @@ - 403 + 423 @@ -2042,6 +2233,7 @@ ApertureToAnselExportPlugin NSObject + id id id id @@ -2049,30 +2241,6 @@ id id id - id - - - IKImageBrowserView - NSButton - NSImageView - NSView - NSComboBox - NSView - NSButton - NSButton - NSTextField - NSSecureTextField - NSTextField - NSTextField - NSPopUpButton - NSWindow - NSWindow - NSPanel - NSTableView - NSView - NSProgressIndicator - NSTextField - NSButton IBProjectSource @@ -2097,6 +2265,7 @@ FirstResponder + NSObject IBUserSource @@ -2106,21 +2275,21 @@ NSObject IBProjectSource - TURAnsel.h + TURAnselKit/TURAnsel.h NSObject IBProjectSource - TURAnselGallery.h + TURAnselKit/TURAnselGallery.h NSObject IBProjectSource - TURAnselGalleryPanelController.h + TURAnselKit/TURAnselGalleryPanelController.h @@ -2774,16 +2943,21 @@ 0 + IBCocoaFramework com.apple.InterfaceBuilder.CocoaPlugin.macosx com.apple.InterfaceBuilder.CocoaPlugin.macosx - + YES ../ApertureToAnselExportPlugin.xcodeproj 3 + + {9, 8} + {7, 2} + diff --git a/ApertureToAnselExportPlugin/English.lproj/ApertureToAnselExportPlugin.nib/keyedobjects.nib b/ApertureToAnselExportPlugin/English.lproj/ApertureToAnselExportPlugin.nib/keyedobjects.nib index a8efc7814..7c3ca87c6 100644 Binary files a/ApertureToAnselExportPlugin/English.lproj/ApertureToAnselExportPlugin.nib/keyedobjects.nib and b/ApertureToAnselExportPlugin/English.lproj/ApertureToAnselExportPlugin.nib/keyedobjects.nib differ diff --git a/ApertureToAnselExportPlugin/TURAnselKit/TURAnsel.h b/ApertureToAnselExportPlugin/TURAnselKit/TURAnsel.h index 577d8ed71..03e09a673 100644 --- a/ApertureToAnselExportPlugin/TURAnselKit/TURAnsel.h +++ b/ApertureToAnselExportPlugin/TURAnselKit/TURAnsel.h @@ -39,6 +39,8 @@ typedef enum { NSString *rpcEndPoint; NSString *username; NSString *password; + NSString *version; + NSMutableArray *galleryList; TURAnselState state; id delegate; @@ -48,6 +50,7 @@ typedef enum { @property (readwrite, retain) NSString *rpcEndPoint; @property (readwrite, retain) NSString *username; @property (readwrite, retain) NSString *password; +@property (readwrite, retain) NSString *version; - (id)initWithConnectionParameters: (NSDictionary *)params; - (void)connect; diff --git a/ApertureToAnselExportPlugin/TURAnselKit/TURAnsel.m b/ApertureToAnselExportPlugin/TURAnselKit/TURAnsel.m index 79580c480..aa18f5860 100644 --- a/ApertureToAnselExportPlugin/TURAnselKit/TURAnsel.m +++ b/ApertureToAnselExportPlugin/TURAnselKit/TURAnsel.m @@ -20,6 +20,7 @@ @synthesize rpcEndPoint; @synthesize username; @synthesize password; +@synthesize version; #pragma mark - #pragma mark init/dealloc @@ -37,6 +38,8 @@ forKey: @"password"]; [self setValue: @"The Ansel Cocoa XML-RPC Client" forKey: @"userAgent"]; + [self setValue: [params objectForKey:@"version"] + forKey: @"version"]; return self; } @@ -49,6 +52,7 @@ [username release]; [password release]; [userAgent release]; + [version release]; [super dealloc]; } @@ -284,20 +288,33 @@ */ - (void)doLogin { - NSArray *params = [[NSArray alloc] initWithObjects: - @"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). - - NSArray *order = [NSArray arrayWithObjects: kTURAnselAPIParamScope, kTURAnselAPIParamPerms, - kTURAnselAPIParamParent, kTURAnselAPIParamAllLevels, - kTURAnselAPIParamOffset, kTURAnselAPIParamCount, - kTURAnselAPIParamUserOnly, nil]; - + NSArray *params; + NSArray *order; + + if (2 == [version intValue]) { + params = [[NSArray alloc] initWithObjects: [[NSDictionary alloc] initWithObjectsAndKeys: + [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: + @"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). + + order = [NSArray arrayWithObjects: kTURAnselAPIParamScope, kTURAnselAPIParamPerms, + kTURAnselAPIParamParent, kTURAnselAPIParamAllLevels, + kTURAnselAPIParamOffset, kTURAnselAPIParamCount, + kTURAnselAPIParamUserOnly, nil]; + } + + NSDictionary *results = [self callRPCMethod: @"images.listGalleries" withParams: params withOrder: order]; diff --git a/ApertureToAnselExportPlugin/TURAnselKit/TURAnselConstants.h b/ApertureToAnselExportPlugin/TURAnselKit/TURAnselConstants.h index 1b6a56b49..7b495cf06 100644 --- a/ApertureToAnselExportPlugin/TURAnselKit/TURAnselConstants.h +++ b/ApertureToAnselExportPlugin/TURAnselKit/TURAnselConstants.h @@ -25,6 +25,9 @@ extern NSString * const kTURAnselAPIParamSetAsDefault; extern NSString * const kTURAnselAPIParamAdditionalData; extern NSString * const kTURAnselAPIParamEncoding; +// Constants specific to Ansel version 2 API parameters. +extern NSString * const kTURAnselAPIParamSingleParameter; + // Constants for the dictionary keys used to describe/create TURAnselGallery extern NSString * const kTURAnselGalleryKeyId; extern NSString * const kTURAnselGalleryKeyName; diff --git a/ApertureToAnselExportPlugin/TURAnselKit/TURAnselConstants.m b/ApertureToAnselExportPlugin/TURAnselKit/TURAnselConstants.m index 74472bb5f..b361ee122 100644 --- a/ApertureToAnselExportPlugin/TURAnselKit/TURAnselConstants.m +++ b/ApertureToAnselExportPlugin/TURAnselKit/TURAnselConstants.m @@ -26,6 +26,8 @@ NSString * const kTURAnselAPIParamSetAsDefault = @"default"; NSString * const kTURAnselAPIParamAdditionalData = @"additionalData"; NSString * const kTURAnselAPIParamEncoding = @"encoding"; +NSString * const kTURAnselAPIParamSingleParameter = @"params"; + // Ansel gallery attribtues. NSString * const kTURAnselGalleryKeyId = @"share_id"; NSString * const kTURAnselGalleryKeyName = @"attribute_name";