Communi  3.0.0
A cross-platform IRC framework written with Qt
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Macros Groups Pages
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
}
 
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

Q_INVOKABLE int channelLimit (const QString &type) const
 
Q_INVOKABLE QStringList channelModes (IrcNetwork::ModeTypes types) 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
 
Q_INVOKABLE QString modeToPrefix (const QString &mode) const
 
Q_INVOKABLE int numericLimit (IrcNetwork::Limit limit) const
 
Q_INVOKABLE QString prefixToMode (const QString &prefix) const
 
Q_INVOKABLE int targetLimit (const QString &command) const
 

Properties

QStringList activeCapabilities
 
QStringList availableCapabilities
 
QStringList channelTypes
 
bool initialized
 
QStringList modes
 
QString name
 
QStringList prefixes
 
QStringList requestedCapabilities
 

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 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

Member Enumeration Documentation

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.

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

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()
QStringList IrcNetwork::channelModes ( IrcNetwork::ModeTypes  types) const

Returns the supported channel modes for specified types.

See Also
ModeType
bool IrcNetwork::hasCapability ( const QString capability) const

Returns true if the capability is available.

See Also
availableCapabilities
bool IrcNetwork::isCapable ( const QString capability) const

Returns true if the capability is active.

See Also
activeCapabilities
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
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()
QString IrcNetwork::modeToPrefix ( const QString mode) const

Converts a channel user mode letter to a prefix character.

See Also
modes, prefixToMode()
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()
QString IrcNetwork::prefixToMode ( const QString prefix) const

Converts a channel mode prefix character to a mode letter.

See Also
prefixes, modeToPrefix()
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".
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".
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
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

QStringList IrcNetwork::activeCapabilities
read

This property holds the active capabilities.

Access function:
Notifier signal:
  • void activeCapabilitiesChanged(const QStringList& capabilities)
See Also
requestedCapabilities, availableCapabilities
QStringList IrcNetwork::availableCapabilities
read

This property holds the available capabilities.

Access function:
Notifier signal:
  • void availableCapabilitiesChanged(const QStringList& capabilities)
See Also
requestedCapabilities, activeCapabilities
QStringList IrcNetwork::channelTypes
read

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:
Notifier signal:
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()
QStringList IrcNetwork::modes
read

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:
Notifier signal:
See Also
prefixes, modeToPrefix()
QString IrcNetwork::name
read

This property holds the network name.

Access function:
Notifier signal:
  • void nameChanged(const QString& name)
QStringList IrcNetwork::prefixes
read

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:
Notifier signal:
See Also
modes, prefixToMode()
QStringList IrcNetwork::requestedCapabilities
readwrite

This property holds the requested capabilities.

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

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