Communi 1.0.0
A cross-platform IRC client library written with Qt 4
Public Slots | Signals | Public Member Functions | Properties
IrcSession Class Reference

The IrcSession class provides an IRC session. More...

#include <IrcSession>

Inherits QObject.

List of all members.

Public Slots

void close ()
void open ()

Signals

void connecting ()
void disconnected ()
void hostChanged (const QString &host)
void messageReceived (IrcMessage *message)
void nickNameChanged (const QString &name)
void password (QString *password)
void portChanged (int port)
void realNameChanged (const QString &name)
void socketError (QAbstractSocket::SocketError error)
void socketStateChanged (QAbstractSocket::SocketState state)
void userNameChanged (const QString &name)

Public Member Functions

 IrcSession (QObject *parent=0)
virtual ~IrcSession ()
Q_INVOKABLE bool sendCommand (IrcCommand *command)
Q_INVOKABLE bool sendRaw (const QString &message)

Properties

bool active
bool connected
QByteArray encoding
QString host
QString nickName
int port
QString realName
QAbstractSocket socket
QString userName

Detailed Description

The IrcSession class provides an IRC session.

IrcSession provides means to establish a connection to an IRC server.

IrcSession works asynchronously ie. it is non-blocking, emitting signals to notify when the state of connection changes or data has arrived. The asynchronous approach depends on an event loop. See QCoreApplication::exec() for more details.

Example usage:

    IrcSession* session = new IrcSession(this);
    connect(session, SIGNAL(messageReceived(IrcMessage*)), this, SLOT(onMessageReceived(IrcMessage*)));
    session->setHost("irc.server.com");
    session->setUserName("me");
    session->setNickName("myself");
    session->setRealName("And I");
    session->open();
See also:
IrcMessage and IrcCommand

Constructor & Destructor Documentation

IrcSession::IrcSession ( QObject parent = 0) [explicit]

Constructs a new IRC session with parent.

IrcSession::~IrcSession ( ) [virtual]

Destructs the IRC session.


Member Function Documentation

void IrcSession::close ( ) [slot]

Closes the connection to the server.

void IrcSession::connecting ( ) [signal]

This signal is emitted when the connection is being established.

void IrcSession::disconnected ( ) [signal]

This signal is emitted when the session has been disconnected.

void IrcSession::hostChanged ( const QString host) [signal]

This signal is emitted when the host has changed.

void IrcSession::messageReceived ( IrcMessage message) [signal]

This signal is emitted whenever a message is received.

void IrcSession::nickNameChanged ( const QString name) [signal]

This signal is emitted when the nick name has changed.

void IrcSession::open ( ) [slot]

Opens a connection to the server.

Note:
The function merely outputs a warnings and returns immediately if either host, userName, nickName or realName is empty.
void IrcSession::password ( QString password) [signal]

This signal is emitted when the connection password may be set.

Note:
IrcSession does not store the password.
void IrcSession::portChanged ( int  port) [signal]

This signal is emitted when the port has changed.

void IrcSession::realNameChanged ( const QString name) [signal]

This signal is emitted when the real name has changed.

bool IrcSession::sendCommand ( IrcCommand command)

Sends a command to the server.

Warning:
The command must be allocated on the heap since the session will take ownership of the command and delete it once it has been sent. It is not safe to access the command after it has been sent.
See also:
sendRaw()
bool IrcSession::sendRaw ( const QString message)

Sends a raw message to the server.

See also:
sendCommand()
void IrcSession::socketError ( QAbstractSocket::SocketError  error) [signal]

This signal is emitted whenever a socket error occurs.

See also:
QAbstractSocket::error()
void IrcSession::socketStateChanged ( QAbstractSocket::SocketState  state) [signal]

This signal is emitted whenever the socket's state changes.

See also:
QAbstractSocket::stateChanged()
void IrcSession::userNameChanged ( const QString name) [signal]

This signal is emitted when the user name has changed.


Property Documentation

bool IrcSession::active [read]

This property holds whether the session is active.

The session is considered active when the socket state is not QAbstractSocket::UnconnectedState.

Access functions:
  • bool isActive() const
bool IrcSession::connected [read]

This signal is emitted when the connection has been established ie. the welcome message has been received and the server is ready to receive commands.

See also:
Irc::RPL_WELCOME

This property holds whether the session is connected.

The session is considered connected when the welcome message has been received and the server is ready to receive commands.

See also:
Irc::RPL_WELCOME
Access functions:
  • bool isConnected() const
QByteArray IrcSession::encoding [read, write]

This property holds the message encoding. See QTextCodec documentation for supported encodings.

Encoding auto-detection can be turned on by passing a null QByteArray. The fallback codec is QTextCodec::codecForLocale().

The default value is a null QByteArray.

Access functions:
QString IrcSession::host [read, write]

This property holds the server host.

Access functions:
QString IrcSession::nickName [read, write]

This property holds the nick name.

Access functions:
int IrcSession::port [read, write]

This property holds the server port.

The default value is 6667.

Access functions:
  • int port() const
  • void setPort(int port)
QString IrcSession::realName [read, write]

This property holds the real name.

Note:
Changing the real name has no effect until the connection is re-established.
Access functions:
QAbstractSocket * IrcSession::socket [read, write]

This property holds the socket. IrcSession creates an instance of QTcpSocket by default.

The previously set socket is deleted if its parent is this.

Note:
IrcSession supports QSslSocket in the way that it automatically calls QSslSocket::startClientEncryption() while connecting.
Access functions:
  • QAbstractSocket* socket() const
  • void setSocket(QAbstractSocket* socket)
QString IrcSession::userName [read, write]

This property holds the user name.

Note:
Changing the user name has no effect until the connection is re-established.
Access functions:

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Defines