diff options
author | jk7744.park <jk7744.park@samsung.com> | 2015-10-24 15:44:18 +0900 |
---|---|---|
committer | jk7744.park <jk7744.park@samsung.com> | 2015-10-24 15:44:18 +0900 |
commit | 730191fd414d47760dbc95ad049cab29d42e3b2b (patch) | |
tree | 58827332b01aba4d5b77d58266ab8160e8c6cfe4 /src/wearable/starter.c | |
parent | 5cea387de7e517476d31b915642c232347ca7a3d (diff) | |
download | starter-submit/tizen_2.4/20151028.062659.tar.gz starter-submit/tizen_2.4/20151028.062659.tar.bz2 starter-submit/tizen_2.4/20151028.062659.zip |
tizen 2.4 releasetizen_2.4_mobile_releasesubmit/tizen_2.4/20151028.062659accepted/tizen/2.4/mobile/20151029.041232accepted/tizen_2.4_mobile
Diffstat (limited to 'src/wearable/starter.c')
-rw-r--r-- | src/wearable/starter.c | 191 |
1 files changed, 191 insertions, 0 deletions
diff --git a/src/wearable/starter.c b/src/wearable/starter.c new file mode 100644 index 0000000..39151f1 --- /dev/null +++ b/src/wearable/starter.c @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <Elementary.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include <string.h> +#include <errno.h> +#include <vconf.h> +#include <signal.h> +#include <dd-deviced.h> + +#include "hw_key.h" +#include "util.h" +#include "hourly_alert.h" +#include "dbus_util.h" +#include "clock_mgr.h" +#include "status.h" +#include "home_mgr.h" +#include "process_mgr.h" + +#define PWLOCK_PKGNAME "org.tizen.b2-pwlock" + +int errno; + + + + +static struct { + int lcd_status; +} s_starter = { + .lcd_status = -1, +}; + + + +static void _signal_handler(int signum, siginfo_t *info, void *unused) +{ + _D("_signal_handler : Terminated..."); + elm_exit(); +} + + + +static int _power_off_cb(status_active_key_e key, void *data) +{ + int val = status_active_get()->sysman_power_off_status; + + if (val > VCONFKEY_SYSMAN_POWER_OFF_POPUP) { + _E("power off status : %d", val); + elm_exit(); + } + + return 1; +} + + + +static int _change_language_cb(status_active_key_e key, void *data) +{ + _D("%s, %d", __func__, __LINE__); + + if (status_active_get()->langset) { + elm_language_set(status_active_get()->langset); + } + + return 1; +} + + + +static int _change_sequence_cb(status_active_key_e key, void *data) +{ + int seq = status_active_get()->starter_sequence; + + if (seq == 1) { + home_mgr_launch_home_first(); + } + + return 1; +} + + + +static void _on_lcd_changed_receive(void *data, DBusMessage *msg) +{ + int lcd_on = 0; + int lcd_off = 0; + + _D("LCD signal is received"); + + lcd_on = dbus_message_is_signal(msg, DEVICED_INTERFACE_DISPLAY, MEMBER_LCD_ON); + lcd_off = dbus_message_is_signal(msg, DEVICED_INTERFACE_DISPLAY, MEMBER_LCD_OFF); + + if (lcd_on) { + _W("LCD on"); + s_starter.lcd_status = 1; + } else if(lcd_off) { + _W("LCD off"); + s_starter.lcd_status = 0; + } else { + _E("%s dbus_message_is_signal error", DEVICED_INTERFACE_DISPLAY); + } +} + + + +static void _init(void) +{ + struct sigaction act; + + memset(&act,0x00,sizeof(struct sigaction)); + act.sa_sigaction = _signal_handler; + act.sa_flags = SA_SIGINFO; + + int ret = sigemptyset(&act.sa_mask); + if (ret < 0) { + _E("Failed to sigemptyset[%s]", strerror(errno)); + } + ret = sigaddset(&act.sa_mask, SIGTERM); + if (ret < 0) { + _E("Failed to sigaddset[%s]", strerror(errno)); + } + ret = sigaction(SIGTERM, &act, NULL); + if (ret < 0) { + _E("Failed to sigaction[%s]", strerror(errno)); + } + + status_register(); + status_active_register_cb(STATUS_ACTIVE_KEY_SYSMAN_POWER_OFF_STATUS, _power_off_cb, NULL); + status_active_register_cb(STATUS_ACTIVE_KEY_LANGSET, _change_language_cb, NULL); + + home_mgr_launch_home(); + process_mgr_must_launch(PWLOCK_PKGNAME, NULL, NULL, NULL, NULL); + + dbus_util_receive_lcd_status(_on_lcd_changed_receive, NULL); + + home_mgr_init(); + clock_mgr_init(); + hourly_alert_init(); + hw_key_create_window(); +} + + + +static void _fini(void) +{ + hw_key_destroy_window(); + hourly_alert_fini(); + clock_mgr_fini(); + home_mgr_fini(); + + status_active_unregister_cb(STATUS_ACTIVE_KEY_SYSMAN_POWER_OFF_STATUS, _power_off_cb); + status_active_unregister_cb(STATUS_ACTIVE_KEY_LANGSET, _change_language_cb); + status_active_unregister_cb(STATUS_ACTIVE_KEY_STARTER_SEQUENCE, _change_sequence_cb); + status_unregister(); +} + + + +int main(int argc, char *argv[]) +{ + _D("starter is launched..!!"); + + elm_init(argc, argv); + _init(); + + elm_run(); + + _fini(); + elm_shutdown(); + + return 0; +} |