IRCResponseType Class Reference

Defines types of IRC network response message. More...

#include <ircresponsetype.h>

Public Types

enum  MsgType {
  Invalid = 0, HelloClient, RPLISupport, RPLLUserClient,
  RPLLUserOp, RPLLUserUnknown, RPLLUserChannels, RPLAway,
  RPLWhoIsRegnick, RPLLUserMe, RPLWhoIsUser, RPLWhoIsServer,
  RPLWhoIsOperator, RPLWhoIsIdle, RPLEndOfWhoIs, RPLWhoIsChannels,
  RPLWhoIsSpecial, RPLChannelUrl, RPLCreationTime, RPLWhoIsAccount,
  RPLTopic, RPLTopicWhoTime, RPLWhoIsBot, RPLWhoIsActually,
  RPLNamReply, RPLEndOfNames, RPLMOTD, RPLMOTDStart,
  RPLEndOfMOTD, RPLWhoIsHost, RPLWhoIsModes, ERRNoSuchNick,
  ERRCannotSendToChan, ERRErroneousNickname, ERRNicknameInUse, ERRChannelIsFull,
  ERRInviteOnlyChan, ERRBannedFromChan, ERRBadChannelKey, ERRBadChannelMask,
  ERRNoChanModes, ERRChanOpPrivIsNeeded, RPLWhoIsSecure, Join,
  Kick, Kill, Mode, Nick,
  Notice, Part, Ping, PrivMsg,
  Quit, Topic, NUM_TYPES
}
 Represents types defined by RFC 1459. More...
 

Public Member Functions

 IRCResponseType ()
 Initializes an invalid IRCResponseType object. More...
 
 IRCResponseType (MsgType type)
 Initializes object with specified type. More...
 
 IRCResponseType (const QString &typeRepresentation)
 Initializes object by attempting to convert specified string to MsgType through typeFromRfcString(). More...
 
bool isCommandResponse () const
 Check if numeric value is between 200 and 399 (inclusive). More...
 
bool isErrorMessage () const
 Check if numeric value is equal to or above 400. More...
 
bool isValid () const
 Response is valid if type is different than Invalid. More...
 
int numericType () const
 If message type can be represented as number, this will contain its value. More...
 
bool operator!= (const IRCResponseType &other) const
 
bool operator== (const IRCResponseType &other) const
 
QString toRfcString () const
 String representation of the message type. More...
 
MsgType type () const
 

Static Public Member Functions

static IRCResponseType fromIntegerResponseValue (int responseType)
 Creates IRCResponseType objects taking numeric value as the more important here. More...
 
static int toRfcNumber (MsgType type)
 If type can be represented as an integer, this will convert it. More...
 
static QString toRfcString (MsgType type)
 String representation of specified message type. More...
 
static MsgType typeFromRfcString (const QString &typeRepresentation)
 Returns MsgType basing on typeRepresentation. More...
 

Detailed Description

Defines types of IRC network response message.

Types are compliant to the response types defined by RFC 1459.

Definition at line 16 of file ircresponsetype.h.

Member Enumeration Documentation

Represents types defined by RFC 1459.

In order to learn what each type represents please refer to RFC 1459 document.

Enumerator
Invalid 

Type unknown to this IRC client.

Messages with Invalid types may still be valid IRC messages that are complaint with the RFC 1459 document. However they may not be supported by this client.

HelloClient 

001 - sent when client connects.

This is the first thing delivered after successful client registration.

RPLISupport 

005 - all sorts of server flags.

RPLLUserClient 

251 - how many users on how many servers

See also
RPLLUserMe
RPLLUserOp 

252 - how many ops

RPLLUserUnknown 

253 - how many unknown connections

RPLLUserChannels 

254 - how many channels,

RPLAway 

301

RPLWhoIsRegnick 

307 - no idea what this is, but we'll treat it the same way we treat RPLWhoIsSpecial.

RPLLUserMe 

255 - how many clients on how many servers,

Server must send that and RPLLUserClient (251). Other values in between are sent only if they are not zero.

RPLWhoIsUser 

311

RPLWhoIsServer 

312

RPLWhoIsOperator 

313

RPLWhoIsIdle 

317

