diff --git a/password.cpp b/password.cpp index efd4b39..fd2b295 100644 --- a/password.cpp +++ b/password.cpp @@ -1,22 +1,59 @@ +#include "mainwindow.h" #include "password.h" #include #include -/*password::password("RsyncUI") -{ +using namespace std; -}*/ - -void password::store (QString account, QString password) +/*Password::Password() { + this->passwdJob->setObjectName(this->appName); + this->passwdJob->setAutoDelete(false); + this->passwdJob->connect(this->passwdJob, SIGNAL(finished(QKeychain::Job*)), this, SLOT(finished(QKeychain::Job*))); + //this->readPass->connect(this->readPass, SIGNAL(finished())) } -QString password::read(QString) +void Password::store (QString account, QString password) { + this->passwdJob->setKey(account); + this->passwdJob->setTextData(password); + this->passwdJob->start(); +} + +QString Password::read(QString account) +{ + this->readPass->setObjectName(""); + this->readPass->setKey(account); + this->readPass->start(); +} + +bool Password::remove(QString) +{ + } -bool password::remove(QString) +void Password::finished(QKeychain::Job * passwdJob) { - + if(passwdJob->error()) { + QMessageBox::warning( + NULL, + "RsyncUI", + QString(this->mw->tr("Error: Unable to save password!")) + QString(passwdJob->error())); + } } + +void Password::readReturn() +{ + if(this->readPass->error()) + { + QMessageBox::warning( + NULL, + "RsyncUI", + QString(this->mw->tr("Error: Unable to read password!")) + QString(readPass->error())); + }else + { + this->password = readPass->textData(); + } +} +*/ diff --git a/password.h b/password.h index b1b6ed6..da3e688 100644 --- a/password.h +++ b/password.h @@ -5,17 +5,25 @@ #include #include -class password +class Password : QObject { - password(QString); + public: + QString appName; + QKeychain::WritePasswordJob * passwdJob; + QKeychain::ReadPasswordJob * readPass; + MainWindow * mw; + QString password; - ~password(); + Password(); + ~Password(); - void store(QString, QString); + void store(QString, QString); + QString read(QString); + bool remove(QString); - QString read(QString); - - bool remove(QString); + private slots: + void finished(QKeychain::Job*); + void readReturn(); }; #endif // PASSWORD_H