File indexing completed on 2024-05-19 04:03:21

0001 /*
0002     SPDX-FileCopyrightText: 2014 Alejandro Fiestas Olivares <afiestas@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef SOLID_REQUEST_STATE_JOB_H
0008 #define SOLID_REQUEST_STATE_JOB_H
0009 
0010 #include <Solid/Job>
0011 
0012 #include "power.h"
0013 #include "solid_export.h"
0014 
0015 namespace Solid
0016 {
0017 class RequestStateJobPrivate;
0018 /**
0019  * Tries to set the device under the state indicated via setState()
0020  *
0021  * On success this job will contain no error and the device will
0022  * be set to the desired state (for example Sleep). On error
0023  * use error() and errorText() to know more about the issue.
0024  *
0025  * @note In some devices changing the system state might happen
0026  * too fast for the callee of this job to be notified (for example
0027  * the system might suspend before result() is emitted.
0028  */
0029 class SOLID_EXPORT RequestStateJob : public Job
0030 {
0031     Q_OBJECT
0032 
0033 public:
0034     enum Error {
0035         Unsupported = Job::UserDefinedError,
0036     };
0037 
0038     explicit RequestStateJob(QObject *parent = nullptr);
0039 
0040     void setState(Power::InhibitionType state);
0041 
0042 private Q_SLOTS:
0043     void doStart() override;
0044 
0045     /**
0046      * We have to re-declare the signal because
0047      * if not, Q_PROPERTY wouldn't work.
0048      */
0049 Q_SIGNALS:
0050     void result(Solid::Job *);
0051 
0052 private:
0053     Q_DECLARE_PRIVATE(RequestStateJob)
0054 };
0055 } // Solid namespace
0056 #endif // SOLID_REQUEST_STATE_JOB_H