File indexing completed on 2024-04-21 16:17:32
0001 /* 0002 * SPDX-FileCopyrightText: 2012 Alejandro Fiestas Olivares <afiestas@kde.org> 0003 * SPDX-FileCopyrightText: 2014 Daniel Vrátil <dvratil@redhat.com> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.1-or-later 0006 */ 0007 0008 #ifndef ABSTRACT_BACKEND_H 0009 #define ABSTRACT_BACKEND_H 0010 0011 #include "kscreen_export.h" 0012 #include "types.h" 0013 0014 #include <QObject> 0015 #include <QString> 0016 0017 namespace KScreen 0018 { 0019 class Config; 0020 0021 /** 0022 * Abstract class for backends. 0023 */ 0024 class KSCREEN_EXPORT AbstractBackend : public QObject 0025 { 0026 Q_OBJECT 0027 0028 public: 0029 ~AbstractBackend() override 0030 { 0031 } 0032 0033 /** 0034 * This is where the backend should perform all initialization. This method 0035 * is always called right after the backend is created. 0036 * 0037 * Default implementation does nothing. 0038 * 0039 * @p arguments Optional arguments passed by caller. Used mostly for unit-testing. 0040 */ 0041 virtual void init(const QVariantMap &arguments); 0042 0043 /** 0044 * Returns a user-friendly name of the backend. 0045 */ 0046 virtual QString name() const = 0; 0047 0048 /** 0049 * Returns the name of the DBus service that should be used for this backend. 0050 * 0051 * Each backend must have an unique service name (usually something like 0052 * org.kde.KScreen.Backend.%backendName%) to allow multiple different backends 0053 * running concurrently. 0054 */ 0055 virtual QString serviceName() const = 0; 0056 0057 /** 0058 * Returns a new Config object, holding Screen, Output objects, etc. 0059 * 0060 * @return Config object for the system. 0061 */ 0062 virtual KScreen::ConfigPtr config() const = 0; 0063 0064 /** 0065 * Apply a config object to the system. 0066 * 0067 * @param config Configuration to apply 0068 */ 0069 virtual void setConfig(const KScreen::ConfigPtr &config) = 0; 0070 0071 /** 0072 * Returns whether the backend is in valid state. 0073 * 0074 * Backends should use this to tell BackendLauncher whether they are capable 0075 * of operating on the current platform. 0076 */ 0077 virtual bool isValid() const = 0; 0078 0079 /** 0080 * Returns encoded EDID data for given output 0081 * 0082 * Default implementation does nothing and returns null QByteArray. Backends 0083 * that don't support EDID don't have to reimplement this method. 0084 * 0085 * @param outputd ID of output to return EDID data for 0086 */ 0087 virtual QByteArray edid(int outputId) const; 0088 0089 Q_SIGNALS: 0090 /** 0091 * Emitted when backend detects a change in configuration 0092 * 0093 * It's OK to emit this signal for every single change. The emissions are aggregated 0094 * in the backend launcher, so that the backend does not spam DBus and client 0095 * applications. 0096 * 0097 * @param config New configuration 0098 */ 0099 void configChanged(const KScreen::ConfigPtr &config); 0100 }; 0101 0102 } // namespace KScreen 0103 0104 #endif // ABSTRACT_BACKEND_H