[Adium-devl] Importer API

Graham Booker gbooker at cod3r.com
Thu Apr 12 16:07:20 UTC 2007


After reading the feedback, I have a new API suggestion.  Let me know  
what you think:

Even though the API asks for the imported accounts and status, the  
importer actually and adds them.  The array is for canceling purposes  
so that the UI can rollback the changes.  Also, I liked Peter's  
suggestion of using a temp dir for the log import, so that is added too.

//Importer's protocol

typedef enum{
	IMPORT_TYPE_ACCOUNTS = 1,
	IMPORT_TYPE_STATUS = 2,
	IMPORT_TYPE_LOGS = 4
} ImportType;

@protocol ClientImporter : <NSObject>

- (id)initWithUIController:(ImportUIController *)importUIController;

/*
  * Import capabilites of this importer
  * @return The items from ImportType that this importer supports,  
ored together.
  */
- (int)importCapabilities;

/*
  * Import the accounts
  * @param err address of an NSError * to store the error, if there  
is one
  * @return if successfull, an NSArray containing the new accounts,  
otherwise nil
  */
- (NSArray *)importAccounts:(NSError **)err;

/*
  * Import the status messages
  * @param err address of an NSError * to store the error, if there  
is one
  * @return if successfull, an NSArray containing the new status  
messages, otherwise nil
  */
- (NSArray *)importStatus:(NSError **)err;

/*
  * Import the logs
  * This operation takes place in another thread, so be aware of  
that.  Shouldn't be an
  * issue with any code design.
  * @param err address of an NSError * to store the error, if there  
is one
  * @param dir temporary directory to store the new logs
  * @return YES if successfull, NO otherwise
  */
- (BOOL)importLogs:(NSError **)err toDirectory:(NSString *)dir;

/*
  * Cancel import of the logs
  * This operation takes place in the main thread.  It is suggested  
that the implementation
  * sets a boolean that the log import selector checks after each  
log.  If set, the log
  * import should return when it can.
  */
- (void)cancelLogImport;

@end

@interface ImporterUI
/*
  * Sets the current progress for a progress bar
  * @param current the log number just imported
  * @param total the total number of logs
  */
- (void)importedLog:(int)current of:(int)total;
@end



- Graham


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://adium.im/pipermail/devel_adium.im/attachments/20070412/a5f58d5e/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1601 bytes
Desc: not available
URL: <http://adium.im/pipermail/devel_adium.im/attachments/20070412/a5f58d5e/attachment.p7s>


More information about the devel mailing list