-rw-r--r-- | libopie2/opiesecurity/multiauthcommon.cpp | 19 | ||||
-rw-r--r-- | libopie2/opiesecurity/multiauthcommon.h | 3 | ||||
-rw-r--r-- | libopie2/opiesecurity/opiesecurity.pro | 1 |
3 files changed, 13 insertions, 10 deletions
diff --git a/libopie2/opiesecurity/multiauthcommon.cpp b/libopie2/opiesecurity/multiauthcommon.cpp index e563193..2760760 100644 --- a/libopie2/opiesecurity/multiauthcommon.cpp +++ b/libopie2/opiesecurity/multiauthcommon.cpp @@ -1,94 +1,97 @@ #include "multiauthplugininterface.h" #include "multiauthcommon.h" /* Opie */ #include <opie2/odebug.h> #include <opie2/oapplication.h> +#include <opie2/ocontactaccessbackend_vcard.h> +#include <opie2/ocontactaccess.h> /* Qt */ #include <qpe/qpeapplication.h> #include <qpe/qlibrary.h> #include <qpe/qcom.h> #include <qtextview.h> #include <qdir.h> /* UNIX */ #include <unistd.h> #include <qpe/config.h> namespace Opie { namespace Security { -SecOwnerDlg::SecOwnerDlg( QWidget *parent, const char * name, Contact c, +SecOwnerDlg::SecOwnerDlg( QWidget *parent, const char * name, const QString& c, bool modal, bool fullscreen = FALSE ) : QDialog( parent, name, modal, fullscreen ? WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop : 0 ) { if ( fullscreen ) { QRect desk = qApp->desktop()->geometry(); setGeometry( 0, 0, desk.width(), desk.height() ); } // set up contents. QString text("<H3>" + tr("Please contact the owner (directions follow), or try again clicking of this screen (and waiting for the penalty time) if you are the legitimate owner") + "</H3>"); - text += c.toRichText(); + text += c; tv = new QTextView(this); tv->setText(text); tv->viewport()->installEventFilter(this); } void SecOwnerDlg::resizeEvent( QResizeEvent * ) { tv->resize( size() ); } bool SecOwnerDlg::eventFilter(QObject *o, QEvent *e) { if (e->type() == QEvent::KeyPress || e->type() == QEvent::MouseButtonPress ) { accept(); return TRUE; } return QWidget::eventFilter(o, e); } void SecOwnerDlg::mousePressEvent( QMouseEvent * ) { accept(); } namespace Internal { /// run plugins until we reach nbSuccessMin successes int runPlugins() { SecOwnerDlg *oi = 0; // see if there is contact information. QString vfilename = Global::applicationFileName("addressbook", "businesscard.vcf"); - if (QFile::exists(vfilename)) { - Contact c; - c = Contact::readVCard( vfilename )[0]; - - oi = new SecOwnerDlg(0, 0, c, TRUE, TRUE); + Opie::OPimContactAccess acc( "multiauth", vfilename, + new Opie::OPimContactAccessBackend_VCard( "multiauth", vfilename ) ); + if ( acc.load() ) { + Opie::OPimContact contact = acc.allRecords()[0]; + if ( !contact.isEmpty() ) + oi = new SecOwnerDlg(0, 0, contact.toRichText(), TRUE, TRUE); } Config config("Security"); config.setGroup("Plugins"); QStringList plugins = config.readListEntry("IncludePlugins", ','); /* if there are no configured plugins, we simply return 0 to * let the user in: */ if (plugins.isEmpty() == true) { owarn << "No authentication plugin has been configured yet!" << oendl; odebug << "Letting the user in..." << oendl; if(oi) delete oi; return 0; } config.setGroup("Misc"); int nbSuccessMin = config.readNumEntry("nbSuccessMin", 1); int nbSuccess = 0; /* tries to launch successively each plugin in $OPIEDIR/plugins/security * directory which file name is in Security.conf / [Misc] / IncludePlugins */ QString path = QPEApplication::qpeDir() + "plugins/security"; QStringList::Iterator libIt; @@ -165,31 +168,31 @@ int runPlugins() { nbSuccess++; break; case MultiauthPluginObject::Failure: resultMessage = "Failure..."; break; case MultiauthPluginObject::Skip: resultMessage = "Skip"; break; } odebug << "Plugin result: " << resultMessage << oendl; } delete lib; if (resultCode == MultiauthPluginObject::Success && nbSuccess == nbSuccessMin) { if(oi) delete oi; // we have reached the required number of successes, we can exit the plugin loop return 0; } } else { owarn << "Could not recognize plugin " << QString( path + "/" + *libIt ) << oendl; delete lib; } // end if plugin recognized } //end for - if(oi) delete oi; + delete oi; return 1; } } } } diff --git a/libopie2/opiesecurity/multiauthcommon.h b/libopie2/opiesecurity/multiauthcommon.h index b728dae..42dff17 100644 --- a/libopie2/opiesecurity/multiauthcommon.h +++ b/libopie2/opiesecurity/multiauthcommon.h @@ -20,57 +20,56 @@ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef MULTIAUTHCOMMON_H #define MULTIAUTHCOMMON_H /* OwnerDialog stuff */ #include <qpe/global.h> #include <qpe/contact.h> #include <qtextview.h> #include <qdialog.h> - namespace Opie { namespace Security { /// QDialog simply showing the owner information class SecOwnerDlg : public QDialog { Q_OBJECT public: - SecOwnerDlg( QWidget *parent, const char * name, Contact c, + SecOwnerDlg( QWidget *parent, const char * name, const QString& owner, bool modal, bool fullscreen); void resizeEvent( QResizeEvent * ); bool eventFilter(QObject *o, QEvent *e); void mousePressEvent( QMouseEvent * ); private: QTextView *tv; private: struct Private; Private *d; }; namespace Internal { int runPlugins(); } } } #endif // MULTIAUTHCOMMON_H diff --git a/libopie2/opiesecurity/opiesecurity.pro b/libopie2/opiesecurity/opiesecurity.pro index 7171e67..d4d7925 100644 --- a/libopie2/opiesecurity/opiesecurity.pro +++ b/libopie2/opiesecurity/opiesecurity.pro @@ -1,17 +1,18 @@ TEMPLATE = lib CONFIG += qt warn_on DESTDIR = $(OPIEDIR)/lib HEADERS = multiauthcommon.h \ multiauthmainwindow.h \ multiauthconfigwidget.h \ multiauthplugininterface.h \ multiauthpassword.h SOURCES = multiauthcommon.cpp \ multiauthmainwindow.cpp \ multiauthpassword.cpp TARGET = opiesecurity2 VERSION = 0.0.2 INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include +LIBS += -lopiepim2 include( $(OPIEDIR)/include.pro ) |