Some clarifications in the terminology of the core config wizard.
authorMarcus Eggenberger <egs@quassel-irc.org>
Sun, 8 Jun 2008 11:07:11 +0000 (13:07 +0200)
committerMarcus Eggenberger <egs@quassel-irc.org>
Sun, 8 Jun 2008 11:08:06 +0000 (13:08 +0200)
Added the manageusers.py script to git.

scripts/manageusers.py [new file with mode: 0755]
src/qtui/configwizard.cpp [deleted file]
src/qtui/configwizard.h [deleted file]
src/qtui/coreconfigwizard.cpp
src/qtui/qtui.pri
src/qtui/ui/coreconfigwizardadminuserpage.ui

diff --git a/scripts/manageusers.py b/scripts/manageusers.py
new file mode 100755 (executable)
index 0000000..c327865
--- /dev/null
@@ -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 <username> <password>)" % 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 (file)
index c08ef6c..0000000
+++ /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 <QtGui>
-
-#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 (file)
index a63cd54..0000000
+++ /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 <QWizard>
-
-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_*/
index 792fbc0..799801a 100644 (file)
@@ -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);
index 0b18667..729a128 100644 (file)
@@ -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
 
index fcab077..cb6cc92 100644 (file)
@@ -5,7 +5,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>415</width>
+    <width>429</width>
     <height>273</height>
    </rect>
   </property>
    <item>
     <widget class="QLabel" name="label" >
      <property name="text" >
-      <string>&lt;em>Note: Adding more users and changing your username/password has not been implemented yet.</string>
+      <string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
+p, li { white-space: pre-wrap; }
+&lt;/style>&lt;/head>&lt;body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;">
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-style:italic;">Note: Adding more users and changing your username/password is not possible via Quassel's interface yet.&lt;/span>&lt;/p>
+&lt;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.&lt;/p>&lt;/body>&lt;/html></string>
      </property>
      <property name="alignment" >
       <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
@@ -80,7 +85,7 @@
      <property name="orientation" >
       <enum>Qt::Vertical</enum>
      </property>
-     <property name="sizeHint" >
+     <property name="sizeHint" stdset="0" >
       <size>
        <width>405</width>
        <height>51</height>