[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/network/kvpnc/src
From:       Fathi Boudra <fabo () kde ! org>
Date:       2009-08-20 8:57:20
Message-ID: 1250758640.356793.32173.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1013532 by fabo:

commit current cisco certificate enrollment wizard port:
- control the port using QWIZARD_QT4_PORT definition until it's finished.
- change constructor parameters order.
- cleanup Q3Wizard implementation from extra spaces.


 M  +117 -57   ciscocertificateenrollment.cpp  
 M  +55 -2     ciscocertificateenrollment.h  
 M  +1 -2      kvpnc.cpp  


--- trunk/playground/network/kvpnc/src/ciscocertificateenrollment.cpp \
#1013531:1013532 @@ -20,23 +20,130 @@
 
 #include <QtCore/QObject>
 #include <QtGui/QCursor>
-#include <QtGui/QRadioButton>
-#include <QtGui/QWizard>
-#include <kcombobox.h>
+
 #include <kdebug.h>
-#include <klineedit.h>
 #include <klocale.h>
 #include <kmessagebox.h>
 #include <kpassworddialog.h>
-#include <kurlrequester.h>
 
-
 #include <unistd.h>
 
 #include "utils.h"
 
-CiscoCertificateEnrollment::CiscoCertificateEnrollment(QWidget *, const char*, \
KVpncConfig *GlobalConfig) +#if defined(QWIZARD_QT4_PORT)
+CiscoCertificateEnrollment::CiscoCertificateEnrollment(const QString &text, \
KVpncConfig *GlobalConfig, QWidget *parent) +    : QWizard(parent)
 {
+    addPage(new EnrollmentMethodPage);
+    addPage(new EnrollmentMethodPage);
+    addPage(new EnrollmentMethodPage);
+    setWindowTitle(text);
+}
+
+CiscoCertificateEnrollment::~CiscoCertificateEnrollment()
+{
+}
+
+void CiscoCertificateEnrollment::accept()
+{
+    QDialog::accept();
+}
+
+EnrollmentMethodPage::EnrollmentMethodPage(QWidget *parent)
+    : QWizardPage(parent)
+{
+    setTitle(i18n("Enrollment Method"));
+    setSubTitle(i18n("Select your enrollment method"));
+
+    onlineRadioButton = new QRadioButton(i18n("&Online"), this);
+    onlineRadioButton->setChecked(true);
+
+    caLabel = new QLabel(i18n("Certificate authority"), this);
+    caComboBox = new KComboBox(this);
+    
+    caUrlLabel = new QLabel(i18n("CA Url"), this);
+    caUrlLineEdit = new KLineEdit(this);
+
+    caDomainLabel = new QLabel(i18n("CA domain"), this);
+    caDomainLineEdit = new KLineEdit(this);
+
+    caChallengePasswordLabel = new QLabel(i18n("Challenge password"), this);
+    caChallengePasswordLineEdit = new KLineEdit(this);
+    caChallengePasswordLineEdit->setPasswordMode(true);
+
+    connect(onlineRadioButton, SIGNAL(toggled(bool)),
+            caLabel, SLOT(setEnabled(bool)));
+    connect(onlineRadioButton, SIGNAL(toggled(bool)),
+            caComboBox, SLOT(setEnabled(bool)));
+    connect(onlineRadioButton, SIGNAL(toggled(bool)),
+            caUrlLabel, SLOT(setEnabled(bool)));
+    connect(onlineRadioButton, SIGNAL(toggled(bool)),
+            caUrlLineEdit, SLOT(setEnabled(bool)));
+    connect(onlineRadioButton, SIGNAL(toggled(bool)),
+            caDomainLabel, SLOT(setEnabled(bool)));
+    connect(onlineRadioButton, SIGNAL(toggled(bool)),
+            caDomainLineEdit, SLOT(setEnabled(bool)));
+    connect(onlineRadioButton, SIGNAL(toggled(bool)),
+            caChallengePasswordLabel, SLOT(setEnabled(bool)));
+    connect(onlineRadioButton, SIGNAL(toggled(bool)),
+            caChallengePasswordLineEdit, SLOT(setEnabled(bool)));
+
+    fileRadioButton = new QRadioButton("Fi&le", this);
+
+    fileEncodingLabel = new QLabel(i18n("File encoding"), this);
+    fileEncodingLabel->setEnabled(false);
+    QStringList fileEncodingList;
+    fileEncodingList << i18n("Binary") << i18n("Base64");
+    fileEncodingComboBox = new KComboBox(this);
+    fileEncodingComboBox->insertItems(0, fileEncodingList);
+    fileEncodingComboBox->setEnabled(false);
+
+    filenameLabel = new QLabel(i18n("Filename"), this);
+    filenameLabel->setEnabled(false);
+    filenameUrlRequester = new KUrlRequester(this);
+    filenameUrlRequester->setEnabled(false);
+
+    newPasswordLabel = new QLabel(i18n("New password"), this);
+    newPasswordLabel->setEnabled(false);
+    newPasswordLineEdit = new KLineEdit(this);
+    newPasswordLineEdit->setEnabled(false);
+
+    connect(fileRadioButton, SIGNAL(toggled(bool)),
+            fileEncodingLabel, SLOT(setEnabled(bool)));
+    connect(fileRadioButton, SIGNAL(toggled(bool)),
+            fileEncodingComboBox, SLOT(setEnabled(bool)));
+    connect(fileRadioButton, SIGNAL(toggled(bool)),
+            filenameLabel, SLOT(setEnabled(bool)));
+    connect(fileRadioButton, SIGNAL(toggled(bool)),
+            filenameUrlRequester, SLOT(setEnabled(bool)));
+    connect(fileRadioButton, SIGNAL(toggled(bool)),
+            newPasswordLabel, SLOT(setEnabled(bool)));
+    connect(fileRadioButton, SIGNAL(toggled(bool)),
+            newPasswordLineEdit, SLOT(setEnabled(bool)));
+
+    QGridLayout *layout = new QGridLayout;
+    layout->addWidget(onlineRadioButton, 0, 0);
+    layout->addWidget(caLabel, 1, 0);
+    layout->addWidget(caComboBox, 1, 1);
+    layout->addWidget(caUrlLabel, 2, 0);
+    layout->addWidget(caUrlLineEdit, 2, 1);
+    layout->addWidget(caDomainLabel, 3, 0);
+    layout->addWidget(caDomainLineEdit, 3, 1);
+    layout->addWidget(caChallengePasswordLabel, 4, 0);
+    layout->addWidget(caChallengePasswordLineEdit, 4, 1);
+    layout->addWidget(fileRadioButton, 5, 0);
+    layout->addWidget(fileEncodingLabel, 6, 0);
+    layout->addWidget(fileEncodingComboBox, 6, 1);
+    layout->addWidget(filenameLabel, 7, 0);
+    layout->addWidget(filenameUrlRequester, 7, 1);
+    layout->addWidget(newPasswordLabel, 8, 0);
+    layout->addWidget(newPasswordLineEdit, 8, 1);
+    setLayout(layout);
+}
+#else
+CiscoCertificateEnrollment::CiscoCertificateEnrollment(const QString &text, \
KVpncConfig *GlobalConfig, QWidget *parent) +    : Q3Wizard(parent)
+{
     this->GlobalConfig = GlobalConfig;
     valuesOk = true;
     type = "";
@@ -77,9 +184,6 @@
 
 void CiscoCertificateEnrollment::canAccept()
 {
-
-
-
     QDialog::accept();
 }
 
@@ -131,7 +235,6 @@
 
 //  finishpage->main->sizeHint();
     addPage((QWidget *)finishpage, "<b>" + i18n("Finish") + "</b>");
-
 }
 
 void CiscoCertificateEnrollment::next()
@@ -208,7 +311,6 @@
                     GlobalConfig->appendLogEntry(i18nc("cleartext means the password \
is visible", "Challenge password (cleartext): %1" ,   \
                selectionpage->main->ChallengePasswordPasswordEdit->text()), \
                KVpncEnum::debug);
                 ChallengePassword = \
QString(selectionpage->main->ChallengePasswordPasswordEdit->text());  }
-
         }
     }
 