RPLEndOfWhoIs 

318

RPLWhoIsChannels 

319

RPLWhoIsSpecial 

320 - it's inconclusive what this code means.

This source https://www.alien.net.au/irc/irc2numerics.html specified that this can have more than one meaning. I'm not sure what to expect here, but this message will be treated the same as a generic WHOIS reply.

RPLChannelUrl 

328

RPLCreationTime 

329

RPLWhoIsAccount 

330

RPLTopic 

332

RPLTopicWhoTime 

333

RPLWhoIsBot 

335 - non-standard

RPLWhoIsActually 

338

RPLNamReply 

353 - names list for a channel

RPLEndOfNames 

366 - end of names list

RPLMOTD 

372 - message of the day

RPLMOTDStart 

375 - start of the message of the day

RPLEndOfMOTD 

376 - end of the message of the day

RPLWhoIsHost 

378

RPLWhoIsModes 

379

ERRNoSuchNick 

401

ERRCannotSendToChan 

404

ERRErroneousNickname 

432

ERRNicknameInUse 

433

ERRChanOpPrivIsNeeded 

482

RPLWhoIsSecure 

671

NUM_TYPES 

Not a real type, denotes number of all types.

Definition at line 25 of file ircresponsetype.h.

Constructor & Destructor Documentation

IRCResponseType::IRCResponseType ( )

Initializes an invalid IRCResponseType object.

Definition at line 8 of file ircresponsetype.cpp.

IRCResponseType::IRCResponseType ( MsgType  type)

Initializes object with specified type.

Definition at line 14 of file ircresponsetype.cpp.

IRCResponseType::IRCResponseType ( const QString &  typeRepresentation)

Initializes object by attempting to convert specified string to MsgType through typeFromRfcString().

Definition at line 20 of file ircresponsetype.cpp.

Member Function Documentation

IRCResponseType IRCResponseType::fromIntegerResponseValue ( int  responseType)
static

Creates IRCResponseType objects taking numeric value as the more important here.

The MsgType, returned by type(), in the created object may still point to Invalid value but the numericValue() will be set to whatever was specified as the parameter of this method.

Definition at line 34 of file ircresponsetype.cpp.

bool IRCResponseType::isCommandResponse ( ) const
inline

Check if numeric value is between 200 and 399 (inclusive).

See: RFC 1459.

Definition at line 270 of file ircresponsetype.h.

bool IRCResponseType::isErrorMessage ( ) const
inline

Check if numeric value is equal to or above 400.

See: RFC 1459.

Definition at line 280 of file ircresponsetype.h.

bool IRCResponseType::isValid ( ) const
inline

Response is valid if type is different than Invalid.

Definition at line 288 of file ircresponsetype.h.

int IRCResponseType::numericType ( ) const
inline

If message type can be represented as number, this will contain its value.

Numeric types values are stored to easilly distinct a message family. For example all errors start with 400 and above.

Definition at line 303 of file ircresponsetype.h.

int IRCResponseType::toRfcNumber ( MsgType  type)
static

If type can be represented as an integer, this will convert it.

Some IRC message types are represented by words like KILL or PING, but some are represented by numbers like 001, 311, 401, etc. This method will convert MsgType value to numeric value, if such value can be found.

Internally, type is converted to string using the toRfcString() method and then that string is converted to integer.

Returns
Either a valid, non-negative number on success, or negative value on failure.

Definition at line 61 of file ircresponsetype.cpp.

QString IRCResponseType::toRfcString ( MsgType  type)
static

String representation of specified message type.

This returns the RFC 1459 representation of the message type!

Returns
If type is invalid or unknown, null QString is returned. All returned strings are upper-case.

Definition at line 76 of file ircresponsetype.cpp.

QString IRCResponseType::toRfcString ( ) const
inline

String representation of the message type.

This returns the RFC 1459 representation of the message type!

Definition at line 313 of file ircresponsetype.h.

IRCResponseType::MsgType IRCResponseType::typeFromRfcString ( const QString &  typeRepresentation)
static

Returns MsgType basing on typeRepresentation.

It is either one of the known and implemented types or Invalid if string cannot be successfuly converted.

Definition at line 245 of file ircresponsetype.cpp.


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