"Fossies" - the Fresh Open Source Software Archive

Member "ownCloud-2.9.1.5500/src/libsync/creds/credentialmanager.h" (13 Oct 2021, 1745 Bytes) of package /linux/misc/ownCloud-2.9.1.5500.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "credentialmanager.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.9.0.5150_vs_2.9.1.5500.

    1 #pragma once
    2 
    3 #include <QSettings>
    4 #include <QVariant>
    5 
    6 #include "owncloudlib.h"
    7 
    8 #include <qt5keychain/keychain.h>
    9 
   10 #include <memory>
   11 
   12 namespace OCC {
   13 class Account;
   14 class CredentialJob;
   15 
   16 class OWNCLOUDSYNC_EXPORT CredentialManager : public QObject
   17 {
   18     Q_OBJECT
   19 public:
   20     // global credentials
   21     CredentialManager(QObject *parent);
   22     // account related credentials
   23     explicit CredentialManager(Account *acc);
   24 
   25     CredentialJob *get(const QString &key);
   26     QKeychain::Job *set(const QString &key, const QVariant &data);
   27     QKeychain::Job *remove(const QString &key);
   28     /**
   29      * Delete all credentials asigned with an account
   30      */
   31     QVector<QPointer<QKeychain::Job>> clear(const QString &group = {});
   32 
   33     bool contains(const QString &key) const;
   34     const Account *account() const;
   35 
   36 private:
   37     QSettings &credentialsList() const;
   38 
   39     // TestCredentialManager
   40     QStringList knownKeys(const QString &group = {}) const;
   41 
   42     const Account *const _account = nullptr;
   43     mutable std::unique_ptr<QSettings> _credentialsList;
   44 
   45     friend class TestCredentialManager;
   46 };
   47 
   48 class OWNCLOUDSYNC_EXPORT CredentialJob : public QObject
   49 {
   50     Q_OBJECT
   51 public:
   52     QString key() const;
   53 
   54     QKeychain::Error error() const;
   55 
   56     const QVariant &data() const;
   57 
   58     QString errorString() const;
   59 
   60 Q_SIGNALS:
   61     void finished();
   62 
   63 private:
   64     CredentialJob(CredentialManager *parent, const QString &key);
   65     void start();
   66 
   67     QString _key;
   68     QVariant _data;
   69     QKeychain::Error _error = QKeychain::NoError;
   70     QString _errorString;
   71     bool _retryOnKeyChainError = true;
   72     QKeychain::ReadPasswordJob *_job;
   73 
   74     CredentialManager *const _parent;
   75 
   76     friend class CredentialManager;
   77     friend class TestCredentialManager;
   78 };
   79 
   80 
   81 }