Connection Kit

Add ftp, sftp, webdav and .mac publishing to your application through a single API.

HOW TO

NB: There is a sample application included that shows you how to interact with the framework.
All the transfer protocols implement the AbstractConnectionProtocol defined below:

@protocol AbstractConnectionProtocol
+ (NSString *)name;
+ (id)connectionToHost:(NSString *)host
				  port:(NSString *)port
			  username:(NSString *)username
			  password:(NSString *)password;
+ (id)connectionWithURL:(NSURL *)url;
+ (id)connectionWithName:(NSString *)name
					host:(NSString *)host
					port:(NSString *)port
				username:(NSString *)username
				password:(NSString *)password;
- (id)initWithHost:(NSString *)host
			  port:(NSString *)port
		  username:(NSString *)username
		  password:(NSString *)password;
- (void)setHost:(NSString *)host;
- (void)setPort:(NSString *)port;
- (void)setUsername:(NSString *)username;
- (void)setPassword:(NSString *)password;

- (NSString *)host;
- (NSString *)port;
- (NSString *)username;
- (NSString *)password;

- (void)setDelegate:(id)delegate;   // we do not retain the delegate

- (id)delegate;
- (void)connect;
- (BOOL)isConnected;

/* disconnect queues a disconnection where as forceDisconnect '

   will terminate at the next available opportunity. */

- (void)disconnect;
- (void)forceDisconnect;

- (void)changeToDirectory:(NSString *)dirPath;
- (NSString *)currentDirectory;

- (NSString *)rootDirectory;
- (void)createDirectory:(NSString *)dirPath;
- (void)createDirectory:(NSString *)dirPath permissions:(unsigned long)permissions;
- (void)setPermissions:(unsigned long)permissions forFile:(NSString *)path;

- (void)rename:(NSString *)fromPath to:(NSString *)toPath;
- (void)deleteFile:(NSString *)path;
- (void)deleteDirectory:(NSString *)dirPath;

- (void)startBulkCommands;
- (void)endBulkCommands;

- (void)uploadFile:(NSString *)localPath;
- (void)uploadFile:(NSString *)localPath toFile:(NSString *)remotePath;
- (void)uploadFile:(NSString *)localPath toFile:(NSString *)remotePath checkRemoteExistence:(BOOL)flag;

- (void)resumeUploadFile:(NSString *)localPath fileOffset:(long long)offset;
- (void)resumeUploadFile:(NSString *)localPath toFile:(NSString *)remotePath fileOffset:(long long)offset;

- (void)uploadFromData:(NSData *)data toFile:(NSString *)remotePath;
- (void)uploadFromData:(NSData *)data toFile:(NSString *)remotePath checkRemoteExistence:(BOOL)flag;

- (void)resumeUploadFromData:(NSData *)data toFile:(NSString *)remotePath fileOffset:(long long)offset;

- (void)downloadFile:(NSString *)remotePath toDirectory:(NSString *)dirPath overwrite:(BOOL)flag;
- (void)resumeDownloadFile:(NSString *)remotePath toDirectory:(NSString *)dirPath fileOffset:(long long)offset;

- (unsigned)numberOfTransfers;
- (void)cancelTransfer;
- (void)cancelAll;
- (void)directoryContents;
- (void)contentsOfDirectory:(NSString *)dirPath;
- (long long)transferSpeed; // bytes/second
- (void)checkExistenceOfPath:(NSString *)path;

@end

There is a helper method that you  can use defined in AbstractConnection that allows the framework to guess the type of connection to make. If you allow your users to specify custom ports, then it is better to not let it guess.

@interface AbstractConnection : NSObject <AbstractConnectionProtocol> 
+ (id)connectionWithName:(NSString *)name
					host:(NSString *)host
					port:(NSString *)port
				username:(NSString *)username
				password:(NSString *)password;
+ (id)connectionWithURL:(NSURL *)url;

// Protocol registration

+ (NSArray *)registeredConnectionTypes;
+ (NSString *)registeredPortForConnectionType:(NSString *)type;

@end

If you are having difficulty integrating it into your application, then your best bet will be to look at the sample application as a reference. If you are still having problems, you can email me, but I don't have much spare time to help.

Copyright 2006 Under The Radar Software. All Rights Reserved.