GWE::GXmppNetwork Class Reference

Implements XML based networking using the XMPP-Core protocol. More...

#include <GXmppNetwork.h>

Inheritance diagram for GWE::GXmppNetwork:

Inheritance graph
[legend]
Collaboration diagram for GWE::GXmppNetwork:

Collaboration graph
[legend]
List of all members.

Public Slots

virtual bool initNetwork ()
virtual void reconnectNetwork ()
virtual bool closeNetwork ()
virtual void setPassword (const QString &password)
virtual bool send (QDomElement data, const QString &destination)
virtual bool send (const QString &data)
virtual bool flushOutput ()
virtual void makeDestinationAvailable (const QString &destination)

Public Member Functions

 GXmppNetwork (QString full_jid="", QObject *parent=0)
virtual ~GXmppNetwork ()
virtual bool isConnected ()
virtual QString getNetworkId () const

Protected Slots

bool createXmppLayer ()
bool deleteXmppLayer (bool force)
void sendHeartbeat ()
void connectorServerLookup (const QString &server)
void connectorServerResult (bool success)
void connectorHttpSyncStarted ()
void connectorHttpSyncFinished ()
void tlsHandshaken ()
void clientStreamConnected ()
void clientStreamSecurityLayerActivated (int)
void clientStreamNeedAuthenticationParameters (bool, bool, bool)
void clientStreamAuthenticated ()
void clientStreamConnectionClosed ()
void clientStreamDelayedCloseFinished ()
void clientStreamReadyRead ()
void clientStreamStanzaWritten ()
void clientStreamWarning (int w)
void clientStreamError (int e)

Protected Member Functions

virtual void customEvent (QEvent *event)
bool isSubscribed (QString destination)
void sendQueuedMessages (QString destination)

Protected Attributes

bool Active
bool Connected
bool Connecting
bool XmppLayerCreated
XMPP::AdvancedConnector * XmppConnector
QCA::TLS * Tls
XMPP::QCATLSHandler * TlsHandler
XMPP::ClientStream * Stream
XMPP::Jid NetworkId
QMap< QString, QString > SubscriptionStates
GNetworkMessageQueue * MessageQueue
bool StayConnected

Private Attributes

QString Password

Detailed Description

Implements XML based networking using the XMPP-Core protocol.

GXmppNetwork GXmppNetwork.h

Author:
Raphael Langerhorst
This XML network implementation represents the GWE Server as an XMPP client.

This Network implementation uses the XMPP library Iris, by Justin Karneges.

Please note that the GXmppNetwork class just provides the protocol regarding XMPP. The communication logic between GWE Servers is fully included in the GXmlDataController which just uses this class for data transport. The GXmppNetwork takes care of different stanza kinds. Tags in a message stanza are handled as normal messages and handed to the data controller.

See also:
http://www.xmpp.org/

http://delta.affinix.com/iris/


Constructor & Destructor Documentation

GWE::GXmppNetwork::GXmppNetwork ( QString  full_jid = "",
QObject *  parent = 0 
)

Constructors

Parameters:
full_jid a string representation of a full JID as defined by the XMPP protocol
See also:
setJid()

GWE::GXmppNetwork::~GXmppNetwork (  )  [virtual]

Virtual Destructor. All active network connections are closed.


Member Function Documentation

bool GWE::GXmppNetwork::closeNetwork (  )  [virtual, slot]

Shuts down the network. This should be called when the GWE Server is shutting down, and AFTER all required tasks were performed to allow safe shutdown (moving data to other server, etc.).

Implements GWE::GXmlNetwork.

bool GWE::GXmppNetwork::createXmppLayer (  )  [protected, slot]

Creates all XMPP related member objects: XmppConnector, Tls, TlsHandler, Stream.

void GWE::GXmppNetwork::customEvent ( QEvent *  event  )  [protected, virtual]

Processes queued data events - if pending data has to be sent. The recognised event type is QCustomEvent with type 65001 and data should be a (pointer to a) QString. These strings are then sent out.

All event creation is done internally, in particular in the send methods.

bool GWE::GXmppNetwork::deleteXmppLayer ( bool  force  )  [protected, slot]

Deletes all XMPP related member objects - be careful!! Shut down the network beforehand.

Parameters:
force if set to TRUE then all objects will be deleted no matter what the state varaibles are.
See also:
closeNetwork()
Note:
This gets automatically called when the object is deleted.

bool GWE::GXmppNetwork::flushOutput (  )  [virtual, slot]

Send all pending output data. This call blocks until all data was sent.

