QXmpp  Version:0.9.3
QXmppStream.h
00001 /*
00002  * Copyright (C) 2008-2014 The QXmpp developers
00003  *
00004  * Authors:
00005  *  Manjeet Dahiya
00006  *  Jeremy Lainé
00007  *
00008  * Source:
00009  *  https://github.com/qxmpp-project/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 <QAbstractSocket>
00030 #include <QObject>
00031 #include "QXmppLogger.h"
00032 
00033 class QDomElement;
00034 class QSslSocket;
00035 class QXmppStanza;
00036 class QXmppStreamPrivate;
00037 
00040 
00041 class QXMPP_EXPORT QXmppStream : public QXmppLoggable
00042 {
00043     Q_OBJECT
00044 
00045 public:
00046     QXmppStream(QObject *parent);
00047     ~QXmppStream();
00048 
00049     virtual bool isConnected() const;
00050     bool sendPacket(const QXmppStanza&);
00051 
00052 signals:
00054     void connected();
00055 
00057     void disconnected();
00058 
00059 protected:
00060     // Access to underlying socket
00061     QSslSocket *socket() const;
00062     void setSocket(QSslSocket *socket);
00063 
00064     // Overridable methods
00065     virtual void handleStart();
00066 
00070     virtual void handleStanza(const QDomElement &element) = 0;
00071 
00075     virtual void handleStream(const QDomElement &element) = 0;
00076 
00077 public slots:
00078     virtual void disconnectFromHost();
00079     virtual bool sendData(const QByteArray&);
00080 
00081 private slots:
00082     void _q_socketConnected();
00083     void _q_socketEncrypted();
00084     void _q_socketError(QAbstractSocket::SocketError error);
00085     void _q_socketReadyRead();
00086 
00087 private:
00088     QXmppStreamPrivate * const d;
00089 };
00090 
00091 #endif // QXMPPSTREAM_H
 All Classes Functions Enumerations Enumerator Properties