CL_IRCConnection Class Reference
[clanNetwork Internet Relay Chat]

IRC Connection class. More...

#include <irc_connection.h>

List of all members.

Operations

CL_IRCConnectionoperator= (const CL_IRCConnection &copy)
void send_command (const CL_String8 &prefix, const CL_String8 &command, const std::vector< CL_String8 > &params)
 Send command to IRC server.
void send_pass (const CL_String8 &password)
 Send password.
void send_nick (const CL_String8 &nick, int hopcount=-1)
 Send nick.
void send_user (const CL_String8 &username, const CL_String8 &hostname, const CL_String8 &servername, const CL_String8 &realname)
 Send user login/identify command.
void send_oper (const CL_String8 &user, const CL_String8 &password)
 Send operator login command.
void send_quit (const CL_String8 &quitmessage="")
 Send quit command.
void send_join (const CL_String8 &channel, const CL_String8 &key="")
 Send join channel command.
void send_join (const std::list< CL_String8 > &channels, const std::list< CL_String8 > &keys)
 Send join.
void send_part (const CL_String8 &channel, const CL_String8 &reason="")
 Send part channel command.
void send_part (const std::list< CL_String8 > &channels, const CL_String8 &reason="")
 Send part.
void send_mode (const CL_String8 &target, const CL_String8 &mode, const std::vector< CL_String8 > &args)
 Send set mode command.
void send_topic (const CL_String8 &channel, const CL_String8 &topic)
 Set/Get topic on channel.
void send_topic (const CL_String8 &channel)
 Send topic.
void send_names (const CL_String8 &channel="")
 List nicks on channel(s).
void send_names (const std::list< CL_String8 > &channels)
 Send names.
void send_list (const CL_String8 &channel="", const CL_String8 &server="")
 Send list of channels.
void send_list (const std::list< CL_String8 > &channels, const CL_String8 &server="")
 Send list.
void send_invite (const CL_String8 &nickname, const CL_String8 &channel)
 Send channel join invitation.
void send_kick (const CL_String8 &channel, const CL_String8 &user, const CL_String8 &comment="")
 Send kick command.
void send_kick (const std::list< CL_String8 > &channels, const std::list< CL_String8 > &users, const CL_String8 &comment="")
 Send kick.
void send_version (const CL_String8 &server="")
 Send version command.
void send_stats (const CL_String8 &query="", const CL_String8 &server="")
 Send statistics command.
void send_links (const CL_String8 &remote_server="", const CL_String8 &server_mask="")
 Send links command.
void send_time (const CL_String8 &server="")
 Send time command.
void send_connect (const CL_String8 &target_server, int port=0, const CL_String8 &remote_server="")
 Send connect command.
void send_trace (const CL_String8 &server=CL_String8())
 Send trace command.
void send_admin (const CL_String8 &server=CL_String8())
 Send admin command.
void send_info (const CL_String8 &server=CL_String8())
 Send info command.
void send_privmsg (const CL_String8 &receiver, const CL_String8 &text)
 Send channel message or private message.
void send_privmsg (const std::list< CL_String8 > &receivers, const CL_String8 &text)
 Send privmsg.
void send_privmsg_ctcp (const CL_String8 &receiver, const CL_String8 &command, const CL_String8 &data)
 Send Client To Client Protocol (CTCP) message.
void send_privmsg_ctcp (std::list< CL_String8 > &receivers, const CL_String8 &command, const CL_String8 &data)
 Send privmsg ctcp.
void send_notice (const CL_String8 &nickname, const CL_String8 &text)
 Send notice message.
void send_notice_ctcp (const CL_String8 &nickname, const CL_String8 &command, const CL_String8 &data)
 Send Client To Client Protocol (CTCP) notice.
void send_who (const CL_String8 &name, bool oper=false)
 Send who command.
void send_whois (const CL_String8 &nickmask)
 Send whois command.
void send_whois (const CL_String8 &server, const CL_String8 &nickmask)
 Send whois.
void send_whois (const std::list< CL_String8 > &nickmasks)
 Send whois.
void send_whois (const CL_String8 &server, const std::list< CL_String8 > &nickmasks)
 Send whois.
void send_whowas (const CL_String8 &nickname, int count=0, const CL_String8 &server="")
 Send whowas command.
void send_kill (const CL_String8 &nickname, const CL_String8 &comment)
 Send kill command.
void send_ping (const CL_String8 &server, const CL_String8 &server2="")
 Send ping command.
void send_pong (const CL_String8 &daemon, const CL_String8 &daemon2="")
 Send pong command.
static CL_String8 extract_nick (const CL_String8 &str)
 Extracts nick part of a fully qualified IRC prefix.
