GNUMessenger::Protocol Class Reference

The Protocol abstract base class. More...

#include <protocol.h>

Inheritance diagram for GNUMessenger::Protocol:

Inheritance graph
[legend]
Collaboration diagram for GNUMessenger::Protocol:

Collaboration graph
[legend]
List of all members.

Public Types

enum  Errors {
  E_invalidLogin, E_userTaken, E_protocol, E_network,
  E_success
}
enum  State {
  S_offline = 0, S_invalid, S_online, S_connecting,
  S_disconnecting
}
enum  Status {
  S_available, S_away, S_na, S_occupied,
  S_dnd, S_ffc, S_off
}

Public Member Functions

 Protocol (const XMLNode &xml, ProtocolManager *manager, const string &name)
 Protocol constructor, associates a protocol with a XML configuration, a ProtocolManager, and a name.
virtual ~Protocol ()
 The Protocol destructor will attempt to destroy all of the associated Network objects in an implementation dependant way by using the function ProtocolManager::removeNet if (for some TERRIBLE reason) the manager pointer is null, the destructor will simply call delete on the pointers.
virtual void changeSettings (XMLNode &conf)
 Updates the protocol configuration and calls reset().
virtual void reset ()=0
 Resets the protocol by disconnecting and reconnecting to the network.
virtual State getState () const
 Returns the state of the network connection.
virtual Status getStatus () const
 Returns the user-defined statues of the protocol.
virtual const string & getProtocol ()
 Returns the text string name of the protocol.
virtual const string getLoginName ()=0
 Returns the text string name used to login to the protocol.
virtual void update ()
 In a non-event based system this call will check the network for incoming data and will call appropriate handlers.
virtual void login ()=0
 Initiates the login sequence for this protocol.
virtual void logout ()=0
 Sends the protocol the log-out request and disconnects the socket (Network).
virtual void shutdown ()=0
virtual bool sendMessage (const Contact &recipient, const string &message)=0
 Tries to send a message to a Contact via this protocol.
virtual bool sendMessage (const Contact &recipient, const VBuffer &data)
 Tries to send a data message to a Contact.
virtual void addContact (const Contact &contact)=0
virtual void delContact (const Contact &contact)=0
virtual void newUser (const string &userName, const VBuffer &password)=0
virtual void setAway (const string &msg="")
virtual void setInfo (const string &info="")
virtual void handleData (Network *net)=0
virtual void handleData (Network *net, const string &data)=0
virtual void handleData (Network *net, const VBuffer &data)
virtual void connectionError (Network *net, int error)=0
virtual void connectedToServer (Network *net)
virtual void clearBuddies ()
 I don't know what you'd want to do this.
void setConfig (XMLNode conf)
 Set the configureation settings from this network, you'll need to reset to make any account/server settings activate.
virtual list< Network * > getNetworks ()
 Get the list of all sockets used by this protocol.
unsigned long getSentBytes () const
 Return the number of bytes sent, recv-ed, packets, etc.
unsigned long getSentPackets () const
unsigned long getRecvBytes () const
unsigned long getRecvPackets () const
vector< string > getRemoteIPs () const
 Try to get list of remote IPs/Hosts from the sockets that this protocol uses.
virtual void setContacts (vector< Contact > &cnts)
 Used at statup, sets all contacts from a vector of Contact that was, most likely, obtained from the XMLManager.
virtual void getInfo (const string &contact)=0
 Get information about this contact, ie: away message/profile.

Protected Types

typedef map< string, Contactbuddy_t

Protected Member Functions

virtual string formatId (const string &id)
void eventLoggedIn ()
void eventLoggedOut ()
void eventRecvdMessage (const Contact &c, const string &message)
void eventRecvdMessageNotBuddy (const Contact &c, const string &message)
void eventStatusChange (const Contact &c)
void eventError (int err_no, const string &error)
void eventStateChange (State state)
void eventGotPubkey (const Contact &c, const string &key)
void eventGotCustom (const XMLNode &n)
void eventGotContacts (const vector< buddy > &c)
void eventGotInfo (const Contact &c, const string &info)
virtual NetworkaddNet ()
virtual void removeNet (Network *)

Protected Attributes

Status m_status
XMLNode m_conf
 xml config for protocol
map< string, Contactm_buddies
list< Network * > m_nets

Detailed Description

The Protocol abstract base class.

Author:
Emil Styrke

Jesse Lovelace

Henrik Abelsson

Definition at line 61 of file protocol.h.


Constructor & Destructor Documentation

