2 /// \file m_javaloader.h
3 /// Mode class for the JavaLoader mode
7 Copyright (C) 2005-2009, Net Direct Inc. (http://www.netdirect.ca/)
8 Copyright (C) 2008-2009, Nicolas VIVIEN
10 Some parts are inspired from m_desktop.h
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU General Public License in the COPYING file at the
22 root directory of this project for more details.
25 #ifndef __BARRY_M_JAVALOADER_H__
26 #define __BARRY_M_JAVALOADER_H__
29 #include "m_mode_base.h"
36 // forward declarations
42 class JLDirectoryEntry
;
44 class JLEventlogEntry
;
46 class BXEXPORT JLDirectory
: public std::vector
<JLDirectoryEntry
>
49 typedef std::vector
<JLDirectoryEntry
> BaseType
;
50 typedef BaseType::iterator BaseIterator
;
51 typedef std::vector
<uint16_t> TableType
;
52 typedef TableType::iterator TableIterator
;
60 JLDirectory(int level
= 0);
63 int Level() const { return m_level
; }
64 TableIterator
TableBegin() { return m_idTable
.begin(); }
65 TableIterator
TableEnd() { return m_idTable
.end(); }
67 void ParseTable(const Data
&table_packet
);
69 void Dump(std::ostream
&os
) const;
71 BXEXPORT
inline std::ostream
& operator<<(std::ostream
&os
, const JLDirectory
&d
) {
76 class BXEXPORT JLDirectoryEntry
91 explicit JLDirectoryEntry(int level
);
93 void Parse(uint16_t id
, const Data
&entry_packet
);
95 void Dump(std::ostream
&os
) const;
97 BXEXPORT
inline std::ostream
& operator<<(std::ostream
&os
, const JLDirectoryEntry
&e
) {
103 class BXEXPORT JLScreenInfo
{
114 class BXEXPORT JLEventlog
: public std::vector
<JLEventlogEntry
>
117 void Dump(std::ostream
&os
) const;
119 BXEXPORT
inline std::ostream
& operator<<(std::ostream
&os
, const JLEventlog
&log
) {
125 class BXEXPORT JLEventlogEntry
144 uint64_t Timestamp
; //FIXME what is this? time since epoch? eg: 0x11F133E6470
151 static Severity_t
SeverityProto2Rec(unsigned int s
);
152 static unsigned int SeverityRec2Proto(Severity_t s
);
154 static ViewerType_t
ViewerTypeProto2Rec(unsigned int v
);
155 static unsigned int ViewerTypeRec2Proto(ViewerType_t v
);
158 void Parse(uint16_t size
, const char* str
);
160 void Dump(std::ostream
&os
) const;
164 class BXEXPORT JLDeviceInfo
169 VersionQuad(uint32_t v
) {
170 Major
= (v
& 0xff000000) >> 24;
171 Minor
= (v
& 0xff0000) >> 16;
172 SubMinor
= (v
& 0xff00) >> 8;
178 unsigned int SubMinor
;
185 VersionQuad OsVersion
;
186 VersionQuad VmVersion
;
194 void Dump(std::ostream
&os
) const;
196 BXEXPORT
inline std::ostream
& operator<<(std::ostream
&os
, const JLDeviceInfo
&info
) {
207 /// The main interface class to the java program loader protocol
209 /// To use this class, use the following steps:
211 /// - Create a Controller object (see Controller class for more details)
212 /// - Create this Mode::JavaLoader object, passing in the Controller
213 /// object during construction
214 /// - Call Open() to open database socket and finish constructing.
215 /// - Call LoadDatabase() to retrieve and store a database
217 class BXEXPORT JavaLoader
: public Mode
220 bool m_StreamStarted
;
223 void GetDirectoryEntries(JLPacket
&packet
, uint8_t entry_cmd
,
224 JLDirectory
&dir
, bool include_subdirs
);
225 void GetDir(JLPacket
&packet
, uint8_t entry_cmd
, JLDirectory
&dir
,
226 bool include_subdirs
);
227 void ThrowJLError(const std::string
&msg
, uint8_t cmd
);
228 void DoErase(uint8_t cmd
, const std::string
&cod_name
);
229 void SaveData(JLPacket
&packet
, uint16_t, CodFileBuilder
&builder
,
230 std::ostream
&output
);
232 //////////////////////////////////
235 virtual void OnOpen();
238 JavaLoader(Controller
&con
);
241 //////////////////////////////////
246 // mid-stream operations
247 void SendStream(std::istream
&input
, size_t module_size
);
248 void LoadApp(std::istream
&input
);
249 void SetTime(time_t when
);
250 void GetDirectory(JLDirectory
&dir
, bool include_subdirs
);
251 void GetScreenshot(JLScreenInfo
&info
, Data
&image
);
252 void Erase(const std::string
&cod_name
);
253 void ForceErase(const std::string
&cod_name
);
254 void GetEventlog(JLEventlog
&log
);
255 void ClearEventlog();
256 void Save(const std::string
&cod_name
, std::ostream
&output
);
257 void DeviceInfo(JLDeviceInfo
&info
);
260 }} // namespace Barry::Mode