QXmpp Version:0.3.0
|
00001 /* 00002 * Copyright (C) 2008-2011 The QXmpp developers 00003 * 00004 * Authors: 00005 * Manjeet Dahiya 00006 * Jeremy Lainé 00007 * 00008 * Source: 00009 * http://code.google.com/p/qxmpp 00010 * 00011 * This file is a part of QXmpp library. 00012 * 00013 * This library is free software; you can redistribute it and/or 00014 * modify it under the terms of the GNU Lesser General Public 00015 * License as published by the Free Software Foundation; either 00016 * version 2.1 of the License, or (at your option) any later version. 00017 * 00018 * This library is distributed in the hope that it will be useful, 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00021 * Lesser General Public License for more details. 00022 * 00023 */ 00024 00025 00026 #ifndef QXMPPSTREAM_H 00027 #define QXMPPSTREAM_H 00028 00029 #include <QObject> 00030 #include "QXmppLogger.h" 00031 00032 class QDomElement; 00033 class QSslSocket; 00034 class QXmppPacket; 00035 class QXmppStreamPrivate; 00036 00039 00040 class QXmppStream : public QXmppLoggable 00041 { 00042 Q_OBJECT 00043 00044 public: 00045 QXmppStream(QObject *parent); 00046 ~QXmppStream(); 00047 00048 virtual bool isConnected() const; 00049 virtual void disconnectFromHost(); 00050 00051 virtual bool sendData(const QByteArray&); 00052 bool sendElement(const QDomElement&); 00053 bool sendPacket(const QXmppPacket&); 00054 00055 signals: 00057 void connected(); 00058 00060 void disconnected(); 00061 00062 protected: 00063 // Access to underlying socket 00064 QSslSocket *socket() const; 00065 void setSocket(QSslSocket *socket); 00066 00067 // Overridable methods 00068 virtual void handleStart(); 00069 00073 virtual void handleStanza(const QDomElement &element) = 0; 00074 00078 virtual void handleStream(const QDomElement &element) = 0; 00079 00080 private slots: 00081 void socketConnected(); 00082 void socketDisconnected(); 00083 void socketEncrypted(); 00084 void socketReadyRead(); 00085 00086 private: 00087 QXmppStreamPrivate * const d; 00088 }; 00089 00090 #endif // QXMPPSTREAM_H