File indexing completed on 2024-04-14 04:01:44

0001 
0002 /***************************************************************************
0003                    jabberbytestream.h  -  Byte Stream for Jabber
0004                              -------------------
0005     begin                : Wed Jul 7 2004
0006     copyright            : (C) 2004 by Till Gerken <till@tantalo.net>
0007 
0008                Kopete (C) 2004 Kopete developers <kopete-devel@kde.org>
0009  ***************************************************************************/
0010 
0011 /***************************************************************************
0012  *                                                                         *
0013  *   This program is free software; you can redistribute it and/or modify  *
0014  *   it under the terms of the GNU Lesser General Public License as        *
0015  *   published by the Free Software Foundation; either either version 2
0016    of the License, or (at your option) any later version.1 of the  *
0017  *   License, or (at your option) any later version.                       *
0018  *                                                                         *
0019  ***************************************************************************/
0020 
0021 #ifndef JABBERBYTESTREAM_H
0022 #define JABBERBYTESTREAM_H
0023 
0024 #include <bytestream.h>
0025 #include <QTcpSocket>
0026 #include <memory>
0027 
0028 /**
0029 @author Kopete Developers
0030 */
0031 class JabberByteStream : public ByteStream
0032 {
0033 
0034 Q_OBJECT
0035 
0036 public:
0037     JabberByteStream ( QObject *parent = nullptr );
0038 
0039     ~JabberByteStream () override;
0040 
0041     void connect ( QString host, int port );
0042     bool isOpen () const override;
0043     void close () override;
0044 
0045     QTcpSocket *socket () const;
0046 
0047 signals:
0048     void connected ();
0049 
0050 protected:
0051     int tryWrite () override;
0052 
0053 private slots:
0054     void slotConnected ();
0055     void slotConnectionClosed ();
0056     void slotReadyRead ();
0057     void slotBytesWritten ( qint64 );
0058   void slotError ( QAbstractSocket::SocketError );
0059 
0060 private:
0061     std::shared_ptr<QTcpSocket> mSocket;
0062     bool mClosing;
0063 
0064 };
0065 
0066 #endif