00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef GXMPPNETWORK_H
00026 #define GXMPPNETWORK_H
00027
00028 #include "GXmlNetwork.h"
00029
00030 #include <QMap>
00031 #include <xmpp.h>
00032
00033 #include <qmutex.h>
00034
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
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
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
00294
00295
00296
00297
00298 protected slots:
00299
00300
00301
00302 void connectorServerLookup(const QString& server);
00303 void connectorServerResult(bool success);
00304 void connectorHttpSyncStarted();
00305 void connectorHttpSyncFinished();
00306
00307
00308
00309 void tlsHandshaken();
00310
00311
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
00326
00327 };
00328
00329 }
00330
00331 #endif //GXMPPNETWORK_H
00332