Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef ABICOLLABSESSIONMANAGER_H
00022 #define ABICOLLABSESSIONMANAGER_H
00023
00024 #include <map>
00025 #include <string>
00026 #include <vector>
00027 #include "ut_types.h"
00028 #include "pt_Types.h"
00029 #include "stdio.h"
00030 #include "ut_string_class.h"
00031 #include "xap_Dialog_Id.h"
00032 #include "xap_Types.h"
00033 #include "ie_imp.h"
00034 #include <account/xp/AccountHandler.h>
00035 #include <libxml/tree.h>
00036
00037 #ifdef _WIN32
00038 #define WIN32_LEAN_AND_MEAN
00039 #include <windows.h>
00040 #endif
00041
00042 class AbiCollab;
00043 class Event;
00044 class EventListener;
00045
00046 class AbiCollabSessionManager
00047 {
00048 public:
00049 static AbiCollabSessionManager* getManager();
00050
00051 virtual ~AbiCollabSessionManager(void);
00052
00053
00054 static UT_Error serializeDocument(const PD_Document* pDoc, std::string& document, bool encodeBase64=true );
00055 static UT_Error deserializeDocument(PD_Document** pDoc, const std::string& document, bool isEncodedBase64=true);
00056
00057
00058 bool registerDialogs(void);
00059 bool unregisterDialogs(void);
00060 XAP_Dialog_Id getDialogShareId()
00061 { return m_iDialogShare; }
00062 XAP_Dialog_Id getDialogJoinId()
00063 { return m_iDialogJoin; }
00064 XAP_Dialog_Id getDialogAccountsId()
00065 { return m_iDialogAccounts; }
00066 XAP_Dialog_Id getDialogAddAccountId()
00067 { return m_iDialogAddAccount; }
00068 XAP_Dialog_Id getDialogEditAccountId()
00069 { return m_iDialogEditAccount; }
00070 XAP_Dialog_Id getDialogAddBuddyId()
00071 { return m_iDialogAddBuddy; }
00072
00073 #ifdef _WIN32
00074
00075 void setInstance(HINSTANCE hModule)
00076 { m_hModule = hModule; }
00077 HINSTANCE getInstance()
00078 { return m_hModule; }
00079
00080 #endif
00081
00082
00083 void loadProfile();
00084 void storeProfile();
00085
00086
00087 bool destroySession(PD_Document* pDoc);
00088 bool destroySession(AbiCollab* pSession);
00089 void disconnectSession(AbiCollab* pSession);
00090 void disconnectSessions();
00091 AbiCollab* getSession(PD_Document* pDoc);
00092 AbiCollab* getSessionFromDocumentId(const std::string& sDocumentId);
00093 AbiCollab* getSessionFromSessionId(const std::string& sSessionId);
00094 const UT_GenericVector<AbiCollab *>& getSessions(void) const
00095 { return m_vecSessions;}
00096 AbiCollab* startSession(PD_Document* pDoc, std::string& sNewSessionId, AccountHandler* pAclAccount,
00097 bool bLocallyOwned, XAP_Frame* pFrame, const UT_UTF8String& masterDescriptor);
00098 void closeSession(AbiCollab* pSession, bool canConfirm);
00099 void closeSessions();
00100 void joinSessionInitiate(BuddyPtr pBuddy, DocHandle* pDocHandle);
00101 void joinSession(const std::string& sSessionId, PD_Document* pDoc,
00102 const std::string& docUUID, UT_sint32 iRev, UT_sint32 iAuthorId,
00103 BuddyPtr pCollaborator, AccountHandler* pAclAccount, bool bLocallyOwned,
00104 XAP_Frame *pFrame);
00105 void joinSession(AbiCollab* pSession, BuddyPtr pCollaborator);
00106 void disjoinSession(const std::string& sSessionId);
00107 bool isLocallyControlled(PD_Document* pDoc);
00108 bool isInSession(PD_Document* pDoc);
00109 bool isActive(const std::string& sSessionId);
00110 void removeBuddy(BuddyPtr pBuddy, bool graceful = true);
00111 void updateAcl(AbiCollab* pSession, AccountHandler* pAccount, const std::vector<std::string> acl);
00112 XAP_Frame* findFrameForSession(AbiCollab* pSession);
00113
00114
00115 bool registerAccountHandlers(void);
00116 bool unregisterAccountHandlers(void);
00117 const std::map<UT_UTF8String, AccountHandlerConstructor>&
00118 getRegisteredAccountHandlers(void)
00119 { return m_regAccountHandlers; }
00120 bool addAccount(AccountHandler* pHandler);
00121 const std::vector<AccountHandler *>& getAccounts() const
00122 { return m_vecAccounts; }
00123 void destroyAccounts();
00124 bool destroyAccount(AccountHandler* pHandler);
00125 void setDocumentHandles(BuddyPtr buddy, const UT_GenericVector<DocHandle*>& vDocHandle);
00126 BuddyPtr constructBuddy(const std::string& identifier, BuddyPtr pBuddy);
00127
00128
00129 bool processPacket(AccountHandler& handler, Packet* pPacket, BuddyPtr buddy);
00130
00131
00132 void registerEventListener(EventListener* pListener);
00133 void unregisterEventListener(EventListener* pListener);
00134 void signal(const Event& event, BuddyPtr pSource = BuddyPtr());
00135
00136
00137 void beginAsyncOperation(AbiCollab* pSession);
00138 void endAsyncOperation(AbiCollab* pSession);
00139 void beginAsyncOperation(AccountHandler* pSession);
00140 void endAsyncOperation(AccountHandler* pSession);
00141
00142
00143 void unregisterSniffers(void);
00144
00145 AbiCollabSessionManager(void);
00146
00147 private:
00148 bool _setupFrame(XAP_Frame** pFrame, PD_Document* pDoc);
00149
00150
00151 void _deleteSession(AbiCollab* pSession);
00152 void _deleteAccount(AccountHandler* pHandler);
00153 bool _nullUpdate();
00154
00155
00156 bool _canInitiateSessionTakeover(AbiCollab* pSession);
00157
00158 static AbiCollabSessionManager* m_pManager;
00159
00160
00161 XAP_Dialog_Id m_iDialogShare;
00162 XAP_Dialog_Id m_iDialogJoin;
00163 XAP_Dialog_Id m_iDialogAccounts;
00164 XAP_Dialog_Id m_iDialogAddAccount;
00165 XAP_Dialog_Id m_iDialogEditAccount;
00166 XAP_Dialog_Id m_iDialogAddBuddy;
00167
00168 #ifdef _WIN32
00169 HINSTANCE m_hModule;
00170 #endif
00171
00172
00173 UT_GenericVector<AbiCollab *> m_vecSessions;
00174
00175
00176 std::map<UT_UTF8String, AccountHandlerConstructor> m_regAccountHandlers;
00177 std::vector<AccountHandler *> m_vecAccounts;
00178 UT_GenericVector<EventListener *> m_vecEventListeners;
00179
00180
00181 std::map<AbiCollab*, int> m_asyncSessionOps;
00182 std::map<AccountHandler*, int> m_asyncAccountOps;
00183
00184
00185 std::vector<IE_ImpSniffer*> m_vImpSniffers;
00186 };
00187
00188 #endif