From 4f9dd5e4618a2ae5b14a6dab871ad5d7c984500d Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Sun, 8 Jun 2008 13:07:11 +0200 Subject: [PATCH] Some clarifications in the terminology of the core config wizard. Added the manageusers.py script to git. --- scripts/manageusers.py | 56 +++++ src/qtui/configwizard.cpp | 202 ------------------- src/qtui/configwizard.h | 120 ----------- src/qtui/coreconfigwizard.cpp | 4 +- src/qtui/qtui.pri | 4 +- src/qtui/ui/coreconfigwizardadminuserpage.ui | 11 +- 6 files changed, 68 insertions(+), 329 deletions(-) create mode 100755 scripts/manageusers.py delete mode 100644 src/qtui/configwizard.cpp delete mode 100644 src/qtui/configwizard.h diff --git a/scripts/manageusers.py b/scripts/manageusers.py new file mode 100755 index 00000000..c327865f --- /dev/null +++ b/scripts/manageusers.py @@ -0,0 +1,56 @@ +#!/usr/bin/python +# -*- coding: iso-8859-1 -*- + +# ============================== +# Imports +# ============================== +import os +import sha +import sys + +try: + import sqlite3 +except ImportError: + print >> sys.stderr, "ERROR: sqlite3 module not available!" + print >> sys.stderr, "This script needs sqlite3 support which is part of Python 2.5" + print >> sys.stderr, "You probably need to upgrade your Python installation first." + sys.exit(3) + +class UserManager(object): + def __init__(self): + self.db = sqlite3.connect(os.environ['HOME'] + '/.quassel/quassel-storage.sqlite') + + def __del__(self): + self.db.commit() + self.db.close(); + + def shaCrypt(self, password): + shaPass = sha.new(password) + return shaPass.hexdigest() + + def addUser(self, username, password): + cursor = self.db.cursor() + cursor.execute('INSERT INTO quasseluser (username, password) VALUES (:username, :password)', + {'username':username, 'password':self.shaCrypt(password)}) + + def changePass(self, username, password): + cursor = self.db.cursor() + cursor.execute('UPDATE quasseluser SET password = :password WHERE username = :username', + {'username':username, 'password':self.shaCrypt(password)}) + +if __name__ == "__main__": + generalError = "ERROR: Wrong arugment count (Syntax: %s add|changepass )" % sys.argv[0] + if len(sys.argv) < 3: + print generalError + sys.exit(1) + + if sys.argv[1].lower() not in ['add', 'changepass']: + print generalError + sys.exit(2) + + userManager = UserManager() + actions = {'add':userManager.addUser, + 'changepass':userManager.changePass} + + actions[sys.argv[1]](sys.argv[2], sys.argv[3]) + diff --git a/src/qtui/configwizard.cpp b/src/qtui/configwizard.cpp deleted file mode 100644 index c08ef6ca..00000000 --- a/src/qtui/configwizard.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * - * devel@quassel-irc.org * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) version 3. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include - -#include "configwizard.h" - -ConfigWizard::ConfigWizard(const QStringList &storageProviders, QWidget *parent) : QWizard(parent) { - setPage(Page_Intro, new IntroPage()); - setPage(Page_AdminUser, new AdminUserPage()); - setPage(Page_StorageSelection, new StorageSelectionPage(storageProviders)); - setPage(Page_StorageDetails, new StorageDetailsPage()); - setPage(Page_Conclusion, new ConclusionPage(storageProviders)); - - setStartId(Page_Intro); - -#ifndef Q_WS_MAC - setWizardStyle(ModernStyle); -#endif - - setOption(HaveHelpButton, false); - setOption(NoBackButtonOnStartPage, true); - setOption(HaveNextButtonOnLastPage, false); - setOption(HaveFinishButtonOnEarlyPages, false); - setOption(NoCancelButton, true); - - setWindowTitle(tr("Core Configuration Wizard")); -} - - -IntroPage::IntroPage(QWidget *parent) : QWizardPage(parent) { - setTitle(tr("Introduction")); - - label = new QLabel(tr("This wizard will guide you through the setup process for your shiny new Quassel IRC Client.")); - label->setWordWrap(true); - - QVBoxLayout *layout = new QVBoxLayout(); - layout->addWidget(label); - setLayout(layout); -} - -int IntroPage::nextId() const { - return ConfigWizard::Page_AdminUser; -} - - -AdminUserPage::AdminUserPage(QWidget *parent) : QWizardPage(parent) { - setTitle(tr("Setup Admin User")); - setSubTitle(tr("Please enter credentials for the admin user.")); - - nameLabel = new QLabel(tr("Name:")); - nameEdit = new QLineEdit(); - nameLabel->setBuddy(nameEdit); - - passwordLabel = new QLabel(tr("Password:")); - passwordEdit = new QLineEdit(); - passwordEdit->setEchoMode(QLineEdit::Password); - passwordLabel->setBuddy(passwordLabel); - - registerField("adminuser.name*", nameEdit); - registerField("adminuser.password*", passwordEdit); - - QGridLayout *layout = new QGridLayout(); - layout->addWidget(nameLabel, 0, 0); - layout->addWidget(nameEdit, 0, 1); - layout->addWidget(passwordLabel, 1, 0); - layout->addWidget(passwordEdit, 1, 1); - setLayout(layout); -} - -int AdminUserPage::nextId() const { - return ConfigWizard::Page_StorageSelection; -} - - -StorageSelectionPage::StorageSelectionPage(const QStringList &storageProviders, QWidget *parent) : QWizardPage(parent) { - setTitle(tr("Select Storage Provider")); - setSubTitle(tr("Please select the storage provider you want to use.")); - - storageSelection = new QComboBox(); - storageSelection->addItems(storageProviders); - - registerField("storage.provider", storageSelection); - - QVBoxLayout *layout = new QVBoxLayout(); - layout->addWidget(storageSelection); - setLayout(layout); -} - -int StorageSelectionPage::nextId() const { - QString selection = storageSelection->currentText(); - if (!selection.compare("Sqlite", Qt::CaseInsensitive)) { - return ConfigWizard::Page_Conclusion; - } else { - return ConfigWizard::Page_StorageDetails; - } -} - - -StorageDetailsPage::StorageDetailsPage(QWidget *parent) : QWizardPage(parent) { - setTitle(tr("Setup Storage Provider")); - setSubTitle(tr("Please enter credentials for the selected storage provider.")); - - hostLabel = new QLabel(tr("Host:")); - hostEdit = new QLineEdit(); - hostLabel->setBuddy(hostEdit); - - portLabel = new QLabel(tr("Port:")); - portEdit = new QLineEdit(); - QIntValidator *portValidator = new QIntValidator(0, 65535, this); - portEdit->setValidator(portValidator); - portLabel->setBuddy(portEdit); - - databaseLabel = new QLabel(tr("Database:")); - databaseEdit = new QLineEdit(); - databaseLabel->setBuddy(databaseEdit); - - userLabel = new QLabel(tr("User:")); - userEdit = new QLineEdit(); - userLabel->setBuddy(userEdit); - - passwordLabel = new QLabel(tr("Password:")); - passwordEdit = new QLineEdit(); - passwordEdit->setEchoMode(QLineEdit::Password); - passwordLabel->setBuddy(passwordLabel); - - registerField("storage.host*", hostEdit); - registerField("storage.port*", portEdit); - registerField("storage.database*", databaseEdit); - registerField("storage.user*", userEdit); - registerField("storage.password*", passwordEdit); - - QGridLayout *layout = new QGridLayout(); - layout->addWidget(hostLabel, 0, 0); - layout->addWidget(hostEdit, 0, 1); - layout->addWidget(portLabel, 1, 0); - layout->addWidget(portEdit, 1, 1); - layout->addWidget(databaseLabel, 2, 0); - layout->addWidget(databaseEdit, 2, 1); - layout->addWidget(userLabel, 3, 0); - layout->addWidget(userEdit, 3, 1); - layout->addWidget(passwordLabel, 4, 0); - layout->addWidget(passwordEdit, 4, 1); - setLayout(layout); -} - -int StorageDetailsPage::nextId() const { - return ConfigWizard::Page_Conclusion; -} - - -ConclusionPage::ConclusionPage(const QStringList &storageProviders, QWidget *parent) : QWizardPage(parent) { - setTitle(tr("Conclusion")); - setSubTitle(tr("You chose the following configuration:")); - - this->storageProviders = storageProviders; - - adminuser = new QLabel(); - storage = new QLabel(); - storage->setWordWrap(true); - - QVBoxLayout *layout = new QVBoxLayout(); - layout->addWidget(adminuser); - layout->addWidget(storage); - setLayout(layout); -} - -int ConclusionPage::nextId() const { - return -1; -} - -void ConclusionPage::initializePage() { - QString adminuserText = "Admin User: " + field("adminuser.name").toString(); - adminuser->setText(adminuserText); - - QString storageText = "Selected Storage Provider: "; - QString sp = storageProviders.value(field("storage.provider").toInt()); - if (!sp.compare("Sqlite", Qt::CaseInsensitive)) { - storageText.append(sp); - } else { - storageText += sp + "\nHost: " + field("storage.host").toString() + "\nPort: " + field("storage.port").toString() + "\nDatabase: " + field("storage.database").toString() + "\nUser: " + field("storage.user").toString(); - } - storage->setText(storageText); -} - diff --git a/src/qtui/configwizard.h b/src/qtui/configwizard.h deleted file mode 100644 index a63cd549..00000000 --- a/src/qtui/configwizard.h +++ /dev/null @@ -1,120 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * - * devel@quassel-irc.org * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) version 3. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#ifndef CONFIGWIZARD_H_ -#define CONFIGWIZARD_H_ - -#include - -class QLabel; -class QLineEdit; -class QComboBox; - -class ConfigWizard : public QWizard { - Q_OBJECT - - public: - enum { - Page_Intro, - Page_AdminUser, - Page_StorageSelection, - Page_StorageDetails, - Page_Conclusion - }; - - ConfigWizard(const QStringList &storageProviders, QWidget *parent = NULL); -}; - -class IntroPage : public QWizardPage { - Q_OBJECT - - public: - IntroPage(QWidget *parent = NULL); - - int nextId() const; - - private: - QLabel *label; -}; - -class AdminUserPage : public QWizardPage { - Q_OBJECT - - public: - AdminUserPage(QWidget *parent = NULL); - - int nextId() const; - - private: - QLabel *nameLabel; - QLineEdit *nameEdit; - QLabel *passwordLabel; - QLineEdit *passwordEdit; -}; - -class StorageSelectionPage : public QWizardPage { - Q_OBJECT - - public: - StorageSelectionPage(const QStringList &storageProviders, QWidget *parent = NULL); - - int nextId() const; - - private: - QComboBox *storageSelection; -}; - -class StorageDetailsPage : public QWizardPage { - Q_OBJECT - - public: - StorageDetailsPage(QWidget *parent = NULL); - - int nextId() const; - - private: - QLabel *hostLabel; - QLineEdit *hostEdit; - QLabel *portLabel; - QLineEdit *portEdit; - QLabel *databaseLabel; - QLineEdit *databaseEdit; - QLabel *userLabel; - QLineEdit *userEdit; - QLabel *passwordLabel; - QLineEdit *passwordEdit; -}; - -class ConclusionPage : public QWizardPage { - Q_OBJECT - - public: - ConclusionPage(const QStringList &storageProviders, QWidget *parent = NULL); - - void initializePage(); - int nextId() const; - - private: - QLabel *adminuser; - QLabel *storage; - QStringList storageProviders; -}; - -#endif /*CONFIGWIZARD_H_*/ diff --git a/src/qtui/coreconfigwizard.cpp b/src/qtui/coreconfigwizard.cpp index 792fbc0b..799801a3 100644 --- a/src/qtui/coreconfigwizard.cpp +++ b/src/qtui/coreconfigwizard.cpp @@ -135,8 +135,8 @@ int IntroPage::nextId() const { AdminUserPage::AdminUserPage(QWidget *parent) : QWizardPage(parent) { ui.setupUi(this); - setTitle(tr("Create User Account")); - setSubTitle(tr("First, we will create a user account on the core. This first user will have administrator privileges.")); + setTitle(tr("Create Admin User")); + setSubTitle(tr("First, we will create a user on the core. This first user will have administrator privileges.")); registerField("adminUser.user*", ui.user); registerField("adminUser.password*", ui.password); diff --git a/src/qtui/qtui.pri b/src/qtui/qtui.pri index 0b186674..729a128a 100644 --- a/src/qtui/qtui.pri +++ b/src/qtui/qtui.pri @@ -2,12 +2,12 @@ DEPMOD = client common uisupport QT_MOD = core gui network SRCS += aboutdlg.cpp bufferwidget.cpp chatline-old.cpp chatwidget.cpp \ - coreconfigwizard.cpp coreconnectdlg.cpp configwizard.cpp debugconsole.cpp inputwidget.cpp \ + coreconfigwizard.cpp coreconnectdlg.cpp debugconsole.cpp inputwidget.cpp \ mainwin.cpp nicklistwidget.cpp qtui.cpp qtuisettings.cpp qtuistyle.cpp settingsdlg.cpp settingspagedlg.cpp \ titlesetter.cpp topicbutton.cpp topicwidget.cpp verticaldock.cpp jumpkeyhandler.cpp HDRS += aboutdlg.h bufferwidget.h chatline-old.h chatwidget.h \ - coreconfigwizard.h configwizard.h debugconsole.h inputwidget.h \ + coreconfigwizard.h debugconsole.h inputwidget.h \ coreconnectdlg.h mainwin.h nicklistwidget.h qtui.h qtuisettings.h qtuistyle.h settingsdlg.h settingspagedlg.h \ titlesetter.h topicbutton.h topicwidget.h verticaldock.h jumpkeyhandler.h diff --git a/src/qtui/ui/coreconfigwizardadminuserpage.ui b/src/qtui/ui/coreconfigwizardadminuserpage.ui index fcab0778..cb6cc92a 100644 --- a/src/qtui/ui/coreconfigwizardadminuserpage.ui +++ b/src/qtui/ui/coreconfigwizardadminuserpage.ui @@ -5,7 +5,7 @@ 0 0 - 415 + 429 273 @@ -65,7 +65,12 @@ - <em>Note: Adding more users and changing your username/password has not been implemented yet. + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Note: Adding more users and changing your username/password is not possible via Quassel's interface yet.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-style:italic;">If you need to do these things have a look at the manageusers.py script which is located in the /scripts directory.</p></body></html> Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop @@ -80,7 +85,7 @@ Qt::Vertical - + 405 51 -- 2.20.1