Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __REALM_BUDDY__
00020 #define __REALM_BUDDY__
00021
00022 #ifdef _MSC_VER
00023 #include "msc_stdint.h"
00024 #else
00025 #include <stdint.h>
00026 #endif
00027 #include <string>
00028 #include <boost/shared_ptr.hpp>
00029 #include <boost/enable_shared_from_this.hpp>
00030 #include <boost/lexical_cast.hpp>
00031 #include "ut_string_class.h"
00032 #include <core/account/xp/Buddy.h>
00033 #include <core/account/xp/AccountHandler.h>
00034
00035 class RealmConnection;
00036
00037 class RealmBuddy : public Buddy , public boost::enable_shared_from_this<RealmBuddy>
00038 {
00039 public:
00040 RealmBuddy(AccountHandler* handler, uint64_t _user_id, const std::string& domain_,
00041 UT_uint8 realm_conn_id, bool _master, boost::shared_ptr<RealmConnection> conn)
00042 : Buddy(handler),
00043 m_user_id(_user_id),
00044 m_domain(domain_),
00045 m_realm_connection_id(realm_conn_id),
00046 m_master(_master),
00047 m_connection(conn)
00048 {
00049 setVolatile(true);
00050 }
00051
00052 virtual UT_UTF8String getDescriptor(bool include_session_info = false) const
00053 {
00054 return UT_UTF8String("acn://") +
00055 boost::lexical_cast<std::string>(m_user_id).c_str() +
00056 (include_session_info ? UT_UTF8String(":") + boost::lexical_cast<std::string>((uint32_t)m_realm_connection_id).c_str() : UT_UTF8String("")) +
00057 UT_UTF8String("@") +
00058 m_domain.c_str();
00059 }
00060
00061 virtual UT_UTF8String getDescription() const
00062 {
00063 return getDescriptor();
00064 }
00065
00066 virtual const DocTreeItem* getDocTreeItems() const
00067 {
00068 return NULL;
00069 }
00070
00071 boost::shared_ptr<RealmBuddy> ptr() {
00072 return shared_from_this();
00073 }
00074
00075 std::string domain() {
00076 return m_domain;
00077 }
00078
00079 boost::shared_ptr<RealmConnection> connection() {
00080 return m_connection;
00081 }
00082
00083 uint64_t user_id() const {
00084 return m_user_id;
00085 }
00086
00087 UT_uint8 realm_connection_id() const {
00088 return m_realm_connection_id;
00089 }
00090
00091 bool master() const {
00092 return m_master;
00093 }
00094
00095 void demote() {
00096 m_master = false;
00097 }
00098
00099 void promote() {
00100 m_master = true;
00101 }
00102
00103 private:
00104 uint64_t m_user_id;
00105 std::string m_domain;
00106 UT_uint8 m_realm_connection_id;
00107 bool m_master;
00108 boost::shared_ptr<RealmConnection> m_connection;
00109 };
00110
00111 typedef boost::shared_ptr<RealmBuddy> RealmBuddyPtr;
00112
00113 #endif