The methods declared in IRCClientSessionDelegate and IRCClientChannelDelegate now have an additional parameter, for the session or the channel to send a reference to itself. This is in order that a single delegate object may manage multiple sessions or channels, and disambiguate between them when receiving messages.master
| @@ -148,44 +148,44 @@ | |||
| - (void)userJoined:(NSData *)nick | |||
| { | |||
| [_delegate userJoined:nick]; | |||
| [_delegate userJoined:nick channel:self]; | |||
| } | |||
| - (void)userParted:(NSData *)nick withReason:(NSData *)reason us:(BOOL)wasItUs | |||
| { | |||
| [_delegate userParted:nick withReason:reason us:wasItUs]; | |||
| [_delegate userParted:nick channel:self withReason:reason us:wasItUs]; | |||
| } | |||
| - (void)modeSet:(NSData *)mode withParams:(NSData *)params by:(NSData *)nick | |||
| { | |||
| [_delegate modeSet:mode withParams:params by:nick]; | |||
| [_delegate modeSet:mode forChannel:self withParams:params by:nick]; | |||
| } | |||
| - (void)topicSet:(NSData *)topic by:(NSData *)nick | |||
| { | |||
| _topic = topic; | |||
| [_delegate topicSet:topic by:nick]; | |||
| [_delegate topicSet:topic forChannel:self by:nick]; | |||
| } | |||
| - (void)userKicked:(NSData *)nick withReason:(NSData *)reason by:(NSData *)byNick us:(BOOL)wasItUs | |||
| { | |||
| [_delegate userKicked:nick withReason:reason by:byNick us:wasItUs]; | |||
| [_delegate userKicked:nick fromChannel:self withReason:reason by:byNick us:wasItUs]; | |||
| } | |||
| - (void)messageSent:(NSData *)message byUser:(NSData *)nick | |||
| { | |||
| [_delegate messageSent:message byUser:nick]; | |||
| [_delegate messageSent:message byUser:nick onChannel:self]; | |||
| } | |||
| - (void)noticeSent:(NSData *)notice byUser:(NSData *)nick | |||
| { | |||
| [_delegate noticeSent:notice byUser:nick]; | |||
| [_delegate noticeSent:notice byUser:nick onChannel:self]; | |||
| } | |||
| - (void)actionPerformed:(NSData *)action byUser:(NSData *)nick | |||
| { | |||
| [_delegate actionPerformed:action byUser:nick]; | |||
| [_delegate actionPerformed:action byUser:nick onChannel:self]; | |||
| } | |||
| @end | |||
| @@ -28,6 +28,8 @@ | |||
| * object may be supplied instead of the given parameter. | |||
| */ | |||
| @class IRCClientChannel; | |||
| @protocol IRCClientChannelDelegate <NSObject> | |||
| /** When a client joins this channel, the userJoined event is fired. Note that | |||
| @@ -39,7 +41,7 @@ | |||
| * | |||
| * @param nick The nickname of the user that joined the channel. | |||
| */ | |||
| - (void)userJoined:(NSData *)nick; | |||
| - (void)userJoined:(NSData *)nick channel:(IRCClientChannel *)sender; | |||
| /** When an IRC client parts a channel you are connect to, you will see | |||
| * an onPart event. You will also see this event when you part a channel. | |||
| @@ -48,7 +50,7 @@ | |||
| * @param reason (optional) The reason, if any, that the user gave for leaving. | |||
| * @param wasItUs (required) Was it us who parted, or another user? | |||
| */ | |||
| - (void)userParted:(NSData *)nick withReason:(NSData *)reason us:(BOOL)wasItUs; | |||
| - (void)userParted:(NSData *)nick channel:(IRCClientChannel *)sender withReason:(NSData *)reason us:(BOOL)wasItUs; | |||
| /** Received when an IRC client changes the channel mode. What modes are available | |||
| * for a given channel is an implementation detail for each server. | |||
| @@ -57,14 +59,14 @@ | |||
| * @param params any parameters with the mode (such as channel key). | |||
| * @param nick the nickname of the IRC client that changed the mode. | |||
| */ | |||
| - (void)modeSet:(NSData *)mode withParams:(NSData *)params by:(NSData *)nick; | |||
| - (void)modeSet:(NSData *)mode forChannel:(IRCClientChannel *)sender withParams:(NSData *)params by:(NSData *)nick; | |||
| /** Received when the topic is changed for the channel. | |||
| * | |||
| * @param aTopic The new topic of the channel. | |||
| * @param nick Nickname of the IRC client that changed the topic. | |||
| */ | |||
| - (void)topicSet:(NSData *)topic by:(NSData *)nick; | |||
| - (void)topicSet:(NSData *)topic forChannel:(IRCClientChannel *)sender by:(NSData *)nick; | |||
| /** Received when an IRC client is kicked from a channel. | |||
| * | |||
| @@ -73,7 +75,7 @@ | |||
| * @param byNick nickname of the client that performed the kick command | |||
| * @param wasItUs Was it us who got kicked, or another user? | |||
| */ | |||
| - (void)userKicked:(NSData *)nick withReason:(NSData *)reason by:(NSData *)byNick us:(BOOL)wasItUs; | |||
| - (void)userKicked:(NSData *)nick fromChannel:(IRCClientChannel *)sender withReason:(NSData *)reason by:(NSData *)byNick us:(BOOL)wasItUs; | |||
| /** Received when an IRC client sends a public PRIVMSG to the channel. Note that the | |||
| * user may not necessarily be required to be on the channel to send a message | |||
| @@ -82,7 +84,7 @@ | |||
| * @param message the message sent to the channel. | |||
| * @param nick the nickname of the IRC client that sent the message. | |||
| */ | |||
| - (void)messageSent:(NSData *)message byUser:(NSData *)nick; | |||
| - (void)messageSent:(NSData *)message byUser:(NSData *)nick onChannel:(IRCClientChannel *)sender; | |||
| /** Received when an IRC client sends a public NOTICE to the channel. Note that | |||
| * the user may not necessarily be required to be on the channel to send a notice to | |||
| @@ -92,13 +94,13 @@ | |||
| * @param notice the notice sent to the channel. | |||
| * @param nick the nickname of the IRC client that sent the notice. | |||
| */ | |||
| - (void)noticeSent:(NSData *)notice byUser:(NSData *)nick; | |||
| - (void)noticeSent:(NSData *)notice byUser:(NSData *)nick onChannel:(IRCClientChannel *)sender; | |||
| /** Received when an IRC client sends a CTCP ACTION message to the channel. | |||
| * | |||
| * @param action the action message sent to the channel. | |||
| * @param nick the nickname of the IRC client that sent the message. | |||
| */ | |||
| - (void)actionPerformed:(NSData *)action byUser:(NSData *)nick; | |||
| - (void)actionPerformed:(NSData *)action byUser:(NSData *)nick onChannel:(IRCClientChannel *)sender; | |||
| @end | |||
| @@ -314,7 +314,7 @@ static NSDictionary* ircNumericCodeList; | |||
| - (void)connectionSucceeded | |||
| { | |||
| [_delegate connectionSucceeded]; | |||
| [_delegate connectionSucceeded:self]; | |||
| } | |||
| - (void)nickChangedFrom:(NSData *)oldNick to:(NSData *)newNick | |||
| @@ -324,17 +324,17 @@ static NSDictionary* ircNumericCodeList; | |||
| if ([_nickname isEqualToData:oldNickOnly]) | |||
| { | |||
| _nickname = newNick; | |||
| [_delegate nickChangedFrom:oldNickOnly to:newNick own:YES]; | |||
| [_delegate nickChangedFrom:oldNickOnly to:newNick own:YES session:self]; | |||
| } | |||
| else | |||
| { | |||
| [_delegate nickChangedFrom:oldNickOnly to:newNick own:NO]; | |||
| [_delegate nickChangedFrom:oldNickOnly to:newNick own:NO session:self]; | |||
| } | |||
| } | |||
| - (void)userQuit:(NSData *)nick withReason:(NSData *)reason | |||
| { | |||
| [_delegate userQuit:nick withReason:reason]; | |||
| [_delegate userQuit:nick withReason:reason session:self]; | |||
| } | |||
| - (void)userJoined:(NSData *)nick channel:(NSData *)channelName | |||
| @@ -348,7 +348,7 @@ static NSDictionary* ircNumericCodeList; | |||
| IRCClientChannel* newChannel = [[IRCClientChannel alloc] initWithName:channelName andIRCSession:_irc_session]; | |||
| _channels[channelName] = newChannel; | |||
| [_delegate joinedNewChannel:newChannel]; | |||
| [_delegate joinedNewChannel:newChannel session:self]; | |||
| } | |||
| else | |||
| { | |||
| @@ -386,7 +386,7 @@ static NSDictionary* ircNumericCodeList; | |||
| - (void)modeSet:(NSData *)mode by:(NSData *)nick | |||
| { | |||
| [_delegate modeSet:mode by:nick]; | |||
| [_delegate modeSet:mode by:nick session:self]; | |||
| } | |||
| - (void)topicSet:(NSData *)newTopic forChannel:(NSData *)channelName by:(NSData *)nick | |||
| @@ -422,17 +422,17 @@ static NSDictionary* ircNumericCodeList; | |||
| - (void)privateMessageReceived:(NSData *)message fromUser:(NSData *)nick | |||
| { | |||
| [_delegate privateMessageReceived:message fromUser:nick]; | |||
| [_delegate privateMessageReceived:message fromUser:nick session:self]; | |||
| } | |||
| - (void)serverMessageReceivedFrom:(NSData *)origin params:(NSArray *)params | |||
| { | |||
| [_delegate serverMessageReceivedFrom:origin params:params]; | |||
| [_delegate serverMessageReceivedFrom:origin params:params session:self]; | |||
| } | |||
| - (void)privateNoticeReceived:(NSData *)notice fromUser:(NSData *)nick | |||
| { | |||
| [_delegate privateNoticeReceived:notice fromUser:nick]; | |||
| [_delegate privateNoticeReceived:notice fromUser:nick session:self]; | |||
| } | |||
| - (void)noticeSent:(NSData *)notice toChannel:(NSData *)channelName byUser:(NSData *)nick | |||
| @@ -444,12 +444,12 @@ static NSDictionary* ircNumericCodeList; | |||
| - (void)serverNoticeReceivedFrom:(NSData *)origin params:(NSArray *)params | |||
| { | |||
| [_delegate serverNoticeReceivedFrom:origin params:params]; | |||
| [_delegate serverNoticeReceivedFrom:origin params:params session:self]; | |||
| } | |||
| - (void)invitedToChannel:(NSData *)channelName by:(NSData *)nick | |||
| { | |||
| [_delegate invitedToChannel:channelName by:nick]; | |||
| [_delegate invitedToChannel:channelName by:nick session:self]; | |||
| } | |||
| - (void)CTCPRequestReceived:(NSData *)request fromUser:(NSData *)nick | |||
| @@ -481,7 +481,7 @@ static NSDictionary* ircNumericCodeList; | |||
| } | |||
| else | |||
| { | |||
| if ([_delegate respondsToSelector:@selector(CTCPRequestReceived:ofType:fromUser:)]) | |||
| if ([_delegate respondsToSelector:@selector(CTCPRequestReceived:ofType:fromUser:session:)]) | |||
| { | |||
| char* request_string = malloc(request.length); | |||
| [request getBytes:request_string length:request.length]; | |||
| @@ -492,7 +492,7 @@ static NSDictionary* ircNumericCodeList; | |||
| NSData* requestTypeData = [NSData dataWithBytes:request_body length:strlen(request_body) + 1]; | |||
| NSData* requestBodyData = [NSData dataWithBytes:request_type length:strlen(request_type) + 1]; | |||
| [_delegate CTCPRequestReceived:requestBodyData ofType:requestTypeData fromUser:nick]; | |||
| [_delegate CTCPRequestReceived:requestBodyData ofType:requestTypeData fromUser:nick session:self]; | |||
| free(request_string); | |||
| } | |||
| @@ -501,7 +501,7 @@ static NSDictionary* ircNumericCodeList; | |||
| - (void)CTCPReplyReceived:(NSData *)reply fromUser:(NSData *)nick | |||
| { | |||
| [_delegate CTCPReplyReceived:reply fromUser:nick]; | |||
| [_delegate CTCPReplyReceived:reply fromUser:nick session:self]; | |||
| } | |||
| - (void)CTCPActionPerformed:(NSData *)action byUser:(NSData *)nick atTarget:(NSData *)target | |||
| @@ -516,18 +516,18 @@ static NSDictionary* ircNumericCodeList; | |||
| else | |||
| { | |||
| // An action in a private message | |||
| [_delegate privateCTCPActionReceived:action fromUser:nick]; | |||
| [_delegate privateCTCPActionReceived:action fromUser:nick session:self]; | |||
| } | |||
| } | |||
| - (void)unknownEventReceived:(NSData *)event from:(NSData *)origin params:(NSArray *)params | |||
| { | |||
| [_delegate unknownEventReceived:event from:origin params:params]; | |||
| [_delegate unknownEventReceived:event from:origin params:params session:self]; | |||
| } | |||
| -(void)numericEventReceived:(NSUInteger)event from:(NSData *)origin params:(NSArray *)params | |||
| { | |||
| [_delegate numericEventReceived:event from:origin params:params]; | |||
| [_delegate numericEventReceived:event from:origin params:params session:self]; | |||
| } | |||
| @end | |||
| @@ -19,6 +19,7 @@ | |||
| #import <Cocoa/Cocoa.h> | |||
| @class IRCClientSession; | |||
| @class IRCClientChannel; | |||
| /** @brief Receives delegate messages from an IRCClientSession. | |||
| @@ -33,7 +34,8 @@ | |||
| @protocol IRCClientSessionDelegate <NSObject> | |||
| /** The client has successfully connected to the IRC server. */ | |||
| - (void)connectionSucceeded; | |||
| @required | |||
| - (void)connectionSucceeded:(IRCClientSession *)sender; | |||
| /** An IRC client on a channel that this client is connected to has changed nickname, | |||
| * or this IRC client has changed nicknames. | |||
| @@ -42,14 +44,16 @@ | |||
| * @param oldNick the old nickname | |||
| * @param wasItUs did our nick change, or someone else's? | |||
| */ | |||
| - (void)nickChangedFrom:(NSData *)oldNick to:(NSData *)newNick own:(BOOL)wasItUs; | |||
| @required | |||
| - (void)nickChangedFrom:(NSData *)oldNick to:(NSData *)newNick own:(BOOL)wasItUs session:(IRCClientSession *)sender; | |||
| /** An IRC client on a channel that this client is connected to has quit IRC. | |||
| * | |||
| * @param nick the nickname of the client that quit. | |||
| * @param reason (optional) the quit message, if any. | |||
| */ | |||
| - (void)userQuit:(NSData *)nick withReason:(NSData *)reason; | |||
| @required | |||
| - (void)userQuit:(NSData *)nick withReason:(NSData *)reason session:(IRCClientSession *)sender; | |||
| /** The IRC client has joined (connected) successfully to a new channel. This | |||
| * event creates an IRCClientChannel object, which you are expected to assign a | |||
| @@ -63,48 +67,55 @@ | |||
| * | |||
| * @param channel the IRCClientChannel object for the newly joined channel. | |||
| */ | |||
| - (void)joinedNewChannel:(IRCClientChannel *)channel; | |||
| @required | |||
| - (void)joinedNewChannel:(IRCClientChannel *)channel session:(IRCClientSession *)sender; | |||
| /** The client has changed it's user mode. | |||
| * | |||
| * @param mode the new mode. | |||
| */ | |||
| - (void)modeSet:(NSData *)mode by:(NSData *)nick; | |||
| @required | |||
| - (void)modeSet:(NSData *)mode by:(NSData *)nick session:(IRCClientSession *)sender; | |||
| /** The client has received a private PRIVMSG from another IRC client. | |||
| * | |||
| * @param message the text of the message | |||
| * @param nick the other IRC Client that sent the message. | |||
| */ | |||
| - (void)privateMessageReceived:(NSData *)message fromUser:(NSData *)nick; | |||
| @required | |||
| - (void)privateMessageReceived:(NSData *)message fromUser:(NSData *)nick session:(IRCClientSession *)sender; | |||
| /** The client has received a private NOTICE from another client. | |||
| * | |||
| * @param notice the text of the message | |||
| * @param nick the nickname of the other IRC client that sent the message. | |||
| */ | |||
| - (void)privateNoticeReceived:(NSData *)notice fromUser:(NSData *)nick; | |||
| @required | |||
| - (void)privateNoticeReceived:(NSData *)notice fromUser:(NSData *)nick session:(IRCClientSession *)sender; | |||
| /** The client has received a private PRIVMSG from the server. | |||
| * | |||
| * @param origin the sender of the message | |||
| * @param params the parameters of the message | |||
| */ | |||
| - (void)serverMessageReceivedFrom:(NSData *)origin params:(NSArray *)params; | |||
| @required | |||
| - (void)serverMessageReceivedFrom:(NSData *)origin params:(NSArray *)params session:(IRCClientSession *)sender; | |||
| /** The client has received a private NOTICE from the server. | |||
| * | |||
| * @param origin the sender of the notice | |||
| * @param params the parameters of the notice | |||
| */ | |||
| - (void)serverNoticeReceivedFrom:(NSData *)origin params:(NSArray *)params; | |||
| @required | |||
| - (void)serverNoticeReceivedFrom:(NSData *)origin params:(NSArray *)params session:(IRCClientSession *)sender; | |||
| /** The IRC client has been invited to a channel. | |||
| * | |||
| * @param channel the channel for the invitation. | |||
| * @param nick the nickname of the user that sent the invitation. | |||
| */ | |||
| - (void)invitedToChannel:(NSData *)channelName by:(NSData *)nick; | |||
| @required | |||
| - (void)invitedToChannel:(NSData *)channelName by:(NSData *)nick session:(IRCClientSession *)sender; | |||
| /** A private CTCP request was sent to the IRC client. | |||
| * | |||
| @@ -112,14 +123,16 @@ | |||
| * @param type the CTCP request type | |||
| * @param nick the nickname of the user that sent the request. | |||
| */ | |||
| - (void)CTCPRequestReceived:(NSData *)request ofType:(NSData *)type fromUser:(NSData *)nick; | |||
| @optional | |||
| - (void)CTCPRequestReceived:(NSData *)request ofType:(NSData *)type fromUser:(NSData *)nick session:(IRCClientSession *)sender; | |||
| /** A private CTCP reply was sent to the IRC client. | |||
| * | |||
| * @param reply an NSData containing the raw C string of the reply. | |||
| * @param nick the nickname of the user that sent the reply. | |||
| */ | |||
| - (void)CTCPReplyReceived:(NSData *)reply fromUser:(NSData *)nick; | |||
| @optional | |||
| - (void)CTCPReplyReceived:(NSData *)reply fromUser:(NSData *)nick session:(IRCClientSession *)sender; | |||
| /** A private CTCP ACTION was sent to the IRC client. | |||
| * | |||
| @@ -128,22 +141,25 @@ | |||
| * @param action the action message text. | |||
| * @param nick the nickname of the client that sent the action. | |||
| */ | |||
| - (void)privateCTCPActionReceived:(NSData *)action fromUser:(NSData *)nick; | |||
| @required | |||
| - (void)privateCTCPActionReceived:(NSData *)action fromUser:(NSData *)nick session:(IRCClientSession *)sender; | |||
| /** An unhandled event was received from the IRC server. | |||
| /** An unhandled numeric was received from the IRC server | |||
| * | |||
| * @param event the unknown event name | |||
| * @param event the unknown event number | |||
| * @param origin the sender of the event | |||
| * @param params an NSArray of NSData objects that are the raw C strings of the event. | |||
| */ | |||
| - (void)unknownEventReceived:(NSData *)event from:(NSData *)origin params:(NSArray *)params; | |||
| @optional | |||
| - (void)numericEventReceived:(NSUInteger)event from:(NSData *)origin params:(NSArray *)params session:(IRCClientSession *)sender; | |||
| /** An unhandled numeric was received from the IRC server | |||
| /** An unhandled event was received from the IRC server. | |||
| * | |||
| * @param event the unknown event number | |||
| * @param event the unknown event name | |||
| * @param origin the sender of the event | |||
| * @param params an NSArray of NSData objects that are the raw C strings of the event. | |||
| */ | |||
| - (void)numericEventReceived:(NSUInteger)event from:(NSData *)origin params:(NSArray *)params; | |||
| @optional | |||
| - (void)unknownEventReceived:(NSData *)event from:(NSData *)origin params:(NSArray *)params session:(IRCClientSession *)sender; | |||
| @end | |||