/* Copyright (C) 2006,2007 Marc Maurer * Copyright (C) 2008 AbiSource Corporation B.V. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. */ #ifndef __SERVICEBUDDY__ #define __SERVICEBUDDY__ #include #ifdef _MSC_VER #include "msc_stdint.h" #else #include #endif #include #include #include "ut_string_class.h" #include #include enum ServiceBuddyType { SERVICE_USER = 0, SERVICE_FRIEND, SERVICE_GROUP }; class ServiceBuddy : public Buddy { public: ServiceBuddy(AccountHandler* handler, ServiceBuddyType type_, uint64_t user_id, const std::string& name, const std::string& domain) : Buddy(handler), m_type(type_), m_user_id(user_id), m_name(name), m_domain(domain) { setVolatile(true); } virtual UT_UTF8String getDescriptor(bool include_session_info = false) const { if (include_session_info) { UT_ASSERT_HARMLESS(UT_NOT_REACHED); } std::string descr = std::string("acn://")+ boost::lexical_cast(m_user_id) + ":" + boost::lexical_cast(m_type) + "@" + m_domain; return descr.c_str(); } virtual UT_UTF8String getDescription() const { return m_name.c_str(); } ServiceBuddyType getType() const { return m_type; } uint64_t getUserId() const { return m_user_id; } const std::string& getName() const { return m_name; } virtual const DocTreeItem* getDocTreeItems() const { const vector& docHandles = getDocHandles(); DocTreeItem* first = 0; DocTreeItem* prev = 0; for (vector::const_iterator pos = docHandles.begin(); pos != docHandles.end(); pos++) { DocTreeItem* item = new DocTreeItem(); item->m_type = DOCTREEITEM_TYPE_DOCUMENT; item->m_docHandle = *pos; item->m_child = 0; item->m_next = 0; if (!first) first = item; if (prev) prev->m_next = item; prev = item; } return first; } private: ServiceBuddyType m_type; uint64_t m_user_id; std::string m_name; std::string m_domain; }; typedef boost::shared_ptr ServiceBuddyPtr; #endif /* __SERVICEBUDDY__ */