summaryrefslogtreecommitdiff
path: root/core/settings/security
authorkergoth <kergoth>2002-01-25 22:14:26 (UTC)
committer kergoth <kergoth>2002-01-25 22:14:26 (UTC)
commit15318cad33835e4e2dc620d033e43cd930676cdd (patch) (unidiff)
treec2fa0399a2c47fda8e2cd0092c73a809d17f68eb /core/settings/security
downloadopie-15318cad33835e4e2dc620d033e43cd930676cdd.zip
opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.gz
opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.bz2
Initial revision
Diffstat (limited to 'core/settings/security') (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/security/.cvsignore5
-rw-r--r--core/settings/security/Makefile.in135
-rw-r--r--core/settings/security/main.cpp38
-rw-r--r--core/settings/security/qpe-security.control9
-rw-r--r--core/settings/security/security.cpp234
-rw-r--r--core/settings/security/security.h64
-rw-r--r--core/settings/security/security.pro12
-rw-r--r--core/settings/security/securitybase.ui200
8 files changed, 697 insertions, 0 deletions
diff --git a/core/settings/security/.cvsignore b/core/settings/security/.cvsignore
new file mode 100644
index 0000000..11eef0d
--- a/dev/null
+++ b/core/settings/security/.cvsignore
@@ -0,0 +1,5 @@
1Makefile
2moc_*
3*.moc
4securitybase.cpp
5securitybase.h
diff --git a/core/settings/security/Makefile.in b/core/settings/security/Makefile.in
new file mode 100644
index 0000000..803edc5
--- a/dev/null
+++ b/core/settings/security/Makefile.in
@@ -0,0 +1,135 @@
1#############################################################################
2
3####### Compiler, tools and options
4
5 CXX =$(SYSCONF_CXX) $(QT_CXX_MT)
6 CXXFLAGS=$(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS)
7 CC =$(SYSCONF_CC) $(QT_C_MT)
8 CFLAGS =$(SYSCONF_CFLAGS)
9 INCPATH =-I$(QPEDIR)/include
10 LFLAGS =$(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT)
11 LIBS =$(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP)
12 MOC =$(SYSCONF_MOC)
13 UIC =$(SYSCONF_UIC)
14
15####### Target
16
17DESTDIR = ../../bin/
18VER_MAJ = 1
19VER_MIN = 0
20VER_PATCH = 0
21 TARGET= security
22TARGET1 = lib$(TARGET).so.$(VER_MAJ)
23
24####### Files
25
26 HEADERS =security.h
27 SOURCES =security.cpp \
28 main.cpp
29 OBJECTS =security.o \
30 main.o \
31 securitybase.o
32INTERFACES = securitybase.ui
33UICDECLS = securitybase.h
34UICIMPLS = securitybase.cpp
35 SRCMOC =moc_security.cpp \
36 moc_securitybase.cpp
37 OBJMOC =moc_security.o \
38 moc_securitybase.o
39
40
41####### Implicit rules
42
43.SUFFIXES: .cpp .cxx .cc .C .c
44
45.cpp.o:
46 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
47
48.cxx.o:
49 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
50
51.cc.o:
52 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
53
54.C.o:
55 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
56
57.c.o:
58 $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
59
60####### Build rules
61
62
63all: $(DESTDIR)$(TARGET)
64
65$(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS)
66 $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)
67
68moc: $(SRCMOC)
69
70tmake:
71 tmake security.pro
72
73clean:
74 -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS)
75 -rm -f *~ core
76 -rm -f allmoc.cpp
77
78####### Extension Modules
79
80listpromodules:
81 @echo
82
83listallmodules:
84 @echo
85
86listaddonpromodules:
87 @echo
88
89listaddonentmodules:
90 @echo
91
92
93REQUIRES=
94
95####### Sub-libraries
96
97
98###### Combined headers
99
100
101
102####### Compile
103
104security.o: security.cpp \
105 security.h \
106 securitybase.h
107
108main.o: main.cpp \
109 security.h \
110 securitybase.h
111
112securitybase.h: securitybase.ui
113 $(UIC) securitybase.ui -o $(INTERFACE_DECL_PATH)/securitybase.h
114
115securitybase.cpp: securitybase.ui
116 $(UIC) securitybase.ui -i securitybase.h -o securitybase.cpp
117
118securitybase.o: securitybase.cpp \
119 securitybase.h \
120 securitybase.ui
121
122moc_security.o: moc_security.cpp \
123 security.h \
124 securitybase.h
125
126moc_securitybase.o: moc_securitybase.cpp \
127 securitybase.h
128
129moc_security.cpp: security.h
130 $(MOC) security.h -o moc_security.cpp
131
132moc_securitybase.cpp: securitybase.h
133 $(MOC) securitybase.h -o moc_securitybase.cpp
134
135
diff --git a/core/settings/security/main.cpp b/core/settings/security/main.cpp
new file mode 100644
index 0000000..c15bb31
--- a/dev/null
+++ b/core/settings/security/main.cpp
@@ -0,0 +1,38 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include <qpe/qpeapplication.h>
22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/global.h>
24
25#include "security.h"
26
27
28int main(int argc, char** argv)
29{
30 QPEApplication a(argc,argv);
31
32 Security dlg;
33
34 a.showMainWidget(&dlg);
35
36 return a.exec();
37}
38
diff --git a/core/settings/security/qpe-security.control b/core/settings/security/qpe-security.control
new file mode 100644
index 0000000..78a5a86
--- a/dev/null
+++ b/core/settings/security/qpe-security.control
@@ -0,0 +1,9 @@
1Files: bin/security apps/Settings/Security.desktop
2Priority: optional
3Section: qpe/settings
4Maintainer: Warwick Allison <warwick@trolltech.com>
5Architecture: arm
6Version: $QPE_VERSION-3
7Depends: qpe-base ($QPE_VERSION)
8Description: Security settings dialog
9 For the Qtopia environment.
diff --git a/core/settings/security/security.cpp b/core/settings/security/security.cpp
new file mode 100644
index 0000000..f4116b0
--- a/dev/null
+++ b/core/settings/security/security.cpp
@@ -0,0 +1,234 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include "security.h"
21
22#include <qpe/config.h>
23#include <qpe/password.h>
24#include <qpe/qpedialog.h>
25
26#include <qcheckbox.h>
27#include <qpushbutton.h>
28#include <qcombobox.h>
29#include <qmessagebox.h>
30
31Security::Security( QWidget* parent, const char* name, WFlags fl )
32 : SecurityBase( parent, name, TRUE, fl )
33{
34 valid=FALSE;
35 Config cfg("Security");
36 cfg.setGroup("Passcode");
37 passcode = cfg.readEntry("passcode");
38 passcode_poweron->setChecked(cfg.readBoolEntry("passcode_poweron",FALSE));
39 cfg.setGroup("Sync");
40 int auth_peer = cfg.readNumEntry("auth_peer",0xc0a80100);
41 int auth_peer_bits = cfg.readNumEntry("auth_peer_bits",24);
42 selectNet(auth_peer,auth_peer_bits);
43 connect(syncnet, SIGNAL(textChanged(const QString&)),
44 this, SLOT(setSyncNet(const QString&)));
45
46 /*
47 cfg.setGroup("Remote");
48 if ( telnetAvailable() )
49 telnet->setChecked(cfg.readEntry("allow_telnet"));
50 else
51 telnet->hide();
52
53 if ( sshAvailable() )
54 ssh->setChecked(cfg.readEntry("allow_ssh"));
55 else
56 ssh->hide();
57 */
58
59 connect(changepasscode,SIGNAL(clicked()), this, SLOT(changePassCode()));
60 connect(clearpasscode,SIGNAL(clicked()), this, SLOT(clearPassCode()));
61 updateGUI();
62
63 dl = new QPEDialogListener(this);
64}
65
66Security::~Security()
67{
68}
69
70
71void Security::updateGUI()
72{
73 bool empty = passcode.isEmpty();
74
75 changepasscode->setText( empty ? tr("Set passcode" )
76 : tr("Change passcode" ) );
77 passcode_poweron->setEnabled( !empty );
78 clearpasscode->setEnabled( !empty );
79}
80
81
82void Security::show()
83{
84 valid=FALSE;
85 setEnabled(FALSE);
86 SecurityBase::show();
87 if ( passcode.isEmpty() ) {
88 // could insist...
89 //changePassCode();
90 //if ( passcode.isEmpty() )
91 //reject();
92 } else {
93 QString pc = enterPassCode(tr("Enter passcode"));
94 if ( pc != passcode ) {
95 QMessageBox::critical(this, tr("Passcode incorrect"),
96 tr("The passcode entered is incorrect.\nAccess denied"));
97 reject();
98 return;
99 }
100 }
101 setEnabled(TRUE);
102 valid=TRUE;
103}
104
105void Security::accept()
106{
107 applySecurity();
108 QDialog::accept();
109}
110
111void Security::done(int r)
112{
113 QDialog::done(r);
114 close();
115}
116
117void Security::selectNet(int auth_peer,int auth_peer_bits)
118{
119 QString sn;
120 if ( auth_peer_bits == 0 && auth_peer == 0 ) {
121 sn = tr("Any");
122 } else if ( auth_peer_bits == 32 && auth_peer == 0 ) {
123 sn = tr("None");
124 } else {
125 sn =
126 QString::number((auth_peer>>24)&0xff) + "."
127 + QString::number((auth_peer>>16)&0xff) + "."
128 + QString::number((auth_peer>>8)&0xff) + "."
129 + QString::number((auth_peer>>0)&0xff) + "/"
130 + QString::number(auth_peer_bits);
131 }
132 for (int i=0; i<syncnet->count(); i++) {
133 if ( syncnet->text(i).left(sn.length()) == sn ) {
134 syncnet->setCurrentItem(i);
135 return;
136 }
137 }
138 qDebug("No match for \"%s\"",sn.latin1());
139}
140
141void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits)
142{
143 auth_peer=0;
144 if ( sn == tr("Any") ) {
145 auth_peer = 0;
146 auth_peer_bits = 0;
147 } else if ( sn == tr("None") ) {
148 auth_peer = 0;
149 auth_peer_bits = 32;
150 } else {
151 int x=0;
152 for (int i=0; i<4; i++) {
153 int nx = sn.find(QChar(i==3 ? '/' : '.'),x);
154 auth_peer = (auth_peer<<8)|sn.mid(x,nx-x).toInt();
155 x = nx+1;
156 }
157 uint n = (uint)sn.find(' ',x)-x;
158 auth_peer_bits = sn.mid(x,n).toInt();
159 }
160}
161
162void Security::setSyncNet(const QString& sn)
163{
164 int auth_peer,auth_peer_bits;
165 parseNet(sn,auth_peer,auth_peer_bits);
166 selectNet(auth_peer,auth_peer_bits);
167}
168
169void Security::applySecurity()
170{
171 if ( valid ) {
172 Config cfg("Security");
173 cfg.setGroup("Passcode");
174 cfg.writeEntry("passcode",passcode);
175 cfg.writeEntry("passcode_poweron",passcode_poweron->isChecked());
176 cfg.setGroup("Sync");
177 int auth_peer=0;
178 int auth_peer_bits;
179 QString sn = syncnet->currentText();
180 parseNet(sn,auth_peer,auth_peer_bits);
181 cfg.writeEntry("auth_peer",auth_peer);
182 cfg.writeEntry("auth_peer_bits",auth_peer_bits);
183 /*
184 cfg.setGroup("Remote");
185 if ( telnetAvailable() )
186 cfg.writeEntry("allow_telnet",telnet->isChecked());
187 if ( sshAvailable() )
188 cfg.writeEntry("allow_ssh",ssh->isChecked());
189 // ### write ssh/telnet sys config files
190 */
191 }
192}
193
194void Security::changePassCode()
195{
196 QString new1;
197 QString new2;
198
199 do {
200 new1 = enterPassCode("Enter new passcode");
201 if ( new1.isNull() )
202 return;
203 new2 = enterPassCode("Re-enter new passcode");
204 if ( new2.isNull() )
205 return;
206 } while (new1 != new2);
207
208 passcode = new1;
209 updateGUI();
210}
211
212void Security::clearPassCode()
213{
214 passcode = QString::null;
215 updateGUI();
216}
217
218
219QString Security::enterPassCode(const QString& prompt)
220{
221 return Password::getPassword(prompt);
222}
223
224bool Security::telnetAvailable() const
225{
226 // ### not implemented
227 return FALSE;
228}
229
230bool Security::sshAvailable() const
231{
232 // ### not implemented
233 return FALSE;
234}
diff --git a/core/settings/security/security.h b/core/settings/security/security.h
new file mode 100644
index 0000000..efc83a2
--- a/dev/null
+++ b/core/settings/security/security.h
@@ -0,0 +1,64 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef SECURITY_H
21#define SECURITY_H
22
23#include "securitybase.h"
24
25class QPEDialogListener;
26
27class Security : public SecurityBase
28{
29 Q_OBJECT
30
31public:
32 Security( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
33 ~Security();
34
35 void show();
36
37protected:
38 void accept();
39 void applySecurity();
40 void done(int);
41
42private slots:
43 void changePassCode();
44 void clearPassCode();
45 void setSyncNet(const QString&);
46
47private:
48 bool telnetAvailable() const;
49 bool sshAvailable() const;
50 void updateGUI();
51
52 static void parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits);
53 void selectNet(int auth_peer,int auth_peer_bits);
54
55 QString enterPassCode(const QString&);
56 QString passcode;
57 bool valid;
58
59 QPEDialogListener *dl;
60};
61
62
63#endif // SECURITY_H
64
diff --git a/core/settings/security/security.pro b/core/settings/security/security.pro
new file mode 100644
index 0000000..282127e
--- a/dev/null
+++ b/core/settings/security/security.pro
@@ -0,0 +1,12 @@
1 TEMPLATE= app
2 CONFIG += qt warn_on release
3 DESTDIR = ../../bin
4 HEADERS = security.h
5 SOURCES = security.cpp main.cpp
6 INTERFACES= securitybase.ui
7INCLUDEPATH += $(QPEDIR)/include
8 DEPENDPATH+= ../$(QPEDIR)/include
9LIBS += -lqpe
10 TARGET = security
11
12TRANSLATIONS = ../../i18n/de/security.ts
diff --git a/core/settings/security/securitybase.ui b/core/settings/security/securitybase.ui
new file mode 100644
index 0000000..2f3189d
--- a/dev/null
+++ b/core/settings/security/securitybase.ui
@@ -0,0 +1,200 @@
1<!DOCTYPE UI><UI>
2<class>SecurityBase</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>SecurityBase</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>281</width>
15 <height>328</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Security Settings</string>
21 </property>
22 <property>
23 <name>layoutMargin</name>
24 </property>
25 <grid>
26 <property stdset="1">
27 <name>margin</name>
28 <number>11</number>
29 </property>
30 <property stdset="1">
31 <name>spacing</name>
32 <number>6</number>
33 </property>
34 <widget row="0" column="0" >
35 <class>QLayoutWidget</class>
36 <property stdset="1">
37 <name>name</name>
38 <cstring>Layout1</cstring>
39 </property>
40 <property>
41 <name>layoutSpacing</name>
42 </property>
43 <hbox>
44 <property stdset="1">
45 <name>margin</name>
46 <number>0</number>
47 </property>
48 <property stdset="1">
49 <name>spacing</name>
50 <number>-1</number>
51 </property>
52 <widget>
53 <class>QPushButton</class>
54 <property stdset="1">
55 <name>name</name>
56 <cstring>changepasscode</cstring>
57 </property>
58 <property stdset="1">
59 <name>text</name>
60 <string>Change passcode</string>
61 </property>
62 </widget>
63 <widget>
64 <class>QPushButton</class>
65 <property stdset="1">
66 <name>name</name>
67 <cstring>clearpasscode</cstring>
68 </property>
69 <property stdset="1">
70 <name>text</name>
71 <string>Clear passcode</string>
72 </property>
73 </widget>
74 </hbox>
75 </widget>
76 <widget row="1" column="0" >
77 <class>QCheckBox</class>
78 <property stdset="1">
79 <name>name</name>
80 <cstring>passcode_poweron</cstring>
81 </property>
82 <property stdset="1">
83 <name>text</name>
84 <string>Require pass code at power-on</string>
85 </property>
86 </widget>
87 <widget row="3" column="0" >
88 <class>QTabWidget</class>
89 <property stdset="1">
90 <name>name</name>
91 <cstring>TabWidget2</cstring>
92 </property>
93 <widget>
94 <class>QWidget</class>
95 <property stdset="1">
96 <name>name</name>
97 <cstring>tab</cstring>
98 </property>
99 <attribute>
100 <name>title</name>
101 <string>Sync</string>
102 </attribute>
103 <vbox>
104 <property stdset="1">
105 <name>margin</name>
106 <number>11</number>
107 </property>
108 <property stdset="1">
109 <name>spacing</name>
110 <number>6</number>
111 </property>
112 <widget>
113 <class>QLabel</class>
114 <property stdset="1">
115 <name>name</name>
116 <cstring>TextLabel1_2</cstring>
117 </property>
118 <property stdset="1">
119 <name>text</name>
120 <string>Accept sync from network:</string>
121 </property>
122 </widget>
123 <widget>
124 <class>QComboBox</class>
125 <item>
126 <property>
127 <name>text</name>
128 <string>192.168.1.0/24 (default)</string>
129 </property>
130 </item>
131 <item>
132 <property>
133 <name>text</name>
134 <string>192.168.0.0/16</string>
135 </property>
136 </item>
137 <item>
138 <property>
139 <name>text</name>
140 <string>172.16.0.0/12</string>
141 </property>
142 </item>
143 <item>
144 <property>
145 <name>text</name>
146 <string>10.0.0.0/8</string>
147 </property>
148 </item>
149 <item>
150 <property>
151 <name>text</name>
152 <string>Any</string>
153 </property>
154 </item>
155 <item>
156 <property>
157 <name>text</name>
158 <string>None</string>
159 </property>
160 </item>
161 <property stdset="1">
162 <name>name</name>
163 <cstring>syncnet</cstring>
164 </property>
165 <property stdset="1">
166 <name>editable</name>
167 <bool>true</bool>
168 </property>
169 </widget>
170 </vbox>
171 </widget>
172 </widget>
173 <widget row="2" column="0" >
174 <class>QLabel</class>
175 <property stdset="1">
176 <name>name</name>
177 <cstring>TextLabel1</cstring>
178 </property>
179 <property stdset="1">
180 <name>sizePolicy</name>
181 <sizepolicy>
182 <hsizetype>5</hsizetype>
183 <vsizetype>7</vsizetype>
184 </sizepolicy>
185 </property>
186 <property stdset="1">
187 <name>text</name>
188 <string>&lt;P&gt;Pass code protection provides a minimal level of protection from casual access to this device.</string>
189 </property>
190 <property stdset="1">
191 <name>alignment</name>
192 <set>AlignTop|AlignLeft</set>
193 </property>
194 <property>
195 <name>vAlign</name>
196 </property>
197 </widget>
198 </grid>
199</widget>
200</UI>