From: Jin Yoon Date: Wed, 22 Aug 2012 04:19:04 +0000 (+0900) Subject: New features : Power-off, Set the vconf key when not launching selected home-screen... X-Git-Tag: submit/2.0alpha-wayland/20130208.005754~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7595f39f90002c04c0a1bc70cfbaa409308775b2;p=profile%2Fivi%2Fmenu-daemon.git New features : Power-off, Set the vconf key when not launching selected home-screen, handle cancel-key Change-Id: I6a2db10cbe56c62723d0390c8c8d6a9ac9a40afb --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d534651 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +.gitattributes +.*swp +*.log +*.cmake +*.install +*.substvars +*stamp +CMakeCache.txt +CMakeFiles +debian/tmp +debian/menu-daemon-dbg +debian/menu-daemon +debian/files +Makefile +menu-daemon diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e47275..3056f3d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,25 +9,25 @@ SET(VERSION 0.1.0) INCLUDE(FindPkgConfig) pkg_check_modules(pkgs REQUIRED - elementary - heynoti - elementary + ail aul - vconf + capi-system-media-key + db-util + dlog ecore - evas ecore-evas - eet - x11 - dlog - db-util ecore-x - utilX ecore-input ecore-file - syspopup-caller - ail + eet eina + elementary + evas + heynoti + syspopup-caller + utilX + vconf + x11 ) diff --git a/data/menudaemon b/data/menudaemon index 536cf12..22fc127 100755 --- a/data/menudaemon +++ b/data/menudaemon @@ -1,3 +1,4 @@ #!/bin/sh +echo -e "<2>[${_G}menu-daemon start${C_}]" > /dev/kmsg /usr/bin/menu-daemon & sleep 9 diff --git a/data/menudaemon.fast b/data/menudaemon.fast index 4d16383..281034b 100755 --- a/data/menudaemon.fast +++ b/data/menudaemon.fast @@ -1,2 +1,3 @@ #!/bin/sh +echo -e "<2>[${_G}menu-daemon start${C_}]" > /dev/kmsg /usr/bin/menu-daemon & diff --git a/debian/control b/debian/control index 7d2b2eb..7725f48 100755 --- a/debian/control +++ b/debian/control @@ -2,14 +2,14 @@ Source: menu-daemon Section: utils Priority: extra Maintainer: Jin Yoon , Youngjoo Park -Build-Depends: debhelper (>= 5), libelm-dev, libslp-setting-dev, libefreet-dev, dlog-dev, libecore-dev, libaul-1-dev, syspopup-caller-dev, libheynoti-dev, libslp-utilx-dev, libail-0-dev +Build-Depends: debhelper (>= 5), libelm-dev, libslp-setting-dev, libefreet-dev, dlog-dev, libecore-dev, libaul-1-dev, syspopup-caller-dev, libheynoti-dev, libslp-utilx-dev, libail-0-dev, capi-system-media-key-dev Homepage: N/A Standards-Version: 0.1.0 Package: menu-daemon Section: utils Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, libelm, libslp-setting-0, libefreet, libdlog-0, libaul-1, syspopup-caller-0, libheynoti-0, libslp-utilx-0, libail-0 +Depends: ${shlibs:Depends}, ${misc:Depends}, libelm, libslp-setting-0, libefreet, libdlog-0, libaul-1, syspopup-caller-0, libheynoti-0, libslp-utilx-0, libail-0, capi-system-media-key Description: menu-daemon (Grab H/W key, Package manifest file parsing) Package: menu-daemon-dbg diff --git a/debian/menu-daemon.postinst b/debian/menu-daemon.postinst index f0970fd..38c2969 100755 --- a/debian/menu-daemon.postinst +++ b/debian/menu-daemon.postinst @@ -2,8 +2,8 @@ vconf_init() { - vconftool set -t string memory/menuscreen/desktop "0" -i - vconftool set -t string db/menuscreen/pkgname "org.tizen.menu-screen" -i -u 5000 + vconftool set -t string memory/menuscreen/desktop "0" -i -f + vconftool set -t int memory/idle-screen/is_idle_screen_launched "0" -i -u 5000 -f } vconf_init diff --git a/debian/rules b/debian/rules index 62ff850..74d350c 100755 --- a/debian/rules +++ b/debian/rules @@ -9,8 +9,8 @@ # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 -CFLAGS += -Wall -Werror -fpie -CXXFLAGS += -Wall -Werror -fpie +CFLAGS += -Wall -Werror -fpie -Winline +CXXFLAGS += -Wall -Werror -fpie -Winline LDFLAGS ?= PREFIX ?= /usr DATADIR ?= /opt diff --git a/include/util.h b/include/util.h index 557daaa..c7e257a 100644 --- a/include/util.h +++ b/include/util.h @@ -21,7 +21,7 @@ #include #define HOME_SCREEN_PKG_NAME "org.tizen.menu-screen" -#define MENU_PKG_VCONF_KEY "db/menuscreen/pkgname" +#define MENU_PKG_VCONF_KEY "db/setting/menuscreen/pkgname" #define CONF_PATH_NUMBER 1024 /* Log */ diff --git a/packaging/menu-daemon.spec b/packaging/menu-daemon.spec index d262f57..6256649 100644 --- a/packaging/menu-daemon.spec +++ b/packaging/menu-daemon.spec @@ -9,24 +9,21 @@ Release: 1 Group: TO_BE/FILLED_IN License: Flora Software License Source0: menu-daemon-%{version}.tar.gz -BuildRequires: pkgconfig(ail) -BuildRequires: pkgconfig(aul) -BuildRequires: pkgconfig(db-util) -BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(ecore) -BuildRequires: pkgconfig(ecore-evas) -BuildRequires: pkgconfig(ecore-file) -BuildRequires: pkgconfig(ecore-input) -BuildRequires: pkgconfig(ecore-x) -BuildRequires: pkgconfig(eet) -BuildRequires: pkgconfig(eina) -BuildRequires: pkgconfig(elementary) -BuildRequires: pkgconfig(evas) -BuildRequires: pkgconfig(heynoti) -BuildRequires: pkgconfig(syspopup-caller) -BuildRequires: pkgconfig(utilX) -BuildRequires: pkgconfig(vconf) -BuildRequires: pkgconfig(x11) +BuildRequires: pkgconfig(ail) +BuildRequires: pkgconfig(aul) +BuildRequires: pkgconfig(capi-system-media-key) +BuildRequires: pkgconfig(db-util) +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(ecore) +BuildRequires: pkgconfig(eet) +BuildRequires: pkgconfig(eina) +BuildRequires: pkgconfig(elementary) +BuildRequires: pkgconfig(evas) +BuildRequires: pkgconfig(heynoti) +BuildRequires: pkgconfig(syspopup-caller) +BuildRequires: pkgconfig(utilX) +BuildRequires: pkgconfig(vconf) +BuildRequires: pkgconfig(x11) BuildRequires: cmake BuildRequires: edje-bin @@ -53,12 +50,14 @@ chmod +x %{buildroot}/etc/init.d/menudaemon chmod +x %{buildroot}/etc/init.d/menudaemon.fast %post -vconftool set -t string memory/menuscreen/desktop "0" -i -vconftool set -t string db/menuscreen/pkgname "org.tizen.menu-screen" -i -u 5000 +vconftool set -t string memory/menuscreen/desktop "0" -i -f +vconftool set -t int memory/idle-screen/is_idle_screen_launched "0" -i -u 5000 -f + ln -sf /etc/init.d/menudaemon /etc/rc.d/rc3.d/S46menudaemon ln -sf /etc/init.d/menudaemon.fast /etc/rc.d/rc4.d/S85menudaemon %files +%defattr(-,root,root,-) %{_sysconfdir}/init.d/menudaemon %{_sysconfdir}/init.d/menudaemon.fast %{_bindir}/menu-daemon diff --git a/src/hw_key.c b/src/hw_key.c index b5470b3..deccb9b 100644 --- a/src/hw_key.c +++ b/src/hw_key.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "hw_key.h" #include "util.h" @@ -79,7 +80,7 @@ static Eina_Bool _launch_home_screen(void *data) syspopup_destroy_all(); key_info.single_timer = NULL; - package = vconf_get_str(MENU_PKG_VCONF_KEY); + package = vconf_get_str(VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME); if (package) { int ret; @@ -89,6 +90,9 @@ static Eina_Bool _launch_home_screen(void *data) _E("Default homescreen is not able to launch"); } else { _E("Package %s is not exists, rollback to default home", package); + if (0 != vconf_set_str(VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME, HOME_SCREEN_PKG_NAME)) { + _E("Cannot set value(%s) into key(%s)", VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME, HOME_SCREEN_PKG_NAME); + } ret = aul_open_app(HOME_SCREEN_PKG_NAME); if (ret < 0) _E("Failed to launch default home"); @@ -97,6 +101,10 @@ static Eina_Bool _launch_home_screen(void *data) free(package); } else { + if (0 != vconf_set_str(VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME, HOME_SCREEN_PKG_NAME)) { + _E("Cannot set value(%s) into key(%s)", VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME, HOME_SCREEN_PKG_NAME); + } + if (aul_open_app(HOME_SCREEN_PKG_NAME) < 0) _E("Cannot open default home"); } @@ -177,6 +185,21 @@ static Eina_Bool _key_release_cb(void *data, int type, void *event) } else if (!strcmp(ev->keyname, KEY_CAMERA)) { } else if (!strcmp(ev->keyname, KEY_SEND)) { } else if (!strcmp(ev->keyname, KEY_SELECT)) { + if (EINA_TRUE == key_info.cancel) { + _D("Cancel key is activated"); + if (key_info.long_press) { + ecore_timer_del(key_info.long_press); + key_info.long_press = NULL; + } + + if (key_info.single_timer) { + ecore_timer_del(key_info.single_timer); + key_info.single_timer = NULL; + } + + return ECORE_CALLBACK_RENEW; + } + _release_home_key(); } else if (!strcmp(ev->keyname, KEY_PAUSE)) { } else if (!strcmp(ev->keyname, KEY_VOLUMEDOWN)) { @@ -184,8 +207,9 @@ static Eina_Bool _key_release_cb(void *data, int type, void *event) ecore_timer_del(key_info.volume_down_long_press); key_info.volume_down_long_press = NULL; } - if (key_info.cancel == EINA_TRUE) { - _D("Cancel key is deactivating"); + + if (EINA_TRUE == key_info.cancel) { + _D("Cancel key is activated"); return ECORE_CALLBACK_RENEW; } if (syspopup_launch("volume", NULL) < 0) @@ -243,7 +267,7 @@ static Eina_Bool _volume_down_cb(void* data) _D("Long press : Volume down"); key_info.volume_down_long_press = NULL; - if (key_info.cancel == EINA_TRUE) + if (EINA_TRUE == key_info.cancel) return ECORE_CALLBACK_CANCEL; b = bundle_create(); @@ -326,6 +350,20 @@ static Eina_Bool _key_press_cb(void *data, int type, void *event) +void _media_key_event_cb(media_key_e key, media_key_event_e status, void *user_data) +{ + _D("MEDIA KEY EVENT"); + if (MEDIA_KEY_STATUS_PRESSED == status) return; + + if (MEDIA_KEY_PAUSE == key) { + _release_multimedia_key("KEY_PAUSECD"); + } else if (MEDIA_KEY_PLAY == key) { + _release_multimedia_key("KEY_PLAYCD"); + } +} + + + void create_key_window(void) { key_info.win = ecore_x_window_input_new(0, 0, 0, 1, 1); @@ -353,6 +391,8 @@ void create_key_window(void) key_info.key_down = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _key_press_cb, NULL); if (!key_info.key_down) _D("Failed to register a key down event handler"); + + media_key_reserve(_media_key_event_cb, NULL); } @@ -377,8 +417,10 @@ void destroy_key_window(void) key_info.key_down = NULL; } - ecore_x_window_delete_request_send(key_info.win); + ecore_x_window_delete_request_send(key_info.win); key_info.win = 0x0; + + media_key_release(); } diff --git a/src/menu_daemon.c b/src/menu_daemon.c index 4b4e2cf..b2ede4d 100644 --- a/src/menu_daemon.c +++ b/src/menu_daemon.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -39,6 +40,8 @@ int errno; #define QUERY_UPDATE_NAME "UPDATE app_info SET name='%s' where package='%s';" #define SAT_DESKTOP_FILE "/opt/share/applications/org.tizen.sat-ui.desktop" +#define HIBERNATION_DIR "/tmp/hibernation" +#define HIBERNATION_READY "/tmp/hibernation/menuscreen_ready" @@ -49,26 +52,31 @@ extern int aul_listen_app_dead_signal(int (*func)(int signal, void *data), void static struct info { pid_t pid; + int power_off; } s_info = { .pid = -1, + .power_off = 0, }; -static inline char *_get_pkgname(keynode_t *node) +static inline char *_get_selected_pkgname(void) { char *pkgname; - if (node) - pkgname = vconf_keynode_get_str(node); - else - pkgname = vconf_get_str(MENU_PKG_VCONF_KEY); - + pkgname = vconf_get_str(VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME); if (!pkgname) { _E("Cannot get pkgname from vconf."); + + if (0 != vconf_set_str(VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME, HOME_SCREEN_PKG_NAME)) { + _E("Cannot set value(%s) into key(%s)", VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME, HOME_SCREEN_PKG_NAME); + } + pkgname = strdup(HOME_SCREEN_PKG_NAME); - if (!pkgname) + if (!pkgname) { _E("strdup error for pkgname, %s", strerror(errno)); + return NULL; + } } return pkgname; @@ -84,6 +92,10 @@ static inline void _open_homescreen(const char *pkgname) ret = aul_open_app(homescreen); _D("can%s launch %s now. (%d)", ret < 0 ? "not" : "", homescreen, ret); if (ret < 0 && strcmp(homescreen, HOME_SCREEN_PKG_NAME)) { + if (0 != vconf_set_str(VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME, HOME_SCREEN_PKG_NAME)) { + _E("Cannot set value(%s) into key(%s)", VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME, HOME_SCREEN_PKG_NAME); + } + ret = aul_open_app(HOME_SCREEN_PKG_NAME); if (ret < 0) { _E("Failed to open a default home, %s", HOME_SCREEN_PKG_NAME); @@ -104,14 +116,14 @@ static void _show_cb(keynode_t* node, void *data) _D("[MENU_DAEMON] _show_cb is invoked"); - pkgname = _get_pkgname(NULL); + pkgname = _get_selected_pkgname(); if (!pkgname) return; if (node) { seq = vconf_keynode_get_int(node); } else { - if (vconf_get_int("memory/startapps/sequence", &seq) < 0) { + if (vconf_get_int(VCONFKEY_STARTER_SEQUENCE, &seq) < 0) { _E("Failed to get sequence info"); free(pkgname); return; @@ -151,7 +163,7 @@ static void _pkg_changed(keynode_t* node, void *data) char *pkgname; int seq; - if (vconf_get_int("memory/startapps/sequence", &seq) < 0) { + if (vconf_get_int(VCONFKEY_STARTER_SEQUENCE, &seq) < 0) { _E("Do nothing, there is no sequence info yet"); return; } @@ -163,7 +175,7 @@ static void _pkg_changed(keynode_t* node, void *data) _D("_pkg_changed is invoked"); - pkgname = _get_pkgname(node); + pkgname = _get_selected_pkgname(); if (!pkgname) return; @@ -200,13 +212,17 @@ static int _dead_cb(int pid, void *data) { char *pkgname; - _D("Process %d is termianted", pid); - if (pid != s_info.pid || s_info.pid <= 0) { - _D("Unknown process, ignore it (pid %d, menu pid %d)", pid, s_info.pid); + if (s_info.power_off) { + _D("Power off. ignore dead cb\n"); return 0; } - pkgname = _get_pkgname(NULL); + _D("Process %d is termianted", pid); + + if (pid < 0) + return 0; + + pkgname = _get_selected_pkgname(); if (!pkgname) return 0; @@ -233,15 +249,23 @@ static void _hibernation_preleave_cb(void *data) if (unlink(SAT_DESKTOP_FILE) != 0) _E("cannot remove sat-ui desktop."); - if (vconf_notify_key_changed(MENU_PKG_VCONF_KEY, _pkg_changed, NULL) < 0) + if (vconf_notify_key_changed(VCONFKEY_SETAPPL_SELECTED_PACKAGE_NAME, _pkg_changed, NULL) < 0) _E("Failed to add callback for package change event"); - if (vconf_notify_key_changed("memory/startapps/sequence", _show_cb, NULL) < 0) + if (vconf_notify_key_changed(VCONFKEY_STARTER_SEQUENCE, _show_cb, NULL) < 0) _E("Failed to add callback for show event"); _pkg_changed(NULL, NULL); // THIS ROUTINE IS FOR SAT. - vconf_set_int("memory/menu-screen/is_menu_screen_done", 1); + vconf_set_int(VCONFKEY_IDLE_SCREEN_LAUNCHED, VCONFKEY_IDLE_SCREEN_LAUNCHED_TRUE); +} + + + +static void power_off_cb(void *data) +{ + _D("heynoti power off\n"); + s_info.power_off = 1; } @@ -250,11 +274,21 @@ int elm_main(int argc, char *argv[]) { FILE *fp; int fd; + int ret; elm_init(argc, argv); + fd = heynoti_init(); + if (fd < 0) + fprintf(stderr, "heynoti_init\n"); + + ret = heynoti_subscribe(fd, "power_off_start", power_off_cb, NULL); + if (ret < 0) + fprintf(stderr, "heynoti_subscribe\n"); - system("/usr/bin/ail_initdb"); + ret = system("/usr/bin/ail_initdb"); + if (-1 == ret) + _D("Cannot execute ail_initdb"); fp = fopen("/opt/etc/.hib_capturing", "r"); if (!fp) { @@ -269,22 +303,26 @@ int elm_main(int argc, char *argv[]) fprintf(stderr,"Heynoti subscribe is failed\n"); } else { fprintf(stderr,"Heynoti subscribe is done\n"); - } - - if (heynoti_attach_handler(fd)) { - fprintf(stderr,"Heynoti attach handler is failed\n"); - } else { - fprintf(stderr,"Heynoti attach handler is done\n"); - if (vconf_set_int("memory/hibernation/menuscreen_ready", 1)) { - fprintf(stderr, "[MENU_DAEMON]vconf_set_int FAIL\n"); - } else { - fprintf(stderr, "[MENU_DAEMON]vconf_set_int OK\n"); + int fd; + if (mkdir(HIBERNATION_DIR, 0777) != -1) + _D("Make a directory - [%s]", HIBERNATION_DIR); + + fd = creat(HIBERNATION_READY, 0644); + if (fd != -1) { + _D("Create a file for hibernation_ready"); + close(fd); } } + } fclose(fp); } + if (heynoti_attach_handler(fd)) + fprintf(stderr,"Heynoti attach handler is failed\n"); + else + fprintf(stderr,"Heynoti attach handler is done\n"); + elm_run(); destroy_key_window(); elm_exit();