summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-11-05 10:41:28 (UTC)
committer llornkcor <llornkcor>2003-11-05 10:41:28 (UTC)
commite6bb5b92e21ad08d00e399f30abeaea22f08ca18 (patch) (unidiff)
treeabfaef874a2c729340ba04d9d94c4a0be0955165
parent15163234024750178829812f31a1e7173a66fa1d (diff)
downloadopie-e6bb5b92e21ad08d00e399f30abeaea22f08ca18.zip
opie-e6bb5b92e21ad08d00e399f30abeaea22f08ca18.tar.gz
opie-e6bb5b92e21ad08d00e399f30abeaea22f08ca18.tar.bz2
remove <<<<<<
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/security/security.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/settings/security/security.cpp b/core/settings/security/security.cpp
index 00ea105..42a39c2 100644
--- a/core/settings/security/security.cpp
+++ b/core/settings/security/security.cpp
@@ -1,325 +1,325 @@
1/********************************************************************** 1/**********************************************************************
2 ** Copyright (C) 2000 Trolltech AS. All rights reserved. 2 ** Copyright (C) 2000 Trolltech AS. All rights reserved.
3 ** 3 **
4 ** This file is part of Qtopia Environment. 4 ** This file is part of Qtopia Environment.
5 ** 5 **
6 ** This file may be distributed and/or modified under the terms of the 6 ** This file may be distributed and/or modified under the terms of the
7 ** GNU General Public License version 2 as published by the Free Software 7 ** GNU General Public License version 2 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.GPL included in the 8 ** Foundation and appearing in the file LICENSE.GPL included in the
9 ** packaging of this file. 9 ** packaging of this file.
10 ** 10 **
11 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13 ** 13 **
14 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 14 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
15 ** 15 **
16 ** Contact info@trolltech.com if any conditions of this licensing are 16 ** Contact info@trolltech.com if any conditions of this licensing are
17 ** not clear to you. 17 ** not clear to you.
18 ** 18 **
19 **********************************************************************/ 19 **********************************************************************/
20#include "security.h" 20#include "security.h"
21 21
22#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
23#include <qpe/config.h> 23#include <qpe/config.h>
24#include <qpe/password.h> 24#include <qpe/password.h>
25#include <qpe/qpedialog.h> 25#include <qpe/qpedialog.h>
26#include <qpe/qcopenvelope_qws.h> 26#include <qpe/qcopenvelope_qws.h>
27 27
28#include <qcheckbox.h> 28#include <qcheckbox.h>
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30#include <qcombobox.h> 30#include <qcombobox.h>
31#include <qmessagebox.h> 31#include <qmessagebox.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qlistview.h> 33#include <qlistview.h>
34#include <qtextstream.h> 34#include <qtextstream.h>
35 35
36 Security::Security( QWidget* parent, const char* name, WFlags fl ) 36 Security::Security( QWidget* parent, const char* name, WFlags fl )
37: SecurityBase( parent, name, TRUE, fl ) 37: SecurityBase( parent, name, TRUE, fl )
38{ 38{
39 valid=FALSE; 39 valid=FALSE;
40 Config cfg("Security"); 40 Config cfg("Security");
41 cfg.setGroup("Passcode"); 41 cfg.setGroup("Passcode");
42 passcode = cfg.readEntry("passcode"); 42 passcode = cfg.readEntry("passcode");
43 passcode_poweron->setChecked(cfg.readBoolEntry("passcode_poweron",FALSE)); 43 passcode_poweron->setChecked(cfg.readBoolEntry("passcode_poweron",FALSE));
44 cfg.setGroup("Sync"); 44 cfg.setGroup("Sync");
45 int auth_peer = cfg.readNumEntry("auth_peer",0xc0a88100);//new default 192.168.129.0/24 45 int auth_peer = cfg.readNumEntry("auth_peer",0xc0a88100);//new default 192.168.129.0/24
46 int auth_peer_bits = cfg.readNumEntry("auth_peer_bits",24); 46 int auth_peer_bits = cfg.readNumEntry("auth_peer_bits",24);
47 selectNet(auth_peer,auth_peer_bits); 47 selectNet(auth_peer,auth_peer_bits);
48 connect(syncnet, SIGNAL(textChanged(const QString&)), 48 connect(syncnet, SIGNAL(textChanged(const QString&)),
49 this, SLOT(setSyncNet(const QString&))); 49 this, SLOT(setSyncNet(const QString&)));
50 50
51 /* 51 /*
52 cfg.setGroup("Remote"); 52 cfg.setGroup("Remote");
53 if ( telnetAvailable() ) 53 if ( telnetAvailable() )
54 telnet->setChecked(cfg.readEntry("allow_telnet")); 54 telnet->setChecked(cfg.readEntry("allow_telnet"));
55 else 55 else
56 telnet->hide(); 56 telnet->hide();
57 57
58 if ( sshAvailable() ) 58 if ( sshAvailable() )
59 ssh->setChecked(cfg.readEntry("allow_ssh")); 59 ssh->setChecked(cfg.readEntry("allow_ssh"));
60 else 60 else
61 ssh->hide(); 61 ssh->hide();
62 */ 62 */
63 63
64 QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; 64 QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf";
65 Config loginCfg(configFile,Config::File); 65 Config loginCfg(configFile,Config::File);
66 66
67 loginCfg.setGroup("General"); 67 loginCfg.setGroup("General");
68 autoLoginName=loginCfg.readEntry("AutoLogin",""); 68 autoLoginName=loginCfg.readEntry("AutoLogin","");
69 69
70 if (autoLoginName.stripWhiteSpace().isEmpty()) { 70 if (autoLoginName.stripWhiteSpace().isEmpty()) {
71 autoLogin=false; 71 autoLogin=false;
72 } else { 72 } else {
73 autoLogin=true; 73 autoLogin=true;
74 } 74 }
75 75
76 cfg.setGroup("SyncMode"); 76 cfg.setGroup("SyncMode");
77 int mode = cfg.readNumEntry("Mode",2); // Default to Sharp 77 int mode = cfg.readNumEntry("Mode",2); // Default to Sharp
78 syncModeCombo->setCurrentItem( mode - 1 ); 78 syncModeCombo->setCurrentItem( mode - 1 );
79 79
80 connect(autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool))); 80 connect(autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool)));
81 connect(userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int))); 81 connect(userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int)));
82 connect(changepasscode,SIGNAL(clicked()), this, SLOT(changePassCode())); 82 connect(changepasscode,SIGNAL(clicked()), this, SLOT(changePassCode()));
83 connect(clearpasscode,SIGNAL(clicked()), this, SLOT(clearPassCode())); 83 connect(clearpasscode,SIGNAL(clicked()), this, SLOT(clearPassCode()));
84 84
85 loadUsers(); 85 loadUsers();
86 updateGUI(); 86 updateGUI();
87 87
88 dl = new QPEDialogListener(this); 88 dl = new QPEDialogListener(this);
89 showMaximized(); 89 showMaximized();
90} 90}
91 91
92Security::~Security() 92Security::~Security()
93{ 93{
94} 94}
95 95
96 96
97void Security::updateGUI() 97void Security::updateGUI()
98{ 98{
99 bool empty = passcode.isEmpty(); 99 bool empty = passcode.isEmpty();
100 100
101 changepasscode->setText( empty ? tr("Set passcode" ) 101 changepasscode->setText( empty ? tr("Set passcode" )
102 : tr("Change passcode" ) ); 102 : tr("Change passcode" ) );
103 passcode_poweron->setEnabled( !empty ); 103 passcode_poweron->setEnabled( !empty );
104 clearpasscode->setEnabled( !empty ); 104 clearpasscode->setEnabled( !empty );
105 105
106 autologinToggle->setChecked(autoLogin); 106 autologinToggle->setChecked(autoLogin);
107 userlist->setEnabled(autoLogin); 107 userlist->setEnabled(autoLogin);
108 108
109} 109}
110 110
111 111
112void Security::show() 112void Security::show()
113{ 113{
114 //valid=FALSE; 114 //valid=FALSE;
115 setEnabled(FALSE); 115 setEnabled(FALSE);
116 SecurityBase::show(); 116 SecurityBase::show();
117 if ( passcode.isEmpty() ) { 117 if ( passcode.isEmpty() ) {
118 // could insist... 118 // could insist...
119 //changePassCode(); 119 //changePassCode();
120 //if ( passcode.isEmpty() ) 120 //if ( passcode.isEmpty() )
121 //reject(); 121 //reject();
122 } else { 122 } else {
123 123
124 if (!valid) // security passcode was not asked yet, so ask now 124 if (!valid) // security passcode was not asked yet, so ask now
125 { 125 {
126 QString pc = enterPassCode(tr("Enter passcode")); 126 QString pc = enterPassCode(tr("Enter passcode"));
127 if ( pc != passcode ) { 127 if ( pc != passcode ) {
128 QMessageBox::critical(this, tr("Passcode incorrect"), 128 QMessageBox::critical(this, tr("Passcode incorrect"),
129 tr("The passcode entered is incorrect.\nAccess denied")); 129 tr("The passcode entered is incorrect.\nAccess denied"));
130 reject(); 130 reject();
131 return; 131 return;
132 } 132 }
133 } 133 }
134 } 134 }
135 setEnabled(TRUE); 135 setEnabled(TRUE);
136 valid=TRUE; 136 valid=TRUE;
137} 137}
138 138
139void Security::accept() 139void Security::accept()
140{ 140{
141 applySecurity(); 141 applySecurity();
142 QDialog::accept(); 142 QDialog::accept();
143 QCopEnvelope env("QPE/System", "securityChanged()" ); 143 QCopEnvelope env("QPE/System", "securityChanged()" );
144} 144}
145 145
146void Security::done(int r) 146void Security::done(int r)
147{ 147{
148 QDialog::done(r); 148 QDialog::done(r);
149 close(); 149 close();
150} 150}
151 151
152void Security::selectNet(int auth_peer,int auth_peer_bits) 152void Security::selectNet(int auth_peer,int auth_peer_bits)
153{ 153{
154 QString sn; 154 QString sn;
155 if ( auth_peer_bits == 0 && auth_peer == 0 ) { 155 if ( auth_peer_bits == 0 && auth_peer == 0 ) {
156 sn = tr("Any"); 156 sn = tr("Any");
157 } else if ( auth_peer_bits == 32 && auth_peer == 0 ) { 157 } else if ( auth_peer_bits == 32 && auth_peer == 0 ) {
158 sn = tr("None"); 158 sn = tr("None");
159 } else { 159 } else {
160 sn = 160 sn =
161 QString::number((auth_peer>>24)&0xff) + "." 161 QString::number((auth_peer>>24)&0xff) + "."
162 + QString::number((auth_peer>>16)&0xff) + "." 162 + QString::number((auth_peer>>16)&0xff) + "."
163 + QString::number((auth_peer>>8)&0xff) + "." 163 + QString::number((auth_peer>>8)&0xff) + "."
164 + QString::number((auth_peer>>0)&0xff) + "/" 164 + QString::number((auth_peer>>0)&0xff) + "/"
165 + QString::number(auth_peer_bits); 165 + QString::number(auth_peer_bits);
166 } 166 }
167 for (int i=0; i<syncnet->count(); i++) { 167 for (int i=0; i<syncnet->count(); i++) {
168 if ( syncnet->text(i).left(sn.length()) == sn ) { 168 if ( syncnet->text(i).left(sn.length()) == sn ) {
169 syncnet->setCurrentItem(i); 169 syncnet->setCurrentItem(i);
170 return; 170 return;
171 } 171 }
172 } 172 }
173 qDebug("No match for \"%s\"",sn.latin1()); 173 qDebug("No match for \"%s\"",sn.latin1());
174} 174}
175 175
176void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits) 176void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits)
177{ 177{
178 auth_peer=0; 178 auth_peer=0;
179 if ( sn == tr("Any") ) { 179 if ( sn == tr("Any") ) {
180 auth_peer = 0; 180 auth_peer = 0;
181 auth_peer_bits = 0; 181 auth_peer_bits = 0;
182 } else if ( sn == tr("None") ) { 182 } else if ( sn == tr("None") ) {
183 auth_peer = 0; 183 auth_peer = 0;
184 auth_peer_bits = 32; 184 auth_peer_bits = 32;
185 } else { 185 } else {
186 int x=0; 186 int x=0;
187 for (int i=0; i<4; i++) { 187 for (int i=0; i<4; i++) {
188 int nx = sn.find(QChar(i==3 ? '/' : '.'),x); 188 int nx = sn.find(QChar(i==3 ? '/' : '.'),x);
189 auth_peer = (auth_peer<<8)|sn.mid(x,nx-x).toInt(); 189 auth_peer = (auth_peer<<8)|sn.mid(x,nx-x).toInt();
190 x = nx+1; 190 x = nx+1;
191 } 191 }
192 uint n = (uint)sn.find(' ',x)-x; 192 uint n = (uint)sn.find(' ',x)-x;
193 auth_peer_bits = sn.mid(x,n).toInt(); 193 auth_peer_bits = sn.mid(x,n).toInt();
194 } 194 }
195} 195}
196 196
197void Security::loadUsers ( void ) 197void Security::loadUsers ( void )
198{ 198{
199 QFile passwd("/etc/passwd"); 199 QFile passwd("/etc/passwd");
200 if ( passwd.open(IO_ReadOnly) ) { 200 if ( passwd.open(IO_ReadOnly) ) {
201 QTextStream t( &passwd ); 201 QTextStream t( &passwd );
202 QString s; 202 QString s;
203 QStringList account; 203 QStringList account;
204 while ( !t.eof() ) { 204 while ( !t.eof() ) {
205 account = QStringList::split(':',t.readLine()); 205 account = QStringList::split(':',t.readLine());
206 206
207 // Hide disabled accounts 207 // Hide disabled accounts
208 if (*account.at(1)!="*") { 208 if (*account.at(1)!="*") {
209 209
210 userlist->insertItem(*account.at(0)); 210 userlist->insertItem(*account.at(0));
211 // Highlight this item if it is set to autologinToggle 211 // Highlight this item if it is set to autologinToggle
212 if ( *account.at(0) == autoLoginName) 212 if ( *account.at(0) == autoLoginName)
213 userlist->setCurrentItem(userlist->count()-1); 213 userlist->setCurrentItem(userlist->count()-1);
214 } 214 }
215 } 215 }
216 passwd.close(); 216 passwd.close();
217 } 217 }
218 218
219} 219}
220 220
221void Security::toggleAutoLogin(bool val) 221void Security::toggleAutoLogin(bool val)
222{ 222{
223 autoLogin=val; 223 autoLogin=val;
224 userlist->setEnabled(val); 224 userlist->setEnabled(val);
225 if (!autoLogin) 225 if (!autoLogin)
226 autoLoginName=userlist->currentText(); 226 autoLoginName=userlist->currentText();
227} 227}
228 228
229 229
230 230
231 231
232void Security::setSyncNet(const QString& sn) 232void Security::setSyncNet(const QString& sn)
233{ 233{
234 int auth_peer,auth_peer_bits; 234 int auth_peer,auth_peer_bits;
235 parseNet(sn,auth_peer,auth_peer_bits); 235 parseNet(sn,auth_peer,auth_peer_bits);
236 selectNet(auth_peer,auth_peer_bits); 236 selectNet(auth_peer,auth_peer_bits);
237} 237}
238 238
239void Security::applySecurity() 239void Security::applySecurity()
240{ 240{
241 if ( valid ) { 241 if ( valid ) {
242<<<<<<< security.cpp 242
243 Config cfg("Security"); 243 Config cfg("Security");
244 cfg.setGroup("Passcode"); 244 cfg.setGroup("Passcode");
245 cfg.writeEntry("passcode",passcode); 245 cfg.writeEntry("passcode",passcode);
246 cfg.writeEntry("passcode_poweron",passcode_poweron->isChecked()); 246 cfg.writeEntry("passcode_poweron",passcode_poweron->isChecked());
247 cfg.setGroup("Sync"); 247 cfg.setGroup("Sync");
248 int auth_peer=0; 248 int auth_peer=0;
249 int auth_peer_bits; 249 int auth_peer_bits;
250 QString sn = syncnet->currentText(); 250 QString sn = syncnet->currentText();
251 parseNet(sn,auth_peer,auth_peer_bits); 251 parseNet(sn,auth_peer,auth_peer_bits);
252 cfg.writeEntry("auth_peer",auth_peer); 252 cfg.writeEntry("auth_peer",auth_peer);
253 cfg.writeEntry("auth_peer_bits",auth_peer_bits); 253 cfg.writeEntry("auth_peer_bits",auth_peer_bits);
254 /* 254 /*
255 cfg.setGroup("Remote"); 255 cfg.setGroup("Remote");
256 if ( telnetAvailable() ) 256 if ( telnetAvailable() )
257 cfg.writeEntry("allow_telnet",telnet->isChecked()); 257 cfg.writeEntry("allow_telnet",telnet->isChecked());
258 if ( sshAvailable() ) 258 if ( sshAvailable() )
259 cfg.writeEntry("allow_ssh",ssh->isChecked()); 259 cfg.writeEntry("allow_ssh",ssh->isChecked());
260 // ### write ssh/telnet sys config files 260 // ### write ssh/telnet sys config files
261 */ 261 */
262 262
263 QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; 263 QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf";
264 Config loginCfg(configFile,Config::File); 264 Config loginCfg(configFile,Config::File);
265 loginCfg.setGroup("General"); 265 loginCfg.setGroup("General");
266 266
267 if (autoLogin) { 267 if (autoLogin) {
268 loginCfg.writeEntry("AutoLogin",autoLoginName); 268 loginCfg.writeEntry("AutoLogin",autoLoginName);
269 } else { 269 } else {
270 loginCfg.removeEntry("AutoLogin"); 270 loginCfg.removeEntry("AutoLogin");
271 } 271 }
272 272
273 cfg.setGroup("SyncMode"); 273 cfg.setGroup("SyncMode");
274 cfg.writeEntry("Mode", syncModeCombo->currentItem()+1 ); 274 cfg.writeEntry("Mode", syncModeCombo->currentItem()+1 );
275 275
276 } 276 }
277} 277}
278 278
279void Security::changeLoginName( int idx ) 279void Security::changeLoginName( int idx )
280{ 280{
281 autoLoginName = userlist->text(idx);; 281 autoLoginName = userlist->text(idx);;
282 updateGUI(); 282 updateGUI();
283} 283}
284 284
285void Security::changePassCode() 285void Security::changePassCode()
286{ 286{
287 QString new1; 287 QString new1;
288 QString new2; 288 QString new2;
289 289
290 do { 290 do {
291 new1 = enterPassCode(tr("Enter new passcode")); 291 new1 = enterPassCode(tr("Enter new passcode"));
292 if ( new1.isNull() ) 292 if ( new1.isNull() )
293 return; 293 return;
294 new2 = enterPassCode(tr("Re-enter new passcode")); 294 new2 = enterPassCode(tr("Re-enter new passcode"));
295 if ( new2.isNull() ) 295 if ( new2.isNull() )
296 return; 296 return;
297 } while (new1 != new2); 297 } while (new1 != new2);
298 298
299 passcode = new1; 299 passcode = new1;
300 updateGUI(); 300 updateGUI();
301} 301}
302 302
303void Security::clearPassCode() 303void Security::clearPassCode()
304{ 304{
305 passcode = QString::null; 305 passcode = QString::null;
306 updateGUI(); 306 updateGUI();
307} 307}
308 308
309 309
310QString Security::enterPassCode(const QString& prompt) 310QString Security::enterPassCode(const QString& prompt)
311{ 311{
312 return Password::getPassword(prompt); 312 return Password::getPassword(prompt);
313} 313}
314 314
315bool Security::telnetAvailable() const 315bool Security::telnetAvailable() const
316{ 316{
317 // ### not implemented 317 // ### not implemented
318 return FALSE; 318 return FALSE;
319} 319}
320 320
321bool Security::sshAvailable() const 321bool Security::sshAvailable() const
322{ 322{
323 // ### not implemented 323 // ### not implemented
324 return FALSE; 324 return FALSE;
325} 325}