The base class of all messages. More...
#include <IrcMessage>
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 IrcMessage * | clone (QObject *parent=nullptr) const |
QString | command () const |
IrcConnection * | connection () const |
QByteArray | encoding () const |
Flags | flags () const |
QString | host () const |
QString | ident () const |
IrcNetwork * | network () 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 ¶meter) |
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 IrcMessage * | fromData (const QByteArray &data, IrcConnection *connection) |
static Q_INVOKABLE IrcMessage * | fromParameters (const QString &prefix, const QString &command, const QStringList ¶meters, IrcConnection *connection) |
Properties | |
bool | implicit |
bool | own |
bool | valid |
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.
enum IrcMessage::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.
|
Unidentified | The message is unidentified.
|
Playback | The message is playback.
|
Implicit | The message is an implicit "reply" after joining a channel.
|
enum IrcMessage::Type |
This enum describes the supported message types.
Enumerator | |
---|---|
Unknown | An unknown message (IrcMessage). |
Capability | A capability message (IrcCapabilityMessage).
|
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).
|
Account | An account notify message (IrcAccountMessage).
|
Away | An away message (IrcAwayMessage).
|
Whois | A whois reply message (IrcWhoisMessage).
|
Whowas | A whowas reply message (IrcWhowasMessage).
|
HostChange | A host change message (IrcHostChangeMessage).
|
Batch | A batch message (IrcBatchMessage).
|
|
explicit |
Constructs a new IrcMessage with connection.
|
override |
Destructs the message.
QString IrcMessage::account | ( | ) | const |
This property holds the services account of the message sender.
account-tag
capability is enabled and the user has identified with services.IrcMessage * IrcMessage::clone | ( | QObject * | parent = nullptr | ) | const |
Clones the message.
QString IrcMessage::command | ( | ) | const |
This property holds the message command.
IrcConnection * IrcMessage::connection | ( | ) | const |
This property holds the message connection.
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.
IrcMessage::Flags IrcMessage::flags | ( | ) | const |
This property holds the message flags.
|
static |
Creates a new message from data and connection.
|
static |
Creates a new message from prefix, command and parameters with connection.
QString IrcMessage::host | ( | ) | const |
This property holds the message sender host.
Host is part of the sender prefix as specified in RFC 1459:
<nick> [ '!' <ident> ] [ '@' <host> ]
QString IrcMessage::ident | ( | ) | const |
This property holds the message sender ident.
Ident is part of the sender prefix as specified in RFC 1459:
<nick> [ '!' <ident> ] [ '@' <host> ]
IrcNetwork * IrcMessage::network | ( | ) | const |
This property holds the message network.
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> ] [ '@' <host> ]
QString IrcMessage::parameter | ( | int | index | ) | const |
Returns the parameter at the specified index.
QStringList IrcMessage::parameters | ( | ) | const |
This property holds the message parameters.
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> [ '!' <ident> ] [ '@' <host> ]
void IrcMessage::setFlag | ( | Flag | flag, |
bool | on = true ) |
Sets whether the flag is on.
void IrcMessage::setParameter | ( | int | index, |
const QString & | parameter ) |
Sets the parameter at the specified index.
void IrcMessage::setTag | ( | const QString & | name, |
const QVariant & | value ) |
QVariant IrcMessage::tag | ( | const QString & | name | ) | const |
QVariantMap IrcMessage::tags | ( | ) | const |
This property holds the message tags.
bool IrcMessage::testFlag | ( | Flag | flag | ) | const |
Returns true
if the flag is on; otherwise false
.
QDateTime IrcMessage::timeStamp | ( | ) | const |
This property holds the message time stamp.
server-time
capability is enabled, the time stamp is automatically set from the time
message tag.QByteArray IrcMessage::toData | ( | ) | const |
Returns the message as received from an IRC server.
IrcMessage::Type IrcMessage::type | ( | ) | const |
This property holds the message type.
|
read |
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.
|
read |
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.
|
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.