/* Copyright (C) 2010 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 __TELEPATHY_CHATROOM_H__ #define __TELEPATHY_CHATROOM_H__ #include #include #include #include #include #include #include #include #include #include "TelepathyBuddy.h" class TelepathyAccountHandler; class DTubeBuddy; typedef boost::shared_ptr DTubeBuddyPtr; class TelepathyChatroom : public boost::enable_shared_from_this { public: TelepathyChatroom(TelepathyAccountHandler* pHandler, TpChannel* pChannel, PD_Document* pDoc, const UT_UTF8String& sSessionId); bool running() { return m_pChannel != NULL; } bool tubeOffered() { return m_pTube != NULL; } void stop(); void finalize(); void setChannel(TpChannel* pChannel); boost::shared_ptr ptr() { return shared_from_this(); } TelepathyAccountHandler* getHandler() { return m_pHandler; } void addBuddy(DTubeBuddyPtr pBuddy); const std::vector& getBuddies() { return m_buddies; } DTubeBuddyPtr getBuddy(TpHandle handle); DTubeBuddyPtr getBuddy(UT_UTF8String dbusName); void removeBuddy(TpHandle handle); DBusConnection* getTube() { return m_pTube; } const UT_UTF8String& getSessionId() { return m_sSessionId; } void setSessionId(const UT_UTF8String& sSessionId) { m_sSessionId = sSessionId; } UT_UTF8String getDocName(); void queue(const std::string& dbusName, const std::string& packet); void acceptTube(const char* address); void queueInvite(TelepathyBuddyPtr pBuddy); bool offerTube(); void finalizeOfferTube(DBusConnection* pTube); bool isController(DTubeBuddyPtr pBuddy); bool isLocallyControlled(); private: TelepathyAccountHandler* m_pHandler; TpChannel* m_pChannel; PD_Document* m_pDoc; DBusConnection* m_pTube; UT_UTF8String m_sSessionId; std::vector m_buddies; std::vector m_pending_invitees; std::map > m_packet_queue; bool m_bShuttingDown; std::vector m_offered_tubes; // list of TelepathyBuddy descriptors }; typedef boost::shared_ptr TelepathyChatroomPtr; #endif /* __TELEPATHY_CHATROOM_H__ */