|
Lines 26-33
with this program; if not, write to the Free Software Foundation, Inc.,
Link Here
|
| 26 |
|
26 |
|
| 27 |
#include "alarm.h" |
27 |
#include "alarm.h" |
| 28 |
|
28 |
|
| 29 |
const char* inhibitorDestinationName = "org.freedesktop.login1"; |
29 |
auto inhibitorDestinationName = sdbus::ServiceName{"org.freedesktop.login1"}; |
| 30 |
const char* inhibitorObjectPath = "/org/freedesktop/login1"; |
30 |
auto inhibitorObjectPath = sdbus::ObjectPath{"/org/freedesktop/login1"}; |
| 31 |
const char* inhibitorInterfaceName = "org.freedesktop.login1.Manager"; |
31 |
const char* inhibitorInterfaceName = "org.freedesktop.login1.Manager"; |
| 32 |
std::unique_ptr inhibitorProxy = sdbus::createProxy(inhibitorDestinationName, inhibitorObjectPath); |
32 |
std::unique_ptr inhibitorProxy = sdbus::createProxy(inhibitorDestinationName, inhibitorObjectPath); |
| 33 |
std::list<Alarm> alarmList; |
33 |
std::list<Alarm> alarmList; |
|
Lines 136-156
void handleSuspend(const bool active) {
Link Here
|
| 136 |
int main(int argc, char *argv[]) |
136 |
int main(int argc, char *argv[]) |
| 137 |
{ |
137 |
{ |
| 138 |
// Create D-Bus connection to the system bus and requests name on it. |
138 |
// Create D-Bus connection to the system bus and requests name on it. |
| 139 |
const char* serviceName = "de.seath.Waked"; |
139 |
auto serviceName = sdbus::ServiceName{"de.seath.Waked"}; |
| 140 |
auto connection = sdbus::createSystemBusConnection(serviceName); |
140 |
auto connection = sdbus::createSystemBusConnection(serviceName); |
| 141 |
|
141 |
|
| 142 |
const char* wakedObjectPath = "/de/seath/Waked/Alarm"; |
142 |
auto wakedObjectPath = sdbus::ObjectPath{"/de/seath/Waked/Alarm"}; |
| 143 |
auto wakedDbusObject = sdbus::createObject(*connection, wakedObjectPath); |
143 |
auto wakedDbusObject = sdbus::createObject(*connection, wakedObjectPath); |
| 144 |
|
144 |
|
| 145 |
|
145 |
|
| 146 |
const char* wakedInterfaceName = "de.seath.Waked"; |
146 |
const char* wakedInterfaceName = "de.seath.Waked"; |
| 147 |
wakedDbusObject->registerMethod("Add").onInterface(wakedInterfaceName).implementedAs(®isterAlarm); |
147 |
wakedDbusObject->addVTable( |
| 148 |
wakedDbusObject->registerMethod("Update").onInterface(wakedInterfaceName).implementedAs(&updateAlarm); |
148 |
sdbus::registerMethod("Add").implementedAs(®isterAlarm), |
| 149 |
wakedDbusObject->registerMethod("Remove").onInterface(wakedInterfaceName).implementedAs(&removeAlarm); |
149 |
sdbus::registerMethod("Update").implementedAs(&updateAlarm), |
| 150 |
wakedDbusObject->finishRegistration(); |
150 |
sdbus::registerMethod("Remove").implementedAs(&removeAlarm)).forInterface(wakedInterfaceName); |
| 151 |
|
|
|
| 152 |
inhibitorProxy->uponSignal("PrepareForSleep").onInterface(inhibitorInterfaceName).call(&handleSuspend); //[](const std::string& str){ onConcatenated(str); }); |
151 |
inhibitorProxy->uponSignal("PrepareForSleep").onInterface(inhibitorInterfaceName).call(&handleSuspend); //[](const std::string& str){ onConcatenated(str); }); |
| 153 |
inhibitorProxy->finishRegistration(); |
|
|
| 154 |
|
152 |
|
| 155 |
inhibitorProxy->callMethod("Inhibit").onInterface(inhibitorInterfaceName).withArguments("sleep", "Waked", "Manage system wake-ups", "delay").storeResultsTo(suspendDelayLockFd); |
153 |
inhibitorProxy->callMethod("Inhibit").onInterface(inhibitorInterfaceName).withArguments("sleep", "Waked", "Manage system wake-ups", "delay").storeResultsTo(suspendDelayLockFd); |
| 156 |
|
154 |
|