summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/manager.cc7
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp2
-rw-r--r--noncore/net/opietooth/manager/btconnectionitem.cpp1
3 files changed, 6 insertions, 4 deletions
diff --git a/noncore/net/opietooth/lib/manager.cc b/noncore/net/opietooth/lib/manager.cc
index 1281116..59ade6d 100644
--- a/noncore/net/opietooth/lib/manager.cc
+++ b/noncore/net/opietooth/lib/manager.cc
@@ -1,299 +1,300 @@
1 1
2 2
3#include <opie/oprocess.h> 3#include <opie/oprocess.h>
4 4
5#include "parser.h" 5#include "parser.h"
6#include "manager.h" 6#include "manager.h"
7 7
8 8
9using namespace OpieTooth; 9using namespace OpieTooth;
10 10
11Manager::Manager( const QString& dev ) 11Manager::Manager( const QString& dev )
12 : QObject() 12 : QObject()
13{ 13{
14 qWarning("created"); 14 qWarning("created");
15 m_device = dev; 15 m_device = dev;
16 m_hcitool = 0; 16 m_hcitool = 0;
17 m_sdp = 0; 17 m_sdp = 0;
18} 18}
19Manager::Manager( Device* /*dev*/ ) 19Manager::Manager( Device* /*dev*/ )
20 : QObject() 20 : QObject()
21{ 21{
22 m_hcitool = 0; 22 m_hcitool = 0;
23 m_sdp = 0; 23 m_sdp = 0;
24} 24}
25Manager::Manager() 25Manager::Manager()
26 : QObject() 26 : QObject()
27{ 27{
28 m_hcitool = 0; 28 m_hcitool = 0;
29 m_sdp = 0; 29 m_sdp = 0;
30} 30}
31Manager::~Manager(){ 31Manager::~Manager(){
32 delete m_hcitool; 32 delete m_hcitool;
33 delete m_sdp; 33 delete m_sdp;
34} 34}
35void Manager::setDevice( const QString& dev ){ 35void Manager::setDevice( const QString& dev ){
36 m_device = dev; 36 m_device = dev;
37} 37}
38void Manager::setDevice( Device* /*dev*/ ){ 38void Manager::setDevice( Device* /*dev*/ ){
39 39
40} 40}
41void Manager::isAvailable( const QString& device ){ 41void Manager::isAvailable( const QString& device ){
42 OProcess* l2ping = new OProcess(); 42 OProcess* l2ping = new OProcess();
43 l2ping->setName( device.latin1() ); 43 l2ping->setName( device.latin1() );
44 *l2ping << "l2ping" << "-c1" << device; 44 *l2ping << "l2ping" << "-c1" << device;
45 connect(l2ping, SIGNAL(processExited(OProcess* ) ), 45 connect(l2ping, SIGNAL(processExited(OProcess* ) ),
46 this, SLOT(slotProcessExited(OProcess*) ) ); 46 this, SLOT(slotProcessExited(OProcess*) ) );
47 if (!l2ping->start() ) { 47 if (!l2ping->start() ) {
48 emit available( device, false ); 48 emit available( device, false );
49 delete l2ping; 49 delete l2ping;
50 } 50 }
51 51
52} 52}
53 53
54void Manager::isAvailable( Device* /*dev*/ ){ 54void Manager::isAvailable( Device* /*dev*/ ){
55 55
56 56
57} 57}
58void Manager::searchDevices( const QString& device ){ 58void Manager::searchDevices( const QString& device ){
59 qWarning("search devices"); 59 qWarning("search devices");
60 OProcess* hcitool = new OProcess(); 60 OProcess* hcitool = new OProcess();
61 hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() ); 61 hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() );
62 *hcitool << "hcitool" << "scan"; 62 *hcitool << "hcitool" << "scan";
63 connect( hcitool, SIGNAL(processExited(OProcess*) ) , 63 connect( hcitool, SIGNAL(processExited(OProcess*) ) ,
64 this, SLOT(slotHCIExited(OProcess* ) ) ); 64 this, SLOT(slotHCIExited(OProcess* ) ) );
65 connect( hcitool, SIGNAL(receivedStdout(OProcess*, char*, int ) ), 65 connect( hcitool, SIGNAL(receivedStdout(OProcess*, char*, int ) ),
66 this, SLOT(slotHCIOut(OProcess*, char*, int ) ) ); 66 this, SLOT(slotHCIOut(OProcess*, char*, int ) ) );
67 if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 67 if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
68 qWarning("could not start"); 68 qWarning("could not start");
69 RemoteDevice::ValueList list; 69 RemoteDevice::ValueList list;
70 emit foundDevices( device, list ); 70 emit foundDevices( device, list );
71 delete hcitool; 71 delete hcitool;
72 } 72 }
73} 73}
74 74
75void Manager::searchDevices(Device* /*d*/ ){ 75void Manager::searchDevices(Device* /*d*/ ){
76 76
77 77
78} 78}
79void Manager::addService(const QString& name ){ 79void Manager::addService(const QString& name ){
80 OProcess proc; 80 OProcess proc;
81 proc << "sdptool" << "add" << name; 81 proc << "sdptool" << "add" << name;
82 bool bo = true; 82 bool bo = true;
83 if (!proc.start(OProcess::DontCare ) ) 83 if (!proc.start(OProcess::DontCare ) )
84 bo = false; 84 bo = false;
85 emit addedService( name, bo ); 85 emit addedService( name, bo );
86} 86}
87void Manager::addServices(const QStringList& list){ 87void Manager::addServices(const QStringList& list){
88 QStringList::ConstIterator it; 88 QStringList::ConstIterator it;
89 for (it = list.begin(); it != list.end(); ++it ) 89 for (it = list.begin(); it != list.end(); ++it )
90 addService( (*it) ); 90 addService( (*it) );
91} 91}
92void Manager::removeService( const QString& name ){ 92void Manager::removeService( const QString& name ){
93 OProcess prc; 93 OProcess prc;
94 prc << "sdptool" << "del" << name; 94 prc << "sdptool" << "del" << name;
95 bool bo = true; 95 bool bo = true;
96 if (!prc.start(OProcess::DontCare ) ) 96 if (!prc.start(OProcess::DontCare ) )
97 bo = false; 97 bo = false;
98 emit removedService( name, bo ); 98 emit removedService( name, bo );
99} 99}
100void Manager::removeServices( const QStringList& list){ 100void Manager::removeServices( const QStringList& list){
101 QStringList::ConstIterator it; 101 QStringList::ConstIterator it;
102 for (it = list.begin(); it != list.end(); ++it ) 102 for (it = list.begin(); it != list.end(); ++it )
103 removeService( (*it) ); 103 removeService( (*it) );
104} 104}
105void Manager::searchServices( const QString& remDevice ){ 105void Manager::searchServices( const QString& remDevice ){
106 OProcess *m_sdp =new OProcess(); 106 OProcess *m_sdp =new OProcess();
107 *m_sdp << "sdptool" << "browse" << remDevice; 107 *m_sdp << "sdptool" << "browse" << remDevice;
108 m_sdp->setName( remDevice.latin1() ); 108 m_sdp->setName( remDevice.latin1() );
109 qWarning("search Services for %s", remDevice.latin1() ); 109 qWarning("search Services for %s", remDevice.latin1() );
110 connect(m_sdp, SIGNAL(processExited(OProcess*) ), 110 connect(m_sdp, SIGNAL(processExited(OProcess*) ),
111 this, SLOT(slotSDPExited(OProcess* ) ) ); 111 this, SLOT(slotSDPExited(OProcess* ) ) );
112 connect(m_sdp, SIGNAL(receivedStdout(OProcess*, char*, int ) ), 112 connect(m_sdp, SIGNAL(receivedStdout(OProcess*, char*, int ) ),
113 this, SLOT(slotSDPOut(OProcess*, char*, int) ) ); 113 this, SLOT(slotSDPOut(OProcess*, char*, int) ) );
114 if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 114 if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
115 qWarning("could not start sdptool" ); 115 qWarning("could not start sdptool" );
116 delete m_sdp; 116 delete m_sdp;
117 Services::ValueList list; 117 Services::ValueList list;
118 emit foundServices( remDevice, list ); 118 emit foundServices( remDevice, list );
119 } 119 }
120} 120}
121void Manager::searchServices( const RemoteDevice& dev){ 121void Manager::searchServices( const RemoteDevice& dev){
122 searchServices( dev.mac() ); 122 searchServices( dev.mac() );
123} 123}
124QString Manager::toDevice( const QString& /*mac*/ ){ 124QString Manager::toDevice( const QString& /*mac*/ ){
125 return QString::null; 125 return QString::null;
126} 126}
127QString Manager::toMac( const QString &/*device*/ ){ 127QString Manager::toMac( const QString &/*device*/ ){
128 return QString::null; 128 return QString::null;
129} 129}
130void Manager::slotProcessExited(OProcess* proc ) { 130void Manager::slotProcessExited(OProcess* proc ) {
131 bool conn= false; 131 bool conn= false;
132 if (proc->normalExit() && proc->exitStatus() == 0 ) 132 if (proc->normalExit() && proc->exitStatus() == 0 )
133 conn = true; 133 conn = true;
134 134
135 QString name = QString::fromLatin1(proc->name() ); 135 QString name = QString::fromLatin1(proc->name() );
136 emit available( name, conn ); 136 emit available( name, conn );
137 delete proc; 137 delete proc;
138} 138}
139void Manager::slotSDPOut(OProcess* proc, char* ch, int len) 139void Manager::slotSDPOut(OProcess* proc, char* ch, int len)
140{ 140{
141 QCString str(ch, len+1 ); 141 QCString str(ch, len+1 );
142 qWarning("SDP:%s", str.data() ); 142 qWarning("SDP:%s", str.data() );
143 QMap<QString, QString>::Iterator it; 143 QMap<QString, QString>::Iterator it;
144 it = m_out.find(proc->name() ); 144 it = m_out.find(proc->name() );
145 QString string; 145 QString string;
146 if ( it != m_out.end() ) { 146 if ( it != m_out.end() ) {
147 string = it.data(); 147 string = it.data();
148 } 148 }
149 string.append( str ); 149 string.append( str );
150 m_out.replace( proc->name(), string ); 150 m_out.replace( proc->name(), string );
151 151
152} 152}
153void Manager::slotSDPExited( OProcess* proc) 153void Manager::slotSDPExited( OProcess* proc)
154{ 154{
155 qWarning("proc name %s", proc->name() ); 155 qWarning("proc name %s", proc->name() );
156 Services::ValueList list; 156 Services::ValueList list;
157 if (proc->normalExit() ) { 157 if (proc->normalExit() ) {
158 QMap<QString, QString>::Iterator it = m_out.find( proc->name() ); 158 QMap<QString, QString>::Iterator it = m_out.find( proc->name() );
159 if ( it != m_out.end() ) { 159 if ( it != m_out.end() ) {
160 qWarning("found process" ); 160 qWarning("found process" );
161 list = parseSDPOutput( it.data() ); 161 list = parseSDPOutput( it.data() );
162 m_out.remove( it ); 162 m_out.remove( it );
163 } 163 }
164 } 164 }
165 emit foundServices( proc->name(), list ); 165 emit foundServices( proc->name(), list );
166 delete proc; 166 delete proc;
167} 167}
168Services::ValueList Manager::parseSDPOutput( const QString& out ) { 168Services::ValueList Manager::parseSDPOutput( const QString& out ) {
169 Services::ValueList list; 169 Services::ValueList list;
170 qWarning("parsing output" ); 170 qWarning("parsing output" );
171 Parser parser( out ); 171 Parser parser( out );
172 list = parser.services(); 172 list = parser.services();
173 return list; 173 return list;
174} 174}
175 175
176void Manager::slotHCIExited(OProcess* proc ) { 176void Manager::slotHCIExited(OProcess* proc ) {
177 qWarning("process exited"); 177 qWarning("process exited");
178 RemoteDevice::ValueList list; 178 RemoteDevice::ValueList list;
179 if (proc->normalExit() ) { 179 if (proc->normalExit() ) {
180 qWarning("normalExit %s", proc->name() ); 180 qWarning("normalExit %s", proc->name() );
181 QMap<QString, QString>::Iterator it = m_devices.find(proc->name() ); 181 QMap<QString, QString>::Iterator it = m_devices.find(proc->name() );
182 if (it != m_devices.end() ) { 182 if (it != m_devices.end() ) {
183 qWarning("!= end ;)"); 183 qWarning("!= end ;)");
184 list = parseHCIOutput( it.data() ); 184 list = parseHCIOutput( it.data() );
185 m_devices.remove( it ); 185 m_devices.remove( it );
186 } 186 }
187 } 187 }
188 emit foundDevices( proc->name(), list ); 188 emit foundDevices( proc->name(), list );
189 delete proc; 189 delete proc;
190} 190}
191void Manager::slotHCIOut(OProcess* proc, char* ch, int len) { 191void Manager::slotHCIOut(OProcess* proc, char* ch, int len) {
192 QCString str( ch, len+1 ); 192 QCString str( ch, len+1 );
193 qWarning("hci: %s", str.data() ); 193 qWarning("hci: %s", str.data() );
194 QMap<QString, QString>::Iterator it; 194 QMap<QString, QString>::Iterator it;
195 it = m_devices.find( proc->name() ); 195 it = m_devices.find( proc->name() );
196 qWarning("proc->name %s", proc->name() ); 196 qWarning("proc->name %s", proc->name() );
197 QString string; 197 QString string;
198 if (it != m_devices.end() ) { 198 if (it != m_devices.end() ) {
199 qWarning("slotHCIOut "); 199 qWarning("slotHCIOut ");
200 string = it.data(); 200 string = it.data();
201 } 201 }
202 string.append( str ); 202 string.append( str );
203 203
204 m_devices.replace( proc->name(), string ); 204 m_devices.replace( proc->name(), string );
205} 205}
206RemoteDevice::ValueList Manager::parseHCIOutput(const QString& output ) { 206RemoteDevice::ValueList Manager::parseHCIOutput(const QString& output ) {
207 qWarning("parseHCI %s", output.latin1() ); 207 qWarning("parseHCI %s", output.latin1() );
208 RemoteDevice::ValueList list; 208 RemoteDevice::ValueList list;
209 QStringList strList = QStringList::split('\n', output ); 209 QStringList strList = QStringList::split('\n', output );
210 QStringList::Iterator it; 210 QStringList::Iterator it;
211 QString str; 211 QString str;
212 for ( it = strList.begin(); it != strList.end(); ++it ) { 212 for ( it = strList.begin(); it != strList.end(); ++it ) {
213 str = (*it).stripWhiteSpace(); 213 str = (*it).stripWhiteSpace();
214 qWarning("OpieTooth %s", str.latin1() ); 214 qWarning("OpieTooth %s", str.latin1() );
215 int pos = str.findRev(':' ); 215 int pos = str.findRev(':' );
216 if ( pos > 0 ) { 216 if ( pos > 0 ) {
217 QString mac = str.left(17 ); 217 QString mac = str.left(17 );
218 str.remove( 0, 17 ); 218 str.remove( 0, 17 );
219 qWarning("mac %s", mac.latin1() ); 219 qWarning("mac %s", mac.latin1() );
220 qWarning("rest:%s", str.latin1() ); 220 qWarning("rest:%s", str.latin1() );
221 RemoteDevice rem( mac , str.stripWhiteSpace() ); 221 RemoteDevice rem( mac , str.stripWhiteSpace() );
222 list.append( rem ); 222 list.append( rem );
223 } 223 }
224 } 224 }
225 return list; 225 return list;
226} 226}
227 227
228////// hcitool cc and hcitool con 228////// hcitool cc and hcitool con
229 229
230/** 230/**
231 * Create it on the stack as don't care 231 * Create it on the stack as don't care
232 * so we don't need to care for it 232 * so we don't need to care for it
233 * cause hcitool gets reparented 233 * cause hcitool gets reparented
234 */ 234 */
235void Manager::connectTo( const QString& mac) { 235void Manager::connectTo( const QString& mac) {
236 OProcess proc; 236 OProcess proc;
237 proc << "hcitool"; 237 proc << "hcitool";
238 proc << "cc"; 238 proc << "cc";
239 proc << mac; 239 proc << mac;
240 proc.start(OProcess::DontCare); // the lib does not care at this point 240 proc.start(OProcess::DontCare); // the lib does not care at this point
241} 241}
242 242
243 243
244void Manager::searchConnections() { 244void Manager::searchConnections() {
245 qWarning("searching connections?"); 245 qWarning("searching connections?");
246 OProcess* proc = new OProcess(); 246 OProcess* proc = new OProcess();
247 m_hcitoolCon = QString::null; 247 m_hcitoolCon = QString::null;
248 248
249 connect(proc, SIGNAL(processExited(OProcess*) ), 249 connect(proc, SIGNAL(processExited(OProcess*) ),
250 this, SLOT(slotConnectionExited( OProcess*) ) ); 250 this, SLOT(slotConnectionExited( OProcess*) ) );
251 connect(proc, SIGNAL(receivedStdout(OProcess*, char*, int) ), 251 connect(proc, SIGNAL(receivedStdout(OProcess*, char*, int) ),
252 this, SLOT(slotConnectionOutput(OProcess*, char*, int) ) ); 252 this, SLOT(slotConnectionOutput(OProcess*, char*, int) ) );
253 *proc << "hcitool"; 253 *proc << "hcitool";
254 *proc << "con"; 254 *proc << "con";
255 255
256 if (!proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 256 if (!proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
257 ConnectionState::ValueList list; 257 ConnectionState::ValueList list;
258 emit connections( list ); 258 emit connections( list );
259 delete proc; 259 delete proc;
260 } 260 }
261} 261}
262void Manager::slotConnectionExited( OProcess* /*proc*/ ) { 262void Manager::slotConnectionExited( OProcess* proc ) {
263 qWarning("exited"); 263 qWarning("<<<<<<<<<<<<<<<<<exited");
264 ConnectionState::ValueList list; 264 ConnectionState::ValueList list;
265 list = parseConnections( m_hcitoolCon ); 265 list = parseConnections( m_hcitoolCon );
266 emit connections(list ); 266 emit connections(list );
267 delete proc;
267} 268}
268void Manager::slotConnectionOutput(OProcess* proc, char* cha, int len) { 269void Manager::slotConnectionOutput(OProcess* proc, char* cha, int len) {
269 QCString str(cha, len ); 270 QCString str(cha, len );
270 m_hcitoolCon.append( str ); 271 m_hcitoolCon.append( str );
271 delete proc; 272 //delete proc;
272} 273}
273ConnectionState::ValueList Manager::parseConnections( const QString& out ) { 274ConnectionState::ValueList Manager::parseConnections( const QString& out ) {
274 ConnectionState::ValueList list2; 275 ConnectionState::ValueList list2;
275 QStringList list = QStringList::split('\n', out ); 276 QStringList list = QStringList::split('\n', out );
276 QStringList::Iterator it; 277 QStringList::Iterator it;
277 for (it = list.begin(); it != list.end(); ++it ) { 278 for (it = list.begin(); it != list.end(); ++it ) {
278 QString row = (*it).stripWhiteSpace(); 279 QString row = (*it).stripWhiteSpace();
279 QStringList value = QStringList::split(' ', row ); 280 QStringList value = QStringList::split(' ', row );
280 qWarning("0: %s", value[0].latin1() ); 281 qWarning("0: %s", value[0].latin1() );
281 qWarning("1: %s", value[1].latin1() ); 282 qWarning("1: %s", value[1].latin1() );
282 qWarning("2: %s", value[2].latin1() ); 283 qWarning("2: %s", value[2].latin1() );
283 qWarning("3: %s", value[3].latin1() ); 284 qWarning("3: %s", value[3].latin1() );
284 qWarning("4: %s", value[4].latin1() ); 285 qWarning("4: %s", value[4].latin1() );
285 qWarning("5: %s", value[5].latin1() ); 286 qWarning("5: %s", value[5].latin1() );
286 qWarning("6: %s", value[6].latin1() ); 287 qWarning("6: %s", value[6].latin1() );
287 qWarning("7: %s", value[7].latin1() ); 288 qWarning("7: %s", value[7].latin1() );
288 qWarning("8: %s", value[8].latin1() ); 289 qWarning("8: %s", value[8].latin1() );
289 ConnectionState con; 290 ConnectionState con;
290 con.setDirection( value[0] == QString::fromLatin1("<") ? Outgoing : Incoming ); 291 con.setDirection( value[0] == QString::fromLatin1("<") ? Outgoing : Incoming );
291 con.setConnectionMode( value[1] ); 292 con.setConnectionMode( value[1] );
292 con.setMac( value[2] ); 293 con.setMac( value[2] );
293 con.setHandle( value[4].toInt() ); 294 con.setHandle( value[4].toInt() );
294 con.setState( value[6].toInt() ); 295 con.setState( value[6].toInt() );
295 con.setLinkMode( value[8] == QString::fromLatin1("MASTER") ? Master : Client ); 296 con.setLinkMode( value[8] == QString::fromLatin1("MASTER") ? Master : Client );
296 list2.append( con ); 297 list2.append( con );
297 } 298 }
298 return list2; 299 return list2;
299} 300}
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index d3abb54..5c5f069 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -1,540 +1,540 @@
1/* 1/*
2 * bluebase.cpp * 2 * bluebase.cpp *
3 * --------------------- 3 * ---------------------
4 * 4 *
5 * copyright : (c) 2002 by Maximilian Reiß 5 * copyright : (c) 2002 by Maximilian Reiß
6 * email : max.reiss@gmx.de 6 * email : max.reiss@gmx.de
7 * 7 *
8 */ 8 */
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include "bluebase.h" 18#include "bluebase.h"
19#include "scandialog.h" 19#include "scandialog.h"
20#include "hciconfwrapper.h" 20#include "hciconfwrapper.h"
21#include "devicehandler.h" 21#include "devicehandler.h"
22#include "btconnectionitem.h" 22#include "btconnectionitem.h"
23 23
24#include <remotedevice.h> 24#include <remotedevice.h>
25#include <services.h> 25#include <services.h>
26 26
27#include <stdlib.h> 27#include <stdlib.h>
28 28
29#include <qframe.h> 29#include <qframe.h>
30#include <qlabel.h> 30#include <qlabel.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qlayout.h> 32#include <qlayout.h>
33#include <qvariant.h> 33#include <qvariant.h>
34#include <qimage.h> 34#include <qimage.h>
35#include <qpixmap.h> 35#include <qpixmap.h>
36#include <qtabwidget.h> 36#include <qtabwidget.h>
37#include <qscrollview.h> 37#include <qscrollview.h>
38#include <qvbox.h> 38#include <qvbox.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qlineedit.h> 41#include <qlineedit.h>
42#include <qlistview.h> 42#include <qlistview.h>
43#include <qdir.h> 43#include <qdir.h>
44#include <qpopupmenu.h> 44#include <qpopupmenu.h>
45#include <qtimer.h> 45#include <qtimer.h>
46 46
47#include <qpe/qpeapplication.h> 47#include <qpe/qpeapplication.h>
48#include <qpe/resource.h> 48#include <qpe/resource.h>
49#include <qpe/config.h> 49#include <qpe/config.h>
50 50
51 51
52using namespace OpieTooth; 52using namespace OpieTooth;
53 53
54BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) 54BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
55 : BluetoothBase( parent, name, fl ) { 55 : BluetoothBase( parent, name, fl ) {
56 56
57 m_localDevice = new Manager( "hci0" ); 57 m_localDevice = new Manager( "hci0" );
58 58
59 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); 59 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) );
60 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); 60 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) );
61 // not good since lib is async 61 // not good since lib is async
62 // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), 62 // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ),
63 // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); 63 // this, SLOT( addServicesToDevice( QListViewItem * ) ) );
64 connect( ListView2, SIGNAL( clicked( QListViewItem* )), 64 connect( ListView2, SIGNAL( clicked( QListViewItem* )),
65 this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); 65 this, SLOT( startServiceActionClicked( QListViewItem* ) ) );
66 connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), 66 connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ),
67 this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); 67 this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) );
68 connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), 68 connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ),
69 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); 69 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) );
70 connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), 70 connect( m_localDevice, SIGNAL( available( const QString&, bool ) ),
71 this, SLOT( deviceActive( const QString& , bool ) ) ); 71 this, SLOT( deviceActive( const QString& , bool ) ) );
72 connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ), 72 connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ),
73 this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) ); 73 this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) );
74 74
75 75
76 // let hold be rightButtonClicked() 76 // let hold be rightButtonClicked()
77 QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold); 77 QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold);
78 QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold); 78 QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold);
79 79
80 //Load all icons needed 80 //Load all icons needed
81 m_offPix = Resource::loadPixmap( "opietooth/notconnected" ); 81 m_offPix = Resource::loadPixmap( "opietooth/notconnected" );
82 m_onPix = Resource::loadPixmap( "opietooth/connected" ); 82 m_onPix = Resource::loadPixmap( "opietooth/connected" );
83 m_findPix = Resource::loadPixmap( "opietooth/find" ); 83 m_findPix = Resource::loadPixmap( "opietooth/find" );
84 84
85 QPalette pal = this->palette(); 85 QPalette pal = this->palette();
86 QColor col = pal.color( QPalette::Active, QColorGroup::Background ); 86 QColor col = pal.color( QPalette::Active, QColorGroup::Background );
87 pal.setColor( QPalette::Active, QColorGroup::Button, col ); 87 pal.setColor( QPalette::Active, QColorGroup::Button, col );
88 pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); 88 pal.setColor( QPalette::Inactive, QColorGroup::Button, col );
89 pal.setColor( QPalette::Normal, QColorGroup::Button, col ); 89 pal.setColor( QPalette::Normal, QColorGroup::Button, col );
90 pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); 90 pal.setColor( QPalette::Disabled, QColorGroup::Button, col );
91 this->setPalette( pal ); 91 this->setPalette( pal );
92 92
93 setCaption( tr( "Bluetooth Manager" ) ); 93 setCaption( tr( "Bluetooth Manager" ) );
94 94
95 readConfig(); 95 readConfig();
96 initGui(); 96 initGui();
97 97
98 ListView2->setRootIsDecorated(true); 98 ListView2->setRootIsDecorated(true);
99 99
100 writeToHciConfig(); 100 writeToHciConfig();
101 // search conncetions 101 // search conncetions
102 addConnectedDevices(); 102 addConnectedDevices();
103 m_iconLoader = new BTIconLoader(); 103 m_iconLoader = new BTIconLoader();
104 readSavedDevices(); 104 readSavedDevices();
105} 105}
106 106
107/** 107/**
108 * Reads all options from the config file 108 * Reads all options from the config file
109 */ 109 */
110void BlueBase::readConfig() { 110void BlueBase::readConfig() {
111 111
112 Config cfg( "bluetoothmanager" ); 112 Config cfg( "bluetoothmanager" );
113 cfg.setGroup( "bluezsettings" ); 113 cfg.setGroup( "bluezsettings" );
114 114
115 m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with 115 m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with
116 m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak 116 m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak
117 m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE ); 117 m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE );
118 m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE ); 118 m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE );
119 m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE ); 119 m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE );
120 m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE ); 120 m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE );
121} 121}
122 122
123/** 123/**
124 * Writes all options to the config file 124 * Writes all options to the config file
125 */ 125 */
126void BlueBase::writeConfig() { 126void BlueBase::writeConfig() {
127 127
128 Config cfg( "bluetoothmanager" ); 128 Config cfg( "bluetoothmanager" );
129 cfg.setGroup( "bluezsettings" ); 129 cfg.setGroup( "bluezsettings" );
130 130
131 cfg.writeEntry( "name" , m_deviceName ); 131 cfg.writeEntry( "name" , m_deviceName );
132 cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); 132 cfg.writeEntryCrypt( "passkey" , m_defaultPasskey );
133 cfg.writeEntry( "useEncryption" , m_useEncryption ); 133 cfg.writeEntry( "useEncryption" , m_useEncryption );
134 cfg.writeEntry( "enableAuthentification" , m_enableAuthentification ); 134 cfg.writeEntry( "enableAuthentification" , m_enableAuthentification );
135 cfg.writeEntry( "enablePagescan" , m_enablePagescan ); 135 cfg.writeEntry( "enablePagescan" , m_enablePagescan );
136 cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan ); 136 cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan );
137 137
138 writeToHciConfig(); 138 writeToHciConfig();
139} 139}
140 140
141/** 141/**
142 * Modify the hcid.conf file to our needs 142 * Modify the hcid.conf file to our needs
143 */ 143 */
144void BlueBase::writeToHciConfig() { 144void BlueBase::writeToHciConfig() {
145 qWarning("writeToHciConfig"); 145 qWarning("writeToHciConfig");
146 HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" ); 146 HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" );
147 hciconf.load(); 147 hciconf.load();
148 hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); 148 hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" );
149 hciconf.setName( m_deviceName ); 149 hciconf.setName( m_deviceName );
150 hciconf.setEncrypt( m_useEncryption ); 150 hciconf.setEncrypt( m_useEncryption );
151 hciconf.setAuth( m_enableAuthentification ); 151 hciconf.setAuth( m_enableAuthentification );
152 hciconf.setPscan( m_enablePagescan ); 152 hciconf.setPscan( m_enablePagescan );
153 hciconf.setIscan( m_enableInquiryscan ); 153 hciconf.setIscan( m_enableInquiryscan );
154 hciconf.save(); 154 hciconf.save();
155} 155}
156 156
157 157
158/** 158/**
159 * Read the list of allready known devices 159 * Read the list of allready known devices
160 */ 160 */
161void BlueBase::readSavedDevices() { 161void BlueBase::readSavedDevices() {
162 162
163 QValueList<RemoteDevice> loadedDevices; 163 QValueList<RemoteDevice> loadedDevices;
164 DeviceHandler handler; 164 DeviceHandler handler;
165 loadedDevices = handler.load(); 165 loadedDevices = handler.load();
166 166
167 addSearchedDevices( loadedDevices ); 167 addSearchedDevices( loadedDevices );
168} 168}
169 169
170 170
171/** 171/**
172 * Write the list of allready known devices 172 * Write the list of allready known devices
173 */ 173 */
174void BlueBase::writeSavedDevices() { 174void BlueBase::writeSavedDevices() {
175 QListViewItemIterator it( ListView2 ); 175 QListViewItemIterator it( ListView2 );
176 BTListItem* item; 176 BTListItem* item;
177 BTDeviceItem* device; 177 BTDeviceItem* device;
178 RemoteDevice::ValueList list; 178 RemoteDevice::ValueList list;
179 for ( ; it.current(); ++it ) { 179 for ( ; it.current(); ++it ) {
180 item = (BTListItem*)it.current(); 180 item = (BTListItem*)it.current();
181 if(item->typeId() != BTListItem::Device ) 181 if(item->typeId() != BTListItem::Device )
182 continue; 182 continue;
183 device = (BTDeviceItem*)item; 183 device = (BTDeviceItem*)item;
184 184
185 list.append( device->remoteDevice() ); 185 list.append( device->remoteDevice() );
186 } 186 }
187 /* 187 /*
188 * if not empty save the List through DeviceHandler 188 * if not empty save the List through DeviceHandler
189 */ 189 */
190 if ( list.isEmpty() ) 190 if ( list.isEmpty() )
191 return; 191 return;
192 DeviceHandler handler; 192 DeviceHandler handler;
193 handler.save( list ); 193 handler.save( list );
194} 194}
195 195
196 196
197/** 197/**
198 * Set up the gui 198 * Set up the gui
199 */ 199 */
200void BlueBase::initGui() { 200void BlueBase::initGui() {
201 StatusLabel->setText( status() ); // maybe move it to getStatus() 201 StatusLabel->setText( status() ); // maybe move it to getStatus()
202 cryptCheckBox->setChecked( m_useEncryption ); 202 cryptCheckBox->setChecked( m_useEncryption );
203 authCheckBox->setChecked( m_enableAuthentification ); 203 authCheckBox->setChecked( m_enableAuthentification );
204 pagescanCheckBox->setChecked( m_enablePagescan ); 204 pagescanCheckBox->setChecked( m_enablePagescan );
205 inquiryscanCheckBox->setChecked( m_enableInquiryscan ); 205 inquiryscanCheckBox->setChecked( m_enableInquiryscan );
206 deviceNameLine->setText( m_deviceName ); 206 deviceNameLine->setText( m_deviceName );
207 passkeyLine->setText( m_defaultPasskey ); 207 passkeyLine->setText( m_defaultPasskey );
208 // set info tab 208 // set info tab
209 setInfo(); 209 setInfo();
210} 210}
211 211
212 212
213/** 213/**
214 * Get the status informations and returns it 214 * Get the status informations and returns it
215 * @return QString the status informations gathered 215 * @return QString the status informations gathered
216 */ 216 */
217QString BlueBase::status()const{ 217QString BlueBase::status()const{
218 QString infoString = tr( "<b>Device name : </b> Ipaq" ); 218 QString infoString = tr( "<b>Device name : </b> Ipaq" );
219 infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); 219 infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" );
220 infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); 220 infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" );
221 221
222 return (infoString); 222 return (infoString);
223} 223}
224 224
225 225
226/** 226/**
227 * Read the current values from the gui and invoke writeConfig() 227 * Read the current values from the gui and invoke writeConfig()
228 */ 228 */
229void BlueBase::applyConfigChanges() { 229void BlueBase::applyConfigChanges() {
230 m_deviceName = deviceNameLine->text(); 230 m_deviceName = deviceNameLine->text();
231 m_defaultPasskey = passkeyLine->text(); 231 m_defaultPasskey = passkeyLine->text();
232 m_useEncryption = cryptCheckBox->isChecked(); 232 m_useEncryption = cryptCheckBox->isChecked();
233 m_enableAuthentification = authCheckBox->isChecked(); 233 m_enableAuthentification = authCheckBox->isChecked();
234 m_enablePagescan = pagescanCheckBox->isChecked(); 234 m_enablePagescan = pagescanCheckBox->isChecked();
235 m_enableInquiryscan = inquiryscanCheckBox->isChecked(); 235 m_enableInquiryscan = inquiryscanCheckBox->isChecked();
236 236
237 writeConfig(); 237 writeConfig();
238 238
239 QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); 239 QMessageBox::information( this, tr("Test") , tr("Changes were applied.") );
240} 240}
241 241
242/** 242/**
243 * Add fresh found devices from scan dialog to the listing 243 * Add fresh found devices from scan dialog to the listing
244 * 244 *
245 */ 245 */
246void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { 246void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) {
247 BTDeviceItem * deviceItem; 247 BTDeviceItem * deviceItem;
248 QValueList<RemoteDevice>::ConstIterator it; 248 QValueList<RemoteDevice>::ConstIterator it;
249 249
250 for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { 250 for( it = newDevices.begin(); it != newDevices.end() ; ++it ) {
251 251
252 if (find( (*it) )) // is already inserted 252 if (find( (*it) )) // is already inserted
253 continue; 253 continue;
254 254
255 deviceItem = new BTDeviceItem( ListView2 , (*it) ); 255 deviceItem = new BTDeviceItem( ListView2 , (*it) );
256 deviceItem->setPixmap( 1, m_findPix ); 256 deviceItem->setPixmap( 1, m_findPix );
257 deviceItem->setExpandable ( true ); 257 deviceItem->setExpandable ( true );
258 258
259 // look if device is avail. atm, async 259 // look if device is avail. atm, async
260 deviceActive( (*it) ); 260 deviceActive( (*it) );
261 261
262 // ggf auch hier? 262 // ggf auch hier?
263 addServicesToDevice( deviceItem ); 263 addServicesToDevice( deviceItem );
264 } 264 }
265} 265}
266 266
267 267
268/** 268/**
269 * Action that is toggled on entrys on click 269 * Action that is toggled on entrys on click
270 */ 270 */
271void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { 271void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) {
272} 272}
273 273
274 274
275/** 275/**
276 * Action that are toggled on hold (mostly QPopups i guess) 276 * Action that are toggled on hold (mostly QPopups i guess)
277 */ 277 */
278void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { 278void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) {
279 if (!item ) 279 if (!item )
280 return; 280 return;
281 281
282 QPopupMenu *menu = new QPopupMenu(); 282 QPopupMenu *menu = new QPopupMenu();
283 int ret=0; 283 int ret=0;
284 284
285 if ( ((BTListItem*)item)->type() == "device") { 285 if ( ((BTListItem*)item)->type() == "device") {
286 286
287 QPopupMenu *groups = new QPopupMenu(); 287 QPopupMenu *groups = new QPopupMenu();
288 288
289 menu->insertItem( ((BTDeviceItem*)item)->name(),0 ); 289 menu->insertItem( ((BTDeviceItem*)item)->name(),0 );
290 menu->insertSeparator(1); 290 menu->insertSeparator(1);
291 menu->insertItem( tr("rescan sevices"), 2); 291 menu->insertItem( tr("rescan sevices"), 2);
292 menu->insertItem( tr("to group"), groups , 3); 292 menu->insertItem( tr("to group"), groups , 3);
293 menu->insertItem( tr("delete"), 4); 293 menu->insertItem( tr("delete"), 4);
294 294
295 ret = menu->exec( point , 0); 295 ret = menu->exec( point , 0);
296 296
297 switch(ret) { 297 switch(ret) {
298 case -1: 298 case -1:
299 break; 299 break;
300 case 2: 300 case 2:
301 addServicesToDevice( (BTDeviceItem*)item ); 301 addServicesToDevice( (BTDeviceItem*)item );
302 break; 302 break;
303 303
304 case 4: 304 case 4:
305 // deletes childs too 305 // deletes childs too
306 delete item; 306 delete item;
307 break; 307 break;
308 } 308 }
309 delete groups; 309 delete groups;
310 310
311 } 311 }
312 312
313 /* 313 /*
314 * We got service sensitive PopupMenus in our factory 314 * We got service sensitive PopupMenus in our factory
315 * We will create one through the factory and will insert 315 * We will create one through the factory and will insert
316 * our Separator + ShowInfo into the menu or create a new 316 * our Separator + ShowInfo into the menu or create a new
317 * one if the factory returns 0 317 * one if the factory returns 0
318 * PopupMenu deletion is kind of weird. 318 * PopupMenu deletion is kind of weird.
319 * If escaped( -1 ) or any of our items were chosen we'll 319 * If escaped( -1 ) or any of our items were chosen we'll
320 * delete the PopupMenu otherwise it's the responsibility of 320 * delete the PopupMenu otherwise it's the responsibility of
321 * the PopupMenu to delete itself 321 * the PopupMenu to delete itself
322 * 322 *
323 */ 323 */
324 else if ( ((BTListItem*)item)->type() == "service") { 324 else if ( ((BTListItem*)item)->type() == "service") {
325 BTServiceItem* service = (BTServiceItem*)item; 325 BTServiceItem* service = (BTServiceItem*)item;
326 QMap<int, QString> list = service->services().classIdList(); 326 QMap<int, QString> list = service->services().classIdList();
327 QMap<int, QString>::Iterator it = list.begin(); 327 QMap<int, QString>::Iterator it = list.begin();
328 QPopupMenu *popup =0l; 328 QPopupMenu *popup =0l;
329 if ( it != list.end() ) { 329 if ( it != list.end() ) {
330 qWarning("Searching id %d %s", it.key(), it.data().latin1() ); 330 qWarning("Searching id %d %s", it.key(), it.data().latin1() );
331 popup = m_popHelper.find( it.key() /*1*/, 331 popup = m_popHelper.find( it.key() /*1*/,
332 service->services(), 332 service->services(),
333 (BTDeviceItem*)service->parent() ); 333 (BTDeviceItem*)service->parent() );
334 }else { 334 }else {
335 qWarning("Empty"); 335 qWarning("Empty");
336 } 336 }
337 337
338 if ( popup == 0l ) { 338 if ( popup == 0l ) {
339 qWarning("factory returned 0l"); 339 qWarning("factory returned 0l");
340 popup = new QPopupMenu(); 340 popup = new QPopupMenu();
341 } 341 }
342 int test1 = popup->insertItem( tr("Test1:"), 2); 342 int test1 = popup->insertItem( tr("Test1:"), 2);
343 343
344 ret = popup->exec( point ); 344 ret = popup->exec( point );
345 qWarning("returned from exec() "); 345 qWarning("returned from exec() ");
346 if ( ret == -1 ) { 346 if ( ret == -1 ) {
347 ; 347 ;
348 } else if ( ret == test1 ) { 348 } else if ( ret == test1 ) {
349 ; 349 ;
350 } 350 }
351 delete popup; 351 delete popup;
352 } 352 }
353 delete menu; 353 delete menu;
354} 354}
355 355
356 356
357/** 357/**
358 * Search and display avail. services for a device (on expand from device listing) 358 * Search and display avail. services for a device (on expand from device listing)
359 * @param item the service item returned 359 * @param item the service item returned
360 */ 360 */
361void BlueBase::addServicesToDevice( BTDeviceItem * item ) { 361void BlueBase::addServicesToDevice( BTDeviceItem * item ) {
362 qDebug("addServicesToDevice"); 362 qDebug("addServicesToDevice");
363 // row of mac adress text(3) 363 // row of mac adress text(3)
364 RemoteDevice device = item->remoteDevice(); 364 RemoteDevice device = item->remoteDevice();
365 m_deviceList.insert( item->mac() , item ); 365 m_deviceList.insert( item->mac() , item );
366 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back 366 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back
367 m_localDevice->searchServices( device ); 367 m_localDevice->searchServices( device );
368} 368}
369 369
370 370
371/** 371/**
372 * Overloaded. This one it the one that is connected to the foundServices signal 372 * Overloaded. This one it the one that is connected to the foundServices signal
373 * @param device the mac address of the remote device 373 * @param device the mac address of the remote device
374 * @param servicesList the list with the service the device has. 374 * @param servicesList the list with the service the device has.
375 */ 375 */
376void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { 376void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) {
377 qDebug("fill services list"); 377 qDebug("fill services list");
378 378
379 QMap<QString,BTDeviceItem*>::Iterator it; 379 QMap<QString,BTDeviceItem*>::Iterator it;
380 BTDeviceItem* deviceItem = 0; 380 BTDeviceItem* deviceItem = 0;
381 381
382 // get the right devices which requested the search 382 // get the right devices which requested the search
383 it = m_deviceList.find( device ); 383 it = m_deviceList.find( device );
384 if( it == m_deviceList.end() ) 384 if( it == m_deviceList.end() )
385 return; 385 return;
386 deviceItem = it.data(); 386 deviceItem = it.data();
387 387
388 QValueList<OpieTooth::Services>::Iterator it2; 388 QValueList<OpieTooth::Services>::Iterator it2;
389 BTServiceItem * serviceItem; 389 BTServiceItem * serviceItem;
390 390
391 if (!servicesList.isEmpty() ) { 391 if (!servicesList.isEmpty() ) {
392 // add services 392 // add services
393 QMap<int, QString> list; 393 QMap<int, QString> list;
394 QMap<int, QString>::Iterator classIt; 394 QMap<int, QString>::Iterator classIt;
395 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { 395 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) {
396 serviceItem = new BTServiceItem( deviceItem , (*it2) ); 396 serviceItem = new BTServiceItem( deviceItem , (*it2) );
397 list = (*it2).classIdList(); 397 list = (*it2).classIdList();
398 classIt = list.begin(); 398 classIt = list.begin();
399 int classId=0; 399 int classId=0;
400 if ( classIt != list.end() ) { 400 if ( classIt != list.end() ) {
401 classId = classIt.key(); 401 classId = classIt.key();
402 } 402 }
403 403
404 serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); 404 serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) );
405 } 405 }
406 } else { 406 } else {
407 Services s1; 407 Services s1;
408 s1.setServiceName( tr("no serives found") ); 408 s1.setServiceName( tr("no serives found") );
409 serviceItem = new BTServiceItem( deviceItem, s1 ); 409 serviceItem = new BTServiceItem( deviceItem, s1 );
410 } 410 }
411 // now remove them from the list 411 // now remove them from the list
412 m_deviceList.remove( it ); 412 m_deviceList.remove( it );
413} 413}
414 414
415 415
416/** 416/**
417 * Add the existing connections (pairs) to the connections tab. 417 * Add the existing connections (pairs) to the connections tab.
418 * This one triggers the search 418 * This one triggers the search
419 */ 419 */
420void BlueBase::addConnectedDevices() { 420void BlueBase::addConnectedDevices() {
421 m_localDevice->searchConnections(); 421 m_localDevice->searchConnections();
422} 422}
423 423
424 424
425/** 425/**
426 * This adds the found connections to the connection tab. 426 * This adds the found connections to the connection tab.
427 * @param connectionList the ValueList with all current connections 427 * @param connectionList the ValueList with all current connections
428 */ 428 */
429void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { 429void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) {
430 430
431 // clear the ListView first 431 // clear the ListView first
432 ListView4->clear(); 432 ListView4->clear();
433 433
434 QValueList<OpieTooth::ConnectionState>::Iterator it; 434 QValueList<OpieTooth::ConnectionState>::Iterator it;
435 BTConnectionItem * connectionItem; 435 BTConnectionItem * connectionItem;
436 436
437 if ( !connectionList.isEmpty() ) { 437 if ( !connectionList.isEmpty() ) {
438 438
439 for (it = connectionList.begin(); it != connectionList.end(); ++it) { 439 for (it = connectionList.begin(); it != connectionList.end(); ++it) {
440 connectionItem = new BTConnectionItem( ListView4 , (*it) ); 440 connectionItem = new BTConnectionItem( ListView4 , (*it) );
441 } 441 }
442 } else { 442 } else {
443 ConnectionState con; 443 ConnectionState con;
444 con.setMac( tr("No connections found") ); 444 con.setMac( tr("No connections found") );
445 connectionItem = new BTConnectionItem( ListView4 , con ); 445 connectionItem = new BTConnectionItem( ListView4 , con );
446 } 446 }
447 447
448 // recall connection search after some time 448 // recall connection search after some time
449 QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) ); 449 QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) );
450} 450}
451 451
452 452
453/** 453/**
454 * Find out if a device can currently be reached 454 * Find out if a device can currently be reached
455 * @param device 455 * @param device
456 */ 456 */
457void BlueBase::deviceActive( const RemoteDevice &device ) { 457void BlueBase::deviceActive( const RemoteDevice &device ) {
458 // search by mac, async, gets a signal back 458 // search by mac, async, gets a signal back
459 // We should have a BTDeviceItem there or where does it get added to the map -zecke 459 // We should have a BTDeviceItem there or where does it get added to the map -zecke
460 m_localDevice->isAvailable( device.mac() ); 460 m_localDevice->isAvailable( device.mac() );
461} 461}
462 462
463 463
464/** 464/**
465 * The signal catcher. Set the avail. status on device. 465 * The signal catcher. Set the avail. status on device.
466 * @param device - the mac address 466 * @param device - the mac address
467 * @param connected - if it is avail. or not 467 * @param connected - if it is avail. or not
468 */ 468 */
469void BlueBase::deviceActive( const QString& device, bool connected ) { 469void BlueBase::deviceActive( const QString& device, bool connected ) {
470 qDebug("deviceActive slot"); 470 qDebug("deviceActive slot");
471 471
472 QMap<QString,BTDeviceItem*>::Iterator it; 472 QMap<QString,BTDeviceItem*>::Iterator it;
473 473
474 it = m_deviceList.find( device ); 474 it = m_deviceList.find( device );
475 if( it == m_deviceList.end() ) 475 if( it == m_deviceList.end() )
476 return; 476 return;
477 477
478 BTDeviceItem* deviceItem = it.data(); 478 BTDeviceItem* deviceItem = it.data();
479 479
480 480
481 if ( connected ) { 481 if ( connected ) {
482 deviceItem->setPixmap( 1, m_onPix ); 482 deviceItem->setPixmap( 1, m_onPix );
483 } else { 483 } else {
484 deviceItem->setPixmap( 1, m_offPix ); 484 deviceItem->setPixmap( 1, m_offPix );
485 } 485 }
486 m_deviceList.remove( it ); 486 m_deviceList.remove( it );
487} 487}
488 488
489 489
490/** 490/**
491 * Open the "scan for devices" dialog 491 * Open the "scan for devices" dialog
492 */ 492 */
493void BlueBase::startScan() { 493void BlueBase::startScan() {
494 ScanDialog *scan = new ScanDialog( this, "ScanDialog", 494 ScanDialog *scan = new ScanDialog( this, "ScanDialog",
495 true, WDestructiveClose ); 495 true, WDestructiveClose );
496 QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ), 496 QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ),
497 this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) ); 497 this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) );
498 498
499 scan->showMaximized(); 499 scan->showMaximized();
500} 500}
501 501
502 502
503/** 503/**
504 * Set the informations about the local device in information Tab 504 * Set the informations about the local device in information Tab
505 */ 505 */
506void BlueBase::setInfo() { 506void BlueBase::setInfo() {
507 StatusLabel->setText( status() ); 507 StatusLabel->setText( status() );
508} 508}
509 509
510 510
511/** 511/**
512 * Decontructor 512 * Decontructor
513 */ 513 */
514BlueBase::~BlueBase() { 514BlueBase::~BlueBase() {
515 writeSavedDevices(); 515 writeSavedDevices();
516 delete m_iconLoader; 516 delete m_iconLoader;
517} 517}
518 518
519 519
520/** 520/**
521 * find searches the ListView for a BTDeviceItem containig 521 * find searches the ListView for a BTDeviceItem containig
522 * the same Device if found return true else false 522 * the same Device if found return true else false
523 * @param dev RemoteDevice to find 523 * @param dev RemoteDevice to find
524 * @return returns true if found 524 * @return returns true if found
525 */ 525 */
526bool BlueBase::find( const RemoteDevice& rem ) { 526bool BlueBase::find( const RemoteDevice& rem ) {
527 QListViewItemIterator it( ListView2 ); 527 QListViewItemIterator it( ListView2 );
528 BTListItem* item; 528 BTListItem* item;
529 BTDeviceItem* device; 529 BTDeviceItem* device;
530 for (; it.current(); ++it ) { 530 for (; it.current(); ++it ) {
531 item = (BTListItem*) it.current(); 531 item = (BTListItem*) it.current();
532 if ( item->typeId() != BTListItem::Device ) 532 if ( item->typeId() != BTListItem::Device )
533 continue; 533 continue;
534 534
535 device = (BTDeviceItem*)item; 535 device = (BTDeviceItem*)item;
536 if ( rem.equals( device->remoteDevice() ) ) 536 if ( rem.equals( device->remoteDevice() ) )
537 return true; 537 return true;
538 } 538 }
539 return false; // not found 539 return false; // not found
540} 540}
diff --git a/noncore/net/opietooth/manager/btconnectionitem.cpp b/noncore/net/opietooth/manager/btconnectionitem.cpp
index 6fb9c11..b57d1b3 100644
--- a/noncore/net/opietooth/manager/btconnectionitem.cpp
+++ b/noncore/net/opietooth/manager/btconnectionitem.cpp
@@ -1,23 +1,24 @@
1#include <connection.h> 1#include <connection.h>
2#include "btconnectionitem.h" 2#include "btconnectionitem.h"
3 3
4using namespace OpieTooth; 4using namespace OpieTooth;
5 5
6BTConnectionItem::BTConnectionItem( QListView* parent, const ConnectionState& con ) 6BTConnectionItem::BTConnectionItem( QListView* parent, const ConnectionState& con )
7 : BTListItem( parent ){ 7 : BTListItem( parent ){
8 m_con = con; 8 m_con = con;
9 setText(0, m_con.mac() ); 9 setText(0, m_con.mac() );
10 setText(1, m_con.connectionMode() );
10} 11}
11BTConnectionItem::~BTConnectionItem() { 12BTConnectionItem::~BTConnectionItem() {
12 13
13} 14}
14QString BTConnectionItem::type() const { 15QString BTConnectionItem::type() const {
15 return QString::fromLatin1("connection"); 16 return QString::fromLatin1("connection");
16} 17}
17int BTConnectionItem::typeId() const { 18int BTConnectionItem::typeId() const {
18 return Connection; 19 return Connection;
19} 20}
20ConnectionState BTConnectionItem::connection() const { 21ConnectionState BTConnectionItem::connection() const {
21 return m_con; 22 return m_con;
22} 23}
23 24