/**
 * Purple
 */

#import <Cocoa/Cocoa.h>

/*
 * Protocol types.
 * 0 -- AIM
 * 1 -- Facebook
 * 2 -- Gadu-Gadu
 * 3 -- GroupWise
 * 4 -- ICQ
 * 5 -- IRC
 * 6 -- MSN
 * 7 -- MySpaceIM
 * 8 -- QQ
 * 9 -- SIMPLE
 * 10 -- Sametime
 * 11 -- XMPP
 * 12 -- Yahoo
 * 13 -- Yahoo JAPAN
 * 14 -- Zephyr
 */

/**
 * Buddy events.
 */
enum
{
    BUDDY_EVENT_NONE,
    BUDDY_EVENT_SIGNON,
    BUDDY_EVENT_SIGNOFF,
    BUDDY_EVENT_STATUS,
};

@class PurpAccount;

@interface Purple : NSObject {

    /**
     * The run loop.
     */
    CFRunLoopRef _runLoop;
    
    /**
     * The accounts.
     */
    NSMutableDictionary * _accounts;
    
    /**
     * The buddies.
     */
    NSMutableArray * _buddies;
    
    /**
     * The conversations.
     */
    NSMutableArray * _conversations;
}

@property (nonatomic, retain) NSMutableDictionary * accounts;
@property (nonatomic, retain) NSMutableArray * buddies;
@property (nonatomic, retain) NSMutableArray * conversations;

/**
 * Shared class instance.
 */
+ (id)sharedInstance;

- (void)stop;

/**
 * Supported protocols.
 */
- (NSArray *)protocols;

/**
 * Called when an account has signed off.
 */
- (void)signedOff:(void *)account;

/**
 * Enable an account.
 */
- (PurpAccount *)enableAccountType:(NSUInteger)aType 
    username:(NSString *)aUsername password:(NSString *)password
;
- (PurpAccount *)enableAccount:(NSString *)aProtocol 
    username:(NSString *)aUsername password:(NSString *)password
;

/**
 * Disable an account.
 */
- (void)disableAccount:(NSString *)aUsername;

/**
 * Send a conversation message.
 */
- (void)sendConversationMessage:(NSString *)aMessage 
    to:(NSString *)toUsername from:(NSString *)fromUsername
;

/**
 * Receive a conversation message.
 */
- (void)receiveConversationMessage:(NSString *)aWho alias:(NSString *)anAlias 
    message:(NSString *)aMessage time:(NSDate *)aDate
;

/**
 * Update a buddy.
 */
- (void)updateBuddy:(NSDictionary *)aBuddy withEvent:(NSUInteger)aEvent;

/**
 * An account has signed on.
 */
extern  NSString  * kPurpAccountDidSignOnNotification;

/**
 * A buddy has received an update.
 */
extern NSString * kPurpBuddyDidUpdateNotification;

/**
 * A conversation has received a message.
 */
extern NSString * kPurpConversationDidReceiveNotification;

@end
