00001 /* Copyright (C) 2007 One Laptop Per Child 00002 * Author: Marc Maurer <uwog@uwog.net> 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00017 * 02110-1301 USA. 00018 */ 00019 00020 #ifndef __DTUBEBUDDY_H__ 00021 #define __DTUBEBUDDY_H__ 00022 00023 #include <map> 00024 #include <telepathy-glib/telepathy-glib.h> 00025 #include <account/xp/Buddy.h> 00026 #include <account/xp/DocTreeItem.h> 00027 #include <account/xp/AccountHandler.h> 00028 #include "TelepathyChatroom.h" 00029 00030 class DocHandle; 00031 00032 class DTubeBuddy : public Buddy 00033 { 00034 public: 00035 DTubeBuddy(AccountHandler* handler, TelepathyChatroomPtr pChatRoom, TpHandle handle, const UT_UTF8String dbusName) 00036 : Buddy(handler), 00037 m_pChatRoom(pChatRoom), 00038 m_handle(handle), 00039 m_sDBusName(dbusName), 00040 m_pContact(NULL), 00041 m_pGlobalContact(NULL) 00042 { 00043 setVolatile(true); 00044 } 00045 00046 virtual ~DTubeBuddy() 00047 { 00048 if (m_pContact) 00049 g_object_unref(m_pContact); 00050 } 00051 00052 virtual UT_UTF8String getDescriptor(bool /*include_session_info = false*/) const 00053 { 00054 return UT_UTF8String("dtube://") + m_sDBusName; 00055 } 00056 00057 virtual UT_UTF8String getDescription() const 00058 { 00059 static UT_UTF8String description = m_sDBusName; 00060 return description; 00061 } 00062 00063 virtual const DocTreeItem* getDocTreeItems() const 00064 { 00065 UT_ASSERT_HARMLESS(UT_NOT_REACHED); 00066 return NULL; 00067 } 00068 00069 TelepathyChatroomPtr getChatRoom() 00070 { 00071 return m_pChatRoom; 00072 } 00073 00074 TpHandle getHandle() 00075 { 00076 return m_handle; 00077 } 00078 00079 const UT_UTF8String& getDBusName() 00080 { 00081 return m_sDBusName; 00082 } 00083 00084 void setContact(TpContact* pContact) 00085 { 00086 00087 g_object_ref(pContact); 00088 m_pContact = pContact; 00089 } 00090 00091 TpContact* getContact() 00092 { 00093 return m_pContact; 00094 } 00095 00096 void setGlobalContact(TpContact* pGlobalContact) 00097 { 00098 00099 g_object_ref(pGlobalContact); 00100 m_pGlobalContact = pGlobalContact; 00101 } 00102 00103 TpContact* getGlobalContact() 00104 { 00105 return m_pGlobalContact; 00106 } 00107 00108 private: 00109 TelepathyChatroomPtr m_pChatRoom; 00110 TpHandle m_handle; 00111 UT_UTF8String m_sDBusName; 00112 TpContact* m_pContact; 00113 TpContact* m_pGlobalContact; 00114 }; 00115 00116 typedef boost::shared_ptr<DTubeBuddy> DTubeBuddyPtr; 00117 00118 #endif /* __DTUBEBUDDY_H__ */