static CL_String8 extract_user (const CL_String8 &str)
 Extracts user part of a fully qualified IRC prefix.
static CL_String8 extract_address (const CL_String8 &str)
 Extracts address part of a fully qualified IRC prefix.

Public Member Functions

Construction
 CL_IRCConnection ()
 Constructs a CL_IRCConnection and connects a server.
 CL_IRCConnection (const CL_String &server, const CL_String &port=cl_text("6667"))
 Constructs a IRCConnection.
 CL_IRCConnection (const CL_IRCConnection &copy)
 Constructs a IRCConnection.
 ~CL_IRCConnection ()
Attributes
const CL_String8get_nick () const
 Returns our current nick name.
const CL_String8get_username () const
 Returns the username passed to send_user.
const CL_String8get_hostname () const
 Returns hostname passed to send_user.
const CL_String8get_servername () const
 Returns server name passed to send_user.
const CL_String8get_realname () const
 Returns the real name passed to send_user.
Signals
CL_Signal_v1< const CL_String & > & sig_socket_error ()
 sig_socket_error(error_message)
CL_Signal_v3< const CL_String8 &,
const CL_String8 &, const
std::vector< CL_String8 > & > & 
sig_command_received ()
 sig_command_received(prefix, command, params)
CL_Signal_v3< const CL_String8 &,
const CL_String8 &, const
std::vector< CL_String8 > & > & 
sig_unknown_command_received ()
 sig_unknown_command_received(prefix, command, params)
CL_Signal_v3< const CL_String8 &,
int, const std::vector< CL_String8 > & > & 
sig_numeric_reply ()
 sig_numeric_reply(prefix, code, params)
CL_Signal_v3< const CL_String8 &,
const CL_String8 &, const
std::vector< CL_String8 > & > & 
sig_name_reply ()
 sig_name_reply(self, channel, users)
CL_Signal_v2< const CL_String8 &,
const CL_String8 & > & 
sig_nick ()
 sig_nick(old_nick, new_nick)
CL_Signal_v2< const CL_String8 &,
const CL_String8 & > & 
sig_join ()
 sig_join(nick, channel)
CL_Signal_v3< const CL_String8 &,
const CL_String8 &, const
CL_String8 & > & 
sig_part ()
 sig_part(nick, channel, reason)
CL_Signal_v4< const CL_String8 &,
const CL_String8 &, const
CL_String8 &, const std::vector<
CL_String8 > & > & 
sig_mode ()
 sig_mode(prefix, receiver, mode, params)
CL_Signal_v3< const CL_String8 &,
const CL_String8 &, const
CL_String8 & > & 
sig_topic ()
 sig_topic(prefix, channel, topic)
CL_Signal_v3< const CL_String8 &,
const CL_String8 &, const
CL_String8 & > & 
sig_invite ()
 sig_invite(prefix, nick, channel)
CL_Signal_v4< const CL_String8 &,
const CL_String8 &, const
CL_String8 &, const CL_String8 & > & 
sig_kick ()
 sig_kick(prefix, chan, user, comment)
CL_Signal_v3< const CL_String8 &,
const CL_String8 &, const
CL_String8 & > & 
sig_privmsg ()
 sig_privmsg(prefix, receiver, text)
CL_Signal_v3< const CL_String8 &,
const CL_String8 &, const
CL_String8 & > & 
sig_notice ()
 sig_notice(prefix, receiver, text)
CL_Signal_v4< const CL_String8 &,
const CL_String8 &, const
CL_String8 &, const CL_String8 & > & 
sig_privmsg_ctcp ()
 sig_privmsg_ctcp(prefix, receiver, command, data)
CL_Signal_v4< const CL_String8 &,
const CL_String8 &, const
CL_String8 &, const CL_String8 & > & 
sig_notice_ctcp ()
 sig_notice_ctcp(prefix, receiver, command, data)
CL_Signal_v2< const CL_String8 &,
const CL_String8 & > & 
sig_ping ()
 sig_ping(daemon1, daemon2)


Detailed Description

IRC Connection class.

The CL_IRCConnection class represents a socket connection to an IRC server. Upon construction it will connect to the server+port given and then parse each line written by the IRC server. Each time process_data() is called, the CL_IRCConnection will emit the signals for those commands received.

Most IRC networks will expect the connecting IRC client to first send a "nick" command and then a "user" command, as part of the logon process. CL_IRCConnection will not do this, so the general logon procedure looks somewhat like this:

       CL_IRCConnection connection("irc.freenode.net", "6667");
       connection.send_nick("MyNick");
       connection.send_user("username", "our.hostname", "irc.freenode.net", "User Name");
       

