rosteritem.h

00001 /*
00002   Copyright (c) 2004-2006 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 "jid.h"
00019 
00020 #include <string>
00021 #include <list>
00022 
00023 
00024 namespace gloox
00025 {
00026 
00036   class GLOOX_API RosterItem
00037   {
00038     friend class RosterManager;
00039 
00040     public:
00049       class GLOOX_API Resource
00050       {
00051 
00052         friend class RosterItem;
00053 
00054         public:
00061           Resource( int priority, const std::string& msg, Presence status )
00062             : m_priority( priority ), m_message( msg ), m_status( status ) {};
00063 
00067           virtual ~Resource() {};
00068 
00073           int priority() const { return m_priority; };
00074 
00079           const std::string& message() const { return m_message; };
00080 
00085           Presence status() const { return m_status; };
00086 
00087         private:
00088           void setPriority( int priority ) { m_priority = priority; };
00089           void setMessage( std::string message ) { m_message = message; };
00090           void setStatus( Presence status ) { m_status = status; };
00091 
00092           int m_priority;
00093           std::string m_message;
00094           Presence m_status;
00095 
00096       };
00097 
00101       typedef std::map<std::string, Resource*> ResourceMap;
00102 
00106       enum SubscriptionEnum
00107       {
00108         S10N_NONE,            
00110         S10N_NONE_OUT,        
00113         S10N_NONE_IN,         
00118         S10N_NONE_OUT_IN,     
00122         S10N_TO,              
00123         S10N_TO_IN,           
00125         S10N_FROM,            
00126         S10N_FROM_OUT,        
00128         S10N_BOTH             
00129       };
00130 
00136       RosterItem( const JID& jid, const std::string& name = "" );
00137 
00141       virtual ~RosterItem();
00142 
00147       virtual void setName( const std::string& name );
00148 
00153       virtual const std::string& name() const { return m_name; };
00154 
00159       virtual const std::string& jid() const { return m_jid; };
00160 
00165       virtual SubscriptionEnum subscription() const { return m_subscription; };
00166 
00171       virtual void setGroups( const StringList& groups );
00172 
00177       virtual const StringList& groups() { return m_groups; };
00178 
00183       virtual bool changed() const { return m_changed; };
00184 
00189       virtual bool online() const;
00190 
00195       virtual const ResourceMap& resources() const { return m_resources; };
00196 
00197     protected:
00203       virtual void setStatus( const std::string& resource, Presence status );
00204 
00210       virtual void setStatusMsg( const std::string& resource, const std::string& msg );
00211 
00217       virtual void setPriority( const std::string& resource, int priority );
00218 
00224       virtual void setSubscription( const std::string& subscription, bool ask );
00225 
00229       virtual void setSynchronized() { m_changed = false; };
00230 
00235       virtual void removeResource( const std::string& resource );
00236 
00237     private:
00238       StringList m_groups;
00239       ResourceMap m_resources;
00240       SubscriptionEnum m_subscription;
00241       std::string m_name;
00242       std::string m_jid;
00243       bool m_changed;
00244   };
00245 
00246 }
00247 
00248 #endif // ROSTERITEM_H__

Generated on Tue May 1 14:20:20 2007 for gloox by  doxygen 1.5.1