Communi  3.7.0
A cross-platform IRC framework written with Qt
Public Types | Public Member Functions | Static Public Member Functions | Properties | List of all members
IrcMessage Class Reference

The base class of all messages. More...

Inherits QObject.

Inherited by IrcAccountMessage, IrcAwayMessage, IrcBatchMessage, IrcCapabilityMessage, IrcErrorMessage, IrcHostChangeMessage, IrcInviteMessage, IrcJoinMessage, IrcKickMessage, IrcModeMessage, IrcMotdMessage, IrcNamesMessage, IrcNickMessage, IrcNoticeMessage, IrcNumericMessage, IrcPartMessage, IrcPingMessage, IrcPongMessage, IrcPrivateMessage, IrcQuitMessage, IrcTopicMessage, IrcWhoReplyMessage, IrcWhoisMessage, and IrcWhowasMessage.

Public Types

enum  Flag {
  None = 0x00 , Own = 0x01 , Identified = 0x02 , Unidentified = 0x04 ,
  Playback = 0x08 , Implicit = 0x10
}
 
enum  Type {
  Unknown , Capability , Error , Invite ,
  Join , Kick , Mode , Motd ,
  Names , Nick , Notice , Numeric ,
  Part , Ping , Pong , Private ,
  Quit , Topic , WhoReply , Account ,
  Away , Whois , Whowas , HostChange ,
  Batch
}
 

Public Member Functions

Q_INVOKABLE IrcMessage (IrcConnection *connection)
 
 ~IrcMessage () override
 
QString account () const
 
Q_INVOKABLE IrcMessageclone (QObject *parent=nullptr) const
 
QString command () const
 
IrcConnectionconnection () const
 
QByteArray encoding () const
 
Flags flags () const
 
QString host () const
 
QString ident () const
 
IrcNetworknetwork () const
 
QString nick () const
 
QString parameter (int index) const
 
QStringList parameters () const
 
QString prefix () const
 
Q_INVOKABLE void setFlag (Flag flag, bool on=true)
 
void setParameter (int index, const QString &parameter)
 
void setTag (const QString &name, const QVariant &tag)
 
QVariant tag (const QString &name) const
 
QVariantMap tags () const
 
Q_INVOKABLE bool testFlag (Flag flag) const
 
QDateTime timeStamp () const
 
Q_INVOKABLE QByteArray toData () const
 
Type type () const
 

Static Public Member Functions

static Q_INVOKABLE IrcMessagefromData (const QByteArray &data, IrcConnection *connection)
 
static Q_INVOKABLE IrcMessagefromParameters (const QString &prefix, const QString &command, const QStringList &parameters, IrcConnection *connection)
 

Properties

bool implicit
 
bool own
 
bool valid
 

Detailed Description

IRC messages are received from an IRC server. IrcConnection translates received messages into IrcMessage instances and emits the IrcConnection::messageReceived() signal upon message received.

Subclasses of IrcMessage contain specialized accessors for parameters that are specific to the particular type of message. See IrcMessage::Type for the list of supported message types.

See also
IrcConnection::messageReceived(), IrcMessage::Type

Member Enumeration Documentation

◆ Flag

This enum describes the supported message flags.

Enumerator
None 

The message has no flags.

Own 

The message is user's own message.

Identified 

The message is identified.

Deprecated:
Use IrcMessage::account instead.
Unidentified 

The message is unidentified.

Deprecated:
Use IrcMessage::account instead.
Playback 

The message is playback.

Since
3.2
Implicit 

The message is an implicit "reply" after joining a channel.

Since
3.3

◆ Type

This enum describes the supported message types.

Enumerator
Unknown 

An unknown message (IrcMessage).

Capability 

A capability message (IrcCapabilityMessage).

See also
IRCv3 support
Error 

An error message (IrcErrorMessage).

Invite 

An invite message (IrcInviteMessage).

Join 

A join message (IrcJoinMessage).

Kick 

A kick message (IrcKickMessage).

Mode 

A mode message (IrcModeMessage).

Motd 

A message of the day (IrcMotdMessage).

Names 

A names message (IrcNamesMessage).

Nick 

A nick message (IrcNickMessage).

Notice 

A notice message (IrcNoticeMessage).

Numeric 

A numeric message (IrcNumericMessage).

Part 

A part message (IrcPartMessage).

Ping 

A ping message (IrcPingMessage).

Pong 

A pong message (IrcPongMessage).

Private 

A private message (IrcPrivateMessage).

Quit 

A quit message (IrcQuitMessage).

Topic 

A topic message (IrcTopicMessage).

WhoReply 

A who reply message (IrcWhoReplyMessage).

Since
3.1
Account 

An account notify message (IrcAccountMessage).

Since
3.3
See also
IRCv3 support
Away 

An away message (IrcAwayMessage).

Since
3.3
Whois 

A whois reply message (IrcWhoisMessage).

Since
3.3
Whowas 

A whowas reply message (IrcWhowasMessage).

Since
3.3
HostChange 

A host change message (IrcHostChangeMessage).

Since
3.4
Batch 

A batch message (IrcBatchMessage).

Since
3.5
See also
IRCv3 support

Constructor & Destructor Documentation

◆ IrcMessage()

IrcMessage::IrcMessage ( IrcConnection connection)
explicit

Constructs a new IrcMessage with connection.

◆ ~IrcMessage()

IrcMessage::~IrcMessage ( )
override

Destructs the message.

Member Function Documentation