IRC servers will occationally send a "ping" line, which have to be replied with a "pong" command. If this isn't done within some server specific timeout, the IRC network will disconnect the client. CL_IRCConnection will also not do this automatically, so its important you at least hook up the ping slot, to a function looking like this:

       void on_ping(const CL_String8 &daemon1, const CL_String8 &daemon2)
       { connection.send_pong(daemon1, daemon2); }
       


Constructor & Destructor Documentation

CL_IRCConnection::CL_IRCConnection  ) 
 

Constructs a CL_IRCConnection and connects a server.

Parameters:
server IRC server host name. Ie. "irc.freenode.net".
port IRC server port. Defaults to "6667".

CL_IRCConnection::CL_IRCConnection const CL_String server,
const CL_String port = cl_text("6667")
 

Constructs a IRCConnection.

Parameters:
server = String
port = String

CL_IRCConnection::CL_IRCConnection const CL_IRCConnection copy  ) 
 

Constructs a IRCConnection.

Parameters:
copy = IRCConnection

CL_IRCConnection::~CL_IRCConnection  ) 
 


Member Function Documentation

static CL_String8 CL_IRCConnection::extract_address const CL_String8 str  )  [static]
 

Extracts address part of a fully qualified IRC prefix.

static CL_String8 CL_IRCConnection::extract_nick const CL_String8 str  )  [static]
 

Extracts nick part of a fully qualified IRC prefix.

static CL_String8 CL_IRCConnection::extract_user const CL_String8 str  )  [static]
 

Extracts user part of a fully qualified IRC prefix.

const CL_String8& CL_IRCConnection::get_hostname  )  const
 

Returns hostname passed to send_user.

const CL_String8& CL_IRCConnection::get_nick  )  const
 

Returns our current nick name.

const CL_String8& CL_IRCConnection::get_realname  )  const
 

Returns the real name passed to send_user.

const CL_String8& CL_IRCConnection::get_servername  )  const
 

Returns server name passed to send_user.

const CL_String8& CL_IRCConnection::get_username  )  const
 

Returns the username passed to send_user.

CL_IRCConnection& CL_IRCConnection::operator= const CL_IRCConnection copy  ) 
 

void CL_IRCConnection::send_admin const CL_String8 server = CL_String8()  ) 
 

Send admin command.

void CL_IRCConnection::send_command const CL_String8 prefix,
const CL_String8 command,
const std::vector< CL_String8 > &  params
 

Send command to IRC server.

Parameters:
prefix Sender prefix.
command IRC command.
params List of parameters for IRC command.
This is the low-level IRC send command. Useful if you need to send a command not supported by the other higher level send functions.

void CL_IRCConnection::send_connect const CL_String8 target_server,
int  port = 0,
const CL_String8 remote_server = ""
 

Send connect command.

void CL_IRCConnection::send_info const CL_String8 server = CL_String8()  ) 
 

Send info command.

void CL_IRCConnection::send_invite const CL_String8 nickname,
const CL_String8 channel
 

Send channel join invitation.

Parameters:
nickname Nick to receive invitation.
channel Channel being invited to.

void CL_IRCConnection::send_join const std::list< CL_String8 > &  channels,
const std::list< CL_String8 > &  keys
 

Send join.

Parameters:
list = std
list = std

void CL_IRCConnection::send_join const CL_String8 channel,
const CL_String8 key = ""
 

Send join channel command.

Parameters:
channel Channel to join, ie. "#clanlib"
key Channel key, if any.
channels List of channels to join.
keys List of channel keys.

void CL_IRCConnection::send_kick const std::list< CL_String8 > &  channels,
const std::list< CL_String8 > &  users,
const CL_String8 comment = ""
 

Send kick.

Parameters:
list = std
list = std
comment = String8

void CL_IRCConnection::send_kick const CL_String8 channel,
const CL_String8 user,
const CL_String8 comment = ""
 

Send kick command.

void CL_IRCConnection::send_kill const CL_String8 nickname,
const CL_String8 comment
 

Send kill command.

Parameters:
nickname Nick to kill.
comment Reason given for killing nick.

void CL_IRCConnection::send_links const CL_String8 remote_server = "",
const CL_String8 server_mask = ""
 

Send links command.

void CL_IRCConnection::send_list const std::list< CL_String8 > &  channels,
const CL_String8 server = ""
 

Send list.

Parameters:
list = std
server = String8

void CL_IRCConnection::send_list const CL_String8 channel = "",
const CL_String8 server = ""
 

Send list of channels.

Parameters:
channel Channel name substring to match.
server Server to limit results from.

