A fix to be compliant with the commit 'm_mode_base'
[barry.git] / src / controller.h
blob4cb9fe6e81702718e7d2d25aafe3516639e6c97d
1 ///
2 /// \file controller.h
3 /// High level BlackBerry API class
4 ///
6 /*
7 Copyright (C) 2005-2009, 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__
25 #include "dll.h"
26 #include "usbwrap.h"
27 #include "socket.h"
28 #include "probe.h"
30 /// Project namespace, containing all related functions and classes.
31 /// This is the only namespace applications should be concerned with,
32 /// for now.
33 namespace Barry {
35 // forward declarations
36 class SocketRoutingQueue;
38 namespace Mode {
39 class Mode;
40 class IpModem;
41 class Serial;
42 class JavaLoader;
43 class JVMDebug;
47 // Controller class
49 /// The main interface class. This class coordinates the communication to
50 /// a single handheld. This class also owns the only Usb::Device object
51 /// the handheld. All other classes reference this one for the low level
52 /// device object. This class owns the only SocketZero object as well,
53 /// which is the object that any SocketRoutingQueue is plugged into
54 /// if constructed that way.
55 ///
56 /// To use this class, use the following steps:
57 ///
58 /// - Probe the USB bus for matching devices with the Probe class
59 /// - Create an optional SocketRoutingQueue object and create a
60 /// read thread for it, or use its default read thread.
61 /// - Pass one of the probe results into the Controller constructor
62 /// to connect to the USB device. Pass the routing queue
63 /// to the Controller constructor here too, if needed.
64 /// - Create the Mode object of your choice. See m_desktop.h
65 /// and m_serial.h for these mode classes. You pass
66 /// your controller object into these mode constructors
67 /// to create the mode.
68 ///
69 class BXEXPORT Controller
71 friend class Barry::Mode::Mode;
72 friend class Barry::Mode::IpModem;
73 friend class Barry::Mode::Serial;
74 friend class Barry::Mode::JavaLoader;
75 friend class Barry::Mode::JVMDebug;
77 public:
78 /// Handheld mode type
79 enum ModeType {
80 Unspecified, //< default on start up (unused)
81 Bypass, //< unsupported, unknown
82 Desktop, //< desktop mode required for database
83 //< operation
84 JavaLoader, //< experimental
85 JVMDebug, //< experimental
86 UsbSerData, //< GPRS modem support over USB
87 UsbSerCtrl //< internally used behind the scenes
90 private:
91 ProbeResult m_result;
92 Usb::Device m_dev;
93 Usb::Interface *m_iface;
94 uint32_t m_pin;
96 SocketZero m_zero;
97 SocketRoutingQueue *m_queue; //< ptr to external object; no delete
99 private:
100 void SetupUsb(const ProbeResult &device);
102 protected:
103 uint16_t SelectMode(ModeType mode); // returns mode socket
105 public:
106 explicit Controller(const ProbeResult &device);
107 Controller(const ProbeResult &device, SocketRoutingQueue &queue);
108 ~Controller();
110 bool HasQueue() const { return m_queue; }
112 const ProbeResult& GetProbeResult() const { return m_result; }
115 } // namespace Barry
117 #endif