LeechCraft Azoth  0.6.70-15082-g543737046d
Modular multiprotocol IM plugin for LeechCraft
LC::Azoth::IProtocol Class Referenceabstract

Represents a protocol. More...

#include "iprotocol.h"

Public Types

enum  ProtocolFeature {
  PFNone = 0x0, PFSupportsMUCs = 0x01, PFMUCsJoinable = 0x02, PFSupportsInBandRegistration = 0x04,
  PFNoAccountRegistration = 0x08
}
 
enum  AccountAddOption { AAONoOptions = 0, AAORegisterNewAccount = 0x01 }
 

Public Member Functions

virtual ~IProtocol ()
 
virtual QObject * GetQObject ()=0
 Returns the protocol object as a QObject. More...
 
virtual ProtocolFeatures GetFeatures () const =0
 
virtual QList< QObject * > GetRegisteredAccounts ()=0
 Returns the accounts within this protocol. More...
 
virtual QObject * GetParentProtocolPlugin () const =0
 Returns the pointer to the parent protocol plugin that this protocol belongs to. More...
 
virtual QString GetProtocolName () const =0
 Returns the human-readable name of this protocol, like "Jabber" or "ICQ". More...
 
virtual QIcon GetProtocolIcon () const =0
 Returns the icon of this protocol. More...
 
virtual QByteArray GetProtocolID () const =0
 Returns the protocol ID, which must be unique among all the protocols. More...
 
virtual QList< QWidget * > GetAccountRegistrationWidgets (AccountAddOptions options)=0
 Returns the widgets used for account addition. More...
 
virtual void RegisterAccount (const QString &name, const QList< QWidget * > &widgets)=0
 Adds an account with the given name and widgets. More...
 
virtual void RemoveAccount (QObject *account)=0
 Removes the given account. More...
 
virtual void accountAdded (QObject *account)=0
 Notifies about new account. More...
 
virtual void accountRemoved (QObject *account)=0
 Notifies about an account having been removed. More...
 

Detailed Description

Represents a protocol.

IProtocol class represents a single protocol with its own set of accounts.

A protocol may also implement IURIHandler if it supports handling of various URIs, like xmpp: for XMPP protocol.

When user decides to add a new account within this protocol, the GetAccountRegistrationWidgets() function is called to get the list of widgets that should be filled out by the user by the exact values of his account, and if the user accepts the registration, RegisterAccount() would be called with those widgets.

See also
IURIHandler

Definition at line 41 of file iprotocol.h.

Member Enumeration Documentation

◆ AccountAddOption

This enum describes the options that may be selected by the user when adding a new account.

Enumerator
AAONoOptions 

No custom options.

AAORegisterNewAccount 

User has chosen to register a new account (if the protocol advertises PFSupportsInBandRegistration feature).

Definition at line 86 of file iprotocol.h.

◆ ProtocolFeature

This enum describes the features that may be supported by a protocol.

Enumerator
PFNone 

None of these features are supported by the protocol.

PFSupportsMUCs 

Multiuser chats are possible in this proto.

PFMUCsJoinable 

One could join MUCs as he wishes.

       If this feature is supported, a proper widget should be
       returned from the GetMUCJoinWidget() method.
PFSupportsInBandRegistration 

This protocol supports in-band registration: accounts could be registered right from the client.

See also
IRegManagedAccount
PFNoAccountRegistration 

This protocol doesn't support registering new accounts.

       This may be usable for dummy protocols for implementing
       things like metacontacts, for example.

Definition at line 49 of file iprotocol.h.

Constructor & Destructor Documentation

◆ ~IProtocol()

virtual LC::Azoth::IProtocol::~IProtocol ( )
inlinevirtual

Definition at line 44 of file iprotocol.h.

Member Function Documentation

◆ accountAdded()

virtual void LC::Azoth::IProtocol::accountAdded ( QObject *  account)
pure virtual

Notifies about new account.

This signal should be emitted whenever a new account appears in this protocol.