void CL_IRCConnection::send_mode const CL_String8 target,
const CL_String8 mode,
const std::vector< CL_String8 > &  args
 

Send set mode command.

Parameters:
target Channel or nick mode change apply to.
mode Mode change to perform, ie. "+o".
args Arguements to mode command.

void CL_IRCConnection::send_names const std::list< CL_String8 > &  channels  ) 
 

Send names.

Parameters:
list = std

void CL_IRCConnection::send_names const CL_String8 channel = ""  ) 
 

List nicks on channel(s).

Parameters:
channel Channel to list.

void CL_IRCConnection::send_nick const CL_String8 nick,
int  hopcount = -1
 

Send nick.

Parameters:
nick Nick name to use.
hopcount Can't remember. Check the RFC. :-)
Sets or changes your nick.

void CL_IRCConnection::send_notice const CL_String8 nickname,
const CL_String8 text
 

Send notice message.

Parameters:
nickname Nick to receive notice.
text Notice to send.

void CL_IRCConnection::send_notice_ctcp const CL_String8 nickname,
const CL_String8 command,
const CL_String8 data
 

Send Client To Client Protocol (CTCP) notice.

Parameters:
nickname Nick to receive notice.
command CTCP command.
data CTCP data.

void CL_IRCConnection::send_oper const CL_String8 user,
const CL_String8 password
 

Send operator login command.

Parameters:
user Operator login name.
password Operator password.

void CL_IRCConnection::send_part const std::list< CL_String8 > &  channels,
const CL_String8 reason = ""
 

Send part.

Parameters:
list = std
reason = String8

void CL_IRCConnection::send_part const CL_String8 channel,
const CL_String8 reason = ""
 

Send part channel command.

Parameters:
channel Channel to leave.
reason Reason for leaving.
channels List of channels to leave.

void CL_IRCConnection::send_pass const CL_String8 password  ) 
 

Send password.

Parameters:
password Password parameter to send with "pass" command.
Sends a "pass" command to IRC server.

void CL_IRCConnection::send_ping const CL_String8 server,
const CL_String8 server2 = ""
 

Send ping command.

Parameters:
server Server to send to.
server2 Server to relay through.

void CL_IRCConnection::send_pong const CL_String8 daemon,
const CL_String8 daemon2 = ""
 

Send pong command.

Parameters:
daemon Server that sent ping command.
daemon2 Server ping command was relayed through.

void CL_IRCConnection::send_privmsg const std::list< CL_String8 > &  receivers,
const CL_String8 text
 

Send privmsg.

Parameters:
list = std
text = String8

void CL_IRCConnection::send_privmsg const CL_String8 receiver,
const CL_String8 text
 

Send channel message or private message.

Parameters:
reciver Channel or nick to receive message.
text Message to send.

void CL_IRCConnection::send_privmsg_ctcp std::list< CL_String8 > &  receivers,
const CL_String8 command,
const CL_String8 data
 

Send privmsg ctcp.

Parameters:
list = std
command = String8
data = String8

void CL_IRCConnection::send_privmsg_ctcp const CL_String8 receiver,
const CL_String8 command,
const CL_String8 data
 

Send Client To Client Protocol (CTCP) message.

Parameters:
reciver Channel or nick to receive message.
command CTCP command.
data CTCP data.

void CL_IRCConnection::send_quit const CL_String8 quitmessage = ""  ) 
 

Send quit command.

void CL_IRCConnection::send_stats const CL_String8 query = "",
const CL_String8 server = ""
 

Send statistics command.

void CL_IRCConnection::send_time const CL_String8 server = ""  ) 
 

Send time command.

void CL_IRCConnection::send_topic const CL_String8 channel  ) 
 

Send topic.

Parameters:
channel = String8

void CL_IRCConnection::send_topic const CL_String8 channel,
const CL_String8 topic
 

Set/Get topic on channel.

Parameters:
channel Channel name.
topic New topic to be set.
If no topic is specified, this will make the IRC server send back what the topic is on a given channel.

void CL_IRCConnection::send_trace const CL_String8 server = CL_String8()  ) 
 

Send trace command.

void CL_IRCConnection::send_user const CL_String8 username,
const CL_String8 hostname,
const CL_String8 servername,
const CL_String8 realname
 

Send user login/identify command.

Parameters:
username Client username.
hostname Client hostname.
servername Hostname of IRC server.
realname Real name of client user.
This command identifies the IRC client to the IRC network. Each of the parameters passsed will be used to create your fully qualified prefix on the network.

void CL_IRCConnection::send_version const CL_String8 server = ""  ) 
 

Send version command.

