class IRCModule

Handle a client connection to an Internet Relay Chat Server. More...

Definition#include <IRCModule.h>
InheritsQObject
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Signals

Public Static Methods


Detailed Description

Handles a client-side connection to an IRC server. This class uses various signals to notify other objects of events that occured on the IRC connection, such as joins, parts, quits, etc. It uses a ClientSocket as its communication link to the server.

NOTE: In this page, the "client" refers to the object currently being used as a connection to an IRC server. a "user" refers to any user on IRC, wether the client or another user.

See also: ClientSocket, Channels, Channel, ChanUser, Ban

bool connectTo (QString serverName, int serverPort, QString nick, QString ident, QString realName)

Attempt to connect to the specified server and port, with nickname and ident specified by values in parameter.

If the connect is succesful, a onConnect event is generated. Note that a connection could be succesful, but the client disconnected afterwards, for instance if it is K-lined. In that case, an onConnected event will be generated, followed by an onDisconnect event when the server breaks the connection.

PRECONDITIONS: !isConnected() ; serverName != "" ; serverPort > 1024 ; nick != "" ; ident != "" ; realName != ""

Parameters:
serverNameHostname or IP of the server to connect to.
serverPortTCP port to use to establish connection.
nickNickname to give the server when connecting. If that nickname is in use, the IRCModule will use variations on the nick until it can connect.
identIdent to use when connecting. If you have identd active, this value will be ignored by the server.
realNameText to be placed in the client's real name field.

Returns: true if a connection was established, false otherwise.

void setMode (QString channel, QString mode)

Set a specified mode on a channel. No checking is done on the mode, so it should be a mode the server can understand. The mode will also be sent regardless if the client is currently oped or not on that channel.

PRECONDITIONS: isConnected()

void sendPrivmsg (QString dest, QString text)

Send text to dest in PRIVMSG format. Use this method to send text to both channels and users.

PRECONDITIONS: isConnected()

Parameters:
destNickname or channel to send the message to.
textMessage text to send to the destination.

void sendNotice (QString dest, QString text)

