3 /// High level BlackBerry API class
7 Copyright (C) 2005-2006, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #ifndef __BARRY_CONTROLLER_H__
23 #define __BARRY_CONTROLLER_H__
30 /// Project namespace, containing all related functions and classes.
31 /// This is the only namespace applications should be concerned with,
35 // forward declarations
42 /// The main interface class. This class coordinates the communication to
43 /// a single handheld.
45 /// To use this class, use the following steps:
47 /// - Probe the USB bus for matching devices with the Probe class
48 /// - Pass one of the probe results into the Controller constructor
50 /// - Call OpenMode() to select the desired mode. This will fill all
51 /// internal data structures for that mode, such as the
52 /// Database Database in Desktop mode.
53 /// NOTE: only Desktop mode is currently implemented.
54 /// - Call GetDBDB() to get the device's database database
55 /// - Call GetDBID() to get a database ID by name
56 /// - In Desktop mode, call LoadDatabase() to retrieve and store a database
61 /// Handheld mode type
63 Unspecified
, //< default on start up
64 Bypass
, //< unsupported, unknown
65 Desktop
, //< desktop mode required for database
67 JavaLoader
//< unsupported
69 enum CommandType
{ Unknown
, DatabaseAccess
};
73 Usb::Interface
*m_iface
;
78 CommandTable m_commandTable
;
79 DatabaseDatabase m_dbdb
;
84 void SelectMode(ModeType mode
, uint16_t &socket
, uint8_t &flag
);
85 unsigned int GetCommand(CommandType ct
);
87 void LoadCommandTable();
91 Controller(const ProbeResult
&device
);
94 //////////////////////////////////
97 /// Returns DatabaseDatabase object for this connection.
98 /// Must call OpenMode() to select Desktop mode first
99 const DatabaseDatabase
& GetDBDB() const { return m_dbdb
; }
100 unsigned int GetDBID(const std::string
&name
) const;
102 //////////////////////////////////
103 // general operations
104 void OpenMode(ModeType mode
);
106 //////////////////////////////////
107 // Desktop mode - database specific
108 void LoadDatabase(unsigned int dbId
, Parser
&parser
);
109 void SaveDatabase(unsigned int dbId
, Builder
&builder
);
111 template <class RecordT
, class StorageT
> void LoadDatabaseByType(StorageT
&store
);
112 template <class RecordT
, class StorageT
> void SaveDatabaseByType(StorageT
&store
);
114 template <class StorageT
> void LoadDatabaseByName(const std::string
&name
, StorageT
&store
);
115 template <class StorageT
> void SaveDatabaseByName(const std::string
&name
, StorageT
&store
);