Consolidate these upload functions now that we're doing all the uploads on a
authorMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 26 Nov 2008 00:54:49 +0000 (19:54 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 26 Nov 2008 00:59:21 +0000 (19:59 -0500)
single thread.

Correct typo, some more wrapping etc...

iPhoto2Ansel/AnselExportController.m
iPhoto2Ansel/TURAnselGallery.h
iPhoto2Ansel/TURAnselGallery.m

index 9c3c400..21ffff5 100644 (file)
 #pragma mark TURAnselGalleryDelegate
 - (void)TURAnselGalleryDidUploadImage: (TURAnselGallery *)gallery {
     NSLog(@"TURAnselGalleryDidUploadImage");
-    if (++currentImageCount = [mExportMgr imageCount] || cancelExport == YES) {
+    if (++currentImageCount == [mExportMgr imageCount] || cancelExport == YES) {
         [currentGallery setDelegate:nil];
         [currentGallery release];
         [anselController setDelegate:nil];
index c39891c..6083240 100644 (file)
@@ -49,9 +49,4 @@ typedef enum {
 - (void)setState: (TURAnselGalleryState)theState;
 - (bool)isBusy;
 - (void)setAnselController:(TURAnsel *)newController;
-@end
-
-@interface TURAnselGallery (PrivateAPI)
-- (void)uploadThread:(NSDictionary *)threadDispatchInfo;
-- (void)doUplod: (NSDictionary *)imageParams;
 @end
\ No newline at end of file
index a72e5cf..2e7c085 100644 (file)
 #import "TURAnsel.h"
 #import "TURAnselGallery.h"
 
+@interface TURAnselGallery (PrivateAPI)
+- (void)doUpload: (NSDictionary *)imageParams;
+@end
+
 @implementation TURAnselGallery
 
 @synthesize galleryDescription;
@@ -27,7 +31,6 @@
 - (id)initWithObject: (id)galleryData
 {
     [super init];
-    // KVC automatically type coerces
     [self setValue: [galleryData valueForKey:@"share_id"]
             forKey: @"galleryId"];
     [self setValue:[galleryData valueForKey:@"attribute_desc"]
 }
 
 /**
- * Forks off a new thread for the upload
+ * Upload the provided image to this gallery.
  */
 - (void)uploadImageObject: (NSDictionary *)imageParameters
-{
-    //[NSThread prepareForInterThreadMessages];
-    NSDictionary *threadDispatchInfo = [NSDictionary dictionaryWithObjectsAndKeys:
-                                        [NSThread currentThread], @"CallingThread",
-                                        nil];
-    NSDictionary *arguments = [NSDictionary dictionaryWithObjectsAndKeys:
-                               imageParameters, @"imageParameters",
-                               threadDispatchInfo, @"threadDispatchInfo",
-                               nil];
-    
-    
-    [self uploadThread: arguments];
+{    
+    [self doUpload: imageParameters];
 }
 
 - (bool) isBusy
 }
 
 #pragma mark PrivateAPI
-- (void)uploadThread:(NSDictionary *)parameters
-{
-        //For now, assume success stil need to do error checking/handling
-        [self doUplod:[[parameters objectForKey:@"imageParameters"] retain]];
-        if ([delegate respondsToSelector:@selector(TURAnselGalleryDidUploadImage:)]) {
-            [delegate performSelectorOnMainThread:@selector(TURAnselGalleryDidUploadImage:)
-                                       withObject:self 
-                                    waitUntilDone:NO];
-        }
-}
-- (void)doUplod:(NSDictionary *)imageParameters
+- (void)doUpload:(NSDictionary *)imageParameters
 {
         // Need to build the XMLRPC params array now.
         NSArray *params = [[NSArray alloc] initWithObjects:
                            @"ansel",                                 // app
                            [NSNumber numberWithInt: galleryId],      // gallery_id
                            [imageParameters valueForKey: @"data"],   // image data array   
-                           [imageParameters valueForKey:@"default"], // set as default?
+                           [imageParameters valueForKey: @"default"], // set as default?
                            @"",                                      // Additional gallery data to set?      
                            @"base64",                                // Image data encoding      
                            nil];
         
         // Send the request up to the controller
-         [anselController callRPCMethod:@"images.saveImage"
+         [anselController callRPCMethod: @"images.saveImage"
                            withParams: params];
+    
+        if ([delegate respondsToSelector:@selector(TURAnselGalleryDidUploadImage:)]) {
+            [delegate performSelectorOnMainThread: @selector(TURAnselGalleryDidUploadImage:)
+                                       withObject: self 
+                                    waitUntilDone: NO];
+        }
+    
         [params release];
 }
 @end