rostermanager.h
/*
Copyright (c) 2004-2023 by Jakob Schröter <js@camaya.net>
This file is part of the gloox library. http://camaya.net/gloox
This software is distributed under a license. The full license
agreement can be found in the file LICENSE in this distribution.
This software may not be copied, modified, sold or distributed
other than expressed in the named license agreement.
This software is distributed without any warranty.
*/
#ifndef ROSTERMANAGER_H__
#define ROSTERMANAGER_H__
#include "subscriptionhandler.h"
#include "privatexmlhandler.h"
#include "iqhandler.h"
#include "presencehandler.h"
#include "rosterlistener.h"
#include <map>
#include <string>
#include <list>
namespace gloox
{
class ClientBase;
class Stanza;
class PrivateXML;
class RosterItem;
class GLOOX_API RosterManager : public IqHandler, public PresenceHandler, public SubscriptionHandler,
public PrivateXMLHandler
{
public:
RosterManager( ClientBase* parent );
virtual ~RosterManager();
void fill();
Roster* roster();
void subscribe( const JID& jid, const std::string& name = EmptyString,
const StringList& groups = StringList(),
const std::string& msg = EmptyString );
void synchronize();
void add( const JID& jid, const std::string& name, const StringList& groups );
void unsubscribe( const JID& jid, const std::string& msg = EmptyString );
void cancel( const JID& jid, const std::string& msg = EmptyString );
void remove( const JID& jid );
void ackSubscriptionRequest( const JID& to, bool ack );
const std::string& delimiter() const { return m_delimiter; }
void setDelimiter( const std::string& delimiter );
RosterItem* getRosterItem( const JID& jid );
void registerRosterListener( RosterListener* rl, bool syncSubscribeReq = true );
void removeRosterListener();
// reimplemented from IqHandler.
virtual bool handleIq( const IQ& iq );
// reimplemented from IqHandler.
virtual void handleIqID( const IQ& iq, int context );
// reimplemented from PresenceHandler.
virtual void handlePresence( const Presence& presence );
// reimplemented from SubscriptionHandler.
virtual void handleSubscription( const Subscription& subscription );
// reimplemented from PrivateXMLHandler
virtual void handlePrivateXML( const Tag* xml );
// reimplemented from PrivateXMLHandler
virtual void handlePrivateXMLResult( const std::string& uid, PrivateXMLResult pxResult );
private:
#ifdef ROSTERMANAGER_TEST
public:
#endif
typedef std::list<RosterItemData*> RosterData;
class Query : public StanzaExtension
{
public:
Query( const JID& jid, const std::string& name, const StringList& groups );
Query( const JID& jid );
Query( const Tag* tag = 0 );
~Query();
const RosterData& roster() const { return m_roster; }
// reimplemented from StanzaExtension
virtual const std::string& filterString() const;
// reimplemented from StanzaExtension
virtual StanzaExtension* newInstance( const Tag* tag ) const
{
return new Query( tag );
}
// reimplemented from StanzaExtension
virtual Tag* tag() const;
// reimplemented from StanzaExtension
virtual StanzaExtension* clone() const;
private:
RosterData m_roster;
};
void mergePush( const RosterData& data );
void mergeRoster( const RosterData& data );
RosterListener* m_rosterListener;
Roster m_roster;
ClientBase* m_parent;
PrivateXML* m_privateXML;
RosterItem* m_self;
std::string m_delimiter;
bool m_syncSubscribeReq;
enum RosterContext
{
RequestRoster,
AddRosterItem,
RemoveRosterItem,
SynchronizeRoster
};
};
}
#endif // ROSTER_H__
gloox::ClientBase
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
Definition clientbase.h:79
gloox::IQ
An abstraction of an IQ stanza.
Definition iq.h:34
gloox::IqHandler
A virtual interface which can be reimplemented to receive IQ stanzas.
Definition iqhandler.h:32
gloox::JID
An abstraction of a JID.
Definition jid.h:31
gloox::PresenceHandler
A virtual interface which can be reimplemented to receive presence stanzas.
Definition presencehandler.h:31
gloox::Presence
An abstraction of a presence stanza.
Definition presence.h:33
gloox::PrivateXMLHandler
A virtual interface which can be reimplemented to store and receive private XML data.
Definition privatexmlhandler.h:36
gloox::PrivateXML
This class implements XEP-0049 (Private XML Storage).
Definition privatexml.h:38
gloox::RosterItem
An abstraction of a roster item.
Definition rosteritem.h:41
gloox::RosterListener
A virtual interface which can be reimplemented to receive roster updates.
Definition rosterlistener.h:44
gloox::RosterManager::RosterManager
RosterManager(ClientBase *parent)
Definition rostermanager.cpp:108
gloox::RosterManager::add
void add(const JID &jid, const std::string &name, const StringList &groups)
Definition rostermanager.cpp:248
gloox::RosterManager::subscribe
void subscribe(const JID &jid, const std::string &name=EmptyString, const StringList &groups=StringList(), const std::string &msg=EmptyString)
Definition rostermanager.cpp:235
gloox::RosterManager::unsubscribe
void unsubscribe(const JID &jid, const std::string &msg=EmptyString)
Definition rostermanager.cpp:259
gloox::RosterManager::synchronize
void synchronize()
Definition rostermanager.cpp:282
gloox::RosterManager::delimiter
const std::string & delimiter() const
Definition rostermanager.h:141
gloox::RosterManager::roster
Roster * roster()
Definition rostermanager.cpp:140
gloox::RosterManager::cancel
void cancel(const JID &jid, const std::string &msg=EmptyString)
Definition rostermanager.cpp:265
gloox::RosterManager::ackSubscriptionRequest
void ackSubscriptionRequest(const JID &to, bool ack)
Definition rostermanager.cpp:296
gloox::RosterManager::remove
void remove(const JID &jid)
Definition rostermanager.cpp:271
gloox::RosterManager::fill
void fill()
Definition rostermanager.cpp:145
gloox::StanzaExtension
This class abstracts a stanza extension, which is usually an XML child element in a specific namespac...
Definition stanzaextension.h:204
gloox::Stanza
This is the base class for XMPP stanza abstractions.
Definition stanza.h:34
gloox::SubscriptionHandler
A virtual interface which can be reimplemented to receive incoming subscription stanzas.
Definition subscriptionhandler.h:30
gloox::Subscription
An abstraction of a subscription stanza.
Definition subscription.h:32
gloox::Tag
This is an abstraction of an XML element.
Definition tag.h:47
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::StringList
std::list< std::string > StringList
Definition gloox.h:1251
gloox::EmptyString
const std::string EmptyString
Definition gloox.cpp:124
gloox::Roster
std::map< const std::string, RosterItem * > Roster
Definition rosterlistener.h:31