QXmpp Version:0.3.91
QXmppStream.h
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 <QAbstractSocket>
00030 #include <QObject>
00031 #include "QXmppLogger.h"
00032 
00033 class QDomElement;
00034 class QSslSocket;
00035 class QXmppPacket;
00036 class QXmppStreamPrivate;
00037 
00040 
00041 class QXmppStream : public QXmppLoggable
00042 {
00043     Q_OBJECT
00044 
00045 public:
00046     QXmppStream(QObject *parent);
00047     ~QXmppStream();
00048 
00049     virtual bool isConnected() const;
00050     virtual void disconnectFromHost();
00051 
00052     virtual bool sendData(const QByteArray&);
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 _q_socketConnected();
00082     void _q_socketDisconnected();
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