*/
- (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];
NSArray *params;
NSArray *order;
- if (2 == [version intValue]) {
- params = [[NSArray alloc] initWithObjects: [[NSDictionary alloc] initWithObjectsAndKeys:
+ if ([[self valueForKey: @"version"] intValue] == 2) {
+ params = [[NSArray alloc] initWithObjects: [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt: PERMS_EDIT], @"perm",
[self valueForKey:@"username"], @"filter",
nil] ,nil];
- order = [[NSArray arrayWithObjects kTURAnselAPIParamSingleParameter, nil];
+ order = [NSArray arrayWithObjects: kTURAnselAPIParamSingleParameter, nil];
} else {
// Assume it's version 1.x
params = [[NSArray alloc] initWithObjects:
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 *order = [NSArray arrayWithObjects: kTURAnselAPIParamScope,
- kTURAnselAPIParamImageId,
- kTURAnselAPIParamThumbnailStyle,
- kTURAnselAPIParamFullPath, 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];
+
+ order = [NSArray arrayWithObjects: kTURAnselAPIParamScope,
+ kTURAnselAPIParamImageId,
+ kTURAnselAPIParamThumbnailStyle,
+ kTURAnselAPIParamFullPath, nil];
+ }
NSDictionary *response = [anselController callRPCMethod: @"images.getImageUrl"
withParams: params
withOrder: order];
- (NSMutableArray *)listImages
{
if (![imageList count]) {
- 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];
-
+ 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);
}
}
#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 alloc] initWithObjects:
@"ansel", // app
[NSNumber numberWithInt: _galleryId], // gallery_id
[imageParameters valueForKey: @"data"], // image data array
@"", // 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];
+ [params release];
}
@end