Diffstat (limited to 'noncore/net/opietooth/lib/manager.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/lib/manager.h | 231 |
1 files changed, 124 insertions, 107 deletions
diff --git a/noncore/net/opietooth/lib/manager.h b/noncore/net/opietooth/lib/manager.h index 415ec72..2589e9b 100644 --- a/noncore/net/opietooth/lib/manager.h +++ b/noncore/net/opietooth/lib/manager.h | |||
@@ -12,120 +12,137 @@ | |||
12 | 12 | ||
13 | class OProcess; | 13 | class OProcess; |
14 | namespace OpieTooth { | 14 | namespace OpieTooth { |
15 | class Device; | 15 | class Device; |
16 | /** Manager manages a blueZ device (hci0 for example) | 16 | /** Manager manages a blueZ device (hci0 for example) |
17 | * with Manager you can control the things you | 17 | * without Manager you can control the things you |
18 | * could do from command line in a OO and asynchronus | 18 | * could do from command line in a OO and asynchronus |
19 | * way. | 19 | * way. |
20 | */ | ||
21 | class Manager : public QObject { | ||
22 | Q_OBJECT | ||
23 | public: | ||
24 | /** c'tor whichs create a new Manager | ||
25 | * @param device is the device to use. Either a mac or blueZ device name | ||
26 | * | ||
27 | */ | 20 | */ |
28 | Manager( const QString &device ); | 21 | class Manager : public QObject { |
29 | /** c'tor | 22 | Q_OBJECT |
30 | * @param dev The Device to be managed | 23 | public: |
31 | * We don't care of Device so you need to delete it | 24 | /** c'tor whichs create a new Manager |
32 | */ | 25 | * @param device is the device to use. Either a mac or blueZ device name |
33 | Manager( Device* dev ); | 26 | * |
34 | /** | 27 | */ |
35 | * c'tor | 28 | Manager( const QString &device ); |
36 | */ | ||
37 | Manager(); | ||
38 | ~Manager(); | ||
39 | 29 | ||
40 | /** Set the manager to control a new device | 30 | /** c'tor |
41 | * @param device the new device to control (hci0 ) | 31 | * @param dev The Device to be managed |
42 | */ | 32 | * We don't care of Device so you need to delete it |
43 | void setDevice( const QString& device ); | 33 | */ |
44 | /** | 34 | Manager( Device* dev ); |
45 | * Convience functions for setting a new device | ||
46 | */ | ||
47 | void setDevice( Device *dev ); | ||
48 | /** | ||
49 | * Wether or not a device is connected. The function | ||
50 | * is asynchron | ||
51 | * If device is empty it will take the currently managed | ||
52 | * device and see if it's up | ||
53 | * for Remote devices it will ping and see. | ||
54 | * @param either mac or hciX | ||
55 | */ | ||
56 | void isAvailable(const QString& device= QString::null ); | ||
57 | /** | ||
58 | * same as above | ||
59 | */ | ||
60 | void isAvailable(Device *dev ); | ||
61 | 35 | ||
62 | /** this searchs for devices reachable from the | 36 | /** |
63 | * currently managed device | 37 | * c'tor |
64 | * or from device if @param device is not empty | 38 | */ |
65 | */ | 39 | Manager(); |
66 | void searchDevices(const QString& device= QString::null ); | ||
67 | /** same as above | ||
68 | * | ||
69 | */ | ||
70 | void searchDevices(Device *d ); | ||
71 | 40 | ||
72 | /** | 41 | ~Manager(); |
73 | * This will add the service @param name | ||
74 | * to the sdpd daemon | ||
75 | * It will start the daemon if necessary | ||
76 | */ | ||
77 | void addService(const QString &name ); | ||
78 | /** | ||
79 | * This will add the services @param names | ||
80 | * to the sdpd daemon | ||
81 | * It will start the daemon if necessary | ||
82 | */ | ||
83 | void addServices( const QStringList& names ); | ||
84 | /** | ||
85 | * This removes a service from the sdps | ||
86 | */ | ||
87 | void removeService(const QString &name ); | ||
88 | /** | ||
89 | * Removes a list from the sdpd | ||
90 | */ | ||
91 | void removeServices(const QStringList& ); | ||
92 | 42 | ||
93 | /** | 43 | /** Set the manager to control a new device |
94 | * search for services on a remote device | 44 | * @param device the new device to control (hci0 ) |
95 | * | 45 | */ |
96 | */ | 46 | void setDevice( const QString& device ); |
97 | void searchServices( const QString& remDevice ); | 47 | |
98 | /** | 48 | /** |
99 | * search for services on a remote device | 49 | * Convience functions for setting a new device |
100 | */ | 50 | */ |
101 | void searchServices( const RemoteDevice& ); | 51 | void setDevice( Device *dev ); |
102 | /*static*/ QString toDevice( const QString& mac ); | 52 | |
103 | /*static*/ QString toMac( const QString &device ); | 53 | /** |
104 | 54 | * Wether or not a device is connected. The function | |
105 | signals: | 55 | * is asynchron |
106 | // device either mac or dev name | 56 | * If device is empty it will take the currently managed |
107 | // the first device is the device which you access | 57 | * device and see if it's up |
108 | void available( const QString& device, bool connected ); | 58 | * for Remote devices it will ping and see. |
109 | void addedService( const QString& service, bool added ); | 59 | * @param either mac or hciX |
110 | void removedService( const QString& service, bool removed ); | 60 | */ |
111 | void foundServices( const QString& device, Services::ValueList ); | 61 | void isAvailable(const QString& device= QString::null ); |
112 | void foundDevices( const QString& device, RemoteDevice::ValueList ); | 62 | |
63 | /** | ||
64 | * same as above | ||
65 | */ | ||
66 | void isAvailable(Device *dev ); | ||
67 | |||
68 | /** this searchs for devices reachable from the | ||
69 | * currently managed device | ||
70 | * or from device if @param device is not empty | ||
71 | */ | ||
72 | void searchDevices(const QString& device= QString::null ); | ||
73 | /** same as above | ||
74 | * | ||
75 | */ | ||
76 | void searchDevices(Device *d ); | ||
77 | |||
78 | /** | ||
79 | * This will add the service @param name | ||
80 | * to the sdpd daemon | ||
81 | * It will start the daemon if necessary | ||
82 | */ | ||
83 | void addService(const QString &name ); | ||
84 | |||
85 | /** | ||
86 | * This will add the services @param names | ||
87 | * to the sdpd daemon | ||
88 | * It will start the daemon if necessary | ||
89 | */ | ||
90 | void addServices( const QStringList& names ); | ||
91 | |||
92 | /** | ||
93 | * This removes a service from the sdps | ||
94 | */ | ||
95 | void removeService(const QString &name ); | ||
96 | |||
97 | /** | ||
98 | * Removes a list from the sdpd | ||
99 | */ | ||
100 | void removeServices(const QStringList& ); | ||
101 | |||
102 | /** | ||
103 | * search for services on a remote device | ||
104 | * | ||
105 | */ | ||
106 | void searchServices( const QString& remDevice ); | ||
107 | |||
108 | /** | ||
109 | * search for services on a remote device | ||
110 | */ | ||
111 | void searchServices( const RemoteDevice& ); | ||
112 | /*static*/ QString toDevice( const QString& mac ); | ||
113 | /*static*/ QString toMac( const QString &device ); | ||
114 | |||
115 | signals: | ||
116 | // device either mac or dev name | ||
117 | // the first device is the device which you access | ||
118 | void available( const QString& device, bool connected ); | ||
119 | void addedService( const QString& service, bool added ); | ||
120 | void removedService( const QString& service, bool removed ); | ||
121 | void foundServices( const QString& device, Services::ValueList ); | ||
122 | void foundDevices( const QString& device, RemoteDevice::ValueList ); | ||
123 | void connections( Connection::ValueList ); | ||
113 | 124 | ||
114 | private slots: | 125 | private slots: |
115 | void slotProcessExited(OProcess* ); | 126 | void slotProcessExited(OProcess* ); |
116 | void slotSDPExited(OProcess*); | 127 | |
117 | void slotSDPOut(OProcess*, char*, int); | 128 | void slotSDPExited(OProcess*); |
118 | void slotHCIExited(OProcess* ); | 129 | void slotSDPOut(OProcess*, char*, int); |
119 | void slotHCIOut(OProcess*, char*, int ); | 130 | |
120 | private: | 131 | void slotHCIExited(OProcess* ); |
121 | Services::ValueList parseSDPOutput( const QString& ); | 132 | void slotHCIOut(OProcess*, char*, int ); |
122 | RemoteDevice::ValueList parseHCIOutput( const QString& ); | 133 | |
123 | OProcess *m_hcitool; | 134 | void slotConnectionExited(OProcess* ); |
124 | OProcess *m_sdp; // not only one | 135 | void slotConnectionOutput(OProcess*, char*, int ); |
125 | QString m_device; | 136 | private: |
126 | QMap<QString, QString> m_out; | 137 | Services::ValueList parseSDPOutput( const QString& ); |
127 | QMap<QString, QString> m_devices; | 138 | RemoteDevice::ValueList parseHCIOutput( const QString& ); |
128 | }; | 139 | OProcess *m_hcitool; |
140 | OProcess *m_sdp; // not only one | ||
141 | QString m_device; | ||
142 | QMap<QString, QString> m_out; | ||
143 | QMap<QString, QString> m_devices; | ||
144 | QString m_hcitoolCon; | ||
145 | }; | ||
129 | }; | 146 | }; |
130 | 147 | ||
131 | #endif | 148 | #endif |