Пример #1
0
PasswordJob::PasswordJob(QObject *parent) : PluginJob(parent)
{
    connect(this, SIGNAL(error(Plugins::PasswordJob::Error,QString)), this, SLOT(finished()));
    connect(this, SIGNAL(passwordAvailable(QString,QString,QString)), this, SLOT(finished()));
    connect(this, SIGNAL(passwordDeleted(QString)), this, SLOT(finished()));
    connect(this, SIGNAL(passwordStored(QString)), this, SLOT(finished()));
}
void QtKeyChainPasswordJob::result()
{
    switch (m_job->error()) {
    case QKeychain::NoError:
        break;
    case QKeychain::EntryNotFound:
        emit error(PasswordJob::NoSuchPassword, QString());
        return;
    default:
        emit error(PasswordJob::UnknownError, m_job->errorString());
        return;
    }

    switch (m_type) {
    case Request:
        m_password = qobject_cast<QKeychain::ReadPasswordJob *>(m_job)->textData();
        emit passwordAvailable(m_password);
        return;
    case Store:
        emit passwordStored();
        return;
    case Delete:
        emit passwordDeleted();
        return;
    }
}