Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

multiauthmainwindow.cpp

Go to the documentation of this file.
00001 #include "multiauthmainwindow.h"
00002 
00003 #include "multiauthcommon.h"
00004 #include <qpe/config.h>
00005 
00006 namespace Opie {
00007 namespace Security {
00008 
00010 
00013 MultiauthMainWindow::MultiauthMainWindow(bool allowBypass)
00014     : QDialog(0, "main Opie multiauth modal dialog", TRUE,
00015               Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop)
00016 
00017 {
00018     alreadyDone = false;
00019     // initializes widget pointers which not always point to an object
00020     quit = 0;
00021     message2 = 0;
00022 
00023     if (allowBypass == true)
00024         explanScreens = true;
00025     else
00026     {
00027         Config *pcfg = new Config("Security");
00028         pcfg->setGroup("Misc");
00029         explanScreens = pcfg->readBoolEntry("explanScreens", true);
00030         delete pcfg;
00031     }
00032 
00033     layout = new QVBoxLayout(this);
00034     layout->setSpacing(11);
00035     layout->setMargin(11);
00036     layout->setAlignment( Qt::AlignTop );
00037 
00038     // if explanScreens is false, we don't show any text in the QDialog,
00039     // and we proceed directly
00040     if ( explanScreens == true )
00041     {
00042         title = new QLabel("<center><h1>" + tr("Welcome to Opie") + "</h1></center>", this);
00043         message = new QLabel("<center><h3>" + tr("Launching authentication plugins...") + "</h3></center>", this);
00044     } else {
00045         title = new QLabel("", this);
00046         message = new QLabel("", this);
00047     }
00048 
00049     layout->addWidget(title);
00050     layout->addWidget(message);
00051     proceedButton = new QPushButton(tr("Proceed..."), this);
00052     layout->addWidget(proceedButton, 0, Qt::AlignHCenter);
00053 
00054     QObject::connect(proceedButton, SIGNAL(clicked()), this, SLOT(proceed()));
00055 
00056     if ( explanScreens == true )
00057     {
00058         quit = new QPushButton("Exit", this);
00059         layout->addWidget(quit, 0, Qt::AlignHCenter);
00060         if ( allowBypass == true )
00061         {
00062             // very important: we can close the widget through the quit button, and bypass authentication, only if allowBypass is set!
00063             message2 = new QLabel("<center><i>" + tr("Note: this 'exit' button only appears during <b>simulations</b>, like the one we are in. If you don't succeed a step, remember you can <b>skip</b> it.") + "</i></center>", this);
00064             layout->addWidget(message2);
00065             QObject::connect(quit, SIGNAL(clicked()), this, SLOT(close()));
00066         }
00067         else
00068         {
00069             quit->hide();
00070         }
00071 
00072     }
00073     else
00074     {
00075         // we will need this button only if runPlugins() fails in proceed()
00076         proceedButton->hide();
00077         // let's proceed now
00078         proceed();
00079     }
00080 }
00081 
00083 MultiauthMainWindow::~MultiauthMainWindow() {
00084 }
00085 
00087 void MultiauthMainWindow::proceed() {
00088     int result = Internal::runPlugins();
00089 
00090 
00091     if ( (result == 0) && !explanScreens )
00092     {
00093         // the authentication has succeeded, we can exit directly
00094         // this will work if we haven't been called by the constructor of MultiauthMainWindow
00095         close();
00096         // and if we've been called by this constructor, we use this variable to tell our
00097         // caller we're already done
00098         alreadyDone = true;
00099         return;
00100     }
00101     else
00102     {
00103 
00104         proceedButton->setText("Another try?");
00105         QString resultMessage;
00106 
00107         if (result == 0)
00108         {
00109             // authentication has succeeded, adapt interface then
00110             message->setText( "<center><h3>" + tr("Congratulations! Your authentication has been successful.") + "</h3></center>" );
00111             quit->setText("Enter Opie");
00112             if ( quit->isHidden() )
00113             {
00114                 // that means we don't allow to bypass, but now we can show and connect this button
00115                 QObject::connect(quit, SIGNAL(clicked()), this, SLOT(close()));
00116                 quit->show();
00117             } else {
00118                 if ( message2 != 0 ) message2->hide();
00119             }
00120         }
00121         else
00122         {
00123             // authentication has failed, explain that according to allowBypass
00124             message->setText( "<center><h3>" + tr("You have <b>not</b> succeeded enough authentication steps!") + "</h3></center>" );
00125             proceedButton->show();
00126             if ( allowBypass == true )
00127             {
00128                 message2->setText( "<center><p>" + tr("Be careful: if this was not a <b>simulation</b>, you would have to go back through all the steps now.") + "</p></center>" );
00129                 message2->show();
00130             }
00131         }
00132     }
00133 }
00134 
00140 bool MultiauthMainWindow::isAlreadyDone() {
00141     return alreadyDone;
00142 }
00143 
00144 }
00145 }

Generated on Sat Nov 5 16:16:23 2005 for OPIE by  doxygen 1.4.2