File indexing completed on 2024-06-02 04:07:09
0001 /* 0002 * Copyright (C) 2003 Justin Karneges 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Lesser General Public 0006 * License as published by the Free Software Foundation; either 0007 * either version 2 0008 of the License, or (at your option) any later version.1 of the License, or (at your option) any later version. 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 * Lesser General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Lesser General Public 0016 * License along with this library; if not, write to the Free Software 0017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 0018 * 0019 */ 0020 0021 #ifndef XMPP_CLIENT_H 0022 #define XMPP_CLIENT_H 0023 0024 #include <QObject> 0025 #include <QStringList> 0026 0027 #include "iris_export.h" 0028 #include "xmpp/jid/jid.h" 0029 #include "xmpp_status.h" 0030 #include "xmpp_discoitem.h" 0031 0032 class QString; 0033 class QDomElement; 0034 class QDomDocument; 0035 namespace XMPP { 0036 class ClientStream; 0037 class Features; 0038 class FileTransferManager; 0039 class IBBManager; 0040 class JidLinkManager; 0041 class LiveRoster; 0042 class LiveRosterItem; 0043 class Message; 0044 class Resource; 0045 class ResourceList; 0046 class Roster; 0047 class RosterItem; 0048 class S5BManager; 0049 class Stream; 0050 class Task; 0051 } 0052 0053 namespace XMPP 0054 { 0055 class IRIS_EXPORT Client : public QObject 0056 { 0057 Q_OBJECT 0058 0059 public: 0060 Client(QObject *parent=0); 0061 ~Client() override; 0062 0063 bool isActive() const; 0064 void connectToServer(ClientStream *s, const Jid &j, bool auth=true); 0065 void start(const QString &host, const QString &user, const QString &pass, const QString &resource); 0066 void close(bool fast=false); 0067 0068 Stream & stream(); 0069 QString streamBaseNS() const; 0070 const LiveRoster & roster() const; 0071 const ResourceList & resourceList() const; 0072 0073 void send(const QDomElement &); 0074 void send(const QString &); 0075 0076 QString host() const; 0077 QString user() const; 0078 QString pass() const; 0079 QString resource() const; 0080 Jid jid() const; 0081 0082 void rosterRequest(); 0083 void sendMessage(const Message &); 0084 void sendSubscription(const Jid &, const QString &, const QString& nick = QString()); 0085 void setPresence(const Status &); 0086 0087 void debug(const QString &); 0088 QString genUniqueId(); 0089 Task *rootTask(); 0090 QDomDocument *doc() const; 0091 0092 QString OSName() const; 0093 QString timeZone() const; 0094 int timeZoneOffset() const; 0095 QString clientName() const; 0096 QString clientVersion() const; 0097 QString capsNode() const; 0098 QString capsVersion() const; 0099 QString capsExt() const; 0100 0101 void setOSName(const QString &); 0102 void setTimeZone(const QString &, int); 0103 void setClientName(const QString &); 0104 void setClientVersion(const QString &); 0105 void setCapsNode(const QString &); 0106 void setCapsVersion(const QString &); 0107 0108 void setIdentity(DiscoItem::Identity); 0109 DiscoItem::Identity identity(); 0110 0111 void setFeatures(const Features& f); 0112 const Features& features() const; 0113 0114 void addExtension(const QString& ext, const Features& f); 0115 void removeExtension(const QString& ext); 0116 const Features& extension(const QString& ext) const; 0117 QStringList extensions() const; 0118 0119 S5BManager *s5bManager() const; 0120 IBBManager *ibbManager() const; 0121 JidLinkManager *jidLinkManager() const; 0122 0123 void setFileTransferEnabled(bool b); 0124 FileTransferManager *fileTransferManager() const; 0125 0126 QString groupChatPassword(const QString& host, const QString& room) const; 0127 bool groupChatJoin(const QString &host, const QString &room, const QString &nick, const QString& password = QString(), int maxchars = -1, int maxstanzas = -1, int seconds = -1, const Status& = Status()); 0128 void groupChatSetStatus(const QString &host, const QString &room, const Status &); 0129 void groupChatChangeNick(const QString &host, const QString &room, const QString &nick, const Status &); 0130 void groupChatLeave(const QString &host, const QString &room); 0131 0132 signals: 0133 void activated(); 0134 void disconnected(); 0135 //void authFinished(bool, int, const QString &); 0136 void rosterRequestFinished(bool, int, const QString &); 0137 void rosterItemAdded(const RosterItem &); 0138 void rosterItemUpdated(const RosterItem &); 0139 void rosterItemRemoved(const RosterItem &); 0140 void resourceAvailable(const Jid &, const Resource &); 0141 void resourceUnavailable(const Jid &, const Resource &); 0142 void presenceError(const Jid &, int, const QString &); 0143 void subscription(const Jid &, const QString &, const QString &); 0144 void messageReceived(const Message &); 0145 void debugText(const QString &); 0146 void xmlIncoming(const QString &); 0147 void xmlOutgoing(const QString &); 0148 void groupChatJoined(const Jid &); 0149 void groupChatLeft(const Jid &); 0150 void groupChatPresence(const Jid &, const Status &); 0151 void groupChatError(const Jid &, int, const QString &); 0152 0153 void incomingJidLink(); 0154 0155 private slots: 0156 //void streamConnected(); 0157 //void streamHandshaken(); 0158 //void streamError(const StreamError &); 0159 //void streamSSLCertificateReady(const QSSLCert &); 0160 //void streamCloseFinished(); 0161 void streamError(int); 0162 void streamReadyRead(); 0163 void streamIncomingXml(const QString &); 0164 void streamOutgoingXml(const QString &); 0165 0166 void slotRosterRequestFinished(); 0167 0168 // basic daemons 0169 void ppSubscription(const Jid &, const QString &, const QString&); 0170 void ppPresence(const Jid &, const Status &); 0171 void pmMessage(const Message &); 0172 void prRoster(const Roster &); 0173 0174 void s5b_incomingReady(); 0175 void ibb_incomingReady(); 0176 0177 public: 0178 class GroupChat; 0179 private: 0180 void cleanup(); 0181 void distribute(const QDomElement &); 0182 void importRoster(const Roster &); 0183 void importRosterItem(const RosterItem &); 0184 void updateSelfPresence(const Jid &, const Status &); 0185 void updatePresence(LiveRosterItem *, const Jid &, const Status &); 0186 0187 class ClientPrivate; 0188 ClientPrivate *d; 0189 }; 0190 } 0191 0192 #endif