summaryrefslogtreecommitdiff
path: root/core/settings/security
Side-by-side diff
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 @@
+Makefile
+moc_*
+*.moc
+securitybase.cpp
+securitybase.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 @@
+#############################################################################
+
+####### Compiler, tools and options
+
+CXX = $(SYSCONF_CXX) $(QT_CXX_MT)
+CXXFLAGS= $(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS)
+CC = $(SYSCONF_CC) $(QT_C_MT)
+CFLAGS = $(SYSCONF_CFLAGS)
+INCPATH = -I$(QPEDIR)/include
+LFLAGS = $(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT)
+LIBS = $(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP)
+MOC = $(SYSCONF_MOC)
+UIC = $(SYSCONF_UIC)
+
+####### Target
+
+DESTDIR = ../../bin/
+VER_MAJ = 1
+VER_MIN = 0
+VER_PATCH = 0
+TARGET = security
+TARGET1 = lib$(TARGET).so.$(VER_MAJ)
+
+####### Files
+
+HEADERS = security.h
+SOURCES = security.cpp \
+ main.cpp
+OBJECTS = security.o \
+ main.o \
+ securitybase.o
+INTERFACES = securitybase.ui
+UICDECLS = securitybase.h
+UICIMPLS = securitybase.cpp
+SRCMOC = moc_security.cpp \
+ moc_securitybase.cpp
+OBJMOC = moc_security.o \
+ moc_securitybase.o
+
+
+####### Implicit rules
+
+.SUFFIXES: .cpp .cxx .cc .C .c
+
+.cpp.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.cxx.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.cc.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.C.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.c.o:
+ $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
+
+####### Build rules
+
+
+all: $(DESTDIR)$(TARGET)
+
+$(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS)
+ $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)
+
+moc: $(SRCMOC)
+
+tmake:
+ tmake security.pro
+
+clean:
+ -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS)
+ -rm -f *~ core
+ -rm -f allmoc.cpp
+
+####### Extension Modules
+
+listpromodules:
+ @echo
+
+listallmodules:
+ @echo
+
+listaddonpromodules:
+ @echo
+
+listaddonentmodules:
+ @echo
+
+
+REQUIRES=
+
+####### Sub-libraries
+
+
+###### Combined headers
+
+
+
+####### Compile
+
+security.o: security.cpp \
+ security.h \
+ securitybase.h
+
+main.o: main.cpp \
+ security.h \
+ securitybase.h
+
+securitybase.h: securitybase.ui
+ $(UIC) securitybase.ui -o $(INTERFACE_DECL_PATH)/securitybase.h
+
+securitybase.cpp: securitybase.ui
+ $(UIC) securitybase.ui -i securitybase.h -o securitybase.cpp
+
+securitybase.o: securitybase.cpp \
+ securitybase.h \
+ securitybase.ui
+
+moc_security.o: moc_security.cpp \
+ security.h \
+ securitybase.h
+
+moc_securitybase.o: moc_securitybase.cpp \
+ securitybase.h
+
+moc_security.cpp: security.h
+ $(MOC) security.h -o moc_security.cpp
+
+moc_securitybase.cpp: securitybase.h
+ $(MOC) securitybase.h -o moc_securitybase.cpp
+
+
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 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include <qpe/qpeapplication.h>
+#include <qpe/qcopenvelope_qws.h>
+#include <qpe/global.h>
+
+#include "security.h"
+
+
+int main(int argc, char** argv)
+{
+ QPEApplication a(argc,argv);
+
+ Security dlg;
+
+ a.showMainWidget(&dlg);
+
+ return a.exec();
+}
+
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 @@
+Files: bin/security apps/Settings/Security.desktop
+Priority: optional
+Section: qpe/settings
+Maintainer: Warwick Allison <warwick@trolltech.com>
+Architecture: arm
+Version: $QPE_VERSION-3
+Depends: qpe-base ($QPE_VERSION)
+Description: Security settings dialog
+ 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 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+#include "security.h"
+
+#include <qpe/config.h>
+#include <qpe/password.h>
+#include <qpe/qpedialog.h>
+
+#include <qcheckbox.h>
+#include <qpushbutton.h>
+#include <qcombobox.h>
+#include <qmessagebox.h>
+
+Security::Security( QWidget* parent, const char* name, WFlags fl )
+ : SecurityBase( parent, name, TRUE, fl )
+{
+ valid=FALSE;
+ Config cfg("Security");
+ cfg.setGroup("Passcode");
+ passcode = cfg.readEntry("passcode");
+ passcode_poweron->setChecked(cfg.readBoolEntry("passcode_poweron",FALSE));
+ cfg.setGroup("Sync");
+ int auth_peer = cfg.readNumEntry("auth_peer",0xc0a80100);
+ int auth_peer_bits = cfg.readNumEntry("auth_peer_bits",24);
+ selectNet(auth_peer,auth_peer_bits);
+ connect(syncnet, SIGNAL(textChanged(const QString&)),
+ this, SLOT(setSyncNet(const QString&)));
+
+ /*
+ cfg.setGroup("Remote");
+ if ( telnetAvailable() )
+ telnet->setChecked(cfg.readEntry("allow_telnet"));
+ else
+ telnet->hide();
+
+ if ( sshAvailable() )
+ ssh->setChecked(cfg.readEntry("allow_ssh"));
+ else
+ ssh->hide();
+ */
+
+ connect(changepasscode,SIGNAL(clicked()), this, SLOT(changePassCode()));
+ connect(clearpasscode,SIGNAL(clicked()), this, SLOT(clearPassCode()));
+ updateGUI();
+
+ dl = new QPEDialogListener(this);
+}
+
+Security::~Security()
+{
+}
+
+
+void Security::updateGUI()
+{
+ bool empty = passcode.isEmpty();
+
+ changepasscode->setText( empty ? tr("Set passcode" )
+ : tr("Change passcode" ) );
+ passcode_poweron->setEnabled( !empty );
+ clearpasscode->setEnabled( !empty );
+}
+
+
+void Security::show()
+{
+ valid=FALSE;
+ setEnabled(FALSE);
+ SecurityBase::show();
+ if ( passcode.isEmpty() ) {
+ // could insist...
+ //changePassCode();
+ //if ( passcode.isEmpty() )
+ //reject();
+ } else {
+ QString pc = enterPassCode(tr("Enter passcode"));
+ if ( pc != passcode ) {
+ QMessageBox::critical(this, tr("Passcode incorrect"),
+ tr("The passcode entered is incorrect.\nAccess denied"));
+ reject();
+ return;
+ }
+ }
+ setEnabled(TRUE);
+ valid=TRUE;
+}
+
+void Security::accept()
+{
+ applySecurity();
+ QDialog::accept();
+}
+
+void Security::done(int r)
+{
+ QDialog::done(r);
+ close();
+}
+
+void Security::selectNet(int auth_peer,int auth_peer_bits)
+{
+ QString sn;
+ if ( auth_peer_bits == 0 && auth_peer == 0 ) {
+ sn = tr("Any");
+ } else if ( auth_peer_bits == 32 && auth_peer == 0 ) {
+ sn = tr("None");
+ } else {
+ sn =
+ QString::number((auth_peer>>24)&0xff) + "."
+ + QString::number((auth_peer>>16)&0xff) + "."
+ + QString::number((auth_peer>>8)&0xff) + "."
+ + QString::number((auth_peer>>0)&0xff) + "/"
+ + QString::number(auth_peer_bits);
+ }
+ for (int i=0; i<syncnet->count(); i++) {
+ if ( syncnet->text(i).left(sn.length()) == sn ) {
+ syncnet->setCurrentItem(i);
+ return;
+ }
+ }
+ qDebug("No match for \"%s\"",sn.latin1());
+}
+
+void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits)
+{
+ auth_peer=0;
+ if ( sn == tr("Any") ) {
+ auth_peer = 0;
+ auth_peer_bits = 0;
+ } else if ( sn == tr("None") ) {
+ auth_peer = 0;
+ auth_peer_bits = 32;
+ } else {
+ int x=0;
+ for (int i=0; i<4; i++) {
+ int nx = sn.find(QChar(i==3 ? '/' : '.'),x);
+ auth_peer = (auth_peer<<8)|sn.mid(x,nx-x).toInt();
+ x = nx+1;
+ }
+ uint n = (uint)sn.find(' ',x)-x;
+ auth_peer_bits = sn.mid(x,n).toInt();
+ }
+}
+
+void Security::setSyncNet(const QString& sn)
+{
+ int auth_peer,auth_peer_bits;
+ parseNet(sn,auth_peer,auth_peer_bits);
+ selectNet(auth_peer,auth_peer_bits);
+}
+
+void Security::applySecurity()
+{
+ if ( valid ) {
+ Config cfg("Security");
+ cfg.setGroup("Passcode");
+ cfg.writeEntry("passcode",passcode);
+ cfg.writeEntry("passcode_poweron",passcode_poweron->isChecked());
+ cfg.setGroup("Sync");
+ int auth_peer=0;
+ int auth_peer_bits;
+ QString sn = syncnet->currentText();
+ parseNet(sn,auth_peer,auth_peer_bits);
+ cfg.writeEntry("auth_peer",auth_peer);
+ cfg.writeEntry("auth_peer_bits",auth_peer_bits);
+ /*
+ cfg.setGroup("Remote");
+ if ( telnetAvailable() )
+ cfg.writeEntry("allow_telnet",telnet->isChecked());
+ if ( sshAvailable() )
+ cfg.writeEntry("allow_ssh",ssh->isChecked());
+ // ### write ssh/telnet sys config files
+ */
+ }
+}
+
+void Security::changePassCode()
+{
+ QString new1;
+ QString new2;
+
+ do {
+ new1 = enterPassCode("Enter new passcode");
+ if ( new1.isNull() )
+ return;
+ new2 = enterPassCode("Re-enter new passcode");
+ if ( new2.isNull() )
+ return;
+ } while (new1 != new2);
+
+ passcode = new1;
+ updateGUI();
+}
+
+void Security::clearPassCode()
+{
+ passcode = QString::null;
+ updateGUI();
+}
+
+
+QString Security::enterPassCode(const QString& prompt)
+{
+ return Password::getPassword(prompt);
+}
+
+bool Security::telnetAvailable() const
+{
+ // ### not implemented
+ return FALSE;
+}
+
+bool Security::sshAvailable() const
+{
+ // ### not implemented
+ return FALSE;
+}
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 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+#ifndef SECURITY_H
+#define SECURITY_H
+
+#include "securitybase.h"
+
+class QPEDialogListener;
+
+class Security : public SecurityBase
+{
+ Q_OBJECT
+
+public:
+ Security( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
+ ~Security();
+
+ void show();
+
+protected:
+ void accept();
+ void applySecurity();
+ void done(int);
+
+private slots:
+ void changePassCode();
+ void clearPassCode();
+ void setSyncNet(const QString&);
+
+private:
+ bool telnetAvailable() const;
+ bool sshAvailable() const;
+ void updateGUI();
+
+ static void parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits);
+ void selectNet(int auth_peer,int auth_peer_bits);
+
+ QString enterPassCode(const QString&);
+ QString passcode;
+ bool valid;
+
+ QPEDialogListener *dl;
+};
+
+
+#endif // SECURITY_H
+
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 @@
+TEMPLATE = app
+CONFIG += qt warn_on release
+DESTDIR = ../../bin
+HEADERS = security.h
+SOURCES = security.cpp main.cpp
+INTERFACES = securitybase.ui
+INCLUDEPATH += $(QPEDIR)/include
+DEPENDPATH += ../$(QPEDIR)/include
+LIBS += -lqpe
+TARGET = security
+
+TRANSLATIONS = ../../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 @@
+<!DOCTYPE UI><UI>
+<class>SecurityBase</class>
+<widget>
+ <class>QDialog</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>SecurityBase</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>281</width>
+ <height>328</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>caption</name>
+ <string>Security Settings</string>
+ </property>
+ <property>
+ <name>layoutMargin</name>
+ </property>
+ <grid>
+ <property stdset="1">
+ <name>margin</name>
+ <number>11</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget row="0" column="0" >
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout1</cstring>
+ </property>
+ <property>
+ <name>layoutSpacing</name>
+ </property>
+ <hbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>-1</number>
+ </property>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>changepasscode</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Change passcode</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>clearpasscode</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Clear passcode</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget row="1" column="0" >
+ <class>QCheckBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>passcode_poweron</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Require pass code at power-on</string>
+ </property>
+ </widget>
+ <widget row="3" column="0" >
+ <class>QTabWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TabWidget2</cstring>
+ </property>
+ <widget>
+ <class>QWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>tab</cstring>
+ </property>
+ <attribute>
+ <name>title</name>
+ <string>Sync</string>
+ </attribute>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>11</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel1_2</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Accept sync from network:</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QComboBox</class>
+ <item>
+ <property>
+ <name>text</name>
+ <string>192.168.1.0/24 (default)</string>
+ </property>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>192.168.0.0/16</string>
+ </property>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>172.16.0.0/12</string>
+ </property>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>10.0.0.0/8</string>
+ </property>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>Any</string>
+ </property>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>None</string>
+ </property>
+ </item>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>syncnet</cstring>
+ </property>
+ <property stdset="1">
+ <name>editable</name>
+ <bool>true</bool>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </widget>
+ <widget row="2" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>7</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>&lt;P&gt;Pass code protection provides a minimal level of protection from casual access to this device.</string>
+ </property>
+ <property stdset="1">
+ <name>alignment</name>
+ <set>AlignTop|AlignLeft</set>
+ </property>
+ <property>
+ <name>vAlign</name>
+ </property>
+ </widget>
+ </grid>
+</widget>
+</UI>