Note
This function is expected to be a signal.
Parameters
[out]accountThe newly added account, which must implement IAccount.

◆ accountRemoved()

virtual void LC::Azoth::IProtocol::accountRemoved ( QObject *  account)
pure virtual

Notifies about an account having been removed.

This signal should be emitted whenever an already registered account is removed, for example, as the result of the call to RemoveAccount().

Note
This function is expected to be a signal.
Parameters
[out]accountThe just removed account, which must implement IAccount.

◆ GetAccountRegistrationWidgets()

virtual QList<QWidget*> LC::Azoth::IProtocol::GetAccountRegistrationWidgets ( AccountAddOptions  options)
pure virtual

Returns the widgets used for account addition.

The widgets from the returned list are shown in the account addition wizard in the same order they appear in the returned list.

If the user accepts registering the account, the RegisterAccount() method would be called with the same set of widgets in the same order as returned from this function.

The ownership is transferred to the caller.

Parameters
[in]optionsThe options selected by the user to perform the account addition.
Returns
The widgets to be shown and filled by the user.
See also
RegisterAccount()

◆ GetFeatures()

virtual ProtocolFeatures LC::Azoth::IProtocol::GetFeatures ( ) const
pure virtual

Returns the list of features supported by this protocol.

◆ GetParentProtocolPlugin()

virtual QObject* LC::Azoth::IProtocol::GetParentProtocolPlugin ( ) const
pure virtual

Returns the pointer to the parent protocol plugin that this protocol belongs to.

Returns
The parent protocol plugin of this protocol, which must implement IProtocolPlugin.

◆ GetProtocolIcon()

virtual QIcon LC::Azoth::IProtocol::GetProtocolIcon ( ) const
pure virtual

Returns the icon of this protocol.

Returns
The icon of the protocol.

◆ GetProtocolID()

virtual QByteArray LC::Azoth::IProtocol::GetProtocolID ( ) const
pure virtual

Returns the protocol ID, which must be unique among all the protocols.

Returns
The unique ID of this protocol.

◆ GetProtocolName()

virtual QString LC::Azoth::IProtocol::GetProtocolName ( ) const
pure virtual

Returns the human-readable name of this protocol, like "Jabber" or "ICQ".

Returns
Human-readable name of the protocol.

◆ GetQObject()

virtual QObject* LC::Azoth::IProtocol::GetQObject ( )
pure virtual

Returns the protocol object as a QObject.

Returns
Protocol object as QObject.

◆ GetRegisteredAccounts()

virtual QList<QObject*> LC::Azoth::IProtocol::GetRegisteredAccounts ( )
pure virtual

Returns the accounts within this protocol.

Each object in the returned list must implement IAccount.

Returns
The list of accounts of this protocol.

◆ RegisterAccount()

virtual void LC::Azoth::IProtocol::RegisterAccount ( const QString &  name,
const QList< QWidget * > &  widgets 
)
pure virtual

Adds an account with the given name and widgets.

The list of widgets is the same (and in the same order) as returned from the GetAccountRegistrationWidgets() function. If this method is called, the widgets were shown to the user, and the user has accepted the account registration, so the widgets would be filled by the user to contain the required values. One could use qobject_cast to cast each widget in the list to the exact widget type and then use the values filled by the user.

If the account is added successfully, the accountAdded() signal should be emitted, otherwise nothing should be done.

Note
Since ownership of the widgets is transferred to the caller, one shouldn't delete widgets in this method, and one shouldn't store them to use after this function has returned.
Parameters
[in]nameThe name of the account to be registered.
[in]widgetsThe list of widgets returned from the GetAccountRegistrationWidgets() and filled by the user.
See also
GetAccountRegistrationWidgets()

◆ RemoveAccount()

virtual void LC::Azoth::IProtocol::RemoveAccount ( QObject *  account)
pure virtual

Removes the given account.

This function shouldn't ask anything from the user, just remove the account.

If the account is not registered, this function should do nothing.

After the removal, the accountRemoved() signal is expected to be emitted.

Parameters
[in]accountThe account to remove.

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