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 "rosterlistener.h"
00019 #include "privatexmlhandler.h"
00020 #include "iqhandler.h"
00021 #include "presencehandler.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
00044 class GLOOX_EXPORT RosterManager : public IqHandler, PresenceHandler, SubscriptionHandler,
00045 PrivateXMLHandler
00046 {
00047 public:
00053 RosterManager( ClientBase *parent, bool self = false );
00054
00058 virtual ~RosterManager();
00059
00064 void fill();
00065
00070 RosterListener::Roster* roster();
00071
00080 void subscribe( const std::string& jid, const std::string& name, StringList& groups,
00081 const std::string& msg );
00082
00086 void synchronize();
00087
00095 void add( const std::string& jid, const std::string& name, StringList& groups );
00096
00103 void unsubscribe( const std::string& jid, const std::string& msg, bool remove );
00104
00111 void ackSubscriptionRequest( const JID& to, bool ack );
00112
00118 const std::string& delimiter() const { return m_delimiter; };
00119
00125 void setDelimiter( const std::string& delimiter );
00126
00136 void registerRosterListener( RosterListener *rl, bool syncSubscribeReq = true );
00137
00142 void removeRosterListener();
00143
00144
00145 virtual bool handleIq( Stanza *stanza );
00146
00147
00148 virtual bool handleIqID( Stanza * , int ) { return false; };
00149
00150
00151 virtual void handlePresence( Stanza *stanza );
00152
00153
00154 virtual void handleSubscription( Stanza *stanza );
00155
00156
00157 virtual void handlePrivateXML( const std::string& tag, Tag *xml );
00158
00159
00160 virtual void handlePrivateXMLResult( const std::string uid, PrivateXMLResult result );
00161
00162 private:
00163 void add( const std::string& jid, const std::string& name,
00164 StringList& groups, const std::string& sub, bool ask );
00165 void extractItems( Tag *tag, bool isPush );
00166
00167 RosterListener *m_rosterListener;
00168 RosterListener::Roster m_roster;
00169 ClientBase *m_parent;
00170 PrivateXML *m_privateXML;
00171
00172 std::string m_delimiter;
00173 bool m_delimiterFetched;
00174 bool m_syncSubscribeReq;
00175
00176 };
00177
00178 }
00179
00180 #endif // ROSTER_H__