Diffstat (limited to 'noncore/net/opietooth/lib/manager.cc') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/lib/manager.cc | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/noncore/net/opietooth/lib/manager.cc b/noncore/net/opietooth/lib/manager.cc index c89d325..56156a8 100644 --- a/noncore/net/opietooth/lib/manager.cc +++ b/noncore/net/opietooth/lib/manager.cc | |||
@@ -1,22 +1,24 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include <opie/oprocess.h> | 3 | #include <opie2/oprocess.h> |
4 | 4 | ||
5 | #include "parser.h" | 5 | #include "parser.h" |
6 | #include "manager.h" | 6 | #include "manager.h" |
7 | 7 | ||
8 | 8 | ||
9 | using namespace OpieTooth; | 9 | using namespace OpieTooth; |
10 | 10 | ||
11 | using namespace Opie::Core; | ||
12 | using namespace Opie::Core; | ||
11 | Manager::Manager( const QString& dev ) | 13 | Manager::Manager( const QString& dev ) |
12 | : QObject() | 14 | : QObject() |
13 | { | 15 | { |
14 | qWarning("created"); | 16 | qWarning("created"); |
15 | m_device = dev; | 17 | m_device = dev; |
16 | m_hcitool = 0; | 18 | m_hcitool = 0; |
17 | m_sdp = 0; | 19 | m_sdp = 0; |
18 | } | 20 | } |
19 | Manager::Manager( Device* /*dev*/ ) | 21 | Manager::Manager( Device* /*dev*/ ) |
20 | : QObject() | 22 | : QObject() |
21 | { | 23 | { |
22 | m_hcitool = 0; | 24 | m_hcitool = 0; |
@@ -33,45 +35,45 @@ Manager::~Manager(){ | |||
33 | delete m_sdp; | 35 | delete m_sdp; |
34 | } | 36 | } |
35 | void Manager::setDevice( const QString& dev ){ | 37 | void Manager::setDevice( const QString& dev ){ |
36 | m_device = dev; | 38 | m_device = dev; |
37 | } | 39 | } |
38 | void Manager::setDevice( Device* /*dev*/ ){ | 40 | void Manager::setDevice( Device* /*dev*/ ){ |
39 | 41 | ||
40 | } | 42 | } |
41 | void Manager::isAvailable( const QString& device ){ | 43 | void Manager::isAvailable( const QString& device ){ |
42 | OProcess* l2ping = new OProcess(); | 44 | OProcess* l2ping = new OProcess(); |
43 | l2ping->setName( device.latin1() ); | 45 | l2ping->setName( device.latin1() ); |
44 | *l2ping << "l2ping" << "-c1" << device; | 46 | *l2ping << "l2ping" << "-c1" << device; |
45 | connect(l2ping, SIGNAL(processExited(OProcess* ) ), | 47 | connect(l2ping, SIGNAL(processExited(Opie::Core::OProcess* ) ), |
46 | this, SLOT(slotProcessExited(OProcess*) ) ); | 48 | this, SLOT(slotProcessExited(OProcess*) ) ); |
47 | if (!l2ping->start() ) { | 49 | if (!l2ping->start() ) { |
48 | emit available( device, false ); | 50 | emit available( device, false ); |
49 | delete l2ping; | 51 | delete l2ping; |
50 | } | 52 | } |
51 | 53 | ||
52 | } | 54 | } |
53 | 55 | ||
54 | void Manager::isAvailable( Device* /*dev*/ ){ | 56 | void Manager::isAvailable( Device* /*dev*/ ){ |
55 | 57 | ||
56 | 58 | ||
57 | } | 59 | } |
58 | void Manager::searchDevices( const QString& device ){ | 60 | void Manager::searchDevices( const QString& device ){ |
59 | qWarning("search devices"); | 61 | qWarning("search devices"); |
60 | OProcess* hcitool = new OProcess(); | 62 | OProcess* hcitool = new OProcess(); |
61 | hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() ); | 63 | hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() ); |
62 | *hcitool << "hcitool" << "scan"; | 64 | *hcitool << "hcitool" << "scan"; |
63 | connect( hcitool, SIGNAL(processExited(OProcess*) ) , | 65 | connect( hcitool, SIGNAL(processExited(Opie::Core::OProcess*) ) , |
64 | this, SLOT(slotHCIExited(OProcess* ) ) ); | 66 | this, SLOT(slotHCIExited(OProcess* ) ) ); |
65 | connect( hcitool, SIGNAL(receivedStdout(OProcess*, char*, int ) ), | 67 | connect( hcitool, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ), |
66 | this, SLOT(slotHCIOut(OProcess*, char*, int ) ) ); | 68 | this, SLOT(slotHCIOut(OProcess*, char*, int ) ) ); |
67 | if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { | 69 | if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { |
68 | qWarning("could not start"); | 70 | qWarning("could not start"); |
69 | RemoteDevice::ValueList list; | 71 | RemoteDevice::ValueList list; |
70 | emit foundDevices( device, list ); | 72 | emit foundDevices( device, list ); |
71 | delete hcitool; | 73 | delete hcitool; |
72 | } | 74 | } |
73 | } | 75 | } |
74 | 76 | ||
75 | void Manager::searchDevices(Device* /*d*/ ){ | 77 | void Manager::searchDevices(Device* /*d*/ ){ |
76 | 78 | ||
77 | 79 | ||
@@ -98,27 +100,27 @@ void Manager::removeService( const QString& name ){ | |||
98 | emit removedService( name, bo ); | 100 | emit removedService( name, bo ); |
99 | } | 101 | } |
100 | void Manager::removeServices( const QStringList& list){ | 102 | void Manager::removeServices( const QStringList& list){ |
101 | QStringList::ConstIterator it; | 103 | QStringList::ConstIterator it; |
102 | for (it = list.begin(); it != list.end(); ++it ) | 104 | for (it = list.begin(); it != list.end(); ++it ) |
103 | removeService( (*it) ); | 105 | removeService( (*it) ); |
104 | } | 106 | } |
105 | void Manager::searchServices( const QString& remDevice ){ | 107 | void Manager::searchServices( const QString& remDevice ){ |
106 | OProcess *m_sdp =new OProcess(); | 108 | OProcess *m_sdp =new OProcess(); |
107 | *m_sdp << "sdptool" << "browse" << remDevice; | 109 | *m_sdp << "sdptool" << "browse" << remDevice; |
108 | m_sdp->setName( remDevice.latin1() ); | 110 | m_sdp->setName( remDevice.latin1() ); |
109 | qWarning("search Services for %s", remDevice.latin1() ); | 111 | qWarning("search Services for %s", remDevice.latin1() ); |
110 | connect(m_sdp, SIGNAL(processExited(OProcess*) ), | 112 | connect(m_sdp, SIGNAL(processExited(Opie::Core::OProcess*) ), |
111 | this, SLOT(slotSDPExited(OProcess* ) ) ); | 113 | this, SLOT(slotSDPExited(OProcess* ) ) ); |
112 | connect(m_sdp, SIGNAL(receivedStdout(OProcess*, char*, int ) ), | 114 | connect(m_sdp, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ), |
113 | this, SLOT(slotSDPOut(OProcess*, char*, int) ) ); | 115 | this, SLOT(slotSDPOut(OProcess*, char*, int) ) ); |
114 | if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { | 116 | if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { |
115 | qWarning("could not start sdptool" ); | 117 | qWarning("could not start sdptool" ); |
116 | delete m_sdp; | 118 | delete m_sdp; |
117 | Services::ValueList list; | 119 | Services::ValueList list; |
118 | emit foundServices( remDevice, list ); | 120 | emit foundServices( remDevice, list ); |
119 | } | 121 | } |
120 | } | 122 | } |
121 | void Manager::searchServices( const RemoteDevice& dev){ | 123 | void Manager::searchServices( const RemoteDevice& dev){ |
122 | searchServices( dev.mac() ); | 124 | searchServices( dev.mac() ); |
123 | } | 125 | } |
124 | QString Manager::toDevice( const QString& /*mac*/ ){ | 126 | QString Manager::toDevice( const QString& /*mac*/ ){ |
@@ -237,27 +239,27 @@ void Manager::connectTo( const QString& mac) { | |||
237 | proc << "hcitool"; | 239 | proc << "hcitool"; |
238 | proc << "cc"; | 240 | proc << "cc"; |
239 | proc << mac; | 241 | proc << mac; |
240 | proc.start(OProcess::DontCare); // the lib does not care at this point | 242 | proc.start(OProcess::DontCare); // the lib does not care at this point |
241 | } | 243 | } |
242 | 244 | ||
243 | 245 | ||
244 | void Manager::searchConnections() { | 246 | void Manager::searchConnections() { |
245 | qWarning("searching connections?"); | 247 | qWarning("searching connections?"); |
246 | OProcess* proc = new OProcess(); | 248 | OProcess* proc = new OProcess(); |
247 | m_hcitoolCon = QString::null; | 249 | m_hcitoolCon = QString::null; |
248 | 250 | ||
249 | connect(proc, SIGNAL(processExited(OProcess*) ), | 251 | connect(proc, SIGNAL(processExited(Opie::Core::OProcess*) ), |
250 | this, SLOT(slotConnectionExited( OProcess*) ) ); | 252 | this, SLOT(slotConnectionExited( OProcess*) ) ); |
251 | connect(proc, SIGNAL(receivedStdout(OProcess*, char*, int) ), | 253 | connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int) ), |
252 | this, SLOT(slotConnectionOutput(OProcess*, char*, int) ) ); | 254 | this, SLOT(slotConnectionOutput(OProcess*, char*, int) ) ); |
253 | *proc << "hcitool"; | 255 | *proc << "hcitool"; |
254 | *proc << "con"; | 256 | *proc << "con"; |
255 | 257 | ||
256 | if (!proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { | 258 | if (!proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { |
257 | ConnectionState::ValueList list; | 259 | ConnectionState::ValueList list; |
258 | emit connections( list ); | 260 | emit connections( list ); |
259 | delete proc; | 261 | delete proc; |
260 | } | 262 | } |
261 | } | 263 | } |
262 | void Manager::slotConnectionExited( OProcess* proc ) { | 264 | void Manager::slotConnectionExited( OProcess* proc ) { |
263 | ConnectionState::ValueList list; | 265 | ConnectionState::ValueList list; |
@@ -296,27 +298,27 @@ ConnectionState::ValueList Manager::parseConnections( const QString& out ) { | |||
296 | con.setHandle( value[4].toInt() ); | 298 | con.setHandle( value[4].toInt() ); |
297 | con.setState( value[6].toInt() ); | 299 | con.setState( value[6].toInt() ); |
298 | con.setLinkMode( value[8] == QString::fromLatin1("MASTER") ? Master : Client ); | 300 | con.setLinkMode( value[8] == QString::fromLatin1("MASTER") ? Master : Client ); |
299 | list2.append( con ); | 301 | list2.append( con ); |
300 | } | 302 | } |
301 | return list2; | 303 | return list2; |
302 | } | 304 | } |
303 | 305 | ||
304 | void Manager::signalStrength( const QString &mac ) { | 306 | void Manager::signalStrength( const QString &mac ) { |
305 | 307 | ||
306 | OProcess* sig_proc = new OProcess(); | 308 | OProcess* sig_proc = new OProcess(); |
307 | 309 | ||
308 | connect(sig_proc, SIGNAL(processExited(OProcess*) ), | 310 | connect(sig_proc, SIGNAL(processExited(Opie::Core::OProcess*) ), |
309 | this, SLOT(slotSignalStrengthExited( OProcess*) ) ); | 311 | this, SLOT(slotSignalStrengthExited( OProcess*) ) ); |
310 | connect(sig_proc, SIGNAL(receivedStdout(OProcess*, char*, int) ), | 312 | connect(sig_proc, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int) ), |
311 | this, SLOT(slotSignalStrengthOutput(OProcess*, char*, int) ) ); | 313 | this, SLOT(slotSignalStrengthOutput(OProcess*, char*, int) ) ); |
312 | *sig_proc << "hcitool"; | 314 | *sig_proc << "hcitool"; |
313 | *sig_proc << "lq"; | 315 | *sig_proc << "lq"; |
314 | *sig_proc << mac; | 316 | *sig_proc << mac; |
315 | 317 | ||
316 | sig_proc->setName( mac.latin1() ); | 318 | sig_proc->setName( mac.latin1() ); |
317 | 319 | ||
318 | if (!sig_proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { | 320 | if (!sig_proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { |
319 | emit signalStrength( mac, "-1" ); | 321 | emit signalStrength( mac, "-1" ); |
320 | delete sig_proc; | 322 | delete sig_proc; |
321 | } | 323 | } |
322 | } | 324 | } |