|
|
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:
serverName | Hostname or IP of the server to connect to. |
serverPort | TCP port to use to establish connection. |
nick | Nickname to give the server when connecting. If that nickname is in use, the IRCModule will use variations on the nick until it can connect. |
ident | Ident to use when connecting. If you have identd active, this value will be ignored by the server. |
realName | Text 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:
dest | Nickname or channel to send the message to. |
text | Message 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:
dest | Nickname or channel to send the notice to. |
text | Notice 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:
mode | The mode to set. |
bool isConnected () |
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:
channel | Name of the channel to join. |
key | Key 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:
channel | Name 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 () |
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 () |
Get the current nickname of the client.
Returns: The current client's nickname.
bool isChannelName (const QString& nick) |
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) |
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) |
an onConnect signal is emitted when the client succesfully connected to a server.
Parameters:
serverName | The name of the server to which the connection was established. |
nickname | The nick of the client on that server. |
void onChannelCTCP (QString nick,const Channel* channel, QString ctcpType, QString ctcpText) |
Emitted when a user sends a CTCP request to a channel the client is on.
Note: CTCP's include ACTIONs.
Parameters:
nick | The nickname of the user who sent the CTCP. |
channel | A pointer to the channel to which the CTCP was sent. |
ctcpType | A string containing the CTCP's "type" (VERSION, PING, ACTION, etc). |
ctcpText | A string containing the rest of the CTCP request. In other words, any text after CTCP type is contained in the ctcpText parameter. |
void onCTCPReply (QString nuh,QString dest, QString ctcpType, QString ctcpText) |
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:
nuh | nick!user@host of the user sending the reply. |
dest | nick or channel to which the reply was sent. |
ctcpType | CTCP type of the reply, e.g. PING, VERSION, etc. |
ctcpText | Parameters of the reply. |
void onChannelText (QString nick,const Channel* channel, QString text) |
Emitted when a user sends a regular message (PRIVMSG) to a channel the client is on.
Note: This event does not include notices.
Parameters:
nick | The nickname of the user who sent the channel message. |
channel | A pointer to the channel to which the message was sent. |
text | A string containing the text of the message. |
void onChannelNotice (QString nick,const Channel* channel, QString text) |
Emitted when a user sends a notice to a channel the client is on.
Parameters:
nick | The nickname of the user who sent the notice. |
channel | A pointer to the channel to which the notice was sent. |
text | A string containing the text of the notice. |
void onDisconnect () |
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) |
Emitted when the client receives an ERROR message from the server. Such messages include K-lines, kills, server full, etc.
Parameters:
errorMessage | A string containing the full text the server included with the ERROR message. |
void onJoin (QString nick,const Channel* channel) |
Emitted when a user joins a channel. This signal is also emitted when the client joins a channel through the join() method.
Parameters:
nick | The nickname of the user who joined. |
channel | A pointer to the channel on which the join occured. |
void onKick (QString from, const Channel* channel, QString kicked, QString comment) |
Emitted when a user is kicked from a channel.
Parameters:
from | The nick of the user who sent the kick. Note that this can also be a server name. |
channel | A 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. |
kicked | The nickname of the user who got kicked. |
comment | The kick comment. |
void onNickChange (QString nick,QString newNick) |
Emitted when a user on a common channel with the client, or the client itself changes nicknames.
Parameters:
nick | The previous nick of the user. |
newNick | The new nick of the user. |
void onPart (QString nick,const Channel* channel,QString comment) |
Emitted when a user parts a channel. This signal is also emitted when the client parts a channel through the part() method.
Parameters:
nick | The nickname of the user who left the channel |
channel | A pointer to the channel on which the join occured. |
comment | A string containing the part comment, if any. |
void onPrivateCTCP (QString nick,QString ctcpType, QString ctcpText) |
Emitted when a user sends a CTCP request to the client directly (not a channel the client is on).
Parameters:
nick | The nickname of the user sending the CTCP request. |
ctcpType | A string containing the type of the CTCP request (VERSION, PING, etc). |
ctcpText | Any text after the ctcpType will be included in this string. |
See also: onChannelCTCP
void onPrivateText (QString nuh,QString text) |
Emitted when a user sends a private message to the client directly (not a channel the client is on).
Parameters:
nuh | The nick!user@host of the user sending the message. |
text | The text contained in the message. |
See also: onChannelText
void onPrivateNotice (QString nuh,QString text) |
Emitted when a user sends a private notice to the client directly (not a channel the client is on).
Parameters:
nuh | The nick!user@host of the user sending the notice. |
text | The text contained in the notice. |
See also: onChannelNotice
void onServerNotice (QString serverName,QString text) |
Emitted when the client recieves a notice from the server.
Parameters:
serverName | The name of the server sending the notice. |
text | The text contained in the notice. |
void onPing () |
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) |
Emitted when a user on a common channel with the client quits IRC.
Parameters:
nuh | nick!username@host of the user that left IRC. |
comment | The quit message. |
void onRawNumeric (int numeric, const IRCMessage& message) |
Emitted when a numeric reply is received from the server.
Parameters:
numeric | The numeric number of the reply. see numeric.h |
message | a raw IRCMessage containing the reply as recieved from the server. |
void onUserModeChange (QString mode) |
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:
mode | A string containing the mode change, as recieved from the server. |
void onBan (QString from, const Channel* channel, QString mask) |
Emitted on a mode +b on a channel.
Parameters:
from | A string containing the nick of the user who set the mode, or the name of the server in case of the server mode. |
channel | A pointer to the channel on which the mode change occured. |
mask | A string containing the ban mask that was added. |
void onUnban (QString from, const Channel* channel, QString mask) |
Emitted on a mode -b on a channel.
Parameters:
from | A string containing the nick of the user who set the mode, or the name of the server in case of the server mode. |
channel | A pointer to the channel on which the mode change occured. |
mask | A string containing the ban mask that was removed. |
void onOp (QString from,const Channel* channel, const ChanUser* dest) |
Emitted on mode +o on a channel.
Parameters:
from | A string containing the nick of the user who set the mode, or the name of the server in case of a server mode. |
channel | A pointer the the channel on which the mode change occured. |
dest | A pointer to the ChanUser object of the user who was given ops. |
void onDeop (QString from,const Channel* channel, const ChanUser* dest) |
Emitted on mode -o on a channel.
Parameters:
from | A string containing the nick of the user who set the mode, or the name of the server in case of a server mode. |
channel | A pointer the the channel on which the mode change occured. |
dest | A pointer to the ChanUser object of the user who was deoped. |
void onVoice (QString from,const Channel* channel, const ChanUser* dest) |
Emitted on mode +v on a channel.
Parameters:
from | A string containing the nick of the user who set the mode, or the name of the server in case of a server mode. |
channel | A pointer the the channel on which the mode change occured. |
dest | A pointer to the ChanUser object of the user who was voiced. |
void onDevoice (QString from,const Channel* channel, const ChanUser* dest) |
Emitted on mode -v on a channel.
Parameters:
from | A string containing the nick of the user who set the mode, or the name of the server in case of a server mode. |
channel | A pointer the the channel on which the mode change occured. |
dest | A pointer to the ChanUser object of the user who was devoiced. |
void onChanModeChange (QString from,const Channel* channel, QString mode) |
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:
from | A 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. |
mode | A 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) |
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:
from | A 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. |
channel | A pointer the the channel on which the mode change occured. |
mode | A string containing the mode change, exactly as recieved from the server. |