File indexing completed on 2024-03-24 04:07:21
0001 /* 0002 This file is part of the KDE games library 0003 Copyright (C) 2001 Burkhard Lehner (Burkhard.Lehner@gmx.de) 0004 0005 This library is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU Library General Public 0007 License either version 2 0008 of the License, or (at your option) any later version.as published by the Free Software Foundation. 0009 0010 This library is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 Library General Public License for more details. 0014 0015 You should have received a copy of the GNU Library General Public License 0016 along with this library; see the file COPYING.LIB. If not, write to 0017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 Boston, MA 02110-1301, USA. 0019 */ 0020 0021 /* 0022 KMessageJabber, subclass of KMessageIO 0023 */ 0024 0025 #ifndef KMESSAGEJABBER_H 0026 #define KMESSAGEJABBER_H 0027 0028 #include <QObject> 0029 #include <QProcess> 0030 #include <QString> 0031 #include <QHostAddress> 0032 #include "jabber_protocol_debug.h" 0033 0034 #define USE_UNSTABLE_LIBKDEGAMESPRIVATE_API 0035 #include <libkdegamesprivate/kgame/kmessageio.h> 0036 0037 #include "jabberclient.h" 0038 0039 0040 /** 0041 \class KMessageJabber kmessageio.h <KGame/KMessageIO> 0042 0043 This class implements the message communication using a TCP/IP socket. The 0044 object can connect to a server socket, or can use an already connected socket. 0045 */ 0046 0047 class KMessageJabber : public KMessageIO 0048 { 0049 Q_OBJECT 0050 0051 public: 0052 /** 0053 Connects to a server socket on /e host with /e port. host can be an 0054 numerical (e.g. "192.168.0.212") or symbolic (e.g. "wave.peter.org") 0055 IP address. You can immediately use the /e sendSystem() and 0056 /e sendBroadcast() methods. The messages are stored and sent to the 0057 receiver after the connection is established. 0058 0059 If the connection could not be established (e.g. unknown host or no server 0060 socket at this port), the signal /e connectionBroken is emitted. 0061 */ 0062 explicit KMessageJabber (const QString& peerJid, JabberClient* jabberClient, QObject *parent = nullptr ); 0063 0064 /** 0065 Destructor, closes the Jabber connexion. 0066 */ 0067 ~KMessageJabber () override; 0068 0069 /** 0070 * The runtime idendifcation 0071 */ 0072 int rtti() const override {return 3;} 0073 0074 /** 0075 @return The jid this object is connected to. See QSocket::peerName. 0076 */ 0077 QString peerName () const override; 0078 0079 /** 0080 @return TRUE as this is a network IO. 0081 */ 0082 bool isNetwork() const override { return true; } 0083 0084 /** 0085 Returns true if the socket is in state /e connected. 0086 */ 0087 bool isConnected () const override; 0088 0089 /** 0090 Overwritten slot method from KMessageIO. 0091 0092 Note: It is not declared as a slot method, since the slot is already 0093 defined in KMessageIO as a virtual method. 0094 */ 0095 void send (const QByteArray &msg) override; 0096 0097 protected Q_SLOTS: 0098 virtual void slotMessageReceived ( const XMPP::Message &message ); 0099 virtual void slotGroupChatLeft(const XMPP::Message&); 0100 virtual void slotResourceUnavailable(const Jid&, const Resource&); 0101 virtual void slotGroupChatPresence(const XMPP::Jid&, const XMPP::Status&); 0102 0103 protected: 0104 JabberClient* mClient; 0105 bool mAwaitingHeader; 0106 quint32 mNextBlockLength; 0107 QString mPeerJid; 0108 }; 0109 0110 #endif