File indexing completed on 2024-12-01 03:45:35
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 #include "requeststatejob.h" 0008 #include "backends/abstractrequeststatejob.h" 0009 #include "powerbackendloader.h" 0010 #include "requeststatejob_p.h" 0011 0012 using namespace Solid; 0013 0014 RequestStateJobPrivate::RequestStateJobPrivate() 0015 { 0016 backendJob = nullptr; 0017 state = Power::None; 0018 } 0019 0020 RequestStateJob::RequestStateJob(QObject *parent) 0021 : Job(*new RequestStateJobPrivate(), parent) 0022 { 0023 } 0024 0025 void RequestStateJob::setState(Power::InhibitionType state) 0026 { 0027 Q_D(RequestStateJob); 0028 d->state = state; 0029 } 0030 0031 void RequestStateJob::doStart() 0032 { 0033 Q_D(RequestStateJob); 0034 d->backendJob = PowerBackendLoader::requestState(); 0035 d->backendJob->state = d->state; 0036 0037 connect(d->backendJob, &AbstractRequestStateJob::result, [this](Job *job) { 0038 if (job->error()) { 0039 setError(job->error()); 0040 setErrorText(job->errorText()); 0041 } 0042 emitResult(); 0043 }); 0044 0045 d->backendJob->start(); 0046 } 0047 0048 #include "moc_requeststatejob.cpp"