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

TelepathyChatroom.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 __TELEPATHY_CHATROOM_H__
00020 #define __TELEPATHY_CHATROOM_H__
00021 
00022 #include <map>
00023 #include <vector>
00024 
00025 #include <telepathy-glib/telepathy-glib.h>
00026 #include <boost/shared_ptr.hpp>
00027 #include <boost/enable_shared_from_this.hpp>
00028 #include <dbus/dbus.h>
00029 #include <dbus/dbus-glib.h>
00030 #include <dbus/dbus-glib-lowlevel.h>
00031 
00032 #include <ut_string_class.h>
00033 #include "TelepathyBuddy.h"
00034 
00035 class TelepathyAccountHandler;
00036 class DTubeBuddy;
00037 typedef boost::shared_ptr<DTubeBuddy> DTubeBuddyPtr;
00038 
00039 class TelepathyChatroom : public boost::enable_shared_from_this<TelepathyChatroom>
00040 {
00041 public:
00042     TelepathyChatroom(TelepathyAccountHandler* pHandler, TpChannel* pChannel,
00043               PD_Document* pDoc, const std::string& sSessionId);
00044 
00045     bool running()
00046         { return m_pChannel != NULL; }
00047 
00048     bool tubeOffered()
00049         { return m_pTube != NULL; }
00050 
00051     void stop();
00052 
00053     void finalize();
00054 
00055     void setChannel(TpChannel* pChannel);
00056 
00057     boost::shared_ptr<TelepathyChatroom> ptr()
00058         { return shared_from_this(); }
00059 
00060     TelepathyAccountHandler* getHandler()
00061         { return m_pHandler; }
00062 
00063     void addBuddy(DTubeBuddyPtr pBuddy);
00064 
00065     const std::vector<DTubeBuddyPtr>& getBuddies()
00066         { return m_buddies; }
00067 
00068     DTubeBuddyPtr getBuddy(TpHandle handle);
00069 
00070     DTubeBuddyPtr getBuddy(UT_UTF8String dbusName);
00071 
00072     void removeBuddy(TpHandle handle);
00073 
00074     DBusConnection* getTube()
00075         { return m_pTube; }
00076 
00077     const std::string& getSessionId() const
00078         { return m_sSessionId; }
00079 
00080     void setSessionId(const std::string& sSessionId)
00081         { m_sSessionId = sSessionId; }
00082 
00083     std::string getDocName();
00084 
00085     void queue(const std::string& dbusName, const std::string& packet);
00086 
00087     void acceptTube(const char* address);
00088 
00089     void queueInvite(TelepathyBuddyPtr pBuddy);
00090 
00091     bool offerTube();
00092 
00093     void finalizeOfferTube(DBusConnection* pTube);
00094 
00095     bool isController(DTubeBuddyPtr pBuddy);
00096 
00097     bool isLocallyControlled();
00098 
00099 private:
00100     TelepathyAccountHandler*    m_pHandler;
00101     TpChannel*                  m_pChannel;
00102     PD_Document*                m_pDoc;
00103     DBusConnection*             m_pTube;
00104     std::string             m_sSessionId;
00105     std::vector<DTubeBuddyPtr>  m_buddies;
00106     std::vector<TelepathyBuddyPtr> m_pending_invitees;
00107     std::map<std::string, std::vector<std::string> > m_packet_queue;
00108     bool                        m_bShuttingDown;
00109 
00110     std::vector<std::string> m_offered_tubes; // list of TelepathyBuddy descriptors
00111 };
00112 
00113 typedef boost::shared_ptr<TelepathyChatroom> TelepathyChatroomPtr;
00114 
00115 #endif /* __TELEPATHY_CHATROOM_H__ */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1