Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

rostermanager.h

00001 /*
00002   Copyright (c) 2004-2008 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 "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   class RosterItemData;
00035 
00048    class GLOOX_API RosterManager : public IqHandler, public PresenceHandler, public SubscriptionHandler,
00049                                    public PrivateXMLHandler
00050   {
00051     public:
00056       RosterManager( ClientBase* parent );
00057 
00061       virtual ~RosterManager();
00062 
00067       void fill();
00068 
00073       Roster* roster();
00074 
00083       void subscribe( const JID& jid, const std::string& name = EmptyString,
00084                       const StringList& groups = StringList(),
00085                       const std::string& msg = EmptyString );
00086 
00090       void synchronize();
00091 
00099       void add( const JID& jid, const std::string& name, const StringList& groups );
00100 
00109       void unsubscribe( const JID& jid, const std::string& msg = EmptyString );
00110 
00119       void cancel( const JID& jid, const std::string& msg = EmptyString );
00120 
00127       void remove( const JID& jid );
00128 
00135       void ackSubscriptionRequest( const JID& to, bool ack );
00136 
00142       const std::string& delimiter() const { return m_delimiter; }
00143 
00149       void setDelimiter( const std::string& delimiter );
00150 
00155       RosterItem* getRosterItem( const JID& jid );
00156 
00166       void registerRosterListener( RosterListener* rl, bool syncSubscribeReq = true );
00167 
00172       void removeRosterListener();
00173 
00174       // reimplemented from IqHandler.
00175       virtual bool handleIq( const IQ& iq );
00176 
00177       // reimplemented from IqHandler.
00178       virtual void handleIqID( const IQ& iq, int context );
00179 
00180       // reimplemented from PresenceHandler.
00181       virtual void handlePresence( const Presence& presence );
00182 
00183       // reimplemented from SubscriptionHandler.
00184       virtual void handleSubscription( const Subscription& subscription );
00185 
00186       // reimplemented from PrivateXMLHandler
00187       virtual void handlePrivateXML( const Tag* xml );
00188 
00189       // reimplemented from PrivateXMLHandler
00190       virtual void handlePrivateXMLResult( const std::string& uid, PrivateXMLResult pxResult );
00191 
00192     private:
00193 #ifdef ROSTERMANAGER_TEST
00194     public:
00195 #endif
00196       typedef std::list<RosterItemData*> RosterData;
00197 
00204       class Query : public StanzaExtension
00205       {
00206         public:
00213           Query( const JID& jid, const std::string& name, const StringList& groups );
00214 
00219           Query( const JID& jid );
00220 
00225           Query( const Tag* tag = 0 );
00226 
00230           ~Query();
00231 
00238           const RosterData& roster() const { return m_roster; }
00239 
00240           // reimplemented from StanzaExtension
00241           virtual const std::string& filterString() const;
00242 
00243           // reimplemented from StanzaExtension
00244           virtual StanzaExtension* newInstance( const Tag* tag ) const
00245           {
00246             return new Query( tag );
00247           }
00248 
00249           // reimplemented from StanzaExtension
00250           virtual Tag* tag() const;
00251 
00252         private:
00253           RosterData m_roster;
00254 
00255       };
00256 
00257       void mergePush( const RosterData& data );
00258       void mergeRoster( const RosterData& data );
00259 
00260       RosterListener* m_rosterListener;
00261       Roster m_roster;
00262       ClientBase* m_parent;
00263       PrivateXML* m_privateXML;
00264       RosterItem* m_self;
00265 
00266       std::string m_delimiter;
00267       bool m_syncSubscribeReq;
00268 
00269   };
00270 
00271 }
00272 
00273 #endif // ROSTER_H__

Generated on Mon Sep 1 09:25:11 2008 for gloox by  doxygen 1.4.1