Communi  1.1.0
A cross-platform IRC client library written with Qt 4
 All Classes Files Functions Enumerations Enumerator Properties Macros Groups Pages
Public Slots | Signals | Public Member Functions | Properties
IrcSession Class Reference

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

#include <IrcSession>

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 sendData (const QByteArray &data)
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:
sendData()
bool IrcSession::sendData ( const QByteArray &  data)

Sends raw data to the server.

See also:
sendCommand()
bool IrcSession::sendRaw ( const QString &  message)

Sends raw message to the server.

Note:
The is sent using UTF-8 encoding.
See also:
sendData(), 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
readwrite

This property holds the FALLBACK encoding for received messages.

The fallback encoding is used when the auto-detection of message encoding fails. See QTextCodec::availableCodes() for the list of supported encodings. The default value is UTF-8.

Access functions:
  • QByteArray encoding() const
  • void setEncoding(const QByteArray& encoding)
See also:
QTextCodec::availableCodecs(), QTextCodec::codecForLocale()
QString IrcSession::host
readwrite

This property holds the server host.

Access functions:
  • QString host() const
  • void setHost(const QString& host)
QString IrcSession::nickName
readwrite

This property holds the nick name.

Access functions:
  • QString nickName() const
  • void setNickName(const QString& name)
int IrcSession::port
readwrite

This property holds the server port.

The default value is 6667.

Access functions:
  • int port() const
  • void setPort(int port)
QString IrcSession::realName
readwrite

This property holds the real name.

Note:
Changing the real name has no effect until the connection is re-established.
Access functions:
  • QString realName() const
  • void setRealName(const QString& name)
QAbstractSocket * IrcSession::socket
readwrite

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
readwrite

This property holds the user name.

Note:
Changing the user name has no effect until the connection is re-established.
Access functions:
  • QString userName() const
  • void setUserName(const QString& name)

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