All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
xmpp_roster.h
Go to the documentation of this file.
/*
* xmpp_roster.h
*
* Extensible Messaging and Presence Protocol (XMPP) IM
* Roster management classes
*
* Portable Windows Library
*
* Copyright (c) 2004 Reitek S.p.A.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Portable Windows Library.
*
* The Initial Developer of the Original Code is Post Increment
*
* Contributor(s): ______________________________________.
*
* $Revision: 24177 $
* $Author: rjongbloed $
* $Date: 2010-04-05 06:52:04 -0500 (Mon, 05 Apr 2010) $
*/
#ifndef PTLIB_XMPP_ROSTER_H
#define PTLIB_XMPP_ROSTER_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#include <ptclib/xmpp_c2s.h>
#if P_EXPAT
namespace XMPP
{
class Roster : public PObject
{
PCLASSINFO(Roster, PObject);
public:
enum ItemType { // Subscription type
None,
To,
From,
Both,
Unknown = 999
};
class Item : public PObject
{
PCLASSINFO(Item, PObject);
PDICTIONARY(PresenceInfo, PString, Presence);
public:
Item(PXMLElement * item = 0);
Item(PXMLElement& item);
Item(const JID& jid, ItemType type, const PString& group, const PString& name = PString::Empty());
const JID& GetJID() const { return m_JID; }
ItemType GetType() const { return m_Type; }
const PString& GetName() const { return m_Name; }
const PStringSet& GetGroups() const { return m_Groups; }
const PresenceInfo& GetPresence() const { return m_Presence; }
virtual void SetJID(const JID& jid, PBoolean dirty = true)
{ m_JID = jid; if (dirty) SetDirty(); }
virtual void SetType(ItemType type, PBoolean dirty = true)
{ m_Type = type; if (dirty) SetDirty(); }
virtual void SetName(const PString& name, PBoolean dirty = true)
{ m_Name = name; if (dirty) SetDirty(); }
virtual void AddGroup(const PString& group, PBoolean dirty = true);
virtual void RemoveGroup(const PString& group, PBoolean dirty = true);
virtual void SetPresence(const Presence& p);
void SetDirty(PBoolean b = true) { m_IsDirty = b; }
Item & operator=(
const PXMLElement& item
);
virtual PXMLElement * AsXML(PXMLElement * parent) const;
protected:
BareJID m_JID;
ItemType m_Type;
PString m_Name;
PStringSet m_Groups;
// The item's presence state: for each resource (the key to the dictionary) a
// a presence stanza if kept.
PDictionary<PString, Presence> m_Presence;
PBoolean m_IsDirty; // item modified locally, server needs to be updated
};
PLIST(ItemList, Item);
public:
Roster(XMPP::C2S::StreamHandler * handler = 0);
~Roster();
const ItemList& GetItems() const { return m_Items; }
virtual Item * FindItem(const PString& jid);
virtual PBoolean SetItem(Item * item, PBoolean localOnly = false);
virtual PBoolean RemoveItem(const PString& jid, PBoolean localOnly = false);
virtual PBoolean RemoveItem(Item * item, PBoolean localOnly = false);
virtual void Attach(XMPP::C2S::StreamHandler * handler);
virtual void Detach();
virtual void Refresh(PBoolean sendPresence = true);
virtual PNotifierList& ItemChangedHandlers() { return m_ItemChangedHandlers; }
virtual PNotifierList& RosterChangedHandlers() { return m_RosterChangedHandlers; }
protected:
PDECLARE_NOTIFIER(XMPP::C2S::StreamHandler, Roster, OnSessionEstablished);
PDECLARE_NOTIFIER(XMPP::C2S::StreamHandler, Roster, OnSessionReleased);
PDECLARE_NOTIFIER(XMPP::Presence, Roster, OnPresence);
PDECLARE_NOTIFIER(XMPP::IQ, Roster, OnIQ);
ItemList m_Items;
XMPP::C2S::StreamHandler * m_Handler;
PNotifierList m_ItemChangedHandlers;
PNotifierList m_RosterChangedHandlers;
};
} // namespace XMPP
#endif // P_EXPAT
#endif // PTLIB_XMPP_ROSTER_H
// End of File ///////////////////////////////////////////////////////////////
XMPP::Roster::Item::m_Type
ItemType m_Type
Definition: xmpp_roster.h:100
XMPP::Roster::From
Definition: xmpp_roster.h:55
XMPP::Roster::m_Items
ItemList m_Items
Definition: xmpp_roster.h:137
XMPP::Roster::Attach
virtual void Attach(XMPP::C2S::StreamHandler *handler)
XMPP::Roster::Both
Definition: xmpp_roster.h:56
XMPP::Roster::Item::AsXML
virtual PXMLElement * AsXML(PXMLElement *parent) const
XMPP::Roster::Item::GetName
const PString & GetName() const
Definition: xmpp_roster.h:72
PDictionary
This template class maps the PAbstractDictionary to a specific key and data types.
Definition: dict.h:842
XMPP::Roster::Detach
virtual void Detach()
XMPP::Roster::m_RosterChangedHandlers
PNotifierList m_RosterChangedHandlers
Definition: xmpp_roster.h:140
XMPP::Disco::ItemList
ItemList(PXMLElement *list)
XMPP::IQ
Definition: xmpp.h:379
XMPP::Roster::Unknown
Definition: xmpp_roster.h:57
XMPP::Roster::Item::m_Presence
PDictionary< PString, Presence > m_Presence
Definition: xmpp_roster.h:106
XMPP::Roster::To
Definition: xmpp_roster.h:54
XMPP::Roster::PDECLARE_NOTIFIER
PDECLARE_NOTIFIER(XMPP::C2S::StreamHandler, Roster, OnSessionEstablished)
XMPP::Roster::m_ItemChangedHandlers
PNotifierList m_ItemChangedHandlers
Definition: xmpp_roster.h:139
XMPP::Roster::Item::operator=
Item & operator=(const PXMLElement &item)
This operator will set the dirty flag.
XMPP::Roster::ItemChangedHandlers
virtual PNotifierList & ItemChangedHandlers()
Definition: xmpp_roster.h:128
XMPP::Roster::None
Definition: xmpp_roster.h:53
XMPP::Roster::Item::GetGroups
const PStringSet & GetGroups() const
Definition: xmpp_roster.h:73
XMPP::Roster::Item::SetType
virtual void SetType(ItemType type, PBoolean dirty=true)
Definition: xmpp_roster.h:78
XMPP::Roster::Item
Definition: xmpp_roster.h:60
XMPP::JID
Definition: xmpp.h:59
XMPP::Roster::Item::m_Name
PString m_Name
Definition: xmpp_roster.h:101
PBoolean
BOOL PBoolean
Definition: object.h:102
XMPP::Roster::FindItem
virtual Item * FindItem(const PString &jid)
XMPP::Roster::PLIST
PLIST(ItemList, Item)
XMPP::Roster::Roster
Roster(XMPP::C2S::StreamHandler *handler=0)
XMPP::Roster::Item::GetJID
const JID & GetJID() const
Definition: xmpp_roster.h:70
XMPP::Roster::Item::AddGroup
virtual void AddGroup(const PString &group, PBoolean dirty=true)
XMPP::Roster::~Roster
~Roster()
PString
The character string class.
Definition: pstring.h:108
XMPP::BareJID
Definition: xmpp.h:105
PStringSet
This is a set collection class of PString objects.
Definition: pstring.h:2391
XMPP::Roster::Item::GetPresence
const PresenceInfo & GetPresence() const
Definition: xmpp_roster.h:74
XMPP::Presence
Definition: xmpp.h:311
XMPP::Roster::Refresh
virtual void Refresh(PBoolean sendPresence=true)
XMPP::Roster::GetItems
const ItemList & GetItems() const
Definition: xmpp_roster.h:116
PXMLElement
Definition: pxml.h:353
PString::Empty
static PString Empty()
Return an empty string.
XMPP::Roster
Definition: xmpp_roster.h:47
XMPP::Roster::Item::SetName
virtual void SetName(const PString &name, PBoolean dirty=true)
Definition: xmpp_roster.h:80
XMPP::Roster::Item::SetJID
virtual void SetJID(const JID &jid, PBoolean dirty=true)
Definition: xmpp_roster.h:76
XMPP::C2S::StreamHandler
This class handles the client side of a C2S (Client to Server) XMPP stream.
Definition: xmpp_c2s.h:81
XMPP::Roster::Item::RemoveGroup
virtual void RemoveGroup(const PString &group, PBoolean dirty=true)
XMPP::Roster::SetItem
virtual PBoolean SetItem(Item *item, PBoolean localOnly=false)
XMPP::Roster::RemoveItem
virtual PBoolean RemoveItem(const PString &jid, PBoolean localOnly=false)
XMPP::Roster::ItemType
ItemType
Definition: xmpp_roster.h:52
XMPP::Roster::RosterChangedHandlers
virtual PNotifierList & RosterChangedHandlers()
Definition: xmpp_roster.h:129
XMPP::Roster::Item::Item
Item(PXMLElement *item=0)
XMPP::Roster::m_Handler
XMPP::C2S::StreamHandler * m_Handler
Definition: xmpp_roster.h:138
XMPP::Roster::Item::m_Groups
PStringSet m_Groups
Definition: xmpp_roster.h:102
xmpp_c2s.h
XMPP::Roster::Item::m_IsDirty
PBoolean m_IsDirty
Definition: xmpp_roster.h:108
PNotifierList
Definition: notifier_ext.h:102
XMPP::Roster::Item::GetType
ItemType GetType() const
Definition: xmpp_roster.h:71
PObject
Ultimate parent class for all objects in the class library.
Definition: object.h:1118
XMPP::Roster::Item::SetDirty
void SetDirty(PBoolean b=true)
Definition: xmpp_roster.h:88
XMPP::Roster::Item::SetPresence
virtual void SetPresence(const Presence &p)
XMPP::Roster::Item::m_JID
BareJID m_JID
Definition: xmpp_roster.h:99