tizen 2.3 release
[framework/system/deviced.git] / src / apps / cool-down.c
1 /*
2  * deviced
3  *
4  * Copyright (c) 2012 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
20 #include "core/log.h"
21 #include "core/common.h"
22 #include "apps.h"
23 #include "core/edbus-handler.h"
24 #include "core/launch.h"
25
26 #define COOL_DOWN_POPUP_BUS_NAME        POPUP_BUS_NAME
27 #define COOL_DOWN_POPUP_METHOD_LAUNCH   "CooldownPopupLaunch"
28
29 #define COOL_DOWN_POWER_OFF             "cooldown_poweroff"
30 #define COOL_DOWN_POWER_WARNING         "cooldown_warning"
31 #define COOL_DOWN_POWER_ON              "cooldown_poweron"
32
33 #define SIGNAL_COOL_DOWN_SHUT_DOWN      "ShutDown"
34 #define SIGNAL_COOL_DOWN_SHUT_DOWN_LEN  8
35 #define SIGNAL_COOL_DOWN_LIMIT_ACTION   "LimitAction"
36 #define SIGNAL_COOL_DOWN_LIMIT_ACTION_LEN       11
37 #define SIGNAL_COOL_DOWN_RELEASE        "Release"
38 #define SIGNAL_COOL_DOWN_RELEASE_LEN    7
39
40 struct popup_data {
41         char *name;
42         char *key;
43 };
44
45 static int cool_down_launch(void *data)
46 {
47         char *param[2];
48         struct popup_data * key_data = (struct popup_data *)data;
49         int ret;
50
51         if (!key_data || !key_data->key)
52                 goto out;
53
54         _I("%s", key_data->key);
55
56         if (strncmp(key_data->key, SIGNAL_COOL_DOWN_SHUT_DOWN,
57             SIGNAL_COOL_DOWN_SHUT_DOWN_LEN) == 0)
58             param[1] = COOL_DOWN_POWER_OFF;
59         else if (strncmp(key_data->key, SIGNAL_COOL_DOWN_LIMIT_ACTION,
60             SIGNAL_COOL_DOWN_LIMIT_ACTION_LEN) == 0)
61              param[1] = COOL_DOWN_POWER_WARNING;
62         else if (strncmp(key_data->key, SIGNAL_COOL_DOWN_RELEASE,
63             SIGNAL_COOL_DOWN_RELEASE_LEN) == 0)
64              param[1] = COOL_DOWN_POWER_ON;
65         else
66                 goto out;
67
68         param[0] = POPUP_KEY_CONTENT;
69
70         return dbus_method_async(COOL_DOWN_POPUP_BUS_NAME,
71                 POPUP_PATH_SYSTEM, POPUP_INTERFACE_SYSTEM,
72                 COOL_DOWN_POPUP_METHOD_LAUNCH, "ss", param);
73 out:
74         return 0;
75 }
76
77
78 static const struct apps_ops cooldown_ops = {
79         .name   = "cooldown-syspopup",
80         .launch = cool_down_launch,
81 };
82
83 APPS_OPS_REGISTER(&cooldown_ops)