QXmpp Version:0.3.91
|
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 00077 protected: 00079 void setClient(QXmppClient* client); 00081 00082 private slots: 00083 void _q_messageReceived(const QXmppMessage &message); 00084 void _q_roomDestroyed(QObject *object); 00085 00086 private: 00087 QXmppMucManagerPrivate *d; 00088 }; 00089 00094 00095 class QXmppMucRoom : public QObject 00096 { 00097 Q_OBJECT 00098 Q_FLAGS(Action Actions) 00099 Q_PROPERTY(QXmppMucRoom::Actions allowedActions READ allowedActions NOTIFY allowedActionsChanged) 00100 Q_PROPERTY(bool isJoined READ isJoined NOTIFY isJoinedChanged) 00101 Q_PROPERTY(QString jid READ jid CONSTANT) 00102 Q_PROPERTY(QString nickName READ nickName WRITE setNickName NOTIFY nickNameChanged) 00103 Q_PROPERTY(QStringList participants READ participants NOTIFY participantsChanged) 00104 Q_PROPERTY(QString password READ password WRITE setPassword) 00105 Q_PROPERTY(QString subject READ subject WRITE setSubject NOTIFY subjectChanged) 00106 00107 public: 00108 00110 enum Action { 00111 NoAction = 0, 00112 SubjectAction = 1, 00113 ConfigurationAction = 2, 00114 PermissionsAction = 4, 00115 KickAction = 8, 00116 }; 00117 Q_DECLARE_FLAGS(Actions, Action) 00118 00119 ~QXmppMucRoom(); 00120 00121 Actions allowedActions() const; 00122 bool isJoined() const; 00123 QString jid() const; 00124 00125 QString nickName() const; 00126 void setNickName(const QString &nickName); 00127 00128 QXmppPresence participantPresence(const QString &jid) const; 00129 QStringList participants() const; 00130 00131 QString password() const; 00132 void setPassword(const QString &password); 00133 00134 QString subject() const; 00135 void setSubject(const QString &subject); 00136 00137 signals: 00139 void allowedActionsChanged(QXmppMucRoom::Actions actions) const; 00140 00142 void configurationReceived(const QXmppDataForm &configuration); 00143 00145 void error(const QXmppStanza::Error &error); 00146 00148 void joined(); 00149 00151 void kicked(const QString &jid, const QString &reason); 00152 00154 void isJoinedChanged(); 00156 00158 void left(); 00159 00161 void messageReceived(const QXmppMessage &message); 00162 00164 void nickNameChanged(const QString &nickName); 00165 00167 void participantAdded(const QString &jid); 00168 00170 void participantChanged(const QString &jid); 00171 00173 void participantRemoved(const QString &jid); 00174 00176 void participantsChanged(); 00178 00180 void permissionsReceived(const QList<QXmppMucItem> &permissions); 00181 00183 void subjectChanged(const QString &subject); 00184 00185 public slots: 00186 bool join(); 00187 bool kick(const QString &jid, const QString &reason); 00188 bool leave(const QString &message = QString()); 00189 bool requestConfiguration(); 00190 bool requestPermissions(); 00191 bool setConfiguration(const QXmppDataForm &form); 00192 bool setPermissions(const QList<QXmppMucItem> &permissions); 00193 bool sendInvitation(const QString &jid, const QString &reason); 00194 bool sendMessage(const QString &text); 00195 00196 private slots: 00197 void _q_disconnected(); 00198 void _q_messageReceived(const QXmppMessage &message); 00199 void _q_presenceReceived(const QXmppPresence &presence); 00200 00201 private: 00202 QXmppMucRoom(QXmppClient *client, const QString &jid, QObject *parent); 00203 QXmppMucRoomPrivate *d; 00204 friend class QXmppMucManager; 00205 }; 00206 00207 Q_DECLARE_OPERATORS_FOR_FLAGS(QXmppMucRoom::Actions) 00208 00209 #endif