void CL_IRCConnection::send_who const CL_String8 name,
bool  oper = false
 

Send who command.

Parameters:
name Nick to retrieve information about.
oper If set to true, use IRC operator rights.

void CL_IRCConnection::send_whois const CL_String8 server,
const std::list< CL_String8 > &  nickmasks
 

Send whois.

Parameters:
server = String8
list = std

void CL_IRCConnection::send_whois const std::list< CL_String8 > &  nickmasks  ) 
 

Send whois.

Parameters:
list = std

void CL_IRCConnection::send_whois const CL_String8 server,
const CL_String8 nickmask
 

Send whois.

Parameters:
server = String8
nickmask = String8

void CL_IRCConnection::send_whois const CL_String8 nickmask  ) 
 

Send whois command.

Parameters:
nickmask Nick to retrieve information about
server Server to query.

void CL_IRCConnection::send_whowas const CL_String8 nickname,
int  count = 0,
const CL_String8 server = ""
 

Send whowas command.

Parameters:
nickname Nick to retrieve information about
count Amount of users with that nick to get information about.
server Server to query.

CL_Signal_v3<const CL_String8 &, const CL_String8 &, const std::vector<CL_String8> &>& CL_IRCConnection::sig_command_received  ) 
 

sig_command_received(prefix, command, params)

CL_Signal_v3<const CL_String8 &, const CL_String8 &, const CL_String8 &>& CL_IRCConnection::sig_invite  ) 
 

sig_invite(prefix, nick, channel)

CL_Signal_v2<const CL_String8 &, const CL_String8 &>& CL_IRCConnection::sig_join  ) 
 

sig_join(nick, channel)

CL_Signal_v4<const CL_String8 &, const CL_String8 &, const CL_String8 &, const CL_String8 &>& CL_IRCConnection::sig_kick  ) 
 

sig_kick(prefix, chan, user, comment)

CL_Signal_v4<const CL_String8 &, const CL_String8 &, const CL_String8 &, const std::vector<CL_String8> &>& CL_IRCConnection::sig_mode  ) 
 

sig_mode(prefix, receiver, mode, params)

CL_Signal_v3<const CL_String8 &, const CL_String8 &, const std::vector<CL_String8> &>& CL_IRCConnection::sig_name_reply  ) 
 

sig_name_reply(self, channel, users)

CL_Signal_v2<const CL_String8 &, const CL_String8 &>& CL_IRCConnection::sig_nick  ) 
 

sig_nick(old_nick, new_nick)

CL_Signal_v3<const CL_String8 &, const CL_String8 &, const CL_String8 &>& CL_IRCConnection::sig_notice  ) 
 

sig_notice(prefix, receiver, text)

CL_Signal_v4<const CL_String8 &, const CL_String8 &, const CL_String8 &, const CL_String8 &>& CL_IRCConnection::sig_notice_ctcp  ) 
 

sig_notice_ctcp(prefix, receiver, command, data)

CL_Signal_v3<const CL_String8 &, int, const std::vector<CL_String8> &>& CL_IRCConnection::sig_numeric_reply  ) 
 

sig_numeric_reply(prefix, code, params)

CL_Signal_v3<const CL_String8 &, const CL_String8 &, const CL_String8 &>& CL_IRCConnection::sig_part  ) 
 

sig_part(nick, channel, reason)

CL_Signal_v2<const CL_String8 &, const CL_String8 &>& CL_IRCConnection::sig_ping  ) 
 

sig_ping(daemon1, daemon2)

CL_Signal_v3<const CL_String8 &, const CL_String8 &, const CL_String8 &>& CL_IRCConnection::sig_privmsg  ) 
 

sig_privmsg(prefix, receiver, text)

CL_Signal_v4<const CL_String8 &, const CL_String8 &, const CL_String8 &, const CL_String8 &>& CL_IRCConnection::sig_privmsg_ctcp  ) 
 

sig_privmsg_ctcp(prefix, receiver, command, data)

CL_Signal_v1<const CL_String &>& CL_IRCConnection::sig_socket_error  ) 
 

sig_socket_error(error_message)

CL_Signal_v3<const CL_String8 &, const CL_String8 &, const CL_String8 &>& CL_IRCConnection::sig_topic  ) 
 

sig_topic(prefix, channel, topic)

CL_Signal_v3<const CL_String8 &, const CL_String8 &, const std::vector<CL_String8> &>& CL_IRCConnection::sig_unknown_command_received  ) 
 

sig_unknown_command_received(prefix, command, params)


The documentation for this class was generated from the following file:
Generated on Thu Dec 3 02:39:38 2009 for ClanLib by  doxygen 1.4.6