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

SIPSimpleBuddy.h

Go to the documentation of this file.
00001 /* Copyright (C) 2010 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 __SIPSIMPLEBUDDY_H__
00020 #define __SIPSIMPLEBUDDY_H__
00021 
00022 #include <map>
00023 #include <string>
00024 #include <boost/shared_ptr.hpp>
00025 #include "ut_string_class.h"
00026 #include <core/account/xp/Buddy.h>
00027 #include <core/account/xp/DocTreeItem.h>
00028 #include <core/account/xp/AccountHandler.h>
00029 
00030 class DocHandle;
00031 
00032 class SIPSimpleBuddy : public Buddy
00033 {
00034 public:
00035     SIPSimpleBuddy(AccountHandler* handler, const std::string& address)
00036         : Buddy(handler),
00037         m_address(address)
00038     {
00039     }
00040 
00041     virtual UT_UTF8String getDescriptor(bool /*include_session_info = false*/) const
00042     {
00043         return UT_UTF8String("sipsimple://") + m_address.c_str();
00044     }
00045 
00046     virtual UT_UTF8String       getDescription() const
00047         { return m_address.c_str(); }
00048 
00049     virtual const std::string& getAddress() const {
00050         return m_address;
00051     }
00052 
00053     virtual const DocTreeItem* getDocTreeItems() const
00054     {
00055         const std::vector<DocHandle*>& docHandles = getDocHandles();
00056         DocTreeItem* first = 0;
00057         DocTreeItem* prev = 0;
00058         for (std::vector<DocHandle*>::const_iterator pos = docHandles.begin(); pos != docHandles.end(); pos++)
00059         {
00060             DocTreeItem* item = new DocTreeItem();
00061             item->m_type = DOCTREEITEM_TYPE_DOCUMENT;
00062             item->m_docHandle = *pos;
00063             item->m_child = 0;
00064             item->m_next = 0;
00065 
00066             if (!first)
00067                 first = item;
00068             if (prev)
00069                 prev->m_next = item;
00070             prev = item;
00071         }
00072         return first;
00073     }
00074 
00075 private:
00076     std::string m_address;
00077 };
00078 
00079 typedef boost::shared_ptr<SIPSimpleBuddy> SIPSimpleBuddyPtr;
00080 
00081 #endif /* SIPSIMPLEBUDDY_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1