gloox  1.0.1
rosteritem.h
1 /*
2  Copyright (c) 2004-2012 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 "jid.h"
18 #include "gloox.h"
19 #include "resource.h"
20 #include "presence.h"
21 
22 #include <string>
23 #include <list>
24 
25 
26 namespace gloox
27 {
28 
29  class RosterItemData;
30 
40  class GLOOX_API RosterItem
41  {
42  friend class RosterManager;
43 
44  public:
48  typedef std::map<std::string, Resource*> ResourceMap;
49 
53  const JID EmptyJID;
54 
60  RosterItem( const std::string& jid, const std::string& name = EmptyString );
61 
67  RosterItem( const RosterItemData& data );
68 
72  virtual ~RosterItem();
73 
78  void setName( const std::string& name );
79 
84  const std::string& name() const;
85 
91  GLOOX_DEPRECATED const std::string& jid() const;
92 
98  const JID& jidJID() const;
99 
105  void setSubscription( const std::string& subscription, const std::string& ask );
106 
111  SubscriptionType subscription() const;
112 
117  void setGroups( const StringList& groups );
118 
123  const StringList groups() const;
124 
129  bool changed() const;
130 
135  bool online() const;
136 
141  const ResourceMap& resources() const { return m_resources; }
142 
148  const Resource* resource( const std::string& res ) const;
149 
154  const Resource* highestResource() const;
155 
156  protected:
162  void setPresence( const std::string& resource, Presence::PresenceType presence );
163 
169  void setStatus( const std::string& resource, const std::string& msg );
170 
176  void setPriority( const std::string& resource, int priority );
177 
183  void setExtensions( const std::string& resource, const StanzaExtensionList& exts );
184 
188  void setSynchronized();
189 
194  void removeResource( const std::string& resource );
195 
200  void setData( const RosterItemData& rid );
201 
202  private:
203  RosterItemData* m_data;
204  ResourceMap m_resources;
205 
206  };
207 
208 }
209 
210 #endif // ROSTERITEM_H__