Initialize Tizen 2.3
[framework/system/deviced.git] / src / display / display-dbus.c
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
20 /**
21  * @file        display-dbus.c
22  * @brief       dbus interface
23  *
24  */
25
26 #include <error.h>
27 #include <stdbool.h>
28 #include <Ecore.h>
29 #include <device-node.h>
30
31 #include "core/log.h"
32 #include "util.h"
33 #include "core.h"
34 #include "weaks.h"
35 #include "core/common.h"
36 #include "core/devices.h"
37 #include "dd-display.h"
38
39 #define TELEPHONY_PATH                  "/org/tizen/telephony/SAMSUNG_QMI"
40 #define TELEPHONY_INTERFACE_SIM         "org.tizen.telephony.Sim"
41 #define SIGNAL_SIM_STATUS               "Status"
42 #define SIM_CARD_NOT_PRESENT            (0x01)
43
44 #define VCONFKEY_LCD_BRIGHTNESS_INIT "db/private/deviced/lcd_brightness_init"
45
46 #define SIGNAL_HOMESCREEN               "HomeScreen"
47 #define SIGNAL_EXTREME                  "Extreme"
48 #define SIGNAL_NOTEXTREME               "NotExtreme"
49
50 #define BLIND_MASK(val)                 ((val) & 0xFFFF)
51 #define BLIND_RED(val)                  BLIND_MASK((val) >> 32)
52 #define BLIND_GREEN(val)                BLIND_MASK((val) >> 16)
53 #define BLIND_BLUE(val)                 BLIND_MASK((val))
54
55 #define DISPLAY_DIM_BRIGHTNESS  0
56 #define DUMP_MODE_WATING_TIME   600000
57
58 static DBusMessage *edbus_start(E_DBus_Object *obj, DBusMessage *msg)
59 {
60         static const struct device_ops *display_device_ops;
61
62         if (!display_device_ops) {
63                 display_device_ops = find_device("display");
64                 if (!display_device_ops)
65                         return dbus_message_new_method_return(msg);
66         }
67
68         display_device_ops->start();
69         return dbus_message_new_method_return(msg);
70 }
71
72 static DBusMessage *edbus_stop(E_DBus_Object *obj, DBusMessage *msg)
73 {
74         static const struct device_ops *display_device_ops;
75
76         if (!display_device_ops) {
77                 display_device_ops = find_device("display");
78                 if (!display_device_ops)
79                         return dbus_message_new_method_return(msg);
80         }
81
82         display_device_ops->stop();
83         return dbus_message_new_method_return(msg);
84 }
85
86 static DBusMessage *edbus_lockstate(E_DBus_Object *obj, DBusMessage *msg)
87 {
88         DBusError err;
89         DBusMessageIter iter;
90         DBusMessage *reply;
91         char *state_str;
92         char *option1_str;
93         char *option2_str;
94         int timeout;
95         pid_t pid;
96         int state;
97         int flag;
98         int ret;
99
100         dbus_error_init(&err);
101
102         if (!dbus_message_get_args(msg, &err,
103                     DBUS_TYPE_STRING, &state_str,
104                     DBUS_TYPE_STRING, &option1_str,
105                     DBUS_TYPE_STRING, &option2_str,
106                     DBUS_TYPE_INT32, &timeout, DBUS_TYPE_INVALID)) {
107                 _E("there is no message");
108                 ret = -EINVAL;
109                 goto out;
110         }
111
112         if (!state_str || timeout < 0) {
113                 _E("message is invalid!");
114                 ret = -EINVAL;
115                 goto out;
116         }
117
118         pid = get_edbus_sender_pid(msg);
119         if (kill(pid, 0) == -1) {
120                 _E("%d process does not exist, dbus ignored!", pid);
121                 ret = -ESRCH;
122                 goto out;
123         }
124
125         if (!strcmp(state_str, PM_LCDON_STR))
126                 state = LCD_NORMAL;
127         else if (!strcmp(state_str, PM_LCDDIM_STR))
128                 state = LCD_DIM;
129         else if (!strcmp(state_str, PM_LCDOFF_STR))
130                 state = LCD_OFF;
131         else {
132                 _E("%s state is invalid, dbus ignored!", state_str);
133                 ret = -EINVAL;
134                 goto out;
135         }
136
137         if (!strcmp(option1_str, STAYCURSTATE_STR))
138                 flag = STAY_CUR_STATE;
139         else if (!strcmp(option1_str, GOTOSTATENOW_STR))
140                 flag = GOTO_STATE_NOW;
141         else {
142                 _E("%s option is invalid. set default option!", option1_str);
143                 flag = STAY_CUR_STATE;
144         }
145
146         if (!strcmp(option2_str, HOLDKEYBLOCK_STR))
147                 flag |= HOLD_KEY_BLOCK;
148         else if (!strcmp(option2_str, STANDBYMODE_STR))
149                 flag |= STANDBY_MODE;
150
151         if (check_dimstay(state, flag) == true) {
152                 _E("LCD state can not be changed to OFF state now!");
153                 flag &= ~GOTO_STATE_NOW;
154                 flag |= STAY_CUR_STATE;
155         }
156
157         ret = pm_lock_internal(pid, state, flag, timeout);
158 out:
159         reply = dbus_message_new_method_return(msg);
160         dbus_message_iter_init_append(reply, &iter);
161         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
162
163         return reply;
164 }
165
166 static DBusMessage *edbus_unlockstate(E_DBus_Object *obj, DBusMessage *msg)
167 {
168         DBusError err;
169         DBusMessageIter iter;
170         DBusMessage *reply;
171         char *state_str;
172         char *option_str;
173         pid_t pid;
174         int state;
175         int flag;
176         int ret;
177
178         dbus_error_init(&err);
179
180         if (!dbus_message_get_args(msg, &err,
181                     DBUS_TYPE_STRING, &state_str,
182                     DBUS_TYPE_STRING, &option_str, DBUS_TYPE_INVALID)) {
183                 _E("there is no message");
184                 ret = -EINVAL;
185                 goto out;
186         }
187
188         if (!state_str) {
189                 _E("message is invalid!");
190                 ret = -EINVAL;
191                 goto out;
192         }
193
194         pid = get_edbus_sender_pid(msg);
195         if (kill(pid, 0) == -1) {
196                 _E("%d process does not exist, dbus ignored!", pid);
197                 ret = -ESRCH;
198                 goto out;
199         }
200
201         if (!strcmp(state_str, PM_LCDON_STR))
202                 state = LCD_NORMAL;
203         else if (!strcmp(state_str, PM_LCDDIM_STR))
204                 state = LCD_DIM;
205         else if (!strcmp(state_str, PM_LCDOFF_STR))
206                 state = LCD_OFF;
207         else {
208                 _E("%s state is invalid, dbus ignored!", state_str);
209                 ret = -EINVAL;
210                 goto out;
211         }
212
213         if (!strcmp(option_str, SLEEP_MARGIN_STR))
214                 flag = PM_SLEEP_MARGIN;
215         else if (!strcmp(option_str, RESET_TIMER_STR))
216                 flag = PM_RESET_TIMER;
217         else if (!strcmp(option_str, KEEP_TIMER_STR))
218                 flag = PM_KEEP_TIMER;
219         else {
220                 _E("%s option is invalid. set default option!", option_str);
221                 flag = PM_RESET_TIMER;
222         }
223
224         ret = pm_unlock_internal(pid, state, flag);
225 out:
226         reply = dbus_message_new_method_return(msg);
227         dbus_message_iter_init_append(reply, &iter);
228         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
229
230         return reply;
231 }
232
233 static DBusMessage *edbus_changestate(E_DBus_Object *obj, DBusMessage *msg)
234 {
235         DBusError err;
236         DBusMessageIter iter;
237         DBusMessage *reply;
238         char *state_str;
239         pid_t pid;
240         int state;
241         int ret;
242
243         dbus_error_init(&err);
244
245         if (!dbus_message_get_args(msg, &err,
246                     DBUS_TYPE_STRING, &state_str, DBUS_TYPE_INVALID)) {
247                 _E("there is no message");
248                 ret = -EINVAL;
249                 goto out;
250         }
251
252         if (!state_str) {
253                 _E("message is invalid!");
254                 ret = -EINVAL;
255                 goto out;
256         }
257
258         pid = get_edbus_sender_pid(msg);
259         if (kill(pid, 0) == -1) {
260                 _E("%d process does not exist, dbus ignored!", pid);
261                 ret = -ESRCH;
262                 goto out;
263         }
264
265         if (!strcmp(state_str, PM_LCDON_STR))
266                 state = LCD_NORMAL;
267         else if (!strcmp(state_str, PM_LCDDIM_STR))
268                 state = LCD_DIM;
269         else if (!strcmp(state_str, PM_LCDOFF_STR))
270                 state = LCD_OFF;
271         else if (!strcmp(state_str, PM_SUSPEND_STR))
272                 state = SUSPEND;
273         else {
274                 _E("%s state is invalid, dbus ignored!", state_str);
275                 ret = -EINVAL;
276                 goto out;
277         }
278
279         if (check_dimstay(state, GOTO_STATE_NOW) == true) {
280                 _E("LCD state can not be changed to OFF state!");
281                 ret = -EBUSY;
282                 goto out;
283         }
284
285         ret = pm_change_internal(pid, state);
286
287         if (!ret && state == LCD_OFF)
288                 update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_TIMEOUT);
289 out:
290         reply = dbus_message_new_method_return(msg);
291         dbus_message_iter_init_append(reply, &iter);
292         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
293
294         return reply;
295 }
296
297 static DBusMessage *edbus_getdisplaycount(E_DBus_Object *obj, DBusMessage *msg)
298 {
299         DBusMessageIter iter;
300         DBusMessage *reply;
301         int cmd, cnt, ret;
302
303         cmd = DISP_CMD(PROP_DISPLAY_DISPLAY_COUNT, DEFAULT_DISPLAY);
304         ret = device_get_property(DEVICE_TYPE_DISPLAY, cmd, &cnt);
305         if (ret >= 0)
306                 ret = cnt;
307
308         reply = dbus_message_new_method_return(msg);
309         dbus_message_iter_init_append(reply, &iter);
310         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
311         return reply;
312 }
313
314 static DBusMessage *edbus_getmaxbrightness(E_DBus_Object *obj, DBusMessage *msg)
315 {
316         DBusMessageIter iter;
317         DBusMessage *reply;
318         int cmd, brt, ret;
319
320         cmd = DISP_CMD(PROP_DISPLAY_MAX_BRIGHTNESS, DEFAULT_DISPLAY);
321         ret = device_get_property(DEVICE_TYPE_DISPLAY, cmd, &brt);
322         if (ret >= 0)
323                 ret = brt;
324
325         reply = dbus_message_new_method_return(msg);
326         dbus_message_iter_init_append(reply, &iter);
327         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
328         return reply;
329 }
330
331 static DBusMessage *edbus_setmaxbrightness(E_DBus_Object *obj, DBusMessage *msg)
332 {
333         DBusMessageIter iter;
334         DBusMessage *reply;
335         int cmd, brt, ret;
336
337         dbus_message_iter_init(msg, &iter);
338         dbus_message_iter_get_basic(&iter, &brt);
339
340         cmd = DISP_CMD(PROP_DISPLAY_MAX_BRIGHTNESS, DEFAULT_DISPLAY);
341         ret = device_set_property(DEVICE_TYPE_DISPLAY, cmd, brt);
342
343         reply = dbus_message_new_method_return(msg);
344         dbus_message_iter_init_append(reply, &iter);
345         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
346         return reply;
347 }
348
349 static DBusMessage *edbus_getbrightness(E_DBus_Object *obj, DBusMessage *msg)
350 {
351         DBusMessageIter iter;
352         DBusMessage *reply;
353         int cmd, brt, ret;
354
355         cmd = DISP_CMD(PROP_DISPLAY_BRIGHTNESS, DEFAULT_DISPLAY);
356         ret = device_get_property(DEVICE_TYPE_DISPLAY, cmd, &brt);
357         if (ret >= 0)
358                 ret = brt;
359
360         _I("get brightness %d, %d", brt, ret);
361
362         reply = dbus_message_new_method_return(msg);
363         dbus_message_iter_init_append(reply, &iter);
364         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &brt);
365         return reply;
366 }
367
368 static DBusMessage *edbus_setbrightness(E_DBus_Object *obj, DBusMessage *msg)
369 {
370         DBusMessageIter iter;
371         DBusMessage *reply;
372         int cmd, brt, powersaver, autobrt, ret;
373
374         dbus_message_iter_init(msg, &iter);
375         dbus_message_iter_get_basic(&iter, &brt);
376
377         if (brt == DISPLAY_DIM_BRIGHTNESS) {
378                 _E("application can not set this value(DIM VALUE:%d)", brt);
379                 ret = -EPERM;
380                 goto error;
381         }
382
383         if (vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &powersaver) != 0) {
384                 _E("Failed to get VCONFKEY_SETAPPL_PSMODE value");
385                 powersaver = SETTING_PSMODE_NORMAL;
386         }
387
388         if (powersaver == SETTING_PSMODE_WEARABLE) {
389                 _D("brightness is changed in powersaver mode!");
390                 backlight_ops.set_force_brightness(0);
391         }
392
393         if (vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &autobrt) != 0) {
394                 _E("Failed to get VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT value");
395                 autobrt = SETTING_BRIGHTNESS_AUTOMATIC_OFF;
396         }
397
398         if (autobrt == SETTING_BRIGHTNESS_AUTOMATIC_ON) {
399                 _D("auto_brightness state is ON, can not change the brightness value");
400                 ret = 0;
401                 goto error;
402         }
403
404         cmd = DISP_CMD(PROP_DISPLAY_BRIGHTNESS, DEFAULT_DISPLAY);
405         ret = device_set_property(DEVICE_TYPE_DISPLAY, cmd, brt);
406         if (ret < 0)
407                 goto error;
408         if (vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, brt) != 0)
409                 _E("Failed to set VCONFKEY_SETAPPL_LCD_BRIGHTNESS value");
410
411         if (vconf_set_int(VCONFKEY_PM_CURRENT_BRIGHTNESS, brt) != 0)
412                 _E("Failed to set VCONFKEY_PM_CURRENT_BRIGHTNESS value");
413
414         _I("set brightness %d, %d", brt, ret);
415
416 error:
417         reply = dbus_message_new_method_return(msg);
418         dbus_message_iter_init_append(reply, &iter);
419         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
420         return reply;
421 }
422
423 static DBusMessage *edbus_holdbrightness(E_DBus_Object *obj, DBusMessage *msg)
424 {
425         DBusMessageIter iter;
426         DBusMessage *reply;
427         int cmd, brt, powersaver, autobrt, ret;
428
429         dbus_message_iter_init(msg, &iter);
430         dbus_message_iter_get_basic(&iter, &brt);
431
432         if (brt == DISPLAY_DIM_BRIGHTNESS) {
433                 _E("application can not set this value(DIM VALUE:%d)", brt);
434                 ret = -EPERM;
435                 goto error;
436         }
437
438         if (vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &powersaver) != 0) {
439                 _E("Failed to get VCONFKEY_SETAPPL_PSMODE value");
440                 powersaver = SETTING_PSMODE_NORMAL;
441         }
442
443         if (powersaver == SETTING_PSMODE_WEARABLE) {
444                 _D("Powersaver mode! brightness can not be changed!");
445                 ret = -EPERM;
446                 goto error;
447         }
448
449         if (vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &autobrt) != 0) {
450                 _E("Failed to get VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT value");
451                 autobrt = SETTING_BRIGHTNESS_AUTOMATIC_OFF;
452         }
453
454         vconf_set_int(VCONFKEY_PM_CUSTOM_BRIGHTNESS_STATUS, VCONFKEY_PM_CUSTOM_BRIGHTNESS_ON);
455
456         cmd = DISP_CMD(PROP_DISPLAY_BRIGHTNESS, DEFAULT_DISPLAY);
457         ret = device_set_property(DEVICE_TYPE_DISPLAY, cmd, brt);
458         if (ret < 0)
459                 goto error;
460
461         if (autobrt == SETTING_BRIGHTNESS_AUTOMATIC_ON) {
462                 _D("Auto brightness will be paused");
463                 vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SETTING_BRIGHTNESS_AUTOMATIC_PAUSE);
464         }
465
466         if (vconf_set_int(VCONFKEY_PM_CURRENT_BRIGHTNESS, brt) != 0)
467                 _E("Failed to set VCONFKEY_PM_CURRENT_BRIGHTNESS value");
468
469         _I("hold brightness %d, %d", brt, ret);
470
471 error:
472         reply = dbus_message_new_method_return(msg);
473         dbus_message_iter_init_append(reply, &iter);
474         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
475         return reply;
476
477 }
478
479 static DBusMessage *edbus_releasebrightness(E_DBus_Object *obj, DBusMessage *msg)
480 {
481         DBusMessageIter iter;
482         DBusMessage *reply;
483         int cmd, bat, charger, changed, setting, brt, autobrt, ret = 0;
484
485         if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat) != 0) {
486                 _E("Failed to get VCONFKEY_SYSMAN_BATTERY_STATUS_LOW value");
487                 ret = -EPERM;
488                 goto error;
489         }
490
491         if (vconf_get_int(VCONFKEY_SYSMAN_CHARGER_STATUS, &charger) != 0) {
492                 _E("Failed to get VCONFKEY_SYSMAN_CHARGER_STATUS value");
493                 ret = -EPERM;
494                 goto error;
495         }
496
497         if (vconf_get_bool(VCONFKEY_PM_BRIGHTNESS_CHANGED_IN_LPM, &changed) != 0) {
498                 _E("Failed to get VCONFKEY_PM_BRIGHTNESS_CHANGED_IN_LPM value");
499                 ret = -EPERM;
500                 goto error;
501         }
502
503         if (vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &setting) != 0) {
504                 _E("Failed to get VCONFKEY_SETAPPL_LCD_BRIGHTNESS value");
505                 ret = -EPERM;
506                 goto error;
507         }
508
509         if (vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &autobrt) != 0) {
510                 _E("Failed to get VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT value");
511                 ret = -EPERM;
512                 goto error;
513         }
514
515         vconf_set_int(VCONFKEY_PM_CUSTOM_BRIGHTNESS_STATUS, VCONFKEY_PM_CUSTOM_BRIGHTNESS_OFF);
516
517         cmd = DISP_CMD(PROP_DISPLAY_BRIGHTNESS, DEFAULT_DISPLAY);
518         ret = device_get_property(DEVICE_TYPE_DISPLAY, cmd, &brt);
519         if (ret < 0)
520                 brt = ret;
521
522         // check dim state
523         if (low_battery_state(bat) &&
524             charger == VCONFKEY_SYSMAN_CHARGER_DISCONNECTED && !changed) {
525                 _D("batt warning low : brightness is not changed!");
526                 if (brt != 0) {
527                         device_set_property(DEVICE_TYPE_DISPLAY, PROP_DISPLAY_BRIGHTNESS, 0);
528                 }
529                 goto error;
530         }
531
532         if (autobrt == SETTING_BRIGHTNESS_AUTOMATIC_OFF) {
533                 if (brt != setting) {
534                         device_set_property(DEVICE_TYPE_DISPLAY, PROP_DISPLAY_BRIGHTNESS, setting);
535                         if (vconf_set_int(VCONFKEY_PM_CURRENT_BRIGHTNESS, setting) != 0) {
536                                 _E("Failed to set VCONFKEY_PM_CURRENT_BRIGHTNESS value");
537                         }
538                 }
539         } else if (autobrt == SETTING_BRIGHTNESS_AUTOMATIC_PAUSE) {
540                 _D("Auto brightness will be enable");
541                 vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SETTING_BRIGHTNESS_AUTOMATIC_ON);
542         }
543
544 error:
545         reply = dbus_message_new_method_return(msg);
546         dbus_message_iter_init_append(reply, &iter);
547         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
548         return reply;
549 }
550
551 static DBusMessage *edbus_getaclstatus(E_DBus_Object *obj, DBusMessage *msg)
552 {
553         DBusMessageIter iter;
554         DBusMessage *reply;
555         int cmd, st, ret;
556
557         cmd = DISP_CMD(PROP_DISPLAY_ACL_CONTROL, DEFAULT_DISPLAY);
558         ret = device_get_property(DEVICE_TYPE_DISPLAY, cmd, &st);
559         if (ret >= 0)
560                 ret = st;
561
562         _I("get acl status %d, %d", st, ret);
563
564         reply = dbus_message_new_method_return(msg);
565         dbus_message_iter_init_append(reply, &iter);
566         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
567         return reply;
568 }
569
570 static DBusMessage *edbus_setaclstatus(E_DBus_Object *ob, DBusMessage *msg)
571 {
572         DBusMessageIter iter;
573         DBusMessage *reply;
574         int cmd, st, ret;
575
576         dbus_message_iter_init(msg, &iter);
577         dbus_message_iter_get_basic(&iter, &st);
578
579         cmd = DISP_CMD(PROP_DISPLAY_ACL_CONTROL, DEFAULT_DISPLAY);
580         ret = device_set_property(DEVICE_TYPE_DISPLAY, cmd, st);
581
582         _I("set acl status %d, %d", st, ret);
583
584         reply = dbus_message_new_method_return(msg);
585         dbus_message_iter_init_append(reply, &iter);
586         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
587         return reply;
588 }
589
590 static DBusMessage *edbus_getautotone(E_DBus_Object *obj, DBusMessage *msg)
591 {
592         DBusMessageIter iter;
593         DBusMessage *reply;
594         int cmd, tone, ret;
595
596         cmd = DISP_CMD(PROP_DISPLAY_AUTO_SCREEN_TONE, DEFAULT_DISPLAY);
597         ret = device_get_property(DEVICE_TYPE_DISPLAY, cmd, &tone);
598         if (ret >= 0)
599                 ret = tone;
600
601         _I("get auto screen tone %d, %d", tone, ret);
602
603         reply = dbus_message_new_method_return(msg);
604         dbus_message_iter_init_append(reply, &iter);
605         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
606         return reply;
607 }
608
609 static DBusMessage *edbus_setautotone(E_DBus_Object *obj, DBusMessage *msg)
610 {
611         DBusMessageIter iter;
612         DBusMessage *reply;
613         int cmd, tone, ret;
614
615         dbus_message_iter_init(msg, &iter);
616         dbus_message_iter_get_basic(&iter, &tone);
617
618         cmd = DISP_CMD(PROP_DISPLAY_AUTO_SCREEN_TONE, DEFAULT_DISPLAY);
619         ret = device_set_property(DEVICE_TYPE_DISPLAY, cmd, tone);
620
621         _I("set auto screen tone %d, %d", tone, ret);
622
623         reply = dbus_message_new_method_return(msg);
624         dbus_message_iter_init_append(reply, &iter);
625         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
626         return reply;
627 }
628
629 static DBusMessage *edbus_setautotoneforce(E_DBus_Object *obj, DBusMessage *msg)
630 {
631         DBusMessageIter iter;
632         DBusMessage *reply;
633         int cmd, tone, ret;
634
635         dbus_message_iter_init(msg, &iter);
636         dbus_message_iter_get_basic(&iter, &tone);
637
638         cmd = DISP_CMD(PROP_DISPLAY_AUTO_SCREEN_TONE_FORCE, DEFAULT_DISPLAY);
639         ret = device_set_property(DEVICE_TYPE_DISPLAY, cmd, tone);
640
641         _I("set auto screen tone force %d, %d", tone, ret);
642
643         reply = dbus_message_new_method_return(msg);
644         dbus_message_iter_init_append(reply, &iter);
645         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
646         return reply;
647 }
648
649 static DBusMessage *edbus_setrefreshrate(E_DBus_Object *obj, DBusMessage *msg)
650 {
651         DBusMessageIter iter;
652         DBusMessage *reply;
653         int app, val, cmd, ret, control;
654
655         ret = dbus_message_get_args(msg, NULL,
656                         DBUS_TYPE_INT32, &app,
657                         DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
658         if (!ret) {
659                 _I("there is no message");
660                 ret = -EINVAL;
661                 goto error;
662         }
663
664         if (app < 0 || app >= ARRAY_SIZE(display_conf.framerate_app) || val < 0) {
665                 ret = -EINVAL;
666                 goto error;
667         }
668
669         if (!display_conf.framerate_app[app]) {
670                 _I("This case(%d) is not support in this target", app);
671                 ret = -EPERM;
672                 goto error;
673         }
674
675         control = display_conf.control_display;
676
677         if (control)
678                 backlight_ops.off();
679
680         _D("app : %d, value : %d", app, val);
681         cmd = DISP_CMD(PROP_DISPLAY_FRAME_RATE, DEFAULT_DISPLAY);
682         ret = device_set_property(DEVICE_TYPE_DISPLAY, cmd, val);
683
684         if (control)
685                 backlight_ops.on();
686
687 error:
688         reply = dbus_message_new_method_return(msg);
689         dbus_message_iter_init_append(reply, &iter);
690         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
691         return reply;
692 }
693
694 static DBusMessage *edbus_getcolorblind(E_DBus_Object *obj, DBusMessage *msg)
695 {
696         DBusMessageIter iter;
697         DBusMessage *reply;
698         int cmd, val, ret;
699
700         cmd = DISP_CMD(PROP_DISPLAY_IMAGE_ENHANCE_COLOR_BLIND, DEFAULT_DISPLAY);
701         ret = device_get_property(DEVICE_TYPE_DISPLAY, cmd, &val);
702         if (ret >= 0)
703                 ret = val;
704
705         _I("get color blind %d", val);
706
707         reply = dbus_message_new_method_return(msg);
708         dbus_message_iter_init_append(reply, &iter);
709         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
710         return reply;
711 }
712
713 static DBusMessage *edbus_setcolorblind(E_DBus_Object *obj, DBusMessage *msg)
714 {
715         DBusMessageIter iter;
716         DBusMessage *reply;
717         int cmd, val, ret;
718         unsigned int power;
719         uint64_t red, grn, blu;
720         struct color_blind_info info;
721
722         ret = dbus_message_get_args(msg, NULL, DBUS_TYPE_UINT32, &power,
723                         DBUS_TYPE_UINT64, &red, DBUS_TYPE_UINT64, &grn,
724                         DBUS_TYPE_UINT64, &blu, DBUS_TYPE_INVALID);
725         if (!ret) {
726                 _I("there is no message");
727                 ret = -EINVAL;
728                 goto error;
729         }
730
731         info.power = power;
732         info.RrCr = BLIND_RED(red);
733         info.RgCg = BLIND_GREEN(red);
734         info.RbCb = BLIND_BLUE(red);
735         info.GrMr = BLIND_RED(grn);
736         info.GgMg = BLIND_GREEN(grn);
737         info.GbMb = BLIND_BLUE(grn);
738         info.BrYr = BLIND_RED(blu);
739         info.BgYg = BLIND_GREEN(blu);
740         info.BbYb = BLIND_BLUE(blu);
741
742         cmd = DISP_CMD(PROP_DISPLAY_IMAGE_ENHANCE_COLOR_BLIND, DEFAULT_DISPLAY);
743         ret = device_set_property(DEVICE_TYPE_DISPLAY, cmd, (int)&info);
744
745         _I("set color blind %d, %hu, %hu, %hu, %hu, %hu, %hu, %hu, %hu, %hu, %d",
746                         info.power, info.RrCr, info.RgCg, info.RbCb, info.GrMr, info.GgMg,
747                         info.GbMb, info.BrYr, info.BgYg, info.BbYb, ret);
748
749 error:
750         reply = dbus_message_new_method_return(msg);
751         dbus_message_iter_init_append(reply, &iter);
752         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
753         return reply;
754 }
755
756 static DBusMessage *edbus_gethbm(E_DBus_Object *obj, DBusMessage *msg)
757 {
758         DBusMessageIter iter;
759         DBusMessage *reply;
760         int hbm;
761
762         if (!msg) {
763                 _E("msg is empty!");
764                 return NULL;
765         }
766
767         /* check weak function symbol */
768         if (!hbm_get_state) {
769                 hbm = -ENOSYS;
770                 goto error;
771         }
772
773         hbm = hbm_get_state();
774
775         if (hbm < 0)
776                 _E("failed to get high brightness mode %d", hbm);
777         else
778                 _D("get high brightness mode %d", hbm);
779 error:
780         reply = dbus_message_new_method_return(msg);
781         dbus_message_iter_init_append(reply, &iter);
782         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &hbm);
783         return reply;
784 }
785
786 static DBusMessage *edbus_sethbm(E_DBus_Object *obj, DBusMessage *msg)
787 {
788         DBusMessageIter iter;
789         DBusMessage *reply;
790         int hbm, ret;
791
792         if (!msg) {
793                 _E("msg is empty!");
794                 return NULL;
795         }
796
797         if (!dbus_message_get_args(msg, NULL,
798                     DBUS_TYPE_INT32, &hbm,
799                     DBUS_TYPE_INVALID)) {
800                 _E("there is no message");
801                 ret = -EINVAL;
802                 goto error;
803         }
804
805         /* check weak function symbol */
806         if (!hbm_set_state) {
807                 ret = -ENOSYS;
808                 goto error;
809         }
810
811         ret = hbm_set_state(hbm);
812
813         if (ret < 0)
814                 _E("failed to set high brightness mode (%d,%d)", ret, hbm);
815         else
816                 _I("set high brightness mode (%d,%d)", ret, hbm);
817 error:
818         reply = dbus_message_new_method_return(msg);
819         dbus_message_iter_init_append(reply, &iter);
820         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
821         return reply;
822 }
823
824 static DBusMessage *edbus_sethbm_timeout(E_DBus_Object *obj, DBusMessage *msg)
825 {
826         DBusMessageIter iter;
827         DBusMessage *reply;
828         int hbm, timeout, ret;
829
830         if (!msg) {
831                 _E("msg is empty!");
832                 return NULL;
833         }
834
835         if (!dbus_message_get_args(msg, NULL,
836                     DBUS_TYPE_INT32, &hbm,
837                     DBUS_TYPE_INT32, &timeout, DBUS_TYPE_INVALID)) {
838                 _E("there is no message");
839                 ret = -EINVAL;
840                 goto error;
841         }
842
843         /* check weak function symbol */
844         if (!hbm_set_state_with_timeout) {
845                 ret = -ENOSYS;
846                 goto error;
847         }
848
849         ret = hbm_set_state_with_timeout(hbm, timeout);
850
851         if (ret < 0)
852                 _E("failed to set high brightness mode (%d,%d,%d)",
853                     ret, hbm, timeout);
854         else
855                 _I("set high brightness mode (%d,%d,%d)",
856                     ret, hbm, timeout);
857 error:
858         reply = dbus_message_new_method_return(msg);
859         dbus_message_iter_init_append(reply, &iter);
860         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
861         return reply;
862 }
863
864 static DBusMessage *edbus_setautobrightnessmin(E_DBus_Object *obj, DBusMessage *msg)
865 {
866         DBusMessageIter iter;
867         DBusMessage *reply;
868         int val, ret;
869         pid_t pid;
870         const char *sender;
871
872         sender = dbus_message_get_sender(msg);
873         if (!sender) {
874                 _E("invalid sender name!");
875                 ret = -EINVAL;
876                 goto error;
877         }
878         if (!display_info.set_autobrightness_min) {
879                 ret = -EIO;
880                 goto error;
881         }
882         dbus_message_iter_init(msg, &iter);
883         dbus_message_iter_get_basic(&iter, &val);
884
885         pid = get_edbus_sender_pid(msg);
886         ret = display_info.set_autobrightness_min(val, (char *)sender);
887         if (ret) {
888                 _W("fail to set autobrightness min %d, %d by %d", val, ret, pid);
889                 goto error;
890         }
891         if (display_info.reset_autobrightness_min) {
892                 register_edbus_watch(msg, WATCH_DISPLAY_AUTOBRIGHTNESS_MIN,
893                     display_info.reset_autobrightness_min);
894                 _I("set autobrightness min %d by %d", val, pid);
895         }
896 error:
897         reply = dbus_message_new_method_return(msg);
898         dbus_message_iter_init_append(reply, &iter);
899         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
900
901         return reply;
902 }
903
904 static DBusMessage *edbus_setlcdtimeout(E_DBus_Object *obj, DBusMessage *msg)
905 {
906         DBusMessageIter iter;
907         DBusMessage *reply;
908         int on, dim, holdkey_block, ret;
909         pid_t pid;
910         const char *sender;
911
912         sender = dbus_message_get_sender(msg);
913         if (!sender) {
914                 _E("invalid sender name!");
915                 ret = -EINVAL;
916                 goto error;
917         }
918
919         ret = dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &on,
920                     DBUS_TYPE_INT32, &dim, DBUS_TYPE_INT32, &holdkey_block,
921                     DBUS_TYPE_INVALID);
922
923         pid = get_edbus_sender_pid(msg);
924         ret = set_lcd_timeout(on, dim, holdkey_block, sender);
925         if (ret) {
926                 _W("fail to set lcd timeout %d by %d", ret, pid);
927         } else {
928                 register_edbus_watch(msg, WATCH_DISPLAY_LCD_TIMEOUT,
929                     reset_lcd_timeout);
930                 _I("set lcd timeout on %d, dim %d, holdblock %d by %d",
931                     on, dim, holdkey_block, pid);
932         }
933 error:
934         reply = dbus_message_new_method_return(msg);
935         dbus_message_iter_init_append(reply, &iter);
936         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
937
938         return reply;
939 }
940
941 static DBusMessage *edbus_lockscreenbgon(E_DBus_Object *obj, DBusMessage *msg)
942 {
943         DBusMessageIter iter;
944         DBusMessage *reply;
945         int ret = 0;
946         char *on;
947
948         ret = dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &on,
949                     DBUS_TYPE_INVALID);
950
951         if (!ret) {
952                 _E("fail to update lcdscreen bg on state %d", ret);
953                 ret = -EINVAL;
954                 goto error;
955         }
956
957         if (!strcmp(on, "true"))
958                 update_pm_setting(SETTING_LOCK_SCREEN_BG, true);
959         else if (!strcmp(on, "false"))
960                 update_pm_setting(SETTING_LOCK_SCREEN_BG, false);
961         else
962                 ret = -EINVAL;
963
964 error:
965         reply = dbus_message_new_method_return(msg);
966         dbus_message_iter_init_append(reply, &iter);
967         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
968
969         return reply;
970 }
971
972 static DBusMessage *edbus_dumpmode(E_DBus_Object *obj, DBusMessage *msg)
973 {
974         DBusMessageIter iter;
975         DBusMessage *reply;
976         int ret = 0;
977         char *on;
978
979         ret = dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &on,
980                     DBUS_TYPE_INVALID);
981
982         if (!ret) {
983                 _E("fail to get dumpmode state %d", ret);
984                 ret = -EINVAL;
985                 goto error;
986         }
987
988         if (!strcmp(on, "on"))
989                 pm_lock_internal(INTERNAL_LOCK_DUMPMODE, LCD_OFF,
990                     STAY_CUR_STATE, DUMP_MODE_WATING_TIME);
991         else if (!strcmp(on, "off"))
992                 pm_unlock_internal(INTERNAL_LOCK_DUMPMODE, LCD_OFF,
993                     PM_SLEEP_MARGIN);
994         else
995                 ret = -EINVAL;
996
997 error:
998         reply = dbus_message_new_method_return(msg);
999         dbus_message_iter_init_append(reply, &iter);
1000         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
1001
1002         return reply;
1003 }
1004
1005 static DBusMessage *edbus_savelog(E_DBus_Object *obj, DBusMessage *msg)
1006 {
1007         save_display_log();
1008         return dbus_message_new_method_return(msg);
1009 }
1010
1011 static DBusMessage *edbus_powerkeyignore(E_DBus_Object *obj, DBusMessage *msg)
1012 {
1013         DBusMessageIter iter;
1014         DBusMessage *reply;
1015         int ret = 0;
1016         int on;
1017
1018         ret = dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &on,
1019                     DBUS_TYPE_INVALID);
1020
1021         if (!ret) {
1022                 _E("fail to get powerkey ignore %d", ret);
1023                 ret = -EINVAL;
1024                 goto error;
1025         }
1026
1027         if (CHECK_OPS(keyfilter_ops, set_powerkey_ignore))
1028                 keyfilter_ops->set_powerkey_ignore(on == 1 ? true : false);
1029 error:
1030         reply = dbus_message_new_method_return(msg);
1031         dbus_message_iter_init_append(reply, &iter);
1032         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
1033
1034         return reply;
1035 }
1036
1037 static DBusMessage *edbus_powerkeylcdoff(E_DBus_Object *obj, DBusMessage *msg)
1038 {
1039         DBusMessageIter iter;
1040         DBusMessage *reply;
1041         int ret;
1042
1043         if (CHECK_OPS(keyfilter_ops, powerkey_lcdoff))
1044                 ret = keyfilter_ops->powerkey_lcdoff();
1045         else
1046                 ret = -ENOSYS;
1047
1048         reply = dbus_message_new_method_return(msg);
1049         dbus_message_iter_init_append(reply, &iter);
1050         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
1051
1052         return reply;
1053 }
1054
1055 static DBusMessage *edbus_customlcdon(E_DBus_Object *obj, DBusMessage *msg)
1056 {
1057         DBusMessageIter iter;
1058         DBusMessage *reply;
1059         int ret = 0;
1060         int timeout;
1061
1062         ret = dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &timeout,
1063                     DBUS_TYPE_INVALID);
1064
1065         if (!ret) {
1066                 _E("fail to get custom lcd timeout %d", ret);
1067                 ret = -EINVAL;
1068                 goto error;
1069         }
1070
1071         ret = custom_lcdon(timeout);
1072
1073 error:
1074         reply = dbus_message_new_method_return(msg);
1075         dbus_message_iter_init_append(reply, &iter);
1076         dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
1077
1078         return reply;
1079 }
1080
1081 static const struct edbus_method edbus_methods[] = {
1082         { "start",           NULL,  NULL, edbus_start },
1083         { "stop",            NULL,  NULL, edbus_stop },
1084         { "lockstate",     "sssi",   "i", edbus_lockstate },
1085         { "unlockstate",     "ss",   "i", edbus_unlockstate },
1086         { "changestate",      "s",   "i", edbus_changestate },
1087         { "getbrightness",   NULL,   "i", edbus_getbrightness },        /* deprecated */
1088         { "setbrightness",    "i",   "i", edbus_setbrightness },        /* deprecated */
1089         { "getautotone",     NULL,   "i", edbus_getautotone },  /* deprecated */
1090         { "setautotone",      "i",   "i", edbus_setautotone },  /* deprecated */
1091         { "setframerate",    "ii",   "i", edbus_setrefreshrate },       /* deprecated */
1092         { "getcolorblind",   NULL,   "i", edbus_getcolorblind },        /* deprecated */
1093         { "setcolorblind", "uttt",   "i", edbus_setcolorblind },        /* deprecated */
1094         { "setautobrightnessmin", "i", "i", edbus_setautobrightnessmin },
1095         { "setlcdtimeout",  "iii",   "i", edbus_setlcdtimeout },
1096         { "LockScreenBgOn",   "s",   "i", edbus_lockscreenbgon },
1097         { "GetDisplayCount", NULL,   "i", edbus_getdisplaycount },
1098         { "GetMaxBrightness",NULL,   "i", edbus_getmaxbrightness },
1099         { "SetMaxBrightness", "i",   "i", edbus_setmaxbrightness },
1100         { "GetBrightness",   NULL,   "i", edbus_getbrightness },
1101         { "SetBrightness",    "i",   "i", edbus_setbrightness },
1102         { "HoldBrightness",   "i",   "i", edbus_holdbrightness },
1103         { "ReleaseBrightness", NULL, "i", edbus_releasebrightness },
1104         { "GetAclStatus",    NULL,   "i", edbus_getaclstatus },
1105         { "SetAclStatus",    NULL,   "i", edbus_setaclstatus },
1106         { "GetAutoTone",     NULL,   "i", edbus_getautotone },
1107         { "SetAutoTone",      "i",   "i", edbus_setautotone },
1108         { "SetAutoToneForce", "i",   "i", edbus_setautotoneforce },
1109         { "SetRefreshRate",  "ii",   "i", edbus_setrefreshrate },
1110         { "GetColorBlind",   NULL,   "i", edbus_getcolorblind },
1111         { "SetColorBlind", "uttt",   "i", edbus_setcolorblind },
1112         { "GetHBM",          NULL,   "i", edbus_gethbm },
1113         { "SetHBM",           "i",   "i", edbus_sethbm },
1114         { "SetHBMTimeout"   ,"ii",   "i", edbus_sethbm_timeout },
1115         { "Dumpmode",         "s",   "i", edbus_dumpmode },
1116         { "SaveLog",         NULL,  NULL, edbus_savelog },
1117         { "PowerKeyIgnore",   "i",  NULL, edbus_powerkeyignore },
1118         { "PowerKeyLCDOff",  NULL,   "i", edbus_powerkeylcdoff },
1119         { "CustomLCDOn",      "i",   "i", edbus_customlcdon },
1120         /* Add methods here */
1121 };
1122
1123 static void sim_signal_handler(void *data, DBusMessage *msg)
1124 {
1125         DBusError err;
1126         int ret, val;
1127         static int state = false;
1128
1129         if (state)
1130                 return;
1131
1132         ret = dbus_message_is_signal(msg, TELEPHONY_INTERFACE_SIM,
1133             SIGNAL_SIM_STATUS);
1134         if (!ret) {
1135                 _E("there is no power off popup signal");
1136                 return;
1137         }
1138
1139         ret = vconf_get_bool(VCONFKEY_LCD_BRIGHTNESS_INIT, &state);
1140         if (ret < 0 || state)
1141                 return;
1142
1143         dbus_error_init(&err);
1144
1145         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &val,
1146             DBUS_TYPE_INVALID);
1147         if (!ret) {
1148                 _E("no message : [%s:%s]", err.name, err.message);
1149                 dbus_error_free(&err);
1150         }
1151
1152         if (val != SIM_CARD_NOT_PRESENT) {
1153                 /* change setting : autobrightness on */
1154                 state = true;
1155                 vconf_set_bool(VCONFKEY_LCD_BRIGHTNESS_INIT, state);
1156                 vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT,
1157                     SETTING_BRIGHTNESS_AUTOMATIC_ON);
1158                 vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS,
1159                     PM_DEFAULT_BRIGHTNESS);
1160                 _I("SIM card is inserted at first!");
1161         }
1162 }
1163
1164 static void homescreen_signal_handler(void *data, DBusMessage *msg)
1165 {
1166         DBusError err;
1167         int ret;
1168         char *screen;
1169
1170
1171         ret = dbus_message_is_signal(msg, DEVICED_INTERFACE_NAME,
1172             SIGNAL_HOMESCREEN);
1173         if (!ret) {
1174                 _E("there is no homescreen signal");
1175                 return;
1176         }
1177
1178         dbus_error_init(&err);
1179
1180         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &screen,
1181             DBUS_TYPE_INVALID);
1182         if (!ret) {
1183                 _E("no message : [%s:%s]", err.name, err.message);
1184                 dbus_error_free(&err);
1185         }
1186
1187         _D("screen : %s", screen);
1188
1189         if (set_alpm_screen)
1190                 set_alpm_screen(screen);
1191         else
1192                 _E("alpm screen mode is not supported!");
1193 }
1194
1195 static void extreme_signal_handler(void *data, DBusMessage *msg)
1196 {
1197         int ret;
1198
1199         ret = dbus_message_is_signal(msg, POPUP_INTERFACE_LOWBAT,
1200             SIGNAL_EXTREME);
1201         if (!ret) {
1202                 _E("there is no extreme signal");
1203                 return;
1204         }
1205
1206         pm_status_flag &= ~BRTCH_FLAG;
1207         if (hbm_get_state != NULL && hbm_get_state() == true)
1208                 hbm_set_state_with_timeout(false, 0);
1209         backlight_ops.update();
1210         _D("extreme mode : enter dim state!");
1211         if (vconf_set_int(VCONFKEY_PM_KEY_IGNORE, TRUE) != 0)
1212                 _E("failed to set vconf status");
1213 }
1214
1215 static void not_extreme_signal_handler(void *data, DBusMessage *msg)
1216 {
1217         int ret;
1218
1219         ret = dbus_message_is_signal(msg, POPUP_INTERFACE_LOWBAT,
1220             SIGNAL_NOTEXTREME);
1221         if (!ret) {
1222                 _E("there is no extreme signal");
1223                 return;
1224         }
1225
1226         _D("release extreme mode");
1227         if (vconf_set_int(VCONFKEY_PM_KEY_IGNORE, FALSE) != 0)
1228                 _E("failed to set vconf status");
1229 }
1230
1231 int init_pm_dbus(void)
1232 {
1233         int ret;
1234
1235         ret = register_edbus_method(DEVICED_PATH_DISPLAY,
1236                     edbus_methods, ARRAY_SIZE(edbus_methods));
1237         if (ret < 0) {
1238                 _E("Failed to register edbus method! %d", ret);
1239                 return ret;
1240         }
1241
1242         ret = register_edbus_signal_handler(TELEPHONY_PATH,
1243                     TELEPHONY_INTERFACE_SIM, SIGNAL_SIM_STATUS,
1244                     sim_signal_handler);
1245         if (ret < 0 && ret != -EEXIST) {
1246                 _E("Failed to register signal handler! %d", ret);
1247                 return ret;
1248         }
1249
1250         ret = register_edbus_signal_handler(DEVICED_OBJECT_PATH,
1251                     DEVICED_INTERFACE_NAME, SIGNAL_HOMESCREEN,
1252                     homescreen_signal_handler);
1253         if (ret < 0 && ret != -EEXIST) {
1254                 _E("Failed to register signal handler! %d", ret);
1255                 return ret;
1256         }
1257
1258         ret = register_edbus_signal_handler(POPUP_PATH_LOWBAT,
1259                     POPUP_INTERFACE_LOWBAT, SIGNAL_EXTREME,
1260                     extreme_signal_handler);
1261         if (ret < 0 && ret != -EEXIST) {
1262                 _E("Failed to register signal handler! %d", ret);
1263                 return ret;
1264         }
1265         ret = register_edbus_signal_handler(POPUP_PATH_LOWBAT,
1266                     POPUP_INTERFACE_LOWBAT, SIGNAL_NOTEXTREME,
1267                     not_extreme_signal_handler);
1268         if (ret < 0 && ret != -EEXIST) {
1269                 _E("Failed to register signal handler! %d", ret);
1270                 return ret;
1271         }
1272         return 0;
1273 }
1274