GNUMessenger::Protocol::Protocol const XMLNode xml,
ProtocolManager manager,
const string &  name
 

Protocol constructor, associates a protocol with a XML configuration, a ProtocolManager, and a name.

Parameters:
xml The protocol settings
manager A pointer to the controlling ProtocolManager
name The name of this protocol
Definition at line 33 of file protocol.cpp.

References GNUMessenger::ProtocolManager::addProtocol().

00034 : 00035 m_conf(conf), m_manager(manager), m_name(name), m_state(S_offline) 00036 { 00037 if (m_manager) { 00038 m_manager->addProtocol(this); 00039 } 00040 }

Here is the call graph for this function:


Member Function Documentation

void GNUMessenger::Protocol::changeSettings XMLNode conf  )  [virtual]
 

Updates the protocol configuration and calls reset().

Parameters:
conf The new XMLNode configuration.
Definition at line 68 of file protocol.cpp.

References m_conf, and reset().

00069 { 00070 m_conf = conf; 00071 reset(); 00072 }

Here is the call graph for this function:

virtual const string& GNUMessenger::Protocol::getProtocol  )  [inline, virtual]
 

Returns the text string name of the protocol.

Definition at line 125 of file protocol.h.

Referenced by GNUMessenger::TocProtocol::addContact(), GNUMessenger::ProtocolManager::addProtocol(), and setContacts().

00125 { return m_name; }

virtual State GNUMessenger::Protocol::getState  )  const [inline, virtual]
 

Returns the state of the network connection.

Returns:
Enumerated State value.
Definition at line 114 of file protocol.h.

Referenced by GNUMessenger::TocProtocol::addContact(), and GNUMessenger::TocProtocol::handleRealData().

00114 {return m_state;}

virtual Status GNUMessenger::Protocol::getStatus  )  const [inline, virtual]
 

Returns the user-defined statues of the protocol.

Returns:
Enumerated Status value.
Definition at line 120 of file protocol.h.
00120 {return m_status;}

virtual void GNUMessenger::Protocol::login  )  [pure virtual]
 

Initiates the login sequence for this protocol.

Note:
This call in no way guarentees that the login attempt was successful. That information will be relayed by an error callback.

Implemented in GNUMessenger::IcqProtocol, GNUMessenger::KitProtocol, GNUMessenger::MsnProtocol, GNUMessenger::TocProtocol, and GNUMessenger::YahooProtocol.

virtual void GNUMessenger::Protocol::reset  )  [pure virtual]
 

Resets the protocol by disconnecting and reconnecting to the network.

All configuration settings are re-read.

Implemented in GNUMessenger::IcqProtocol, GNUMessenger::KitProtocol, GNUMessenger::MsnProtocol, GNUMessenger::TocProtocol, and GNUMessenger::YahooProtocol.

Referenced by changeSettings().

virtual bool GNUMessenger::Protocol::sendMessage const Contact recipient,
const VBuffer data
[inline, virtual]
 

Tries to send a data message to a Contact.

Parameters:
recipient The intended reciever.
data A VBuffer containing binary data.
Note:
This call is protocol specific and my not be implemented on all protocols (commonly because of rate-limiting). An option to send the data peer-2-peer could be provided by the client GUI.
Returns:
False if the Contact is not subscribed, the Protocol is not online, or if the function is not implemented.
Definition at line 177 of file protocol.h.
00177 { return false; }

virtual bool GNUMessenger::Protocol::sendMessage const Contact recipient,
const string &  message
[pure virtual]
 

Tries to send a message to a Contact via this protocol.

Parameters:
recipient The intended recipient.
message The text message to send.
Note:
This call does not mean the contact has recieved the message, that is network dependent and my fail. If a fail should occur, an appropriate error callback will be called.
Returns:
False if the Contact is not subscribed to this protocol or if the protocol is offline.

Implemented in GNUMessenger::IcqProtocol, GNUMessenger::KitProtocol, GNUMessenger::MsnProtocol, GNUMessenger::TocProtocol, and GNUMessenger::YahooProtocol.

virtual void GNUMessenger::Protocol::update  )  [inline, virtual]
 

In a non-event based system this call will check the network for incoming data and will call appropriate handlers.

Reimplemented in GNUMessenger::KitProtocol, GNUMessenger::MsnProtocol, GNUMessenger::TocProtocol, and GNUMessenger::YahooProtocol.

Definition at line 136 of file protocol.h.

00136 {}


The documentation for this class was generated from the following files:
Generated on Tue Oct 5 14:41:57 2004 for GNU Messenger by doxygen 1.3.8