rostermanager.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef ROSTERMANAGER_H__
00015 #define ROSTERMANAGER_H__
00016
00017 #include "subscriptionhandler.h"
00018 #include "privatexmlhandler.h"
00019 #include "iqhandler.h"
00020 #include "presencehandler.h"
00021 #include "rosterlistener.h"
00022
00023 #include <map>
00024 #include <string>
00025 #include <list>
00026
00027 namespace gloox
00028 {
00029
00030 class ClientBase;
00031 class Stanza;
00032 class PrivateXML;
00033 class RosterItem;
00034
00047 class GLOOX_API RosterManager : public IqHandler, public PresenceHandler, public SubscriptionHandler,
00048 public PrivateXMLHandler
00049 {
00050 public:
00055 RosterManager( ClientBase *parent );
00056
00060 virtual ~RosterManager();
00061
00066 void fill();
00067
00072 Roster* roster();
00073
00082 void subscribe( const JID& jid, const std::string& name = "", const StringList& groups = StringList(),
00083 const std::string& msg = "" );
00084
00088 void synchronize();
00089
00097 void add( const JID& jid, const std::string& name, const StringList& groups );
00098
00107 void unsubscribe( const JID& jid, const std::string& msg = "" );
00108
00117 void cancel( const JID& jid, const std::string& msg = "" );
00118
00125 void remove( const JID& jid );
00126
00133 void ackSubscriptionRequest( const JID& to, bool ack );
00134
00140 const std::string& delimiter() const { return m_delimiter; }
00141
00147 void setDelimiter( const std::string& delimiter );
00148
00153 RosterItem* getRosterItem( const JID& jid );
00154
00164 void registerRosterListener( RosterListener *rl, bool syncSubscribeReq = true );
00165
00170 void removeRosterListener();
00171
00172
00173 virtual bool handleIq( Stanza *stanza );
00174
00175
00176 virtual bool handleIqID( Stanza *stanza, int context );
00177
00178
00179 virtual void handlePresence( Stanza *stanza );
00180
00181
00182 virtual void handleSubscription( Stanza *stanza );
00183
00184
00185 virtual void handlePrivateXML( const std::string& tag, Tag *xml );
00186
00187
00188 virtual void handlePrivateXMLResult( const std::string& uid, PrivateXMLResult pxResult );
00189
00190 private:
00191 void add( const std::string& jid, const std::string& name,
00192 const StringList& groups, const StringList& caps, const std::string& sub, bool ask );
00193 void extractItems( Tag *tag, bool isPush );
00194
00195 RosterListener *m_rosterListener;
00196 Roster m_roster;
00197 ClientBase *m_parent;
00198 PrivateXML *m_privateXML;
00199 RosterItem *m_self;
00200
00201 std::string m_delimiter;
00202 bool m_syncSubscribeReq;
00203
00204 };
00205
00206 }
00207
00208 #endif // ROSTER_H__