power: elevate iot-headless power plugin to core
[platform/core/system/deviced.git] / src / power / power-off.h
1 /*
2  * deviced
3  *
4  * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the License);
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 #ifndef __DEVICED_POWER_OFF_H__
20 #define __DEVICED_POWER_OFF_H__
21
22 #include <sys/types.h>
23
24 #define POWER_POWEROFF      "poweroff"
25 #define POWER_REBOOT        "reboot"
26 #define POWER_OFF_POPUP     "pwroff-popup"
27 #define POWER_EXIT          "exit"
28
29 #define POWER_FLAG_POWEROFF     "/run/"POWER_POWEROFF
30 #define POWER_FLAG_REBOOT       "/run/"POWER_REBOOT
31 #define POWER_FLAG_EXIT         "/run/deviced-shutdown-exit"
32
33 // 0: None
34 // 1: Power Off Popup is launched (not supported since Tizen5.5)
35 // 2: Poweroff
36 // 3: Restart
37 // 4: Exit
38 enum poweroff_type {
39         POWEROFF_TYPE_INVALID = 0,
40         POWEROFF_TYPE_NONE = POWEROFF_TYPE_INVALID,     // compat only
41         POWEROFF_TYPE_POWEROFF = 2,
42         POWEROFF_TYPE_DIRECT = POWEROFF_TYPE_POWEROFF,  // compat only
43         POWEROFF_TYPE_REBOOT,
44         POWEROFF_TYPE_RESTART = POWEROFF_TYPE_REBOOT,   // compat only
45         POWEROFF_TYPE_EXIT,
46 };
47
48 struct power_option {
49         enum poweroff_type type;
50         char *option;
51 };
52
53 struct poweroff_handle {
54         pid_t pid;
55         int timeout;
56         char comm[128];
57         guint timeout_id;
58 };
59
60 void power_off_init(void);
61
62 int poweroff_trigger_poweroff(void *data);
63 int poweroff_check_revived(void);
64 void poweroff_request_shutdown(void);
65 int poweroff_add_wait(pid_t pid);
66 void poweroff_remove_wait(pid_t pid);
67
68 #endif /* __DEVICED_POWER_OFF_H__ */