Irc::Session Class Reference

The Irc::Session class provides an IRC session. More...

#include <ircsession.h>

List of all members.

Public Types

enum  Option { StripNicks = 0x1 }

Public Slots

void setNick (const QString &nick)
void connectToServer (const QString &hostName, quint16 port=6667)
void connectToServer (const QHostAddress &address, quint16 port=6667)
void disconnectFromServer ()
bool sendRaw (const QString &message)
bool cmdJoin (const QString &channel, const QString &key=QString())
bool cmdPart (const QString &channel, const QString &reason=QString())
bool cmdQuit (const QString &reason=QString())
bool cmdNames (const QString &channel)
bool cmdList (const QString &channel=QString())
bool cmdWhois (const QString &nick)
bool cmdMode (const QString &target, const QString &mode=QString())
bool cmdTopic (const QString &channel, const QString &topic=QString())
bool cmdInvite (const QString &nick, const QString &channel)
bool cmdKick (const QString &nick, const QString &channel, const QString &reason=QString())
bool cmdMessage (const QString &receiver, const QString &message)
bool cmdNotice (const QString &receiver, const QString &notice)
bool cmdCtcpAction (const QString &receiver, const QString &action)
bool cmdCtcpRequest (const QString &nick, const QString &request)
bool cmdCtcpReply (const QString &nick, const QString &reply)

Signals

void connected ()
void disconnected ()
void msgJoined (const QString &origin, const QString &channel)
void msgParted (const QString &origin, const QString &channel, const QString &message)
void msgQuit (const QString &origin, const QString &message)
void msgNickChanged (const QString &origin, const QString &nick)
void msgModeChanged (const QString &origin, const QString &receiver, const QString &mode, const QString &args)
void msgTopicChanged (const QString &origin, const QString &channel, const QString &topic)
void msgInvited (const QString &origin, const QString &receiver, const QString &channel)
void msgKicked (const QString &origin, const QString &channel, const QString &nick, const QString &message)
void msgMessageReceived (const QString &origin, const QString &receiver, const QString &message)
void msgNoticeReceived (const QString &origin, const QString &receiver, const QString &notice)
void msgCtcpRequestReceived (const QString &origin, const QString &request)
void msgCtcpReplyReceived (const QString &origin, const QString &reply)
void msgCtcpActionReceived (const QString &origin, const QString &receiver, const QString &action)
void msgNumericMessageReceived (const QString &origin, uint code, const QStringList &params)
void msgUnknownMessageReceived (const QString &origin, const QStringList &params)

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
QString password () const
void setPassword (const QString &password)
QString realName () const
void setRealName (const QString &realName)
QString host () const
quint16 port () const
Options options () const
void setOptions (Options options)
void connectSlotsByName (const QObject *receiver)
bool isConnected () const
QAbstractSocket * socket () const
void setSocket (QAbstractSocket *socket)


Detailed Description

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);

Note:
Irc::Session supports SSL (Secure Sockets Layer) connections since version 0.3.0
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);

See also:
setSocket()

Member Enumeration Documentation

This enum describes special options that may be used by Irc::Session.

Enumerator:
StripNicks  Strips origins automatically.

For every IRC server message, the origin is sent in standard form:

i.e. like jpnurmi!jaxr@jolt.modeemi.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::setOption().


Constructor & Destructor Documentation

Irc::Session::Session ( QObject *  parent = 0  ) 

Constructs a new IRC session with parent.

Irc::Session::~Session (  ) 

Destructs the IRC session.


Member Function Documentation

void Irc::Session::addAutoJoinChannel ( const QString &  channel  ) 

Adds channel to the list of auto-join channels.

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.

bool Irc::Session::cmdCtcpAction ( const QString &  receiver,
const QString &  action 
) [slot]

Sends a CTCP action to receiver.

bool Irc::Session::cmdCtcpReply ( const QString &  nick,
const QString &  reply 
) [slot]

Sends a CTCP reply to receiver.

bool Irc::Session::cmdCtcpRequest ( const QString &  nick,
const QString &  request 
) [slot]

Sends a CTCP request to receiver.

bool Irc::Session::cmdInvite ( const QString &  nick,
const QString &  channel 
) [slot]

Sends an invitation to nick.

bool Irc::Session::cmdJoin ( const QString &  channel,
const QString &  key = QString() 
) [slot]

Joins channel with optional key.

bool Irc::Session::cmdKick ( const QString &  nick,
const QString &  channel,
const QString &  reason = QString() 
) [slot]

Kicks nick from channel with reason.

bool Irc::Session::cmdList ( const QString &  channel = QString()  )  [slot]

Requests the list of channels.

bool Irc::Session::cmdMessage ( const QString &  receiver,
const QString &  message 
) [slot]

Sends a message to receiver.

bool Irc::Session::cmdMode ( const QString &  target,
const QString &  mode = QString() 
) [slot]

Sends a mode command on target.

bool Irc::Session::cmdNames ( const QString &  channel  )  [slot]

Requests the list of names on channel.

bool Irc::Session::cmdNotice ( const QString &  receiver,
const QString &  notice 
) [slot]

Sends a notice to receiver.

