-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 654 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.h | 1 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bticonloader.cpp | 2 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/devicehandler.cpp | 87 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/devicehandler.h | 41 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/hciconfwrapper.cpp | 74 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/hciconfwrapper.h | 4 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/manager.pro | 17 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/popuphelper.cpp | 4 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/scandialog.cpp | 37 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/scandialog.h | 8 |
11 files changed, 568 insertions, 361 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 3f2f138..598ce16 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -21,2 +21,4 @@ | |||
21 | 21 | ||
22 | #include <stdlib.h> | ||
23 | |||
22 | #include <qframe.h> | 24 | #include <qframe.h> |
@@ -46,2 +48,3 @@ | |||
46 | 48 | ||
49 | #include "devicehandler.h" | ||
47 | #include "btconnectionitem.h" | 50 | #include "btconnectionitem.h" |
@@ -50,232 +53,225 @@ using namespace OpieTooth; | |||
50 | 53 | ||
51 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | 54 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) |
52 | : BluetoothBase( parent, name, fl ) { | 55 | : BluetoothBase( parent, name, fl ) { |
53 | 56 | ||
54 | m_localDevice = new Manager( "hci0" ); | 57 | m_localDevice = new Manager( "hci0" ); |
55 | 58 | ||
56 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); | 59 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); |
57 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); | 60 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); |
58 | // not good since lib is async | 61 | // not good since lib is async |
59 | // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), | 62 | // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), |
60 | // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); | 63 | // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); |
61 | connect( ListView2, SIGNAL( clicked( QListViewItem* )), | 64 | connect( ListView2, SIGNAL( clicked( QListViewItem* )), |
62 | this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); | 65 | this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); |
63 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), | 66 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), |
64 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); | 67 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); |
65 | connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), | 68 | connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), |
66 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); | 69 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); |
67 | connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), | 70 | connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), |
68 | this, SLOT( deviceActive( const QString& , bool ) ) ); | 71 | this, SLOT( deviceActive( const QString& , bool ) ) ); |
69 | connect( m_localDevice, SIGNAL( connections( Connection::ValueList ) ), | 72 | connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ), |
70 | this, SLOT( addConnectedDevices( Connection::ValueList ) ) ); | 73 | this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) ); |
71 | 74 | ||
72 | //Load all icons needed | 75 | //Load all icons needed |
73 | m_offPix = Resource::loadPixmap( "editdelete" ); | 76 | m_offPix = Resource::loadPixmap( "editdelete" ); |
74 | m_onPix = Resource::loadPixmap( "installed" ); | 77 | m_onPix = Resource::loadPixmap( "installed" ); |
75 | 78 | ||
76 | QPalette pal = this->palette(); | 79 | QPalette pal = this->palette(); |
77 | QColor col = pal.color( QPalette::Active, QColorGroup::Background ); | 80 | QColor col = pal.color( QPalette::Active, QColorGroup::Background ); |
78 | pal.setColor( QPalette::Active, QColorGroup::Button, col ); | 81 | pal.setColor( QPalette::Active, QColorGroup::Button, col ); |
79 | pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); | 82 | pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); |
80 | pal.setColor( QPalette::Normal, QColorGroup::Button, col ); | 83 | pal.setColor( QPalette::Normal, QColorGroup::Button, col ); |
81 | pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); | 84 | pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); |
82 | this->setPalette( pal ); | 85 | this->setPalette( pal ); |
83 | 86 | ||
84 | setCaption( tr( "Bluetooth Manager" ) ); | 87 | setCaption( tr( "Bluetooth Manager" ) ); |
85 | 88 | ||
86 | readConfig(); | 89 | readConfig(); |
87 | initGui(); | 90 | initGui(); |
88 | 91 | ||
89 | //TESTING | 92 | //TESTING |
90 | ListView2->setRootIsDecorated(true); | 93 | ListView2->setRootIsDecorated(true); |
91 | 94 | ||
92 | BTDeviceItem *topLV2 = new BTDeviceItem( ListView2, RemoteDevice("xx:", "Siemens S45" ) ); | 95 | BTDeviceItem *topLV2 = new BTDeviceItem( ListView2, RemoteDevice("xx:", "Siemens S45" ) ); |
93 | topLV2->setPixmap( 1, m_onPix ); | 96 | topLV2->setPixmap( 1, m_onPix ); |
94 | Services s1; | 97 | Services s1; |
95 | s1.setServiceName( "Serial" ); | 98 | s1.setServiceName( "Serial" ); |
96 | s1.insertClassId(1, "BlueNic"); | 99 | s1.insertClassId(1, "BlueNic"); |
97 | (void) new BTServiceItem( topLV2, s1 ); | 100 | (void) new BTServiceItem( topLV2, s1 ); |
98 | s1.setServiceName( "BlueNic" ); | 101 | s1.setServiceName( "BlueNic" ); |
99 | s1.insertClassId(2, "Obex"); | 102 | s1.insertClassId(2, "Obex"); |
100 | (void) new BTServiceItem( topLV2, s1 ); | 103 | (void) new BTServiceItem( topLV2, s1 ); |
101 | 104 | ||
102 | writeToHciConfig(); | 105 | writeToHciConfig(); |
103 | // search conncetions | 106 | // search conncetions |
104 | addConnectedDevices(); | 107 | addConnectedDevices(); |
105 | m_iconLoader = new BTIconLoader(); | 108 | m_iconLoader = new BTIconLoader(); |
106 | } | 109 | readSavedDevices(); |
107 | 110 | } | |
108 | /** | ||
109 | * Reads all options from the config file | ||
110 | */ | ||
111 | void BlueBase::readConfig() { | ||
112 | |||
113 | Config cfg( "bluetoothmanager" ); | ||
114 | cfg.setGroup( "bluezsettings" ); | ||
115 | |||
116 | m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with | ||
117 | m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak | ||
118 | m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE ); | ||
119 | m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE ); | ||
120 | m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE ); | ||
121 | m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE ); | ||
122 | } | ||
123 | 111 | ||
124 | /** | 112 | /** |
125 | * Writes all options to the config file | 113 | * Reads all options from the config file |
126 | */ | 114 | */ |
127 | void BlueBase::writeConfig() { | 115 | void BlueBase::readConfig() { |
128 | 116 | ||
129 | Config cfg( "bluetoothmanager" ); | 117 | Config cfg( "bluetoothmanager" ); |
130 | cfg.setGroup( "bluezsettings" ); | 118 | cfg.setGroup( "bluezsettings" ); |
131 | 119 | ||
132 | cfg.writeEntry( "name" , m_deviceName ); | 120 | m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with |
133 | cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); | 121 | m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak |
134 | cfg.writeEntry( "useEncryption" , m_useEncryption ); | 122 | m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE ); |
135 | cfg.writeEntry( "enableAuthentification" , m_enableAuthentification ); | 123 | m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE ); |
136 | cfg.writeEntry( "enablePagescan" , m_enablePagescan ); | 124 | m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE ); |
137 | cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan ); | 125 | m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE ); |
126 | } | ||
138 | 127 | ||
139 | writeToHciConfig(); | 128 | /** |
140 | } | 129 | * Writes all options to the config file |
130 | */ | ||
131 | void BlueBase::writeConfig() { | ||
141 | 132 | ||
142 | void BlueBase::writeToHciConfig() { | 133 | Config cfg( "bluetoothmanager" ); |
134 | cfg.setGroup( "bluezsettings" ); | ||
143 | 135 | ||
144 | HciConfWrapper hciconf ( "/tmp/hcid.conf" ); | 136 | cfg.writeEntry( "name" , m_deviceName ); |
145 | hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); | 137 | cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); |
138 | cfg.writeEntry( "useEncryption" , m_useEncryption ); | ||
139 | cfg.writeEntry( "enableAuthentification" , m_enableAuthentification ); | ||
140 | cfg.writeEntry( "enablePagescan" , m_enablePagescan ); | ||
141 | cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan ); | ||
146 | 142 | ||
143 | writeToHciConfig(); | ||
144 | } | ||
147 | 145 | ||
148 | // hciconf->setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); | 146 | void BlueBase::writeToHciConfig() { |
147 | qWarning("writeToHciConfig"); | ||
148 | HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" ); | ||
149 | hciconf.load(); | ||
150 | hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); | ||
149 | 151 | ||
150 | hciconf.setName( m_deviceName ); | ||
151 | hciconf.setEncrypt( m_useEncryption ); | ||
152 | hciconf.setAuth( m_enableAuthentification ); | ||
153 | hciconf.setPscan( m_enablePagescan ); | ||
154 | hciconf.setIscan( m_enableInquiryscan ); | ||
155 | } | ||
156 | 152 | ||
153 | // hciconf->setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); | ||
157 | 154 | ||
158 | /** | 155 | hciconf.setName( m_deviceName ); |
159 | * Read the list of allready known devices | 156 | hciconf.setEncrypt( m_useEncryption ); |
160 | * | 157 | hciconf.setAuth( m_enableAuthentification ); |
161 | */ | 158 | hciconf.setPscan( m_enablePagescan ); |
162 | void BlueBase::readSavedDevices() { | 159 | hciconf.setIscan( m_enableInquiryscan ); |
160 | hciconf.save(); | ||
161 | } | ||
163 | 162 | ||
164 | QValueList<RemoteDevice> loadedDevices; | ||
165 | 163 | ||
166 | QDir deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/"); | 164 | /** |
167 | // list of .conf files | 165 | * Read the list of allready known devices |
168 | QStringList devicesFileList = deviceListSave.entryList(); | 166 | * |
167 | */ | ||
168 | void BlueBase::readSavedDevices() { | ||
169 | 169 | ||
170 | // cut .conf of to get the mac and also read the name entry in it. | 170 | QValueList<RemoteDevice> loadedDevices; |
171 | DeviceHandler handler; | ||
172 | loadedDevices = handler.load(); | ||
171 | 173 | ||
172 | for ( QStringList::Iterator it = devicesFileList.begin(); it != devicesFileList.end(); ++it ) { | 174 | addSearchedDevices( loadedDevices ); |
175 | } | ||
173 | 176 | ||
174 | QString name; | 177 | /** |
175 | QString mac; | 178 | * Write the list of allready known devices |
176 | qDebug((*it).latin1() ); | 179 | * |
177 | Config conf((*it)); | 180 | */ |
178 | conf.setGroup("Info"); | 181 | void BlueBase::writeSavedDevices() { |
179 | name = conf.readEntry("name", "Error"); | 182 | QListViewItemIterator it( ListView2 ); |
180 | qDebug("MAC: " + mac); | 183 | BTListItem* item; |
181 | qDebug("NAME: " + name); | 184 | BTDeviceItem* device; |
182 | RemoteDevice currentDevice( mac , name ); | 185 | RemoteDevice::ValueList list; |
183 | loadedDevices.append( currentDevice ); | 186 | for ( ; it.current(); ++it ) { |
184 | } | 187 | item = (BTListItem*)it.current(); |
185 | addSearchedDevices( loadedDevices ); | 188 | if(item->typeId() != BTListItem::Device ) |
189 | continue; | ||
190 | device = (BTDeviceItem*)item; | ||
191 | |||
192 | list.append( device->remoteDevice() ); | ||
186 | } | 193 | } |
187 | 194 | /* | |
188 | /** | 195 | * if not empty save the List through DeviceHandler |
189 | * Write the list of allready known devices | ||
190 | * | ||
191 | */ | 196 | */ |
192 | void BlueBase::writeSavedDevices() { | 197 | if ( list.isEmpty() ) |
193 | QListViewItemIterator it( ListView2 ); | 198 | return; |
194 | BTListItem* item; | 199 | DeviceHandler handler; |
195 | BTDeviceItem* device; | 200 | handler.save( list ); |
196 | 201 | } | |
197 | for ( ; it.current(); ++it ) { | ||
198 | item = (BTListItem*)it.current(); | ||
199 | if(item->typeId() != BTListItem::Device ) | ||
200 | continue; | ||
201 | device = (BTDeviceItem*)item; | ||
202 | // seperate config file for each device, to store more information in future. | ||
203 | qDebug( "/Settings/bluetooth/" + device->mac() + ".conf"); | ||
204 | Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + device->mac() + ".conf", Config::File ); | ||
205 | conf.setGroup( "Info" ); | ||
206 | conf.writeEntry( "name", device->name() ); | ||
207 | } | ||
208 | } | ||
209 | 202 | ||
210 | 203 | ||
211 | /** | 204 | /** |
212 | * Set up the gui | 205 | * Set up the gui |
213 | */ | 206 | */ |
214 | void BlueBase::initGui() { | 207 | void BlueBase::initGui() { |
215 | StatusLabel->setText( status() ); // maybe move it to getStatus() | 208 | StatusLabel->setText( status() ); // maybe move it to getStatus() |
216 | cryptCheckBox->setChecked( m_useEncryption ); | 209 | cryptCheckBox->setChecked( m_useEncryption ); |
217 | authCheckBox->setChecked( m_enableAuthentification ); | 210 | authCheckBox->setChecked( m_enableAuthentification ); |
218 | pagescanCheckBox->setChecked( m_enablePagescan ); | 211 | pagescanCheckBox->setChecked( m_enablePagescan ); |
219 | inquiryscanCheckBox->setChecked( m_enableInquiryscan ); | 212 | inquiryscanCheckBox->setChecked( m_enableInquiryscan ); |
220 | deviceNameLine->setText( m_deviceName ); | 213 | deviceNameLine->setText( m_deviceName ); |
221 | passkeyLine->setText( m_defaultPasskey ); | 214 | passkeyLine->setText( m_defaultPasskey ); |
222 | // set info tab | 215 | // set info tab |
223 | setInfo(); | 216 | setInfo(); |
224 | } | 217 | } |
225 | 218 | ||
226 | 219 | ||
227 | /** | 220 | /** |
228 | * Get the status informations and returns it | 221 | * Get the status informations and returns it |
229 | * @return QString the status informations gathered | 222 | * @return QString the status informations gathered |
230 | */ | 223 | */ |
231 | QString BlueBase::status()const{ | 224 | QString BlueBase::status()const{ |
232 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); | 225 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); |
233 | infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); | 226 | infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); |
234 | infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); | 227 | infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); |
235 | 228 | ||
236 | return (infoString); | 229 | return (infoString); |
237 | } | 230 | } |
238 | 231 | ||
239 | 232 | ||
240 | /** | 233 | /** |
241 | * Read the current values from the gui and invoke writeConfig() | 234 | * Read the current values from the gui and invoke writeConfig() |
242 | */ | 235 | */ |
243 | void BlueBase::applyConfigChanges() { | 236 | void BlueBase::applyConfigChanges() { |
244 | m_deviceName = deviceNameLine->text(); | 237 | m_deviceName = deviceNameLine->text(); |
245 | m_defaultPasskey = passkeyLine->text(); | 238 | m_defaultPasskey = passkeyLine->text(); |
246 | m_useEncryption = cryptCheckBox->isChecked(); | 239 | m_useEncryption = cryptCheckBox->isChecked(); |
247 | m_enableAuthentification = authCheckBox->isChecked(); | 240 | m_enableAuthentification = authCheckBox->isChecked(); |
248 | m_enablePagescan = pagescanCheckBox->isChecked(); | 241 | m_enablePagescan = pagescanCheckBox->isChecked(); |
249 | m_enableInquiryscan = inquiryscanCheckBox->isChecked(); | 242 | m_enableInquiryscan = inquiryscanCheckBox->isChecked(); |
250 | 243 | ||
251 | writeConfig(); | 244 | writeConfig(); |
252 | 245 | ||
253 | QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); | 246 | QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); |
254 | } | 247 | } |
255 | 248 | ||
256 | /** | 249 | /** |
257 | * Add fresh found devices from scan dialog to the listing | 250 | * Add fresh found devices from scan dialog to the listing |
258 | * | 251 | * |
259 | */ | 252 | */ |
260 | void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { | 253 | void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { |
261 | BTDeviceItem * deviceItem; | 254 | BTDeviceItem * deviceItem; |
262 | QValueList<RemoteDevice>::ConstIterator it; | 255 | QValueList<RemoteDevice>::ConstIterator it; |
263 | 256 | ||
264 | for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { | 257 | for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { |
265 | 258 | ||
266 | deviceItem = new BTDeviceItem( ListView2 , (*it) ); | 259 | if (find( (*it) )) // is already inserted |
267 | deviceItem->setExpandable ( true ); | 260 | continue; |
268 | 261 | ||
269 | // look if device is avail. atm, async | 262 | deviceItem = new BTDeviceItem( ListView2 , (*it) ); |
270 | deviceActive( (*it) ); | 263 | deviceItem->setExpandable ( true ); |
271 | 264 | ||
272 | // ggf auch hier? | 265 | // look if device is avail. atm, async |
273 | addServicesToDevice( deviceItem ); | 266 | deviceActive( (*it) ); |
274 | } | 267 | |
268 | // ggf auch hier? | ||
269 | addServicesToDevice( deviceItem ); | ||
275 | } | 270 | } |
271 | } | ||
276 | 272 | ||
277 | 273 | ||
278 | /** | 274 | /** |
279 | * Action that is toggled on entrys on click | 275 | * Action that is toggled on entrys on click |
280 | */ | 276 | */ |
281 | void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { | 277 | void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { |
@@ -283,5 +279,5 @@ void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { | |||
283 | 279 | ||
284 | /** | 280 | /** |
285 | * Action that are toggled on hold (mostly QPopups i guess) | 281 | * Action that are toggled on hold (mostly QPopups i guess) |
286 | */ | 282 | */ |
287 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { | 283 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { |
@@ -335,3 +331,4 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin | |||
335 | QPopupMenu *popup =0l; | 331 | QPopupMenu *popup =0l; |
336 | if ( it != list.end() ) | 332 | if ( it != list.end() ) { |
333 | qWarning("Searching id %d %s", it.key(), it.data().latin1() ); | ||
337 | popup = m_popHelper.find( it.key(), | 334 | popup = m_popHelper.find( it.key(), |
@@ -339,2 +336,5 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin | |||
339 | service->parent() ); | 336 | service->parent() ); |
337 | }else { | ||
338 | qWarning("Empty"); | ||
339 | } | ||
340 | 340 | ||
@@ -369,144 +369,166 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin | |||
369 | */ | 369 | */ |
370 | void BlueBase::addServicesToDevice( BTDeviceItem * item ) { | 370 | void BlueBase::addServicesToDevice( BTDeviceItem * item ) { |
371 | qDebug("addServicesToDevice"); | 371 | qDebug("addServicesToDevice"); |
372 | // row of mac adress text(3) | 372 | // row of mac adress text(3) |
373 | RemoteDevice device = item->remoteDevice(); | 373 | RemoteDevice device = item->remoteDevice(); |
374 | m_deviceList.insert( item->mac() , item ); | 374 | m_deviceList.insert( item->mac() , item ); |
375 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back | 375 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back |
376 | m_localDevice->searchServices( device ); | 376 | m_localDevice->searchServices( device ); |
377 | } | 377 | } |
378 | 378 | ||
379 | 379 | ||
380 | /** | 380 | /** |
381 | * Overloaded. This one it the one that is connected to the foundServices signal | 381 | * Overloaded. This one it the one that is connected to the foundServices signal |
382 | * @param device the mac address of the remote device | 382 | * @param device the mac address of the remote device |
383 | * @param servicesList the list with the service the device has. | 383 | * @param servicesList the list with the service the device has. |
384 | */ | 384 | */ |
385 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { | 385 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { |
386 | qDebug("fill services list"); | 386 | qDebug("fill services list"); |
387 | 387 | ||
388 | QMap<QString,BTDeviceItem*>::Iterator it; | 388 | QMap<QString,BTDeviceItem*>::Iterator it; |
389 | BTDeviceItem* deviceItem = 0; | 389 | BTDeviceItem* deviceItem = 0; |
390 | 390 | ||
391 | // get the right devices which requested the search | 391 | // get the right devices which requested the search |
392 | it = m_deviceList.find( device ); | 392 | it = m_deviceList.find( device ); |
393 | if( it == m_deviceList.end() ) | 393 | if( it == m_deviceList.end() ) |
394 | return; | 394 | return; |
395 | deviceItem = it.data(); | 395 | deviceItem = it.data(); |
396 | 396 | ||
397 | QValueList<OpieTooth::Services>::Iterator it2; | 397 | QValueList<OpieTooth::Services>::Iterator it2; |
398 | BTServiceItem * serviceItem; | 398 | BTServiceItem * serviceItem; |
399 | 399 | ||
400 | if (!servicesList.isEmpty() ) { | 400 | if (!servicesList.isEmpty() ) { |
401 | // add services | 401 | // add services |
402 | QMap<int, QString> list; | 402 | QMap<int, QString> list; |
403 | QMap<int, QString>::Iterator classIt; | 403 | QMap<int, QString>::Iterator classIt; |
404 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { | 404 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { |
405 | serviceItem = new BTServiceItem( deviceItem , (*it2) ); | 405 | serviceItem = new BTServiceItem( deviceItem , (*it2) ); |
406 | list = (*it2).classIdList(); | 406 | list = (*it2).classIdList(); |
407 | classIt = list.begin(); | 407 | classIt = list.begin(); |
408 | int classId; | 408 | int classId=0; |
409 | if ( classIt != list.end() ) | 409 | if ( classIt != list.end() ) |
410 | classId = classIt.key(); | 410 | classId = classIt.key(); |
411 | serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); | 411 | |
412 | } | 412 | serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); |
413 | } else { | ||
414 | Services s1; | ||
415 | s1.setServiceName( tr("no serives found") ); | ||
416 | serviceItem = new BTServiceItem( deviceItem, s1 ); | ||
417 | } | 413 | } |
418 | // now remove them from the list | 414 | } else { |
419 | m_deviceList.remove( it ); | 415 | Services s1; |
416 | s1.setServiceName( tr("no serives found") ); | ||
417 | serviceItem = new BTServiceItem( deviceItem, s1 ); | ||
420 | } | 418 | } |
419 | // now remove them from the list | ||
420 | m_deviceList.remove( it ); | ||
421 | } | ||
421 | 422 | ||
422 | 423 | ||
423 | /** | 424 | /** |
424 | * Add the existing connections (pairs) to the connections tab. | 425 | * Add the existing connections (pairs) to the connections tab. |
425 | * This one triggers the search | 426 | * This one triggers the search |
426 | */ | 427 | */ |
427 | void BlueBase::addConnectedDevices() { | 428 | void BlueBase::addConnectedDevices() { |
428 | m_localDevice->searchConnections(); | 429 | m_localDevice->searchConnections(); |
429 | } | 430 | } |
430 | 431 | ||
431 | 432 | ||
432 | void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { | 433 | void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { |
433 | QValueList<OpieTooth::ConnectionState>::Iterator it; | 434 | QValueList<OpieTooth::ConnectionState>::Iterator it; |
434 | BTConnectionItem * connectionItem; | 435 | BTConnectionItem * connectionItem; |
435 | 436 | ||
436 | if ( !connectionList.isEmpty() ) { | 437 | if ( !connectionList.isEmpty() ) { |
437 | 438 | ||
438 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { | 439 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { |
439 | connectionItem = new BTConnectionItem( ListView4 , (*it) ); | 440 | connectionItem = new BTConnectionItem( ListView4 , (*it) ); |
440 | } | ||
441 | } else { | ||
442 | ConnectionState con; | ||
443 | con.setMac( tr("No connections found") ); | ||
444 | connectionItem = new BTConnectionItem( ListView4 , con ); | ||
445 | } | 441 | } |
446 | 442 | } else { | |
447 | // recall connection search after some time | 443 | ConnectionState con; |
448 | QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) ); | 444 | con.setMac( tr("No connections found") ); |
445 | connectionItem = new BTConnectionItem( ListView4 , con ); | ||
449 | } | 446 | } |
450 | 447 | ||
451 | /** | 448 | // recall connection search after some time |
452 | * Find out if a device can currently be reached | 449 | QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) ); |
453 | */ | 450 | } |
454 | void BlueBase::deviceActive( const RemoteDevice &device ) { | ||
455 | // search by mac, async, gets a signal back | ||
456 | // We should have a BTDeviceItem there or where does it get added to the map -zecke | ||
457 | m_localDevice->isAvailable( device.mac() ); | ||
458 | } | ||
459 | 451 | ||
460 | /** | 452 | /** |
461 | * The signal catcher. Set the avail. status on device. | 453 | * Find out if a device can currently be reached |
462 | * @param device - the mac address | 454 | */ |
463 | * @param connected - if it is avail. or not | 455 | void BlueBase::deviceActive( const RemoteDevice &device ) { |
464 | */ | 456 | // search by mac, async, gets a signal back |
465 | void BlueBase::deviceActive( const QString& device, bool connected ) { | 457 | // We should have a BTDeviceItem there or where does it get added to the map -zecke |
466 | qDebug("deviceActive slot"); | 458 | m_localDevice->isAvailable( device.mac() ); |
459 | } | ||
467 | 460 | ||
468 | QMap<QString,BTDeviceItem*>::Iterator it; | 461 | /** |
462 | * The signal catcher. Set the avail. status on device. | ||
463 | * @param device - the mac address | ||
464 | * @param connected - if it is avail. or not | ||
465 | */ | ||
466 | void BlueBase::deviceActive( const QString& device, bool connected ) { | ||
467 | qDebug("deviceActive slot"); | ||
469 | 468 | ||
470 | it = m_deviceList.find( device ); | 469 | QMap<QString,BTDeviceItem*>::Iterator it; |
471 | if( it == m_deviceList.end() ) | ||
472 | return; | ||
473 | 470 | ||
474 | BTDeviceItem* deviceItem = it.data(); | 471 | it = m_deviceList.find( device ); |
472 | if( it == m_deviceList.end() ) | ||
473 | return; | ||
475 | 474 | ||
475 | BTDeviceItem* deviceItem = it.data(); | ||
476 | 476 | ||
477 | if ( connected ) { | 477 | |
478 | deviceItem->setPixmap( 1, m_onPix ); | 478 | if ( connected ) { |
479 | } else { | 479 | deviceItem->setPixmap( 1, m_onPix ); |
480 | deviceItem->setPixmap( 1, m_offPix ); | 480 | } else { |
481 | } | 481 | deviceItem->setPixmap( 1, m_offPix ); |
482 | m_deviceList.remove( it ); | ||
483 | } | 482 | } |
483 | m_deviceList.remove( it ); | ||
484 | } | ||
484 | 485 | ||
485 | /** | 486 | /** |
486 | * Open the "scan for devices" dialog | 487 | * Open the "scan for devices" dialog |
487 | */ | 488 | */ |
488 | void BlueBase::startScan() { | 489 | void BlueBase::startScan() { |
489 | ScanDialog *scan = new ScanDialog( this, "ScanDialog", | 490 | ScanDialog *scan = new ScanDialog( this, "ScanDialog", |
490 | true, WDestructiveClose ); | 491 | true, WDestructiveClose ); |
491 | QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ), | 492 | QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ), |
492 | this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) ); | 493 | this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) ); |
493 | 494 | ||
494 | scan->showMaximized(); | 495 | scan->showMaximized(); |
495 | } | 496 | } |
496 | 497 | ||
497 | 498 | ||
498 | /** | 499 | /** |
499 | * Set the informations about the local device in information Tab | 500 | * Set the informations about the local device in information Tab |
500 | */ | 501 | */ |
501 | void BlueBase::setInfo() { | 502 | void BlueBase::setInfo() { |
502 | StatusLabel->setText( status() ); | 503 | StatusLabel->setText( status() ); |
503 | } | 504 | } |
504 | 505 | ||
505 | /** | 506 | /** |
506 | * Decontructor | 507 | * Decontructor |
507 | */ | 508 | */ |
508 | BlueBase::~BlueBase() { | 509 | BlueBase::~BlueBase() { |
509 | writeSavedDevices(); | 510 | writeSavedDevices(); |
510 | delete m_iconLoader; | 511 | delete m_iconLoader; |
511 | } | 512 | } |
512 | 513 | ||
514 | /** | ||
515 | * find searches the ListView for a BTDeviceItem containig | ||
516 | * the same Device if found return true else false | ||
517 | * @param dev RemoteDevice to find | ||
518 | * @return returns true if found | ||
519 | */ | ||
520 | bool BlueBase::find( const RemoteDevice& rem ) { | ||
521 | QListViewItemIterator it( ListView2 ); | ||
522 | BTListItem* item; | ||
523 | BTDeviceItem* device; | ||
524 | for (; it.current(); ++it ) { | ||
525 | item = (BTListItem*) it.current(); | ||
526 | if ( item->typeId() != BTListItem::Device ) | ||
527 | continue; | ||
528 | |||
529 | device = (BTDeviceItem*)item; | ||
530 | if ( rem.equals( device->remoteDevice() ) ) | ||
531 | return true; | ||
532 | } | ||
533 | return false; // not found | ||
534 | } | ||
diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h index bbc519c..a68a04b 100644 --- a/noncore/net/opietooth/manager/bluebase.h +++ b/noncore/net/opietooth/manager/bluebase.h | |||
@@ -48,2 +48,3 @@ namespace OpieTooth { | |||
48 | private: | 48 | private: |
49 | bool find( const RemoteDevice& device ); | ||
49 | void readConfig(); | 50 | void readConfig(); |
diff --git a/noncore/net/opietooth/manager/bticonloader.cpp b/noncore/net/opietooth/manager/bticonloader.cpp index f299117..a26af54 100644 --- a/noncore/net/opietooth/manager/bticonloader.cpp +++ b/noncore/net/opietooth/manager/bticonloader.cpp | |||
@@ -68,3 +68,3 @@ namespace OpieTooth { | |||
68 | 68 | ||
69 | it = deviceIcons.find( serviceClass ); | 69 | it = serviceIcons.find( serviceClass ); |
70 | iconName = it.data(); | 70 | iconName = it.data(); |
diff --git a/noncore/net/opietooth/manager/devicehandler.cpp b/noncore/net/opietooth/manager/devicehandler.cpp new file mode 100644 index 0000000..9c5b817 --- a/dev/null +++ b/noncore/net/opietooth/manager/devicehandler.cpp | |||
@@ -0,0 +1,87 @@ | |||
1 | |||
2 | #include <stdlib.h> | ||
3 | |||
4 | #include <qdir.h> | ||
5 | #include <qpe/config.h> | ||
6 | |||
7 | #include "devicehandler.h" | ||
8 | |||
9 | using namespace OpieTooth; | ||
10 | |||
11 | DeviceHandler::DeviceHandler() { | ||
12 | |||
13 | }; | ||
14 | DeviceHandler::~DeviceHandler() { | ||
15 | |||
16 | } | ||
17 | |||
18 | RemoteDevice::ValueList DeviceHandler::load() { | ||
19 | RemoteDevice::ValueList list; | ||
20 | QString path = QDir::homeDirPath() + "/Settings/bluetooth"; | ||
21 | QDir deviceListSave( path); | ||
22 | |||
23 | // list of .conf files | ||
24 | QStringList devicesFileList = deviceListSave.entryList(); | ||
25 | |||
26 | |||
27 | // cut .conf of to get the mac and also read the name entry in it. | ||
28 | if (!devicesFileList.isEmpty() ) { | ||
29 | QString name; | ||
30 | QString mac; | ||
31 | QStringList::Iterator it; | ||
32 | for (it = devicesFileList.begin(); it != devicesFileList.end(); ++it ) { | ||
33 | if ( (*it) == "." || (*it) == ".." ) | ||
34 | continue; | ||
35 | |||
36 | qDebug((*it).latin1() ); | ||
37 | Config conf(path + "/"+(*it), Config::File); | ||
38 | conf.setGroup("Info"); | ||
39 | name = conf.readEntry("name", "Error"); | ||
40 | mac = conf.readEntry("mac", QString::null); | ||
41 | qDebug("MAC: " + mac); | ||
42 | qDebug("NAME: " + name); | ||
43 | if (mac.isEmpty() ) | ||
44 | continue; | ||
45 | RemoteDevice currentDevice( mac , name ); | ||
46 | list.append( currentDevice ); | ||
47 | } | ||
48 | } | ||
49 | return list; | ||
50 | }; | ||
51 | /* | ||
52 | * This is some how rude but make sure all old devices | ||
53 | * are getting deleted | ||
54 | */ | ||
55 | void DeviceHandler::save( const RemoteDevice::ValueList& list) { | ||
56 | QCString rm; | ||
57 | rm += "rm -rf "; | ||
58 | rm += QDir::homeDirPath() + "/Settings/bluetooth"; | ||
59 | system ( rm.data() ); | ||
60 | |||
61 | if (list.isEmpty() ) // no need to create the dir | ||
62 | return; | ||
63 | |||
64 | /** | ||
65 | * Create a new dir | ||
66 | */ | ||
67 | rm = "mkdir "; | ||
68 | rm += QDir::homeDirPath() + "/Settings/bluetooth"; | ||
69 | qWarning("out %s", rm.data() ); | ||
70 | system( rm.data() ); | ||
71 | |||
72 | RemoteDevice::ValueList::ConstIterator it; | ||
73 | // write the config | ||
74 | |||
75 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
76 | qDebug( "/Settings/bluetooth/" + (*it).mac() + ".conf"); | ||
77 | |||
78 | Config conf( QDir::homeDirPath() + | ||
79 | "/Settings/bluetooth/" + | ||
80 | (*it).mac() + ".conf", Config::File ); | ||
81 | |||
82 | conf.setGroup( "Info" ); | ||
83 | conf.writeEntry( "name", (*it).name() ); | ||
84 | conf.writeEntry( "mac", (*it).mac() ); | ||
85 | } | ||
86 | |||
87 | } | ||
diff --git a/noncore/net/opietooth/manager/devicehandler.h b/noncore/net/opietooth/manager/devicehandler.h new file mode 100644 index 0000000..5cfe048 --- a/dev/null +++ b/noncore/net/opietooth/manager/devicehandler.h | |||
@@ -0,0 +1,41 @@ | |||
1 | |||
2 | #ifndef OPIE_TOOTH_DEVICE_HANDLER_H | ||
3 | #define OPIE_TOOTH_DEVICE_HANDLER_H | ||
4 | |||
5 | #include <qvaluelist.h> | ||
6 | |||
7 | #include <remotedevice.h> | ||
8 | |||
9 | namespace OpieTooth { | ||
10 | /** | ||
11 | * DeviceHandler is responsible for loading | ||
12 | * and saving devices from a config File | ||
13 | */ | ||
14 | class DeviceHandler { | ||
15 | public: | ||
16 | /** | ||
17 | * c'tor | ||
18 | */ | ||
19 | DeviceHandler(); | ||
20 | |||
21 | /** | ||
22 | * d'tor | ||
23 | */ | ||
24 | ~DeviceHandler(); | ||
25 | |||
26 | /** | ||
27 | * loads from $HOME/Settings/bluetooth/ * | ||
28 | */ | ||
29 | RemoteDevice::ValueList load(); | ||
30 | |||
31 | /** | ||
32 | * Saves to $HOME/Settings/bluetooth | ||
33 | */ | ||
34 | void save( const RemoteDevice::ValueList & ); | ||
35 | |||
36 | }; | ||
37 | |||
38 | |||
39 | }; | ||
40 | |||
41 | #endif | ||
diff --git a/noncore/net/opietooth/manager/hciconfwrapper.cpp b/noncore/net/opietooth/manager/hciconfwrapper.cpp index 5f74fee..46eed42 100644 --- a/noncore/net/opietooth/manager/hciconfwrapper.cpp +++ b/noncore/net/opietooth/manager/hciconfwrapper.cpp | |||
@@ -68,25 +68,10 @@ namespace OpieTooth { | |||
68 | 68 | ||
69 | QFile f( m_fileName ); | 69 | if (m_file.isEmpty() ) // load first |
70 | QFile f2( m_fileName ); | ||
71 | |||
72 | if ( !f.open( IO_ReadOnly) ) { | ||
73 | qDebug("Could not open readonly"); | ||
74 | return; | 70 | return; |
75 | } | ||
76 | |||
77 | if ( !f2.open( IO_ReadWrite ) ) { | ||
78 | qDebug("Just readonly - not enough"); | ||
79 | return; | ||
80 | } | ||
81 | 71 | ||
82 | QStringList list; | 72 | QStringList::Iterator it; |
83 | qDebug(m_fileName); | ||
84 | QTextStream stream ( &f); | ||
85 | QTextStream outstream (&f2); | ||
86 | 73 | ||
87 | QString str; | 74 | QString str; |
88 | while ( !(str=stream.readLine()).isNull() ) { | 75 | for (it = m_file.begin(); it != m_file.end(); ++it ) { |
89 | 76 | str = (*it); | |
90 | |||
91 | //qDebug(str); | ||
92 | if( (str.contains(key)) > 0 ) { | 77 | if( (str.contains(key)) > 0 ) { |
@@ -102,11 +87,54 @@ namespace OpieTooth { | |||
102 | qDebug( str ); | 87 | qDebug( str ); |
88 | it = m_file.remove( it ); | ||
89 | it = m_file.insert( it, str ); | ||
90 | //return; the regexp is too wide -zecke // all set | ||
103 | } | 91 | } |
104 | outstream << str << endl; | ||
105 | } | 92 | } |
106 | 93 | ||
107 | f.close(); | ||
108 | 94 | ||
109 | f2.flush(); | ||
110 | f2.close(); | ||
111 | } | 95 | } |
96 | |||
97 | /** | ||
98 | * This loads the config file and stores it inside | ||
99 | * the m_file | ||
100 | */ | ||
101 | void HciConfWrapper::load() { | ||
102 | qWarning("loaded"); | ||
103 | m_file.clear(); | ||
104 | QFile file( m_fileName ); | ||
105 | if (!file.open( IO_ReadOnly ) ) { | ||
106 | qDebug("Could not open"); | ||
107 | return; | ||
108 | } | ||
109 | |||
110 | /** | ||
111 | * readAll() into a QByteArray | ||
112 | * QStringList::split('\n', array ) | ||
113 | * would this be faster? -zecke | ||
114 | */ | ||
115 | QTextStream stream(&file ); | ||
116 | QString tmp; | ||
117 | while ( !stream.atEnd() ) { | ||
118 | tmp = stream.readLine(); | ||
119 | m_file.append( tmp ); | ||
120 | } | ||
121 | } | ||
122 | void HciConfWrapper::save() { | ||
123 | qWarning("save"); | ||
124 | if (m_file.isEmpty() ) // load first | ||
125 | return; | ||
126 | |||
127 | QFile file( m_fileName ); | ||
128 | if ( !file.open(IO_WriteOnly ) ) { | ||
129 | qWarning("could not open %s", m_fileName.latin1() ); | ||
130 | return; | ||
131 | } | ||
132 | |||
133 | QTextStream stream(&file ); | ||
134 | QStringList::Iterator it; | ||
135 | for ( it = m_file.begin(); it != m_file.end(); ++it ) { | ||
136 | stream << (*it) << endl; | ||
137 | } | ||
138 | qWarning("saved"); | ||
139 | }; | ||
112 | } | 140 | } |
diff --git a/noncore/net/opietooth/manager/hciconfwrapper.h b/noncore/net/opietooth/manager/hciconfwrapper.h index de8c9a8..0c4b290 100644 --- a/noncore/net/opietooth/manager/hciconfwrapper.h +++ b/noncore/net/opietooth/manager/hciconfwrapper.h | |||
@@ -4,2 +4,3 @@ | |||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | #include <qstringlist.h> | ||
5 | 6 | ||
@@ -12,2 +13,4 @@ namespace OpieTooth { | |||
12 | ~HciConfWrapper(); | 13 | ~HciConfWrapper(); |
14 | void load(); | ||
15 | void save(); | ||
13 | 16 | ||
@@ -25,2 +28,3 @@ namespace OpieTooth { | |||
25 | QString m_fileName; | 28 | QString m_fileName; |
29 | QStringList m_file; | ||
26 | }; | 30 | }; |
diff --git a/noncore/net/opietooth/manager/manager.pro b/noncore/net/opietooth/manager/manager.pro index 0bdd6b9..762b028 100644 --- a/noncore/net/opietooth/manager/manager.pro +++ b/noncore/net/opietooth/manager/manager.pro | |||
@@ -3,4 +3,17 @@ CONFIG = qt warn_on debug | |||
3 | #CONFIG = qt warn_on release | 3 | #CONFIG = qt warn_on release |
4 | HEADERS = btconnectionitem.h btdeviceitem.h btserviceitem.h stdpopups.h popuphelper.h bluebase.h scandialog.h btlistitem.h hciconfwrapper.h bticonloader.h pppdialog.h obexdialog.h | 4 | HEADERS = btconnectionitem.h btdeviceitem.h \ |
5 | SOURCES = btconnectionitem.cpp btdeviceitem.cpp btserviceitem.h stdpopups.cpp popuphelper.cpp main.cpp bluebase.cpp scandialog.cpp btlistitem.cpp hciconfwrapper.cpp bticonloader.cpp pppdialog.cpp obexdialog.cpp | 5 | btserviceitem.h stdpopups.h \ |
6 | popuphelper.h bluebase.h \ | ||
7 | scandialog.h btlistitem.h \ | ||
8 | hciconfwrapper.h bticonloader.h \ | ||
9 | pppdialog.h obexdialog.h \ | ||
10 | devicehandler.h | ||
11 | |||
12 | SOURCES = btconnectionitem.cpp btdeviceitem.cpp \ | ||
13 | btserviceitem.cpp stdpopups.cpp \ | ||
14 | popuphelper.cpp main.cpp \ | ||
15 | bluebase.cpp scandialog.cpp \ | ||
16 | btlistitem.cpp hciconfwrapper.cpp \ | ||
17 | bticonloader.cpp pppdialog.cpp \ | ||
18 | obexdialog.cpp devicehandler.cpp | ||
6 | INCLUDEPATH += $(OPIEDIR)/include | 19 | INCLUDEPATH += $(OPIEDIR)/include |
diff --git a/noncore/net/opietooth/manager/popuphelper.cpp b/noncore/net/opietooth/manager/popuphelper.cpp index 26c4b02..4ef1ed5 100644 --- a/noncore/net/opietooth/manager/popuphelper.cpp +++ b/noncore/net/opietooth/manager/popuphelper.cpp | |||
@@ -17,6 +17,6 @@ void PopupHelper::insert( int id, popupFactory fact ) { | |||
17 | QPopupMenu* PopupHelper::find( int id, const Services& ser, QListViewItem* item ) { | 17 | QPopupMenu* PopupHelper::find( int id, const Services& ser, QListViewItem* item ) { |
18 | qWarning("find"); | 18 | //qWarning("find"); |
19 | FactoryMap::Iterator it = m_map.find(id ); | 19 | FactoryMap::Iterator it = m_map.find(id ); |
20 | if ( it != m_map.end() ) { | 20 | if ( it != m_map.end() ) { |
21 | qWarning("found"); | 21 | //qWarning("found"); |
22 | popupFactory fact = it.data(); | 22 | popupFactory fact = it.data(); |
diff --git a/noncore/net/opietooth/manager/scandialog.cpp b/noncore/net/opietooth/manager/scandialog.cpp index 3d6c928..9ce1b6a 100644 --- a/noncore/net/opietooth/manager/scandialog.cpp +++ b/noncore/net/opietooth/manager/scandialog.cpp | |||
@@ -67,7 +67,5 @@ namespace OpieTooth { | |||
67 | 67 | ||
68 | StartButton = new QPushButton( buttonFrame, "StartButton" ); | 68 | StartStopButton = new QPushButton( buttonFrame, "StartButton" ); |
69 | StartButton->setText( tr( "Start scan" ) ); | 69 | StartStopButton->setText( tr( "Start scan" ) ); |
70 | 70 | ||
71 | StopButton = new QPushButton( buttonFrame, "StopButton" ); | ||
72 | StopButton->setText( tr( "Cancel scan" ) ); | ||
73 | 71 | ||
@@ -75,4 +73,4 @@ namespace OpieTooth { | |||
75 | 73 | ||
76 | buttonLayout->addWidget(StartButton); | 74 | buttonLayout->addWidget(StartStopButton); |
77 | buttonLayout->addWidget(StopButton); | 75 | //buttonLayout->addWidget(StopButton); |
78 | 76 | ||
@@ -90,4 +88,3 @@ namespace OpieTooth { | |||
90 | 88 | ||
91 | connect( StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); | 89 | connect( StartStopButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); |
92 | connect( StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) ); | ||
93 | connect( localDevice, SIGNAL( foundDevices( const QString& , RemoteDevice::ValueList ) ), | 90 | connect( localDevice, SIGNAL( foundDevices( const QString& , RemoteDevice::ValueList ) ), |
@@ -96,2 +93,3 @@ namespace OpieTooth { | |||
96 | progressStat = 0; | 93 | progressStat = 0; |
94 | m_search = false; | ||
97 | } | 95 | } |
@@ -102,6 +100,6 @@ namespace OpieTooth { | |||
102 | progressStat++; | 100 | progressStat++; |
103 | if (progressStat++ < 20) { | 101 | if (progressStat++ < 20 && m_search ) { |
104 | QTimer::singleShot( 2000, this, SLOT(progressTimer() ) ); | 102 | QTimer::singleShot( 2000, this, SLOT(progressTimer() ) ); |
105 | } | ||
106 | progress->setProgress(progressStat++); | 103 | progress->setProgress(progressStat++); |
104 | } | ||
107 | 105 | ||
@@ -116,2 +114,7 @@ namespace OpieTooth { | |||
116 | void ScanDialog::startSearch() { | 114 | void ScanDialog::startSearch() { |
115 | if ( m_search ) { | ||
116 | stopSearch(); | ||
117 | return; | ||
118 | } | ||
119 | m_search = true; | ||
117 | progress->setProgress(0); | 120 | progress->setProgress(0); |
@@ -128,2 +131,4 @@ namespace OpieTooth { | |||
128 | // checken ob initialisiert , qcop ans applet. | 131 | // checken ob initialisiert , qcop ans applet. |
132 | StartStopButton->setText( tr("Stop scan")); | ||
133 | |||
129 | localDevice->searchDevices(); | 134 | localDevice->searchDevices(); |
@@ -133,7 +138,8 @@ namespace OpieTooth { | |||
133 | void ScanDialog::stopSearch() { | 138 | void ScanDialog::stopSearch() { |
134 | 139 | m_search = true; | |
135 | } | 140 | } |
136 | 141 | ||
137 | void ScanDialog::fillList(const QString& device, RemoteDevice::ValueList deviceList) { | 142 | void ScanDialog::fillList(const QString&, RemoteDevice::ValueList deviceList) { |
138 | 143 | progress->setProgress(0); | |
144 | progressStat = 0; | ||
139 | qDebug("fill List"); | 145 | qDebug("fill List"); |
@@ -147,2 +153,4 @@ namespace OpieTooth { | |||
147 | } | 153 | } |
154 | m_search = false; | ||
155 | StartStopButton->setText(tr ("Start scan") ); | ||
148 | } | 156 | } |
@@ -177,2 +185,3 @@ namespace OpieTooth { | |||
177 | ScanDialog::~ScanDialog() { | 185 | ScanDialog::~ScanDialog() { |
186 | qWarning("delete scan dialog"); | ||
178 | delete localDevice; | 187 | delete localDevice; |
diff --git a/noncore/net/opietooth/manager/scandialog.h b/noncore/net/opietooth/manager/scandialog.h index f18784d..8f8d39a 100644 --- a/noncore/net/opietooth/manager/scandialog.h +++ b/noncore/net/opietooth/manager/scandialog.h | |||
@@ -48,9 +48,10 @@ class Device; | |||
48 | 48 | ||
49 | private: // make them private -zecke | ||
49 | QFrame* Frame7; | 50 | QFrame* Frame7; |
50 | QProgressBar* progress; | 51 | QProgressBar* progress; |
51 | QPushButton* StartButton; | 52 | QPushButton* StartStopButton; |
52 | QPushButton* StopButton; | 53 | // QPushButton* StopButton; |
53 | QListView* ListView1; | 54 | QListView* ListView1; |
54 | 55 | ||
55 | public slots: | 56 | public slots: |
56 | void accept(); | 57 | void accept(); |
@@ -67,2 +68,3 @@ public slots: | |||
67 | private: | 68 | private: |
69 | bool m_search:1; | ||
68 | void emitToManager(); | 70 | void emitToManager(); |