Implements GWE::GXmlNetwork.

QString GWE::GXmppNetwork::getNetworkId (  )  const [virtual]

Returns:
the network ID of this GWE Server instance.
See also:
NetworkId

Implements GWE::GXmlNetwork.

bool GWE::GXmppNetwork::initNetwork (  )  [virtual, slot]

Initialization.

Implements GWE::GXmlNetwork.

bool GWE::GXmppNetwork::isConnected (  )  [virtual]

Returns:
true when the network is connected and usable, otherwise false

Implements GWE::GXmlNetwork.

bool GWE::GXmppNetwork::isSubscribed ( QString  destination  )  [protected]

Checks if presence subscription is active for given destination.

void GWE::GXmppNetwork::makeDestinationAvailable ( const QString &  destination  )  [virtual, slot]

Subscribes presence with given destination. This will either result in a destination not available if the destination is offline or in a successfull presence subscription in which case the destination is available.

Available status is communicated with the signal presenceChanged(QString server, bool available)

See also:
GXmlNetwork::presenceChanged();

Implements GWE::GXmlNetwork.

void GWE::GXmppNetwork::reconnectNetwork (  )  [virtual, slot]

Issues a single shot timer to call initNetwork() Useful when wanting to reconnect but being in the middle of something (that is, in a slot)

bool GWE::GXmppNetwork::send ( const QString &  data  )  [virtual, slot]

Given string is directly sent, it's the responsibility of the application to make it XML compliant.

Do not forget that the above send member function creates a message XML element in which the given data is inserted. Here, such an element is not created, if it should be present, it has to be included in the given data string.

Implements GWE::GXmlNetwork.

bool GWE::GXmppNetwork::send ( QDomElement  data,
const QString &  destination 
) [virtual, slot]

Add data for transportation.

This method constructs a message XML element with a to attribute set to given destination. Inside this element the actual data is inserted.

Parameters:
data The data that will be sent to the given network destination.
destination The GWE Server to which the data should be sent to.
See also:
flushOutput()

Implements GWE::GXmlNetwork.

void GWE::GXmppNetwork::sendHeartbeat (  )  [protected, slot]

Sends a <presence> heartbeat.

void GWE::GXmppNetwork::sendQueuedMessages ( QString  destination  )  [protected]

Checks if any messages are queued for given destination and sends all queued messages.

void GWE::GXmppNetwork::setPassword ( const QString &  password  )  [virtual, slot]

Sets the password to be used, clear text at the moment!!

Implements GWE::GXmlNetwork.


Member Data Documentation

bool GWE::GXmppNetwork::Active [protected]

Network connection active.

bool GWE::GXmppNetwork::Connected [protected]

Connected to the XMPP network.

bool GWE::GXmppNetwork::Connecting [protected]

Currently connecting?

GNetworkMessageQueue* GWE::GXmppNetwork::MessageQueue [protected]

As long as two communication partners are not subscribed to each other information cannot be exchanged. If data is to be sent, the first thing to do is to create a presence subscription. As soon as a communication partner is subscribed, queued messages that are stored in this message queue can be sent for the particular peer.

XMPP::Jid GWE::GXmppNetwork::NetworkId [protected]

The JID that identifies this GWE Server in an XMPP network.

Note:
A GWE Server instance is a client in the sense of an XMPP network!

QString GWE::GXmppNetwork::Password [private]

The password used for authentication.

bool GWE::GXmppNetwork::StayConnected [protected]

Set to true if the network should stay connected. In this case reinitializing the network will be done automatically if the network got disconnected. closeNetwork() sets this to false before shutting down.

XMPP::ClientStream* GWE::GXmppNetwork::Stream [protected]

The stream that is used to transport data.

QMap<QString,QString> GWE::GXmppNetwork::SubscriptionStates [protected]

Stores the subscription state of known servers. This XmppNetwork class always tries to achieve a subscription state of "subscribed". The map key's are the servers and the subscription states are the values. See RFC 3921 for possible states.

QCA::TLS* GWE::GXmppNetwork::Tls [protected]

TLS for security.

XMPP::QCATLSHandler* GWE::GXmppNetwork::TlsHandler [protected]

TLS handler used by the connection.

XMPP::AdvancedConnector* GWE::GXmppNetwork::XmppConnector [protected]

CMPP Connection to an XMPP Server.

bool GWE::GXmppNetwork::XmppLayerCreated [protected]

XMPP related objects created.


The documentation for this class was generated from the following files:
Generated on Thu Nov 16 07:49:41 2006 for G System by  doxygen 1.4.7