• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

RealmBuddy.h

Go to the documentation of this file.
00001 /* Copyright (C) 2008-2009 AbiSource Corporation B.V.
00002  *
00003  * This program is free software; you can redistribute it and/or
00004  * modify it under the terms of the GNU General Public License
00005  * as published by the Free Software Foundation; either version 2
00006  * of the License, or (at your option) any later version.
00007  *
00008  * This program is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  * GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program; if not, write to the Free Software
00015  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00016  * 02110-1301 USA.
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 /* __REALM_BUDDY__ */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1