summaryrefslogtreecommitdiffstats
path: root/src/power/power.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/power/power.c')
-rw-r--r--src/power/power.c96
1 files changed, 48 insertions, 48 deletions
diff --git a/src/power/power.c b/src/power/power.c
index bf22b1d..af4d124 100644
--- a/src/power/power.c
+++ b/src/power/power.c
@@ -22,8 +22,8 @@
#include <glib.h>
-#include "Cura_AssociatedPowerManagementService.h"
-#include "Cura_ConcreteJob.h"
+#include "LMI_AssociatedPowerManagementService.h"
+#include "LMI_ConcreteJob.h"
#ifdef HAS_UPOWER
#include <upower.h>
@@ -87,8 +87,8 @@ Power *power_new(const CMPIBroker *_cb)
Power *power = malloc(sizeof(Power));
power->broker = _cb;
power->instances = 0;
- power->requestedPowerState = Cura_AssociatedPowerManagementService_RequestedPowerState_Unknown;
- power->transitioningToPowerState = Cura_AssociatedPowerManagementService_TransitioningToPowerState_No_Change;
+ power->requestedPowerState = LMI_AssociatedPowerManagementService_RequestedPowerState_Unknown;
+ power->transitioningToPowerState = LMI_AssociatedPowerManagementService_TransitioningToPowerState_No_Change;
power->mutex = _cb->xft->newMutex(0);
power->jobs = NULL;
#ifdef HAS_UPOWER
@@ -142,7 +142,7 @@ void *state_change_thread(void *data)
{
PowerStateChangeJob *powerStateChangeJob = data;
MUTEX_LOCK(powerStateChangeJob);
- powerStateChangeJob->jobState = Cura_ConcreteJob_JobState_Running;
+ powerStateChangeJob->jobState = LMI_ConcreteJob_JobState_Running;
powerStateChangeJob->timeOfLastChange = time(NULL);
MUTEX_UNLOCK(powerStateChangeJob);
@@ -150,14 +150,14 @@ void *state_change_thread(void *data)
// Check if the job was cancelled
if (powerStateChangeJob->cancelled) {
MUTEX_LOCK(powerStateChangeJob);
- powerStateChangeJob->jobState = Cura_ConcreteJob_JobState_Terminated;
+ powerStateChangeJob->jobState = LMI_ConcreteJob_JobState_Terminated;
powerStateChangeJob->timeOfLastChange = time(NULL);
MUTEX_UNLOCK(powerStateChangeJob);
if (!powerStateChangeJob->superseded) {
// There is no job that replaced this job
MUTEX_LOCK(powerStateChangeJob->power);
- powerStateChangeJob->power->transitioningToPowerState = Cura_AssociatedPowerManagementService_TransitioningToPowerState_No_Change;
+ powerStateChangeJob->power->transitioningToPowerState = LMI_AssociatedPowerManagementService_TransitioningToPowerState_No_Change;
MUTEX_UNLOCK(powerStateChangeJob->power);
}
@@ -172,7 +172,7 @@ void *state_change_thread(void *data)
int succeeded = 0;
switch (powerStateChangeJob->requestedPowerState) {
- case Cura_AssociatedPowerManagementService_PowerState_Sleep__Deep:
+ case LMI_AssociatedPowerManagementService_PowerState_Sleep__Deep:
// Sleep
#ifdef HAS_UPOWER
succeeded = up_client_suspend_sync(powerStateChangeJob->power->up, NULL, &error);
@@ -180,7 +180,7 @@ void *state_change_thread(void *data)
succeeded = system("pm-suspend") == 0;
#endif
break;
- case Cura_AssociatedPowerManagementService_PowerState_Power_Cycle_Off___Soft:
+ case LMI_AssociatedPowerManagementService_PowerState_Power_Cycle_Off___Soft:
// Reboot (without shutting down programs)
#ifdef HAS_SYSTEMCTL
succeeded = system("systemctl --force reboot &") == 0;
@@ -188,7 +188,7 @@ void *state_change_thread(void *data)
succeeded = system("reboot --force &") == 0;
#endif
break;
- case Cura_AssociatedPowerManagementService_PowerState_Hibernate_Off___Soft:
+ case LMI_AssociatedPowerManagementService_PowerState_Hibernate_Off___Soft:
// Hibernate
#ifdef HAS_UPOWER
succeeded = up_client_hibernate_sync(powerStateChangeJob->power->up, NULL, &error);
@@ -196,7 +196,7 @@ void *state_change_thread(void *data)
succeeded = system("pm-hibernate") == 0;
#endif
break;
- case Cura_AssociatedPowerManagementService_PowerState_Off___Soft:
+ case LMI_AssociatedPowerManagementService_PowerState_Off___Soft:
// Poweroff (without shutting down programs)
#ifdef HAS_SYSTEMCTL
succeeded = system("systemctl --force poweroff &") == 0;
@@ -204,7 +204,7 @@ void *state_change_thread(void *data)
succeeded = system("shutdown --halt now &") == 0;
#endif
break;
- case Cura_AssociatedPowerManagementService_PowerState_Off___Soft_Graceful:
+ case LMI_AssociatedPowerManagementService_PowerState_Off___Soft_Graceful:
// Poweroff (shut down programs first)
#ifdef HAS_SYSTEMCTL
succeeded = system("systemctl poweroff &") == 0;
@@ -212,7 +212,7 @@ void *state_change_thread(void *data)
succeeded = system("shutdown --poweroff now &") == 0;
#endif
break;
- case Cura_AssociatedPowerManagementService_PowerState_Power_Cycle_Off___Soft_Graceful:
+ case LMI_AssociatedPowerManagementService_PowerState_Power_Cycle_Off___Soft_Graceful:
// Reboot (shut down programs first)
#ifdef HAS_SYSTEMCTL
succeeded = system("systemctl reboot &") == 0;
@@ -223,14 +223,14 @@ void *state_change_thread(void *data)
}
MUTEX_LOCK(powerStateChangeJob->power);
- powerStateChangeJob->power->transitioningToPowerState = Cura_AssociatedPowerManagementService_TransitioningToPowerState_No_Change;
+ powerStateChangeJob->power->transitioningToPowerState = LMI_AssociatedPowerManagementService_TransitioningToPowerState_No_Change;
MUTEX_UNLOCK(powerStateChangeJob->power);
MUTEX_LOCK(powerStateChangeJob);
if (succeeded) {
- powerStateChangeJob->jobState = Cura_ConcreteJob_JobState_Completed;
+ powerStateChangeJob->jobState = LMI_ConcreteJob_JobState_Completed;
} else {
- powerStateChangeJob->jobState = Cura_ConcreteJob_JobState_Exception;
+ powerStateChangeJob->jobState = LMI_ConcreteJob_JobState_Exception;
#ifdef HAS_UPOWER
if (error != NULL) {
powerStateChangeJob->error = error->message;
@@ -267,7 +267,7 @@ int power_request_power_state(Power *power, unsigned short state)
powerStateChangeJob->power = power;
powerStateChangeJob->mutex = power->broker->xft->newMutex(0);
powerStateChangeJob->requestedPowerState = state;
- powerStateChangeJob->jobState = Cura_ConcreteJob_JobState_New;
+ powerStateChangeJob->jobState = LMI_ConcreteJob_JobState_New;
powerStateChangeJob->cancelled = 0;
powerStateChangeJob->superseded = 0;
powerStateChangeJob->timeOfLastChange = time(NULL);
@@ -283,13 +283,13 @@ int power_request_power_state(Power *power, unsigned short state)
while (plist) {
job = plist->data;
MUTEX_LOCK(job);
- if (job->jobState != Cura_ConcreteJob_JobState_Suspended &&
- job->jobState != Cura_ConcreteJob_JobState_Killed &&
- job->jobState != Cura_ConcreteJob_JobState_Terminated) {
+ if (job->jobState != LMI_ConcreteJob_JobState_Suspended &&
+ job->jobState != LMI_ConcreteJob_JobState_Killed &&
+ job->jobState != LMI_ConcreteJob_JobState_Terminated) {
job->cancelled = 1;
job->superseded = 1;
- job->jobState = Cura_ConcreteJob_JobState_Shutting_Down;
+ job->jobState = LMI_ConcreteJob_JobState_Shutting_Down;
job->timeOfLastChange = time(NULL);
}
MUTEX_UNLOCK(job);
@@ -309,7 +309,7 @@ unsigned short *power_available_requested_power_states(Power *power, int *count)
int i = 0;
/* 1 Other
- * Cura_AssociatedPowerManagementService_PowerState_Other
+ * LMI_AssociatedPowerManagementService_PowerState_Other
*/
/* 2 On
@@ -317,7 +317,7 @@ unsigned short *power_available_requested_power_states(Power *power, int *count)
*
* Bring system to full On from any state (Sleep, Hibernate, Off)
*
- * Cura_AssociatedPowerManagementService_PowerState_On
+ * LMI_AssociatedPowerManagementService_PowerState_On
*/
// not supported
@@ -326,7 +326,7 @@ unsigned short *power_available_requested_power_states(Power *power, int *count)
*
* Standby
*
- * Cura_AssociatedPowerManagementService_PowerState_Sleep___Light
+ * LMI_AssociatedPowerManagementService_PowerState_Sleep___Light
*/
// not supported
@@ -335,16 +335,16 @@ unsigned short *power_available_requested_power_states(Power *power, int *count)
*
* Suspend
*
- * Cura_AssociatedPowerManagementService_PowerState_Sleep__Deep
+ * LMI_AssociatedPowerManagementService_PowerState_Sleep__Deep
*/
// Sleep
#ifdef HAS_UPOWER
if (up_client_get_can_suspend(power->up)) {
- list[i++] = Cura_AssociatedPowerManagementService_PowerState_Sleep__Deep;
+ list[i++] = LMI_AssociatedPowerManagementService_PowerState_Sleep__Deep;
}
#else
if (system("pm-is-supported --suspend") == 0) {
- list[i++] = Cura_AssociatedPowerManagementService_PowerState_Sleep__Deep;
+ list[i++] = LMI_AssociatedPowerManagementService_PowerState_Sleep__Deep;
}
#endif
@@ -354,10 +354,10 @@ unsigned short *power_available_requested_power_states(Power *power, int *count)
*
* Reset system without removing power
*
- * Cura_AssociatedPowerManagementService_PowerState_Power_Cycle_Off___Soft
+ * LMI_AssociatedPowerManagementService_PowerState_Power_Cycle_Off___Soft
*/
// Reboot (without shutting down programs)
- list[i++] = Cura_AssociatedPowerManagementService_PowerState_Power_Cycle_Off___Soft;
+ list[i++] = LMI_AssociatedPowerManagementService_PowerState_Power_Cycle_Off___Soft;
/* 6 Off - Hard
* corresponding to ACPI state G3, S5, or D3.
@@ -365,7 +365,7 @@ unsigned short *power_available_requested_power_states(Power *power, int *count)
* Power Off performed through mechanical means like unplugging
* power cable or UPS On
*
- * Cura_AssociatedPowerManagementService_PowerState_Off___Hard
+ * LMI_AssociatedPowerManagementService_PowerState_Off___Hard
*/
/* 7 Hibernate (Off - Soft)
@@ -375,16 +375,16 @@ unsigned short *power_available_requested_power_states(Power *power, int *count)
* System context and OS image written to non-volatile storage;
* system and devices powered off
*
- * Cura_AssociatedPowerManagementService_PowerState_Hibernate_Off___Soft
+ * LMI_AssociatedPowerManagementService_PowerState_Hibernate_Off___Soft
*/
// Hibernate
#ifdef HAS_UPOWER
if (up_client_get_can_hibernate(power->up)) {
- list[i++] = Cura_AssociatedPowerManagementService_PowerState_Hibernate_Off___Soft;
+ list[i++] = LMI_AssociatedPowerManagementService_PowerState_Hibernate_Off___Soft;
}
#else
if (system("pm-is-supported --hibernate") == 0) {
- list[i++] = Cura_AssociatedPowerManagementService_PowerState_Hibernate_Off___Soft;
+ list[i++] = LMI_AssociatedPowerManagementService_PowerState_Hibernate_Off___Soft;
}
#endif
@@ -393,10 +393,10 @@ unsigned short *power_available_requested_power_states(Power *power, int *count)
*
* System power off but auxiliary or flea power may be available
*
- * Cura_AssociatedPowerManagementService_PowerState_Off___Soft
+ * LMI_AssociatedPowerManagementService_PowerState_Off___Soft
*/
// Poweroff (without shutting down programs)
- list[i++] = Cura_AssociatedPowerManagementService_PowerState_Off___Soft;
+ list[i++] = LMI_AssociatedPowerManagementService_PowerState_Off___Soft;
/* 9 Power Cycle (Off-Hard)
* corresponds to the managed element reaching the ACPI state G3
@@ -404,7 +404,7 @@ unsigned short *power_available_requested_power_states(Power *power, int *count)
*
* Equivalent to Off–Hard followed by On
*
- * Cura_AssociatedPowerManagementService_PowerState_Power_Cycle_Off_Hard
+ * LMI_AssociatedPowerManagementService_PowerState_Power_Cycle_Off_Hard
*/
// not implemented
@@ -414,7 +414,7 @@ unsigned short *power_available_requested_power_states(Power *power, int *count)
*
* Hardware reset
*
- * Cura_AssociatedPowerManagementService_PowerState_Master_Bus_Reset
+ * LMI_AssociatedPowerManagementService_PowerState_Master_Bus_Reset
*/
// not implemented
@@ -424,7 +424,7 @@ unsigned short *power_available_requested_power_states(Power *power, int *count)
*
* Hardware reset
*
- * Cura_AssociatedPowerManagementService_PowerState_Diagnostic_Interrupt_NMI
+ * LMI_AssociatedPowerManagementService_PowerState_Diagnostic_Interrupt_NMI
*/
// not implemented
@@ -435,10 +435,10 @@ unsigned short *power_available_requested_power_states(Power *power, int *count)
* System power off but auxiliary or flea power may be available but preceded
* by a request to the managed element to perform an orderly shutdown.
*
- * Cura_AssociatedPowerManagementService_PowerState_Off___Soft_Graceful
+ * LMI_AssociatedPowerManagementService_PowerState_Off___Soft_Graceful
*/
// Poweroff (shut down programs first)
- list[i++] = Cura_AssociatedPowerManagementService_PowerState_Off___Soft_Graceful;
+ list[i++] = LMI_AssociatedPowerManagementService_PowerState_Off___Soft_Graceful;
/* 13 Off - Hard Graceful
* equivalent to Off Hard but preceded by a request to the managed element
@@ -448,7 +448,7 @@ unsigned short *power_available_requested_power_states(Power *power, int *count)
* or UPS On but preceded by a request to the managed element to perform
* an orderly shutdown.
*
- * Cura_AssociatedPowerManagementService_PowerState_Off___Hard_Graceful
+ * LMI_AssociatedPowerManagementService_PowerState_Off___Hard_Graceful
*/
// not implemented
@@ -459,7 +459,7 @@ unsigned short *power_available_requested_power_states(Power *power, int *count)
* Hardware reset but preceded by a request to the managed element
* to perform an orderly shutdown.
*
- * Cura_AssociatedPowerManagementService_PowerState_Master_Bus_Reset_Graceful
+ * LMI_AssociatedPowerManagementService_PowerState_Master_Bus_Reset_Graceful
*/
// not implemented
@@ -470,10 +470,10 @@ unsigned short *power_available_requested_power_states(Power *power, int *count)
* Reset system without removing power but preceded by a request
* to the managed element to perform an orderly shutdown.
*
- * Cura_AssociatedPowerManagementService_PowerState_Power_Cycle_Off___Soft_Graceful
+ * LMI_AssociatedPowerManagementService_PowerState_Power_Cycle_Off___Soft_Graceful
*/
// Reboot (shut down programs first)
- list[i++] = Cura_AssociatedPowerManagementService_PowerState_Power_Cycle_Off___Soft_Graceful;
+ list[i++] = LMI_AssociatedPowerManagementService_PowerState_Power_Cycle_Off___Soft_Graceful;
/* 16 Power Cycle (Off - Hard Graceful)
* equivalent to Power Cycle (Off - Hard) but preceded by a request
@@ -482,7 +482,7 @@ unsigned short *power_available_requested_power_states(Power *power, int *count)
* Equivalent to Off–Hard followed by On but preceded by a request
* to the managed element to perform an orderly shutdown.
*
- * Cura_AssociatedPowerManagementService_PowerState_Power_Cycle_Off___Hard_Graceful
+ * LMI_AssociatedPowerManagementService_PowerState_Power_Cycle_Off___Hard_Graceful
*/
// not implemented
@@ -502,9 +502,9 @@ GList *power_get_jobs(Power *power)
while (plist) {
powerStateChangeJob = plist->data;
MUTEX_LOCK(powerStateChangeJob);
- if ((powerStateChangeJob->jobState == Cura_ConcreteJob_JobState_Completed ||
- powerStateChangeJob->jobState == Cura_ConcreteJob_JobState_Killed ||
- powerStateChangeJob->jobState == Cura_ConcreteJob_JobState_Terminated) &&
+ if ((powerStateChangeJob->jobState == LMI_ConcreteJob_JobState_Completed ||
+ powerStateChangeJob->jobState == LMI_ConcreteJob_JobState_Killed ||
+ powerStateChangeJob->jobState == LMI_ConcreteJob_JobState_Terminated) &&
time(NULL) - powerStateChangeJob->timeOfLastChange > powerStateChangeJob->timeBeforeRemoval) {
MUTEX_LOCK(power);