summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/dasher/QtDasherPlugin.cc4
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp2
-rw-r--r--noncore/settings/usermanager/userdialog.cpp12
3 files changed, 10 insertions, 8 deletions
diff --git a/inputmethods/dasher/QtDasherPlugin.cc b/inputmethods/dasher/QtDasherPlugin.cc
index 50d4539..91167c2 100644
--- a/inputmethods/dasher/QtDasherPlugin.cc
+++ b/inputmethods/dasher/QtDasherPlugin.cc
@@ -1,79 +1,81 @@
1#include "QtDasherPlugin.h" 1#include "QtDasherPlugin.h"
2 2
3#include <qpe/global.h> 3#include <qpe/global.h>
4#include <qpe/qpeapplication.h>
4 5
5#include <qpainter.h> 6#include <qpainter.h>
6#include <qlist.h> 7#include <qlist.h>
7#include <qbitmap.h> 8#include <qbitmap.h>
8#include <qlayout.h> 9#include <qlayout.h>
9#include <qvbox.h> 10#include <qvbox.h>
10#include <qdialog.h> 11#include <qdialog.h>
12#include <qfile.h>
11#include <qscrollview.h> 13#include <qscrollview.h>
12#include <qpopupmenu.h> 14#include <qpopupmenu.h>
13#include <qhbuttongroup.h> 15#include <qhbuttongroup.h>
14#include <qpushbutton.h> 16#include <qpushbutton.h>
15#include <qmessagebox.h> 17#include <qmessagebox.h>
16#include <qwindowsystem_qws.h> 18#include <qwindowsystem_qws.h>
17 19
18QtDasherPlugin::QtDasherPlugin(QWidget* parent, const char* name, WFlags f) : QFrame(parent,name,f) 20QtDasherPlugin::QtDasherPlugin(QWidget* parent, const char* name, WFlags f) : QFrame(parent,name,f)
19{ 21{
20 (new QHBoxLayout(this))->setAutoAdd(TRUE); 22 (new QHBoxLayout(this))->setAutoAdd(TRUE);
21 interface = new CDasherInterface; 23 interface = new CDasherInterface;
22 interface->SetSystemLocation("/opt/QtPalmtop/share/dasher/"); 24 interface->SetSystemLocation( QFile::encodeName(QPEApplication::qpeDir()+"share/dasher/").data() );
23 interface->Unpause(0); 25 interface->Unpause(0);
24 interface->Start(); 26 interface->Start();
25 d = new QtDasherScreen(240,100,interface,this,this); 27 d = new QtDasherScreen(240,100,interface,this,this);
26 interface->ChangeMaxBitRate(2.5); 28 interface->ChangeMaxBitRate(2.5);
27 d->show(); 29 d->show();
28 utf8_codec = new QUtf8Codec; 30 utf8_codec = new QUtf8Codec;
29} 31}
30 32
31QSize QtDasherPlugin::sizeHint() const 33QSize QtDasherPlugin::sizeHint() const
32{ 34{
33 return QSize(240,100); 35 return QSize(240,100);
34} 36}
35 37
36QtDasherPlugin::~QtDasherPlugin() 38QtDasherPlugin::~QtDasherPlugin()
37{ 39{
38 delete interface; 40 delete interface;
39} 41}
40 42
41void QtDasherPlugin::resetState() 43void QtDasherPlugin::resetState()
42{ 44{
43 flushcount=0; 45 flushcount=0;
44 interface->Start(); 46 interface->Start();
45 interface->Redraw(); 47 interface->Redraw();
46} 48}
47 49
48void QtDasherPlugin::unflush() 50void QtDasherPlugin::unflush()
49{ 51{
50 if (flushcount==0) 52 if (flushcount==0)
51 return; 53 return;
52 for (; flushcount>0; flushcount--) { 54 for (; flushcount>0; flushcount--) {
53 deletetext(); 55 deletetext();
54 } 56 }
55} 57}
56 58
57void QtDasherPlugin::output(int Symbol) 59void QtDasherPlugin::output(int Symbol)
58{ 60{
59 std::string label = interface->GetEditText(Symbol); 61 std::string label = interface->GetEditText(Symbol);
60 QString unicodestring = utf8_codec->toUnicode(label.c_str()); 62 QString unicodestring = utf8_codec->toUnicode(label.c_str());
61 for (int i=0; i<int(unicodestring.length()); i++) { 63 for (int i=0; i<int(unicodestring.length()); i++) {
62 emit key( unicodestring[i].unicode(), 0, 0, true, false ); 64 emit key( unicodestring[i].unicode(), 0, 0, true, false );
63 emit key( unicodestring[i].unicode(), 0, 0, false, false ); 65 emit key( unicodestring[i].unicode(), 0, 0, false, false );
64 } 66 }
65} 67}
66 68
67void QtDasherPlugin::deletetext() 69void QtDasherPlugin::deletetext()
68{ 70{
69 emit key( 0, Qt::Key_Backspace, 0, true, false); 71 emit key( 0, Qt::Key_Backspace, 0, true, false);
70 emit key( 0, Qt::Key_Backspace, 0, false, false); 72 emit key( 0, Qt::Key_Backspace, 0, false, false);
71} 73}
72 74
73void QtDasherPlugin::flush(int Symbol) 75void QtDasherPlugin::flush(int Symbol)
74{ 76{
75 if (Symbol==0) 77 if (Symbol==0)
76 return; 78 return;
77 output(Symbol); 79 output(Symbol);
78 flushcount++; 80 flushcount++;
79} 81}
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index ee01b61..90e44cb 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -1,355 +1,355 @@
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#include "rfcommassigndialogimpl.h" 23#include "rfcommassigndialogimpl.h"
24 24
25/* OPIE */ 25/* OPIE */
26#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
27#include <qpe/resource.h> 27#include <qpe/resource.h>
28#include <qpe/config.h> 28#include <qpe/config.h>
29#include <opie2/odebug.h> 29#include <opie2/odebug.h>
30using namespace Opie::Core; 30using namespace Opie::Core;
31 31
32/* QT */ 32/* QT */
33#include <qframe.h> 33#include <qframe.h>
34#include <qlabel.h> 34#include <qlabel.h>
35#include <qpushbutton.h> 35#include <qpushbutton.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qvariant.h> 37#include <qvariant.h>
38#include <qimage.h> 38#include <qimage.h>
39#include <qpixmap.h> 39#include <qpixmap.h>
40#include <qtabwidget.h> 40#include <qtabwidget.h>
41#include <qscrollview.h> 41#include <qscrollview.h>
42#include <qvbox.h> 42#include <qvbox.h>
43#include <qmessagebox.h> 43#include <qmessagebox.h>
44#include <qcheckbox.h> 44#include <qcheckbox.h>
45#include <qlineedit.h> 45#include <qlineedit.h>
46#include <qlistview.h> 46#include <qlistview.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qpopupmenu.h> 48#include <qpopupmenu.h>
49#include <qtimer.h> 49#include <qtimer.h>
50#include <qlist.h> 50#include <qlist.h>
51 51
52/* STD */ 52/* STD */
53#include <remotedevice.h> 53#include <remotedevice.h>
54#include <services.h> 54#include <services.h>
55#include <stdlib.h> 55#include <stdlib.h>
56 56
57using namespace OpieTooth; 57using namespace OpieTooth;
58 58
59BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) 59BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
60 : BluetoothBase( parent, name, fl ) 60 : BluetoothBase( parent, name, fl )
61{ 61{
62 62
63 m_localDevice = new Manager( "hci0" ); 63 m_localDevice = new Manager( "hci0" );
64 64
65 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); 65 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) );
66 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); 66 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) );
67 67
68 connect( rfcommBindButton, SIGNAL( clicked() ), this, SLOT( rfcommDialog() ) ); 68 connect( rfcommBindButton, SIGNAL( clicked() ), this, SLOT( rfcommDialog() ) );
69 // not good since lib is async 69 // not good since lib is async
70 // connect( ListView2, SIGNAL( expanded(QListViewItem*) ), 70 // connect( ListView2, SIGNAL( expanded(QListViewItem*) ),
71 // this, SLOT( addServicesToDevice(QListViewItem*) ) ); 71 // this, SLOT( addServicesToDevice(QListViewItem*) ) );
72 connect( ListView2, SIGNAL( clicked(QListViewItem*)), 72 connect( ListView2, SIGNAL( clicked(QListViewItem*)),
73 this, SLOT( startServiceActionClicked(QListViewItem*) ) ); 73 this, SLOT( startServiceActionClicked(QListViewItem*) ) );
74 connect( ListView2, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), 74 connect( ListView2, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ),
75 this, SLOT(startServiceActionHold(QListViewItem*,const QPoint&,int) ) ); 75 this, SLOT(startServiceActionHold(QListViewItem*,const QPoint&,int) ) );
76 connect( m_localDevice , SIGNAL( foundServices(const QString&,Services::ValueList) ), 76 connect( m_localDevice , SIGNAL( foundServices(const QString&,Services::ValueList) ),
77 this, SLOT( addServicesToDevice(const QString&,Services::ValueList) ) ); 77 this, SLOT( addServicesToDevice(const QString&,Services::ValueList) ) );
78 connect( m_localDevice, SIGNAL( available(const QString&,bool) ), 78 connect( m_localDevice, SIGNAL( available(const QString&,bool) ),
79 this, SLOT( deviceActive(const QString&,bool) ) ); 79 this, SLOT( deviceActive(const QString&,bool) ) );
80 connect( m_localDevice, SIGNAL( connections(ConnectionState::ValueList) ), 80 connect( m_localDevice, SIGNAL( connections(ConnectionState::ValueList) ),
81 this, SLOT( addConnectedDevices(ConnectionState::ValueList) ) ); 81 this, SLOT( addConnectedDevices(ConnectionState::ValueList) ) );
82 connect( m_localDevice, SIGNAL( signalStrength(const QString&,const QString&) ), 82 connect( m_localDevice, SIGNAL( signalStrength(const QString&,const QString&) ),
83 this, SLOT( addSignalStrength(const QString&,const QString&) ) ); 83 this, SLOT( addSignalStrength(const QString&,const QString&) ) );
84 84
85 85
86 // let hold be rightButtonClicked() 86 // let hold be rightButtonClicked()
87 QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold); 87 QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold);
88 QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold); 88 QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold);
89 89
90 //Load all icons needed 90 //Load all icons needed
91 m_offPix = Resource::loadPixmap( "opietooth/notconnected" ); 91 m_offPix = Resource::loadPixmap( "opietooth/notconnected" );
92 m_onPix = Resource::loadPixmap( "opietooth/connected" ); 92 m_onPix = Resource::loadPixmap( "opietooth/connected" );
93 m_findPix = Resource::loadPixmap( "opietooth/find" ); 93 m_findPix = Resource::loadPixmap( "opietooth/find" );
94 94
95 QPalette pal = this->palette(); 95 QPalette pal = this->palette();
96 QColor col = pal.color( QPalette::Active, QColorGroup::Background ); 96 QColor col = pal.color( QPalette::Active, QColorGroup::Background );
97 pal.setColor( QPalette::Active, QColorGroup::Button, col ); 97 pal.setColor( QPalette::Active, QColorGroup::Button, col );
98 pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); 98 pal.setColor( QPalette::Inactive, QColorGroup::Button, col );
99 pal.setColor( QPalette::Normal, QColorGroup::Button, col ); 99 pal.setColor( QPalette::Normal, QColorGroup::Button, col );
100 pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); 100 pal.setColor( QPalette::Disabled, QColorGroup::Button, col );
101 this->setPalette( pal ); 101 this->setPalette( pal );
102 102
103 setCaption( tr( "Bluetooth Manager" ) ); 103 setCaption( tr( "Bluetooth Manager" ) );
104 104
105 readConfig(); 105 readConfig();
106 initGui(); 106 initGui();
107 107
108 ListView2->setRootIsDecorated(true); 108 ListView2->setRootIsDecorated(true);
109 109
110 110
111 writeToHciConfig(); 111 writeToHciConfig();
112 // search conncetions 112 // search conncetions
113 addConnectedDevices(); 113 addConnectedDevices();
114 addSignalStrength(); 114 addSignalStrength();
115 m_iconLoader = new BTIconLoader(); 115 m_iconLoader = new BTIconLoader();
116 readSavedDevices(); 116 readSavedDevices();
117} 117}
118 118
119/** 119/**
120 * Reads all options from the config file 120 * Reads all options from the config file
121 */ 121 */
122void BlueBase::readConfig() 122void BlueBase::readConfig()
123{ 123{
124 124
125 Config cfg( "bluetoothmanager" ); 125 Config cfg( "bluetoothmanager" );
126 cfg.setGroup( "bluezsettings" ); 126 cfg.setGroup( "bluezsettings" );
127 127
128 m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with 128 m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with
129 m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak 129 m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak
130 m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE ); 130 m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE );
131 m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE ); 131 m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE );
132 m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE ); 132 m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE );
133 m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE ); 133 m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE );
134} 134}
135 135
136/** 136/**
137 * Writes all options to the config file 137 * Writes all options to the config file
138 */ 138 */
139void BlueBase::writeConfig() 139void BlueBase::writeConfig()
140{ 140{
141 141
142 Config cfg( "bluetoothmanager" ); 142 Config cfg( "bluetoothmanager" );
143 cfg.setGroup( "bluezsettings" ); 143 cfg.setGroup( "bluezsettings" );
144 144
145 cfg.writeEntry( "name" , m_deviceName ); 145 cfg.writeEntry( "name" , m_deviceName );
146 cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); 146 cfg.writeEntryCrypt( "passkey" , m_defaultPasskey );
147 cfg.writeEntry( "useEncryption" , m_useEncryption ); 147 cfg.writeEntry( "useEncryption" , m_useEncryption );
148 cfg.writeEntry( "enableAuthentification" , m_enableAuthentification ); 148 cfg.writeEntry( "enableAuthentification" , m_enableAuthentification );
149 cfg.writeEntry( "enablePagescan" , m_enablePagescan ); 149 cfg.writeEntry( "enablePagescan" , m_enablePagescan );
150 cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan ); 150 cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan );
151 151
152 writeToHciConfig(); 152 writeToHciConfig();
153} 153}
154 154
155/** 155/**
156 * Modify the hcid.conf file to our needs 156 * Modify the hcid.conf file to our needs
157 */ 157 */
158void BlueBase::writeToHciConfig() 158void BlueBase::writeToHciConfig()
159{ 159{
160 owarn << "writeToHciConfig" << oendl; 160 owarn << "writeToHciConfig" << oendl;
161 HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" ); 161 HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" );
162 hciconf.load(); 162 hciconf.load();
163 hciconf.setPinHelper( "/opt/QtPalmtop/bin/bluepin" ); 163 hciconf.setPinHelper( QPEApplication::qpeDir() + "bin/bluepin" );
164 hciconf.setName( m_deviceName ); 164 hciconf.setName( m_deviceName );
165 hciconf.setEncrypt( m_useEncryption ); 165 hciconf.setEncrypt( m_useEncryption );
166 hciconf.setAuth( m_enableAuthentification ); 166 hciconf.setAuth( m_enableAuthentification );
167 hciconf.setPscan( m_enablePagescan ); 167 hciconf.setPscan( m_enablePagescan );
168 hciconf.setIscan( m_enableInquiryscan ); 168 hciconf.setIscan( m_enableInquiryscan );
169 hciconf.save(); 169 hciconf.save();
170} 170}
171 171
172 172
173/** 173/**
174 * Read the list of allready known devices 174 * Read the list of allready known devices
175 */ 175 */
176void BlueBase::readSavedDevices() 176void BlueBase::readSavedDevices()
177{ 177{
178 178
179 QValueList<RemoteDevice> loadedDevices; 179 QValueList<RemoteDevice> loadedDevices;
180 DeviceHandler handler; 180 DeviceHandler handler;
181 loadedDevices = handler.load(); 181 loadedDevices = handler.load();
182 182
183 addSearchedDevices( loadedDevices ); 183 addSearchedDevices( loadedDevices );
184} 184}
185 185
186 186
187/** 187/**
188 * Write the list of allready known devices 188 * Write the list of allready known devices
189 */ 189 */
190void BlueBase::writeSavedDevices() 190void BlueBase::writeSavedDevices()
191{ 191{
192 QListViewItemIterator it( ListView2 ); 192 QListViewItemIterator it( ListView2 );
193 BTListItem* item; 193 BTListItem* item;
194 BTDeviceItem* device; 194 BTDeviceItem* device;
195 RemoteDevice::ValueList list; 195 RemoteDevice::ValueList list;
196 for ( ; it.current(); ++it ) 196 for ( ; it.current(); ++it )
197 { 197 {
198 item = (BTListItem*)it.current(); 198 item = (BTListItem*)it.current();
199 if(item->typeId() != BTListItem::Device ) 199 if(item->typeId() != BTListItem::Device )
200 continue; 200 continue;
201 device = (BTDeviceItem*)item; 201 device = (BTDeviceItem*)item;
202 202
203 list.append( device->remoteDevice() ); 203 list.append( device->remoteDevice() );
204 } 204 }
205 /* 205 /*
206 * if not empty save the List through DeviceHandler 206 * if not empty save the List through DeviceHandler
207 */ 207 */
208 if ( list.isEmpty() ) 208 if ( list.isEmpty() )
209 return; 209 return;
210 DeviceHandler handler; 210 DeviceHandler handler;
211 handler.save( list ); 211 handler.save( list );
212} 212}
213 213
214 214
215/** 215/**
216 * Set up the gui 216 * Set up the gui
217 */ 217 */
218void BlueBase::initGui() 218void BlueBase::initGui()
219{ 219{
220 StatusLabel->setText( status() ); // maybe move it to getStatus() 220 StatusLabel->setText( status() ); // maybe move it to getStatus()
221 cryptCheckBox->setChecked( m_useEncryption ); 221 cryptCheckBox->setChecked( m_useEncryption );
222 authCheckBox->setChecked( m_enableAuthentification ); 222 authCheckBox->setChecked( m_enableAuthentification );
223 pagescanCheckBox->setChecked( m_enablePagescan ); 223 pagescanCheckBox->setChecked( m_enablePagescan );
224 inquiryscanCheckBox->setChecked( m_enableInquiryscan ); 224 inquiryscanCheckBox->setChecked( m_enableInquiryscan );
225 deviceNameLine->setText( m_deviceName ); 225 deviceNameLine->setText( m_deviceName );
226 passkeyLine->setText( m_defaultPasskey ); 226 passkeyLine->setText( m_defaultPasskey );
227 // set info tab 227 // set info tab
228 setInfo(); 228 setInfo();
229} 229}
230 230
231 231
232/** 232/**
233 * Get the status informations and returns it 233 * Get the status informations and returns it
234 * @return QString the status informations gathered 234 * @return QString the status informations gathered
235 */ 235 */
236QString BlueBase::status()const 236QString BlueBase::status()const
237{ 237{
238 QString infoString = tr( "<b>Device name : </b> Ipaq" ); 238 QString infoString = tr( "<b>Device name : </b> Ipaq" );
239 infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); 239 infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" );
240 infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); 240 infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" );
241 241
242 return (infoString); 242 return (infoString);
243} 243}
244 244
245 245
246/** 246/**
247 * Read the current values from the gui and invoke writeConfig() 247 * Read the current values from the gui and invoke writeConfig()
248 */ 248 */
249void BlueBase::applyConfigChanges() 249void BlueBase::applyConfigChanges()
250{ 250{
251 m_deviceName = deviceNameLine->text(); 251 m_deviceName = deviceNameLine->text();
252 m_defaultPasskey = passkeyLine->text(); 252 m_defaultPasskey = passkeyLine->text();
253 m_useEncryption = cryptCheckBox->isChecked(); 253 m_useEncryption = cryptCheckBox->isChecked();
254 m_enableAuthentification = authCheckBox->isChecked(); 254 m_enableAuthentification = authCheckBox->isChecked();
255 m_enablePagescan = pagescanCheckBox->isChecked(); 255 m_enablePagescan = pagescanCheckBox->isChecked();
256 m_enableInquiryscan = inquiryscanCheckBox->isChecked(); 256 m_enableInquiryscan = inquiryscanCheckBox->isChecked();
257 257
258 writeConfig(); 258 writeConfig();
259 259
260 QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); 260 QMessageBox::information( this, tr("Test") , tr("Changes were applied.") );
261} 261}
262 262
263/** 263/**
264 * Launch Rfcomm Bind dialog 264 * Launch Rfcomm Bind dialog
265 * 265 *
266 */ 266 */
267void BlueBase::rfcommDialog() 267void BlueBase::rfcommDialog()
268{ 268{
269 RfcommAssignDialog rfcommAssign ( this, "RfcommAssignDialog", true, WStyle_ContextHelp ); 269 RfcommAssignDialog rfcommAssign ( this, "RfcommAssignDialog", true, WStyle_ContextHelp );
270 270
271 if ( QPEApplication::execDialog( &rfcommAssign ) == QDialog::Accepted ) 271 if ( QPEApplication::execDialog( &rfcommAssign ) == QDialog::Accepted )
272 { 272 {
273 rfcommAssign.saveConfig(); 273 rfcommAssign.saveConfig();
274 } 274 }
275} 275}
276 276
277/** 277/**
278 * Add fresh found devices from scan dialog to the listing 278 * Add fresh found devices from scan dialog to the listing
279 * 279 *
280 */ 280 */
281void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) 281void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices )
282{ 282{
283 BTDeviceItem * deviceItem; 283 BTDeviceItem * deviceItem;
284 QValueList<RemoteDevice>::ConstIterator it; 284 QValueList<RemoteDevice>::ConstIterator it;
285 285
286 for( it = newDevices.begin(); it != newDevices.end() ; ++it ) 286 for( it = newDevices.begin(); it != newDevices.end() ; ++it )
287 { 287 {
288 288
289 if (find( (*it) )) // is already inserted 289 if (find( (*it) )) // is already inserted
290 continue; 290 continue;
291 291
292 deviceItem = new BTDeviceItem( ListView2 , (*it) ); 292 deviceItem = new BTDeviceItem( ListView2 , (*it) );
293 deviceItem->setPixmap( 1, m_findPix ); 293 deviceItem->setPixmap( 1, m_findPix );
294 deviceItem->setExpandable ( true ); 294 deviceItem->setExpandable ( true );
295 295
296 // look if device is avail. atm, async 296 // look if device is avail. atm, async
297 deviceActive( (*it) ); 297 deviceActive( (*it) );
298 298
299 // ggf auch hier? 299 // ggf auch hier?
300 addServicesToDevice( deviceItem ); 300 addServicesToDevice( deviceItem );
301 } 301 }
302} 302}
303 303
304 304
305/** 305/**
306 * Action that is toggled on entrys on click 306 * Action that is toggled on entrys on click
307 */ 307 */
308void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) 308void BlueBase::startServiceActionClicked( QListViewItem */*item*/ )
309{} 309{}
310 310
311 311
312/** 312/**
313 * Action that are toggled on hold (mostly QPopups i guess) 313 * Action that are toggled on hold (mostly QPopups i guess)
314 */ 314 */
315void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) 315void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ )
316{ 316{
317 if (!item ) 317 if (!item )
318 return; 318 return;
319 319
320 QPopupMenu *menu = new QPopupMenu(); 320 QPopupMenu *menu = new QPopupMenu();
321 int ret=0; 321 int ret=0;
322 322
323 if ( ((BTListItem*)item)->type() == "device") 323 if ( ((BTListItem*)item)->type() == "device")
324 { 324 {
325 325
326 QPopupMenu *groups = new QPopupMenu(); 326 QPopupMenu *groups = new QPopupMenu();
327 327
328 menu->insertItem( ((BTDeviceItem*)item)->name(),0 ); 328 menu->insertItem( ((BTDeviceItem*)item)->name(),0 );
329 menu->insertSeparator(1); 329 menu->insertSeparator(1);
330 menu->insertItem( tr("rescan sevices"), 2); 330 menu->insertItem( tr("rescan sevices"), 2);
331 menu->insertItem( tr("to group"), groups , 3); 331 menu->insertItem( tr("to group"), groups , 3);
332 menu->insertItem( tr("delete"), 4); 332 menu->insertItem( tr("delete"), 4);
333 333
334 ret = menu->exec( point , 0); 334 ret = menu->exec( point , 0);
335 335
336 switch(ret) 336 switch(ret)
337 { 337 {
338 case -1: 338 case -1:
339 break; 339 break;
340 case 2: 340 case 2:
341 addServicesToDevice( (BTDeviceItem*)item ); 341 addServicesToDevice( (BTDeviceItem*)item );
342 break; 342 break;
343 343
344 case 4: 344 case 4:
345 // deletes childs too 345 // deletes childs too
346 delete item; 346 delete item;
347 break; 347 break;
348 } 348 }
349 delete groups; 349 delete groups;
350 350
351 } 351 }
352 352
353 /* 353 /*
354 * We got service sensitive PopupMenus in our factory 354 * We got service sensitive PopupMenus in our factory
355 * We will create one through the factory and will insert 355 * We will create one through the factory and will insert
diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp
index 3616507..9dfb2af 100644
--- a/noncore/settings/usermanager/userdialog.cpp
+++ b/noncore/settings/usermanager/userdialog.cpp
@@ -76,413 +76,413 @@ void UserDialog::setupTab1()
76 76
77 // Picture 77 // Picture
78 picturePushButton = new QPushButton(tabpage,"Label"); 78 picturePushButton = new QPushButton(tabpage,"Label");
79 picturePushButton->setMinimumSize(48,48); 79 picturePushButton->setMinimumSize(48,48);
80 picturePushButton->setMaximumSize(48,48); 80 picturePushButton->setMaximumSize(48,48);
81 picturePushButton->setPixmap(Resource::loadPixmap("usermanager/usericon")); // Load default usericon. 81 picturePushButton->setPixmap(Resource::loadPixmap("usermanager/usericon")); // Load default usericon.
82 connect(picturePushButton,SIGNAL(clicked()),this,SLOT(clickedPicture())); // Clicking the picture should invoke pictureselector. 82 connect(picturePushButton,SIGNAL(clicked()),this,SLOT(clickedPicture())); // Clicking the picture should invoke pictureselector.
83 83
84 // Login 84 // Login
85 QLabel *loginLabel=new QLabel(tabpage,"Login: "); 85 QLabel *loginLabel=new QLabel(tabpage,"Login: ");
86 loginLabel->setText("Login: "); 86 loginLabel->setText("Login: ");
87 loginLineEdit=new QLineEdit(tabpage,"Login: "); 87 loginLineEdit=new QLineEdit(tabpage,"Login: ");
88 88
89 // UID 89 // UID
90 QLabel *uidLabel=new QLabel(tabpage,"uid: "); 90 QLabel *uidLabel=new QLabel(tabpage,"uid: ");
91 uidLabel->setText("UserID: "); 91 uidLabel->setText("UserID: ");
92 uidLineEdit=new QLineEdit(tabpage,"uid: "); 92 uidLineEdit=new QLineEdit(tabpage,"uid: ");
93 uidLineEdit->setEnabled(false); 93 uidLineEdit->setEnabled(false);
94 94
95 // Username (gecos) 95 // Username (gecos)
96 QLabel *gecosLabel=new QLabel(tabpage,"gecos"); 96 QLabel *gecosLabel=new QLabel(tabpage,"gecos");
97 gecosLabel->setText("Username: "); 97 gecosLabel->setText("Username: ");
98 gecosLineEdit=new QLineEdit(tabpage,"gecos"); 98 gecosLineEdit=new QLineEdit(tabpage,"gecos");
99 99
100 // Password 100 // Password
101 QLabel *passwordLabel=new QLabel(tabpage,"password"); 101 QLabel *passwordLabel=new QLabel(tabpage,"password");
102 passwordLabel->setText("Password: "); 102 passwordLabel->setText("Password: ");
103 passwordLineEdit=new QLineEdit(tabpage,"password"); 103 passwordLineEdit=new QLineEdit(tabpage,"password");
104 passwordLineEdit->setEchoMode(QLineEdit::Password); 104 passwordLineEdit->setEchoMode(QLineEdit::Password);
105 105
106 // Shell 106 // Shell
107 QLabel *shellLabel=new QLabel(tabpage,"shell"); 107 QLabel *shellLabel=new QLabel(tabpage,"shell");
108 shellLabel->setText("Shell: "); 108 shellLabel->setText("Shell: ");
109 shellComboBox=new QComboBox(tabpage,"shell"); 109 shellComboBox=new QComboBox(tabpage,"shell");
110 shellComboBox->setEditable(true); 110 shellComboBox->setEditable(true);
111 shellComboBox->insertItem("/bin/sh"); 111 shellComboBox->insertItem("/bin/sh");
112 shellComboBox->insertItem("/bin/ash"); 112 shellComboBox->insertItem("/bin/ash");
113 shellComboBox->insertItem("/bin/false"); 113 shellComboBox->insertItem("/bin/false");
114 114
115 // Primary Group 115 // Primary Group
116 QLabel *groupLabel=new QLabel(tabpage,"group"); 116 QLabel *groupLabel=new QLabel(tabpage,"group");
117 groupLabel->setText("Primary group: "); 117 groupLabel->setText("Primary group: ");
118 groupComboBox=new QComboBox(tabpage,"PrimaryGroup"); 118 groupComboBox=new QComboBox(tabpage,"PrimaryGroup");
119 119
120 if(vm==VIEWMODE_NEW) 120 if(vm==VIEWMODE_NEW)
121 { 121 {
122 // Copy /etc/skel 122 // Copy /etc/skel
123 skelLabel=new QLabel(tabpage,"skel"); 123 skelLabel=new QLabel(tabpage,"skel");
124 skelLabel->setText("Copy /etc/skel: "); 124 skelLabel->setText("Copy /etc/skel: ");
125 skelCheckBox=new QCheckBox(tabpage); 125 skelCheckBox=new QCheckBox(tabpage);
126 skelCheckBox->setChecked(true); 126 skelCheckBox->setChecked(true);
127 } 127 }
128 128
129 // Widget layout 129 // Widget layout
130 QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout"); 130 QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout");
131 layout->addWidget(picturePushButton); 131 layout->addWidget(picturePushButton);
132 layout->addSpacing(5); 132 layout->addSpacing(5);
133 layout->addLayout(hlayout); 133 layout->addLayout(hlayout);
134 QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1"); 134 QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1");
135 QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2"); 135 QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2");
136 // First column, labels 136 // First column, labels
137 vlayout1->addWidget(loginLabel); 137 vlayout1->addWidget(loginLabel);
138 vlayout1->addSpacing(5); 138 vlayout1->addSpacing(5);
139 vlayout1->addWidget(uidLabel); 139 vlayout1->addWidget(uidLabel);
140 vlayout1->addSpacing(5); 140 vlayout1->addSpacing(5);
141 vlayout1->addWidget(gecosLabel); 141 vlayout1->addWidget(gecosLabel);
142 vlayout1->addSpacing(5); 142 vlayout1->addSpacing(5);
143 vlayout1->addWidget(passwordLabel); 143 vlayout1->addWidget(passwordLabel);
144 vlayout1->addSpacing(5); 144 vlayout1->addSpacing(5);
145 vlayout1->addWidget(shellLabel); 145 vlayout1->addWidget(shellLabel);
146 vlayout1->addSpacing(5); 146 vlayout1->addSpacing(5);
147 vlayout1->addWidget(groupLabel); 147 vlayout1->addWidget(groupLabel);
148 if(vm==VIEWMODE_NEW) 148 if(vm==VIEWMODE_NEW)
149 { 149 {
150 vlayout1->addSpacing(5); 150 vlayout1->addSpacing(5);
151 vlayout1->addWidget(skelLabel); 151 vlayout1->addWidget(skelLabel);
152 } 152 }
153 // Second column, data 153 // Second column, data
154 vlayout2->addWidget(loginLineEdit); 154 vlayout2->addWidget(loginLineEdit);
155 vlayout2->addSpacing(5); 155 vlayout2->addSpacing(5);
156 vlayout2->addWidget(uidLineEdit); 156 vlayout2->addWidget(uidLineEdit);
157 vlayout2->addSpacing(5); 157 vlayout2->addSpacing(5);
158 vlayout2->addWidget(gecosLineEdit); 158 vlayout2->addWidget(gecosLineEdit);
159 vlayout2->addSpacing(5); 159 vlayout2->addSpacing(5);
160 vlayout2->addWidget(passwordLineEdit); 160 vlayout2->addWidget(passwordLineEdit);
161 vlayout2->addSpacing(5); 161 vlayout2->addSpacing(5);
162 vlayout2->addWidget(shellComboBox); 162 vlayout2->addWidget(shellComboBox);
163 vlayout2->addSpacing(5); 163 vlayout2->addSpacing(5);
164 vlayout2->addWidget(groupComboBox); 164 vlayout2->addWidget(groupComboBox);
165 if(vm==VIEWMODE_NEW) 165 if(vm==VIEWMODE_NEW)
166 { 166 {
167 vlayout2->addSpacing(5); 167 vlayout2->addSpacing(5);
168 vlayout2->addWidget(skelCheckBox); 168 vlayout2->addWidget(skelCheckBox);
169 } 169 }
170 hlayout->addLayout(vlayout1); 170 hlayout->addLayout(vlayout1);
171 hlayout->addLayout(vlayout2); 171 hlayout->addLayout(vlayout2);
172 172
173 myTabWidget->addTab(tabpage,"User Info"); 173 myTabWidget->addTab(tabpage,"User Info");
174} 174}
175 175
176/** 176/**
177 * Creates the second tab containing additional groups for the user. 177 * Creates the second tab containing additional groups for the user.
178 * 178 *
179 */ 179 */
180void UserDialog::setupTab2() 180void UserDialog::setupTab2()
181{ 181{
182 QWidget *tabpage = new QWidget(myTabWidget,"page2"); 182 QWidget *tabpage = new QWidget(myTabWidget,"page2");
183 QVBoxLayout *layout = new QVBoxLayout(tabpage); 183 QVBoxLayout *layout = new QVBoxLayout(tabpage);
184 layout->setMargin(5); 184 layout->setMargin(5);
185 185
186 // Additional groups 186 // Additional groups
187 groupsListView=new QListView(tabpage,"groups"); 187 groupsListView=new QListView(tabpage,"groups");
188 groupsListView->addColumn("Additional groups"); 188 groupsListView->addColumn("Additional groups");
189 groupsListView->setColumnWidthMode(0,QListView::Maximum); 189 groupsListView->setColumnWidthMode(0,QListView::Maximum);
190 groupsListView->setMultiSelection(false); 190 groupsListView->setMultiSelection(false);
191 groupsListView->setAllColumnsShowFocus(false); 191 groupsListView->setAllColumnsShowFocus(false);
192 192
193 layout->addSpacing(5); 193 layout->addSpacing(5);
194 // Grouplist 194 // Grouplist
195 layout->addWidget(groupsListView); 195 layout->addWidget(groupsListView);
196 196
197 myTabWidget->addTab(tabpage,"User Groups"); 197 myTabWidget->addTab(tabpage,"User Groups");
198} 198}
199 199
200/** 200/**
201 * Static function that creates the userinfo dialog. 201 * Static function that creates the userinfo dialog.
202 * The user will be prompted to add a user. 202 * The user will be prompted to add a user.
203 * 203 *
204 * @param uid This is a suggested available UID. 204 * @param uid This is a suggested available UID.
205 * @param gid This is a suggested available GID. 205 * @param gid This is a suggested available GID.
206 * 206 *
207 * @return <code>true</code> if the user was successfully added, otherwise <code>false</code>. 207 * @return <code>true</code> if the user was successfully added, otherwise <code>false</code>.
208 * 208 *
209 */ 209 */
210bool UserDialog::addUser(int uid, int gid) 210bool UserDialog::addUser(int uid, int gid)
211{ 211{
212 QCheckListItem *temp; 212 QCheckListItem *temp;
213 QFile ozTest; 213 QFile ozTest;
214 int oz=false; 214 int oz=false;
215 if(ODevice::inst()->system()==System_OpenZaurus) oz=true; 215 if(ODevice::inst()->system()==System_OpenZaurus) oz=true;
216 // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating adduserDialog's widgets here. 216 // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating adduserDialog's widgets here.
217 UserDialog *adduserDialog=new UserDialog(VIEWMODE_NEW); 217 UserDialog *adduserDialog=new UserDialog(VIEWMODE_NEW);
218 adduserDialog->setCaption(tr("Add User")); 218 adduserDialog->setCaption(tr("Add User"));
219 adduserDialog->userID=uid; // Set next available UID as default uid. 219 adduserDialog->userID=uid; // Set next available UID as default uid.
220 adduserDialog->groupID=gid; // Set next available GID as default gid. 220 adduserDialog->groupID=gid; // Set next available GID as default gid.
221 // Insert default group into groupComboBox 221 // Insert default group into groupComboBox
222 adduserDialog->groupComboBox->insertItem("<create new group>",0); 222 adduserDialog->groupComboBox->insertItem("<create new group>",0);
223 adduserDialog->uidLineEdit->setText(QString::number(uid)); 223 adduserDialog->uidLineEdit->setText(QString::number(uid));
224 // If we're running on OZ, add new users to some default groups. 224 // If we're running on OZ, add new users to some default groups.
225 if(oz) 225 if(oz)
226 { 226 {
227 QListViewItemIterator iter( adduserDialog->groupsListView ); 227 QListViewItemIterator iter( adduserDialog->groupsListView );
228 for ( ; iter.current(); ++iter ) 228 for ( ; iter.current(); ++iter )
229 { 229 {
230 temp=(QCheckListItem*)iter.current(); 230 temp=(QCheckListItem*)iter.current();
231 if (temp->text()=="video") temp->setOn(true); 231 if (temp->text()=="video") temp->setOn(true);
232 if (temp->text()=="audio") temp->setOn(true); 232 if (temp->text()=="audio") temp->setOn(true);
233 if (temp->text()=="time") temp->setOn(true); 233 if (temp->text()=="time") temp->setOn(true);
234 if (temp->text()=="power") temp->setOn(true); 234 if (temp->text()=="power") temp->setOn(true);
235 if (temp->text()=="input") temp->setOn(true); 235 if (temp->text()=="input") temp->setOn(true);
236 if (temp->text()=="sharp") temp->setOn(true); 236 if (temp->text()=="sharp") temp->setOn(true);
237 if (temp->text()=="tty") temp->setOn(true); 237 if (temp->text()=="tty") temp->setOn(true);
238 } 238 }
239 } 239 }
240 // Show the dialog! 240 // Show the dialog!
241 if(!(adduserDialog->exec())) return false; 241 if(!(adduserDialog->exec())) return false;
242 if((adduserDialog->groupComboBox->currentItem()!=0)) 242 if((adduserDialog->groupComboBox->currentItem()!=0))
243 { 243 {
244 accounts->findGroup(adduserDialog->groupComboBox->currentText()); 244 accounts->findGroup(adduserDialog->groupComboBox->currentText());
245 adduserDialog->groupID=accounts->gr_gid; 245 adduserDialog->groupID=accounts->gr_gid;
246 owarn << QString::number(accounts->gr_gid) << oendl; 246 owarn << QString::number(accounts->gr_gid) << oendl;
247 } 247 }
248 if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(), 248 if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(),
249 adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(), 249 adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(),
250 QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) 250 QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText())))
251 { 251 {
252 QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user."); 252 QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user.");
253 return false; 253 return false;
254 } 254 }
255 255
256 // Add User to additional groups. 256 // Add User to additional groups.
257 QListViewItemIterator it( adduserDialog->groupsListView ); 257 QListViewItemIterator it( adduserDialog->groupsListView );
258 for ( ; it.current(); ++it ) 258 for ( ; it.current(); ++it )
259 { 259 {
260 temp=(QCheckListItem*)it.current(); 260 temp=(QCheckListItem*)it.current();
261 if (temp->isOn() ) 261 if (temp->isOn() )
262 accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text()); 262 accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text());
263 } 263 }
264 // Copy image to pics/users/ 264 // Copy image to pics/users/
265 if(!(adduserDialog->userImage.isNull())) 265 if(!(adduserDialog->userImage.isNull()))
266 { 266 {
267 QDir d; 267 QDir d;
268 if(!(d.exists("/opt/QtPalmtop/pics/users"))) 268 if(!(d.exists(QPEApplication::qpeDir() + "pics/users")))
269 { 269 {
270 d.mkdir("/opt/QtPalmtop/pics/users"); 270 d.mkdir(QPEApplication::qpeDir() + "pics/users");
271 } 271 }
272 QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; 272 QString filename= QPEApplication::qpeDir()+"pics/users/"+accounts->pw_name+".png";
273 // adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48); 273 // adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48);
274 adduserDialog->userImage.save(filename,"PNG"); 274 adduserDialog->userImage.save(filename,"PNG");
275 } 275 }
276 276
277 // Should we copy the skeleton homedirectory /etc/skel to the user's homedirectory? 277 // Should we copy the skeleton homedirectory /etc/skel to the user's homedirectory?
278 accounts->findUser(adduserDialog->loginLineEdit->text()); 278 accounts->findUser(adduserDialog->loginLineEdit->text());
279 if(adduserDialog->skelCheckBox->isChecked()) 279 if(adduserDialog->skelCheckBox->isChecked())
280 { 280 {
281 QString command_cp; 281 QString command_cp;
282 QString command_chown; 282 QString command_chown;
283 command_cp.sprintf("cp -a /etc/skel/* %s/",accounts->pw_dir.latin1()); 283 command_cp.sprintf("cp -a /etc/skel/* %s/",accounts->pw_dir.latin1());
284 system(command_cp); 284 system(command_cp);
285 285
286 command_cp.sprintf("cp -a /etc/skel/.[!.]* %s/",accounts->pw_dir.latin1()); // Bug in busybox, ".*" includes parent directory, does this work as a workaround? 286 command_cp.sprintf("cp -a /etc/skel/.[!.]* %s/",accounts->pw_dir.latin1()); // Bug in busybox, ".*" includes parent directory, does this work as a workaround?
287 system(command_cp); 287 system(command_cp);
288 288
289 command_chown.sprintf("chown -R %d:%d %s",accounts->pw_uid,accounts->pw_gid,accounts->pw_dir.latin1()); 289 command_chown.sprintf("chown -R %d:%d %s",accounts->pw_uid,accounts->pw_gid,accounts->pw_dir.latin1());
290 system(command_chown); 290 system(command_chown);
291 } 291 }
292 292
293 return true; 293 return true;
294} 294}
295 295
296/** 296/**
297 * Deletes the user account. 297 * Deletes the user account.
298 * 298 *
299 * @param username User to be deleted. 299 * @param username User to be deleted.
300 * 300 *
301 * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. 301 * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>.
302 * 302 *
303 */ 303 */
304bool UserDialog::delUser(const char *username) 304bool UserDialog::delUser(const char *username)
305{ 305{
306 if((accounts->findUser(username))) 306 if((accounts->findUser(username)))
307 { // Does that user exist? 307 { // Does that user exist?
308 if(!(accounts->delUser(username))) 308 if(!(accounts->delUser(username)))
309 { // Delete the user. 309 { // Delete the user.
310 QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete user: "+QString(username)+"."); 310 QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete user: "+QString(username)+".");
311 } 311 }
312 } 312 }
313 else 313 else
314 { 314 {
315 QMessageBox::information(0,"Invalid Username","That username ("+QString(username)+")does not exist."); 315 QMessageBox::information(0,"Invalid Username","That username ("+QString(username)+")does not exist.");
316 return false; 316 return false;
317 } 317 }
318 return true; 318 return true;
319} 319}
320 320
321/** 321/**
322 * This displays a confirmation dialog wether a user should be deleted or not. 322 * This displays a confirmation dialog wether a user should be deleted or not.
323 * (And also deletes the account) 323 * (And also deletes the account)
324 * 324 *
325 * @param username User to be deleted. 325 * @param username User to be deleted.
326 * 326 *
327 * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. 327 * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>.
328 * 328 *
329 */ 329 */
330bool UserDialog::editUser(const char *username) 330bool UserDialog::editUser(const char *username)
331{ 331{
332 int invalid_group=0; 332 int invalid_group=0;
333 // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating edituserDialog's widgets here. 333 // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating edituserDialog's widgets here.
334 UserDialog *edituserDialog=new UserDialog(VIEWMODE_EDIT); // Create Dialog 334 UserDialog *edituserDialog=new UserDialog(VIEWMODE_EDIT); // Create Dialog
335 edituserDialog->setCaption(tr("Edit User")); 335 edituserDialog->setCaption(tr("Edit User"));
336 accounts->findUser(username); // Locate user in database and fill variables in 'accounts' object. 336 accounts->findUser(username); // Locate user in database and fill variables in 'accounts' object.
337 if(!(accounts->findGroup(accounts->pw_gid))) 337 if(!(accounts->findGroup(accounts->pw_gid)))
338 { // Locate the user's primary group, and fill group variables in 'accounts' object. 338 { // Locate the user's primary group, and fill group variables in 'accounts' object.
339 invalid_group=1; 339 invalid_group=1;
340 } 340 }
341 // Fill widgets with userinfo. 341 // Fill widgets with userinfo.
342 edituserDialog->loginLineEdit->setText(accounts->pw_name); 342 edituserDialog->loginLineEdit->setText(accounts->pw_name);
343 edituserDialog->uidLineEdit->setText(QString::number(accounts->pw_uid)); 343 edituserDialog->uidLineEdit->setText(QString::number(accounts->pw_uid));
344 edituserDialog->gecosLineEdit->setText(accounts->pw_gecos); 344 edituserDialog->gecosLineEdit->setText(accounts->pw_gecos);
345 // Set password to '........', we will later check if this still is the contents, if not, the password has been changed. 345 // Set password to '........', we will later check if this still is the contents, if not, the password has been changed.
346 edituserDialog->passwordLineEdit->setText("........"); 346 edituserDialog->passwordLineEdit->setText("........");
347 // If this user is not using /bin/sh,/bin/ash or /bin/false as shell, add that entry to the shell-combobox. 347 // If this user is not using /bin/sh,/bin/ash or /bin/false as shell, add that entry to the shell-combobox.
348 if(accounts->pw_shell!="/bin/sh" && accounts->pw_shell!="/bin/ash" && accounts->pw_shell!="/bin/false") 348 if(accounts->pw_shell!="/bin/sh" && accounts->pw_shell!="/bin/ash" && accounts->pw_shell!="/bin/false")
349 { 349 {
350 edituserDialog->shellComboBox->insertItem(accounts->pw_shell,0); 350 edituserDialog->shellComboBox->insertItem(accounts->pw_shell,0);
351 edituserDialog->shellComboBox->setCurrentItem(0); 351 edituserDialog->shellComboBox->setCurrentItem(0);
352 } 352 }
353 // Select the primary group for this user. 353 // Select the primary group for this user.
354 for(int i=0;i<edituserDialog->groupComboBox->count();++i) 354 for(int i=0;i<edituserDialog->groupComboBox->count();++i)
355 { 355 {
356 if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) 356 if(accounts->gr_name==edituserDialog->groupComboBox->text(i))
357 { 357 {
358 edituserDialog->groupComboBox->setCurrentItem(i); 358 edituserDialog->groupComboBox->setCurrentItem(i);
359 break; 359 break;
360 } 360 }
361 } 361 }
362 if(invalid_group) 362 if(invalid_group)
363 { 363 {
364 edituserDialog->groupComboBox->insertItem("<Undefined group>",0); 364 edituserDialog->groupComboBox->insertItem("<Undefined group>",0);
365 edituserDialog->groupComboBox->setCurrentItem(0); 365 edituserDialog->groupComboBox->setCurrentItem(0);
366 } 366 }
367 367
368 // Select the groups in the listview, to which the user belongs. 368 // Select the groups in the listview, to which the user belongs.
369 QCheckListItem *temp; 369 QCheckListItem *temp;
370 // BAH!!! QRegExp in qt2 sucks... or maybe I do... can't figure out how to check for EITHER end of input ($) OR a comma, so here we do two different QRegExps instead. 370 // BAH!!! QRegExp in qt2 sucks... or maybe I do... can't figure out how to check for EITHER end of input ($) OR a comma, so here we do two different QRegExps instead.
371 QRegExp userRegExp(QString("[:,]%1$").arg(username)); // The end of line variant. 371 QRegExp userRegExp(QString("[:,]%1$").arg(username)); // The end of line variant.
372 QStringList tempList=accounts->groupStringList.grep(userRegExp); // Find all entries in the group database, that the user is a member of. 372 QStringList tempList=accounts->groupStringList.grep(userRegExp); // Find all entries in the group database, that the user is a member of.
373 for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) 373 for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it)
374 { // Iterate over all of them. 374 { // Iterate over all of them.
375 owarn << *it << oendl; 375 owarn << *it << oendl;
376 QListViewItemIterator lvit( edituserDialog->groupsListView ); // Compare to all groups. 376 QListViewItemIterator lvit( edituserDialog->groupsListView ); // Compare to all groups.
377 for ( ; lvit.current(); ++lvit ) 377 for ( ; lvit.current(); ++lvit )
378 { 378 {
379 if(lvit.current()->text(0)==(*it).left((*it).find(":"))) 379 if(lvit.current()->text(0)==(*it).left((*it).find(":")))
380 { 380 {
381 temp=(QCheckListItem*)lvit.current(); 381 temp=(QCheckListItem*)lvit.current();
382 temp->setOn(true); // If we find a line with that groupname, select it.; 382 temp->setOn(true); // If we find a line with that groupname, select it.;
383 } 383 }
384 } 384 }
385 } 385 }
386 userRegExp=QRegExp(QString("[:,]%1,").arg(username)); // And the other one. (not end of line.) 386 userRegExp=QRegExp(QString("[:,]%1,").arg(username)); // And the other one. (not end of line.)
387 tempList=accounts->groupStringList.grep(userRegExp); // Find all entries in the group database, that the user is a member of. 387 tempList=accounts->groupStringList.grep(userRegExp); // Find all entries in the group database, that the user is a member of.
388 for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) 388 for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it)
389 { // Iterate over all of them. 389 { // Iterate over all of them.
390 owarn << *it << oendl; 390 owarn << *it << oendl;
391 QListViewItemIterator lvit( edituserDialog->groupsListView ); // Compare to all groups. 391 QListViewItemIterator lvit( edituserDialog->groupsListView ); // Compare to all groups.
392 for ( ; lvit.current(); ++lvit ) 392 for ( ; lvit.current(); ++lvit )
393 { 393 {
394 if(lvit.current()->text(0)==(*it).left((*it).find(":"))) 394 if(lvit.current()->text(0)==(*it).left((*it).find(":")))
395 { 395 {
396 temp=(QCheckListItem*)lvit.current(); 396 temp=(QCheckListItem*)lvit.current();
397 temp->setOn(true); // If we find a line with that groupname, select it.; 397 temp->setOn(true); // If we find a line with that groupname, select it.;
398 } 398 }
399 } 399 }
400 } 400 }
401 401
402 if(!(edituserDialog->exec())) return false; // SHOW THE DIALOG! 402 if(!(edituserDialog->exec())) return false; // SHOW THE DIALOG!
403 403
404 accounts->findUser(username); // Fill user variables in 'acccounts' object. 404 accounts->findUser(username); // Fill user variables in 'acccounts' object.
405 accounts->pw_name=edituserDialog->loginLineEdit->text(); 405 accounts->pw_name=edituserDialog->loginLineEdit->text();
406 // Has the password been changed ? Make a new "crypt":ed password. 406 // Has the password been changed ? Make a new "crypt":ed password.
407 if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt()); 407 if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt());
408 408
409 // Set all variables in accounts object, that will be used when calling 'updateUser()' 409 // Set all variables in accounts object, that will be used when calling 'updateUser()'
410 accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt(); 410 accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt();
411 if(accounts->findGroup(edituserDialog->groupComboBox->currentText())) 411 if(accounts->findGroup(edituserDialog->groupComboBox->currentText()))
412 { // Fill all group variables in 'accounts' object. 412 { // Fill all group variables in 'accounts' object.
413 accounts->pw_gid=accounts->gr_gid; // Only do this if the group is a valid group (ie. "<Undefined group>"), otherwise keep the old group. 413 accounts->pw_gid=accounts->gr_gid; // Only do this if the group is a valid group (ie. "<Undefined group>"), otherwise keep the old group.
414 } 414 }
415 accounts->pw_gecos=edituserDialog->gecosLineEdit->text(); 415 accounts->pw_gecos=edituserDialog->gecosLineEdit->text();
416 accounts->pw_shell=edituserDialog->shellComboBox->currentText(); 416 accounts->pw_shell=edituserDialog->shellComboBox->currentText();
417 // Update userinfo, using the information stored in the user variables stored in the accounts object. 417 // Update userinfo, using the information stored in the user variables stored in the accounts object.
418 accounts->updateUser(username); 418 accounts->updateUser(username);
419 419
420 // Remove user from all groups he/she is a member of. (could be done in a better way I guess, this was simple though.) 420 // Remove user from all groups he/she is a member of. (could be done in a better way I guess, this was simple though.)
421 for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) 421 for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it)
422 { 422 {
423 accounts->delGroupMember((*it).left((*it).find(":")),username); 423 accounts->delGroupMember((*it).left((*it).find(":")),username);
424 } 424 }
425 425
426 // Add User to additional groups that he/she is a member of. 426 // Add User to additional groups that he/she is a member of.
427 QListViewItemIterator it( edituserDialog->groupsListView ); 427 QListViewItemIterator it( edituserDialog->groupsListView );
428 for ( ; it.current(); ++it ) 428 for ( ; it.current(); ++it )
429 { 429 {
430 temp=(QCheckListItem*)it.current(); 430 temp=(QCheckListItem*)it.current();
431 if ( temp->isOn() ) 431 if ( temp->isOn() )
432 accounts->addGroupMember(it.current()->text(0),edituserDialog->loginLineEdit->text()); 432 accounts->addGroupMember(it.current()->text(0),edituserDialog->loginLineEdit->text());
433 } 433 }
434 434
435 // Copy image to pics/users/ 435 // Copy image to pics/users/
436 if(!(edituserDialog->userImage.isNull())) 436 if(!(edituserDialog->userImage.isNull()))
437 { 437 {
438 QDir d; 438 QDir d;
439 if(!(d.exists("/opt/QtPalmtop/pics/users"))) 439 if(!(d.exists(QPEApplication::qpeDir()+"pics/users")))
440 { 440 {
441 d.mkdir("/opt/QtPalmtop/pics/users"); 441 d.mkdir(QPEApplication::qpeDir()+"pics/users");
442 } 442 }
443 QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; 443 QString filename=QPEApplication::qpeDir()+"pics/users/"+accounts->pw_name+".png";
444 // edituserDialog->userImage=edituserDialog->userImage.smoothScale(48,48); 444 // edituserDialog->userImage=edituserDialog->userImage.smoothScale(48,48);
445 edituserDialog->userImage.save(filename,"PNG"); 445 edituserDialog->userImage.save(filename,"PNG");
446 } 446 }
447 return true; 447 return true;
448} 448}
449 449
450/** 450/**
451 * "OK" has been clicked. Verify some information before closing the dialog. 451 * "OK" has been clicked. Verify some information before closing the dialog.
452 * 452 *
453 */ 453 */
454void UserDialog::accept() 454void UserDialog::accept()
455{ 455{
456 // Add checking... valid username? username taken? 456 // Add checking... valid username? username taken?
457 if(loginLineEdit->text().isEmpty()) 457 if(loginLineEdit->text().isEmpty())
458 { 458 {
459 QMessageBox::information(0,"Empty Login","Please enter a login."); 459 QMessageBox::information(0,"Empty Login","Please enter a login.");
460 return; 460 return;
461 } 461 }
462 QDialog::accept(); 462 QDialog::accept();
463} 463}
464 464
465/** 465/**
466 * This slot is called when the usericon is clicked, this loads (should) the iconselector. 466 * This slot is called when the usericon is clicked, this loads (should) the iconselector.
467 * 467 *
468 */ 468 */
469void UserDialog::clickedPicture() 469void UserDialog::clickedPicture()
470{ 470{
471 QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED, QString::null); 471 QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED, QString::null);
472 if(!(filename.isEmpty())) 472 if(!(filename.isEmpty()))
473 { 473 {
474 userImage.reset(); 474 userImage.reset();
475 if(!(userImage.load(filename))) 475 if(!(userImage.load(filename)))
476 { 476 {
477 QMessageBox::information(0,"Sorry!","That icon could not be loaded.\nLoading failed on: "+filename); 477 QMessageBox::information(0,"Sorry!","That icon could not be loaded.\nLoading failed on: "+filename);
478 } 478 }
479 else 479 else
480 { 480 {
481 // userImage=userImage.smoothScale(48,48); 481 // userImage=userImage.smoothScale(48,48);
482 QPixmap *picture; 482 QPixmap *picture;
483 picture=(QPixmap *)picturePushButton->pixmap(); 483 picture=(QPixmap *)picturePushButton->pixmap();
484 picture->convertFromImage(userImage,0); 484 picture->convertFromImage(userImage,0);
485 picturePushButton->update(); 485 picturePushButton->update();
486 } 486 }
487 } 487 }
488} 488}