gloox  1.0
rosteritem.h
1 /*
2  Copyright (c) 2004-2009 by Jakob Schroeter <js@camaya.net>
3  This file is part of the gloox library. http://camaya.net/gloox
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 
14 #ifndef ROSTERITEM_H__
15 #define ROSTERITEM_H__
16 
17 #include "gloox.h"
18 #include "resource.h"
19 #include "presence.h"
20 
21 #include <string>
22 #include <list>
23 
24 
25 namespace gloox
26 {
27 
28  class RosterItemData;
29 
39  class GLOOX_API RosterItem
40  {
41  friend class RosterManager;
42 
43  public:
47  typedef std::map<std::string, Resource*> ResourceMap;
48 
54  RosterItem( const std::string& jid, const std::string& name = EmptyString );
55 
61  RosterItem( const RosterItemData& data );
62 
66  virtual ~RosterItem();
67 
72  void setName( const std::string& name );
73 
78  const std::string& name() const;
79 
84  const std::string& jid() const;
85 
91  void setSubscription( const std::string& subscription, const std::string& ask );
92 
97  SubscriptionType subscription() const;
98 
103  void setGroups( const StringList& groups );
104 
109  const StringList groups() const;
110 
115  bool changed() const;
116 
121  bool online() const;
122 
127  const ResourceMap& resources() const { return m_resources; }
128 
134  const Resource* resource( const std::string& res ) const;
135 
140  const Resource* highestResource() const;
141 
142  protected:
148  void setPresence( const std::string& resource, Presence::PresenceType presence );
149 
155  void setStatus( const std::string& resource, const std::string& msg );
156 
162  void setPriority( const std::string& resource, int priority );
163 
169  void setExtensions( const std::string& resource, const StanzaExtensionList& exts );
170 
174  void setSynchronized();
175 
180  void removeResource( const std::string& resource );
181 
186  void setData( const RosterItemData& rid );
187 
188  private:
189  RosterItemData* m_data;
190  ResourceMap m_resources;
191 
192  };
193 
194 }
195 
196 #endif // ROSTERITEM_H__