Send text to dest in NOTICE format. Use this method to send text to both channels and users (although NOTICE'ing whole channels is usually not a good idea)

PRECONDITIONS: isConnected()

Parameters:
destNickname or channel to send the notice to.
textNotice text to send to the destination.

void setUserMode (QString mode)

Set a specified user mode on the client.

User modes are not supported by the IRCModule, but it provides functionality for clients to support it.

Parameters:
modeThe mode to set.

bool isConnected ()
[const]

Determine wether a succesful connection is currently active with an IRC server.

Returns: true if the client is currently connected to a server, false otherwise.

void join (QString channel, QString key = "")

Make the client join a specified channel with a key if necessary. This method only sends the join command. an onJoin() event will be generated if its succesful, or the appropriate error numerics returned in an onNumeric() event.

Requesting to join a channel that was already joined is an error.

PRECONDITIONS: isConnected() ; !isOn(channel)

Parameters:
channelName of the channel to join.
keyKey to use to join the channel, if required.

void part (QString channel, QString partComment = "")

Request that the client leave a channel in which it currently is.

PRECONDITIONS : isConnected() ; isOn(channel)

Parameters:
channelName of the channel to part. @partComment Part comment to use, if desired.

bool isOn (QString channel)

Determine if the client is currently on a particular channel.

PRECONDITIONS: isConnected()

Returns: true if the client is currently on the specified channel, false otherwise.

void quit (QString quitComment = "Leaving")

Make the client quit IRC with the comment specified. The comment "Leaving" is used if no comment if given.

PRECONDITIONS: isConnected()

bool isOpedOn (QString channel)

Determines if the client is currently oped on a specified channel. the client must be in that channel before calling this method.

PRECONDITIONS: isConnected() ; isOn(channel)

Returns: true if the client is oped on the given channel, false otherwise.

const Channels& channels ()
[const]

Access the client's internal channel list. This list contains information about the channels the client is on, including channel modes, userlists, user hosts if available, etc.

Returns: A const reference to the internal channel list.

See also: Channels

const QString& getNick ()
[const]

Get the current nickname of the client.

Returns: The current client's nickname.

bool isChannelName (const QString& nick)
[static]

Determine if a string is a valid channel name. A channel name is valid if it begins with either a #, & or + and it does not contain any whitespace.

Returns: true if the string is a valid channel name, false otherwise.

bool isServerName (const QString& name)
[static]

Determine if a string is a valid server name. A server name contains at least one '.'.

Returns: true if the string is a valid server name, false otherwise.

void onConnect (QString serverName, QString nickname)
[signal]

an onConnect signal is emitted when the client succesfully connected to a server.

Parameters:
serverNameThe name of the server to which the connection was established.
nicknameThe nick of the client on that server.

void onChannelCTCP (QString nick,const Channel* channel, QString ctcpType, QString ctcpText)
[signal]

Emitted when a user sends a CTCP request to a channel the client is on.

Note: CTCP's include ACTIONs.

Parameters:
nickThe nickname of the user who sent the CTCP.
channelA pointer to the channel to which the CTCP was sent.
ctcpTypeA string containing the CTCP's "type" (VERSION, PING, ACTION, etc).
ctcpTextA string containing the rest of the CTCP request. In other words, any text after CTCP type is contained in the ctcpText parameter.

See also: ChanUser, Channel

void onCTCPReply (QString nuh,QString dest, QString ctcpType, QString ctcpText)
[signal]

Emitted when the client receives a CTCP reply.

This signal applies for replies directed to channels AND private replies. The dest parameter specifies where the reply was sent to.

Note: channel-wide ctcp replies are unlikely.

Parameters:
nuhnick!user@host of the user sending the reply.
destnick or channel to which the reply was sent.
ctcpTypeCTCP type of the reply, e.g. PING, VERSION, etc.
ctcpTextParameters of the reply.

void onChannelText (QString nick,const Channel* channel, QString text)
[signal]

Emitted when a user sends a regular message (PRIVMSG) to a channel the client is on.

Note: This event does not include notices.

Parameters:
nickThe nickname of the user who sent the channel message.
channelA pointer to the channel to which the message was sent.
textA string containing the text of the message.

See also: ChanUser, Channel

void onChannelNotice (QString nick,const Channel* channel, QString text)
[signal]

Emitted when a user sends a notice to a channel the client is on.

Parameters:
nickThe nickname of the user who sent the notice.
channelA pointer to the channel to which the notice was sent.
textA string containing the text of the notice.

void onDisconnect ()
[signal]

Emitted when the client is disconnected from the server. This signal will be emitted when the connection terminates, regardless of the cause of disconnection. Calling quit() results in an onDisconnect event when the server drops the connection.

void onError (QString errorMessage)
[signal]

Emitted when the client receives an ERROR message from the server. Such messages include K-lines, kills, server full, etc.

Parameters:
errorMessageA string containing the full text the server included with the ERROR message.

void onJoin (QString nick,const Channel* channel)
[signal]

Emitted when a user joins a channel. This signal is also emitted when the client joins a channel through the join() method.

Parameters:
nickThe nickname of the user who joined.
channelA pointer to the channel on which the join occured.

See also: ChanUser, Channel

void onKick (QString from, const Channel* channel, QString kicked, QString comment)
[signal]

Emitted when a user is kicked from a channel.

Parameters:
fromThe nick of the user who sent the kick. Note that this can also be a server name.
channelA pointer to the channel on which the kick occured. If the user getting kicked is the client, that pointer is no longer valid outside the scope of this event.
kickedThe nickname of the user who got kicked.
commentThe kick comment.

void onNickChange (QString nick,QString newNick)
[signal]

Emitted when a user on a common channel with the client, or the client itself changes nicknames.

Parameters:
nickThe previous nick of the user.
newNickThe new nick of the user.

void onPart (QString nick,const Channel* channel,QString comment)
[signal]

Emitted when a user parts a channel. This signal is also emitted when the client parts a channel through the part() method.

Parameters:
nickThe nickname of the user who left the channel
channelA pointer to the channel on which the join occured.
commentA string containing the part comment, if any.

void onPrivateCTCP (QString nick,QString ctcpType, QString ctcpText)
[signal]

Emitted when a user sends a CTCP request to the client directly (not a channel the client is on).

Parameters:
nickThe nickname of the user sending the CTCP request.
ctcpTypeA string containing the type of the CTCP request (VERSION, PING, etc).
ctcpTextAny text after the ctcpType will be included in this string.

See also: onChannelCTCP

void onPrivateText (QString nuh,QString text)
[signal]

Emitted when a user sends a private message to the client directly (not a channel the client is on).

Parameters:
nuhThe nick!user@host of the user sending the message.
textThe text contained in the message.

See also: onChannelText

void onPrivateNotice (QString nuh,QString text)
[signal]

Emitted when a user sends a private notice to the client directly (not a channel the client is on).

Parameters:
nuhThe nick!user@host of the user sending the notice.
textThe text contained in the notice.

See also: onChannelNotice

void onServerNotice (QString serverName,QString text)
[signal]

Emitted when the client recieves a notice from the server.

Parameters:
serverNameThe name of the server sending the notice.
textThe text contained in the notice.

void onPing ()
[signal]

Emitted when the client recieves a PING request from the server. The IRCModule replies to PING requests properly. There is no need to manually send a PONG reply when this signal occurs.

void onQuit (QString nuh, QString comment)
[signal]

Emitted when a user on a common channel with the client quits IRC.

Parameters:
nuhnick!username@host of the user that left IRC.
commentThe quit message.

void onRawNumeric (int numeric, const IRCMessage& message)
[signal]

Emitted when a numeric reply is received from the server.

Parameters:
numericThe numeric number of the reply. see numeric.h
messagea raw IRCMessage containing the reply as recieved from the server.

void onUserModeChange (QString mode)
[signal]

Emitted when a user mode change is recieved. The IRCModule does not handle user modes, but provides this signal to allow clients to keep up to date with the current user modes.

Parameters:
modeA string containing the mode change, as recieved from the server.

void onBan (QString from, const Channel* channel, QString mask)
[signal]

Emitted on a mode +b on a channel.

Parameters:
fromA string containing the nick of the user who set the mode, or the name of the server in case of the server mode.
channelA pointer to the channel on which the mode change occured.
maskA string containing the ban mask that was added.

void onUnban (QString from, const Channel* channel, QString mask)
[signal]

Emitted on a mode -b on a channel.

Parameters:
fromA string containing the nick of the user who set the mode, or the name of the server in case of the server mode.
channelA pointer to the channel on which the mode change occured.
maskA string containing the ban mask that was removed.

void onOp (QString from,const Channel* channel, const ChanUser* dest)
[signal]

Emitted on mode +o on a channel.

Parameters:
fromA string containing the nick of the user who set the mode, or the name of the server in case of a server mode.
channelA pointer the the channel on which the mode change occured.
destA pointer to the ChanUser object of the user who was given ops.

void onDeop (QString from,const Channel* channel, const ChanUser* dest)
[signal]

Emitted on mode -o on a channel.

Parameters:
fromA string containing the nick of the user who set the mode, or the name of the server in case of a server mode.
channelA pointer the the channel on which the mode change occured.
destA pointer to the ChanUser object of the user who was deoped.

void onVoice (QString from,const Channel* channel, const ChanUser* dest)
[signal]

Emitted on mode +v on a channel.

Parameters:
fromA string containing the nick of the user who set the mode, or the name of the server in case of a server mode.
channelA pointer the the channel on which the mode change occured.
destA pointer to the ChanUser object of the user who was voiced.

void onDevoice (QString from,const Channel* channel, const ChanUser* dest)
[signal]

Emitted on mode -v on a channel.

Parameters:
fromA string containing the nick of the user who set the mode, or the name of the server in case of a server mode.
channelA pointer the the channel on which the mode change occured.
destA pointer to the ChanUser object of the user who was devoiced.

void onChanModeChange (QString from,const Channel* channel, QString mode)
[signal]

Emitted on channel-specific modes (t,n,m,i,l,k,s,p). This signal is emitted once per mode change. For instance, a mode +tn generates two onChanModeChange signals, one for +t, and one for +n

Parameters:
fromA string containing the nick!user@host of the user who set the mode, or the name of the server in case of a server mode.
modeA string containing the mode change. The mode is preceded by a '+' if the mode was added, or a '-' if the mode was removed.

void onRawChannelMode (QString from, const Channel* channel, QString mode)
[signal]

Emitted on any channel mode change, once per MODE message received from the server. This signal is provided for clients who want to display the mode change in one string, as recieved from the server.

Parameters:
fromA string containing the nick!user@host of the user who set the mode, or the name of the server in case of a server mode.
channelA pointer the the channel on which the mode change occured.
modeA string containing the mode change, exactly as recieved from the server.