author | harlekin <harlekin> | 2002-06-28 21:53:42 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-06-28 21:53:42 (UTC) |
commit | 05a76394214a0066325c71f91eb44ed7412df67c (patch) (unidiff) | |
tree | 2b8995a8670ab3bda9a93bd37792117a4a4fa603 | |
parent | 26be5facf38c25f2b22b18a19ea7fa710f5e2236 (diff) | |
download | opie-05a76394214a0066325c71f91eb44ed7412df67c.zip opie-05a76394214a0066325c71f91eb44ed7412df67c.tar.gz opie-05a76394214a0066325c71f91eb44ed7412df67c.tar.bz2 |
connection view started
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 40 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.h | 1 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/hciconfwrapper.cpp | 4 |
3 files changed, 25 insertions, 20 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 3e7e2ab..d023302 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -1,190 +1,195 @@ | |||
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 | 21 | ||
22 | #include <qframe.h> | 22 | #include <qframe.h> |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qpushbutton.h> | 24 | #include <qpushbutton.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qvariant.h> | 26 | #include <qvariant.h> |
27 | #include <qwhatsthis.h> | 27 | #include <qwhatsthis.h> |
28 | #include <qimage.h> | 28 | #include <qimage.h> |
29 | #include <qpixmap.h> | 29 | #include <qpixmap.h> |
30 | #include <qtabwidget.h> | 30 | #include <qtabwidget.h> |
31 | #include <qscrollview.h> | 31 | #include <qscrollview.h> |
32 | #include <qvbox.h> | 32 | #include <qvbox.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
35 | #include <qlineedit.h> | 35 | #include <qlineedit.h> |
36 | #include <qlistview.h> | 36 | #include <qlistview.h> |
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qpopupmenu.h> | 38 | #include <qpopupmenu.h> |
39 | #include <qtimer.h> | ||
39 | 40 | ||
40 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
41 | #include <qpe/config.h> | 42 | #include <qpe/config.h> |
42 | 43 | ||
43 | #include <remotedevice.h> | 44 | #include <remotedevice.h> |
44 | 45 | ||
45 | 46 | ||
46 | namespace OpieTooth { | 47 | namespace OpieTooth { |
47 | 48 | ||
48 | 49 | ||
49 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | 50 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) |
50 | : BluetoothBase( parent, name, fl ) { | 51 | : BluetoothBase( parent, name, fl ) { |
51 | 52 | ||
52 | localDevice = new Manager( "hci0" ); | 53 | localDevice = new Manager( "hci0" ); |
53 | 54 | ||
54 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); | 55 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); |
55 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); | 56 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); |
56 | // not good since lib is async | 57 | // not good since lib is async |
57 | // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), | 58 | // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), |
58 | // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); | 59 | // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); |
59 | connect( ListView2, SIGNAL( clicked( QListViewItem* )), | 60 | connect( ListView2, SIGNAL( clicked( QListViewItem* )), |
60 | this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); | 61 | this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); |
61 | // hehe, cast right later | 62 | // hehe, cast right later |
62 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), | 63 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), |
63 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); | 64 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); |
64 | connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), | 65 | connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), |
65 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); | 66 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); |
66 | connect( localDevice, SIGNAL( available( const QString&, bool ) ), | 67 | connect( localDevice, SIGNAL( available( const QString&, bool ) ), |
67 | this, SLOT( deviceActive( const QString& , bool ) ) ); | 68 | this, SLOT( deviceActive( const QString& , bool ) ) ); |
69 | connect( localDevice, SIGNAL( connections( Connection::ValueList ) ), | ||
70 | this, SLOT( addConnectedDevices( Connection::ValueList ) ) ); | ||
68 | 71 | ||
69 | //Load all icons needed | 72 | //Load all icons needed |
70 | 73 | ||
71 | offPix = Resource::loadPixmap( "editdelete" ); | 74 | offPix = Resource::loadPixmap( "editdelete" ); |
72 | onPix = Resource::loadPixmap( "installed" ); | 75 | onPix = Resource::loadPixmap( "installed" ); |
73 | 76 | ||
74 | QPalette pal = this->palette(); | 77 | QPalette pal = this->palette(); |
75 | QColor col = pal.color( QPalette::Active, QColorGroup::Background ); | 78 | QColor col = pal.color( QPalette::Active, QColorGroup::Background ); |
76 | pal.setColor( QPalette::Active, QColorGroup::Button, col ); | 79 | pal.setColor( QPalette::Active, QColorGroup::Button, col ); |
77 | pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); | 80 | pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); |
78 | pal.setColor( QPalette::Normal, QColorGroup::Button, col ); | 81 | pal.setColor( QPalette::Normal, QColorGroup::Button, col ); |
79 | pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); | 82 | pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); |
80 | this->setPalette( pal ); | 83 | this->setPalette( pal ); |
81 | 84 | ||
82 | setCaption( tr( "Bluetooth Manager" ) ); | 85 | setCaption( tr( "Bluetooth Manager" ) ); |
83 | 86 | ||
84 | readConfig(); | 87 | readConfig(); |
85 | initGui(); | 88 | initGui(); |
86 | 89 | ||
87 | //TESTING | 90 | //TESTING |
88 | ListView2->setRootIsDecorated(true); | 91 | ListView2->setRootIsDecorated(true); |
89 | 92 | ||
90 | BTListItem *topLV2 = new BTListItem( ListView2, "Siemens S45", "", "device" ); | 93 | BTListItem *topLV2 = new BTListItem( ListView2, "Siemens S45", "", "device" ); |
91 | topLV2->setPixmap( 1, onPix ); | 94 | topLV2->setPixmap( 1, onPix ); |
92 | (void) new BTListItem( topLV2, "Serial" ,"", "service" ); | 95 | (void) new BTListItem( topLV2, "Serial" ,"", "service" ); |
93 | (void) new BTListItem( topLV2, "BlueNiC" , "", "service" ); | 96 | (void) new BTListItem( topLV2, "BlueNiC" , "", "service" ); |
94 | writeToHciConfig(); | 97 | writeToHciConfig(); |
98 | // search conncetions | ||
99 | addConnectedDevices(); | ||
95 | } | 100 | } |
96 | 101 | ||
97 | 102 | ||
98 | /** | 103 | /** |
99 | * Reads all options from the config file | 104 | * Reads all options from the config file |
100 | */ | 105 | */ |
101 | void BlueBase::readConfig() { | 106 | void BlueBase::readConfig() { |
102 | 107 | ||
103 | Config cfg( "bluetoothmanager" ); | 108 | Config cfg( "bluetoothmanager" ); |
104 | cfg.setGroup( "bluezsettings" ); | 109 | cfg.setGroup( "bluezsettings" ); |
105 | 110 | ||
106 | 111 | ||
107 | deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with | 112 | deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with |
108 | defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak | 113 | defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak |
109 | useEncryption = cfg.readNumEntry( "useEncryption" , 1 ); | 114 | useEncryption = cfg.readNumEntry( "useEncryption" , 1 ); |
110 | enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 ); | 115 | enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 ); |
111 | enablePagescan = cfg.readNumEntry( "enablePagescan" , 1 ); | 116 | enablePagescan = cfg.readNumEntry( "enablePagescan" , 1 ); |
112 | enableInquiryscan = cfg.readNumEntry( "enableInquiryscan" , 1 ); | 117 | enableInquiryscan = cfg.readNumEntry( "enableInquiryscan" , 1 ); |
113 | 118 | ||
114 | } | 119 | } |
115 | 120 | ||
116 | /** | 121 | /** |
117 | * Writes all options to the config file | 122 | * Writes all options to the config file |
118 | */ | 123 | */ |
119 | void BlueBase::writeConfig() { | 124 | void BlueBase::writeConfig() { |
120 | 125 | ||
121 | 126 | ||
122 | Config cfg( "bluetoothmanager" ); | 127 | Config cfg( "bluetoothmanager" ); |
123 | cfg.setGroup( "bluezsettings" ); | 128 | cfg.setGroup( "bluezsettings" ); |
124 | 129 | ||
125 | cfg.writeEntry( "name" , deviceName ); | 130 | cfg.writeEntry( "name" , deviceName ); |
126 | cfg.writeEntryCrypt( "passkey" , defaultPasskey ); | 131 | cfg.writeEntryCrypt( "passkey" , defaultPasskey ); |
127 | cfg.writeEntry( "useEncryption" , useEncryption ); | 132 | cfg.writeEntry( "useEncryption" , useEncryption ); |
128 | cfg.writeEntry( "enableAuthentification" , enableAuthentification ); | 133 | cfg.writeEntry( "enableAuthentification" , enableAuthentification ); |
129 | cfg.writeEntry( "enablePagescan" , enablePagescan ); | 134 | cfg.writeEntry( "enablePagescan" , enablePagescan ); |
130 | cfg.writeEntry( "enableInquiryscan" , enableInquiryscan ); | 135 | cfg.writeEntry( "enableInquiryscan" , enableInquiryscan ); |
131 | 136 | ||
132 | writeToHciConfig(); | 137 | writeToHciConfig(); |
133 | } | 138 | } |
134 | 139 | ||
135 | void BlueBase::writeToHciConfig() { | 140 | void BlueBase::writeToHciConfig() { |
136 | 141 | ||
137 | HciConfWrapper *hciconf = new HciConfWrapper( "/tmp/hcid.conf" ); | 142 | HciConfWrapper *hciconf = new HciConfWrapper( "/tmp/hcid.conf" ); |
138 | hciconf->setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); | 143 | hciconf->setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); |
139 | 144 | ||
140 | 145 | ||
141 | // hciconf->setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); | 146 | // hciconf->setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); |
142 | 147 | ||
143 | hciconf->setName( deviceName ); | 148 | hciconf->setName( deviceName ); |
144 | 149 | ||
145 | if ( useEncryption == 1) { | 150 | if ( useEncryption == 1) { |
146 | hciconf->setEncrypt( true ); | 151 | hciconf->setEncrypt( true ); |
147 | } else { | 152 | } else { |
148 | hciconf->setEncrypt( false ); | 153 | hciconf->setEncrypt( false ); |
149 | } | 154 | } |
150 | 155 | ||
151 | 156 | ||
152 | if ( enableAuthentification == 1) { | 157 | if ( enableAuthentification == 1) { |
153 | hciconf->setAuth( true ); | 158 | hciconf->setAuth( true ); |
154 | } else { | 159 | } else { |
155 | hciconf->setAuth( false ); | 160 | hciconf->setAuth( false ); |
156 | } | 161 | } |
157 | 162 | ||
158 | if ( enablePagescan == 1) { | 163 | if ( enablePagescan == 1) { |
159 | hciconf->setPscan( true ); | 164 | hciconf->setPscan( true ); |
160 | } else { | 165 | } else { |
161 | hciconf->setPscan( false ); | 166 | hciconf->setPscan( false ); |
162 | } | 167 | } |
163 | 168 | ||
164 | if ( enableInquiryscan == 1) { | 169 | if ( enableInquiryscan == 1) { |
165 | hciconf->setIscan( true ); | 170 | hciconf->setIscan( true ); |
166 | } else { | 171 | } else { |
167 | hciconf->setIscan( false ); | 172 | hciconf->setIscan( false ); |
168 | } | 173 | } |
169 | delete hciconf; | 174 | delete hciconf; |
170 | } | 175 | } |
171 | 176 | ||
172 | 177 | ||
173 | /** | 178 | /** |
174 | * Read the list of allready known devices | 179 | * Read the list of allready known devices |
175 | * | 180 | * |
176 | */ | 181 | */ |
177 | void BlueBase::readSavedDevices() { | 182 | void BlueBase::readSavedDevices() { |
178 | 183 | ||
179 | QList<RemoteDevice> *loadedDevices = new QList<RemoteDevice>; | 184 | QList<RemoteDevice> *loadedDevices = new QList<RemoteDevice>; |
180 | 185 | ||
181 | QDir deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/"); | 186 | QDir deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/"); |
182 | // list of .conf files | 187 | // list of .conf files |
183 | QStringList devicesFileList = deviceListSave.entryList(); | 188 | QStringList devicesFileList = deviceListSave.entryList(); |
184 | 189 | ||
185 | // cut .conf of to get the mac and also read the name entry in it. | 190 | // cut .conf of to get the mac and also read the name entry in it. |
186 | 191 | ||
187 | for ( QStringList::Iterator it = devicesFileList.begin(); it != devicesFileList.end(); ++it ) { | 192 | for ( QStringList::Iterator it = devicesFileList.begin(); it != devicesFileList.end(); ++it ) { |
188 | 193 | ||
189 | QString name; | 194 | QString name; |
190 | QString mac; | 195 | QString mac; |
@@ -202,316 +207,317 @@ namespace OpieTooth { | |||
202 | 207 | ||
203 | /** | 208 | /** |
204 | * Write the list of allready known devices | 209 | * Write the list of allready known devices |
205 | * | 210 | * |
206 | */ | 211 | */ |
207 | void BlueBase::writeSavedDevices() { | 212 | void BlueBase::writeSavedDevices() { |
208 | 213 | ||
209 | QListViewItemIterator it( ListView2 ); | 214 | QListViewItemIterator it( ListView2 ); |
210 | 215 | ||
211 | for ( ; it.current(); ++it ) { | 216 | for ( ; it.current(); ++it ) { |
212 | 217 | ||
213 | // seperate config file for each device, to store more information in future. | 218 | // seperate config file for each device, to store more information in future. |
214 | // TO FIX: BTLISTITEM!!! | 219 | // TO FIX: BTLISTITEM!!! |
215 | qDebug( "/Settings/bluetooth/" + (((BTListItem*)it.current())->mac()) + ".conf"); | 220 | qDebug( "/Settings/bluetooth/" + (((BTListItem*)it.current())->mac()) + ".conf"); |
216 | Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (((BTListItem*)it.current())->mac()) + ".conf", Config::File ); | 221 | Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (((BTListItem*)it.current())->mac()) + ".conf", Config::File ); |
217 | 222 | ||
218 | conf.setGroup( "Info" ); | 223 | conf.setGroup( "Info" ); |
219 | conf.writeEntry( "name", ((BTListItem*)it.current())->name() ); | 224 | conf.writeEntry( "name", ((BTListItem*)it.current())->name() ); |
220 | } | 225 | } |
221 | } | 226 | } |
222 | 227 | ||
223 | 228 | ||
224 | /** | 229 | /** |
225 | * Set up the gui | 230 | * Set up the gui |
226 | */ | 231 | */ |
227 | void BlueBase::initGui() { | 232 | void BlueBase::initGui() { |
228 | 233 | ||
229 | StatusLabel->setText( getStatus() ); // maybe move it to getStatus() | 234 | StatusLabel->setText( getStatus() ); // maybe move it to getStatus() |
230 | 235 | ||
231 | cryptCheckBox->setChecked( useEncryption ); | 236 | cryptCheckBox->setChecked( useEncryption ); |
232 | authCheckBox->setChecked( enableAuthentification ); | 237 | authCheckBox->setChecked( enableAuthentification ); |
233 | pagescanCheckBox->setChecked( enablePagescan ); | 238 | pagescanCheckBox->setChecked( enablePagescan ); |
234 | inquiryscanCheckBox->setChecked( enableInquiryscan ); | 239 | inquiryscanCheckBox->setChecked( enableInquiryscan ); |
235 | deviceNameLine->setText( deviceName ); | 240 | deviceNameLine->setText( deviceName ); |
236 | passkeyLine->setText( defaultPasskey ); | 241 | passkeyLine->setText( defaultPasskey ); |
237 | // set info tab | 242 | // set info tab |
238 | setInfo(); | 243 | setInfo(); |
239 | } | 244 | } |
240 | 245 | ||
241 | 246 | ||
242 | /** | 247 | /** |
243 | * Get the status informations and returns it | 248 | * Get the status informations and returns it |
244 | * @return QString the status informations gathered | 249 | * @return QString the status informations gathered |
245 | */ | 250 | */ |
246 | QString BlueBase::getStatus(){ | 251 | QString BlueBase::getStatus(){ |
247 | 252 | ||
248 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); | 253 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); |
249 | infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); | 254 | infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); |
250 | infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); | 255 | infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); |
251 | 256 | ||
252 | return (infoString); | 257 | return (infoString); |
253 | } | 258 | } |
254 | 259 | ||
255 | 260 | ||
256 | /** | 261 | /** |
257 | * Read the current values from the gui and invoke writeConfig() | 262 | * Read the current values from the gui and invoke writeConfig() |
258 | */ | 263 | */ |
259 | void BlueBase::applyConfigChanges() { | 264 | void BlueBase::applyConfigChanges() { |
260 | 265 | ||
261 | deviceName = deviceNameLine->text(); | 266 | deviceName = deviceNameLine->text(); |
262 | defaultPasskey = passkeyLine->text(); | 267 | defaultPasskey = passkeyLine->text(); |
263 | useEncryption = cryptCheckBox->isChecked(); | 268 | useEncryption = cryptCheckBox->isChecked(); |
264 | enableAuthentification = authCheckBox->isChecked(); | 269 | enableAuthentification = authCheckBox->isChecked(); |
265 | enablePagescan = pagescanCheckBox->isChecked(); | 270 | enablePagescan = pagescanCheckBox->isChecked(); |
266 | enableInquiryscan = inquiryscanCheckBox->isChecked(); | 271 | enableInquiryscan = inquiryscanCheckBox->isChecked(); |
267 | 272 | ||
268 | writeConfig(); | 273 | writeConfig(); |
269 | 274 | ||
270 | 275 | ||
271 | QMessageBox* box = new QMessageBox( this, "Test" ); | 276 | QMessageBox* box = new QMessageBox( this, "Test" ); |
272 | box->setText( tr( "Changes applied" ) ); | 277 | box->setText( tr( "Changes applied" ) ); |
273 | box->show(); | 278 | box->show(); |
274 | // falls nötig hcid killhupen - die funktionalität adden | 279 | // falls nötig hcid killhupen - die funktionalität adden |
275 | } | 280 | } |
276 | 281 | ||
277 | 282 | ||
278 | /** | 283 | /** |
279 | * Add fresh found devices from scan dialog to the listing | 284 | * Add fresh found devices from scan dialog to the listing |
280 | * | 285 | * |
281 | */ | 286 | */ |
282 | void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) { | 287 | void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) { |
283 | 288 | ||
284 | BTListItem * deviceItem; | 289 | BTListItem * deviceItem; |
285 | 290 | ||
286 | QListIterator<RemoteDevice> it( newDevices ); | 291 | QListIterator<RemoteDevice> it( newDevices ); |
287 | 292 | ||
288 | for( ; it.current() ; ++it ) { | 293 | for( ; it.current() ; ++it ) { |
289 | 294 | ||
290 | 295 | ||
291 | RemoteDevice *dev = it.current(); | 296 | RemoteDevice *dev = it.current(); |
292 | deviceItem = new BTListItem( ListView2 , dev->name(), dev->mac(), "device" ); | 297 | deviceItem = new BTListItem( ListView2 , dev->name(), dev->mac(), "device" ); |
293 | deviceItem->setExpandable ( true ); | 298 | deviceItem->setExpandable ( true ); |
294 | 299 | ||
295 | // look if device is avail. atm, async | 300 | // look if device is avail. atm, async |
296 | deviceActive( dev ); | 301 | deviceActive( dev ); |
297 | 302 | ||
298 | // move into the c'tor | ||
299 | // deviceItem->setMac( dev->mac() ); | ||
300 | // what kind of entry is it. | ||
301 | //deviceItem->setType( "device"); | ||
302 | |||
303 | // ggf auch hier? | 303 | // ggf auch hier? |
304 | addServicesToDevice( deviceItem ); | 304 | addServicesToDevice( deviceItem ); |
305 | } | 305 | } |
306 | } | 306 | } |
307 | 307 | ||
308 | 308 | ||
309 | /** | 309 | /** |
310 | * Action that is toggled on entrys on click | 310 | * Action that is toggled on entrys on click |
311 | */ | 311 | */ |
312 | void BlueBase::startServiceActionClicked( QListViewItem *item ) { | 312 | void BlueBase::startServiceActionClicked( QListViewItem *item ) { |
313 | 313 | ||
314 | 314 | ||
315 | } | 315 | } |
316 | 316 | ||
317 | /** | 317 | /** |
318 | * Action that are toggled on hold (mostly QPopups i guess) | 318 | * Action that are toggled on hold (mostly QPopups i guess) |
319 | */ | 319 | */ |
320 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) { | 320 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) { |
321 | 321 | ||
322 | QPopupMenu *menu = new QPopupMenu(); | 322 | QPopupMenu *menu = new QPopupMenu(); |
323 | 323 | ||
324 | int ret=0; | 324 | int ret=0; |
325 | 325 | ||
326 | 326 | ||
327 | //QSize s = menu->sizeHint ( ); | 327 | //QSize s = menu->sizeHint ( ); |
328 | 328 | ||
329 | if ( ((BTListItem*)item)->type() == "device") { | 329 | if ( ((BTListItem*)item)->type() == "device") { |
330 | 330 | ||
331 | QPopupMenu *groups = new QPopupMenu(); | 331 | QPopupMenu *groups = new QPopupMenu(); |
332 | 332 | ||
333 | menu->insertItem( tr("rescan sevices:"), 0); | 333 | menu->insertItem( tr("rescan sevices:"), 0); |
334 | menu->insertItem( tr("to group"), groups , 1); | 334 | menu->insertItem( tr("to group"), groups , 1); |
335 | menu->insertItem( tr("delete"), 2); | 335 | menu->insertItem( tr("delete"), 2); |
336 | 336 | ||
337 | 337 | ||
338 | ret = menu->exec( point , 0); | 338 | ret = menu->exec( point , 0); |
339 | 339 | ||
340 | switch(ret) { | 340 | switch(ret) { |
341 | case 0: | 341 | case 0: |
342 | break; | 342 | break; |
343 | case 1: | 343 | case 1: |
344 | break; | 344 | break; |
345 | case 2: | 345 | case 2: |
346 | // delete childs too | 346 | // delete childs too |
347 | delete item; | 347 | delete item; |
348 | break; | 348 | break; |
349 | } | 349 | } |
350 | delete groups; | 350 | delete groups; |
351 | 351 | ||
352 | } else if ( ((BTListItem*)item)->type() == "service") { | 352 | } else if ( ((BTListItem*)item)->type() == "service") { |
353 | menu->insertItem( tr("Test1:"), 0); | 353 | menu->insertItem( tr("Test1:"), 0); |
354 | menu->insertItem( tr("connect"), 1); | 354 | menu->insertItem( tr("connect"), 1); |
355 | menu->insertItem( tr("delete"), 2); | 355 | menu->insertItem( tr("delete"), 2); |
356 | 356 | ||
357 | ret = menu->exec( point , 0); | 357 | ret = menu->exec( point , 0); |
358 | 358 | ||
359 | switch(ret) { | 359 | switch(ret) { |
360 | case 0: | 360 | case 0: |
361 | break; | 361 | break; |
362 | case 1: | 362 | case 1: |
363 | break; | 363 | break; |
364 | case 2: | 364 | case 2: |
365 | // delete childs too | 365 | // delete childs too |
366 | delete item; | 366 | delete item; |
367 | break; | 367 | break; |
368 | } | 368 | } |
369 | } | 369 | } |
370 | 370 | ||
371 | delete menu; | 371 | delete menu; |
372 | } | 372 | } |
373 | 373 | ||
374 | /** | 374 | /** |
375 | * Search and display avail. services for a device (on expand from device listing) | 375 | * Search and display avail. services for a device (on expand from device listing) |
376 | * | 376 | * |
377 | */ | 377 | */ |
378 | void BlueBase::addServicesToDevice( BTListItem * item ) { | 378 | void BlueBase::addServicesToDevice( BTListItem * item ) { |
379 | 379 | ||
380 | qDebug("addServicesToDevice"); | 380 | qDebug("addServicesToDevice"); |
381 | // row of mac adress text(3) | 381 | // row of mac adress text(3) |
382 | RemoteDevice *device = new RemoteDevice( item->mac(), item->name() ); | 382 | RemoteDevice *device = new RemoteDevice( item->mac(), item->name() ); |
383 | 383 | ||
384 | deviceList.insert( item->mac() , item ); | 384 | deviceList.insert( item->mac() , item ); |
385 | 385 | ||
386 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back | 386 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back |
387 | localDevice->searchServices( *device ); | 387 | localDevice->searchServices( *device ); |
388 | 388 | ||
389 | // delete | 389 | // delete |
390 | } | 390 | } |
391 | 391 | ||
392 | 392 | ||
393 | /** | 393 | /** |
394 | * Overloaded. This one it the one that is connected to the foundServices signal | 394 | * Overloaded. This one it the one that is connected to the foundServices signal |
395 | * @param device the mac address of the remote device | 395 | * @param device the mac address of the remote device |
396 | * @param servicesList the list with the service the device has. | 396 | * @param servicesList the list with the service the device has. |
397 | */ | 397 | */ |
398 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { | 398 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { |
399 | 399 | ||
400 | qDebug("fill services list"); | 400 | qDebug("fill services list"); |
401 | 401 | ||
402 | QMap<QString,BTListItem*>::Iterator it; | 402 | QMap<QString,BTListItem*>::Iterator it; |
403 | 403 | ||
404 | BTListItem* deviceItem; | 404 | BTListItem* deviceItem; |
405 | 405 | ||
406 | // get the right devices which requested the search | 406 | // get the right devices which requested the search |
407 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { | 407 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { |
408 | if ( it.key() == device ) { | 408 | if ( it.key() == device ) { |
409 | deviceItem = it.data(); | 409 | deviceItem = it.data(); |
410 | } | 410 | } |
411 | } | 411 | } |
412 | 412 | ||
413 | |||
414 | // empty entries | ||
415 | // QListViewItem * myChild = deviceItem->firstChild(); | ||
416 | //QList<QListViewItem*> tmpList; | ||
417 | //while( myChild ) { | ||
418 | // tmpList.append(myChild); | ||
419 | // myChild = myChild->nextSibling(); | ||
420 | // } | ||
421 | |||
422 | |||
423 | QValueList<OpieTooth::Services>::Iterator it2; | 413 | QValueList<OpieTooth::Services>::Iterator it2; |
424 | 414 | ||
425 | BTListItem * serviceItem; | 415 | BTListItem * serviceItem; |
426 | 416 | ||
427 | if (!servicesList.isEmpty() ) { | 417 | if (!servicesList.isEmpty() ) { |
428 | // add services | 418 | // add services |
429 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { | 419 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { |
430 | serviceItem = new BTListItem( deviceItem , (*it2).serviceName() , "" , "service" ); | 420 | serviceItem = new BTListItem( deviceItem , (*it2).serviceName() , "" , "service" ); |
431 | //serviceItem->setText(4, "service"); | 421 | //serviceItem->setText(4, "service"); |
432 | } | 422 | } |
433 | } else { | 423 | } else { |
434 | serviceItem = new BTListItem( deviceItem , tr("no services found"), "" , "service" ); | 424 | serviceItem = new BTListItem( deviceItem , tr("no services found"), "" , "service" ); |
435 | //serviceItem->setText(4, "service"); | 425 | //serviceItem->setText(4, "service"); |
436 | } | 426 | } |
437 | } | 427 | } |
438 | 428 | ||
439 | 429 | ||
440 | /** | 430 | /** |
441 | * Add the existing connections (pairs) to the connections tab. | 431 | * Add the existing connections (pairs) to the connections tab. |
442 | * | 432 | * This one triggers the search |
443 | */ | 433 | */ |
444 | void BlueBase::addConnectedDevices() { | 434 | void BlueBase::addConnectedDevices() { |
435 | localDevice->searchConnections(); | ||
436 | } | ||
445 | 437 | ||
446 | 438 | ||
447 | //mac address | 439 | void BlueBase::addConnectedDevices( Connection::ValueList connectionList ) { |
440 | |||
441 | QValueList<OpieTooth::Connection>::Iterator it; | ||
442 | BTListItem * connectionItem; | ||
443 | |||
444 | if ( !connectionList.isEmpty() ) { | ||
445 | |||
446 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { | ||
447 | connectionItem = new BTListItem( ListView4 , (*it).mac() , (*it).mac() , "connection" ); | ||
448 | } | ||
449 | } else { | ||
450 | connectionItem = new BTListItem( ListView4 , tr("No connections found"), "", "connection" ); | ||
451 | } | ||
448 | 452 | ||
453 | // recall connection search after some time | ||
454 | QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) ); | ||
449 | } | 455 | } |
450 | 456 | ||
451 | /** | 457 | /** |
452 | * Find out if a device can currently be reached | 458 | * Find out if a device can currently be reached |
453 | */ | 459 | */ |
454 | void BlueBase::deviceActive( RemoteDevice *device ) { | 460 | void BlueBase::deviceActive( RemoteDevice *device ) { |
455 | 461 | ||
456 | // search by mac, async, gets a signal back | 462 | // search by mac, async, gets a signal back |
457 | localDevice->isAvailable( device->mac() ); | 463 | localDevice->isAvailable( device->mac() ); |
458 | } | 464 | } |
459 | 465 | ||
460 | /** | 466 | /** |
461 | * The signal catcher. Set the avail. status on device. | 467 | * The signal catcher. Set the avail. status on device. |
462 | * @param device - the mac address | 468 | * @param device - the mac address |
463 | * @param connected - if it is avail. or not | 469 | * @param connected - if it is avail. or not |
464 | */ | 470 | */ |
465 | void BlueBase::deviceActive( const QString& device, bool connected ) { | 471 | void BlueBase::deviceActive( const QString& device, bool connected ) { |
466 | 472 | ||
467 | qDebug("deviceActive slot"); | 473 | qDebug("deviceActive slot"); |
468 | 474 | ||
469 | QMap<QString,BTListItem*>::Iterator it; | 475 | QMap<QString,BTListItem*>::Iterator it; |
470 | 476 | ||
471 | BTListItem* deviceItem; | 477 | BTListItem* deviceItem; |
472 | 478 | ||
473 | // get the right devices which requested the search | 479 | // get the right devices which requested the search |
474 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { | 480 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { |
475 | if ( it.key() == device ) { | 481 | if ( it.key() == device ) { |
476 | deviceItem = it.data(); | 482 | deviceItem = it.data(); |
477 | } | 483 | } |
478 | } | 484 | } |
479 | 485 | ||
480 | if ( connected ) { | 486 | if ( connected ) { |
481 | deviceItem->setPixmap( 1, onPix ); | 487 | deviceItem->setPixmap( 1, onPix ); |
482 | } else { | 488 | } else { |
483 | deviceItem->setPixmap( 1, offPix ); | 489 | deviceItem->setPixmap( 1, offPix ); |
484 | } | 490 | } |
485 | 491 | ||
486 | } | 492 | } |
487 | 493 | ||
488 | 494 | ||
489 | 495 | ||
490 | /** | 496 | /** |
491 | * Open the "scan for devices" dialog | 497 | * Open the "scan for devices" dialog |
492 | */ | 498 | */ |
493 | void BlueBase::startScan() { | 499 | void BlueBase::startScan() { |
494 | 500 | ||
495 | ScanDialog *scan = new ScanDialog( this, "", true); | 501 | ScanDialog *scan = new ScanDialog( this, "", true); |
496 | QObject::connect( scan, SIGNAL( selectedDevices( QList<RemoteDevice>& ) ), | 502 | QObject::connect( scan, SIGNAL( selectedDevices( QList<RemoteDevice>& ) ), |
497 | this, SLOT( addSearchedDevices( QList<RemoteDevice>& ) ) ); | 503 | this, SLOT( addSearchedDevices( QList<RemoteDevice>& ) ) ); |
498 | 504 | ||
499 | scan->showMaximized(); | 505 | scan->showMaximized(); |
500 | } | 506 | } |
501 | 507 | ||
502 | 508 | ||
503 | /** | 509 | /** |
504 | * Set the informations about the local device in information Tab | 510 | * Set the informations about the local device in information Tab |
505 | */ | 511 | */ |
506 | void BlueBase::setInfo() { | 512 | void BlueBase::setInfo() { |
507 | StatusLabel->setText( getStatus() ); | 513 | StatusLabel->setText( getStatus() ); |
508 | } | 514 | } |
509 | 515 | ||
510 | /** | 516 | /** |
511 | * Decontructor | 517 | * Decontructor |
512 | */ | 518 | */ |
513 | BlueBase::~BlueBase() { | 519 | BlueBase::~BlueBase() { |
514 | writeSavedDevices(); | 520 | writeSavedDevices(); |
515 | } | 521 | } |
516 | } | 522 | } |
517 | 523 | ||
diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h index ef67aa2..0516c16 100644 --- a/noncore/net/opietooth/manager/bluebase.h +++ b/noncore/net/opietooth/manager/bluebase.h | |||
@@ -1,81 +1,82 @@ | |||
1 | 1 | ||
2 | #ifndef BLUEBASE_H | 2 | #ifndef BLUEBASE_H |
3 | #define BLUEBASE_H | 3 | #define BLUEBASE_H |
4 | 4 | ||
5 | #include <qvariant.h> | 5 | #include <qvariant.h> |
6 | #include <qwidget.h> | 6 | #include <qwidget.h> |
7 | #include <qscrollview.h> | 7 | #include <qscrollview.h> |
8 | #include <qsplitter.h> | 8 | #include <qsplitter.h> |
9 | #include <qlist.h> | 9 | #include <qlist.h> |
10 | #include <qpixmap.h> | 10 | #include <qpixmap.h> |
11 | 11 | ||
12 | #include "bluetoothbase.h" | 12 | #include "bluetoothbase.h" |
13 | #include "btlistitem.h" | 13 | #include "btlistitem.h" |
14 | 14 | ||
15 | #include <remotedevice.h> | 15 | #include <remotedevice.h> |
16 | #include <manager.h> | 16 | #include <manager.h> |
17 | 17 | ||
18 | class QVBox; | 18 | class QVBox; |
19 | class QHBoxLayout; | 19 | class QHBoxLayout; |
20 | class QGridLayout; | 20 | class QGridLayout; |
21 | class QFrame; | 21 | class QFrame; |
22 | class QLabel; | 22 | class QLabel; |
23 | class QPushButton; | 23 | class QPushButton; |
24 | class QTabWidget; | 24 | class QTabWidget; |
25 | class QCheckBox; | 25 | class QCheckBox; |
26 | 26 | ||
27 | 27 | ||
28 | namespace OpieTooth { | 28 | namespace OpieTooth { |
29 | 29 | ||
30 | class BlueBase : public BluetoothBase { | 30 | class BlueBase : public BluetoothBase { |
31 | Q_OBJECT | 31 | Q_OBJECT |
32 | 32 | ||
33 | public: | 33 | public: |
34 | BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 34 | BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
35 | ~BlueBase(); | 35 | ~BlueBase(); |
36 | 36 | ||
37 | protected: | 37 | protected: |
38 | 38 | ||
39 | 39 | ||
40 | private slots: | 40 | private slots: |
41 | void startScan(); | 41 | void startScan(); |
42 | 42 | ||
43 | private: | 43 | private: |
44 | void readConfig(); | 44 | void readConfig(); |
45 | void writeConfig(); | 45 | void writeConfig(); |
46 | void readSavedDevices(); | 46 | void readSavedDevices(); |
47 | void writeSavedDevices(); | 47 | void writeSavedDevices(); |
48 | void writeToHciConfig(); | 48 | void writeToHciConfig(); |
49 | QString getStatus(); | 49 | QString getStatus(); |
50 | void initGui(); | 50 | void initGui(); |
51 | void setInfo(); | 51 | void setInfo(); |
52 | Manager *localDevice; | 52 | Manager *localDevice; |
53 | QMap<QString,BTListItem*> deviceList; | 53 | QMap<QString,BTListItem*> deviceList; |
54 | 54 | ||
55 | void deviceActive( RemoteDevice *device ); | 55 | void deviceActive( RemoteDevice *device ); |
56 | 56 | ||
57 | QString deviceName; | 57 | QString deviceName; |
58 | QString defaultPasskey; | 58 | QString defaultPasskey; |
59 | int useEncryption; | 59 | int useEncryption; |
60 | int enableAuthentification; | 60 | int enableAuthentification; |
61 | int enablePagescan; | 61 | int enablePagescan; |
62 | int enableInquiryscan; | 62 | int enableInquiryscan; |
63 | 63 | ||
64 | QPixmap offPix; | 64 | QPixmap offPix; |
65 | QPixmap onPix; | 65 | QPixmap onPix; |
66 | 66 | ||
67 | private slots: | 67 | private slots: |
68 | void addSearchedDevices( QList<RemoteDevice> &newDevices ); | 68 | void addSearchedDevices( QList<RemoteDevice> &newDevices ); |
69 | void addServicesToDevice( BTListItem *item ); | 69 | void addServicesToDevice( BTListItem *item ); |
70 | void addServicesToDevice( const QString& device, Services::ValueList ); | 70 | void addServicesToDevice( const QString& device, Services::ValueList ); |
71 | void addConnectedDevices(); | 71 | void addConnectedDevices(); |
72 | void addConnectedDevices( Connection::ValueList ); | ||
72 | void startServiceActionClicked( QListViewItem *item ); | 73 | void startServiceActionClicked( QListViewItem *item ); |
73 | void startServiceActionHold( QListViewItem *, const QPoint &, int ); | 74 | void startServiceActionHold( QListViewItem *, const QPoint &, int ); |
74 | void deviceActive( const QString& mac, bool connected ); | 75 | void deviceActive( const QString& mac, bool connected ); |
75 | void applyConfigChanges(); | 76 | void applyConfigChanges(); |
76 | 77 | ||
77 | }; | 78 | }; |
78 | 79 | ||
79 | } | 80 | } |
80 | 81 | ||
81 | #endif | 82 | #endif |
diff --git a/noncore/net/opietooth/manager/hciconfwrapper.cpp b/noncore/net/opietooth/manager/hciconfwrapper.cpp index 7b2497a..2d6d7da 100644 --- a/noncore/net/opietooth/manager/hciconfwrapper.cpp +++ b/noncore/net/opietooth/manager/hciconfwrapper.cpp | |||
@@ -6,109 +6,107 @@ | |||
6 | #include <qregexp.h> | 6 | #include <qregexp.h> |
7 | 7 | ||
8 | namespace OpieTooth { | 8 | namespace OpieTooth { |
9 | 9 | ||
10 | 10 | ||
11 | HciConfWrapper::HciConfWrapper( const QString &fileName) { | 11 | HciConfWrapper::HciConfWrapper( const QString &fileName) { |
12 | m_fileName = fileName; | 12 | m_fileName = fileName; |
13 | } | 13 | } |
14 | 14 | ||
15 | HciConfWrapper::~HciConfWrapper() { | 15 | HciConfWrapper::~HciConfWrapper() { |
16 | } | 16 | } |
17 | 17 | ||
18 | 18 | ||
19 | void HciConfWrapper::setPinHelper( QString app ) { | 19 | void HciConfWrapper::setPinHelper( QString app ) { |
20 | setValue( "pin_helper" , app ); | 20 | setValue( "pin_helper" , app ); |
21 | } | 21 | } |
22 | 22 | ||
23 | void HciConfWrapper::setName( QString name ) { | 23 | void HciConfWrapper::setName( QString name ) { |
24 | qDebug ("NAME : " + name); | 24 | qDebug ("NAME : " + name); |
25 | setValue( "name" , "\"" + name + "\"" ); | 25 | setValue( "name" , "\"" + name + "\"" ); |
26 | } | 26 | } |
27 | 27 | ||
28 | void HciConfWrapper::setIscan( bool enable) { | 28 | void HciConfWrapper::setIscan( bool enable) { |
29 | 29 | ||
30 | if ( enable ) { | 30 | if ( enable ) { |
31 | setValue( "iscan" , "enable" ); | 31 | setValue( "iscan" , "enable" ); |
32 | } else { | 32 | } else { |
33 | setValue( "iscan" , "disable" ); | 33 | setValue( "iscan" , "disable" ); |
34 | } | 34 | } |
35 | } | 35 | } |
36 | 36 | ||
37 | void HciConfWrapper::setPscan( bool enable) { | 37 | void HciConfWrapper::setPscan( bool enable) { |
38 | 38 | ||
39 | if ( enable ) { | 39 | if ( enable ) { |
40 | setValue( "pscan" , "enable" ); | 40 | setValue( "pscan" , "enable" ); |
41 | } else { | 41 | } else { |
42 | setValue( "pscan" , "disable" ); | 42 | setValue( "pscan" , "disable" ); |
43 | } | 43 | } |
44 | } | 44 | } |
45 | 45 | ||
46 | 46 | ||
47 | void HciConfWrapper::setAuth( bool enable) { | 47 | void HciConfWrapper::setAuth( bool enable) { |
48 | 48 | ||
49 | if ( enable ) { | 49 | if ( enable ) { |
50 | setValue( "auth" , "enable" ); | 50 | setValue( "auth" , "enable" ); |
51 | } else { | 51 | } else { |
52 | setValue( "auth" , "disable" ); | 52 | setValue( "auth" , "disable" ); |
53 | } | 53 | } |
54 | } | 54 | } |
55 | 55 | ||
56 | 56 | ||
57 | void HciConfWrapper::setEncrypt( bool enable) { | 57 | void HciConfWrapper::setEncrypt( bool enable) { |
58 | 58 | ||
59 | if ( enable ) { | 59 | if ( enable ) { |
60 | setValue( "encrypt" , "enable" ); | 60 | setValue( "encrypt" , "enable" ); |
61 | } else { | 61 | } else { |
62 | setValue( "encrypt" , "disable" ); | 62 | setValue( "encrypt" , "disable" ); |
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||
66 | 66 | ||
67 | void HciConfWrapper::setValue(const QString &key, const QString &value ) { | 67 | void HciConfWrapper::setValue(const QString &key, const QString &value ) { |
68 | 68 | ||
69 | QFile f( m_fileName ); | 69 | QFile f( m_fileName ); |
70 | QFile f2( m_fileName ); | 70 | QFile f2( m_fileName ); |
71 | 71 | ||
72 | if ( !f.open( IO_ReadOnly) ) { | 72 | if ( !f.open( IO_ReadOnly) ) { |
73 | qDebug("Could not open readonly"); | 73 | qDebug("Could not open readonly"); |
74 | return; | 74 | return; |
75 | } | 75 | } |
76 | 76 | ||
77 | if ( !f2.open( IO_ReadWrite ) ) { | 77 | if ( !f2.open( IO_ReadWrite ) ) { |
78 | qDebug("Just readonly - not enough"); | 78 | qDebug("Just readonly - not enough"); |
79 | return; | 79 | return; |
80 | } | 80 | } |
81 | 81 | ||
82 | QStringList list; | 82 | QStringList list; |
83 | qDebug(m_fileName); | 83 | qDebug(m_fileName); |
84 | QTextStream stream ( &f); | 84 | QTextStream stream ( &f); |
85 | QTextStream outstream (&f2); | 85 | QTextStream outstream (&f2); |
86 | 86 | ||
87 | QString str; | 87 | QString str; |
88 | while ( !(str=stream.readLine()).isNull() ) { | 88 | while ( !(str=stream.readLine()).isNull() ) { |
89 | 89 | ||
90 | 90 | ||
91 | //qDebug(str); | 91 | //qDebug(str); |
92 | if( (str.contains(key)) > 0 ) { | 92 | if( (str.contains(key)) > 0 ) { |
93 | qDebug("Found"); | 93 | qDebug("Found"); |
94 | // still need to look if its commented out!!! | 94 | // still need to look if its commented out!!! |
95 | str.simplifyWhiteSpace(); | 95 | str.simplifyWhiteSpace(); |
96 | qDebug( key ); | 96 | qDebug( key ); |
97 | if (str.startsWith("#")) { | 97 | if (str.startsWith("#")) { |
98 | str = (key + " " + value + ";"); | 98 | str = (key + " " + value + ";"); |
99 | } else { | 99 | } else { |
100 | str = str.replace( QRegExp( "\\s*"+key+"\\s+[^\\s][^;]*;" ), key + " " + value + ";"); | 100 | str = str.replace( QRegExp( "\\s*"+key+"\\s+[^\\s][^;]*;" ), key + " " + value + ";"); |
101 | } | 101 | } |
102 | |||
103 | qDebug( str ); | 102 | qDebug( str ); |
104 | } | 103 | } |
105 | |||
106 | outstream << str << endl; | 104 | outstream << str << endl; |
107 | } | 105 | } |
108 | 106 | ||
109 | f.close(); | 107 | f.close(); |
108 | |||
110 | f2.flush(); | 109 | f2.flush(); |
111 | f2.close(); | 110 | f2.close(); |
112 | } | 111 | } |
113 | |||
114 | } | 112 | } |