bool Irc::Session::cmdPart ( const QString &  channel,
const QString &  reason = QString() 
) [slot]

Parts channel with reason.

bool Irc::Session::cmdQuit ( const QString &  reason = QString()  )  [slot]

Quits with optional reason.

bool Irc::Session::cmdTopic ( const QString &  channel,
const QString &  topic = QString() 
) [slot]

Sends a topic command on channel.

bool Irc::Session::cmdWhois ( const QString &  nick  )  [slot]

Sends a whois command on nick.

void Irc::Session::connected (  )  [signal]

This signal is emitted after a connection has been successfully established.

void Irc::Session::connectSlotsByName ( const QObject *  receiver  ) 

Connects Irc::Session signals to matching slots of the receiver.

Receiver slots must follow the following syntax:

        void on_<signal name>(<signal parameters>);

void Irc::Session::connectToServer ( const QHostAddress &  address,
quint16  port = 6667 
) [slot]

Connects to server with address and port.

void Irc::Session::connectToServer ( const QString &  hostName,
quint16  port = 6667 
) [slot]

Connects to server with hostName and port.

void Irc::Session::disconnected (  )  [signal]

This signal is emitted when the session has been disconnected.

void Irc::Session::disconnectFromServer (  )  [slot]

Disconnects from the server.

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::isConnected (  )  const

Returns true if connected or false otherwise.

void Irc::Session::msgCtcpActionReceived ( const QString &  origin,
const QString &  receiver,
const QString &  action 
) [signal]

This signal is emitted when origin has sent a CTCP action to receiver.

void Irc::Session::msgCtcpReplyReceived ( const QString &  origin,
const QString &  reply 
) [signal]

This signal is emitted when origin has sent a CTCP reply.

void Irc::Session::msgCtcpRequestReceived ( const QString &  origin,
const QString &  request 
) [signal]

This signal is emitted when origin has sent a CTCP request.

void Irc::Session::msgInvited ( const QString &  origin,
const QString &  receiver,
const QString &  channel 
) [signal]

This signal is emitted when origin has invited receiver to channel.

void Irc::Session::msgJoined ( const QString &  origin,
const QString &  channel 
) [signal]

This signal is emitted when origin has joined channel.

void Irc::Session::msgKicked ( const QString &  origin,
const QString &  channel,
const QString &  nick,
const QString &  message 
) [signal]

This signal is emitted when origin has kicked nick from channel with message.

void Irc::Session::msgMessageReceived ( const QString &  origin,
const QString &  receiver,
const QString &  message 
) [signal]

This signal is emitted when origin has sent message to receiver.

void Irc::Session::msgModeChanged ( const QString &  origin,
const QString &  receiver,
const QString &  mode,
const QString &  args 
) [signal]

This signal is emitted when origin has changed receiver's mode with args.

void Irc::Session::msgNickChanged ( const QString &  origin,
const QString &  nick 
) [signal]

This signal is emitted when origin has changed nick.

void Irc::Session::msgNoticeReceived ( const QString &  origin,
const QString &  receiver,
const QString &  notice 
) [signal]

This signal is emitted when origin has sent notice to receiver.

void Irc::Session::msgNumericMessageReceived ( const QString &  origin,
uint  code,
const QStringList &  params 
) [signal]

This signal is emitted when origin has sent a numeric message with code and params.

void Irc::Session::msgParted ( const QString &  origin,
const QString &  channel,
const QString &  message 
) [signal]

This signal is emitted when origin has parted channel with message.

void Irc::Session::msgQuit ( const QString &  origin,
const QString &  message 
) [signal]

This signal is emitted when origin has quit with message.

void Irc::Session::msgTopicChanged ( const QString &  origin,
const QString &  channel,
const QString &  topic 
) [signal]

This signal is emitted when origin has changed channel's topic.

void Irc::Session::msgUnknownMessageReceived ( const QString &  origin,
const QStringList &  params 
) [signal]

This signal is emitted when origin has sent an unknown message with params.

QString Irc::Session::nick (  )  const

Returns the nick.

Session::Options Irc::Session::options (  )  const

Returns the options.

QString Irc::Session::password (  )  const

Returns the password.

quint16 Irc::Session::port (  )  const

Returns the port.

QString Irc::Session::realName (  )  const

Returns the real name.

void Irc::Session::removeAutoJoinChannel ( const QString &  channel  ) 

Removes channels from the list of auto-join channels.

bool Irc::Session::sendRaw ( const QString &  message  )  [slot]

Sends a raw message to the server.

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::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::setIdent ( const QString &  ident  ) 

Sets the ident.

Note:
setIdent() has no effect on already established connection.

void Irc::Session::setNick ( const QString &  nick  )  [slot]

Sets the nick.

void Irc::Session::setOptions ( Options  options  ) 

Sets the options.

void Irc::Session::setPassword ( const QString &  password  ) 

Sets the password.

Note:
setPassword() has no effect on already established connection.

void Irc::Session::setRealName ( const QString &  realName  ) 

Sets the realName.

Note:
setRealName() has no effect on already established connection.

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.


The documentation for this class was generated from the following files:

Generated on Sun Aug 30 12:36:08 2009 for LibIrcClient-Qt by  doxygen 1.5.8