◆ account()

QString IrcMessage::account ( ) const
Since
3.4

This property holds the services account of the message sender.

Note
Only set if the account-tag capability is enabled and the user has identified with services.
Access function:
  • QString account() const
See also
IRCv3 support

◆ clone()

IrcMessage * IrcMessage::clone ( QObject *  parent = nullptr) const
Since
3.5

Clones the message.

◆ command()

QString IrcMessage::command ( ) const

This property holds the message command.

Access functions:
  • QString command() const
  • void setCommand(const QString& command)

◆ connection()

IrcConnection * IrcMessage::connection ( ) const

This property holds the message connection.

Access function:

◆ encoding()

QByteArray IrcMessage::encoding ( ) const

This property holds the FALLBACK encoding for the message.

The fallback encoding is used when the message is detected not to be valid UTF-8 and the consequent auto-detection of message encoding fails. See QTextCodec::availableCodes() for the list of supported encodings.

The default value is ISO-8859-15.

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

◆ flags()

IrcMessage::Flags IrcMessage::flags ( ) const

This property holds the message flags.

Access function:
See also
testFlag(), setFlag()

◆ fromData()

IrcMessage * IrcMessage::fromData ( const QByteArray &  data,
IrcConnection connection 
)
static

Creates a new message from data and connection.

◆ fromParameters()

IrcMessage * IrcMessage::fromParameters ( const QString &  prefix,
const QString &  command,
const QStringList &  parameters,
IrcConnection connection 
)
static

Creates a new message from prefix, command and parameters with connection.

◆ host()

QString IrcMessage::host ( ) const

This property holds the message sender host.

Host is part of the sender prefix as specified in RFC 1459:

<nick&gt; [ '!' <ident&gt; ] [ '@' <host> ]
Access function:
  • QString host() const

◆ ident()

QString IrcMessage::ident ( ) const

This property holds the message sender ident.

Ident is part of the sender prefix as specified in RFC 1459:

<nick&gt; [ '!' <ident> ] [ '@' <host&gt; ]
Access function:
  • QString ident() const

◆ network()

IrcNetwork * IrcMessage::network ( ) const

This property holds the message network.

Access function:

◆ nick()

QString IrcMessage::nick ( ) const

This property holds the message sender nick.

Nick is part of the sender prefix as specified in RFC 1459:

<nick> [ '!' <ident&gt; ] [ '@' <host&gt; ]
Access function:
  • QString nick() const

◆ parameter()

QString IrcMessage::parameter ( int  index) const
Since
3.5

Returns the parameter at the specified index.

◆ parameters()

QStringList IrcMessage::parameters ( ) const

This property holds the message parameters.

Access functions:
  • QStringList parameters() const
  • void setParameters(const QStringList& parameters)

◆ prefix()

QString IrcMessage::prefix ( ) const

This property holds the message sender prefix.

The prefix consists of nick, ident and host as specified in RFC 1459:

<prefix> ::= <nick&gt; [ '!' <ident&gt; ] [ '@' <host&gt; ]
Access functions:
  • QString prefix() const
  • void setPrefix(const QString& prefix)

◆ setFlag()

void IrcMessage::setFlag ( Flag  flag,
bool  on = true 
)
Since
3.5

Sets whether the flag is on.

See also
IrcMessage::flags

◆ setParameter()

void IrcMessage::setParameter ( int  index,
const QString &  parameter 
)
Since
3.5

Sets the parameter at the specified index.

◆ setTag()

void IrcMessage::setTag ( const QString &  name,
const QVariant &  value 
)
Since
3.5

Sets the value of the specified tag.

See also
IRCv3 support

◆ tag()

QVariant IrcMessage::tag ( const QString &  name) const
Since
3.5

Returns the value of the specified tag.

See also
IRCv3 support

◆ tags()

QVariantMap IrcMessage::tags ( ) const
Since
3.1

This property holds the message tags.

Access functions:
  • QVariantMap tags() const
  • void setTags(const QVariantMap& tags)
See also
IRCv3 support

◆ testFlag()

bool IrcMessage::testFlag ( Flag  flag) const
Since
3.5

Returns true if the flag is on; otherwise false.

See also
IrcMessage::flags

◆ timeStamp()

QDateTime IrcMessage::timeStamp ( ) const

This property holds the message time stamp.

Note
When the server-time capability is enabled, the time stamp is automatically set from the time message tag.
Access functions:
  • QDateTime timeStamp() const
  • void setTimeStamp(const QDateTime& timeStamp)
See also
IRCv3 support

◆ toData()

QByteArray IrcMessage::toData ( ) const

Returns the message as received from an IRC server.

◆ type()

IrcMessage::Type IrcMessage::type ( ) const

This property holds the message type.

Access function:

Property Documentation

◆ implicit

bool IrcMessage::implicit
read
Since
3.5

This property holds whether the message is an implicit "reply" after joining a channel.

This property is provided for convenience. It is equivalent of testing for the IrcMessage::Implicit flag.

Access function:
  • bool isImplicit() const

◆ own

bool IrcMessage::own
read
Since
3.2

This property holds whether the message is user's own.

This property is provided for convenience. It is equivalent of testing for the IrcMessage::Own flag.

Access function:
  • bool isOwn() const

◆ valid

bool IrcMessage::valid
read

This property is true if the message is valid; otherwise false.

A message is considered valid if the prefix is not empty and the parameters match the message.

Access function:
  • bool isValid() const