QXmpp
Version:0.9.3
|
00001 /* 00002 * Copyright (C) 2008-2014 The QXmpp developers 00003 * 00004 * Author: 00005 * Jeremy Lainé 00006 * 00007 * Source: 00008 * https://github.com/qxmpp-project/qxmpp 00009 * 00010 * This file is a part of QXmpp library. 00011 * 00012 * This library is free software; you can redistribute it and/or 00013 * modify it under the terms of the GNU Lesser General Public 00014 * License as published by the Free Software Foundation; either 00015 * version 2.1 of the License, or (at your option) any later version. 00016 * 00017 * This library is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00020 * Lesser General Public License for more details. 00021 * 00022 */ 00023 00024 #ifndef QXMPPMUCMANAGER_H 00025 #define QXMPPMUCMANAGER_H 00026 00027 #include "QXmppClientExtension.h" 00028 #include "QXmppMucIq.h" 00029 #include "QXmppPresence.h" 00030 00031 class QXmppDataForm; 00032 class QXmppDiscoveryIq; 00033 class QXmppMessage; 00034 class QXmppMucManagerPrivate; 00035 class QXmppMucRoom; 00036 class QXmppMucRoomPrivate; 00037 00058 00059 class QXMPP_EXPORT QXmppMucManager : public QXmppClientExtension 00060 { 00061 Q_OBJECT 00062 Q_PROPERTY(QList<QXmppMucRoom*> rooms READ rooms NOTIFY roomAdded) 00063 00064 public: 00065 QXmppMucManager(); 00066 ~QXmppMucManager(); 00067 00068 QXmppMucRoom *addRoom(const QString &roomJid); 00069 QList<QXmppMucRoom*> rooms() const; 00070 00072 QStringList discoveryFeatures() const; 00073 bool handleStanza(const QDomElement &element); 00075 00076 signals: 00078 void invitationReceived(const QString &roomJid, const QString &inviter, const QString &reason); 00079 00081 void roomAdded(QXmppMucRoom *room); 00082 00083 protected: 00085 void setClient(QXmppClient* client); 00087 00088 private slots: 00089 void _q_messageReceived(const QXmppMessage &message); 00090 void _q_roomDestroyed(QObject *object); 00091 00092 private: 00093 QXmppMucManagerPrivate *d; 00094 }; 00095 00100 00101 class QXMPP_EXPORT QXmppMucRoom : public QObject 00102 { 00103 Q_OBJECT 00104 Q_FLAGS(Action Actions) 00105 Q_PROPERTY(QXmppMucRoom::Actions allowedActions READ allowedActions NOTIFY allowedActionsChanged) 00106 Q_PROPERTY(bool isJoined READ isJoined NOTIFY isJoinedChanged) 00107 Q_PROPERTY(QString jid READ jid CONSTANT) 00108 Q_PROPERTY(QString name READ name NOTIFY nameChanged) 00109 Q_PROPERTY(QString nickName READ nickName WRITE setNickName NOTIFY nickNameChanged) 00110 Q_PROPERTY(QStringList participants READ participants NOTIFY participantsChanged) 00111 Q_PROPERTY(QString password READ password WRITE setPassword) 00112 Q_PROPERTY(QString subject READ subject WRITE setSubject NOTIFY subjectChanged) 00113 00114 public: 00115 00117 enum Action { 00118 NoAction = 0, 00119 SubjectAction = 1, 00120 ConfigurationAction = 2, 00121 PermissionsAction = 4, 00122 KickAction = 8 00123 }; 00124 Q_DECLARE_FLAGS(Actions, Action) 00125 00126 ~QXmppMucRoom(); 00127 00128 Actions allowedActions() const; 00129 bool isJoined() const; 00130 QString jid() const; 00131 QString name() const; 00132 00133 QString nickName() const; 00134 void setNickName(const QString &nickName); 00135 00136 Q_INVOKABLE QString participantFullJid(const QString &jid) const; 00137 QXmppPresence participantPresence(const QString &jid) const; 00138 QStringList participants() const; 00139 00140 QString password() const; 00141 void setPassword(const QString &password); 00142 00143 QString subject() const; 00144 void setSubject(const QString &subject); 00145 00146 signals: 00148 void allowedActionsChanged(QXmppMucRoom::Actions actions) const; 00149 00151 void configurationReceived(const QXmppDataForm &configuration); 00152 00154 void error(const QXmppStanza::Error &error); 00155 00157 void joined(); 00158 00160 void kicked(const QString &jid, const QString &reason); 00161 00163 void isJoinedChanged(); 00165 00167 void left(); 00168 00170 void messageReceived(const QXmppMessage &message); 00171 00173 void nameChanged(const QString &name); 00174 00176 void nickNameChanged(const QString &nickName); 00177 00179 void participantAdded(const QString &jid); 00180 00182 void participantChanged(const QString &jid); 00183 00185 void participantRemoved(const QString &jid); 00186 00188 void participantsChanged(); 00190 00192 void permissionsReceived(const QList<QXmppMucItem> &permissions); 00193 00195 void subjectChanged(const QString &subject); 00196 00197 public slots: 00198 bool ban(const QString &jid, const QString &reason); 00199 bool join(); 00200 bool kick(const QString &jid, const QString &reason); 00201 bool leave(const QString &message = QString()); 00202 bool requestConfiguration(); 00203 bool requestPermissions(); 00204 bool setConfiguration(const QXmppDataForm &form); 00205 bool setPermissions(const QList<QXmppMucItem> &permissions); 00206 bool sendInvitation(const QString &jid, const QString &reason); 00207 bool sendMessage(const QString &text); 00208 00209 private slots: 00210 void _q_disconnected(); 00211 void _q_discoveryInfoReceived(const QXmppDiscoveryIq &iq); 00212 void _q_messageReceived(const QXmppMessage &message); 00213 void _q_presenceReceived(const QXmppPresence &presence); 00214 00215 private: 00216 QXmppMucRoom(QXmppClient *client, const QString &jid, QObject *parent); 00217 QXmppMucRoomPrivate *d; 00218 friend class QXmppMucManager; 00219 }; 00220 00221 Q_DECLARE_OPERATORS_FOR_FLAGS(QXmppMucRoom::Actions) 00222 00223 #endif