| * for a given session when the client joins an IRC channel. | * for a given session when the client joins an IRC channel. | ||||
| */ | */ | ||||
| /**********************************************/ | |||||
| #pragma mark IRCClientChannel class declaration | #pragma mark IRCClientChannel class declaration | ||||
| /**********************************************/ | |||||
| @interface IRCClientChannel : NSObject | @interface IRCClientChannel : NSObject | ||||
| #import "IRCClientChannel_Private.h" | #import "IRCClientChannel_Private.h" | ||||
| #import "NSData+SA_NSDataExtensions.h" | #import "NSData+SA_NSDataExtensions.h" | ||||
| /*********************************************/ | |||||
| #pragma mark IRCClientChannel private category | |||||
| /*********************************************/ | |||||
| /********************************************/ | |||||
| #pragma mark IRCClientChannel class extension | |||||
| /********************************************/ | |||||
| @interface IRCClientChannel() | @interface IRCClientChannel() | ||||
| { | { | ||||
| @implementation IRCClientChannel | @implementation IRCClientChannel | ||||
| /********************************/ | |||||
| #pragma mark - Property synthesis | |||||
| /********************************/ | |||||
| @synthesize delegate = _delegate; | |||||
| @synthesize name = _name; | |||||
| @synthesize encoding = _encoding; | |||||
| @synthesize topic = _topic; | |||||
| @synthesize modes = _modes; | |||||
| /******************************/ | /******************************/ | ||||
| #pragma mark - Custom accessors | #pragma mark - Custom accessors | ||||
| /******************************/ | /******************************/ |
| #import "IRCClientChannel.h" | #import "IRCClientChannel.h" | ||||
| #include "libircclient.h" | #include "libircclient.h" | ||||
| /********************************************/ | |||||
| #pragma mark IRCClientChannel class extension | |||||
| /********************************************/ | |||||
| @interface IRCClientChannel () | @interface IRCClientChannel () | ||||
| /** initWithName:andIRCSession: | /** initWithName:andIRCSession: |
| /** delegate to send events to. */ | /** delegate to send events to. */ | ||||
| @property (assign) id <IRCClientSessionDelegate> delegate; | @property (assign) id <IRCClientSessionDelegate> delegate; | ||||
| /** User-defined session ID (for one delegate to keep track of multiple sessions, | |||||
| if desired). | |||||
| */ | |||||
| @property (assign) NSUInteger sessionID; | |||||
| /** The version string for the client to send back on CTCP VERSION requests. | /** The version string for the client to send back on CTCP VERSION requests. | ||||
| There is usually no reason to set this, as IRCClient correctly sets its | There is usually no reason to set this, as IRCClient correctly sets its | ||||
| own version string automatically, but this can be any string you like. | own version string automatically, but this can be any string you like. |
| static void onUnknownEvent(irc_session_t *session, const char *event, const char *origin, const char **params, unsigned int count); | static void onUnknownEvent(irc_session_t *session, const char *event, const char *origin, const char **params, unsigned int count); | ||||
| static void onNumericEvent(irc_session_t *session, unsigned int event, const char *origin, const char **params, unsigned int count); | static void onNumericEvent(irc_session_t *session, unsigned int event, const char *origin, const char **params, unsigned int count); | ||||
| /***********************************************************/ | |||||
| #pragma mark - IRCClientSession private category declaration | |||||
| /***********************************************************/ | |||||
| static NSDictionary* ircNumericCodeList; | static NSDictionary* ircNumericCodeList; | ||||
| /**********************************************/ | |||||
| #pragma mark - IRCClientSession class extension | |||||
| /**********************************************/ | |||||
| @interface IRCClientSession() | @interface IRCClientSession() | ||||
| { | { | ||||
| irc_callbacks_t _callbacks; | irc_callbacks_t _callbacks; | ||||
| @implementation IRCClientSession | @implementation IRCClientSession | ||||
| /********************************/ | |||||
| #pragma mark - Property synthesis | |||||
| /********************************/ | |||||
| @synthesize delegate = _delegate; | |||||
| @synthesize sessionID = _sessionID; | |||||
| @synthesize version = _version; | |||||
| @synthesize server = _server; | |||||
| @synthesize port = _port; | |||||
| @synthesize password = _password; | |||||
| @synthesize nickname = _nickname; | |||||
| @synthesize username = _username; | |||||
| @synthesize realname = _realname; | |||||
| @synthesize encoding = _encoding; | |||||
| /******************************/ | /******************************/ | ||||
| #pragma mark - Custom accessors | #pragma mark - Custom accessors | ||||
| /******************************/ | /******************************/ | ||||
| - (void)nickChangedFrom:(NSData *)oldNick to:(NSData *)newNick | - (void)nickChangedFrom:(NSData *)oldNick to:(NSData *)newNick | ||||
| { | { | ||||
| if ([_nickname isEqualToData:oldNick]) | |||||
| NSData* oldNickOnly = getNickFromNickUserHost(oldNick); | |||||
| if ([_nickname isEqualToData:oldNickOnly]) | |||||
| { | { | ||||
| _nickname = newNick; | _nickname = newNick; | ||||
| [_delegate nickChangedFrom:oldNick to:newNick own:YES]; | |||||
| [_delegate nickChangedFrom:oldNickOnly to:newNick own:YES]; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| [_delegate nickChangedFrom:oldNick to:newNick own:NO]; | |||||
| [_delegate nickChangedFrom:oldNickOnly to:newNick own:NO]; | |||||
| } | } | ||||
| } | } | ||||