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
39 class JLDirectoryEntry
;
41 class BXEXPORT JLDirectory
: public std::vector
<JLDirectoryEntry
>
44 typedef std::vector
<JLDirectoryEntry
> BaseType
;
45 typedef BaseType::iterator BaseIterator
;
46 typedef std::vector
<uint16_t> TableType
;
47 typedef TableType::iterator TableIterator
;
55 JLDirectory(int level
= 0);
58 int Level() const { return m_level
; }
59 TableIterator
TableBegin() { return m_idTable
.begin(); }
60 TableIterator
TableEnd() { return m_idTable
.end(); }
62 void ParseTable(const Data
&table_packet
);
64 void Dump(std::ostream
&os
) const;
66 BXEXPORT
inline std::ostream
& operator<<(std::ostream
&os
, const JLDirectory
&d
) {
71 class BXEXPORT JLDirectoryEntry
86 explicit JLDirectoryEntry(int level
);
88 void Parse(uint16_t id
, const Data
&entry_packet
);
90 void Dump(std::ostream
&os
) const;
92 BXEXPORT
inline std::ostream
& operator<<(std::ostream
&os
, const JLDirectoryEntry
&e
) {
103 /// The main interface class to the java program loader protocol
105 /// To use this class, use the following steps:
107 /// - Create a Controller object (see Controller class for more details)
108 /// - Create this Mode::JavaLoader object, passing in the Controller
109 /// object during construction
110 /// - Call Open() to open database socket and finish constructing.
111 /// - Call LoadDatabase() to retrieve and store a database
113 class BXEXPORT JavaLoader
118 SocketHandle m_socket
;
120 uint16_t m_ModeSocket
; // socket recommended by device
121 // when mode was selected
124 void GetDirectoryEntries(JLPacket
&packet
, uint8_t entry_cmd
,
125 JLDirectory
&dir
, bool include_subdirs
);
126 void GetDir(JLPacket
&packet
, uint8_t entry_cmd
, JLDirectory
&dir
,
127 bool include_subdirs
);
128 void ThrowJLError(const std::string
&msg
, uint8_t cmd
);
131 JavaLoader(Controller
&con
);
134 //////////////////////////////////
135 // primary operations - required before anything else
137 void Open(const char *password
= 0);
138 void RetryPassword(const char *password
);
140 //////////////////////////////////
143 void StopStream(void);
145 // mid-stream operations
146 void SendStream(char *buffer
, int size
);
147 void SetTime(time_t when
);
148 void GetDirectory(JLDirectory
&dir
, bool include_subdirs
);
151 }} // namespace Barry::Mode