From: Michael J. Rubinsky Date: Wed, 26 Nov 2008 00:54:49 +0000 (-0500) Subject: Consolidate these upload functions now that we're doing all the uploads on a X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=17e7ceecf80ac42d0635d5036094814b20ca0f77;p=horde.git Consolidate these upload functions now that we're doing all the uploads on a single thread. Correct typo, some more wrapping etc... --- diff --git a/iPhoto2Ansel/AnselExportController.m b/iPhoto2Ansel/AnselExportController.m index 9c3c40034..21ffff5c7 100644 --- a/iPhoto2Ansel/AnselExportController.m +++ b/iPhoto2Ansel/AnselExportController.m @@ -392,7 +392,7 @@ #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]; diff --git a/iPhoto2Ansel/TURAnselGallery.h b/iPhoto2Ansel/TURAnselGallery.h index c39891c24..608324077 100644 --- a/iPhoto2Ansel/TURAnselGallery.h +++ b/iPhoto2Ansel/TURAnselGallery.h @@ -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 diff --git a/iPhoto2Ansel/TURAnselGallery.m b/iPhoto2Ansel/TURAnselGallery.m index a72e5cf7f..2e7c0858b 100644 --- a/iPhoto2Ansel/TURAnselGallery.m +++ b/iPhoto2Ansel/TURAnselGallery.m @@ -11,6 +11,10 @@ #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"] @@ -67,21 +70,11 @@ } /** - * 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 @@ -175,31 +168,28 @@ } #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