QXmpp Version:0.3.0
|
00001 /* 00002 * Copyright (C) 2008-2011 The QXmpp developers 00003 * 00004 * Authors: 00005 * Manjeet Dahiya 00006 * Jeremy Lainé 00007 * 00008 * Source: 00009 * http://code.google.com/p/qxmpp 00010 * 00011 * This file is a part of QXmpp library. 00012 * 00013 * This library is free software; you can redistribute it and/or 00014 * modify it under the terms of the GNU Lesser General Public 00015 * License as published by the Free Software Foundation; either 00016 * version 2.1 of the License, or (at your option) any later version. 00017 * 00018 * This library is distributed in the hope that it will be useful, 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00021 * Lesser General Public License for more details. 00022 * 00023 */ 00024 00025 #ifndef QXMPPROSTERMANAGER_H 00026 #define QXMPPROSTERMANAGER_H 00027 00028 #include <QObject> 00029 #include <QMap> 00030 #include <QStringList> 00031 00032 #include "QXmppClientExtension.h" 00033 #include "QXmppPresence.h" 00034 #include "QXmppRosterIq.h" 00035 00061 00062 class QXmppRosterManager : public QXmppClientExtension 00063 { 00064 Q_OBJECT 00065 00066 public: 00067 QXmppRosterManager(QXmppClient* stream); 00068 00069 bool isRosterReceived(); 00070 QStringList getRosterBareJids() const; 00071 QXmppRosterIq::Item getRosterEntry(const QString& bareJid) const; 00072 00073 void addRosterEntry(const QString &bareJid, 00074 const QString &name = QString(), 00075 const QString &message = QString(), 00076 const QSet<QString> &groups = QSet<QString>()); 00077 00078 QStringList getResources(const QString& bareJid) const; 00079 QMap<QString, QXmppPresence> getAllPresencesForBareJid( 00080 const QString& bareJid) const; 00081 QXmppPresence getPresence(const QString& bareJid, 00082 const QString& resource) const; 00083 00085 bool handleStanza(const QDomElement &element); 00087 00088 // deprecated in release 0.4.0 00090 void Q_DECL_DEPRECATED removeRosterEntry(const QString &bareJid); 00092 00093 public slots: 00094 bool acceptSubscription(const QString &bareJid, const QString &reason = QString ()); 00095 bool refuseSubscription(const QString &bareJid, const QString &reason = QString ()); 00096 bool removeItem(const QString &bareJid); 00097 bool subscribe(const QString &bareJid, const QString &reason = QString ()); 00098 bool unsubscribe(const QString &bareJid, const QString &reason = QString ()); 00099 00100 signals: 00105 void rosterReceived(); 00106 00108 void presenceChanged(const QString& bareJid, const QString& resource); 00109 00111 // deprecated in release 0.4.0 00112 void rosterChanged(const QString& bareJid); 00114 00122 void subscriptionReceived(const QString& bareJid); 00123 00126 void itemAdded(const QString& bareJid); 00127 00130 void itemChanged(const QString& bareJid); 00131 00134 void itemRemoved(const QString& bareJid); 00135 private: 00136 //map of bareJid and its rosterEntry 00137 QMap<QString, QXmppRosterIq::Item> m_entries; 00138 // map of resources of the jid and map of resources and presences 00139 QMap<QString, QMap<QString, QXmppPresence> > m_presences; 00140 // flag to store that the roster has been populated 00141 bool m_isRosterReceived; 00142 // id of the initial roster request 00143 QString m_rosterReqId; 00144 00145 private slots: 00146 void connected(); 00147 void disconnected(); 00148 void presenceReceived(const QXmppPresence&); 00149 00150 private: 00151 void rosterIqReceived(const QXmppRosterIq&); 00152 }; 00153 00154 #endif // QXMPPROSTER_H