@@ -251,7 +353,6 @@
             GlobalConfig->appendLogEntry(i18n("Country: %1" ,   \
datapage->main->CountryLineEdit->text()), KVpncEnum::debug);  Country = \
datapage->main->CountryLineEdit->text();  
-
         // now do the work
         successmsg = i18n("Enrollment was successful.");
         success = 0;
@@ -271,7 +372,6 @@
             }
         }
 
-
         GlobalConfig->appPointer->setOverrideCursor(QCursor(Qt::WaitCursor));
 
         env = new QStringList();
@@ -333,21 +433,15 @@
                 args.append("-ip");
                 args.append(Ip);
             }
-
-
         }
 
         connect(EnrollmentProcess, SIGNAL(readyReadStandardOutput()), this, \
                SLOT(readFromStdout()));
         connect(EnrollmentProcess, SIGNAL(readyReadStandardError()), this, \
                SLOT(readFromStderr()));
         connect(EnrollmentProcess, SIGNAL(finished(int, QProcess::ExitStatus)) , \
this, SLOT(enrollmentProcessFinished(int, QProcess::ExitStatus)));  
-
-
-
         if (GlobalConfig->KvpncDebugLevel > 3)
             GlobalConfig->appendLogEntry(i18n("EnrollmentProcess args: ") + \
args.join(" "), KVpncEnum::debug);  
-
         EnrollmentProcess->setEnvironment(*env);
         EnrollmentProcess->start(proc, args);
         if (!EnrollmentProcess->waitForStarted()) {
@@ -370,29 +464,17 @@
             CheckEnrollmentTimer.setSingleShot(false);
             CheckEnrollmentTimer.start(500);
 
-            // we stupid have to send the password :(
-//    EnrollmentProcess->writeToStdin ( ChallengePassword + "\n" );
-
-//    if ( GlobalConfig->KvpncDebugLevel > 4 )
-//     GlobalConfig->appendLogEntry ( i18n ( "Send challenge password: %1" ),QString \
                (selectionpage->main->ChallengePasswordPasswordEdit->text()  ), \
                KVpncEnum::debug );
