rostermanager.h

00001 /*
00002   Copyright (c) 2004-2006 by Jakob Schroeter <js@camaya.net>
00003   This file is part of the gloox library. http://camaya.net/gloox
00004 
00005   This software is distributed under a license. The full license
00006   agreement can be found in the file LICENSE in this distribution.
00007   This software may not be copied, modified, sold or distributed
00008   other than expressed in the named license agreement.
00009 
00010   This software is distributed without any warranty.
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 
00046    class GLOOX_API RosterManager : public IqHandler, PresenceHandler, SubscriptionHandler,
00047                                           PrivateXMLHandler
00048   {
00049     public:
00055       RosterManager( ClientBase *parent, bool self = false );
00056 
00060       virtual ~RosterManager();
00061 
00066       void fill();
00067 
00072       RosterListener::Roster* roster();
00073 
00082       void subscribe( const std::string& jid, const std::string& name, StringList& groups,
00083                       const std::string& msg );
00084 
00088       void synchronize();
00089 
00097       void add( const std::string& jid, const std::string& name, StringList& groups );
00098 
00105       void unsubscribe( const std::string& jid, const std::string& msg, bool remove );
00106 
00113       void ackSubscriptionRequest( const JID& to, bool ack );
00114 
00120       const std::string& delimiter() const { return m_delimiter; };
00121 
00127       void setDelimiter( const std::string& delimiter );
00128 
00133       RosterItem* getRosterItem( const JID& jid );
00134 
00144       void registerRosterListener( RosterListener *rl, bool syncSubscribeReq = true );
00145 
00150       void removeRosterListener();
00151 
00152       // reimplemented from IqHandler.
00153       virtual bool handleIq( Stanza *stanza );
00154 
00155       // reimplemented from IqHandler.
00156       virtual bool handleIqID( Stanza *stanza, int context );
00157 
00158       // reimplemented from PresenceHandler.
00159       virtual void handlePresence( Stanza *stanza );
00160 
00161       // reimplemented from SubscriptionHandler.
00162       virtual void handleSubscription( Stanza *stanza );
00163 
00164       // reimplemented from PrivateXMLHandler
00165       virtual void handlePrivateXML( const std::string& tag, Tag *xml );
00166 
00167       // reimplemented from PrivateXMLHandler
00168       virtual void handlePrivateXMLResult( const std::string& uid, PrivateXMLResult result );
00169 
00170     private:
00171       void add( const std::string& jid, const std::string& name,
00172                 StringList& groups, const std::string& sub, bool ask );
00173       void extractItems( Tag *tag, bool isPush );
00174 
00175       RosterListener *m_rosterListener;
00176       RosterListener::Roster m_roster;
00177       ClientBase *m_parent;
00178       PrivateXML *m_privateXML;
00179 
00180       std::string m_delimiter;
00181       bool m_syncSubscribeReq;
00182 
00183   };
00184 
00185 }
00186 
00187 #endif // ROSTER_H__

Generated on Tue May 1 14:20:20 2007 for gloox by  doxygen 1.5.1