| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- //
- // IRCClientSession.h
- // IRCClient
- /*! \mainpage IRCClient - a Cocoa IRC Framework to create IRC clients
- *
- * \section intro_sec Introduction
- *
- * IRCClient is a Cocoa Framework that uses the excellent libircclient library
- * written by Georgy Yunaev.
- *
- * \section usage Basic Usage
- *
- * To use this framework, you will need to write an IRCClientSessionDelegate to
- * handle all of the events generated by the server, and an IRCClientChannelDelegate
- * to handle all of the events generated by channels on that server.
- *
- * You then create an IRCClientSession object in your code, assign the required
- * properties, and call connect: to connect to the server and run: to create
- * the new thread and start receiving events. For example:
- *
- * \code
- * IRCClientSession *session = [[IRCClientSession alloc] init];
- * MyIRCClientSessionDelegate *controller = [[MyIRCClientSessionDelegate alloc] init];
- *
- * [session setDelegate:controller];
- * [controller setSession:session];
- *
- * [session setServer:@"irc.dal.net"];
- * [session setPort:@"6667"];
- * [session setNickname:@"test"];
- * [session setUsername:@"test"];
- * [session setRealname:@"test"];
- * [session connect];
- *
- * [session run]; //starts the thread
- * \endcode
- *
- * \section author Author, copyright, support.
- *
- * If you have any questions, bug reports, suggestions regarding libircclient
- * or the IRCClient framework, please visit http://libircclient.sourceforge.net
- *
- * <PRE>
- * libircclient Copyright (C) 2004-2009 Georgy Yunaev gyunaev@ulduzsoft.com
- * Original IRCClient Copyright (C) 2009 Nathan Ollerenshaw chrome@stupendous.net
- * Modified IRCClient Copyright 2015 Said Achmiz (www.saidachmiz.net)
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- * </PRE>
- */
-
- #import <Cocoa/Cocoa.h>
- #import "IRCClientSessionDelegate.h"
-
- /** @class IRCClientSession
- * @brief Represents a connected IRC Session.
- *
- * IRCClientSession represents a single connection to an IRC server. On initialising
- * the object, and setting the delegate, server, port, password, nickname, username and realname
- * properties, you call the connect: and run: methods to connect to the IRC server
- * and start a new thread.
- *
- * This thread then sends messages back to the main runloop to the IRC server delegate,
- * or to the IRCClientChannel delegate as required.
- */
-
- @class IRCClientChannel;
-
- /**********************************************/
- #pragma mark IRCClientSession class declaration
- /**********************************************/
-
- @interface IRCClientSession : NSObject
-
- /************************/
- #pragma mark - Properties
- /************************/
-
- /** delegate to send events to. */
- @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 */
- @property (copy) NSString *version;
-
- /** IRC server to connect to */
- @property (copy) NSString *server;
-
- /** IRC port to connect to */
- @property (assign) NSUInteger port;
-
- /** Server password to provide on connect (may be left empty or nil) */
- @property (copy) NSData *password;
-
- /** Nickname of the connected client. Note that setting this after connection will
- not result in the client renaming on IRC. You need to send a nick: message instead.
- */
- @property (copy) NSString *nickname;
-
- /** Username of the connected client. Also known as the ident.
-
- Setting this after connection does nothing.
- */
- @property (copy) NSString *username;
-
- /** Realname of the connected client.
-
- Setting this after connection does nothing.
- */
- @property (copy) NSString *realname;
-
- /** The default text encoding for messages on this server.
-
- This concerns messages received via PRIVMSG and NOTICE, and TOPIC in a channel.
- It also affects what encoding reasons given for QUIT messages are assumed to be in.
- You may change this at any time.
- */
- @property (assign) NSStringEncoding encoding;
-
- /** An NSDictionary of channels that the client is currently connected to. */
- @property (readonly) NSDictionary *channels;
-
- /** returns YES if the server is currently connected successfully, and NO if
- it is not. */
- @property (readonly, getter=isConnected) bool connected;
-
- /***************************/
- #pragma mark - Class methods
- /***************************/
-
- /** Connect to the IRC server.
-
- Note that this performs the initial DNS lookup and the TCP connection, so if
- there are any problems you will be notified via the return code of the message.
-
- Look at the libircclient documentation for the different return codes.
- */
- - (int)connect;
-
- /** Disconnect from the IRC server.
-
- This always works, as it simply shuts down the socket. If you want to disconnect
- in a friendly way, you should use the quit: message.
- */
- - (void)disconnect;
-
- /** Starts a new thread and starts the libircclient runloop, processing events and
- firing messages back to the main runloop as required. Calling this again will
- do nothing other than raise a warning in your logs.
- */
- - (void)run;
-
- /**************************/
- #pragma mark - IRC commands
- /**************************/
-
- /** Sends a raw message to the IRC server. Please consult rfc1459 for the format
- of IRC commands. */
- - (int)sendRaw:(NSData *)message;
-
- /** quits the IRC server with the given reason.
-
- On success, a userQuit:withReason: event will be sent to the
- IRCClientSessionDelegate with the nickname of the IRC client and the reason
- provided by the user (or nil if no reason was provided).
- */
- - (int)quit:(NSData *)reason;
-
- /** Joins a channel with a given name and key
-
- On success, a userJoined:channel: event will be sent to the
- IRCClientSessionDelegate with the nickname of the IRC client and the name of
- the channel that was joined.
-
- @param channel the channel to join
- @param key they key for the channel (may be nil)
- */
- - (int)join:(NSData *)channel key:(NSData *)key;
-
- /** lists channels on the IRC server.
-
- @param channel a channel name or string to pass to the LIST command. Implementation specific.
- */
- - (int)list:(NSData *)channel;
-
- /** sets the user mode for the IRC client
-
- @param mode string to set
- */
- - (int)userMode:(NSString *)mode;
-
- /** sets the IRC client nickname.
-
- On success, a nickChangedFrom:to: event will be sent to the
- IRCClientSessionDelegate with our old nick and the new nick that we now
- have.
-
- @param newnick new nickname to set.
- */
- - (int)nick:(NSString *)newnick;
-
- /** sends a WHOIS request to the IRC server
-
- @param nick nickname of the irc client to whois.
- */
- - (int)whois:(NSString *)nick;
-
- /** send a PRIVMSG to another IRC client
-
- @param message message to send
- @param target the other IRC client to send the message to.
- */
- - (int)message:(NSData *)message to:(NSString *)target;
-
- /** send a CTCP ACTION to another IRC client
-
- @param action the action message to send
- @param target the nickname of the irc client to send the message to.
- */
- - (int)action:(NSData *)action to:(NSString *)target;
-
- /** send a NOTICE to another IRC client
-
- @param notice the message text to send
- @param target the nickname of the irc client to send the notice to.
- */
- - (int)notice:(NSData *)notice to:(NSString *)target;
-
- /** send a CTCP request to another IRC client
-
- @param request the CTCP request string to send
- @param target the nickname of the IRC client to send the request to.
- */
- - (int)ctcpRequest:(NSData *)request target:(NSString *)target;
-
- /** send a CTCP reply to another IRC client
-
- @param reply the CTCP reply string to send
- @param target the nickname of the IRC client to send the reply to.
- */
- - (int)ctcpReply:(NSData *)reply target:(NSString *)target;
-
- @end
-
- NSString* getNickFromNickUserHost(NSString *nuh);
-
- NSString* getUserFromNickUserHost(NSString *nuh);
-
- NSString* getHostFromNickUserHost(NSString *nuh);
|