Solid

requeststatejob.cpp
1/*
2 SPDX-FileCopyrightText: 2014 Alejandro Fiestas Olivares <afiestas@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "requeststatejob.h"
8#include "backends/abstractrequeststatejob.h"
9#include "powerbackendloader.h"
10#include "requeststatejob_p.h"
11
12using namespace Solid;
13
14RequestStateJobPrivate::RequestStateJobPrivate()
15{
16 backendJob = nullptr;
17 state = Power::None;
18}
19
20RequestStateJob::RequestStateJob(QObject *parent)
21 : Job(*new RequestStateJobPrivate(), parent)
22{
23}
24
25void RequestStateJob::setState(Power::InhibitionType state)
26{
28 d->state = state;
29}
30
31void RequestStateJob::doStart()
32{
34 d->backendJob = PowerBackendLoader::requestState();
35 d->backendJob->state = d->state;
36
37 connect(d->backendJob, &AbstractRequestStateJob::result, [this](Job *job) {
38 if (job->error()) {
39 setError(job->error());
40 setErrorText(job->errorText());
41 }
42 emitResult();
43 });
44
45 d->backendJob->start();
46}
47
48#include "moc_requeststatejob.cpp"
This class represents an asynchronous job performed by Solid, it is usually not used directly but ins...
Definition job.h:37
void emitResult()
Utility function to emit the result signal, and suicide this job.
Definition job.cpp:36
Tries to set the device under the state indicated via setState()
The single responsibility of this class is to create arguments valid for logind Inhibit call.
Definition fakebattery.h:16
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:17:12 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.