00001 /* Copyright (C) 2006 by Marc Maurer <uwog@uwog.net> 00002 * Copyright (C) 2007 One Laptop Per Child 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00017 * 02110-1301 USA. 00018 */ 00019 00020 #ifndef __SESSIONEVENT_H__ 00021 #define __SESSIONEVENT_H__ 00022 00023 #include "Event.h" 00024 #include <session/xp/AbiCollab.h> 00025 #include <packet/xp/AbiCollab_Packet.h> 00026 00027 class StartSessionEvent : public Event 00028 { 00029 public: 00030 DECLARE_PACKET(StartSessionEvent); 00031 }; 00032 00033 class GetSessionsEvent : public Event 00034 { 00035 public: 00036 DECLARE_PACKET(GetSessionsEvent); 00037 }; 00038 00039 class GetSessionsResponseEvent : public Event 00040 { 00041 public: 00042 DECLARE_PACKET(GetSessionsResponseEvent); 00043 std::map<std::string,UT_UTF8String> m_Sessions; // contains session/name pairs 00044 }; 00045 00046 class JoinSessionEvent : public Event 00047 { 00048 public: 00049 DECLARE_PACKET(JoinSessionEvent); 00050 JoinSessionEvent() : m_sSessionId("") {} 00051 JoinSessionEvent(const std::string& sessionId) 00052 : m_sSessionId(sessionId) 00053 { 00054 UT_ASSERT(m_sSessionId != ""); 00055 } 00056 00057 virtual std::string toStr() const; 00058 00059 const std::string& getSessionId() const 00060 { return m_sSessionId; } 00061 00062 private: 00063 std::string m_sSessionId; 00064 }; 00065 00066 class JoinSessionRequestEvent : public JoinSessionEvent { 00067 public: 00068 DECLARE_PACKET(JoinSessionRequestEvent); 00069 JoinSessionRequestEvent() {} 00070 JoinSessionRequestEvent(const std::string& sessionId) 00071 : JoinSessionEvent(sessionId) {} 00072 }; 00073 00074 class JoinSessionRequestResponseEvent : public Event 00075 { 00076 public: 00077 DECLARE_PACKET(JoinSessionRequestResponseEvent); 00078 JoinSessionRequestResponseEvent() : m_sDocumentName(""), m_sDocumentId(""), m_sSessionId(""), m_iAuthorId(-1) {} 00079 JoinSessionRequestResponseEvent(const std::string& sessionId, UT_sint32 iAuthorId) 00080 : m_iRev(0) 00081 , m_sDocumentName("") 00082 , m_sDocumentId("") 00083 , m_sSessionId(sessionId) 00084 , m_iAuthorId(iAuthorId) 00085 { 00086 UT_ASSERT(m_sSessionId != ""); 00087 } 00088 00089 const std::string& getSessionId() const 00090 { return m_sSessionId; } 00091 00092 UT_sint32 getAuthorId() const 00093 { return m_iAuthorId; } 00094 00095 virtual std::string toStr() const; 00096 00097 std::string m_sZABW; 00098 UT_sint32 m_iRev; 00099 UT_UTF8String m_sDocumentName; 00100 std::string m_sDocumentId; 00101 00102 private: 00103 std::string m_sSessionId; 00104 UT_sint32 m_iAuthorId; 00105 }; 00106 00107 class DisjoinSessionEvent : public Event 00108 { 00109 public: 00110 DECLARE_PACKET(DisjoinSessionEvent); 00111 DisjoinSessionEvent() : m_sSessionId("") {} 00112 DisjoinSessionEvent(const std::string& sessionId) 00113 : m_sSessionId(sessionId) 00114 { 00115 UT_ASSERT(m_sSessionId != ""); 00116 } 00117 00118 virtual std::string toStr() const; 00119 00120 const std::string& getSessionId() const 00121 { return m_sSessionId; } 00122 00123 private: 00124 std::string m_sSessionId; 00125 }; 00126 00127 class CloseSessionEvent : public Event 00128 { 00129 public: 00130 DECLARE_PACKET(CloseSessionEvent); 00131 CloseSessionEvent() : m_sSessionId("") {} 00132 CloseSessionEvent(const std::string& sessionId) 00133 : m_sSessionId(sessionId) 00134 { 00135 UT_ASSERT(m_sSessionId != ""); 00136 } 00137 00138 virtual std::string toStr() const; 00139 00140 const std::string& getSessionId() const 00141 { return m_sSessionId; } 00142 00143 private: 00144 std::string m_sSessionId; 00145 }; 00146 00147 #endif /* __SESSIONEVENT_H__ */