gloox 1.0
rosteritem.h
00001 /*
00002   Copyright (c) 2004-2009 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 ROSTERITEM_H__
00015 #define ROSTERITEM_H__
00016 
00017 #include "gloox.h"
00018 #include "resource.h"
00019 #include "presence.h"
00020 
00021 #include <string>
00022 #include <list>
00023 
00024 
00025 namespace gloox
00026 {
00027 
00028   class RosterItemData;
00029 
00039   class GLOOX_API RosterItem
00040   {
00041     friend class RosterManager;
00042 
00043     public:
00047       typedef std::map<std::string, Resource*> ResourceMap;
00048 
00054       RosterItem( const std::string& jid, const std::string& name = EmptyString );
00055 
00061       RosterItem( const RosterItemData& data );
00062 
00066       virtual ~RosterItem();
00067 
00072       void setName( const std::string& name );
00073 
00078       const std::string& name() const;
00079 
00084       const std::string& jid() const;
00085 
00091       void setSubscription( const std::string& subscription, const std::string& ask );
00092 
00097       SubscriptionType subscription() const;
00098 
00103       void setGroups( const StringList& groups );
00104 
00109       const StringList groups() const;
00110 
00115       bool changed() const;
00116 
00121       bool online() const;
00122 
00127       const ResourceMap& resources() const { return m_resources; }
00128 
00134       const Resource* resource( const std::string& res ) const;
00135 
00140       const Resource* highestResource() const;
00141 
00142     protected:
00148       void setPresence( const std::string& resource, Presence::PresenceType presence );
00149 
00155       void setStatus( const std::string& resource, const std::string& msg );
00156 
00162       void setPriority( const std::string& resource, int priority );
00163 
00169       void setExtensions( const std::string& resource, const StanzaExtensionList& exts );
00170 
00174       void setSynchronized();
00175 
00180       void removeResource( const std::string& resource );
00181 
00186       void setData( const RosterItemData& rid );
00187 
00188     private:
00189       RosterItemData* m_data;
00190       ResourceMap m_resources;
00191 
00192   };
00193 
00194 }
00195 
00196 #endif // ROSTERITEM_H__