-
-
-
             if (ProgressDlg != 0)
                 ProgressDlg->progressBar()->setValue(33);
 
         }
-
-
     }
 
     if (currentpage == (QWidget *)finishpage) {
-
         if (GlobalConfig->KvpncDebugLevel > 2)
             GlobalConfig->appendLogEntry(i18n("Enrollment finished: %1." ,   \
successmsg), KVpncEnum::debug);  }
 
-
     if (ok) {
         previouspage = currentpage;
         Q3Wizard::next();
@@ -403,17 +485,6 @@
 
 void CiscoCertificateEnrollment::back()
 {
-    /*
-    currentpage=previouspage;
-    //  showPage(previouspage);
-
-    if ( currentpage == page1 )
-    {
-     // nothing here
-    }
-
-
-    */
     Q3Wizard::back();
 }
 
@@ -422,7 +493,6 @@
     currentpage = page;
     Q3Wizard::showPage(page);
 
-
     // FIXME set currentpage at back()
     //backButton()->setEnabled(false);
 
@@ -438,8 +508,10 @@
     disconnect(EnrollmentProcess, SIGNAL(readyReadStandardOutput()), this, \
                SLOT(readFromStdout()));
     disconnect(EnrollmentProcess, SIGNAL(readyReadStandardError()), this, \
                SLOT(readFromStderr()));
     disconnect(EnrollmentProcess, SIGNAL(finished(int, QProcess::ExitStatus)) , \
this, SLOT(cancelProcessFinished(int, QProcess::ExitStatus))); +
     if (ProgressDlg != 0)
         ProgressDlg->progressBar()->setValue(100);
+
     GlobalConfig->appPointer->restoreOverrideCursor();
     finishpage->main->successTextLabel->setText(successmsg);
     finishButton() ->setEnabled(true);
@@ -498,7 +570,6 @@
         if (GlobalConfig->KvpncDebugLevel > 2)
             GlobalConfig->appendLogEntry("[cisco_cert_mgr raw] " + line, \
KVpncEnum::debug);  
-
         if (line.indexOf("Password:" , 0) > -1) {
             if (GlobalConfig->KvpncDebugLevel > 0)
                 GlobalConfig->appendLogEntry(i18n("Certificate enrollment: %1 was \
requested, send it..." ,   i18n(" challenge password")), KVpncEnum::debug); @@ -517,7 \
                +588,6 @@
             GlobalConfig->appendLogEntry(i18n("Certificate enrollment: contacting \
CA...") , KVpncEnum::info);  }
 
-
         if (line.indexOf("Success: certificate enrollment completed with no errors." \
, 0) > -1) {  if (ProgressDlg != 0)
                 ProgressDlg->progressBar()->setValue(99);
@@ -527,7 +597,6 @@
                 successmsg = "The enrollment was successful. The CA has granted the \
request. The user and CA certificates are imported.";  }
         }
-
     }
 }
 
@@ -546,11 +615,8 @@
             success = -1;
             successmsg = i18n("Enrollment has failed.");
 //    GlobalConfig->appPointer->restoreOverrideCursor();
-
-
         }
     }
-
 //  success=-1;
 }
 
@@ -559,7 +625,6 @@
     if (GlobalConfig->KvpncDebugLevel > 6)
         GlobalConfig->appendLogEntry(i18n("Enrollment timer event"), \
KVpncEnum::debug);  
-
     if (ProgressDlg->wasCancelled()) {
         // user has canceled the dlg, so we have to stop here
         if (GlobalConfig->KvpncDebugLevel > 2)
@@ -627,7 +692,6 @@
     } else {
         // nothing to do...
     }
