From: Michael J. Rubinsky Date: Fri, 3 Sep 2010 19:31:37 +0000 (-0400) Subject: Support Ansel's version 2 API X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=93a16a36ac8aa0cf90c518161a4631763b3f2ece;p=horde.git Support Ansel's version 2 API --- diff --git a/iPhoto2Ansel/AnselExportController.h b/iPhoto2Ansel/AnselExportController.h index e253b061c..4993f690e 100644 --- a/iPhoto2Ansel/AnselExportController.h +++ b/iPhoto2Ansel/AnselExportController.h @@ -1,10 +1,11 @@ -// -// AnselExportController.h -// iPhoto2Ansel -// -// Created by Michael Rubinsky on 10/23/08. -// Copyright 2008 __MyCompanyName__. All rights reserved. -// +/** + * iPhoto2Ansel + * + * Copyright 2008-2010 The Horde Project (http://www.horde.org) + * + * @license http://opensource.org/licenses/bsd-license.php + * @author Michael J. Rubinsky + */ #import #import @@ -35,6 +36,7 @@ IBOutlet NSButton *mNewGalleryButton; IBOutlet NSPopUpButton *mServersPopUp; IBOutlet NSTextField *mImageCountLabel; + IBOutlet NSPopUpButton *mAnselVersion; // Gallery View IBOutlet NSButton *viewGallery; diff --git a/iPhoto2Ansel/AnselExportController.m b/iPhoto2Ansel/AnselExportController.m index d4e716554..95d6d8166 100644 --- a/iPhoto2Ansel/AnselExportController.m +++ b/iPhoto2Ansel/AnselExportController.m @@ -1,7 +1,8 @@ /** * AnselExportController.m + * iPhoto2Ansel * - * Copyright 2008 The Horde Project (http://www.horde.org) + * Copyright 2008-2010 The Horde Project (http://www.horde.org) * * @license http://opensource.org/licenses/bsd-license.php * @author Michael J. Rubinsky @@ -37,6 +38,7 @@ NSString * const TURAnselServerNickKey = @"nickname"; NSString * const TURAnselServerEndpointKey = @"endpoint"; NSString * const TURAnselServerUsernameKey = @"username"; NSString * const TURAnselServerPasswordKey = @"password"; +NSString * const TURAnselServerVersionKey = @"version"; @implementation AnselExportController @@ -266,6 +268,7 @@ NSString * const TURAnselServerPasswordKey = @"password"; [mServerSheetHostURL stringValue], TURAnselServerEndpointKey, [mServerSheetUsername stringValue], TURAnselServerUsernameKey, [mServerSheetPassword stringValue], TURAnselServerPasswordKey, + [NSNumber numberWithInt: [mAnselVersion indexOfSelectedItem] + 1] , TURAnselServerVersionKey, nil]; [anselServers addObject: newServer]; [NSApp endSheet: newServerSheet]; @@ -509,12 +512,23 @@ NSString * const TURAnselServerPasswordKey = @"password"; [self setStatusText: @"Connecting..."]; [spinner startAnimation: self]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + // NSDictionary objects cannot contain nil objects + NSNumber *apiversion = [currentServer objectForKey: TURAnselServerVersionKey]; + if (apiversion == nil) { + apiversion = [NSNumber numberWithInt: 1]; + } NSDictionary *p = [[NSDictionary alloc] initWithObjects: [NSArray arrayWithObjects: [currentServer objectForKey:TURAnselServerEndpointKey], [currentServer objectForKey:TURAnselServerUsernameKey], [currentServer objectForKey:TURAnselServerPasswordKey], + apiversion, nil] - forKeys: [NSArray arrayWithObjects:@"endpoint", @"username", @"password", nil]]; + forKeys: [NSArray arrayWithObjects:TURAnselServerEndpointKey, + TURAnselServerUsernameKey, + TURAnselServerPasswordKey, + TURAnselServerVersionKey, + nil]]; // Create our controller anselController = [[TURAnsel alloc] initWithConnectionParameters:p]; [anselController setDelegate:self]; diff --git a/iPhoto2Ansel/AnselExportPluginBox.h b/iPhoto2Ansel/AnselExportPluginBox.h index 9bf027a56..f1678a5c2 100644 --- a/iPhoto2Ansel/AnselExportPluginBox.h +++ b/iPhoto2Ansel/AnselExportPluginBox.h @@ -1,10 +1,11 @@ -// -// AnselExportPluginBox.h -// iPhoto2Ansel -// -// Created by Michael Rubinsky on 10/23/08. -// Copyright 2008 __MyCompanyName__. All rights reserved. -// +/** + * iPhoto2Ansel + * + * Copyright 2008-2010 The Horde Project (http://www.horde.org) + * + * @license http://opensource.org/licenses/bsd-license.php + * @author Michael J. Rubinsky + */ #import #import "ExportPluginProtocol.h" diff --git a/iPhoto2Ansel/AnselExportPluginBox.m b/iPhoto2Ansel/AnselExportPluginBox.m index ef325f8da..c67afcc14 100644 --- a/iPhoto2Ansel/AnselExportPluginBox.m +++ b/iPhoto2Ansel/AnselExportPluginBox.m @@ -1,14 +1,12 @@ -// -// AnselExportPluginBox.m -// iPhoto2Ansel -// -// Generic PluginBox handles Enter key presses to initiate the -// export. -// -// Created by Michael Rubinsky on 10/23/08. -// Copyright 2008 __MyCompanyName__. All rights reserved. -// - +/** + * AnselExportPluginBox.m + * iPhoto2Ansel + * + * Copyright 2008-2010 The Horde Project (http://www.horde.org) + * + * @license http://opensource.org/licenses/bsd-license.php + * @author Michael J. Rubinsky + */ #import "AnselExportPluginBox.h" @implementation AnselExportPluginBox @@ -18,7 +16,7 @@ { NSString *keyString = [anEvent charactersIgnoringModifiers]; unichar keyChar = [keyString characterAtIndex:0]; - + switch (keyChar) { case NSFormFeedCharacter: @@ -32,7 +30,7 @@ default: break; } - + return([super performKeyEquivalent:anEvent]); } @end diff --git a/iPhoto2Ansel/ExportImageProtocol.h b/iPhoto2Ansel/ExportImageProtocol.h index d9334f619..37180dfb4 100755 --- a/iPhoto2Ansel/ExportImageProtocol.h +++ b/iPhoto2Ansel/ExportImageProtocol.h @@ -1,16 +1,16 @@ /* File: ExportImageProtocol.h - + Contains: iPhoto Plug-ins interfaces: Protocol for image exporting - + Version: Technology: iPhoto Release: 1.0 - + Copyright: © 2002-2007 by Apple Inc. All rights reserved. - + Bugs?: For bug reports, consult the following page on the World Wide Web: - + http://developer.apple.com/bugreporter/ */ diff --git a/iPhoto2Ansel/ExportPluginBoxProtocol.h b/iPhoto2Ansel/ExportPluginBoxProtocol.h index cf9f9ac39..8761d147d 100755 --- a/iPhoto2Ansel/ExportPluginBoxProtocol.h +++ b/iPhoto2Ansel/ExportPluginBoxProtocol.h @@ -1,16 +1,16 @@ /* File: ExportPluginBoxProtocol.h - + Contains: iPhoto Plug-ins interfaces: Export plugin box expected format and methods - + Version: Technology: iPhoto Release: 1.0 - + Copyright: © 2002-2007 by Apple Inc. All rights reserved. - + Bugs?: For bug reports, consult the following page on the World Wide Web: - + http://developer.apple.com/bugreporter/ */ diff --git a/iPhoto2Ansel/ExportPluginProtocol.h b/iPhoto2Ansel/ExportPluginProtocol.h index 96bdbff02..9e18ea272 100755 --- a/iPhoto2Ansel/ExportPluginProtocol.h +++ b/iPhoto2Ansel/ExportPluginProtocol.h @@ -1,16 +1,16 @@ /* File: ExportPluginProtocol.h - + Contains: iPhoto Plug-ins interfaces: Export plugin expected format and methods - + Version: Technology: iPhoto Release: 1.0 - + Copyright: © 2002-2007 by Apple Inc. All rights reserved. - + Bugs?: For bug reports, consult the following page on the World Wide Web: - + http://developer.apple.com/bugreporter/ */ @@ -88,7 +88,7 @@ typedef struct // This selector may be called from within a separate NSThread. // Perform the export with the current settings to . - // It will periodically send the selector a + // It will periodically send the selector a // progress message in the form of a pointer to a ExportPluginProgress structure. - (void)performExport:(NSString *)path; diff --git a/iPhoto2Ansel/FBProgressController.h b/iPhoto2Ansel/FBProgressController.h index 4fb61bd4d..7ae55df0c 100644 --- a/iPhoto2Ansel/FBProgressController.h +++ b/iPhoto2Ansel/FBProgressController.h @@ -2,35 +2,35 @@ * Facebook Exporter for iPhoto Software License * Copyright 2007, Facebook, Inc. * All rights reserved. - * Permission is hereby granted, free of charge, to any person or organization - * obtaining a copy of the software and accompanying documentation covered by - * this license (which, together with any graphical images included with such - * software, are collectively referred to below as the “Software”) to (a) use, - * reproduce, display, distribute, execute, and transmit the Software, (b) - * prepare derivative works of the Software (excluding any graphical images - * included with the Software, which may not be modified or altered), and (c) - * permit third-parties to whom the Software is furnished to do so, all + * Permission is hereby granted, free of charge, to any person or organization + * obtaining a copy of the software and accompanying documentation covered by + * this license (which, together with any graphical images included with such + * software, are collectively referred to below as the “Software”) to (a) use, + * reproduce, display, distribute, execute, and transmit the Software, (b) + * prepare derivative works of the Software (excluding any graphical images + * included with the Software, which may not be modified or altered), and (c) + * permit third-parties to whom the Software is furnished to do so, all * subject to the following: * - * - Redistributions of source code must retain the above copyright notice, + * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * - Neither the name of Facebook, Inc. nor the names of its contributors may - * be used to endorse or promote products derived from this software without + * - Neither the name of Facebook, Inc. nor the names of its contributors may + * be used to endorse or promote products derived from this software without * specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * */ diff --git a/iPhoto2Ansel/FBProgressController.m b/iPhoto2Ansel/FBProgressController.m index 30be30b43..ea1c0daa3 100644 --- a/iPhoto2Ansel/FBProgressController.m +++ b/iPhoto2Ansel/FBProgressController.m @@ -2,35 +2,35 @@ * Facebook Exporter for iPhoto Software License * Copyright 2007, Facebook, Inc. * All rights reserved. - * Permission is hereby granted, free of charge, to any person or organization - * obtaining a copy of the software and accompanying documentation covered by - * this license (which, together with any graphical images included with such - * software, are collectively referred to below as the “Software”) to (a) use, - * reproduce, display, distribute, execute, and transmit the Software, (b) - * prepare derivative works of the Software (excluding any graphical images - * included with the Software, which may not be modified or altered), and (c) - * permit third-parties to whom the Software is furnished to do so, all + * Permission is hereby granted, free of charge, to any person or organization + * obtaining a copy of the software and accompanying documentation covered by + * this license (which, together with any graphical images included with such + * software, are collectively referred to below as the “Software”) to (a) use, + * reproduce, display, distribute, execute, and transmit the Software, (b) + * prepare derivative works of the Software (excluding any graphical images + * included with the Software, which may not be modified or altered), and (c) + * permit third-parties to whom the Software is furnished to do so, all * subject to the following: * - * - Redistributions of source code must retain the above copyright notice, + * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * - Neither the name of Facebook, Inc. nor the names of its contributors may - * be used to endorse or promote products derived from this software without + * - Neither the name of Facebook, Inc. nor the names of its contributors may + * be used to endorse or promote products derived from this software without * specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * */ @@ -78,7 +78,7 @@ NSString* const CompleteStatus = @"Export completed!"; [progressIndicator setIndeterminate: YES]; [progressIndicator startAnimation: nil]; [self setStatus: @"Started export"]; - + [NSApp beginSheet: progressPanel modalForWindow: [fbExport window] modalDelegate: nil didEndSelector: nil contextInfo: nil]; } diff --git a/iPhoto2Ansel/NSDataAdditions.h b/iPhoto2Ansel/NSDataAdditions.h index a0f6acb1b..b745010cb 100644 --- a/iPhoto2Ansel/NSDataAdditions.h +++ b/iPhoto2Ansel/NSDataAdditions.h @@ -1,16 +1,16 @@ -// +// // Copyright 2008 Eric Czarny -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -18,15 +18,15 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. -// +// -// +// // Cocoa XML-RPC Framework // NSDataAdditions.h -// +// // Created by Eric Czarny on Wednesday, January 14, 2004. // Copyright 2008 Divisible by Zero. -// +// #import diff --git a/iPhoto2Ansel/NSDataAdditions.m b/iPhoto2Ansel/NSDataAdditions.m index 4b3c076f4..ae898595a 100644 --- a/iPhoto2Ansel/NSDataAdditions.m +++ b/iPhoto2Ansel/NSDataAdditions.m @@ -1,16 +1,16 @@ -// +// // Copyright 2008 Eric Czarny -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -18,15 +18,15 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. -// +// -// +// // Cocoa XML-RPC Framework // NSDataAdditions.m -// +// // Created by Eric Czarny on Wednesday, January 14, 2004. // Copyright 2008 Divisible by Zero. -// +// #import "NSDataAdditions.h" @@ -39,30 +39,30 @@ Boolean flignore, flendtext = false; const char *temporary; NSMutableData *result; - + if (string == nil) { return [NSData data]; } - + ixtext = 0; - + temporary = [string UTF8String]; - + lentext = [string length]; - + result = [NSMutableData dataWithCapacity: lentext]; - + ixinput = 0; - + while (true) { if (ixtext >= lentext) { break; } - + ch = temporary[ixtext++]; - + flignore = false; - + if ((ch >= 'A') && (ch <= 'Z')) { ch = ch - 'A'; } else if ((ch >= 'a') && (ch <= 'z')) { @@ -76,49 +76,49 @@ } else if (ch == '/') { ch = 63; } else { - flignore = true; + flignore = true; } - + if (!flignore) { short ctcharsinput = 3; Boolean flbreak = false; - + if (flendtext) { if (ixinput == 0) { break; } - + if ((ixinput == 1) || (ixinput == 2)) { ctcharsinput = 1; } else { ctcharsinput = 2; } - + ixinput = 3; - + flbreak = true; } - + input[ixinput++] = ch; - + if (ixinput == 4) { ixinput = 0; - + output[0] = (input[0] << 2) | ((input[1] & 0x30) >> 4); output[1] = ((input[1] & 0x0F) << 4) | ((input[2] & 0x3C) >> 2); output[2] = ((input[2] & 0x03) << 6) | (input[3] & 0x3F); - + for (i = 0; i < ctcharsinput; i++) { [result appendBytes: &output[i] length: 1]; } } - + if (flbreak) { break; } } } - + return result; } diff --git a/iPhoto2Ansel/NSStringAdditions.h b/iPhoto2Ansel/NSStringAdditions.h index b4776f961..2abc2200e 100644 --- a/iPhoto2Ansel/NSStringAdditions.h +++ b/iPhoto2Ansel/NSStringAdditions.h @@ -1,16 +1,16 @@ -// +// // Copyright 2008 Eric Czarny -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -18,15 +18,15 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. -// +// -// +// // Cocoa XML-RPC Framework // NSStringAdditions.h -// +// // Created by Eric Czarny on Wednesday, January 14, 2004. // Copyright 2008 Divisible by Zero. -// +// #import diff --git a/iPhoto2Ansel/NSStringAdditions.m b/iPhoto2Ansel/NSStringAdditions.m index 22387b952..056610378 100644 --- a/iPhoto2Ansel/NSStringAdditions.m +++ b/iPhoto2Ansel/NSStringAdditions.m @@ -1,16 +1,16 @@ -// +// // Copyright 2008 Eric Czarny -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -18,15 +18,15 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. -// +// -// +// // Cocoa XML-RPC Framework // NSStringAdditions.m -// +// // Created by Eric Czarny on Wednesday, January 14, 2004. // Copyright 2008 Divisible by Zero. -// +// #import "NSDataAdditions.h" @@ -47,72 +47,72 @@ static char base64EncodingTable[64] = { short i, charsonline = 0, ctcopy; const unsigned char *raw; NSMutableString *result; - + lentext = [data length]; - + if (lentext < 1) { return @""; } - + result = [NSMutableString stringWithCapacity: lentext]; - + raw = [data bytes]; - - ixtext = 0; - + + ixtext = 0; + while (true) { ctremaining = lentext - ixtext; - + if (ctremaining <= 0) { break; } - - for (i = 0; i < 3; i++) { + + for (i = 0; i < 3; i++) { unsigned long ix = ixtext + i; - + if (ix < lentext) { input[i] = raw[ix]; } else { input[i] = 0; } } - + output[0] = (input[0] & 0xFC) >> 2; output[1] = ((input[0] & 0x03) << 4) | ((input[1] & 0xF0) >> 4); output[2] = ((input[1] & 0x0F) << 2) | ((input[2] & 0xC0) >> 6); output[3] = input[2] & 0x3F; - + ctcopy = 4; - + switch (ctremaining) { - case 1: - ctcopy = 2; + case 1: + ctcopy = 2; break; - case 2: - ctcopy = 3; + case 2: + ctcopy = 3; break; } - + for (i = 0; i < ctcopy; i++) { [result appendString: [NSString stringWithFormat: @"%c", base64EncodingTable[output[i]]]]; } - + for (i = ctcopy; i < 4; i++) { [result appendString: @"="]; } - + ixtext += 3; charsonline += 4; - + if (length > 0) { if (charsonline >= length) { charsonline = 0; - + [result appendString: @"\n"]; } } } - + return result; } diff --git a/iPhoto2Ansel/Resources/English.lproj/Panel.nib/designable.nib b/iPhoto2Ansel/Resources/English.lproj/Panel.nib/designable.nib index a0d9f6767..6bed80b35 100644 --- a/iPhoto2Ansel/Resources/English.lproj/Panel.nib/designable.nib +++ b/iPhoto2Ansel/Resources/English.lproj/Panel.nib/designable.nib @@ -2,10 +2,10 @@ 1050 - 10B504 - 732 - 1038.2 - 437.00 + 10F569 + 762 + 1038.29 + 461.00 YES @@ -15,13 +15,14 @@ YES - 732 + 762 1.1 YES + YES @@ -51,21 +52,21 @@ 23 2 - {{196, 315}, {455, 195}} + {{196, 281}, {455, 229}} -1543503872 Add Server NSPanel {1.79769e+308, 1.79769e+308} - + 256 YES 268 - {{124, 124}, {311, 22}} + {{124, 158}, {311, 22}} YES @@ -102,7 +103,7 @@ 268 - {{17, 126}, {102, 17}} + {{17, 160}, {102, 17}} YES @@ -131,7 +132,7 @@ 268 - {{124, 92}, {311, 22}} + {{124, 126}, {311, 22}} YES @@ -148,7 +149,7 @@ 268 - {{124, 60}, {311, 22}} + {{124, 94}, {311, 22}} YES @@ -169,7 +170,7 @@ 268 - {{17, 94}, {67, 17}} + {{17, 128}, {67, 17}} YES @@ -185,7 +186,7 @@ 268 - {{17, 62}, {67, 17}} + {{17, 96}, {67, 17}} YES @@ -201,7 +202,7 @@ 268 - {{17, 158}, {102, 17}} + {{17, 192}, {102, 17}} YES @@ -217,7 +218,7 @@ 268 - {{124, 156}, {311, 22}} + {{124, 190}, {311, 22}} YES @@ -274,7 +275,7 @@ 268 - {{18, 18}, {145, 18}} + {{18, 21}, {145, 18}} YES @@ -298,8 +299,87 @@ 25 + + + 268 + {{17, 71}, {67, 17}} + + YES + + 68288064 + 272630784 + Version + + + + + + + + + 268 + {{121, 65}, {100, 26}} + + YES + + -2076049856 + 2048 + + + 109199615 + 129 + + + 400 + 75 + + + 2.x + + 1048576 + 2147483647 + 1 + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + + _popUpItemAction: + + + YES + + OtherViews + + YES + + + 1.x + + 1048576 + 2147483647 + + + _popUpItemAction: + + + + + + + 1 + 1 + YES + YES + 2 + + - {455, 195} + {455, 229} + {{0, 0}, {1920, 1178}} {1.79769e+308, 1.79769e+308} @@ -547,7 +627,6 @@ - QSAAAEEgAABBmAAAQZgAAA @@ -606,7 +685,7 @@ {1.79769e+308, 1.79769e+308} - + 256 YES @@ -615,7 +694,6 @@ 268 {{370, 12}, {96, 32}} - YES 67239424 @@ -730,6 +808,7 @@ NSTypedFilenamesPboardType:SGI NSTypedFilenamesPboardType:SR2 NSTypedFilenamesPboardType:SRF + NSTypedFilenamesPboardType:SRW NSTypedFilenamesPboardType:TARGA NSTypedFilenamesPboardType:TGA NSTypedFilenamesPboardType:TIF @@ -792,6 +871,7 @@ NSTypedFilenamesPboardType:sgi NSTypedFilenamesPboardType:sr2 NSTypedFilenamesPboardType:srf + NSTypedFilenamesPboardType:srw NSTypedFilenamesPboardType:targa NSTypedFilenamesPboardType:tga NSTypedFilenamesPboardType:tif @@ -803,7 +883,6 @@ {423, 337} - NO YES YES @@ -820,7 +899,6 @@ {{1, 1}, {423, 337}} - @@ -831,7 +909,6 @@ 256 {{424, 1}, {15, 337}} - _doScroller: 1 @@ -842,7 +919,6 @@ 256 {{1, 338}, {423, 15}} - 1 _doScroller: @@ -851,7 +927,6 @@ {{20, 60}, {440, 354}} - 50 @@ -861,8 +936,6 @@ {480, 413} - - {{0, 0}, {1920, 1178}} {1.79769e+308, 1.79769e+308} @@ -952,14 +1025,8 @@ 1048576 2147483647 1 - - NSImage - NSMenuCheckmark - - - NSImage - NSMenuMixedState - + + _popUpItemAction: @@ -1264,8 +1331,8 @@ 1048576 2147483647 1 - - + + _popUpItemAction: 2 @@ -1283,8 +1350,8 @@ 1048576 2147483647 - - + + _popUpItemAction: @@ -1294,8 +1361,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 1 @@ -1307,8 +1374,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 3 @@ -1706,6 +1773,14 @@ 583 + + + mAnselVersion + + + + 641 + @@ -1760,6 +1835,8 @@ + + @@ -2411,6 +2488,58 @@ + + 626 + + + YES + + + + + + 627 + + + + + 634 + + + YES + + + + + + 635 + + + YES + + + + + + 636 + + + YES + + + + + + + 637 + + + + + 638 + + + @@ -2553,6 +2682,14 @@ 582.IBPluginDependency 6.IBPluginDependency 6.ImportedFromIB2 + 626.IBPluginDependency + 627.IBPluginDependency + 634.IBPluginDependency + 635.IBPluginDependency + 636.IBEditorWindowLastContentRect + 636.IBPluginDependency + 637.IBPluginDependency + 638.IBPluginDependency 7.CustomClassName 7.IBPluginDependency 7.ImportedFromIB2 @@ -2595,9 +2732,9 @@ - {{351, 386}, {455, 195}} + {{226, 873}, {455, 229}} com.apple.InterfaceBuilder.CocoaPlugin - {{351, 386}, {455, 195}} + {{226, 873}, {455, 229}} com.apple.InterfaceBuilder.CocoaPlugin @@ -2653,9 +2790,9 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{1069, 745}, {548, 406}} + {{433, 614}, {548, 406}} com.apple.InterfaceBuilder.CocoaPlugin - {{1069, 745}, {548, 406}} + {{433, 614}, {548, 406}} {213, 107} @@ -2697,6 +2834,14 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{336, 921}, {100, 43}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin AnselExportPluginBox com.apple.InterfaceBuilder.CocoaPlugin @@ -2720,7 +2865,7 @@ - 625 + 641 @@ -2737,6 +2882,7 @@ defaultImageView firstView galleryCombo + mAnselVersion mImageCountLabel mMakeNewServerDefault mNewGalleryButton @@ -2762,6 +2908,7 @@ NSImageView NSControl NSComboBox + NSPopUpButton NSTextField NSButton NSButton @@ -3105,6 +3252,7 @@ 0 + IBCocoaFramework com.apple.InterfaceBuilder.CocoaPlugin.macosx @@ -3118,7 +3266,22 @@ YES - ../iPhoto2Ansel.xcodeproj + ../../iPhoto2Ansel.xcodeproj 3 + + YES + + YES + NSMenuCheckmark + NSMenuMixedState + NSSwitch + + + YES + {9, 8} + {7, 2} + {15, 15} + + diff --git a/iPhoto2Ansel/Resources/English.lproj/Panel.nib/keyedobjects.nib b/iPhoto2Ansel/Resources/English.lproj/Panel.nib/keyedobjects.nib index 8eb1ec6ed..6d91891a2 100644 Binary files a/iPhoto2Ansel/Resources/English.lproj/Panel.nib/keyedobjects.nib and b/iPhoto2Ansel/Resources/English.lproj/Panel.nib/keyedobjects.nib differ diff --git a/iPhoto2Ansel/TURAnselKit/AnselGalleryViewItem.h b/iPhoto2Ansel/TURAnselKit/AnselGalleryViewItem.h index 91cbd8433..8a9803d78 100644 --- a/iPhoto2Ansel/TURAnselKit/AnselGalleryViewItem.h +++ b/iPhoto2Ansel/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/iPhoto2Ansel/TURAnselKit/AnselGalleryViewItem.m b/iPhoto2Ansel/TURAnselKit/AnselGalleryViewItem.m index 42edf5b21..15aed58cc 100644 --- a/iPhoto2Ansel/TURAnselKit/AnselGalleryViewItem.m +++ b/iPhoto2Ansel/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/iPhoto2Ansel/TURAnselKit/TURAnsel.h b/iPhoto2Ansel/TURAnselKit/TURAnsel.h index e89702709..c3ea089c9 100644 --- a/iPhoto2Ansel/TURAnselKit/TURAnsel.h +++ b/iPhoto2Ansel/TURAnselKit/TURAnsel.h @@ -2,7 +2,7 @@ * TURAnsel * * Copyright 2009-2010 The Horde Project (http://www.horde.org) - * + * * @license http://opensource.org/licenses/bsd-license.php * @author Michael J. Rubinsky */ @@ -33,12 +33,14 @@ typedef enum { @interface TURAnsel : NSObject #else @interface TURAnsel : NSObject -#endif +#endif { NSString *userAgent; 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; @@ -62,4 +65,7 @@ typedef enum { - (TURAnselState)state; - (id)delegate; - (void)setDelegate: (id)newDelegate; + +- (NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox; +- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)index; @end diff --git a/iPhoto2Ansel/TURAnselKit/TURAnsel.m b/iPhoto2Ansel/TURAnselKit/TURAnsel.m index 31560d192..506cfacb5 100644 --- a/iPhoto2Ansel/TURAnselKit/TURAnsel.m +++ b/iPhoto2Ansel/TURAnselKit/TURAnsel.m @@ -4,7 +4,7 @@ * Main class for interacting with a remote Ansel server. * * Copyright 2009-2010 The Horde Project (http://www.horde.org) - * + * * @license http://opensource.org/licenses/bsd-license.php * @author Michael J. Rubinsky */ @@ -20,6 +20,7 @@ @synthesize rpcEndPoint; @synthesize username; @synthesize password; +@synthesize version; #pragma mark - #pragma mark init/dealloc @@ -27,9 +28,9 @@ { [super init]; galleryList = [[NSMutableArray alloc] init]; - + // Initialize the connection properties, KVC style - [self setValue:[params objectForKey:@"endpoint"] + [self setValue:[params objectForKey:@"endpoint"] forKey: @"rpcEndPoint"]; [self setValue: [params objectForKey:@"username"] forKey: @"username"]; @@ -37,24 +38,27 @@ forKey: @"password"]; [self setValue: @"The Ansel Cocoa XML-RPC Client" forKey: @"userAgent"]; - + [self setValue: [params objectForKey:@"version"] + forKey: @"version"]; + return self; } -(void) dealloc { - NSLog(@"TURAnsel dealloc"); + NSLog(@"TURAnsel dealloc"); [galleryList removeAllObjects]; [galleryList release]; [rpcEndPoint release]; [username release]; [password release]; [userAgent release]; + [version release]; [super dealloc]; } #pragma mark - #pragma mark Actions -- (void)connect +- (void)connect { [self doLogin]; } @@ -72,37 +76,45 @@ */ - (NSDictionary *)createNewGallery: (NSDictionary *)params { - NSArray *apiparams = [NSArray arrayWithObjects: @"ansel", params, nil]; - NSArray *order = [NSArray arrayWithObjects: kTURAnselAPIParamScope, kTURAnselAPIParamGaleryParams, nil]; - + NSArray *apiparams; + NSArray *order; + + if ([[self valueForKey: @"version"] intValue] == 2) { + apiparams = [NSArray arrayWithObjects: params, nil]; + order = [NSArray arrayWithObjects: kTURAnselAPIParamGalleryParams, nil]; + } else { + apiparams = [NSArray arrayWithObjects: @"ansel", params, nil]; + order = [NSArray arrayWithObjects: kTURAnselAPIParamScope, kTURAnselAPIParamGalleryParams, nil]; + } + NSDictionary *response = [self callRPCMethod: @"images.createGallery" withParams: apiparams withOrder: order]; - + if (response) { - NSNumber *gallery_id = [response objectForKey: (NSString *)kWSMethodInvocationResult]; + NSNumber *gallery_id = [response objectForKey: (NSString *)kWSMethodInvocationResult]; NSDictionary *results = [NSDictionary dictionaryWithObjectsAndKeys: gallery_id, kTURAnselGalleryKeyId, [params valueForKey: @"name"], kTURAnselGalleryKeyName, @"", kTURAnselGalleryKeyDescription, [NSNumber numberWithInt: 0], kTURAnselGalleryKeyImages, [NSNumber numberWithInt: 0], kTURAnselGalleryKeyDefaultImage, nil]; - + TURAnselGallery *newGallery = [[TURAnselGallery alloc] initWithObject: results controller: self]; [galleryList addObject: newGallery]; [newGallery release]; - + return results; } - + return nil; } /** - * Entry point for calling RPC methods on the Horde server. - * + * Entry point for calling RPC methods on the Horde server. + * * @param NSString methodName The method to call (e.g. images.listGalleries) * @param NSArray params All the method's parameters * @param NSArray order Keys for the params array, needed because of how @@ -118,15 +130,15 @@ withOrder: (NSArray *) order { NSLog(@"Initiating connection for %@", methodName); - + // Get a URL object NSURL *url = [NSURL URLWithString: [self valueForKey: @"rpcEndPoint"]]; NSDictionary *values = [NSDictionary dictionaryWithObjects: params forKeys:order]; - + // Credentials NSString *user = [self valueForKey:@"username"]; NSString *pass = [self valueForKey:@"password"]; - + if (user != nil && [user length] && pass != nil && [pass length]) { // Create a custom http request with authorization CFHTTPMessageRef request = CFHTTPMessageCreateRequest(kCFAllocatorDefault, @@ -140,26 +152,23 @@ (CFStringRef)pass, kCFHTTPAuthenticationSchemeBasic, false); - + 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]; WSMethodInvocationRef rpcCall; - rpcCall = WSMethodInvocationCreate((CFURLRef)url, (CFStringRef)methodName, kWSXMLRPCProtocol); + rpcCall = WSMethodInvocationCreate((CFURLRef)url, (CFStringRef)methodName, kWSXMLRPCProtocol); WSMethodInvocationSetParameters(rpcCall, (CFDictionaryRef)values, (CFArrayRef)order); WSMethodInvocationSetProperty(rpcCall, kWSHTTPMessage, request); NSDictionary *result = (NSDictionary *)WSMethodInvocationInvoke(rpcCall); @@ -183,9 +192,9 @@ error = [NSError errorWithDomain: @"TURAnsel" code: [faultCode intValue] userInfo: [NSDictionary dictionaryWithObjectsAndKeys: [NSString stringWithFormat: @"There was an error contacting the Ansel server: %@, %@", resStatusLine, faultString], @"NSLocalizedDescriptionKey", nil]]; - - - } + + + } [resStatusLine release]; } else { // No response @@ -197,30 +206,36 @@ userInfo: [NSDictionary dictionaryWithObjectsAndKeys: [NSString stringWithFormat: @"There was an error contacting the Ansel server: %@", faultString], @"NSLocalizedDescriptionKey", nil]]; } - + if ([[self delegate] respondsToSelector: @selector(TURAnselHadError:)]) { [[self delegate] TURAnselHadError: error]; } [result autorelease]; + 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; - } #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) { @@ -228,13 +243,17 @@ return g; } } - + return nil; } /** * 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 { @@ -248,7 +267,6 @@ { return [galleryList count]; } - - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)index { @@ -266,11 +284,9 @@ { state = newstate; } - - (id)delegate { - return delegate; + return delegate; } - - (void)setDelegate:(id)newDelegate { delegate = newDelegate; } @@ -284,24 +300,34 @@ */ - (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 ([[self valueForKey: @"version"] intValue] == 2) { + 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 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. + + 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) { @@ -312,15 +338,13 @@ [theGallery release]; theGallery = nil; } - + if ([delegate respondsToSelector:@selector(TURAnselDidInitialize)]) { [delegate performSelectorOnMainThread:@selector(TURAnselDidInitialize) withObject:self waitUntilDone: NO]; } - + } - - [params release]; } -@end \ No newline at end of file +@end diff --git a/iPhoto2Ansel/TURAnselKit/TURAnselConstants.h b/iPhoto2Ansel/TURAnselKit/TURAnselConstants.h index 1b6a56b49..757bdeaab 100644 --- a/iPhoto2Ansel/TURAnselKit/TURAnselConstants.h +++ b/iPhoto2Ansel/TURAnselKit/TURAnselConstants.h @@ -2,14 +2,14 @@ * TURAnselConstants * * Copyright 2009-2010 The Horde Project (http://www.horde.org) - * + * * @license http://opensource.org/licenses/bsd-license.php * @author Michael J. Rubinsky */ // Constants for the API parameter names. extern NSString * const kTURAnselAPIParamScope; -extern NSString * const kTURAnselAPIParamGaleryParams; +extern NSString * const kTURAnselAPIParamGalleryParams; extern NSString * const kTURAnselAPIParamPerms; extern NSString * const kTURAnselAPIParamParent; extern NSString * const kTURAnselAPIParamAllLevels; @@ -25,6 +25,12 @@ extern NSString * const kTURAnselAPIParamSetAsDefault; extern NSString * const kTURAnselAPIParamAdditionalData; extern NSString * const kTURAnselAPIParamEncoding; +// Constants specific to Ansel version 2 API parameters. +extern NSString * const kTURAnselAPIParamSingleParameter; +extern NSString * const kTURAnselAPIParamView; +extern NSString * const kTURAnselAPIParamFull; +extern NSString * const kTURAnselAPIParamEncoding; + // Constants for the dictionary keys used to describe/create TURAnselGallery extern NSString * const kTURAnselGalleryKeyId; extern NSString * const kTURAnselGalleryKeyName; diff --git a/iPhoto2Ansel/TURAnselKit/TURAnselConstants.m b/iPhoto2Ansel/TURAnselKit/TURAnselConstants.m index 74472bb5f..a0162b925 100644 --- a/iPhoto2Ansel/TURAnselKit/TURAnselConstants.m +++ b/iPhoto2Ansel/TURAnselKit/TURAnselConstants.m @@ -1,16 +1,18 @@ -// -// 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" // Constants for the API parameter names. NSString * const kTURAnselAPIParamScope = @"scope"; -NSString * const kTURAnselAPIParamGaleryParams = @"galleryParams"; +NSString * const kTURAnselAPIParamGalleryParams = @"galleryParams"; NSString * const kTURAnselAPIParamPerms = @"perms"; NSString * const kTURAnselAPIParamParent = @"parent"; NSString * const kTURAnselAPIParamAllLevels = @"allLevels"; @@ -26,6 +28,10 @@ NSString * const kTURAnselAPIParamSetAsDefault = @"default"; NSString * const kTURAnselAPIParamAdditionalData = @"additionalData"; NSString * const kTURAnselAPIParamEncoding = @"encoding"; +NSString * const kTURAnselAPIParamSingleParameter = @"params"; +NSString * const kTURAnselAPIParamView = @"view"; +NSString * const kTURAnselAPIParamFull = @"full"; + // Ansel gallery attribtues. NSString * const kTURAnselGalleryKeyId = @"share_id"; NSString * const kTURAnselGalleryKeyName = @"attribute_name"; diff --git a/iPhoto2Ansel/TURAnselKit/TURAnselGallery.h b/iPhoto2Ansel/TURAnselKit/TURAnselGallery.h index dfb31436e..e077773cc 100644 --- a/iPhoto2Ansel/TURAnselKit/TURAnselGallery.h +++ b/iPhoto2Ansel/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 */ @@ -36,7 +36,7 @@ - (void)setDelegate: (id)newDelegate; - (id)delegate; - (NSURL *)galleryKeyImageURL; -- (id)listImages; +- (NSMutableArray *)listImages; - (int)galleryId; - (void)setAnselController:(TURAnsel *)newController; @end \ No newline at end of file diff --git a/iPhoto2Ansel/TURAnselKit/TURAnselGallery.m b/iPhoto2Ansel/TURAnselKit/TURAnselGallery.m index c6f945e63..75130d158 100644 --- a/iPhoto2Ansel/TURAnselKit/TURAnselGallery.m +++ b/iPhoto2Ansel/TURAnselKit/TURAnselGallery.m @@ -2,7 +2,7 @@ * TURAnselGallery.m * * Copyright 2009-2010 The Horde Project (http://www.horde.org) - * + * * @license http://opensource.org/licenses/bsd-license.php * @author Michael J. Rubinsky */ @@ -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 { @@ -35,7 +35,7 @@ [self setValue:[galleryData valueForKey: kTURAnselGalleryKeyName] forKey:@"galleryName"]; [self setValue: [galleryData valueForKey: kTURAnselGalleryKeyImages] - forKey:@"galleryImageCount"]; + forKey:@"galleryImageCount"]; [self setValue: [galleryData valueForKey: kTURAnselGalleryKeyDefaultImage] forKey:@"galleryKeyImage"]; [self setAnselController: controller]; @@ -46,16 +46,16 @@ NSLog(@"TURAnselGallery dealloc called on Gallery %@", self); [anselController release]; anselController = nil; - + [galleryKeyImageURL release]; galleryKeyImageURL = nil; - + [imageList release]; imageList = nil; - + [super dealloc]; } -- (id)description +- (id)description { NSString *text = [NSString stringWithFormat:@"Description: %@ Id: %d has: %d images", galleryName, _galleryId, galleryImageCount]; return text; @@ -66,37 +66,51 @@ /** * 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). + * from the images.listGalleries call). + * + * @return NSURL The url object */ - (NSURL *)galleryKeyImageURL { if (galleryKeyImageURL) { return galleryKeyImageURL; } else { - NSArray *params = [[NSArray alloc] initWithObjects: - @"ansel", // Scope - [NSNumber numberWithInt: galleryKeyImage], // Image Id - @"thumb", // Thumbnail type - [NSNumber numberWithBool:YES], // Full path - nil]; + NSArray *params; + NSArray *order; + if ([[anselController valueForKey:@"version"] intValue] == 2) { + // Version 2 API + params = [NSArray arrayWithObjects: + [NSNumber numberWithInt: galleryKeyImage], + [NSDictionary dictionaryWithObjectsAndKeys: @"thumb", kTURAnselAPIParamView, [NSNumber numberWithBool:YES], kTURAnselAPIParamFull, nil], + nil]; + order = [NSArray arrayWithObjects: kTURAnselAPIParamImageId, + kTURAnselAPIParamSingleParameter, + nil]; + } else { + params = [NSArray arrayWithObjects: + @"ansel", // Scope + [NSNumber numberWithInt: galleryKeyImage], // Image Id + @"thumb", // Thumbnail type + [NSNumber numberWithBool:YES], // Full path + nil]; - NSArray *order = [NSArray arrayWithObjects: kTURAnselAPIParamScope, - kTURAnselAPIParamImageId, - kTURAnselAPIParamThumbnailStyle, - kTURAnselAPIParamFullPath, nil]; - + order = [NSArray arrayWithObjects: kTURAnselAPIParamScope, + kTURAnselAPIParamImageId, + kTURAnselAPIParamThumbnailStyle, + kTURAnselAPIParamFullPath, nil]; + } NSDictionary *response = [anselController callRPCMethod: @"images.getImageUrl" withParams: params withOrder: order]; - + if (response) { NSDictionary *url = [response objectForKey:(id)kWSMethodInvocationResult]; [galleryKeyImageURL autorelease]; galleryKeyImageURL = [[NSURL URLWithString: [NSString stringWithFormat: @"%@", url]] retain]; NSLog(@"galleryKeyImageURL: %@", galleryKeyImageURL); return galleryKeyImageURL; - } - + } + return nil; } } @@ -104,39 +118,46 @@ /** * Get the complete list of image ids and URLs */ -- (id)listImages +- (NSMutableArray *)listImages { - if (!imageList) { - - NSArray *params = [[NSArray alloc] initWithObjects: - @"ansel", //Scope - [NSNumber numberWithInt: _galleryId], //Gallery Id - [NSNumber numberWithInt: 2], //PERMS_SHOW - @"thumb", // Thumbnail - [NSNumber numberWithBool:YES], // Full path - nil]; - NSArray *order = [NSArray arrayWithObjects: kTURAnselAPIParamScope, - kTURAnselAPIParamGalleryId, - kTURAnselAPIParamPerms, - kTURAnselAPIParamThumbnailStyle, - kTURAnselAPIParamFullPath, nil]; - + if (![imageList count]) { + NSArray *params; + NSArray *order; + +// if ([[anselController valueForKey:@"version"] intValue] == 2) { +// listImages hasn't been refactored yet in version 2 API +// } else { + params = [NSArray arrayWithObjects: + @"ansel", //Scope + [NSNumber numberWithInt: _galleryId], //Gallery Id + [NSNumber numberWithInt: 2], //PERMS_SHOW + @"thumb", // Thumbnail + [NSNumber numberWithBool:YES], // Full path + nil]; + order = [NSArray arrayWithObjects: kTURAnselAPIParamScope, + kTURAnselAPIParamGalleryId, + kTURAnselAPIParamPerms, + kTURAnselAPIParamThumbnailStyle, + kTURAnselAPIParamFullPath, nil]; +// } NSDictionary *response = [anselController callRPCMethod: @"images.listImages" withParams: params withOrder: order]; if (response) { [imageList autorelease]; - imageList = [[response objectForKey: (id)kWSMethodInvocationResult] retain]; - + if ([[anselController valueForKey:@"version"] intValue] == 2) { + // images.listImages returns a hash in version 2, not an array + imageList = [NSMutableArray arrayWithArray: [[[response objectForKey: (id)kWSMethodInvocationResult] retain] allValues]]; + } else { + imageList = [[response objectForKey: (id)kWSMethodInvocationResult] retain]; + } NSLog(@"listImages: %@", imageList); - - return imageList; } } - - return nil; + + return imageList;; } - + /** * Upload the provided image to this gallery. */ @@ -182,35 +203,47 @@ #pragma mark PrivateAPI - (void)doUpload:(NSDictionary *)imageParameters { - // Need to build the params array now. - NSArray *params = [[NSArray alloc] initWithObjects: + + NSArray *params; + NSArray *order; + + if ([[anselController valueForKey:@"version"] intValue] == 2) { + params = [NSArray arrayWithObjects: [NSNumber numberWithInt: _galleryId], + [imageParameters valueForKey: @"data"], + [NSDictionary dictionaryWithObjectsAndKeys:@"base64", kTURAnselAPIParamEncoding, nil], + nil]; + order = [NSArray arrayWithObjects: kTURAnselAPIParamGalleryId, + kTURAnselAPIParamImageData, + kTURAnselAPIParamSingleParameter, + nil]; + } else { + params = [NSArray arrayWithObjects: @"ansel", // app [NSNumber numberWithInt: _galleryId], // gallery_id - [imageParameters valueForKey: @"data"], // image data array + [imageParameters valueForKey: @"data"], // image data array [imageParameters valueForKey: @"default"], // set as default? - @"", // Additional gallery data to set? - @"base64", // Image data encoding + @"", // Additional gallery data to set? + @"base64", // Image data encoding nil]; - NSArray *order = [NSArray arrayWithObjects: kTURAnselAPIParamScope, - kTURAnselAPIParamGalleryId, - kTURAnselAPIParamImageData, - kTURAnselAPIParamSetAsDefault, - kTURAnselAPIParamAdditionalData, - kTURAnselAPIParamEncoding, nil]; - - // Send the request up to the controller - NSDictionary *result = [anselController callRPCMethod: @"images.saveImage" - withParams: params - withOrder: order]; - - if (result) { - if ([delegate respondsToSelector:@selector(TURAnselGalleryDidUploadImage:)]) { - [delegate performSelectorOnMainThread: @selector(TURAnselGalleryDidUploadImage:) - withObject: self - waitUntilDone: NO]; - } + order = [NSArray arrayWithObjects: kTURAnselAPIParamScope, + kTURAnselAPIParamGalleryId, + kTURAnselAPIParamImageData, + kTURAnselAPIParamSetAsDefault, + kTURAnselAPIParamAdditionalData, + kTURAnselAPIParamEncoding, nil]; + } + + // Send the request up to the controller + NSDictionary *result = [anselController callRPCMethod: @"images.saveImage" + withParams: params + withOrder: order]; + + if (result) { + if ([delegate respondsToSelector:@selector(TURAnselGalleryDidUploadImage:)]) { + [delegate performSelectorOnMainThread: @selector(TURAnselGalleryDidUploadImage:) + withObject: self + waitUntilDone: NO]; } - - [params release]; + } } @end diff --git a/iPhoto2Ansel/TURAnselKit/TURAnselGalleryPanelController.h b/iPhoto2Ansel/TURAnselKit/TURAnselGalleryPanelController.h index 2def0264e..d11d39fa1 100644 --- a/iPhoto2Ansel/TURAnselKit/TURAnselGalleryPanelController.h +++ b/iPhoto2Ansel/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/iPhoto2Ansel/TURAnselKit/TURAnselGalleryPanelController.m b/iPhoto2Ansel/TURAnselKit/TURAnselGalleryPanelController.m index 988d1b137..e7c375669 100644 --- a/iPhoto2Ansel/TURAnselKit/TURAnselGalleryPanelController.m +++ b/iPhoto2Ansel/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]; }