The Irc::Session class provides an IRC session. More...
#include <ircsession.h>
Public Types | |
enum | Option { NoOptions = 0x0, StripNicks = 0x1, EchoMessages = 0x2 } |
Public Slots | |
void | connectToServer (const QString &hostName=QString(), quint16 port=6667) |
void | reconnectToServer () |
void | disconnectFromServer () |
bool | raw (const QString &message) |
bool | motd () |
bool | join (const QString &channel, const QString &key=QString()) |
bool | part (const QString &channel, const QString &reason=QString()) |
bool | quit (const QString &reason=QString()) |
bool | names (const QString &channel) |
bool | list (const QString &channel=QString()) |
bool | whois (const QString &nick) |
bool | whowas (const QString &nick) |
bool | mode (const QString &target, const QString &mode=QString()) |
bool | topic (const QString &channel, const QString &topic=QString()) |
bool | invite (const QString &nick, const QString &channel) |
bool | kick (const QString &nick, const QString &channel, const QString &reason=QString()) |
bool | message (const QString &receiver, const QString &message) |
bool | notice (const QString &receiver, const QString ¬ice) |
bool | ctcpAction (const QString &receiver, const QString &action) |
bool | ctcpRequest (const QString &nick, const QString &request) |
bool | ctcpReply (const QString &nick, const QString &reply) |
void | requestCapabilities (const QStringList &capabilities) |
void | clearCapabilities () |
Q_DECL_DEPRECATED bool | sendRaw (const QString &message) |
Q_DECL_DEPRECATED bool | cmdJoin (const QString &channel, const QString &key=QString()) |
Q_DECL_DEPRECATED bool | cmdPart (const QString &channel, const QString &reason=QString()) |
Q_DECL_DEPRECATED bool | cmdQuit (const QString &reason=QString()) |
Q_DECL_DEPRECATED bool | cmdNames (const QString &channel) |
Q_DECL_DEPRECATED bool | cmdList (const QString &channel=QString()) |
Q_DECL_DEPRECATED bool | cmdWhois (const QString &nick) |
Q_DECL_DEPRECATED bool | cmdMode (const QString &target, const QString &mode=QString()) |
Q_DECL_DEPRECATED bool | cmdTopic (const QString &channel, const QString &topic=QString()) |
Q_DECL_DEPRECATED bool | cmdInvite (const QString &nick, const QString &channel) |
Q_DECL_DEPRECATED bool | cmdKick (const QString &nick, const QString &channel, const QString &reason=QString()) |
Q_DECL_DEPRECATED bool | cmdMessage (const QString &receiver, const QString &message) |
Q_DECL_DEPRECATED bool | cmdNotice (const QString &receiver, const QString ¬ice) |
Q_DECL_DEPRECATED bool | cmdCtcpAction (const QString &receiver, const QString &action) |
Q_DECL_DEPRECATED bool | cmdCtcpRequest (const QString &nick, const QString &request) |
Q_DECL_DEPRECATED bool | cmdCtcpReply (const QString &nick, const QString &reply) |
Signals | |
void | connected () |
void | welcomed () |
void | reconnecting () |
void | disconnected () |
void | bufferAdded (Irc::Buffer *buffer) |
void | bufferRemoved (Irc::Buffer *buffer) |
void | capabilitiesListed (const QStringList &capabilities) |
void | capabilitiesAcked (const QStringList &capabilities) |
void | capabilitiesNotAcked (const QStringList &capabilities) |
Q_DECL_DEPRECATED void | msgJoined (const QString &origin, const QString &channel) |
Q_DECL_DEPRECATED void | msgParted (const QString &origin, const QString &channel, const QString &message) |
Q_DECL_DEPRECATED void | msgQuit (const QString &origin, const QString &message) |
Q_DECL_DEPRECATED void | msgNickChanged (const QString &origin, const QString &nick) |
Q_DECL_DEPRECATED void | msgModeChanged (const QString &origin, const QString &receiver, const QString &mode, const QString &args) |
Q_DECL_DEPRECATED void | msgTopicChanged (const QString &origin, const QString &channel, const QString &topic) |
Q_DECL_DEPRECATED void | msgInvited (const QString &origin, const QString &receiver, const QString &channel) |
Q_DECL_DEPRECATED void | msgKicked (const QString &origin, const QString &channel, const QString &nick, const QString &message) |
Q_DECL_DEPRECATED void | msgMessageReceived (const QString &origin, const QString &receiver, const QString &message) |
Q_DECL_DEPRECATED void | msgNoticeReceived (const QString &origin, const QString &receiver, const QString ¬ice) |
Q_DECL_DEPRECATED void | msgCtcpRequestReceived (const QString &origin, const QString &request) |
Q_DECL_DEPRECATED void | msgCtcpReplyReceived (const QString &origin, const QString &reply) |
Q_DECL_DEPRECATED void | msgCtcpActionReceived (const QString &origin, const QString &receiver, const QString &action) |
Q_DECL_DEPRECATED void | msgNumericMessageReceived (const QString &origin, uint code, const QStringList ¶ms) |
Q_DECL_DEPRECATED void | msgUnknownMessageReceived (const QString &origin, const QStringList ¶ms) |
Public Member Functions | |
Session (QObject *parent=0) | |
~Session () | |
QStringList | autoJoinChannels () const |
void | addAutoJoinChannel (const QString &channel) |
void | removeAutoJoinChannel (const QString &channel) |
void | setAutoJoinChannels (const QStringList &channels) |
int | autoReconnectDelay () const |
void | setAutoReconnectDelay (int seconds) |
QByteArray | encoding () const |
void | setEncoding (const QByteArray &encoding) |
QString | ident () const |
void | setIdent (const QString &ident) |
QString | nick () const |
void | setNick (const QString &nick) |
QString | password () const |
void | setPassword (const QString &password) |
QString | realName () const |
void | setRealName (const QString &realName) |
QString | host () const |
void | setHost (const QString &host) |
quint16 | port () const |
void | setPort (quint16 port) |
Options | options () const |
void | setOptions (Options options) |
QAbstractSocket * | socket () const |
void | setSocket (QAbstractSocket *socket) |
QList< Buffer * > | buffers () const |
Buffer * | buffer (const QString &receiver=QString()) const |
Buffer * | addBuffer (const QString &receiver) |
Buffer * | defaultBuffer () const |
void | setDefaultBuffer (Buffer *buffer) |
QStringList | supportedCapabilities () const |
QStringList | enabledCapabilities () const |
bool | capabilityEnabled (const QString &name) const |
Protected Member Functions | |
virtual Buffer * | createBuffer (const QString &receiver) |
IRC (Internet Relay Chat protocol) is a simple communication protocol. Irc::Session provides means to establish a connection to an IRC server. Irc::Session works asynchronously. None of the functions block the calling thread but they return immediately and the actual work is done behind the scenes in the event loop.
Example usage:
Irc::Session* session = new Irc::Session(this); session->setNick("jpnurmi"); session->setIdent("jpn"); session->setRealName("J-P Nurmi"); session->connectToServer("irc.freenode.net", 6667);
Example SSL usage:
Irc::Session* session = new Irc::Session(this); // ... QSslSocket* socket = new QSslSocket(session); socket->ignoreSslErrors(); socket->setPeerVerifyMode(QSslSocket::VerifyNone); session->setSocket(socket); session->connectToServer("irc.secure.ssl", 6669);
enum Irc::Session::Option |
This enum describes special options that may be used by Irc::Session.
NoOptions |
Clears options. |
StripNicks |
Strips origins automatically. For every IRC server message, the origin is sent in standard form: i.e. like jpnurmi!jpnurmi@xob.kapsi.fi. Such origins can not be used in IRC commands but need to be stripped (i.e. ident and host part should be cut off) before using. This can be done either explicitly, by calling Irc::Util::nickFromTarget(), or implicitly for all the messages - by setting this option with Irc::Session::setOptions(). |
EchoMessages |
Echo own messages, notices and actions. IRC servers do not echo users own messages, notices or actions. This option makes Irc::Session to echo them to ease up IRC client implementation. |
Irc::Session::Session | ( | QObject * | parent = 0 |
) |
Constructs a new IRC session with parent.
Irc::Session::~Session | ( | ) |
Destructs the IRC session.
void Irc::Session::addAutoJoinChannel | ( | const QString & | channel | ) |
Adds channel to the list of auto-join channels.
Buffer * Irc::Session::addBuffer | ( | const QString & | receiver | ) |
Adds a buffer for receiver and returns it.
QStringList Irc::Session::autoJoinChannels | ( | ) | const |
Returns the list of auto-join channels.
int Irc::Session::autoReconnectDelay | ( | ) | const |
Returns the auto-reconnecting delay.
A negative value means no auto-reconnecting.
The default value is -1
.
Buffer * Irc::Session::buffer | ( | const QString & | receiver = QString() |
) | const |
Returns the buffer for receiver. Returns 0
if the buffer does not exist.
void Irc::Session::bufferAdded | ( | Irc::Buffer * | buffer | ) | [signal] |
This signal is emitted whenever a buffer was added.
void Irc::Session::bufferRemoved | ( | Irc::Buffer * | buffer | ) | [signal] |
This signal is emitted whenever a buffer was removed.
void Irc::Session::capabilitiesAcked | ( | const QStringList & | capabilities | ) | [signal] |
This signal is emitted when the server acknowledges the use of a previously requested list of capabilities. Note that if you request a list of capabilities, either all of them will be acked, or all of them will be nacked.
void Irc::Session::capabilitiesListed | ( | const QStringList & | capabilities | ) | [signal] |
This signal is emitted when the library receives a list of supported capabilities for this session.
void Irc::Session::capabilitiesNotAcked | ( | const QStringList & | capabilities | ) | [signal] |
This signal is emitted when the server disacknowledges enabling a previously requested list of capabilities. This means that none of the requested capabilities will be enabled, even if some of them were valid. (Any previously enabled capabilities will still be enabled.)
bool Irc::Session::capabilityEnabled | ( | const QString & | name | ) | const |
Returns whether a capability is enabled for this session.
If you give modifier names along with the name (i.e. '=' or '~'), this method will remove them; it will match them to any name delivered by the server, whether or not it sends any modifiers along. Behaviour when including the 'disabled modifier' ('-') is undefined; you should negate the return value of this method instead.
Note: This does not include the network specific modifier (i.e. '.'). For example, =identify-msg matches ~IDENTIFY-MSG but not .identify-msg.
void Irc::Session::clearCapabilities | ( | ) | [slot] |
Clear all non-sticky capabilities for this session.
bool Irc::Session::cmdCtcpAction | ( | const QString & | receiver, | |
const QString & | action | |||
) | [slot] |
bool Irc::Session::cmdCtcpReply | ( | const QString & | nick, | |
const QString & | reply | |||
) | [slot] |
bool Irc::Session::cmdCtcpRequest | ( | const QString & | nick, | |
const QString & | request | |||
) | [slot] |
bool Irc::Session::cmdInvite | ( | const QString & | nick, | |
const QString & | channel | |||
) | [slot] |
bool Irc::Session::cmdJoin | ( | const QString & | channel, | |
const QString & | key = QString() | |||
) | [slot] |
bool Irc::Session::cmdKick | ( | const QString & | nick, | |
const QString & | channel, | |||
const QString & | reason = QString() | |||
) | [slot] |
bool Irc::Session::cmdList | ( | const QString & | channel = QString() |
) | [slot] |
bool Irc::Session::cmdMessage | ( | const QString & | receiver, | |
const QString & | message | |||
) | [slot] |
bool Irc::Session::cmdMode | ( | const QString & | target, | |
const QString & | mode = QString() | |||
) | [slot] |
bool Irc::Session::cmdNames | ( | const QString & | channel | ) | [slot] |
bool Irc::Session::cmdNotice | ( | const QString & | receiver, | |
const QString & | notice | |||
) | [slot] |
bool Irc::Session::cmdPart | ( | const QString & | channel, | |
const QString & | reason = QString() | |||
) | [slot] |
bool Irc::Session::cmdQuit | ( | const QString & | reason = QString() |
) | [slot] |
bool Irc::Session::cmdTopic | ( | const QString & | channel, | |
const QString & | topic = QString() | |||
) | [slot] |
bool Irc::Session::cmdWhois | ( | const QString & | nick | ) | [slot] |
void Irc::Session::connected | ( | ) | [signal] |
This signal is emitted after a connection has been successfully established.
void Irc::Session::connectToServer | ( | const QString & | hostName = QString() , |
|
quint16 | port = 6667 | |||
) | [slot] |
Connects to server with hostName and port.
Buffer * Irc::Session::createBuffer | ( | const QString & | receiver | ) | [protected, virtual] |
Returns a new Irc::Buffer object to act as an IRC buffer for receiver.
This virtual factory method can be overridden for example in order to make Irc::Session use a subclass of Irc::Buffer.
bool Irc::Session::ctcpAction | ( | const QString & | receiver, | |
const QString & | action | |||
) | [slot] |
Sends a CTCP action to receiver.
bool Irc::Session::ctcpReply | ( | const QString & | nick, | |
const QString & | reply | |||
) | [slot] |
Sends a CTCP reply to receiver.
bool Irc::Session::ctcpRequest | ( | const QString & | nick, | |
const QString & | request | |||
) | [slot] |
Sends a CTCP request to receiver.
Buffer * Irc::Session::defaultBuffer | ( | ) | const |
Returns the default buffer.
void Irc::Session::disconnected | ( | ) | [signal] |
This signal is emitted when the session has been disconnected.
void Irc::Session::disconnectFromServer | ( | ) | [slot] |
Disconnects from the server.
QStringList Irc::Session::enabledCapabilities | ( | ) | const |
Returns the list of enabled capabilities for this session, as reported by the server (including any modifiers).
QByteArray Irc::Session::encoding | ( | ) | const |
Returns the encoding.
The default value is a null QByteArray.
QString Irc::Session::host | ( | ) | const |
Returns the host.
QString Irc::Session::ident | ( | ) | const |
Returns the ident.
bool Irc::Session::invite | ( | const QString & | nick, | |
const QString & | channel | |||
) | [slot] |
Sends an invitation to nick.
bool Irc::Session::join | ( | const QString & | channel, | |
const QString & | key = QString() | |||
) | [slot] |
Joins channel with optional key.
bool Irc::Session::kick | ( | const QString & | nick, | |
const QString & | channel, | |||
const QString & | reason = QString() | |||
) | [slot] |
Kicks nick from channel with reason.
bool Irc::Session::list | ( | const QString & | channel = QString() |
) | [slot] |
Requests the list of channels.
bool Irc::Session::message | ( | const QString & | receiver, | |
const QString & | message | |||
) | [slot] |
Sends a message to receiver.
bool Irc::Session::mode | ( | const QString & | target, | |
const QString & | mode = QString() | |||
) | [slot] |
Sends a mode command on target.
bool Irc::Session::motd | ( | ) | [slot] |
Requests message of the day.
Q_DECL_DEPRECATED void Irc::Session::msgCtcpActionReceived | ( | const QString & | origin, | |
const QString & | receiver, | |||
const QString & | action | |||
) | [signal] |
Q_DECL_DEPRECATED void Irc::Session::msgCtcpReplyReceived | ( | const QString & | origin, | |
const QString & | reply | |||
) | [signal] |
Q_DECL_DEPRECATED void Irc::Session::msgCtcpRequestReceived | ( | const QString & | origin, | |
const QString & | request | |||
) | [signal] |
Q_DECL_DEPRECATED void Irc::Session::msgInvited | ( | const QString & | origin, | |
const QString & | receiver, | |||
const QString & | channel | |||
) | [signal] |
Q_DECL_DEPRECATED void Irc::Session::msgJoined | ( | const QString & | origin, | |
const QString & | channel | |||
) | [signal] |
Q_DECL_DEPRECATED void Irc::Session::msgKicked | ( | const QString & | origin, | |
const QString & | channel, | |||
const QString & | nick, | |||
const QString & | message | |||
) | [signal] |
Q_DECL_DEPRECATED void Irc::Session::msgMessageReceived | ( | const QString & | origin, | |
const QString & | receiver, | |||
const QString & | message | |||
) | [signal] |
Q_DECL_DEPRECATED void Irc::Session::msgModeChanged | ( | const QString & | origin, | |
const QString & | receiver, | |||
const QString & | mode, | |||
const QString & | args | |||
) | [signal] |
Q_DECL_DEPRECATED void Irc::Session::msgNickChanged | ( | const QString & | origin, | |
const QString & | nick | |||
) | [signal] |
Q_DECL_DEPRECATED void Irc::Session::msgNoticeReceived | ( | const QString & | origin, | |
const QString & | receiver, | |||
const QString & | notice | |||
) | [signal] |
Q_DECL_DEPRECATED void Irc::Session::msgNumericMessageReceived | ( | const QString & | origin, | |
uint | code, | |||
const QStringList & | params | |||
) | [signal] |
Q_DECL_DEPRECATED void Irc::Session::msgParted | ( | const QString & | origin, | |
const QString & | channel, | |||
const QString & | message | |||
) | [signal] |
Q_DECL_DEPRECATED void Irc::Session::msgQuit | ( | const QString & | origin, | |
const QString & | message | |||
) | [signal] |
Q_DECL_DEPRECATED void Irc::Session::msgTopicChanged | ( | const QString & | origin, | |
const QString & | channel, | |||
const QString & | topic | |||
) | [signal] |
Q_DECL_DEPRECATED void Irc::Session::msgUnknownMessageReceived | ( | const QString & | origin, | |
const QStringList & | params | |||
) | [signal] |
bool Irc::Session::names | ( | const QString & | channel | ) | [slot] |
Requests the list of names on channel.
QString Irc::Session::nick | ( | ) | const |
Returns the nick.
bool Irc::Session::notice | ( | const QString & | receiver, | |
const QString & | notice | |||
) | [slot] |
Sends a notice to receiver.
Session::Options Irc::Session::options | ( | ) | const |
Returns the options.
The default value is StripNicks
.
bool Irc::Session::part | ( | const QString & | channel, | |
const QString & | reason = QString() | |||
) | [slot] |
Parts channel with reason.
QString Irc::Session::password | ( | ) | const |
Returns the password.
quint16 Irc::Session::port | ( | ) | const |
Returns the port.
bool Irc::Session::quit | ( | const QString & | reason = QString() |
) | [slot] |
Quits with optional reason.
bool Irc::Session::raw | ( | const QString & | message | ) | [slot] |
Sends a raw message to the server.
QString Irc::Session::realName | ( | ) | const |
Returns the real name.
void Irc::Session::reconnecting | ( | ) | [signal] |
This signal is emitted when the session is about to reconnect.
void Irc::Session::reconnectToServer | ( | ) | [slot] |
Reconnects to server.
void Irc::Session::removeAutoJoinChannel | ( | const QString & | channel | ) |
Removes channels from the list of auto-join channels.
void Irc::Session::requestCapabilities | ( | const QStringList & | capabilities | ) | [slot] |
Requests a capability in the server.
bool Irc::Session::sendRaw | ( | const QString & | message | ) | [slot] |
void Irc::Session::setAutoJoinChannels | ( | const QStringList & | channels | ) |
Sets the list of auto-join channels.
void Irc::Session::setAutoReconnectDelay | ( | int | seconds | ) |
Sets auto-reconnecting delay in seconds.
void Irc::Session::setDefaultBuffer | ( | Buffer * | buffer | ) |
Sets the default buffer.
void Irc::Session::setEncoding | ( | const QByteArray & | encoding | ) |
Sets the encoding.
See QTextCodec documentation for supported encodings.
Encoding auto-detection can be turned on by passing a null QByteArray.
The fallback locale is QTextCodec::codecForLocale().
void Irc::Session::setHost | ( | const QString & | host | ) |
Sets the host.
void Irc::Session::setIdent | ( | const QString & | ident | ) |
Sets the ident.
void Irc::Session::setNick | ( | const QString & | nick | ) |
Sets the nick.
void Irc::Session::setOptions | ( | Options | options | ) |
Sets the options.
void Irc::Session::setPassword | ( | const QString & | password | ) |
Sets the password.
void Irc::Session::setPort | ( | quint16 | port | ) |
Sets the port.
void Irc::Session::setRealName | ( | const QString & | realName | ) |
Sets the realName.
void Irc::Session::setSocket | ( | QAbstractSocket * | socket | ) |
Sets the socket. The previously set socket is deleted if its parent is this
.
Irc::Session supports QSslSocket in the way that it automatically calls QSslSocket::startClientEncryption() while connecting.
This function was introduced in version 0.3.0.
QAbstractSocket * Irc::Session::socket | ( | ) | const |
Returns the socket.
Irc::Session creates an instance of QTcpSocket by default.
This function was introduced in version 0.3.0.
QStringList Irc::Session::supportedCapabilities | ( | ) | const |
Returns the list of capabilities the server supports, as reported by the server (including any modifiers). If empty, the server might not implement the capabilities extension, or it might simply not support any specific capability.
bool Irc::Session::topic | ( | const QString & | channel, | |
const QString & | topic = QString() | |||
) | [slot] |
Sends a topic command on channel.
void Irc::Session::welcomed | ( | ) | [signal] |
This signal is emitted when the welcome message has been received.
bool Irc::Session::whois | ( | const QString & | nick | ) | [slot] |
Sends a whois command on nick.
bool Irc::Session::whowas | ( | const QString & | nick | ) | [slot] |
Sends a whowas command on nick.