-
 }
 
 void CiscoCertificateEnrollment::cancelProcessFinished(int, QProcess::ExitStatus)
@@ -644,13 +708,11 @@
 
 void CiscoCertificateEnrollment::readFromStdout_cancel()
 {
-
     QStringList msg_list = \
QString(DeleteProcess->readAllStandardOutput()).split('\n');  for (int i = 0; i < \
msg_list.size(); ++i) {  QString line = msg_list.at(i);
         if (GlobalConfig->KvpncDebugLevel > 2)
             GlobalConfig->appendLogEntry("[cisco_cert_mgr raw] " + line, \
                KVpncEnum::debug);
-
     }
 }
 
@@ -661,10 +723,8 @@
         QString line = msg_list.at(i);
         if (GlobalConfig->KvpncDebugLevel > 2)
             GlobalConfig->appendLogEntry("[cisco_cert_mgr err raw] " + line, \
                KVpncEnum::debug);
-
     }
 
 //  success=-1;
 }
-
-
+#endif
--- trunk/playground/network/kvpnc/src/ciscocertificateenrollment.h #1013531:1013532
@@ -19,8 +19,16 @@
 #ifndef CISCOCERTIFICATEENROLLMENT_H
 #define CISCOCERTIFICATEENROLLMENT_H
 
+//#define QWIZARD_QT4_PORT
+
+#if defined(QWIZARD_QT4_PORT)
+#include <QtGui/QWizard>
+#else
+#include <Qt3Support/Q3Wizard>
+
+#endif
+
 #include <QProcess>
-#include <Qt3Support/Q3Wizard>
 #include <QtCore/QString>
 #include <QtCore/QStringList>
 #include <QtCore/QTimer>
@@ -33,12 +41,56 @@
 #include "ciscocertificateenrollmentdatadialog.h"
 #include "kvpncconfig.h"
 
+class QRadioButton;
+class QLabel;
+class KComboBox;
+class KLineEdit;
+class KUrlRequester;
+
+#if defined(QWIZARD_QT4_PORT)
+class CiscoCertificateEnrollment : public QWizard
+{
+    Q_OBJECT
+
+public:
+    CiscoCertificateEnrollment(const QString &text, KVpncConfig *GlobalConfig = 0, \
QWidget *parent = 0); +    ~CiscoCertificateEnrollment();
+
+    void accept();
+};
+
+class EnrollmentMethodPage : public QWizardPage
+{
+    Q_OBJECT
+
+public:
+    EnrollmentMethodPage(QWidget *parent = 0);
+
+private:
+    QRadioButton *onlineRadioButton;
+    QLabel *caLabel;
+    KComboBox *caComboBox;
+    QLabel *caUrlLabel;
+    KLineEdit *caUrlLineEdit;
+    QLabel *caDomainLabel;
+    KLineEdit *caDomainLineEdit;
+    QLabel *caChallengePasswordLabel;
+    KLineEdit *caChallengePasswordLineEdit;
+    QRadioButton *fileRadioButton;
+    QLabel *fileEncodingLabel;
+    KComboBox *fileEncodingComboBox;
+    QLabel *filenameLabel;
+    KUrlRequester *filenameUrlRequester;
+    QLabel *newPasswordLabel;
+    KLineEdit *newPasswordLineEdit;
+};
+#else
 class CiscoCertificateEnrollment : public Q3Wizard
 {
     Q_OBJECT
 
 public:
-    CiscoCertificateEnrollment(QWidget *parent, const char* caption, KVpncConfig \
*GlobalConfig); +    CiscoCertificateEnrollment(const QString &text, KVpncConfig \
*GlobalConfig = 0, QWidget *parent = 0);  ~CiscoCertificateEnrollment();
 
     QProcess *EnrollmentProcess;
@@ -96,5 +148,6 @@
 private:
     QTimer CheckEnrollmentTimer;
 };
+#endif
 
 #endif
--- trunk/playground/network/kvpnc/src/kvpnc.cpp #1013531:1013532
@@ -18401,8 +18401,7 @@
 
 void KVpnc::enrollCiscoCertClicked()
 {
-    CiscoCertificateEnrollment dlg(this, i18n("Enroll certificate...").toAscii(), \
                GlobalConfig);
-    //int result =
+    CiscoCertificateEnrollment dlg(i18n("Enroll certificate..."), GlobalConfig, \
this);  dlg.exec();
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic