summaryrefslogtreecommitdiffstats
path: root/pica-client/askpassword.cpp
diff options
context:
space:
mode:
authorAnton <anton@picapica>2017-12-01 22:16:24 +0400
committerAnton <anton@picapica>2017-12-01 22:16:24 +0400
commit0f726c30f5f11990d325bc5e55015c42c80cd9d2 (patch)
treef8c9b83cc440dd3a2f43285dc35199435f6e2701 /pica-client/askpassword.cpp
parentac041927bc0c82e33acaa9e15fd46ecca0b77172 (diff)
downloadpica-pica-0f726c30f5f11990d325bc5e55015c42c80cd9d2.tar.gz
pica-pica-0f726c30f5f11990d325bc5e55015c42c80cd9d2.zip
fixed code style on all source files (*.c *.cpp *.h) using astyle --style=allman --lineend=linux --indent=tab --pad-oper
Diffstat (limited to 'pica-client/askpassword.cpp')
-rw-r--r--pica-client/askpassword.cpp98
1 files changed, 49 insertions, 49 deletions
diff --git a/pica-client/askpassword.cpp b/pica-client/askpassword.cpp
index 70f8644..cf21ed4 100644
--- a/pica-client/askpassword.cpp
+++ b/pica-client/askpassword.cpp
@@ -12,87 +12,87 @@ int AskPassword::is_cancelled = 0;
int AskPassword::is_set = 0;
AskPassword::AskPassword(QObject *parent) :
- QObject(parent)
+ QObject(parent)
{
- connect(this,SIGNAL(password_requested()),this,SLOT(password_dialog()), Qt::BlockingQueuedConnection);
+ connect(this, SIGNAL(password_requested()), this, SLOT(password_dialog()), Qt::BlockingQueuedConnection);
}
AskPassword::~AskPassword()
{
- memset(current_password, 0, sizeof(current_password));
+ memset(current_password, 0, sizeof(current_password));
}
int AskPassword::ask_password_cb(char *buf, int size, int rwflag, void *userdata)
{
- //QString pswd;
- //QByteArray id = QByteArray((const char*) userdata, PICA_ID_SIZE);
+ //QString pswd;
+ //QByteArray id = QByteArray((const char*) userdata, PICA_ID_SIZE);
- if (is_cancelled)
- return 0;
+ if (is_cancelled)
+ return 0;
- passwd_mutex.lock();
+ passwd_mutex.lock();
- if (!is_set || is_invalid)
- {
- if (askpassword->thread() != QThread::currentThread())
- askpassword->emit_sig();
- else
- askpassword->password_dialog();
- }
+ if (!is_set || is_invalid)
+ {
+ if (askpassword->thread() != QThread::currentThread())
+ askpassword->emit_sig();
+ else
+ askpassword->password_dialog();
+ }
- if (is_set)
- {
- strncpy(buf, current_password, size);
- buf[size - 1] = 0;
- }
+ if (is_set)
+ {
+ strncpy(buf, current_password, size);
+ buf[size - 1] = 0;
+ }
- passwd_mutex.unlock();
+ passwd_mutex.unlock();
- return is_set ? (strlen(buf)) : 0;
+ return is_set ? (strlen(buf)) : 0;
}
void AskPassword::emit_sig()
{
- emit password_requested();
+ emit password_requested();
}
void AskPassword::clear()
{
- passwd_mutex.lock();
- is_invalid = 0;
- is_set = 0;
- is_cancelled = 0;
- memset(current_password, 0, sizeof(current_password));
- passwd_mutex.unlock();
+ passwd_mutex.lock();
+ is_invalid = 0;
+ is_set = 0;
+ is_cancelled = 0;
+ memset(current_password, 0, sizeof(current_password));
+ passwd_mutex.unlock();
}
void AskPassword::setInvalidPassword()
{
- passwd_mutex.lock();
- is_invalid = 1;
- memset(current_password, 0, sizeof(current_password));
- passwd_mutex.unlock();
+ passwd_mutex.lock();
+ is_invalid = 1;
+ memset(current_password, 0, sizeof(current_password));
+ passwd_mutex.unlock();
}
void AskPassword::password_dialog()
{
- bool ok = false;
- QString title = is_invalid ? QObject::tr("Invalid passphrase, try again") : QObject::tr("Enter private key passphrase");
- QString text = QObject::tr(QString("Passphrase for account %1 \n (%2)")
- .arg(Accounts::GetCurrentAccount().name)
- .arg(Accounts::GetCurrentAccount().id.toBase64().constData()).toUtf8().constData());
- QString psw = QInputDialog::getText((QWidget*)mainwindow,title,text,QLineEdit::Password,QString(),&ok);
-
- if (ok)
- {
- strncpy(current_password, psw.toUtf8().constData(), sizeof(current_password));
- current_password[sizeof(current_password) - 1] = 0;
- is_set = 1;
- is_invalid = 0;
- }
- else
- is_cancelled = 1;
+ bool ok = false;
+ QString title = is_invalid ? QObject::tr("Invalid passphrase, try again") : QObject::tr("Enter private key passphrase");
+ QString text = QObject::tr(QString("Passphrase for account %1 \n (%2)")
+ .arg(Accounts::GetCurrentAccount().name)
+ .arg(Accounts::GetCurrentAccount().id.toBase64().constData()).toUtf8().constData());
+ QString psw = QInputDialog::getText((QWidget*)mainwindow, title, text, QLineEdit::Password, QString(), &ok);
+
+ if (ok)
+ {
+ strncpy(current_password, psw.toUtf8().constData(), sizeof(current_password));
+ current_password[sizeof(current_password) - 1] = 0;
+ is_set = 1;
+ is_invalid = 0;
+ }
+ else
+ is_cancelled = 1;
}