GXmppNetwork.h

00001 /***************************************************************************
00002  *   Copyright (C) 2004 - 2005 by Raphael Langerhorst                      *
00003  *   raphael-langerhorst@gmx.at                                            *
00004  *                                                                         *
00005  *   Permission is hereby granted, free of charge, to any person obtaining *
00006  *   a copy of this software and associated documentation files (the       *
00007  *   "Software"), to deal in the Software without restriction, including   *
00008  *   without limitation the rights to use, copy, modify, merge, publish,   *
00009  *   distribute, sublicense, and/or sell copies of the Software, and to    *
00010  *   permit persons to whom the Software is furnished to do so, subject to *
00011  *   the following conditions:                                             *
00012  *                                                                         *
00013  *   The above copyright notice and this permission notice shall be        *
00014  *   included in all copies or substantial portions of the Software.       *
00015  *                                                                         *
00016  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       *
00017  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    *
00018  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*
00019  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR     *
00020  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
00021  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
00022  *   OTHER DEALINGS IN THE SOFTWARE.                                       *
00023  ***************************************************************************/
00024 
00025 #ifndef GXMPPNETWORK_H
00026 #define GXMPPNETWORK_H
00027 
00028 #include "GXmlNetwork.h"
00029 
00030 #include <QMap>
00031 #include <xmpp.h>
00032 // #include <qca.h>
00033 #include <qmutex.h>
00034 //Added by qt3to4:
00035 #include <QCustomEvent>
00036 
00037 class QCustomEvent;
00038 
00039 namespace GWE
00040 {
00041 
00042 class GNetworkMessageQueue;
00043 
00063 class GXmppNetwork : public GXmlNetwork, protected QMutex
00064 {
00065   Q_OBJECT
00066   
00067   private:
00068   
00072   QString Password;
00073   
00074   protected:
00075   
00079   bool Active;
00080   
00084   bool Connected;
00085   
00089   bool Connecting;
00090   
00094   bool XmppLayerCreated;
00095   
00099   XMPP::AdvancedConnector* XmppConnector;
00100   
00104   QCA::TLS* Tls;
00105   
00109   XMPP::QCATLSHandler* TlsHandler;
00110   
00114   XMPP::ClientStream* Stream;
00115   
00120   XMPP::Jid NetworkId;
00121   
00129   QMap<QString,QString> SubscriptionStates;
00130   
00139   GNetworkMessageQueue* MessageQueue;
00140   
00147   bool StayConnected;
00148   
00149   protected slots:
00150   
00154   bool createXmppLayer();
00155   
00162   bool deleteXmppLayer(bool force);
00163   
00164   protected:
00165     
00175     virtual void customEvent(QEvent* event);
00176     
00180     bool isSubscribed(QString destination);
00181     
00186     void sendQueuedMessages(QString destination);
00187 
00188   protected slots:
00189 
00193     void sendHeartbeat();
00194   
00195   public:
00196   
00202   GXmppNetwork(QString full_jid = "", QObject *parent = 0);
00203 
00208   virtual ~GXmppNetwork();
00209   
00210   // GXmlNetwork implementation BEGIN //
00211 
00212   virtual bool isConnected();
00213 
00219   virtual QString getNetworkId() const;
00220   
00221   public slots:
00222   
00226   virtual bool initNetwork();
00227   
00233   virtual void reconnectNetwork();
00234    
00241   virtual bool closeNetwork();
00242   
00246   virtual void setPassword(const QString& password);
00247   
00248    
00249   // DATA TRANSPORTING
00250    
00262   virtual bool send(QDomElement data, const QString& destination);
00263 
00273   virtual bool send(const QString& data);
00274   
00278   virtual bool flushOutput();
00279   
00291   virtual void makeDestinationAvailable(const QString& destination);
00292   
00293   // GXmlNetwork implementation END //
00294   
00295   
00296   // XMPP slots and signals for network management BEGIN //
00297    
00298   protected slots:
00299   
00300   // CONNECTOR SLOTS //
00301   
00302   void connectorServerLookup(const QString& server);
00303   void connectorServerResult(bool success);
00304   void connectorHttpSyncStarted();
00305   void connectorHttpSyncFinished();
00306   
00307   // TLS SLOTS //
00308   
00309   void tlsHandshaken();
00310   
00311   // STREAM SLOTS //
00312   
00313   void clientStreamConnected();
00314   void clientStreamSecurityLayerActivated(int);
00315   void clientStreamNeedAuthenticationParameters(bool,bool,bool);
00316   void clientStreamAuthenticated();
00317   void clientStreamConnectionClosed();
00318   void clientStreamDelayedCloseFinished();
00319   void clientStreamReadyRead();
00320   void clientStreamStanzaWritten();
00321   
00322   void clientStreamWarning(int w);
00323   void clientStreamError(int e);
00324   
00325   // XMPP slots and signals for network management END //
00326   
00327 };
00328 
00329 }
00330 
00331 #endif //GXMPPNETWORK_H
00332 

Generated on Thu Nov 16 07:49:12 2006 for G System by  doxygen 1.4.7