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

Provides network information and capability management. More...

Inherits QObject.

Public Types

enum  Limit {
  NickLength , ChannelLength , TopicLength , MessageLength ,
  KickReasonLength , AwayReasonLength , ModeCount , MonitorCount
}
 
enum  ModeType {
  TypeA = 0x1 , TypeB = 0x2 , TypeC = 0x4 , TypeD = 0x8 ,
  AllTypes = 0xf
}
 

Public Slots

bool requestCapabilities (const QStringList &capabilities)
 
bool requestCapability (const QString &capability)
 

Signals

void requestingCapabilities ()
 

Public Member Functions

QStringList activeCapabilities () const
 
QStringList availableCapabilities () const
 
Q_INVOKABLE int channelLimit (const QString &type) const
 
Q_INVOKABLE QStringList channelModes (IrcNetwork::ModeTypes types) const
 
QStringList channelTypes () const
 
Q_INVOKABLE bool hasCapability (const QString &capability) const
 
Q_INVOKABLE bool isCapable (const QString &capability) const
 
Q_INVOKABLE bool isChannel (const QString &name) const
 
Q_INVOKABLE int modeLimit (const QString &mode) const
 
QStringList modes () const
 
Q_INVOKABLE QString modeToPrefix (const QString &mode) const
 
QString name () const
 
Q_INVOKABLE int numericLimit (IrcNetwork::Limit limit) const
 
QStringList prefixes () const
 
Q_INVOKABLE QString prefixToMode (const QString &prefix) const
 
QStringList requestedCapabilities () const
 
bool skipCapabilityValidation () const
 
QStringList statusPrefixes () const
 
Q_INVOKABLE int targetLimit (const QString &command) const
 

Properties

bool initialized
 

Detailed Description

Network information

IrcNetwork provides various information about the IRC network of a connection. This includes the network name, supported channel types, channel user mode characters and prefix letters and status prefixes, and various numeric limitations, such as the maximum nick, channel, topic and message lengths.

Furthermore, IrcNetwork provides convenient methods for converting channel user modes to prefixes and vice versa and testing whether a target name is a channel.

Note
Most properties have empty values until the network information has been initialized.

Capability management

IrcNetwork also provides means for capability management. It maintais a list of available and active capabilities, automatically requests desired capabilities, and provides convenient methods for manual capability requests.

See also
IrcConnection::network, Irc::supportedCapabilities, IRCv3 support

Member Enumeration Documentation

◆ Limit

This enum describes the numeric limit types.

Enumerator
NickLength 

The maximum nick name length.

ChannelLength 

The maximum channel name length.

TopicLength 

The maximum channel topic length.

MessageLength 

The maximum message length.

KickReasonLength 

The maximum kick reason length.

AwayReasonLength 

The maximum away reason length.

ModeCount 

The maximum number of channel modes allowed per mode command.

MonitorCount 

The maximum amount of targets a client may have in their monitor list.

Since
3.4

◆ ModeType

This enum describes the channel mode types.

Enumerator
TypeA 

Type A modes.

Modes that add or remove an address to or from a list. These modes always take a parameter when sent by the server to a client; when sent by a client, they may be specified without a parameter, which requests the server to display the current contents of the corresponding list on the channel to the client.

TypeB 

Type B modes.

Modes that change a setting on the channel. These modes always take a parameter.

TypeC 

Type C modes.

Modes that change a setting on the channel. These modes take a parameter only when set; the parameter is absent when the mode is removed both in the client's and server's MODE command.

TypeD 

Type D modes.

Modes that change a setting on the channel. These modes never take a parameter.

AllTypes 

All type modes.

Member Function Documentation

◆ activeCapabilities()

QStringList IrcNetwork::activeCapabilities ( ) const

This property holds the active capabilities.

Access function:
  • QStringList activeCapabilities() const
Notifier signal:
  • void activeCapabilitiesChanged(const QStringList& capabilities)
See also
requestedCapabilities, availableCapabilities

◆ availableCapabilities()

QStringList IrcNetwork::availableCapabilities ( ) const

This property holds the available capabilities.

Access function:
  • QStringList availableCapabilities() const
Notifier signal:
  • void availableCapabilitiesChanged(const QStringList& capabilities)
See also
requestedCapabilities, activeCapabilities

◆ channelLimit()

int IrcNetwork::channelLimit ( const QString &  type) const

Returns the limit for a type of channels, or -1 if the limitation is not known.

See also
channelTypes()

◆ channelModes()

QStringList IrcNetwork::channelModes ( IrcNetwork::ModeTypes  types) const

Returns the supported channel modes for specified types.

See also
ModeType

◆ channelTypes()

QStringList IrcNetwork::channelTypes ( ) const

This property holds the supported channel type prefix characters.

Examples of typical channel types:

Description Type Example
Normal channel # #communi
Local channel & &foo
Access function:
  • QStringList channelTypes() const
