Solid

requeststatejob.cpp
1 /*
2  SPDX-FileCopyrightText: 2014 Alejandro Fiestas Olivares <[email protected]>
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 "requeststatejob_p.h"
9 #include "powerbackendloader.h"
10 #include "backends/abstractrequeststatejob.h"
11 
12 
13 using namespace Solid;
14 
15 RequestStateJobPrivate::RequestStateJobPrivate()
16 {
17  backendJob = nullptr;
18  state = Power::None;
19 }
20 
21 RequestStateJob::RequestStateJob(QObject* parent) : Job(*new RequestStateJobPrivate(), parent)
22 {
23 }
24 
25 void RequestStateJob::setState(Power::InhibitionType state)
26 {
27  Q_D(RequestStateJob);
28  d->state = state;
29 }
30 
31 void RequestStateJob::doStart()
32 {
33  Q_D(RequestStateJob);
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 }
Tries to set the device under the state indicated via setState()
This class represents an asynchronous job performed by Solid, it is usually not used directly but ins...
Definition: job.h:36
The single responsibility of this class is to create arguments valid for logind Inhibit call...
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Sep 22 2020 22:50:18 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.