X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fauthenticator.h;h=543e93df15e512bc99e55ab7a8814f3887985792;hp=3bec6f6fa9c0140a29209121d74c7ee120d57904;hb=b134e777b822b929a78455fd92146bf7443e9aa1;hpb=423e088804d243368074ab218b2bda2fff3303c9 diff --git a/src/core/authenticator.h b/src/core/authenticator.h index 3bec6f6f..543e93df 100644 --- a/src/core/authenticator.h +++ b/src/core/authenticator.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2016 by the Quassel Project * + * Copyright (C) 2005-2020 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -21,27 +21,28 @@ #pragma once #include +#include #include #include #include #include "types.h" -class Authenticator : public QObject { - +class Authenticator : public QObject +{ Q_OBJECT public: - Authenticator(QObject *parent = 0); - virtual ~Authenticator() {}; + using QObject::QObject; + ~Authenticator() override = default; - enum State { + enum State + { IsReady, // ready to go NeedsSetup, // need basic setup (ask the user for input) NotAvailable // remove the authenticator backend from the list of avaliable authenticators. }; - public slots: // General @@ -64,36 +65,41 @@ public slots: /** \return A string that can be displayed by the client to describe the authenticator */ virtual QString description() const = 0; - //! Returns a list of properties required to use the authenticator backend - virtual QStringList setupKeys() const = 0; + //! Returns data required to configure the authenticator backend + /** + * A list of flattened triples for each field: {key, translated field name, default value} + * The default value's type determines the kind of input widget to be shown + * (int -> QSpinBox; QString -> QLineEdit) + * \return A list of triples defining the data to be shown in the configuration dialog + */ + virtual QVariantList setupData() const = 0; //! Checks if the authenticator allows manual password changes from inside quassel. virtual bool canChangePassword() const = 0; - //! Returns a map where the keys are are properties to use the authenticator backend - /* the values are QVariants with default values */ - virtual QVariantMap setupDefaults() const = 0; - //! Setup the authenticator provider. /** This prepares the authenticator provider (e.g. create tables, etc.) for use within Quassel. * \param settings Hostname, port, username, password, ... * \return True if and only if the authenticator provider was initialized successfully. */ - virtual bool setup(const QVariantMap &settings = QVariantMap()) = 0; + virtual bool setup(const QVariantMap& settings = QVariantMap(), + const QProcessEnvironment& environment = {}, + bool loadFromEnvironment = false) + = 0; //! Initialize the authenticator provider /** \param settings Hostname, port, username, password, ... * \return the State the authenticator backend is now in (see authenticator::State) */ - virtual State init(const QVariantMap &settings = QVariantMap()) = 0; + virtual State init(const QVariantMap& settings = QVariantMap(), + const QProcessEnvironment& environment = {}, + bool loadFromEnvironment = false) + = 0; //! Validate a username with a given password. /** \param user The username to validate * \param password The user's alleged password * \return A valid UserId if the password matches the username; 0 else */ - virtual UserId validateUser(const QString &user, const QString &password) = 0; - -private: - + virtual UserId validateUser(const QString& user, const QString& password) = 0; };