- (id)imageRepresentation
{
- return [[image retain] autorelease];
+ return image;
}
#pragma mark
#pragma mark Optional methods.
- (NSString *)imageTitle
{
+ NSLog(@"imageTitle: %@", imageTitle);
return imageTitle;
}
- (NSString *)imageSubtitle
{
+ NSLog(@"imageSubtitle: %@", [imageDate description]);
return [imageDate description];
}
#import "TURAnselGallery.h"
#import "TURAnselGalleryPanelController.h"
#import "AnselGalleryViewItem.h"
+#import "NSStringAdditions.h"
@interface ApertureToAnselExportPlugin (PrivateAPI)
- (void)showNewServerSheet;
- (void)dealloc
{
+ NSLog(@"ApertureToAnselExportPlugin: dealloc called");
[_anselServers release];
+ _anselServers = nil;
+ NSLog(@"_anselServers released");
+
[_anselController setDelegate:nil];
[_anselController release];
+ _anselController = nil;
+ NSLog(@"_anselController released");
+
[_browserData release];
+ _browserData = nil;
+ NSLog(@"_browserData released");
// Release the top-level objects from the nib.
[_topLevelNibObjects makeObjectsPerformSelector:@selector(release)];
[_topLevelNibObjects release];
+ NSLog(@"topLevelNibs released");
+
[_progressLock release];
+ _progressLock = nil;
+ NSLog(@"_progressLock released");
+
[_exportManager release];
- [super dealloc];
+ _exportManager = nil;
+ NSLog(@"exportManager released");
+
+ [super dealloc];
}
#pragma mark -
[exportProgress.message autorelease];
exportProgress.message = [[NSString stringWithFormat:@"Uploading picture %d / %d",
index + 1, [_exportManager imageCount]] retain];
-
[self unlockProgress];
+
NSString *base64ImageData = [NSString base64StringFromData: imageData
length: [imageData length]];
NSDictionary *properties = [_exportManager propertiesWithoutThumbnailForImageAtIndex: index];
fileType,
[properties objectForKey:kExportKeyKeywords],
nil];
-
-
-
+
NSDictionary *imageDataDict = [[NSDictionary alloc] initWithObjects:values
forKeys:keys];
NSDictionary *params = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithBool:NO], @"default",
nil];
- //Start upload with current gallery.
- NSLog(@"Uploading photo %d out of %d", index, [_exportManager imageCount]);
-
- // Make sure we are around for all callbacks to return even if Aperture cancelled.
- [self retain];
- [_currentGallery uploadImageObject: params];
- [keys release];
- [values release];
- [imageDataDict release];
- [params release];
+
+ //Start upload with current gallery.
+ NSLog(@"Uploading photo %d out of %d", index, [_exportManager imageCount]);
+
+ // Make sure we are around for all callbacks to return even if Aperture cancelled.
+ [self retain];
+ [_currentGallery uploadImageObject: params];
+ [keys release];
+ [values release];
+ [imageDataDict release];
+ [params release];
+
// Returning NO informs Aperture that the plugin is handling the export,
// and NOT Aperture.
- (void)exportManagerDidWriteImageDataToRelativePath:(NSString *)relativePath forImageAtIndex:(unsigned)index
{
NSLog(@"exportManagerDidWriteImageDataToRelativePath %@", relativePath);
- [self lockProgress];
- exportProgress.currentValue++;
- [self unlockProgress];
}
- (void)exportManagerDidFinishExport
// You must call [_exportManager shouldFinishExport] before Aperture will put away the progress window and complete the export.
// NOTE: You should assume that your plug-in will be deallocated immediately following this call. Be sure you have cleaned up
// any callbacks or running threads before calling.
- [[NSNotificationCenter defaultCenter] removeObserver: self
- name: NSWindowWillCloseNotification
- object: nil];
[[NSNotificationCenter defaultCenter] removeObserver: self
name: @"NSPopUpButtonWillPopUpNotification"
object: nil];
// You must call [_exportManager shouldCancelExport] here or elsewhere before Aperture will cancel the export process
// NOTE: You should assume that your plug-in will be deallocated immediately following this call. Be sure you have cleaned up
// any callbacks or running threads before calling.
- [[NSNotificationCenter defaultCenter] removeObserver: self
- name: NSWindowWillCloseNotification
- object: nil];
[[NSNotificationCenter defaultCenter] removeObserver: self
name: @"NSPopUpButtonWillPopUpNotification"
object: nil];
// and update the UI.
- (void)TURAnselDidInitialize
{
+ NSLog(@"TURAnselDidInitialize");
// Release now that the callback has completed.
[self release];
[galleryCombo reloadData];
[mServersPopUp setEnabled: true];
}
+- (void)TURAnselReceivedResults:(NSDictionary *)results forMethod:(NSString *)method
+{
+ NSLog(@"method: %@", method);
+ NSLog(@"results: %@", results);
+
+}
+
//@TODO - need to add a flag to indicate if we have a UI or not
- (void)TURAnselHadError: (NSError *)error
{
- [self release];
NSLog(@"TURAnselHadError");
// Stop the spinner
[spinner stopAnimation: self];
- [self disconnect];
[mServersPopUp setEnabled: true];
NSAlert *alert;
didEndSelector:nil
contextInfo:nil];
[alert release];
+ [self disconnect];
+ //[self release];
+}
+
+#pragma mark -
+#pragma mark TURAnselGallery Delegate
+- (void)TURAnselGalleryDidUploadImage:(id *)gallery
+{
+ [self release];
+ NSLog(@"TURAnselGalleryDidUploadImage:");
+ [self lockProgress];
+ exportProgress.currentValue++;
+ [self unlockProgress];
}
#pragma mark -
[_currentGallery setDelegate: self];
// Obtain and properly size the image for screen
- NSImage *theImage = [[NSImage alloc] initWithContentsOfURL: [_currentGallery galleryDefaultImageURL]];
+ NSImage *theImage = [[NSImage alloc] initWithContentsOfURL: [_currentGallery galleryKeyImageURL]];
NSSize imageSize;
imageSize.width = [[theImage bestRepresentationForDevice:nil] pixelsWide];
imageSize.height = [[theImage bestRepresentationForDevice:nil] pixelsHigh];
[self setStatusText: @"Connected" withColor: [NSColor greenColor]];
}
-#pragma mark export notifications
-- (void)exportWindowWillClose: (NSNotification *)notification
-{
- [mServersPopUp selectItemAtIndex: 0];
- [self disconnect];
- [[NSNotificationCenter defaultCenter] removeObserver: self
- name: NSWindowWillCloseNotification
- object: nil];
-}
-
- (void)exportWindowDidBecomeKey: (NSNotification *)notification
{
- NSLog(@"exportWindowDidBecomeKey");
- // Register for the close notification
- [[NSNotificationCenter defaultCenter] addObserver: self
- selector: @selector(exportWindowWillClose:)
- name: NSWindowWillCloseNotification
- object :nil];
-
// Only do this once
[[NSNotificationCenter defaultCenter] removeObserver: self
name: NSWindowDidBecomeKeyNotification
// Action sent by the server pop up menu
- (IBAction)clickServer: (id)sender
{
+ NSLog(@"clickServer");
// Are we set to "none" now?
if ([mServersPopUp indexOfSelectedItem] == 0) {
[self disconnect];
}
for (NSDictionary *image in images) {
+ // The CF Web Services library can return NSNull objects for values that
+ // were returned as empty or null, so we need to check for that.
+ // (Even if caption is nil, caption.length will still be zero, so we
+ // don't need a seperate case for that).
NSString *caption = [image objectForKey:@"caption"];
- if (caption == nil) {
- caption = [image objectForKey:@"filename"];
+ if (caption == (NSString *)[NSNull null] || [caption length] == 0) {
+ caption = [image objectForKey:@"name"];
}
NSDate *theDate = [NSDate dateWithTimeIntervalSince1970: [[image objectForKey:@"original_date"] doubleValue]];
withTitle: caption
withDate: theDate];
[_browserData addObject: item];
+ [item release];
}
[NSApp beginSheet: mviewGallerySheet
- (IBAction) closeGalleryView: (id)sender
{
+ NSLog(@"closeGalleryView");
[NSApp endSheet: mviewGallerySheet];
[mviewGallerySheet orderOut: nil];
[_browserData removeAllObjects];
// Put up the newGallerySheet NSPanel
- (IBAction)showNewGallery: (id)sender
{
+ NSLog(@"showNewGallery:");
TURAnselGalleryPanelController *newGalleryController;
//NSString *albumName;
// See if we have everything we need to export...
- (void)canExport
{
- if ([_anselController state] == TURAnselStateConnected) {
+ //if ([_anselController state] == TURAnselStateConnected) {
[mNewGalleryButton setEnabled: YES];
[galleryCombo setEnabled: YES];
- } else {
+ //} else {
+ if (1 == 2) {
+
+
[mNewGalleryButton setEnabled: NO];
[galleryCombo setEnabled: NO];
[viewGallery setEnabled: NO];
[viewGallery setEnabled: NO];
[self setStatusText: @"Connecting..."];
[spinner startAnimation: self];
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
NSDictionary *p = [[NSDictionary alloc] initWithObjects: [NSArray arrayWithObjects:
[_currentServer objectForKey:TURAnselServerEndpointKey],
[_currentServer objectForKey:TURAnselServerUsernameKey],
nil]
forKeys: [NSArray arrayWithObjects:@"endpoint", @"username", @"password", nil]];
// Create our controller
+ [_anselController autorelease];
_anselController = [[TURAnsel alloc] initWithConnectionParameters:p];
[_anselController setDelegate:self];
[galleryCombo setDataSource:_anselController];
[galleryCombo setDelegate:self];
[spinner startAnimation:self];
+
// Detach to a new thread and do the actual login/retrieval of gallery list
[NSApplication detachDrawingThread: @selector(connect)
toTarget: self
withObject: nil];
+
[p release];
- [pool drain];
}
// Runs in a new thread.
- (void)connect
// Make sure we clean up from any previous connection
-(void)disconnect
{
- //[galleryCombo deselectItemAtIndex: [galleryCombo indexOfSelectedItem]];
+ NSLog(@"disconnect");
[galleryCombo setDelegate: nil];
[galleryCombo setDataSource: nil];
[galleryCombo reloadData];
[_anselController setDelegate: nil];
[_anselController release];
_anselController = nil;
+
[self setStatusText:@"Not logged in" withColor: [NSColor redColor]];
}
#pragma mark IKImageBrowserView Datasource methods
- (NSUInteger)numberOfItemsInImageBrowser:(IKImageBrowserView *) aBrowser
{
+ NSLog(@"numberOfItemsInImageBrowser: %u", [_browserData count]);
return [_browserData count];
}
- (id)imageBrowser:(IKImageBrowserView *) aBrowser itemAtIndex:(NSUInteger)index
{
+ NSLog(@"imageBrowser:itemAtIndex: %@", [_browserData objectAtIndex:index]);
return [_browserData objectAtIndex:index];
}
#pragma mark NSTableView Datasource
B0AE23411049F7A20096565B /* AnselGalleryPanel.nib in Resources */ = {isa = PBXBuildFile; fileRef = B0AE233D1049F7A20096565B /* AnselGalleryPanel.nib */; };
B0D311D01049A7DE006B06C6 /* TURAnsel.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D311CB1049A7DE006B06C6 /* TURAnsel.m */; };
B0D311D11049A7DE006B06C6 /* TURAnselGallery.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D311CD1049A7DE006B06C6 /* TURAnselGallery.m */; };
- B0D311D21049A7DE006B06C6 /* TURXMLConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D311CF1049A7DE006B06C6 /* TURXMLConnection.m */; };
- B0D312241049A977006B06C6 /* NSDataAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D3120F1049A977006B06C6 /* NSDataAdditions.m */; };
- B0D312251049A977006B06C6 /* NSStringAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D312111049A977006B06C6 /* NSStringAdditions.m */; };
- B0D312271049A977006B06C6 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = B0D312141049A977006B06C6 /* Localizable.strings */; };
- B0D312281049A977006B06C6 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = B0D312161049A977006B06C6 /* LICENSE */; };
- B0D312291049A977006B06C6 /* README in Resources */ = {isa = PBXBuildFile; fileRef = B0D312171049A977006B06C6 /* README */; };
- B0D3122A1049A977006B06C6 /* XMLRPCConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D3121B1049A977006B06C6 /* XMLRPCConnection.m */; };
- B0D3122B1049A977006B06C6 /* XMLRPCDecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D3121D1049A977006B06C6 /* XMLRPCDecoder.m */; };
- B0D3122C1049A977006B06C6 /* XMLRPCEncoder.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D3121F1049A977006B06C6 /* XMLRPCEncoder.m */; };
- B0D3122D1049A977006B06C6 /* XMLRPCRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D312211049A977006B06C6 /* XMLRPCRequest.m */; };
- B0D3122E1049A977006B06C6 /* XMLRPCResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D312231049A977006B06C6 /* XMLRPCResponse.m */; };
- B0D312321049A9F2006B06C6 /* XMLRPC-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B0D312311049A9F2006B06C6 /* XMLRPC-Info.plist */; };
- B0D312591049AD08006B06C6 /* XMLRPC.h in Headers */ = {isa = PBXBuildFile; fileRef = B0D312181049A977006B06C6 /* XMLRPC.h */; settings = {ATTRIBUTES = (Public, ); }; };
- B0D3125A1049AD16006B06C6 /* XMLRPCConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = B0D3121A1049A977006B06C6 /* XMLRPCConnection.h */; settings = {ATTRIBUTES = (Public, ); }; };
- B0D3125B1049AD16006B06C6 /* XMLRPCDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = B0D3121C1049A977006B06C6 /* XMLRPCDecoder.h */; settings = {ATTRIBUTES = (Public, ); }; };
- B0D3125C1049AD16006B06C6 /* XMLRPCEncoder.h in Headers */ = {isa = PBXBuildFile; fileRef = B0D3121E1049A977006B06C6 /* XMLRPCEncoder.h */; settings = {ATTRIBUTES = (Public, ); }; };
- B0D3125D1049AD16006B06C6 /* XMLRPCRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = B0D312201049A977006B06C6 /* XMLRPCRequest.h */; settings = {ATTRIBUTES = (Public, ); }; };
- B0D3125E1049AD16006B06C6 /* XMLRPCResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = B0D312221049A977006B06C6 /* XMLRPCResponse.h */; settings = {ATTRIBUTES = (Public, ); }; };
- B0D3125F1049AD42006B06C6 /* XMLRPCConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D3121B1049A977006B06C6 /* XMLRPCConnection.m */; };
- B0D312601049AD42006B06C6 /* XMLRPCDecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D3121D1049A977006B06C6 /* XMLRPCDecoder.m */; };
- B0D312611049AD42006B06C6 /* XMLRPCEncoder.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D3121F1049A977006B06C6 /* XMLRPCEncoder.m */; };
- B0D312621049AD42006B06C6 /* XMLRPCRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D312211049A977006B06C6 /* XMLRPCRequest.m */; };
- B0D312631049AD42006B06C6 /* XMLRPCResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D312231049A977006B06C6 /* XMLRPCResponse.m */; };
- B0D312641049AD51006B06C6 /* NSDataAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = B0D3120E1049A977006B06C6 /* NSDataAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
- B0D312651049AD51006B06C6 /* NSStringAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = B0D312101049A977006B06C6 /* NSStringAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
- B0D312661049AD5B006B06C6 /* NSDataAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D3120F1049A977006B06C6 /* NSDataAdditions.m */; };
- B0D312671049AD5B006B06C6 /* NSStringAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B0D312111049A977006B06C6 /* NSStringAdditions.m */; };
- B0D312681049AD7F006B06C6 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = B0D312161049A977006B06C6 /* LICENSE */; };
- B0D312691049AD7F006B06C6 /* README in Resources */ = {isa = PBXBuildFile; fileRef = B0D312171049A977006B06C6 /* README */; };
- B0D3126A1049AD9A006B06C6 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = B0D312141049A977006B06C6 /* Localizable.strings */; };
- B0D312A01049B26B006B06C6 /* XMLRPC.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = B0D312941049B24A006B06C6 /* XMLRPC.framework */; };
+ B0DD64D2106738DB00085661 /* NSStringAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B0DD64D1106738DB00085661 /* NSStringAdditions.m */; };
+ B0DD64E31067391E00085661 /* NSDataAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B0DD64E21067391E00085661 /* NSDataAdditions.m */; };
B0DEA058104D7012001D1509 /* AnselGalleryViewItem.m in Sources */ = {isa = PBXBuildFile; fileRef = B0DEA057104D7012001D1509 /* AnselGalleryViewItem.m */; };
B0DEA1CE104D7DE2001D1509 /* Quartz.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B0DEA1CD104D7DE2001D1509 /* Quartz.framework */; };
D118EA660AC08CCB006DD2FE /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = D118EA640AC08CCB006DD2FE /* Localizable.strings */; };
D15DEA520ABF641300CBE3A5 /* ApertureToAnselExportPlugin.nib in Resources */ = {isa = PBXBuildFile; fileRef = D15DEA500ABF641300CBE3A5 /* ApertureToAnselExportPlugin.nib */; };
/* End PBXBuildFile section */
-/* Begin PBXContainerItemProxy section */
- B0D312401049AB4A006B06C6 /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = 089C1669FE841209C02AAC07 /* Project object */;
- proxyType = 1;
- remoteGlobalIDString = B0D312371049AACC006B06C6;
- remoteInfo = XMLRPC;
- };
-/* End PBXContainerItemProxy section */
-
/* Begin PBXCopyFilesBuildPhase section */
B0D3124D1049AB8B006B06C6 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
dstPath = "";
dstSubfolderSpec = 10;
files = (
- B0D312A01049B26B006B06C6 /* XMLRPC.framework in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
B0D311CB1049A7DE006B06C6 /* TURAnsel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TURAnsel.m; sourceTree = "<group>"; };
B0D311CC1049A7DE006B06C6 /* TURAnselGallery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TURAnselGallery.h; sourceTree = "<group>"; };
B0D311CD1049A7DE006B06C6 /* TURAnselGallery.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TURAnselGallery.m; sourceTree = "<group>"; };
- B0D311CE1049A7DE006B06C6 /* TURXMLConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TURXMLConnection.h; sourceTree = "<group>"; };
- B0D311CF1049A7DE006B06C6 /* TURXMLConnection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TURXMLConnection.m; sourceTree = "<group>"; };
- B0D3120E1049A977006B06C6 /* NSDataAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSDataAdditions.h; sourceTree = "<group>"; };
- B0D3120F1049A977006B06C6 /* NSDataAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSDataAdditions.m; sourceTree = "<group>"; };
- B0D312101049A977006B06C6 /* NSStringAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSStringAdditions.h; sourceTree = "<group>"; };
- B0D312111049A977006B06C6 /* NSStringAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSStringAdditions.m; sourceTree = "<group>"; };
- B0D312151049A977006B06C6 /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/Localizable.strings; sourceTree = "<group>"; };
- B0D312161049A977006B06C6 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
- B0D312171049A977006B06C6 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
- B0D312181049A977006B06C6 /* XMLRPC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLRPC.h; sourceTree = "<group>"; };
- B0D312191049A977006B06C6 /* XMLRPC.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLRPC.pch; sourceTree = "<group>"; };
- B0D3121A1049A977006B06C6 /* XMLRPCConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLRPCConnection.h; sourceTree = "<group>"; };
- B0D3121B1049A977006B06C6 /* XMLRPCConnection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XMLRPCConnection.m; sourceTree = "<group>"; };
- B0D3121C1049A977006B06C6 /* XMLRPCDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLRPCDecoder.h; sourceTree = "<group>"; };
- B0D3121D1049A977006B06C6 /* XMLRPCDecoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XMLRPCDecoder.m; sourceTree = "<group>"; };
- B0D3121E1049A977006B06C6 /* XMLRPCEncoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLRPCEncoder.h; sourceTree = "<group>"; };
- B0D3121F1049A977006B06C6 /* XMLRPCEncoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XMLRPCEncoder.m; sourceTree = "<group>"; };
- B0D312201049A977006B06C6 /* XMLRPCRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLRPCRequest.h; sourceTree = "<group>"; };
- B0D312211049A977006B06C6 /* XMLRPCRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XMLRPCRequest.m; sourceTree = "<group>"; };
- B0D312221049A977006B06C6 /* XMLRPCResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLRPCResponse.h; sourceTree = "<group>"; };
- B0D312231049A977006B06C6 /* XMLRPCResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XMLRPCResponse.m; sourceTree = "<group>"; };
- B0D312311049A9F2006B06C6 /* XMLRPC-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "XMLRPC-Info.plist"; sourceTree = "<group>"; };
- B0D312391049AACC006B06C6 /* XMLRPC-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "XMLRPC-Info.plist"; sourceTree = "<group>"; };
- B0D312941049B24A006B06C6 /* XMLRPC.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = XMLRPC.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+ B0DD64D0106738DB00085661 /* NSStringAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSStringAdditions.h; sourceTree = "<group>"; };
+ B0DD64D1106738DB00085661 /* NSStringAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSStringAdditions.m; sourceTree = "<group>"; };
+ B0DD64E11067391E00085661 /* NSDataAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSDataAdditions.h; sourceTree = "<group>"; };
+ B0DD64E21067391E00085661 /* NSDataAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSDataAdditions.m; sourceTree = "<group>"; };
B0DEA056104D7012001D1509 /* AnselGalleryViewItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnselGalleryViewItem.h; sourceTree = "<group>"; };
B0DEA057104D7012001D1509 /* AnselGalleryViewItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AnselGalleryViewItem.m; sourceTree = "<group>"; };
B0DEA1CD104D7DE2001D1509 /* Quartz.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quartz.framework; path = /System/Library/Frameworks/Quartz.framework; sourceTree = "<absolute>"; };
);
runOnlyForDeploymentPostprocessing = 0;
};
- B0D312361049AACC006B06C6 /* Frameworks */ = {
- isa = PBXFrameworksBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
089C166AFE841209C02AAC07 /* MyApertureExportPlugIn */ = {
isa = PBXGroup;
children = (
+ B00872201066B73A00BE0CCF /* Additions */,
B0D312931049B17F006B06C6 /* AnselToolkit */,
287924B60DAEB2A20074992A /* ApertureHeaders */,
08FB77AFFE84173DC02AAC07 /* Classes */,
089C167CFE841241C02AAC07 /* Resources */,
089C1671FE841209C02AAC07 /* Frameworks and Libraries */,
D118EB1C0AC08EE7006DD2FE /* Products */,
- B0D312391049AACC006B06C6 /* XMLRPC-Info.plist */,
);
name = MyApertureExportPlugIn;
sourceTree = "<group>";
089C1671FE841209C02AAC07 /* Frameworks and Libraries */ = {
isa = PBXGroup;
children = (
- B0D3120C1049A977006B06C6 /* xmlrpc-1.5.1 */,
1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */,
1058C7AEFEA557BF11CA2CBB /* Other Frameworks */,
);
08FB77AFFE84173DC02AAC07 /* Classes */ = {
isa = PBXGroup;
children = (
- B0DEA056104D7012001D1509 /* AnselGalleryViewItem.h */,
- B0DEA057104D7012001D1509 /* AnselGalleryViewItem.m */,
D15DEA4E0ABF63C600CBE3A5 /* ApertureToAnselExportPlugin.h */,
D15DEA4D0ABF63C600CBE3A5 /* ApertureToAnselExportPlugin.m */,
);
32C88E010371C26100C91783 /* Other Sources */ = {
isa = PBXGroup;
children = (
- B0D311CF1049A7DE006B06C6 /* TURXMLConnection.m */,
- B0D311CE1049A7DE006B06C6 /* TURXMLConnection.h */,
32DBCF630370AF2F00C91783 /* ApertureToAnselExportPlugin_Prefix.pch */,
);
name = "Other Sources";
sourceTree = "<group>";
};
- B0D3120C1049A977006B06C6 /* xmlrpc-1.5.1 */ = {
- isa = PBXGroup;
- children = (
- B0D312311049A9F2006B06C6 /* XMLRPC-Info.plist */,
- B0D3120D1049A977006B06C6 /* Additions */,
- B0D312131049A977006B06C6 /* Languages */,
- B0D312161049A977006B06C6 /* LICENSE */,
- B0D312171049A977006B06C6 /* README */,
- B0D312181049A977006B06C6 /* XMLRPC.h */,
- B0D312191049A977006B06C6 /* XMLRPC.pch */,
- B0D3121A1049A977006B06C6 /* XMLRPCConnection.h */,
- B0D3121B1049A977006B06C6 /* XMLRPCConnection.m */,
- B0D3121C1049A977006B06C6 /* XMLRPCDecoder.h */,
- B0D3121D1049A977006B06C6 /* XMLRPCDecoder.m */,
- B0D3121E1049A977006B06C6 /* XMLRPCEncoder.h */,
- B0D3121F1049A977006B06C6 /* XMLRPCEncoder.m */,
- B0D312201049A977006B06C6 /* XMLRPCRequest.h */,
- B0D312211049A977006B06C6 /* XMLRPCRequest.m */,
- B0D312221049A977006B06C6 /* XMLRPCResponse.h */,
- B0D312231049A977006B06C6 /* XMLRPCResponse.m */,
- );
- path = "xmlrpc-1.5.1";
- sourceTree = "<group>";
- };
- B0D3120D1049A977006B06C6 /* Additions */ = {
+ B00872201066B73A00BE0CCF /* Additions */ = {
isa = PBXGroup;
children = (
- B0D3120E1049A977006B06C6 /* NSDataAdditions.h */,
- B0D3120F1049A977006B06C6 /* NSDataAdditions.m */,
- B0D312101049A977006B06C6 /* NSStringAdditions.h */,
- B0D312111049A977006B06C6 /* NSStringAdditions.m */,
+ B0DD64E11067391E00085661 /* NSDataAdditions.h */,
+ B0DD64E21067391E00085661 /* NSDataAdditions.m */,
+ B0DD64D0106738DB00085661 /* NSStringAdditions.h */,
+ B0DD64D1106738DB00085661 /* NSStringAdditions.m */,
);
- path = Additions;
- sourceTree = "<group>";
- };
- B0D312131049A977006B06C6 /* Languages */ = {
- isa = PBXGroup;
- children = (
- B0D312141049A977006B06C6 /* Localizable.strings */,
- );
- path = Languages;
+ name = Additions;
sourceTree = "<group>";
};
B0D312931049B17F006B06C6 /* AnselToolkit */ = {
isa = PBXGroup;
children = (
+ B0DEA056104D7012001D1509 /* AnselGalleryViewItem.h */,
+ B0DEA057104D7012001D1509 /* AnselGalleryViewItem.m */,
B0AE23351049F7770096565B /* TURAnselGalleryPanelController.h */,
B0AE23361049F7770096565B /* TURAnselGalleryPanelController.m */,
- B0D311CC1049A7DE006B06C6 /* TURAnselGallery.h */,
B0D311CB1049A7DE006B06C6 /* TURAnsel.m */,
B0D311CA1049A7DE006B06C6 /* TURAnsel.h */,
+ B0D311CC1049A7DE006B06C6 /* TURAnselGallery.h */,
B0D311CD1049A7DE006B06C6 /* TURAnselGallery.m */,
);
name = AnselToolkit;
D118EB1C0AC08EE7006DD2FE /* Products */ = {
isa = PBXGroup;
children = (
- B0D312941049B24A006B06C6 /* XMLRPC.framework */,
D118EB0F0AC08EAE006DD2FE /* ApertureToAnselExportPlugin.ApertureExport */,
);
name = Products;
};
/* End PBXGroup section */
-/* Begin PBXHeadersBuildPhase section */
- B0D312331049AACC006B06C6 /* Headers */ = {
- isa = PBXHeadersBuildPhase;
- buildActionMask = 2147483647;
- files = (
- B0D312641049AD51006B06C6 /* NSDataAdditions.h in Headers */,
- B0D312651049AD51006B06C6 /* NSStringAdditions.h in Headers */,
- B0D3125A1049AD16006B06C6 /* XMLRPCConnection.h in Headers */,
- B0D3125B1049AD16006B06C6 /* XMLRPCDecoder.h in Headers */,
- B0D3125C1049AD16006B06C6 /* XMLRPCEncoder.h in Headers */,
- B0D3125D1049AD16006B06C6 /* XMLRPCRequest.h in Headers */,
- B0D3125E1049AD16006B06C6 /* XMLRPCResponse.h in Headers */,
- B0D312591049AD08006B06C6 /* XMLRPC.h in Headers */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXHeadersBuildPhase section */
-
/* Begin PBXNativeTarget section */
8D5B49AC048680CD000E48DA /* ApertureToAnselExportPlugin */ = {
isa = PBXNativeTarget;
buildRules = (
);
dependencies = (
- B0D312411049AB4A006B06C6 /* PBXTargetDependency */,
);
name = ApertureToAnselExportPlugin;
productInstallPath = "$(HOME)/Library/Bundles";
productReference = D118EB0F0AC08EAE006DD2FE /* ApertureToAnselExportPlugin.ApertureExport */;
productType = "com.apple.product-type.bundle";
};
- B0D312371049AACC006B06C6 /* XMLRPC */ = {
- isa = PBXNativeTarget;
- buildConfigurationList = B0D3123C1049AACD006B06C6 /* Build configuration list for PBXNativeTarget "XMLRPC" */;
- buildPhases = (
- B0D312331049AACC006B06C6 /* Headers */,
- B0D312341049AACC006B06C6 /* Resources */,
- B0D312351049AACC006B06C6 /* Sources */,
- B0D312361049AACC006B06C6 /* Frameworks */,
- );
- buildRules = (
- );
- dependencies = (
- );
- name = XMLRPC;
- productName = XMLRPC;
- productReference = B0D312941049B24A006B06C6 /* XMLRPC.framework */;
- productType = "com.apple.product-type.framework";
- };
/* End PBXNativeTarget section */
/* Begin PBXProject section */
projectRoot = "";
targets = (
8D5B49AC048680CD000E48DA /* ApertureToAnselExportPlugin */,
- B0D312371049AACC006B06C6 /* XMLRPC */,
);
};
/* End PBXProject section */
8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */,
D15DEA520ABF641300CBE3A5 /* ApertureToAnselExportPlugin.nib in Resources */,
D118EA660AC08CCB006DD2FE /* Localizable.strings in Resources */,
- B0D312271049A977006B06C6 /* Localizable.strings in Resources */,
- B0D312281049A977006B06C6 /* LICENSE in Resources */,
- B0D312291049A977006B06C6 /* README in Resources */,
- B0D312321049A9F2006B06C6 /* XMLRPC-Info.plist in Resources */,
B0AE23411049F7A20096565B /* AnselGalleryPanel.nib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
- B0D312341049AACC006B06C6 /* Resources */ = {
- isa = PBXResourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- B0D3126A1049AD9A006B06C6 /* Localizable.strings in Resources */,
- B0D312681049AD7F006B06C6 /* LICENSE in Resources */,
- B0D312691049AD7F006B06C6 /* README in Resources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
D15DEA4F0ABF63C600CBE3A5 /* ApertureToAnselExportPlugin.m in Sources */,
B0D311D01049A7DE006B06C6 /* TURAnsel.m in Sources */,
B0D311D11049A7DE006B06C6 /* TURAnselGallery.m in Sources */,
- B0D311D21049A7DE006B06C6 /* TURXMLConnection.m in Sources */,
- B0D312241049A977006B06C6 /* NSDataAdditions.m in Sources */,
- B0D312251049A977006B06C6 /* NSStringAdditions.m in Sources */,
- B0D3122A1049A977006B06C6 /* XMLRPCConnection.m in Sources */,
- B0D3122B1049A977006B06C6 /* XMLRPCDecoder.m in Sources */,
- B0D3122C1049A977006B06C6 /* XMLRPCEncoder.m in Sources */,
- B0D3122D1049A977006B06C6 /* XMLRPCRequest.m in Sources */,
- B0D3122E1049A977006B06C6 /* XMLRPCResponse.m in Sources */,
B0AE23391049F7770096565B /* TURAnselGalleryPanelController.m in Sources */,
B0DEA058104D7012001D1509 /* AnselGalleryViewItem.m in Sources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- B0D312351049AACC006B06C6 /* Sources */ = {
- isa = PBXSourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- B0D312661049AD5B006B06C6 /* NSDataAdditions.m in Sources */,
- B0D312671049AD5B006B06C6 /* NSStringAdditions.m in Sources */,
- B0D3125F1049AD42006B06C6 /* XMLRPCConnection.m in Sources */,
- B0D312601049AD42006B06C6 /* XMLRPCDecoder.m in Sources */,
- B0D312611049AD42006B06C6 /* XMLRPCEncoder.m in Sources */,
- B0D312621049AD42006B06C6 /* XMLRPCRequest.m in Sources */,
- B0D312631049AD42006B06C6 /* XMLRPCResponse.m in Sources */,
+ B0DD64D2106738DB00085661 /* NSStringAdditions.m in Sources */,
+ B0DD64E31067391E00085661 /* NSDataAdditions.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
-/* Begin PBXTargetDependency section */
- B0D312411049AB4A006B06C6 /* PBXTargetDependency */ = {
- isa = PBXTargetDependency;
- target = B0D312371049AACC006B06C6 /* XMLRPC */;
- targetProxy = B0D312401049AB4A006B06C6 /* PBXContainerItemProxy */;
- };
-/* End PBXTargetDependency section */
-
/* Begin PBXVariantGroup section */
089C167DFE841241C02AAC07 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
name = AnselGalleryPanel.nib;
sourceTree = "<group>";
};
- B0D312141049A977006B06C6 /* Localizable.strings */ = {
- isa = PBXVariantGroup;
- children = (
- B0D312151049A977006B06C6 /* English */,
- );
- name = Localizable.strings;
- sourceTree = "<group>";
- };
D118EA640AC08CCB006DD2FE /* Localizable.strings */ = {
isa = PBXVariantGroup;
children = (
isa = XCBuildConfiguration;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = "/Library/Frameworks//**";
+ GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
- SDKROOT = macosx10.4;
+ SDKROOT = macosx10.5;
};
name = Debug;
};
i386,
);
FRAMEWORK_SEARCH_PATHS = "/Library/Frameworks//**";
+ GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
};
name = Release;
};
- B0D3123A1049AACC006B06C6 /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- COPY_PHASE_STRIP = NO;
- DYLIB_COMPATIBILITY_VERSION = 1;
- DYLIB_CURRENT_VERSION = 1;
- FRAMEWORK_VERSION = A;
- GCC_DYNAMIC_NO_PIC = NO;
- GCC_ENABLE_FIX_AND_CONTINUE = YES;
- GCC_MODEL_TUNING = G5;
- GCC_OPTIMIZATION_LEVEL = 0;
- GCC_PRECOMPILE_PREFIX_HEADER = YES;
- GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
- INFOPLIST_FILE = "XMLRPC-Info.plist";
- INSTALL_PATH = "$(HOME)/Library/Frameworks";
- OTHER_LDFLAGS = (
- "-framework",
- Foundation,
- "-framework",
- AppKit,
- );
- PREBINDING = NO;
- PRODUCT_NAME = XMLRPC;
- };
- name = Debug;
- };
- B0D3123B1049AACC006B06C6 /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- COPY_PHASE_STRIP = YES;
- DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
- DYLIB_COMPATIBILITY_VERSION = 1;
- DYLIB_CURRENT_VERSION = 1;
- FRAMEWORK_VERSION = A;
- GCC_ENABLE_FIX_AND_CONTINUE = NO;
- GCC_MODEL_TUNING = G5;
- GCC_PRECOMPILE_PREFIX_HEADER = YES;
- GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
- INFOPLIST_FILE = "XMLRPC-Info.plist";
- INSTALL_PATH = "@loader_path/../Frameworks";
- OTHER_LDFLAGS = (
- "-framework",
- Foundation,
- "-framework",
- AppKit,
- );
- PREBINDING = NO;
- PRODUCT_NAME = XMLRPC;
- ZERO_LINK = NO;
- };
- name = Release;
- };
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
- B0D3123C1049AACD006B06C6 /* Build configuration list for PBXNativeTarget "XMLRPC" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- B0D3123A1049AACC006B06C6 /* Debug */,
- B0D3123B1049AACC006B06C6 /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
/* End XCConfigurationList section */
};
rootObject = 089C1669FE841209C02AAC07 /* Project object */;
--- /dev/null
+//
+// Copyright 2008 Eric Czarny <eczarny@gmail.com>
+//
+// 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
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// 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 <Foundation/NSData.h>
+
+@class NSString;
+
+@interface NSData (NSDataAdditions)
+
++ (NSData *)base64DataFromString: (NSString *)string;
+
+@end
--- /dev/null
+//
+// Copyright 2008 Eric Czarny <eczarny@gmail.com>
+//
+// 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
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// 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"
+
+@implementation NSData (NSDataAdditions)
+
++ (NSData *)base64DataFromString: (NSString *)string {
+ unsigned long ixtext, lentext;
+ unsigned char ch, input[4], output[3];
+ short i, ixinput;
+ 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')) {
+ ch = ch - 'a' + 26;
+ } else if ((ch >= '0') && (ch <= '9')) {
+ ch = ch - '0' + 52;
+ } else if (ch == '+') {
+ ch = 62;
+ } else if (ch == '=') {
+ flendtext = true;
+ } else if (ch == '/') {
+ ch = 63;
+ } else {
+ 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;
+}
+
+@end
--- /dev/null
+//
+// Copyright 2008 Eric Czarny <eczarny@gmail.com>
+//
+// 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
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// 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 <Foundation/NSString.h>
+
+@class NSData;
+
+@interface NSString (NSStringAdditions)
+
++ (NSString *)base64StringFromData: (NSData *)data length: (NSInteger)length;
+
+@end
--- /dev/null
+//
+// Copyright 2008 Eric Czarny <eczarny@gmail.com>
+//
+// 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
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// 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"
+
+/* Base64 Encoding Table */
+static char base64EncodingTable[64] = {
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
+ 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
+ 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
+ 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
+};
+
+@implementation NSString (NSStringExtensions)
+
++ (NSString *)base64StringFromData: (NSData *)data length: (NSInteger)length {
+ unsigned long ixtext, lentext;
+ long ctremaining;
+ unsigned char input[3], output[4];
+ 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;
+
+ while (true) {
+ ctremaining = lentext - ixtext;
+
+ if (ctremaining <= 0) {
+ break;
+ }
+
+ 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;
+ break;
+ 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;
+}
+
+@end
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
-@class TURAnselGallery, XMLRPCResponse;
+@class TURAnselGallery;
typedef enum {
PERMS_SHOW = 2,
TURAnselStateDisconnected = 0,
TURAnselStateConnected,
TURAnselStateError,
- TURAnselStateCancelled
+ TURAnselStateCancelled,
+ TURAnselStateWaiting
} TURAnselState;
-
@interface NSObject (TURAnselDelegate)
- (void)TURAnselDidInitialize;
- (void)TURAnselHadError: (NSError *)error;
- (void)connect;
- (TURAnselGallery *)getGalleryById: (NSString *)galleryId;
- (TURAnselGallery *)getGalleryByIndex: (NSInteger)index;
-- (XMLRPCResponse *)callRPCMethod: (NSString *)methodName withParams: (NSArray *)params;
+- (NSDictionary *)callRPCMethod: (NSString *)methodName withParams: (NSArray *)params withOrder: (NSArray *)order;
- (NSDictionary *)createNewGallery: (NSDictionary *)params;
- (void)cancel;
- (void) setState: (TURAnselState)state;
- (TURAnselState)state;
- (id)delegate;
-- (void)setDelegate:(id)newDelegate;
+- (void)setDelegate: (id)newDelegate;
@end
//
#import <Foundation/Foundation.h>
-#import <XMLRPC/XMLRPC.h>
-#import "TURXMLConnection.h"
#import "TURAnsel.h"
#import "TURAnselGallery.h"
@synthesize username;
@synthesize password;
+#pragma mark -
#pragma mark init
- (id)initWithConnectionParameters: (NSDictionary *)params
{
forKey: @"password"];
[self setValue: @"The Ansel Cocoa XML-RPC Client"
forKey: @"userAgent"];
+
return self;
}
+-(void) dealloc
+{
+ NSLog(@"TURAnsel dealloc");
+ [galleryList removeAllObjects];
+ [galleryList release];
+ [rpcEndPoint release];
+ [username release];
+ [password release];
+ [userAgent release];
+ [super dealloc];
+}
+#pragma mark -
+#pragma mark Actions
-#pragma mark Instance Methods
-/**
- * Initial connection to the Ansel server
- * Authenticate and fill our cache with the available galleries for uploading to
- */
- (void)connect
{
[self doLogin];
- if (state == TURAnselStateConnected) {
- if ([delegate respondsToSelector:@selector(TURAnselDidInitialize)]) {
- [delegate performSelectorOnMainThread:@selector(TURAnselDidInitialize)
- withObject:self
- waitUntilDone: NO];
- }
- }
}
- (void) cancel
state = TURAnselStateCancelled;
}
-// Fetch a gallery by id
-- (TURAnselGallery *)getGalleryById: (NSString *)galleryId
-{
- for (TURAnselGallery *g in galleryList) {
- if ([galleryId isEqualTo: [NSNumber numberWithInt: [g galleryId]]]) {
- 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.
-- (TURAnselGallery *)getGalleryByIndex: (NSInteger)index
-{
- TURAnselGallery *g = [galleryList objectAtIndex:index];
- return g;
-}
-
-// Creates a new gallery
-// For now, only takes a gallery name, but no reason it can't take descriiption
-// and default perms etc...
+/**
+ * Create a new gallery on the Ansel server.
+ *
+ * @param NSDictionary params A dictionary of parameters for the new gallery.
+ *
+ * @return NSDictionary A dictionary describing the new gallery
+ */
- (NSDictionary *)createNewGallery: (NSDictionary *)params
{
- NSArray *apiparams = [NSArray arrayWithObjects:
- @"ansel", params, nil];
- XMLRPCResponse *response = [self callRPCMethod: @"images.createGallery"
- withParams: apiparams];
- if (state != TURAnselStateError) {
+ NSArray *apiparams = [NSArray arrayWithObjects: @"ansel", params, nil];
+ NSArray *order = [NSArray arrayWithObjects:@"scope", @"galleryparams", nil];
+
+ NSDictionary *response = [self callRPCMethod: @"images.createGallery"
+ withParams: apiparams
+ withOrder: order];
+
+ if (response) {
+
+ NSNumber *gallery_id = [response objectForKey: (NSString *)kWSMethodInvocationResult];
NSDictionary *results = [NSDictionary dictionaryWithObjectsAndKeys:
- response, @"share_id",
- [params valueForKey: @"name"], @"attribute_name",
- @"", @"attribute_desc",
- [NSNumber numberWithInt: 0], @"attribute_images",
- [NSNumber numberWithInt: 0], @"attribute_default", nil];
+ gallery_id, @"share_id",
+ [params valueForKey: @"name"], @"attribute_name",
+ @"", @"attribute_desc",
+ [NSNumber numberWithInt: 0], @"attribute_images",
+ [NSNumber numberWithInt: 0], @"attribute_default", nil];
TURAnselGallery *newGallery = [[TURAnselGallery alloc] initWithObject: results
controller: self];
[galleryList addObject: newGallery];
- //[attributes release];
+ [newGallery release];
+
return results;
}
- // If we have an error, tell the world
- // *really* need to give these errors real numbers.....
- if ([delegate respondsToSelector:@selector(TURAnselHadError:)]) {
- NSError *error = [NSError errorWithDomain:@"TURAnsel"
- code:3
- userInfo:[NSDictionary dictionaryWithObjectsAndKeys: @"Could not create gallery.", @"message", nil]];
- [delegate TURAnselHadError:error];
- }
-
return nil;
}
-// Call an arbitrary RPC method on the Horde server.
-- (XMLRPCResponse *)callRPCMethod: (NSString *)methodName
- withParams: (NSArray *)params
+/**
+ * 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
+ * WSMethodInvocationSetParameters is used. (The keys are
+ * disregarded by Horde, but needed to ensure they get
+ * sent in the correct order by WS.
+ *
+ * The invocationCallback function is called on completion, which in turn will
+ * call the methodCompletionCallback with the results
+ */
+- (NSDictionary *)callRPCMethod: (NSString *)methodName
+ withParams: (NSArray *) params
+ withOrder: (NSArray *) order
{
NSLog(@"Initiating connection for %@", methodName);
// Get a URL object
NSURL *url = [NSURL URLWithString: [self valueForKey: @"rpcEndPoint"]];
- XMLRPCRequest *request = [[XMLRPCRequest alloc]initWithHost: url];
- [request setUserAgent: [self valueForKey:@"userAgent"]];
- [request setMethod: methodName withParameters: params];
+ NSDictionary *values = [NSDictionary dictionaryWithObjects: params forKeys:order];
- NSDictionary *credentials = [[NSDictionary alloc] initWithObjectsAndKeys:
- [self valueForKey:@"username"], @"username",
- [self valueForKey:@"password"], @"password", nil];
+ // Credentials
+ NSString *user = [self valueForKey:@"username"];
+ NSString *pass = [self valueForKey:@"password"];
- TURXMLConnection *connection = [[TURXMLConnection alloc]
- initWithXMLRPCRequest: request
- withCredentials:credentials];
-
- // Don't move on until we have a response - this blocks the thread until
- // that happens. We should have some kind of timeout here...
- while ([connection isRunning]) {
- if (state == TURAnselStateCancelled) {
- [connection cancel];
- }
- NSDate *loopDate = [[NSDate alloc] initWithTimeIntervalSinceNow:0.1];
- [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
- beforeDate:loopDate];
- [loopDate release];
+ if (user != nil && [user length] && pass != nil && [pass length]) {
+ // Create a custom http request with authorization
+ CFHTTPMessageRef request = CFHTTPMessageCreateRequest(kCFAllocatorDefault,
+ (CFStringRef)@"POST",
+ (CFURLRef)url,
+ kCFHTTPVersion1_1);
+ // Add auth creds to request.
+ Boolean success = CFHTTPMessageAddAuthentication(request,
+ NULL,
+ (CFStringRef)user,
+ (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);
+ WSMethodInvocationSetParameters(rpcCall, (CFDictionaryRef)values, (CFArrayRef)order);
+ WSMethodInvocationSetProperty(rpcCall, kWSHTTPMessage, request);
+ NSDictionary *result = (NSDictionary *)WSMethodInvocationInvoke(rpcCall);
+ CFRelease(request);
+ // Check out the results
+ if (WSMethodResultIsFault((CFDictionaryRef) result)) {
+ NSNumber *faultCode = [result objectForKey: (NSString *)kWSFaultCode];
+ NSString *faultString = [result objectForKey: (NSString *)kWSFaultString];
+ NSLog(@"faultCode: %@ faultString: %@", faultCode, faultString);
+
+ if ([[self delegate] respondsToSelector: @selector(TURAnselHadError:)]) {
+ NSError *error = [NSError errorWithDomain:@"TURAnsel"
+ code:[faultCode intValue]
+ userInfo:[NSDictionary dictionaryWithObjectsAndKeys: faultString, @"message", nil]];
+
+ [[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];
+ }
}
- if ([connection hasError] == NO) {
- XMLRPCResponse *response = [[connection response] autorelease];
- [credentials release];
- [connection release];
- [request release];
- return response;
- } else {
- state = TURAnselStateError;
- NSError *error = [[connection error] retain];
- if ([delegate respondsToSelector:@selector(TURAnselHadError:)]) {
- [delegate TURAnselHadError:error];
- }
- [error autorelease];
- [connection release];
- [request release];
- return nil;
- }
-
+ NSLog(@"No authentication information present.");
+ return nil;
+
}
-#pragma mark TableView datasource
-- (int)numberOfRowsInTableView: (NSTableView *)tv
+#pragma mark -
+#pragma mark Setters/Getters
+// Fetch a gallery by id
+- (TURAnselGallery *)getGalleryById: (NSString *)galleryId
{
- return [galleryList count];
+ for (TURAnselGallery *g in galleryList) {
+ if ([galleryId isEqualTo: [NSNumber numberWithInt: [g galleryId]]]) {
+ return g;
+ }
+ }
+
+ return nil;
}
-- (id)tableView: (NSTableView *)tv
-objectValueForTableColumn:(NSTableColumn *)tc
- row: (int)rowIndex
+/**
+ * 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.
+ */
+- (TURAnselGallery *)getGalleryByIndex: (NSInteger)index
{
- NSString *identifier = [tc identifier];
- TURAnselGallery *g = [galleryList objectAtIndex:rowIndex];
- NSString *stringValue = [g valueForKey: identifier];
- return stringValue;
+ TURAnselGallery *g = [galleryList objectAtIndex:index];
+ return g;
}
+#pragma mark --
#pragma mark ComboBox Datasource
-
- (NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox
{
return [galleryList count];
delegate = newDelegate;
}
--(void) dealloc
-{
- NSLog(@"TURAnsel dealloc");
- [galleryList removeAllObjects];
- [galleryList release];
- [rpcEndPoint release];
- [username release];
- [password release];
- [userAgent release];
- [super dealloc];
-}
-
#pragma mark PrivateAPI
+/**
+ * Perform initial contact with Ansel server. Retrieves the list of galleries
+ * available for the selected server.
+ *
+ * @return void
+ */
- (void)doLogin
{
- // Start out by building an array of parameters to pass to the api call.
- // We start by asking for a list of available galleries with PERMS_EDIT.
- // This has the side effect of authenticating for the session.
NSArray *params = [[NSArray alloc] initWithObjects:
@"ansel", // Scope
[NSNumber numberWithInt: PERMS_EDIT], // Perms
[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).do
+ [self valueForKey:@"username"], nil]; // Restrict to user (This should be an option eventually).
-
- id galleries = [self callRPCMethod:@"images.listGalleries"
- withParams:params];
- if (state != TURAnselStateError) {
- state = TURAnselStateConnected;
+ NSArray *order = [NSArray arrayWithObjects: @"scope", @"perms", @"parent", @"levels", @"offset", @"count", @"useronly", nil];
+ NSDictionary *results = [self callRPCMethod: @"images.listGalleries"
+ withParams: params
+ withOrder: order];
+
+ if (results) {
+ NSDictionary *galleries = [results objectForKey: (id)kWSMethodInvocationResult];
for (NSString *gal in galleries) {
TURAnselGallery *theGallery = [[TURAnselGallery alloc] initWithObject: gal
controller: self];
[theGallery release];
theGallery = nil;
}
+
+ if ([delegate respondsToSelector:@selector(TURAnselDidInitialize)]) {
+ [delegate performSelectorOnMainThread:@selector(TURAnselDidInitialize)
+ withObject:self
+ waitUntilDone: NO];
+ }
+
}
+
[params release];
}
} TURAnselGalleryState;
@interface NSObject (TURAnselGalleryDelegate)
-- (void)TURAnselGalleryDidReceiveRPCResponse: (XMLRPCResponse *)response;
- (void)TURAnselGalleryDidUploadImage: (id *)gallery;
@end
@interface TURAnselGallery : NSObject {
- int galleryId;
+ int _galleryId;
int galleryImageCount;
- int galleryDefaultImage;
- NSURL *galleryDefaultImageURL;
+ int galleryKeyImage;
+ NSURL *galleryKeyImageURL;
NSMutableArray *imageList;
NSString *galleryName;
NSString *galleryDescription;
@property (readonly) NSString *galleryName;
@property (readonly) NSString *galleryDescription;
@property (readonly) int galleryImageCount;
-@property (readwrite) int galleryDefaultImage;
+@property (readwrite) int galleryKeyImage;
- (id)initWithObject:(id)galleryData controller:(TURAnsel * )controller;
- (void)uploadImageObject: (NSDictionary *)imageParameters;
-- (bool)isBusy;
// Getter / Setter
- (void)setDelegate: (id)newDelegate;
- (id)delegate;
-- (NSURL *)galleryDefaultImageURL;
+- (NSURL *)galleryKeyImageURL;
- (id)listImages;
- (int)galleryId;
- (TURAnselGalleryState) state;
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
-#import "XMLRPC/XMLRPC.h"
-#import "TURXMLConnection.h"
#import "TURAnsel.h"
#import "TURAnselGallery.h"
@synthesize galleryDescription;
@synthesize galleryName;
@synthesize galleryImageCount;
-@synthesize galleryDefaultImage;
+@synthesize galleryKeyImage;
-#pragma mark Instance Methods --------------------------------------------------
+#pragma mark -
+#pragma mark init
/**
* Init a gallery object
[self setValue: [galleryData valueForKey:@"attribute_images"]
forKey:@"galleryImageCount"];
[self setValue: [galleryData valueForKey:@"attribute_default"]
- forKey:@"galleryDefaultImage"];
+ forKey:@"galleryKeyImage"];
[self setAnselController: controller];
return self;
}
+- (void)dealloc
+{
+ NSLog(@"TURAnselGallery dealloc called on Gallery %@", self);
+ [anselController release];
+ anselController = nil;
+
+ [galleryKeyImageURL release];
+ galleryKeyImageURL = nil;
+
+ [imageList release];
+ imageList = nil;
+
+ [super dealloc];
+}
+- (id)description
+{
+ NSString *text = [NSString stringWithFormat:@"Description: %@ Id: %d has: %d images", galleryName, _galleryId, galleryImageCount];
+ return text;
+}
+
+#pragma mark -
+#pragma mark Actions
/**
- * Requests the gallery's default image url to be fetched from the server
+ * 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).
*/
-- (NSURL *)galleryDefaultImageURL
+- (NSURL *)galleryKeyImageURL
{
- if (!galleryDefaultImageURL) {
-
+ if (galleryKeyImageURL) {
+ return galleryKeyImageURL;
+ } else {
NSArray *params = [[NSArray alloc] initWithObjects:
@"ansel", // Scope
- [NSNumber numberWithInt: galleryDefaultImage], // Image Id
+ [NSNumber numberWithInt: galleryKeyImage], // Image Id
@"thumb", // Thumbnail type
[NSNumber numberWithBool:YES], // Full path
nil];
-
- [self setState:TURAnselGalleryStateBusy];
- XMLRPCResponse *response = [anselController callRPCMethod: @"images.getImageUrl"
- withParams: params];
+ NSArray *order = [NSArray arrayWithObjects: @"scope", @"image_id", @"thumbnail", @"path", nil];
+ NSDictionary *response = [anselController callRPCMethod: @"images.getImageUrl"
+ withParams: params
+ withOrder: order];
if (response) {
- galleryDefaultImageURL = [[NSURL URLWithString: [NSString stringWithFormat:@"%@", response]] retain];
- }
+ NSDictionary *url = [response objectForKey:(id)kWSMethodInvocationResult];
+ [galleryKeyImageURL autorelease];
+ galleryKeyImageURL = [[NSURL URLWithString: [NSString stringWithFormat: @"%@", url]] retain];
+ NSLog(@"galleryKeyImageURL: %@", galleryKeyImageURL);
+ return galleryKeyImageURL;
+ }
+
+ return nil;
}
-
- return galleryDefaultImageURL;
+
}
/**
NSArray *params = [[NSArray alloc] initWithObjects:
@"ansel", //Scope
- [NSNumber numberWithInt: galleryId], //Gallery Id
+ [NSNumber numberWithInt: _galleryId], //Gallery Id
[NSNumber numberWithInt: 2], //PERMS_SHOW
@"thumb", // Thumbnail
[NSNumber numberWithBool:YES], // Full path
nil];
-
- [self setState:TURAnselGalleryStateBusy];
- XMLRPCResponse *response = [anselController callRPCMethod: @"images.listImages"
- withParams: params];
-
+ NSArray *order = [NSArray arrayWithObjects: @"scope", @"gallery_id", @"perms", @"thumnail", @"path", nil];
+ NSDictionary *response = [anselController callRPCMethod: @"images.listImages"
+ withParams: params
+ withOrder: order];
if (response) {
- imageList = [response retain];
+ [imageList autorelease];
+ imageList = [[response objectForKey: (id)kWSMethodInvocationResult] retain];
+
+ NSLog(@"listImages: %@", imageList);
+
+ return imageList;
}
}
- return imageList;
+ return nil;
}
/**
* Upload the provided image to this gallery.
*/
- (void)uploadImageObject: (NSDictionary *)imageParameters
-{
- [self doUpload: imageParameters];
-}
-
-- (bool) isBusy
{
- if (state == TURAnselGalleryStateReady) {
- return NO;
- } else {
- return YES;
- }
+ [self doUpload: imageParameters];
}
-#pragma mark Getter/Setter------------------------------------------------------
+#pragma mark -
+#pragma mark Getter/Setter
- (int)galleryId
{
- return galleryId;
+ return _galleryId;
}
- (void)setGalleryId:(int)id
{
- galleryId = id;
+ _galleryId = id;
}
- (id)delegate
return anselController;
}
-#pragma mark Overrides----------------------------------------------------------
-- (void)dealloc
-{
- NSLog(@"TURAnselGallery dealloc called on Gallery %@", self);
- [anselController release];
- [galleryDefaultImageURL release];
- [imageList release];
- [super dealloc];
-}
-
-- (id)init
-{
- [super init];
- [self setState:TURAnselGalleryStateReady];
- return self;
-}
-
-- (id)description
-{
- NSString *text = [NSString stringWithFormat:@"Description: %@ Id: %d has: %d images", galleryName, galleryId, galleryImageCount];
- return text;
-}
-
+#pragma mark -
#pragma mark PrivateAPI
- (void)doUpload:(NSDictionary *)imageParameters
{
- // Need to build the XMLRPC params array now.
+ // Need to build the params array now.
NSArray *params = [[NSArray alloc] initWithObjects:
- @"ansel", // app
- [NSNumber numberWithInt: galleryId], // gallery_id
- [imageParameters valueForKey: @"data"], // image data array
+ @"ansel", // app
+ [NSNumber numberWithInt: _galleryId], // gallery_id
+ [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: @"scope", @"gallery_id", @"data", @"default", @"additional_data", @"encoding", nil];
// Send the request up to the controller
- [anselController callRPCMethod: @"images.saveImage"
- withParams: params];
+ NSDictionary *result = [anselController callRPCMethod: @"images.saveImage"
+ withParams: params
+ withOrder: order];
- if ([delegate respondsToSelector:@selector(TURAnselGalleryDidUploadImage:)]) {
- [delegate performSelectorOnMainThread: @selector(TURAnselGalleryDidUploadImage:)
- withObject: self
- waitUntilDone: NO];
+ if (result) {
+ if ([delegate respondsToSelector:@selector(TURAnselGalleryDidUploadImage:)]) {
+ [delegate performSelectorOnMainThread: @selector(TURAnselGalleryDidUploadImage:)
+ withObject: self
+ waitUntilDone: NO];
+ }
}
[params release];
+++ /dev/null
-//
-// TURXMLConnection.h
-//
-// This is a thin wrapper around XMLRPCRequests to allow them to more easily
-// be run in a seperate thread then the reciever that needs to know about it's
-// progress. Done to deal with modal threads blocking the NSURLConnection
-// responses in iPhoto plugins.
-//
-// Created by Michael Rubinsky on 11/5/08.
-// Copyright 2008 __MyCompanyName__. All rights reserved.
-//
-
-#import <Cocoa/Cocoa.h>
-#import "XMLRPC/XMLRPCConnection.h"
-@class XMLRPCRequest;
-
-// Local error codes
-#define TURXML_ERR_BADAUTH 1 // Login failed
-#define TURXML_ERR_PARSE 2 // Could not parse XML
-#define TURXML_ERR_CANCEL 3 // Action cancelled
-
-@interface TURXMLConnection : XMLRPCConnection {
- NSString *username;
- NSString *password;
- XMLRPCResponse *response;
- XMLRPCConnection *connection;
- BOOL hasError;
- NSError *error;
- BOOL running;
-}
-
-- (TURXMLConnection *)initWithXMLRPCRequest: (XMLRPCRequest *)request
- withCredentials:(NSDictionary *)credentials;
-
-- (id)response;
-- (BOOL)hasError;
-- (BOOL)isRunning;
-- (NSError *)error;
-@end
+++ /dev/null
-//
-// TURXMLConnection.m
-// iPhoto2Ansel
-//
-// Created by Michael Rubinsky on 11/5/08.
-// Copyright 2008 __MyCompanyName__. All rights reserved.
-//
-#import <Foundation/Foundation.h>
-#import <XMLRPC/XMLRPC.h>
-#import "TURXMLConnection.h"
-
-@implementation TURXMLConnection
-
-static NSString *ERR_DOMAIN = @"com.theupstairsroom.XMLConnection";
-
-- (TURXMLConnection *)initWithXMLRPCRequest: (XMLRPCRequest *)request
- withCredentials: (NSDictionary *)credentials
-{
- username = [[credentials objectForKey:@"username"] retain];
- password = [[credentials objectForKey:@"password"] retain];
- running = YES;
- connection = [[XMLRPCConnection alloc] initWithXMLRPCRequest: request
- delegate: self];
- return self;
-}
-
-- (BOOL)isRunning
-{
- return running;
-}
-
-- (id)response
-{
- return response;
-}
-
-- (void)dealloc
-{
- NSLog(@"TURXMLConnection dealloc called");
- [username release];
- [password release];
- [super dealloc];
-}
-
-- (BOOL)hasError
-{
- return hasError;
-}
-
-// Return the error object, but get rid of it.
-- (NSError *)error
-{
- return [error autorelease];
-}
-
-#pragma mark XMLRPCConnection Delegate
-- (void)connection: (XMLRPCConnection *)xconnection
-didReceiveResponse: (XMLRPCResponse *)theResponse
- forMethod: (NSString *)method
-{
- NSLog(@"Received response for %@", method);
- if (theResponse != nil) {
- if ([theResponse isFault]) {
- NSLog(@"Fault code: %@", [theResponse faultCode]);
- NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
- [theResponse faultString], @"NSLocalizedDescriptionKey", nil];
- error = [[NSError alloc] initWithDomain: ERR_DOMAIN
- code: [[theResponse faultCode] intValue]
- userInfo: userInfo];
- hasError = YES;
- [theResponse release];
- [xconnection cancel];
- }
- } else {
- NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
- @"Unable to parse XML in XMLRPCDelegate method", @"NSLocalizedDescriptionKey", nil];
- error = [[NSError alloc] initWithDomain: ERR_DOMAIN
- code: TURXML_ERR_PARSE
- userInfo: userInfo];
- hasError = YES;
- [theResponse release];
- }
-
- response = [[theResponse responseObject] retain];
- [theResponse release];
- if (!hasError) {
- // Looks like the NSURLConnection object is released somewhere upstream
- // when there is an error.
- [xconnection release];
- }
- running = NO;
-}
-
-- (void)connection: (XMLRPCConnection *)xconnection
-didReceiveAuthenticationChallenge: (NSURLAuthenticationChallenge *)challenge
- forMethod: (NSString *)method
-{
- NSLog(@"Credentials requested in method: %@", method);
- if ([challenge previousFailureCount] == 0) {
- NSURLCredential *newCredential;
- newCredential = [NSURLCredential credentialWithUser: [self valueForKey: @"username"]
- password: [self valueForKey: @"password"]
- persistence: NSURLCredentialPersistenceForSession];
-
- [[challenge sender] useCredential: newCredential
- forAuthenticationChallenge: challenge];
- NSLog(@"Credentials sent %@", newCredential);
- } else {
- [[challenge sender] cancelAuthenticationChallenge: challenge];
- NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
- @"Authentication Failed", @"NSLocalizedDescriptionKey",
- @"Check your username and password and try again.", @"NSLocalizedRecoverySuggestionErrorKey", nil];
-
- error = [[NSError alloc] initWithDomain: ERR_DOMAIN
- code: TURXML_ERR_BADAUTH
- userInfo: userInfo];
- running = NO;
- hasError = YES;
- }
-}
-
-- (void)connection: (XMLRPCConnection *)xconnection
- didFailWithError: (NSError *)xerror
- forMethod: (NSString *)method
-{
- error = [xerror retain];
- hasError = YES;
- running = NO;
-}
-
-// Set the status and tell the underlaying connection we cancelled.
-- (void) cancel
-{
- running = NO;
- hasError = YES;
- error = [[NSError alloc] initWithDomain: ERR_DOMAIN
- code: TURXML_ERR_CANCEL
- userInfo: nil];
- [super cancel];
-}
-
-@end
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CFBundleDevelopmentRegion</key>
- <string>English</string>
- <key>CFBundleExecutable</key>
- <string>${EXECUTABLE_NAME}</string>
- <key>CFBundleIdentifier</key>
- <string>com.yourcompany.${PRODUCT_NAME:identifier}</string>
- <key>CFBundleInfoDictionaryVersion</key>
- <string>6.0</string>
- <key>CFBundlePackageType</key>
- <string>FMWK</string>
- <key>CFBundleSignature</key>
- <string>????</string>
- <key>CFBundleVersion</key>
- <string>1.0</string>
-</dict>
-</plist>
+++ /dev/null
-//
-// Copyright 2008 Eric Czarny <eczarny@gmail.com>
-//
-// 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
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// 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 <Foundation/NSData.h>
-
-@class NSString;
-
-@interface NSData (NSDataAdditions)
-
-+ (NSData *)base64DataFromString: (NSString *)string;
-
-@end
+++ /dev/null
-//
-// Copyright 2008 Eric Czarny <eczarny@gmail.com>
-//
-// 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
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// 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"
-
-@implementation NSData (NSDataAdditions)
-
-+ (NSData *)base64DataFromString: (NSString *)string {
- unsigned long ixtext, lentext;
- unsigned char ch, input[4], output[3];
- short i, ixinput;
- 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')) {
- ch = ch - 'a' + 26;
- } else if ((ch >= '0') && (ch <= '9')) {
- ch = ch - '0' + 52;
- } else if (ch == '+') {
- ch = 62;
- } else if (ch == '=') {
- flendtext = true;
- } else if (ch == '/') {
- ch = 63;
- } else {
- 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;
-}
-
-@end
+++ /dev/null
-//
-// Copyright 2008 Eric Czarny <eczarny@gmail.com>
-//
-// 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
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// 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 <Foundation/NSString.h>
-
-@class NSData;
-
-@interface NSString (NSStringAdditions)
-
-+ (NSString *)base64StringFromData: (NSData *)data length: (NSInteger)length;
-
-@end
+++ /dev/null
-//
-// Copyright 2008 Eric Czarny <eczarny@gmail.com>
-//
-// 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
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// 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"
-
-/* Base64 Encoding Table */
-static char base64EncodingTable[64] = {
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
- 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
- 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
- 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
-};
-
-@implementation NSString (NSStringExtensions)
-
-+ (NSString *)base64StringFromData: (NSData *)data length: (NSInteger)length {
- unsigned long ixtext, lentext;
- long ctremaining;
- unsigned char input[3], output[4];
- 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;
-
- while (true) {
- ctremaining = lentext - ixtext;
-
- if (ctremaining <= 0) {
- break;
- }
-
- 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;
- break;
- 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;
-}
-
-@end
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
- "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
- <dict>
- <key>CFBundleDevelopmentRegion</key>
- <string>English</string>
- <key>CFBundleExecutable</key>
- <string>${EXECUTABLE_NAME}</string>
- <key>CFBundleIconFile</key>
- <string></string>
- <key>CFBundleIdentifier</key>
- <string>com.divisiblebyzero.XMLRPC</string>
- <key>CFBundleInfoDictionaryVersion</key>
- <string>6.0</string>
- <key>CFBundleName</key>
- <string>${PRODUCT_NAME}</string>
- <key>CFBundlePackageType</key>
- <string>FMWK</string>
- <key>CFBundleSignature</key>
- <string>ZERO</string>
- <key>CFBundleVersion</key>
- <string>1.5.1</string>
- <key>NSPrincipalClass</key>
- <string></string>
- </dict>
-</plist>
+++ /dev/null
-== License
-
-= The Cocoa XML-RPC Framework is distributed under the MIT License:
-
-Copyright 2008 Eric Czarny <eczarny@gmail.com>
-
-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
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-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.
+++ /dev/null
-/* ENGLISH */
-
-NSHumanReadableCopyright = "Cocoa XML-RPC Framework © 2008 Divisible by Zero";
+++ /dev/null
-== The Cocoa XML-RPC Framework
-
-The Cocoa XML-RPC Framework is a simple, and lightweight, XML-RPC client
-framework written in Objective-C.
-
-== Requirements
-
-The Cocoa XML-RPC Framework has been built, and designed, for OS X 10.4 or
-later. The framework relies on NSURLConnection and NSURLRequest for HTTP
-transport, and NSXMLDocument for parsing XML-RPC responses.
-
-This version of the framework will not work with the iPhone SDK.
-
-== Usage
-
-The following examples of the Cocoa XML-RPC Framework assume that the included
-XML-RPC test server are running. The test server can be found under:
-
- XMLRPC\Tools\xmlrpc-server
-
-The XML-RPC test server is written in Java and utilizes the Apache XML-RPC
-server library. To start the server simply call Ant from the same directory
-where the build.xml file is located:
-
- ant <target>
-
-The target is optional, omitting this argument will execute the default
-target (the default target is "run"). The following targets are available:
-
- - compile
- - jar
- - run
- - clean
-
-More information on the XML-RPC test server can be found below.
-
-= Asynchronous
-
-Making an asynchronous XML-RPC request is probably the best way to communicate
-with an XML-RPC server. After creating an XMLRPCConnection the XML-RPC request
-is sent to the XML-RPC server in the background. This allows the requesting
-application to continue performing other functions.
-
-Sending an asynchronous XML-RPC request is simple:
-
-- (void)sendRequest {
- NSURL *URL = [NSURL URLWithString: @"http://127.0.0.1/"];
- XMLRPCRequest *request = [[XMLRPCRequest alloc] initWithHost: URL];
-
- [request setMethod: @"Echo.echo" withParameter: @"Hello World!"];
- [request setUserAgent: @"XML-RPC Example"];
-
- XMLRPCConnection *connection = [[XMLRPCConnection alloc]
- initWithXMLRPCRequest: request delegate: self];
-
- if (connection == nil) {
- NSLog(@"Connection failed.");
- }
-}
-
-It is important to understand that the caller is responsible for releasing the
-connection and response objects at the end of the connection response and
-connection failure delegate methods. Do not attempt to release the connection
-object anywhere but within these two delegate methods.
-
-- (void)connection: (XMLRPCConnection *)connection didReceiveResponse:
- (XMLRPCResponse *)response forMethod: (NSString *)method {
- if (response != nil) {
- if ([response isFault]) {
- NSLog(@"Fault code: %@", [response faultCode]);
- } else {
- NSLog(@"Response object: %@", [response responseObject]);
- }
-
- NSLog(@"Response source: %@", [response responseSourceXML]);
- } else {
- NSLog(@"Unable to parse response.");
- }
-
- [response release];
- [connection release];
-}
-
-= Synchronous
-
-Synchronous XML-RPC requests may be suitable in some situations. Unlike sending
-an asynchronous request, a synchronous request is made in the foreground causing
-the calling application to await an XML-RPC response.
-
-- (void)sendRequest {
- NSURL *URL = [NSURL URLWithString: @"http://127.0.0.1/"];
- XMLRPCRequest *request = [[[XMLRPCRequest alloc] initWithHost: URL]];
-
- [request setMethod: @"Echo.echo" setParameter: @"Hello World!"];
- [request setUserAgent: @"XML-RPC Example"];
-
- XMLRPCResponse *response = [XMLRPCConnection
- sendSynchronousXMLRPCRequest: request];
-
- if (response != nil) {
- if ([response isFault]) {
- NSLog(@"Fault: %@", [response fault]);
- } else {
- NSLog(@"Response object: %@", [response responseObject]);
- }
-
- NSLog(@"Response source: %@", [response responseSourceXML]);
- } else {
- NSLog(@"Unable to parse response.");
- }
-
- [request release];
- [response release];
-}
-
-A response will always return nil upon creation if it is unable to parse the XML
-data. However, in the case of a synchronous request, a nil response can either
-mean the response could not be parsed, or the connection failed to send the
-request.
-
-An asynchronous connection will return nil if it fails to send the request. The
-response passed to the connection:didReceiveResponse:forMethod: delegate
-method will be nil if the response object is unable to parse the XML response
-data.
-
-Also note that you may have access to the raw XML source to either the request
-and/or response. Though you may be able to extract the source from the request
-at any moment in the object's life, it is always best to get the source after
-invoking the setMethod:withParameters: or setMethod:withParameter: methods. If
-you ask for the source too early, you won't receive the fully created XML
-request source.
-
-== Using the XML-RPC test server
-
-The XML-RPC test server is a simple Java application that allows developers to
-easily develop software with Cocoa XML-RPC Framework. The test server is built
-on top of the Apache XML-RPC library.
-
-Using the test server is easy, simply call Ant from the same location as the
-build.xml file:
-
- ant
-
-The default target is the "run" target, which will compile the Java source code,
-build the executable JAR file, and run the application. Included with the test
-server is a server.sh script, this Bash script will launch the test server (if
-it has already been built with Ant).
-
-= Creating XML-RPC server handlers
-
-The XML-RPC test server exposes the methods defined in server handlers. Each
-server handler is simply a Java class that is registered with the Apache XML-RPC
-library. Here is an example of the Echo handler provided in the distribution:
-
- public class Echo {
- public String echo(String message) {
- return message;
- }
- }
-
-This handler simply takes a message provided in the XML-RPC request and returns
-it in the XML-RPC response. To register this handler with the XML-RPC server
-simply add it to the propertyHandlerMapping in Server.java:
-
- import com.divisiblebyzero.xmlrpc.model.handlers.*;
-
- ...
-
- try {
- propertyHandlerMapping.addHandler("Echo", Echo.class);
-
- this.embeddedXmlRpcServer.setHandlerMapping(propertyHandlerMapping);
- } catch (Exception e) {
- this.controlPanel.addLogMessage(e.getMessage());
- }
-
-The handler is now available to any incoming XML-RPC requests.
-
-== What if I find a bug, or what if I want to help?
-
-Please, contact me with any questions, comments, suggestions, or problems. I try
-to make the time to answer every request. If you find a bug, it would be
-helpful to also provide steps to reproduce the problem.
-
-Those wishing to contribute to the project should begin by obtaining a working
-copy of the trunk:
-
- svn co http://svn.divisiblebyzero.com/xmlrpc/trunk/
-
-The trunk contains the most recent changes to the project. The modifications you
-make should then be used to create a patch. Patches should be sent to me with a
-detailed description of every change.
-
-== Acknowledgments
-
-The Base64 encoder/decoder found in NSStringAdditions and NSDataAdditions have
-been adapted from code provided by Dave Winer.
-
-The idea for this framework came from examples provided by Brent Simmons, the
-creator of NetNewsWire.
-
-== License
-
-Copyright 2008 Eric Czarny.
-
-The Cocoa XML-RPC Framework should be accompanied by a LICENSE file, this
-file contains the license relevant to this distribution. If no LICENSE exists
-please contact Eric Czarny <eczarny@gmail.com>.
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CFBundleDevelopmentRegion</key>
- <string>English</string>
- <key>CFBundleExecutable</key>
- <string>${EXECUTABLE_NAME}</string>
- <key>CFBundleIdentifier</key>
- <string>com.yourcompany.XMLRPC</string>
- <key>CFBundleInfoDictionaryVersion</key>
- <string>6.0</string>
- <key>CFBundlePackageType</key>
- <string>FMWK</string>
- <key>CFBundleSignature</key>
- <string>????</string>
- <key>CFBundleVersion</key>
- <string>1.0</string>
-</dict>
-</plist>
+++ /dev/null
-//
-// Copyright 2008 Eric Czarny <eczarny@gmail.com>
-//
-// 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
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// 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
-// XMLRPC.h
-//
-// Created by Eric Czarny on Wednesday, February 10, 2004.
-// Copyright 2008 Divisible by Zero.
-//
-
-#import <XMLRPC/XMLRPCConnection.h>
-#import <XMLRPC/XMLRPCRequest.h>
-#import <XMLRPC/XMLRPCResponse.h>
+++ /dev/null
-//
-// Copyright 2008 Eric Czarny <eczarny@gmail.com>
-//
-// 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
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// 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
-// XMLRPC.pch
-//
-// Created by Eric Czarny on Wednesday, January 14, 2004.
-// Copyright 2008 Divisible by Zero.
-//
-
-#ifdef __OBJC__
- #import <Foundation/Foundation.h>
-#endif
+++ /dev/null
-//
-// Copyright 2008 Eric Czarny <eczarny@gmail.com>
-//
-// 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
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// 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
-// XMLRPCConnection.h
-//
-// Created by Eric Czarny on Thursday, January 15, 2004.
-// Copyright 2008 Divisible by Zero.
-//
-
-#import <Foundation/Foundation.h>
-
-@class XMLRPCRequest, XMLRPCResponse;
-
-/* XML-RPC Connection Notifications */
-extern NSString *XMLRPCSentRequestNotification;
-extern NSString *XMLRPCRequestFailedNotification;
-extern NSString *XMLRPCReceivedAuthenticationChallengeNotification;
-extern NSString *XMLRPCCancelledAuthenticationChallengeNotification;
-extern NSString *XMLRPCReceivedResponseNotification;
-
-@interface XMLRPCConnection : NSObject {
- NSURLConnection *currentConnection;
- NSString *currentXMLRPCMethod;
- NSMutableData *incomingXMLData;
- id applicationDelegate;
-}
-
-- (id)initWithXMLRPCRequest: (XMLRPCRequest *)request delegate: (id)delegate;
-
-#pragma mark -
-
-+ (XMLRPCResponse *)sendSynchronousXMLRPCRequest: (XMLRPCRequest *)request;
-
-#pragma mark -
-
-- (void)cancel;
-
-@end
-
-#pragma mark -
-
-@interface NSObject (XMLRPCConnectionDelegate)
-
-- (void)connection: (XMLRPCConnection *)connection didReceiveResponse: (XMLRPCResponse *)response forMethod: (NSString *)method;
-
-- (void)connection: (XMLRPCConnection *)connection didFailWithError: (NSError *)error forMethod: (NSString *)method;
-
-- (void)connection: (XMLRPCConnection *)connection didReceiveAuthenticationChallenge: (NSURLAuthenticationChallenge *)challenge forMethod: (NSString *)method;
-
-- (void)connection: (XMLRPCConnection *)connection didCancelAuthenticationChallenge: (NSURLAuthenticationChallenge *)challenge forMethod: (NSString *)method;
-
-@end
+++ /dev/null
-//
-// Copyright 2008 Eric Czarny <eczarny@gmail.com>
-//
-// 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
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// 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
-// XMLRPCConnection.m
-//
-// Created by Eric Czarny on Thursday, January 15, 2004.
-// Copyright 2008 Divisible by Zero.
-//
-
-#import "XMLRPCConnection.h"
-#import "XMLRPCRequest.h"
-#import "XMLRPCResponse.h"
-
-NSString *XMLRPCSentRequestNotification = @"XML-RPC Sent Request";
-NSString *XMLRPCRequestFailedNotification = @"XML-RPC Failed Receiving Response";
-NSString *XMLRPCReceivedAuthenticationChallengeNotification = @"XML-RPC Received Authentication Challenge";
-NSString *XMLRPCCancelledAuthenticationChallengeNotification = @"XML-RPC Cancelled Authentication Challenge";
-NSString *XMLRPCReceivedResponseNotification = @"XML-RPC Successfully Received Response";
-
-@interface XMLRPCConnection (XMLRPCConnectionPrivate)
-
-- (void)connection: (NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response;
-
-- (void)connection: (NSURLConnection *)connection didReceiveData: (NSData *)data;
-
-- (void)connection: (NSURLConnection *)connection didFailWithError: (NSError *)error;
-
-- (void)connection: (NSURLConnection *)connection didReceiveAuthenticationChallenge: (NSURLAuthenticationChallenge *)challenge;
-
-- (void)connection: (NSURLConnection *)connection didCancelAuthenticationChallenge: (NSURLAuthenticationChallenge *)challenge;
-
-- (void)connectionDidFinishLoading: (NSURLConnection *)connection;
-
-@end
-
-#pragma mark -
-
-@implementation XMLRPCConnection
-
-- (id)initWithXMLRPCRequest: (XMLRPCRequest *)request delegate: (id)delegate {
- if (self = [super init]) {
- [request retain];
- incomingXMLData = [[NSMutableData alloc] init];
- currentConnection = [[NSURLConnection alloc] initWithRequest: [request request] delegate: self];
-
- applicationDelegate = delegate;
-
- if (currentConnection != nil) {
- currentXMLRPCMethod = [[NSString alloc] initWithString: [request method]];
-
- [request release];
-
- [[NSNotificationCenter defaultCenter] postNotificationName: XMLRPCSentRequestNotification object: nil];
- } else {
- if ([applicationDelegate respondsToSelector: @selector(connection:didFailWithError:forMethod:)]) {
- [applicationDelegate connection: self didFailWithError: nil forMethod: [request method]];
- }
-
- [request release];
-
- return nil;
- }
- }
-
- return self;
-}
-
-#pragma mark -
-
-+ (XMLRPCResponse *)sendSynchronousXMLRPCRequest: (XMLRPCRequest *)request {
- NSData *data = [[[NSURLConnection sendSynchronousRequest: [request request]
- returningResponse: nil error: nil] retain] autorelease];
-
- [request release];
-
- if (data != nil) {
- return [[[XMLRPCResponse alloc] initWithData: data] autorelease];
- }
-
- return nil;
-}
-
-#pragma mark -
-
-- (void)cancel {
- [currentConnection cancel];
-
- [currentConnection release];
-}
-
-#pragma mark -
-
-- (void)dealloc {
- [currentXMLRPCMethod release];
- [incomingXMLData release];
- NSLog(@"XMLRPCConnection being released");
- [super dealloc];
-}
-
-@end
-
-#pragma mark -
-
-@implementation XMLRPCConnection (XMLRPCConnectionPrivate)
-
-- (void)connection: (NSURLConnection *)connection didReceiveResponse: (NSURLResponse *)response {
- if([response respondsToSelector: @selector(statusCode)]) {
- NSInteger statusCode = [(NSHTTPURLResponse *)response statusCode];
-
- if(statusCode >= 400) {
- [connection cancel];
-
- if ([applicationDelegate respondsToSelector: @selector(connection:didFailWithError:forMethod:)]) {
- NSError *error = [NSError errorWithDomain: NSCocoaErrorDomain code: statusCode userInfo: nil];
-
- [applicationDelegate connection: self didFailWithError: error forMethod: currentXMLRPCMethod];
- }
-
- [connection release];
- }
- }
-
- [incomingXMLData setLength: 0];
-}
-
-- (void)connection: (NSURLConnection *)connection didReceiveData: (NSData *)data {
- [incomingXMLData appendData: data];
-}
-
-- (void)connection: (NSURLConnection *)connection didFailWithError: (NSError *)error {
- if ([applicationDelegate respondsToSelector: @selector(connection:didFailWithError:forMethod:)]) {
- [applicationDelegate connection: self didFailWithError: error forMethod: currentXMLRPCMethod];
- }
-
- [[NSNotificationCenter defaultCenter] postNotificationName: XMLRPCRequestFailedNotification object: nil];
-
- [connection release];
-}
-
-- (void)connection: (NSURLConnection *)connection didReceiveAuthenticationChallenge: (NSURLAuthenticationChallenge *)challenge {
- if ([applicationDelegate respondsToSelector: @selector(connection:didReceiveAuthenticationChallenge:forMethod:)]) {
- [applicationDelegate connection: self didReceiveAuthenticationChallenge: challenge forMethod: currentXMLRPCMethod];
- }
-
- [[NSNotificationCenter defaultCenter] postNotificationName: XMLRPCReceivedAuthenticationChallengeNotification object: nil];
-}
-
-- (void)connection: (NSURLConnection *)connection didCancelAuthenticationChallenge: (NSURLAuthenticationChallenge *)challenge {
- if ([applicationDelegate respondsToSelector: @selector(connection:didCancelAuthenticationChallenge:forMethod:)]) {
- [applicationDelegate connection: self didCancelAuthenticationChallenge: challenge forMethod: currentXMLRPCMethod];
- }
-
- [[NSNotificationCenter defaultCenter] postNotificationName: XMLRPCCancelledAuthenticationChallengeNotification object: nil];
-}
-
-- (void)connectionDidFinishLoading: (NSURLConnection *)connection {
- XMLRPCResponse *response = [[XMLRPCResponse alloc] initWithData: incomingXMLData];
-
- if ([applicationDelegate respondsToSelector: @selector(connection:didReceiveResponse:forMethod:)]) {
- [applicationDelegate connection: self didReceiveResponse: response forMethod: currentXMLRPCMethod];
- }
-
- [[NSNotificationCenter defaultCenter] postNotificationName: XMLRPCReceivedResponseNotification object: nil];
-
- [connection release];
-}
-
-@end
+++ /dev/null
-//
-// Copyright 2008 Eric Czarny <eczarny@gmail.com>
-//
-// 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
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// 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
-// XMLRPCDecoder.h
-//
-// Created by Eric Czarny on Wednesday, January 14, 2004.
-// Copyright 2008 Divisible by Zero.
-//
-
-#import <Foundation/Foundation.h>
-
-@interface XMLRPCDecoder : NSObject {
- NSXMLDocument *responseXMLDocument;
- BOOL isFault;
-}
-
-- (id)initWithData: (NSData *)data;
-
-#pragma mark -
-
-- (id)decode;
-
-#pragma mark -
-
-- (BOOL)isFault;
-
-@end
+++ /dev/null
-//
-// Copyright 2008 Eric Czarny <eczarny@gmail.com>
-//
-// 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
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// 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
-// XMLRPCDecoder.m
-//
-// Created by Eric Czarny on Wednesday, January 14, 2004.
-// Copyright 2008 Divisible by Zero.
-//
-
-#import "XMLRPCDecoder.h"
-#import "NSDataAdditions.h"
-
-@interface XMLRPCDecoder (XMLRPCDecoderPrivate)
-
-- (NSXMLElement *)getChildFromElement: (NSXMLElement *)element withName: (NSString *)name;
-
-#pragma mark -
-
-- (id)decodeObject: (NSXMLElement *)element;
-
-- (id)trueDecodeObject: (NSXMLElement *)element;
-
-#pragma mark -
-
-- (NSArray *)decodeArray: (NSXMLElement *)element;
-
-#pragma mark -
-
-- (NSDictionary *)decodeDictionary: (NSXMLElement *)element;
-
-#pragma mark -
-
-- (NSNumber *)decodeNumber: (NSXMLElement *)element isDouble: (BOOL)flag;
-
-- (CFBooleanRef)decodeBool: (NSXMLElement *)element;
-
-- (NSString *)decodeString: (NSXMLElement *)element;
-
-- (NSDate *)decodeDate: (NSXMLElement *)element;
-
-- (NSData *)decodeData: (NSXMLElement *)element;
-
-@end
-
-#pragma mark -
-
-@implementation XMLRPCDecoder
-
-- (id)initWithData: (NSData *)data {
- if (data == nil) {
- return nil;
- }
-
- if (self = [super init]) {
- NSError *error = nil;
- responseXMLDocument = [[NSXMLDocument alloc] initWithData: data options: NSXMLDocumentTidyXML error: &error];
-
- if (responseXMLDocument == nil) {
- if (error) {
- NSLog(@"Encountered an XML error: %@", error);
- }
-
- return nil;
- }
-
- if (error) {
- NSLog(@"Encountered an XML error: %@", error);
-
- return nil;
- }
- }
-
- return self;
-}
-
-#pragma mark -
-
-- (id)decode {
- NSXMLElement *child, *root = [responseXMLDocument rootElement];
-
- if (root == nil) {
- return nil;
- }
-
- child = [self getChildFromElement: root withName: @"params"];
-
- if (child != nil) {
- child = [self getChildFromElement: child withName: @"param"];
-
- if (child == nil) {
- return nil;
- }
-
- child = [self getChildFromElement: child withName: @"value"];
-
- if (child == nil) {
- return nil;
- }
- } else {
- child = [self getChildFromElement: root withName: @"fault"];
-
- if (child == nil) {
- return nil;
- }
-
- child = [self getChildFromElement: child withName: @"value"];
-
- if (child == nil) {
- return nil;
- }
-
- isFault = YES;
- }
-
- return [self decodeObject: child];
-}
-
-#pragma mark -
-
-- (BOOL)isFault {
- return isFault;
-}
-
-#pragma mark -
-
-- (void)dealloc {
- [responseXMLDocument release];
-
- [super dealloc];
-}
-
-@end
-
-#pragma mark -
-
-@implementation XMLRPCDecoder (XMLRPCDecoderPrivate)
-
-- (NSXMLElement *)getChildFromElement: (NSXMLElement *)element withName: (NSString *)name {
- NSArray *children = [element elementsForName: name];
-
- if ([children count] > 0) {
- return [children objectAtIndex: 0];
- }
-
- return nil;
-}
-
-#pragma mark -
-
-- (id)decodeObject: (NSXMLElement *)element {
- NSXMLElement *child = (NSXMLElement *)[element childAtIndex: 0];
-
- if (child != nil) {
- return [self trueDecodeObject: child];
- }
-
- return nil;
-}
-
-- (id)trueDecodeObject: (NSXMLElement *)element {
- NSString *name = [element name];
-
- if ([name isEqualToString: @"array"]) {
- return [self decodeArray: element];
- } else if ([name isEqualToString: @"struct"]) {
- return [self decodeDictionary: element];
- } else if ([name isEqualToString: @"int"] || [name isEqualToString: @"i4"]) {
- return [self decodeNumber: element isDouble: NO];
- } else if ([name isEqualToString: @"double"]) {
- return [self decodeNumber: element isDouble: YES];
- } else if ([name isEqualToString: @"boolean"]) {
- return (id)[self decodeBool: element];
- } else if ([name isEqualToString: @"string"]) {
- return [self decodeString: element];
- } else if ([name isEqualToString: @"dateTime.iso8601"]) {
- return [self decodeDate: element];
- } else if ([name isEqualToString: @"base64"]) {
- return [self decodeData: element];
- } else {
- return [self decodeString: element];
- }
-
- return nil;
-}
-
-#pragma mark -
-
-- (NSArray *)decodeArray: (NSXMLElement *)element {
- NSXMLElement *parent = [self getChildFromElement: element withName: @"data"];
- NSMutableArray *array = [NSMutableArray array];
- NSInteger index;
-
- if (parent == nil) {
- return nil;
- }
-
- for (index = 0; index < [parent childCount]; index++) {
- NSXMLElement *child = (NSXMLElement *)[parent childAtIndex: index];
-
- if (![[child name] isEqualToString: @"value"]) {
- continue;
- }
-
- id value = [self decodeObject: child];
-
- if (value != nil) {
- [array addObject: value];
- }
- }
-
- return (NSArray *)array;
-}
-
-#pragma mark -
-
-- (NSDictionary *)decodeDictionary: (NSXMLElement *)element {
- NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
- NSInteger index;
-
- for (index = 0; index < [element childCount]; index++) {
- NSXMLElement *child, *parent = (NSXMLElement *)[element childAtIndex: index];
-
- if (![[parent name] isEqualToString: @"member"]) {
- continue;
- }
-
- child = [self getChildFromElement: parent withName: @"name"];
-
- if (child == nil) {
- continue;
- }
-
- NSString *key = [child stringValue];
-
- child = [self getChildFromElement: parent withName: @"value"];
-
- if (child == nil) {
- continue;
- }
-
- id object = [self decodeObject: child];
-
- if ((object != nil) && (key != nil) && ![key isEqualToString: @""]) {
- [dictionary setObject: object forKey: key];
- }
- }
-
- return (NSDictionary *)dictionary;
-}
-
-#pragma mark -
-
-- (NSNumber *)decodeNumber: (NSXMLElement *)element isDouble: (BOOL)flag {
- if (flag) {
- return [NSNumber numberWithDouble: [[element stringValue] intValue]];
- }
-
- return [NSNumber numberWithInt: [[element stringValue] intValue]];
-}
-
-- (CFBooleanRef)decodeBool: (NSXMLElement *)element {
- if ([[element stringValue] isEqualToString: @"1"]) {
- return kCFBooleanTrue;
- }
-
- return kCFBooleanFalse;
-}
-
-- (NSString *)decodeString: (NSXMLElement *)element {
- return [element stringValue];
-}
-
-- (NSDate *)decodeDate: (NSXMLElement *)element {
- NSCalendarDate *date = [NSCalendarDate dateWithString: [element stringValue]
- calendarFormat: @"%Y%m%dT%H:%M:%S" locale: nil];
-
- return date;
-}
-
-- (NSData *)decodeData: (NSXMLElement *)element {
- return [NSData base64DataFromString: [element stringValue]];
-}
-
-@end
+++ /dev/null
-//
-// Copyright 2008 Eric Czarny <eczarny@gmail.com>
-//
-// 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
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// 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
-// XMLRPCEncoder.h
-//
-// Created by Eric Czarny on Wednesday, January 14, 2004.
-// Copyright 2008 Divisible by Zero.
-//
-
-#import <Foundation/Foundation.h>
-
-@interface XMLRPCEncoder : NSObject {
- NSString *currentXMLRPCMethod, *encoderSourceXML;
- NSArray *currentXMLRPCParameters;
-}
-
-- (NSString *)encode;
-
-#pragma mark -
-
-- (void)setMethod: (NSString *)method withParameters: (NSArray *)parameters;
-
-#pragma mark -
-
-- (NSString *)method;
-- (NSArray *)parameters;
-
-#pragma mark -
-
-- (NSString *)encoderSourceXML;
-
-@end
+++ /dev/null
-//
-// Copyright 2008 Eric Czarny <eczarny@gmail.com>
-//
-// 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
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// 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
-// XMLRPCEncoder.m
-//
-// Created by Eric Czarny on Wednesday, January 14, 2004.
-// Copyright 2008 Divisible by Zero.
-//
-
-#import "XMLRPCEncoder.h"
-#import "NSStringAdditions.h"
-
-@interface XMLRPCEncoder (XMLRPCEncoderPrivate)
-
-- (NSString *)valueTag: (NSString *)tag value: (NSString *)value;
-
-#pragma mark -
-
-- (NSString *)replaceTarget: (NSString *)target withValue: (NSString *)value inString: (NSString *)string;
-
-- (NSString *)escapeValue: (NSString *)value;
-
-#pragma mark -
-
-- (NSString *)encodeObject: (id)object;
-
-#pragma mark -
-
-- (NSString *)encodeArray: (NSArray *)array;
-
-- (NSString *)encodeDictionary: (NSDictionary *)dictionary;
-
-#pragma mark -
-
-- (NSString *)encodeBoolean: (CFBooleanRef)boolean;
-
-- (NSString *)encodeNumber: (NSNumber *)number;
-
-- (NSString *)encodeString: (NSString *)string;
-
-- (NSString *)encodeDate: (NSDate *)date;
-
-- (NSString *)encodeData: (NSData *)data;
-
-@end
-
-#pragma mark -
-
-@implementation XMLRPCEncoder
-
-- (id)init {
- if (self = [super init]) {
- currentXMLRPCMethod = [[NSString alloc] init];
- encoderSourceXML = [[NSString alloc] init];
- currentXMLRPCParameters = [[NSArray alloc] init];
- }
-
- return self;
-}
-
-#pragma mark -
-
-- (NSString *)encode {
- NSMutableString *buffer = [NSMutableString stringWithString: @"<?xml version=\"1.0\"?><methodCall>"];
-
- [buffer appendFormat: @"<methodName>%@</methodName>", currentXMLRPCMethod];
-
- [buffer appendString: @"<params>"];
-
- if (currentXMLRPCParameters != nil) {
- NSEnumerator *enumerator = [currentXMLRPCParameters objectEnumerator];
- id parameter = nil;
-
- while (parameter = [enumerator nextObject]) {
- [buffer appendString: @"<param>"];
- [buffer appendString: [self encodeObject: parameter]];
- [buffer appendString: @"</param>"];
- }
- }
-
- [buffer appendString: @"</params>"];
-
- [buffer appendString: @"</methodCall>"];
-
- return buffer;
-}
-
-#pragma mark -
-
-- (void)setMethod: (NSString *)method withParameters: (NSArray *)parameters {
- if (currentXMLRPCMethod != nil) {
- [currentXMLRPCMethod release];
- }
-
- if (method == nil) {
- currentXMLRPCMethod = nil;
- } else {
- currentXMLRPCMethod = [method retain];
- }
-
- if (currentXMLRPCParameters != nil) {
- [currentXMLRPCParameters release];
- }
-
- if (parameters == nil) {
- currentXMLRPCParameters = nil;
- } else {
- currentXMLRPCParameters = [parameters retain];
- }
-}
-
-#pragma mark -
-
-- (NSString *)method {
- return currentXMLRPCMethod;
-}
-
-- (NSArray *)parameters {
- return currentXMLRPCParameters;
-}
-
-#pragma mark -
-
-- (NSString *)encoderSourceXML {
- if (encoderSourceXML != nil) {
- [encoderSourceXML release];
- }
-
- encoderSourceXML = [[self encode] retain];
-
- return encoderSourceXML;
-}
-
-#pragma mark -
-
-- (void)dealloc {
- [currentXMLRPCMethod release];
- [encoderSourceXML release];
- [currentXMLRPCParameters release];
-
- [super dealloc];
-}
-
-@end
-
-#pragma mark -
-
-@implementation XMLRPCEncoder (XMLRPCEncoderPrivate)
-
-- (NSString *)valueTag: (NSString *)tag value: (NSString *)value {
- return [NSString stringWithFormat: @"<value><%@>%@</%@></value>", tag, [self escapeValue: value], tag];
-}
-
-#pragma mark -
-
-- (NSString *)replaceTarget: (NSString *)target withValue: (NSString *)value inString: (NSString *)string {
- return [[string componentsSeparatedByString: target] componentsJoinedByString: value];
-}
-
-- (NSString *)escapeValue: (NSString *)value {
- value = [self replaceTarget: @"&" withValue: @"&" inString: value];
- value = [self replaceTarget: @"<" withValue: @"<" inString: value];
-
- return value;
-}
-
-#pragma mark -
-
-- (NSString *)encodeObject: (id)object {
- if (object == nil) {
- return nil;
- }
-
- if ([object isKindOfClass: [NSArray class]]) {
- return [self encodeArray: object];
- } else if ([object isKindOfClass: [NSDictionary class]]) {
- return [self encodeDictionary: object];
- } else if (((CFBooleanRef)object == kCFBooleanTrue) || ((CFBooleanRef)object == kCFBooleanFalse)) {
- return [self encodeBoolean: (CFBooleanRef)object];
- } else if ([object isKindOfClass: [NSNumber class]]) {
- return [self encodeNumber: object];
- } else if ([object isKindOfClass: [NSString class]]) {
- return [self encodeString: object];
- } else if ([object isKindOfClass: [NSDate class]]) {
- return [self encodeDate: object];
- } else if ([object isKindOfClass: [NSData class]]) {
- return [self encodeData: object];
- } else {
- return [self encodeString: object];
- }
-}
-
-#pragma mark -
-
-- (NSString *)encodeArray: (NSArray *)array {
- NSMutableString *buffer = [NSMutableString string];
- NSEnumerator *enumerator = [array objectEnumerator];
-
- [buffer appendString: @"<value><array><data>"];
-
- id object = nil;
-
- while (object = [enumerator nextObject]) {
- [buffer appendString: [self encodeObject: object]];
- }
-
- [buffer appendString: @"</data></array></value>"];
-
- return (NSString *)buffer;
-}
-
-- (NSString *)encodeDictionary: (NSDictionary *)dictionary {
- NSMutableString * buffer = [NSMutableString string];
- NSEnumerator *enumerator = [dictionary keyEnumerator];
-
- [buffer appendString: @"<value><struct>"];
-
- NSString *key = nil;
-
- while (key = [enumerator nextObject]) {
- [buffer appendString: @"<member>"];
- [buffer appendFormat: @"<name>%@</name>", key];
- [buffer appendString: [self encodeObject: [dictionary objectForKey: key]]];
- [buffer appendString: @"</member>"];
- }
-
- [buffer appendString: @"</struct></value>"];
-
- return (NSString *)buffer;
-}
-
-#pragma mark -
-
-- (NSString *)encodeBoolean: (CFBooleanRef)boolean {
- if (boolean == kCFBooleanTrue) {
- return [self valueTag: @"boolean" value: @"1"];
- } else {
- return [self valueTag: @"boolean" value: @"0"];
- }
-}
-
-- (NSString *)encodeNumber: (NSNumber *)number {
- return [self valueTag: @"i4" value: [number stringValue]];
-}
-
-- (NSString *)encodeString: (NSString *)string {
- return [self valueTag: @"string" value: string];
-}
-
-- (NSString *)encodeDate: (NSDate *)date {
- NSString *buffer = [date descriptionWithCalendarFormat: @"%Y%m%dT%H:%M:%S"
- timeZone: nil locale: nil];
-
- return [self valueTag: @"dateTime.iso8601" value: buffer];
-}
-
-- (NSString *)encodeData: (NSData *)data {
- NSString *buffer = [NSString base64StringFromData: data
- length: [data length]];
-
- return [self valueTag: @"base64" value: buffer];
-}
-
-@end
+++ /dev/null
-//
-// Copyright 2008 Eric Czarny <eczarny@gmail.com>
-//
-// 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
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// 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
-// XMLRPCRequest.h
-//
-// Created by Eric Czarny on Wednesday, January 14, 2004.
-// Copyright 2008 Divisible by Zero.
-//
-
-#import <Foundation/Foundation.h>
-
-@class XMLRPCEncoder;
-
-@interface XMLRPCRequest : NSObject {
- NSMutableURLRequest *mutableRequest;
- XMLRPCEncoder *requestXMLEncoder;
-}
-
-- (id)initWithHost: (NSURL *)host;
-
-#pragma mark -
-
-- (void)setHost: (NSURL *)host;
-- (NSURL *)host;
-
-#pragma mark -
-
-- (void)setUserAgent: (NSString *)userAgent;
-- (NSString *)userAgent;
-
-#pragma mark -
-
-- (void)setMethod: (NSString *)method;
-
-- (void)setMethod: (NSString *)method withParameter: (id)parameter;
-
-- (void)setMethod: (NSString *)method withParameters: (NSArray *)parameters;
-
-#pragma mark -
-
-- (NSString *)method;
-- (NSArray *)parameters;
-
-#pragma mark -
-
-- (NSString *)requestSourceXML;
-
-#pragma mark -
-
-- (NSURLRequest *)request;
-
-@end
+++ /dev/null
-//
-// Copyright 2008 Eric Czarny <eczarny@gmail.com>
-//
-// 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
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// 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
-// XMLRPCRequest.m
-//
-// Created by Eric Czarny on Wednesday, January 14, 2004.
-// Copyright 2008 Divisible by Zero.
-//
-
-#import "XMLRPCRequest.h"
-#import "XMLRPCEncoder.h"
-
-@implementation XMLRPCRequest
-
-- (id)initWithHost: (NSURL *)host {
- if (self = [super init]) {
- if (host != nil) {
- mutableRequest = [[NSMutableURLRequest alloc] initWithURL: host];
- } else {
- mutableRequest = [[NSMutableURLRequest alloc] init];
- }
-
- requestXMLEncoder = [[XMLRPCEncoder alloc] init];
- }
-
- return self;
-}
-
-#pragma mark -
-
-- (void)setHost: (NSURL *)host {
- [mutableRequest setURL: host];
-}
-
-- (NSURL *)host {
- return [mutableRequest URL];
-}
-
-#pragma mark -
-
-- (void)setUserAgent: (NSString *)userAgent {
- if ([self userAgent] == nil) {
- [mutableRequest addValue: userAgent forHTTPHeaderField: @"User-Agent"];
- } else {
- [mutableRequest setValue: userAgent forHTTPHeaderField: @"User-Agent"];
- }
-}
-
-- (NSString *)userAgent {
- return [mutableRequest valueForHTTPHeaderField: @"User-Agent"];
-}
-
-#pragma mark -
-
-- (void)setMethod: (NSString *)method {
- [requestXMLEncoder setMethod: method withParameters: nil];
-}
-
-- (void)setMethod: (NSString *)method withParameter: (id)parameter {
- [requestXMLEncoder setMethod: method withParameters: [NSArray arrayWithObject: parameter]];
-}
-
-- (void)setMethod: (NSString *)method withParameters: (NSArray *)parameters {
- [requestXMLEncoder setMethod: method withParameters: parameters];
-}
-
-#pragma mark -
-
-- (NSString *)method {
- return [requestXMLEncoder method];
-}
-
-- (NSArray *)parameters {
- return [requestXMLEncoder parameters];
-}
-
-#pragma mark -
-
-- (NSString *)requestSourceXML {
- return [requestXMLEncoder encoderSourceXML];
-}
-
-#pragma mark -
-
-- (NSURLRequest *)request {
- NSData *request = [[requestXMLEncoder encode] dataUsingEncoding: NSUTF8StringEncoding];
- NSNumber *contentLength = [NSNumber numberWithInt: [request length]];
-
- if (request == nil) {
- return nil;
- }
-
- [mutableRequest setHTTPMethod: @"POST"];
-
- if ([mutableRequest valueForHTTPHeaderField: @"Content-Length"] == nil) {
- [mutableRequest addValue: @"text/xml" forHTTPHeaderField: @"Content-Type"];
- } else {
- [mutableRequest setValue: @"text/xml" forHTTPHeaderField: @"Content-Type"];
- }
-
- if ([mutableRequest valueForHTTPHeaderField: @"Content-Length"] == nil) {
- [mutableRequest addValue: [contentLength stringValue] forHTTPHeaderField: @"Content-Length"];
- } else {
- [mutableRequest setValue: [contentLength stringValue] forHTTPHeaderField: @"Content-Length"];
- }
-
- [mutableRequest setHTTPBody: request];
-
- return (NSURLRequest *)mutableRequest;
-}
-
-#pragma mark -
-
-- (void)dealloc {
- [mutableRequest release];
- [requestXMLEncoder release];
-
- [super dealloc];
-}
-
-@end
+++ /dev/null
-//
-// Copyright 2008 Eric Czarny <eczarny@gmail.com>
-//
-// 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
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// 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
-// XMLRPCResponse.h
-//
-// Created by Eric Czarny on Wednesday, January 14, 2004.
-// Copyright 2008 Divisible by Zero.
-//
-
-#import <Foundation/Foundation.h>
-
-@class XMLRPCDecoder;
-
-@interface XMLRPCResponse : NSObject {
- NSData *responseXMLData;
- NSString *responseSourceXML;
- id responseObject;
- BOOL isFault;
-}
-
-- (id)initWithData: (NSData *)data;
-
-#pragma mark -
-
-- (BOOL)isFault;
-
-- (NSNumber *)faultCode;
-
-- (NSString *)faultString;
-
-#pragma mark -
-
-- (id)responseObject;
-
-#pragma mark -
-
-- (NSString *)responseSourceXML;
-
-@end
+++ /dev/null
-//
-// Copyright 2008 Eric Czarny <eczarny@gmail.com>
-//
-// 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
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// 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
-// XMLRPCResponse.m
-//
-// Created by Eric Czarny on Wednesday, January 14, 2004.
-// Copyright 2008 Divisible by Zero.
-//
-
-#import "XMLRPCResponse.h"
-#import "XMLRPCDecoder.h"
-
-@implementation XMLRPCResponse
-
-- (id)initWithData: (NSData *)data
-{
- if (data == nil) {
- return nil;
- }
-
- if (self = [super init]) {
- XMLRPCDecoder *responseXMLDecoder =[[XMLRPCDecoder alloc] initWithData: data];
-
- if (responseXMLDecoder == nil) {
- return nil;
- }
-
- responseXMLData = [[NSData alloc] initWithData: data];
- responseSourceXML = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
- responseObject = [[responseXMLDecoder decode] retain];
-
- isFault = [responseXMLDecoder isFault];
-
- [responseXMLDecoder release];
- }
-
- return self;
-}
-
-#pragma mark -
-
-- (BOOL)isFault {
- return isFault;
-}
-
-- (NSNumber *)faultCode {
- if (isFault) {
- return [responseObject objectForKey: @"faultCode"];
- }
-
- return nil;
-}
-
-- (NSString *)faultString {
- if (isFault) {
- return [responseObject objectForKey: @"faultString"];
- }
-
- return nil;
-}
-
-#pragma mark -
-
-- (id)responseObject {
- return responseObject;
-}
-
-#pragma mark -
-
-- (NSString *)responseSourceXML {
- return responseSourceXML;
-}
-
-#pragma mark -
-
-- (void)dealloc {
- [responseXMLData release];
- [responseSourceXML release];
- [responseObject release];
-
- [super dealloc];
-}
-
-@end