Notifier signal:
  • void channelTypesChanged(const QStringList& types)

◆ hasCapability()

bool IrcNetwork::hasCapability ( const QString &  capability) const

Returns true if the capability is available.

See also
availableCapabilities

◆ isCapable()

bool IrcNetwork::isCapable ( const QString &  capability) const

Returns true if the capability is active.

See also
activeCapabilities

◆ isChannel()

bool IrcNetwork::isChannel ( const QString &  name) const

Returns true if the name is a channel.

QString name = ...;
if (connection->network()->isChannel(name))
doSomeChannelAction(name);
See also
channelTypes

◆ modeLimit()

int IrcNetwork::modeLimit ( const QString &  mode) const

Returns the limit of entries in the list per mode, or -1 if the limitation is not known.

See also
modes()

◆ modes()

QStringList IrcNetwork::modes ( ) const

This property holds the supported channel user mode letters.

Examples of typical channel user modes:

Description Mode Prefix
Channel operator o @
Voiced user v +
Access function:
  • QStringList modes() const
Notifier signal:
  • void modesChanged(const QStringList& modes)
See also
prefixes, modeToPrefix()

◆ modeToPrefix()

QString IrcNetwork::modeToPrefix ( const QString &  mode) const

Converts a channel user mode letter to a prefix character.

See also
modes, prefixToMode()

◆ name()

QString IrcNetwork::name ( ) const

This property holds the network name.

Access function:
  • QString name() const
Notifier signal:
  • void nameChanged(const QString& name)

◆ numericLimit()

int IrcNetwork::numericLimit ( IrcNetwork::Limit  limit) const

Returns a numeric type of limit, or -1 if the limitation is not known.

See also
modeLimit(), channelLimit(), targetLimit()

◆ prefixes()

QStringList IrcNetwork::prefixes ( ) const

This property holds the supported channel user mode prefix characters.

Examples of typical channel user modes:

Description Mode Prefix
Channel operator o @
Voiced user v +
Access function:
  • QStringList prefixes() const
Notifier signal:
  • void prefixesChanged(const QStringList& prefixes)
See also
modes, prefixToMode(), statusPrefixes

◆ prefixToMode()

QString IrcNetwork::prefixToMode ( const QString &  prefix) const

Converts a channel mode prefix character to a mode letter.

See also
prefixes, modeToPrefix()

◆ requestCapabilities

bool IrcNetwork::requestCapabilities ( const QStringList &  capabilities)
slot

Requests the specified capabilities.

Note
The capabilities are NOT added to the list of requested capabilities to avoid them "piling up".

◆ requestCapability

bool IrcNetwork::requestCapability ( const QString &  capability)
slot

Requests the specified capability.

Note
The capability is NOT added to the list of requested capabilities to avoid them "piling up".

◆ requestedCapabilities()

QStringList IrcNetwork::requestedCapabilities ( ) const

This property holds the requested capabilities.

These capabilities are automatically requested during the handshake, right after requestingCapabilities() has been emitted.

Access functions:
  • QStringList requestedCapabilities() const
  • void setRequestedCapabilities(const QStringList& capabilities)
Notifier signal:
  • void requestedCapabilitiesChanged(const QStringList& capabilities)
See also
availableCapabilities, activeCapabilities

◆ requestingCapabilities

void IrcNetwork::requestingCapabilities ( )
signal

This signal is emitted when capabilities are being requested.

Normally it is enough to add the desired capabilities to the list of requested capabilities. Connect to this signal in order to implement more advanced capability handling eg. based on which capabilities are available.

See also
requestedCapabilities, availableCapabilities

◆ skipCapabilityValidation()

bool IrcNetwork::skipCapabilityValidation ( ) const

This property specifies whether we should request capabilities right away after establishing connecting or not. Otherwise, we wait for CAP * LS and check if capabilities we're about to request are supported by the server.

By default this is set to false

Access functions:
  • bool skipCapabilityValidation() const
  • void setSkipCapabilityValidation(bool skip)
Notifier signal:
  • void skipCapabilityValidationChanged(bool skip)

◆ statusPrefixes()

QStringList IrcNetwork::statusPrefixes ( ) const
Since
3.4

This property holds the supported message status prefixes.

The server supports messaging channel members who have a certain status or higher.

Access function:
  • QStringList statusPrefixes() const
Notifier signal:
  • void statusPrefixesChanged(const QStringList& prefixes)
See also
prefixes

◆ targetLimit()

int IrcNetwork::targetLimit ( const QString &  command) const

Returns the limit of targets for a command, or -1 if the limitation is not known.

Property Documentation

◆ initialized

bool IrcNetwork::initialized
read

This property holds whether the network information has been initialized.

Most properties have empty values until the server provides the relevant network information during the client-server handshake.

Access function:
  • bool isInitialized() const
Notifier signal:
  • void initialized()