QXmpp Version:0.3.0
|
00001 /* 00002 * Copyright (C) 2008-2011 The QXmpp developers 00003 * 00004 * Author: 00005 * Jeremy Lainé 00006 * 00007 * Source: 00008 * http://code.google.com/p/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 QXmppMessage; 00033 class QXmppMucManagerPrivate; 00034 class QXmppMucRoom; 00035 class QXmppMucRoomPrivate; 00036 00057 00058 class QXmppMucManager : public QXmppClientExtension 00059 { 00060 Q_OBJECT 00061 00062 public: 00063 QXmppMucManager(); 00064 ~QXmppMucManager(); 00065 00066 QXmppMucRoom *addRoom(const QString &roomJid); 00067 00069 QStringList discoveryFeatures() const; 00070 bool handleStanza(const QDomElement &element); 00072 00073 signals: 00075 void invitationReceived(const QString &roomJid, const QString &inviter, const QString &reason); 00076 protected: 00078 void setClient(QXmppClient* client); 00080 00081 private slots: 00082 void _q_messageReceived(const QXmppMessage &message); 00083 void _q_roomDestroyed(QObject *object); 00084 00085 private: 00086 QXmppMucManagerPrivate *d; 00087 }; 00088 00093 00094 class QXmppMucRoom : public QObject 00095 { 00096 Q_OBJECT 00097 Q_FLAGS(Action Actions) 00098 Q_PROPERTY(QXmppMucRoom::Actions allowedActions READ allowedActions NOTIFY allowedActionsChanged) 00099 Q_PROPERTY(bool isJoined READ isJoined NOTIFY isJoinedChanged) 00100 Q_PROPERTY(QString jid READ jid CONSTANT) 00101 Q_PROPERTY(QString nickName READ nickName WRITE setNickName NOTIFY nickNameChanged) 00102 Q_PROPERTY(QStringList participants READ participants) 00103 Q_PROPERTY(QString password READ password WRITE setPassword) 00104 Q_PROPERTY(QString subject READ subject WRITE setSubject NOTIFY subjectChanged) 00105 00106 public: 00107 00109 enum Action { 00110 NoAction = 0, 00111 SubjectAction = 1, 00112 ConfigurationAction = 2, 00113 PermissionsAction = 4, 00114 KickAction = 8, 00115 }; 00116 Q_DECLARE_FLAGS(Actions, Action) 00117 00118 ~QXmppMucRoom(); 00119 00120 Actions allowedActions() const; 00121 bool isJoined() const; 00122 QString jid() const; 00123 00124 QString nickName() const; 00125 void setNickName(const QString &nickName); 00126 00127 QXmppPresence participantPresence(const QString &jid) const; 00128 QStringList participants() const; 00129 00130 QString password() const; 00131 void setPassword(const QString &password); 00132 00133 QString subject() const; 00134 void setSubject(const QString &subject); 00135 00136 signals: 00138 void allowedActionsChanged(QXmppMucRoom::Actions actions) const; 00139 00141 void configurationReceived(const QXmppDataForm &configuration); 00142 00144 void error(const QXmppStanza::Error &error); 00145 00147 void joined(); 00148 00150 void kicked(const QString &jid, const QString &reason); 00151 00153 void isJoinedChanged(); 00155 00157 void left(); 00158 00160 void messageReceived(const QXmppMessage &message); 00161 00163 void nickNameChanged(const QString &nickName); 00164 00166 void participantAdded(const QString &jid); 00167 00169 void participantChanged(const QString &jid); 00170 00172 void participantRemoved(const QString &jid); 00173 00175 void permissionsReceived(const QList<QXmppMucItem> &permissions); 00176 00178 void subjectChanged(const QString &subject); 00179 00180 public slots: 00181 bool join(); 00182 bool kick(const QString &jid, const QString &reason); 00183 bool leave(const QString &message = QString()); 00184 bool requestConfiguration(); 00185 bool requestPermissions(); 00186 bool setConfiguration(const QXmppDataForm &form); 00187 bool setPermissions(const QList<QXmppMucItem> &permissions); 00188 bool sendInvitation(const QString &jid, const QString &reason); 00189 bool sendMessage(const QString &text); 00190 00191 private slots: 00192 void _q_disconnected(); 00193 void _q_messageReceived(const QXmppMessage &message); 00194 void _q_presenceReceived(const QXmppPresence &presence); 00195 00196 private: 00197 QXmppMucRoom(QXmppClient *client, const QString &jid, QObject *parent); 00198 QXmppMucRoomPrivate *d; 00199 friend class QXmppMucManager; 00200 }; 00201 00202 Q_DECLARE_OPERATORS_FOR_FLAGS(QXmppMucRoom::Actions) 00203 00204 #endif