gloox  0.9.9.12
rosteritem.h
1 /*
2  Copyright (c) 2004-2008 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 "jid.h"
19 #include "resource.h"
20 
21 #include <string>
22 #include <list>
23 
24 
25 namespace gloox
26 {
27 
37  class GLOOX_API RosterItem
38  {
39  friend class RosterManager;
40 
41  public:
45  typedef std::map<std::string, Resource*> ResourceMap;
46 
51  {
52  S10nNone,
54  S10nNoneOut,
57  S10nNoneIn,
62  S10nNoneOutIn,
67  S10nToIn,
70  S10nFromOut,
72  S10nBoth
73  };
74 
80  RosterItem( const JID& jid, const std::string& name = "" );
81 
85  virtual ~RosterItem();
86 
91  virtual void setName( const std::string& name );
92 
97  virtual const std::string& name() const { return m_name; }
98 
103  virtual const std::string& jid() const { return m_jid; }
104 
109  virtual SubscriptionEnum subscription() const { return m_subscription; }
110 
115  virtual void setGroups( const StringList& groups );
116 
121  virtual const StringList& groups() const { return m_groups; }
122 
127  virtual bool changed() const { return m_changed; }
128 
133  virtual bool online() const;
134 
139  virtual const ResourceMap& resources() const { return m_resources; }
140 
146  virtual const Resource* resource( const std::string& res ) const;
147 
148  protected:
154  virtual void setPresence( const std::string& resource, Presence presence );
155 
161  virtual void setStatus( const std::string& resource, const std::string& msg );
162 
168  virtual void setPriority( const std::string& resource, int priority );
169 
175  virtual void setSubscription( const std::string& subscription, bool ask );
176 
180  virtual void setSynchronized() { m_changed = false; }
181 
186  virtual void removeResource( const std::string& resource );
187 
188  private:
189  StringList m_groups;
190  ResourceMap m_resources;
191  SubscriptionEnum m_subscription;
192  std::string m_name;
193  std::string m_jid;
194  bool m_changed;
195  };
196 
197 }
198 
199 #endif // ROSTERITEM_H__