QXmpp
Version:0.4.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 Q_PROPERTY(QList<QXmppMucRoom*> rooms READ rooms NOTIFY roomAdded) 00062 00063 public: 00064 QXmppMucManager(); 00065 ~QXmppMucManager(); 00066 00067 QXmppMucRoom *addRoom(const QString &roomJid); 00068 QList<QXmppMucRoom*> rooms() const; 00069 00071 QStringList discoveryFeatures() const; 00072 bool handleStanza(const QDomElement &element); 00074 00075 signals: 00077 void invitationReceived(const QString &roomJid, const QString &inviter, const QString &reason); 00078 00080 void roomAdded(QXmppMucRoom *room); 00081 00082 protected: 00084 void setClient(QXmppClient* client); 00086 00087 private slots: 00088 void _q_messageReceived(const QXmppMessage &message); 00089 void _q_roomDestroyed(QObject *object); 00090 00091 private: 00092 QXmppMucManagerPrivate *d; 00093 }; 00094 00099 00100 class QXmppMucRoom : public QObject 00101 { 00102 Q_OBJECT 00103 Q_FLAGS(Action Actions) 00104 Q_PROPERTY(QXmppMucRoom::Actions allowedActions READ allowedActions NOTIFY allowedActionsChanged) 00105 Q_PROPERTY(bool isJoined READ isJoined NOTIFY isJoinedChanged) 00106 Q_PROPERTY(QString jid READ jid CONSTANT) 00107 Q_PROPERTY(QString nickName READ nickName WRITE setNickName NOTIFY nickNameChanged) 00108 Q_PROPERTY(QStringList participants READ participants NOTIFY participantsChanged) 00109 Q_PROPERTY(QString password READ password WRITE setPassword) 00110 Q_PROPERTY(QString subject READ subject WRITE setSubject NOTIFY subjectChanged) 00111 00112 public: 00113 00115 enum Action { 00116 NoAction = 0, 00117 SubjectAction = 1, 00118 ConfigurationAction = 2, 00119 PermissionsAction = 4, 00120 KickAction = 8, 00121 }; 00122 Q_DECLARE_FLAGS(Actions, Action) 00123 00124 ~QXmppMucRoom(); 00125 00126 Actions allowedActions() const; 00127 bool isJoined() const; 00128 QString jid() const; 00129 00130 QString nickName() const; 00131 void setNickName(const QString &nickName); 00132 00133 QXmppPresence participantPresence(const QString &jid) const; 00134 QStringList participants() const; 00135 00136 QString password() const; 00137 void setPassword(const QString &password); 00138 00139 QString subject() const; 00140 void setSubject(const QString &subject); 00141 00142 signals: 00144 void allowedActionsChanged(QXmppMucRoom::Actions actions) const; 00145 00147 void configurationReceived(const QXmppDataForm &configuration); 00148 00150 void error(const QXmppStanza::Error &error); 00151 00153 void joined(); 00154 00156 void kicked(const QString &jid, const QString &reason); 00157 00159 void isJoinedChanged(); 00161 00163 void left(); 00164 00166 void messageReceived(const QXmppMessage &message); 00167 00169 void nickNameChanged(const QString &nickName); 00170 00172 void participantAdded(const QString &jid); 00173 00175 void participantChanged(const QString &jid); 00176 00178 void participantRemoved(const QString &jid); 00179 00181 void participantsChanged(); 00183 00185 void permissionsReceived(const QList<QXmppMucItem> &permissions); 00186 00188 void subjectChanged(const QString &subject); 00189 00190 public slots: 00191 bool join(); 00192 bool kick(const QString &jid, const QString &reason); 00193 bool leave(const QString &message = QString()); 00194 bool requestConfiguration(); 00195 bool requestPermissions(); 00196 bool setConfiguration(const QXmppDataForm &form); 00197 bool setPermissions(const QList<QXmppMucItem> &permissions); 00198 bool sendInvitation(const QString &jid, const QString &reason); 00199 bool sendMessage(const QString &text); 00200 00201 private slots: 00202 void _q_disconnected(); 00203 void _q_messageReceived(const QXmppMessage &message); 00204 void _q_presenceReceived(const QXmppPresence &presence); 00205 00206 private: 00207 QXmppMucRoom(QXmppClient *client, const QString &jid, QObject *parent); 00208 QXmppMucRoomPrivate *d; 00209 friend class QXmppMucManager; 00210 }; 00211 00212 Q_DECLARE_OPERATORS_FOR_FLAGS(QXmppMucRoom::Actions) 00213 00214 #endif