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__
34 // forward declarations
41 class JLDirectoryEntry
;
43 class JLEventlogEntry
;
45 class BXEXPORT JLDirectory
: public std::vector
<JLDirectoryEntry
>
48 typedef std::vector
<JLDirectoryEntry
> BaseType
;
49 typedef BaseType::iterator BaseIterator
;
50 typedef std::vector
<uint16_t> TableType
;
51 typedef TableType::iterator TableIterator
;
59 JLDirectory(int level
= 0);
62 int Level() const { return m_level
; }
63 TableIterator
TableBegin() { return m_idTable
.begin(); }
64 TableIterator
TableEnd() { return m_idTable
.end(); }
66 void ParseTable(const Data
&table_packet
);
68 void Dump(std::ostream
&os
) const;
70 BXEXPORT
inline std::ostream
& operator<<(std::ostream
&os
, const JLDirectory
&d
) {
75 class BXEXPORT JLDirectoryEntry
90 explicit JLDirectoryEntry(int level
);
92 void Parse(uint16_t id
, const Data
&entry_packet
);
94 void Dump(std::ostream
&os
) const;
96 BXEXPORT
inline std::ostream
& operator<<(std::ostream
&os
, const JLDirectoryEntry
&e
) {
102 class BXEXPORT JLScreenInfo
{
113 class BXEXPORT JLEventlog
: public std::vector
<JLEventlogEntry
>
116 void Dump(std::ostream
&os
) const;
118 BXEXPORT
inline std::ostream
& operator<<(std::ostream
&os
, const JLEventlog
&log
) {
124 class BXEXPORT JLEventlogEntry
143 uint64_t Timestamp
; //FIXME what is this? time since epoch? eg: 0x11F133E6470
150 static Severity_t
SeverityProto2Rec(unsigned int s
);
151 static unsigned int SeverityRec2Proto(Severity_t s
);
153 static ViewerType_t
ViewerTypeProto2Rec(unsigned int v
);
154 static unsigned int ViewerTypeRec2Proto(ViewerType_t v
);
157 void Parse(uint16_t size
, const char* str
);
159 void Dump(std::ostream
&os
) const;
168 /// The main interface class to the java program loader protocol
170 /// To use this class, use the following steps:
172 /// - Create a Controller object (see Controller class for more details)
173 /// - Create this Mode::JavaLoader object, passing in the Controller
174 /// object during construction
175 /// - Call Open() to open database socket and finish constructing.
176 /// - Call LoadDatabase() to retrieve and store a database
178 class BXEXPORT JavaLoader
183 SocketHandle m_socket
;
185 uint16_t m_ModeSocket
; // socket recommended by device
186 // when mode was selected
188 bool m_StreamStarted
;
191 void GetDirectoryEntries(JLPacket
&packet
, uint8_t entry_cmd
,
192 JLDirectory
&dir
, bool include_subdirs
);
193 void GetDir(JLPacket
&packet
, uint8_t entry_cmd
, JLDirectory
&dir
,
194 bool include_subdirs
);
195 void ThrowJLError(const std::string
&msg
, uint8_t cmd
);
196 void DoErase(uint8_t cmd
, const std::string
&cod_name
);
197 void SaveData(JLPacket
&packet
, uint16_t, CodFileBuilder
&builder
,
198 std::ostream
&output
);
201 JavaLoader(Controller
&con
);
204 //////////////////////////////////
205 // primary operations - required before anything else
207 void Open(const char *password
= 0);
208 void RetryPassword(const char *password
);
210 //////////////////////////////////
215 // mid-stream operations
216 void SendStream(std::istream
&input
, size_t module_size
);
217 void LoadApp(std::istream
&input
);
218 void SetTime(time_t when
);
219 void GetDirectory(JLDirectory
&dir
, bool include_subdirs
);
220 void GetScreenshot(JLScreenInfo
&info
, Data
&image
);
221 void Erase(const std::string
&cod_name
);
222 void ForceErase(const std::string
&cod_name
);
223 void GetEventlog(JLEventlog
&log
);
224 void ClearEventlog();
225 void Save(const std::string
&cod_name
, std::ostream
&output
);
228 }} // namespace Barry::Mode