0
@@ -933,111 +933,113 @@ static int loggingIn;
0
ZWGalleryRemoteStatusCode status = 0;
0
- for (imageNum = 0; imageNum < (int)[exportManager imageCount]; imageNum++) {
0
+ for (imageNum = 0; imageNum < (int)[exportManager imageCount] && !cancel; imageNum++) {
0
// Create our own pool so we don't use up tons of memory with autoreleased image data
0
- NSAutoreleasePool *innerPool = [[NSAutoreleasePool alloc] init];
0
+ NSAutoreleasePool *innerPool = [[NSAutoreleasePool alloc] init];
{0
- NSString *imagePath = [exportManager imagePathAtIndex:imageNum];
0
- NSDictionary *imageDict = [self exportManagerImageDictionaryAtIndex:imageNum];
0
- ZWGalleryItem *item = [ZWGalleryItem itemWithAlbum:album];
0
- [item setFilename:[imagePath lastPathComponent]];
0
- // add the image type (default to jpg)
0
- // TODO: Be smarter here. There are many more possible image types we need to handle.
0
- if ([[imagePath pathExtension] caseInsensitiveCompare:@"gif"] == NSOrderedSame)
0
- [item setImageType:@"image/gif"];
0
- else if ([[imagePath pathExtension] caseInsensitiveCompare:@"png"] == NSOrderedSame)
0
- [item setImageType:@"image/png"];
0
- [item setImageType:@"image/jpeg"];
0
- // add the comments and description, if so desired
0
- if ([mainExportCommentsSwitch state]) {
0
- if ([imageDict objectForKey:@"Caption"])
0
- [item setCaption:[imageDict objectForKey:@"Caption"]];
0
- if ([imageDict objectForKey:@"Annotation"])
0
- [item setDescription:[imageDict objectForKey:@"Annotation"]];
0
- // finally, add the image data
0
- NSData *imageData = [NSData dataWithContentsOfFile:imagePath];
0
- NSImage *image = [[[NSImage alloc] initWithData:imageData] autorelease];
0
+ NSString *imagePath = [exportManager imagePathAtIndex:imageNum];
0
+ NSDictionary *imageDict = [self exportManagerImageDictionaryAtIndex:imageNum];
0
+ ZWGalleryItem *item = [ZWGalleryItem itemWithAlbum:album];
0
+ [item setFilename:[imagePath lastPathComponent]];
0
+ // add the image type (default to jpg)
0
+ // TODO: Be smarter here. There are many more possible image types we need to handle.
0
+ if ([[imagePath pathExtension] caseInsensitiveCompare:@"gif"] == NSOrderedSame)
0
+ [item setImageType:@"image/gif"];
0
+ else if ([[imagePath pathExtension] caseInsensitiveCompare:@"png"] == NSOrderedSame)
0
+ [item setImageType:@"image/png"];
0
+ [item setImageType:@"image/jpeg"];
0
+ // add the comments and description, if so desired
0
+ if ([mainExportCommentsSwitch state]) {
0
+ if ([imageDict objectForKey:@"Caption"])
0
+ [item setCaption:[imageDict objectForKey:@"Caption"]];
0
+ if ([imageDict objectForKey:@"Annotation"])
0
+ [item setDescription:[imageDict objectForKey:@"Annotation"]];
0
+ // finally, add the image data
0
+ NSData *imageData = [NSData dataWithContentsOfFile:imagePath];
0
+ NSImage *image = [[[NSImage alloc] initWithData:imageData] autorelease];
0
+ currentImageIndex = imageNum;
0
+ if ([mainScaleImagesSwitch state] == NSOnState) {
0
+ NSDictionary *progressInfo = [NSDictionary dictionaryWithObjectsAndKeys:
0
+ [NSString stringWithFormat:@"Resizing %@...", [imagePath lastPathComponent]], @"UploadingTextField",
0
+ [NSString stringWithFormat:@"(Photo %i of %i)", imageNum + 1, (int)[exportManager imageCount]], @"UploadingDetailField",
0
+ [NSNumber numberWithInt:currentImageIndex], @"ProgressBarLocation",
0
+ [self performSelectorOnMainThread:@selector(updateProgress:) withObject:progressInfo waitUntilDone:NO modes:[NSArray arrayWithObjects:NSDefaultRunLoopMode, NSModalPanelRunLoopMode, nil]];
0
+ NSData *scaledData = [ImageResizer getScaledImageFromData:imageData toSize:NSMakeSize([mainScaleImagesWidthField intValue], [mainScaleImagesHeightField intValue])];
0
+ [item setData:scaledData];
0
+ currentImageSize = [scaledData length];
0
+ [item setData:imageData];
0
+ currentImageSize = [imageData length];
0
- currentImageIndex = imageNum;
0
- if ([mainScaleImagesSwitch state] == NSOnState) {
0
NSDictionary *progressInfo = [NSDictionary dictionaryWithObjectsAndKeys:
0
- [NSString stringWithFormat:@"
Resizing %@...", [imagePath lastPathComponent]], @"UploadingTextField",
0
+ [NSString stringWithFormat:@"
Uploading %@...", [imagePath lastPathComponent]], @"UploadingTextField",
0
[NSString stringWithFormat:@"(Photo %i of %i)", imageNum + 1, (int)[exportManager imageCount]], @"UploadingDetailField",
0
[NSNumber numberWithInt:currentImageIndex], @"ProgressBarLocation",
0
[self performSelectorOnMainThread:@selector(updateProgress:) withObject:progressInfo waitUntilDone:NO modes:[NSArray arrayWithObjects:NSDefaultRunLoopMode, NSModalPanelRunLoopMode, nil]];
0
- NSData *scaledData = [ImageResizer getScaledImageFromData:imageData toSize:NSMakeSize([mainScaleImagesWidthField intValue], [mainScaleImagesHeightField intValue])];
0
- [item setData:scaledData];
0
- currentImageSize = [scaledData length];
0
- [item setData:imageData];
0
- currentImageSize = [imageData length];
0
- NSDictionary *progressInfo = [NSDictionary dictionaryWithObjectsAndKeys:
0
- [NSString stringWithFormat:@"Uploading %@...", [imagePath lastPathComponent]], @"UploadingTextField",
0
- [NSString stringWithFormat:@"(Photo %i of %i)", imageNum + 1, (int)[exportManager imageCount]], @"UploadingDetailField",
0
- [NSNumber numberWithInt:currentImageIndex], @"ProgressBarLocation",
0
- [self performSelectorOnMainThread:@selector(updateProgress:) withObject:progressInfo waitUntilDone:NO modes:[NSArray arrayWithObjects:NSDefaultRunLoopMode, NSModalPanelRunLoopMode, nil]];
0
- [album setDelegate:self];
0
- status = [album addItemSynchronously:item];
0
- if (status != GR_STAT_SUCCESS) {
0
- case ZW_GALLERY_OPERATION_DID_CANCEL:
0
- [mainStatusString setStringValue:[NSString stringWithFormat:@"Export cancelled after %i photo", imageNum]];
0
- [mainStatusString setStringValue:[NSString stringWithFormat:@"Export cancelled after %i photos", imageNum]];
0
+ [album setDelegate:self];
0
+ status = [album addItemSynchronously:item];
0
+ if (status != GR_STAT_SUCCESS) {
0
+ case ZW_GALLERY_OPERATION_DID_CANCEL:
0
+ [mainStatusString setStringValue:[NSString stringWithFormat:@"Export cancelled after %i photo", imageNum]];
0
+ [mainStatusString setStringValue:[NSString stringWithFormat:@"Export cancelled after %i photos", imageNum]];
0
+ case GR_STAT_UPLOAD_PHOTO_FAIL:
0
+ [mainStatusString setStringValue:@"Failed. Could not upload."];
0
+ NSLog(@"Export failed with error: %i", status);
0
+ [mainStatusString setStringValue:[NSString stringWithFormat:@"Export failed (error code: %i)", status]];
0
+ if (status != ZW_GALLERY_OPERATION_DID_CANCEL) {
0
+ [GrowlApplicationBridge notifyWithTitle:@"Export Failed"
0
+ description:[NSString stringWithFormat:@"Export to gallery failed after %i photos were uploaded",
0
+ notificationName:@"Export to Gallery Failed"
0
- case GR_STAT_UPLOAD_PHOTO_FAIL:
0
- [mainStatusString setStringValue:@"Failed. Could not upload."];
0
- [mainStatusString setStringValue:[NSString stringWithFormat:@"Export failed (error code: %i)", status]];
0
- if (status != ZW_GALLERY_OPERATION_DID_CANCEL)
0
- [GrowlApplicationBridge notifyWithTitle:@"Export Failed"
0
- description:[NSString stringWithFormat:@"Export to gallery failed after %i photos were uploaded",
0
- notificationName:@"Export to Gallery Failed"
0
+ [GrowlApplicationBridge notifyWithTitle:@"Photo Uploaded"
0
+ description:[NSString stringWithFormat:@"Photo %@ uploaded to Gallery",
0
+ notificationName:@"Photo Uploaded to Gallery"
0
- [GrowlApplicationBridge notifyWithTitle:@"Photo Uploaded"
0
- description:[NSString stringWithFormat:@"Photo %@ uploaded to Gallery",
0
- notificationName:@"Photo Uploaded to Gallery"
0
+ } [innerPool release];
0
[NSApp endSheet:progressPanel];
Comments
No one has commented yet.