summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKim Kibum <kb0929.kim@samsung.com>2012-06-08 14:54:06 +0900
committerKim Kibum <kb0929.kim@samsung.com>2012-06-08 14:54:06 +0900
commitf49ccb71d7a62ec2d8743bfcf9fbe6c7f40b2aaf (patch)
tree4d172cef6094b9c58ad806d6099983259d7cd1d9
parent51c6a1be576b2bf51544a96c6f43f7a73659b446 (diff)
downloadmenu-daemon-f49ccb71d7a62ec2d8743bfcf9fbe6c7f40b2aaf.tar.gz
menu-daemon-f49ccb71d7a62ec2d8743bfcf9fbe6c7f40b2aaf.tar.bz2
menu-daemon-f49ccb71d7a62ec2d8743bfcf9fbe6c7f40b2aaf.zip
apply FSL(Flora Software License)
-rwxr-xr-xCMakeLists.txt55
-rw-r--r--LICENSE75
-rw-r--r--NOTICE0
-rw-r--r--data/CMakeLists.txt7
-rwxr-xr-xdata/menudaemon3
-rwxr-xr-xdata/menudaemon.fast2
-rw-r--r--debian/changelog8
-rw-r--r--debian/compat1
-rwxr-xr-xdebian/control19
-rw-r--r--debian/copyright0
-rw-r--r--debian/jobs0
-rw-r--r--debian/menu-daemon.install.in2
-rwxr-xr-xdebian/menu-daemon.postinst13
-rwxr-xr-xdebian/rules133
-rw-r--r--include/desktop_to_db.h73
-rw-r--r--include/hw_key.h24
-rw-r--r--include/parser.h30
-rw-r--r--include/pkg_event.h50
-rw-r--r--include/util.h75
-rw-r--r--packaging/menu-daemon.spec65
-rw-r--r--src/hw_key.c386
-rw-r--r--src/menu_daemon.c300
-rw-r--r--src/parser.c95
-rw-r--r--src/pkg_event.c230
24 files changed, 1646 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755
index 0000000..4e47275
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,55 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(menu-daemon C)
+
+SET(PREFIX "/usr")
+SET(EXEC_PREFIX "${PREFIX}/bin")
+SET(LIBDIR "${PREFIX}/lib")
+SET(CONFDIR "/etc")
+SET(VERSION 0.1.0)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+ elementary
+ heynoti
+ elementary
+ aul
+ vconf
+ ecore
+ evas
+ ecore-evas
+ eet
+ x11
+ dlog
+ db-util
+ ecore-x
+ utilX
+ ecore-input
+ ecore-file
+ syspopup-caller
+ ail
+ eina
+)
+
+
+ADD_DEFINITIONS("-DLOG_TAG=\"${PROJECT_NAME}\"")
+
+FOREACH (flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+ADD_DEFINITIONS(${EXTRA_CFLAGS})
+ADD_EXECUTABLE(${PROJECT_NAME}
+ src/hw_key.c
+ src/parser.c
+ src/pkg_event.c
+ src/menu_daemon.c
+)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${EXEC_PREFIX})
+
+ADD_SUBDIRECTORY(data)
+
+
+
+# End of a file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..7ccb5b5
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,75 @@
+Flora License
+
+Version 1.0, May, 2012
+
+http://www.tizenopensource.org/license
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
+
+"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
+
+"Tizen Certified Platform" shall mean a software platform that complies with the standards set forth in the Compatibility Definition Document and passes the Compatibility Test Suite as defined from time to time by the Tizen Technical Steering Group and certified by the Tizen Association or its designated agent.
+
+2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work solely as incorporated into a Tizen Certified Platform, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work solely as incorporated into a Tizen Certified Platform to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof pursuant to the copyright license above, in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
+
+ 1. You must give any other recipients of the Work or Derivative Works a copy of this License; and
+
+ 2. You must cause any modified files to carry prominent notices stating that You changed the files; and
+
+ 3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
+
+ 4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Flora License to your work
+
+To apply the Flora License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+
+ 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.
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/NOTICE
diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt
new file mode 100644
index 0000000..a649cde
--- /dev/null
+++ b/data/CMakeLists.txt
@@ -0,0 +1,7 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+# Install
+INSTALL(FILES menudaemon DESTINATION ${CONFDIR}/init.d)
+INSTALL(FILES menudaemon.fast DESTINATION ${CONFDIR}/init.d)
+
+#End of a file
diff --git a/data/menudaemon b/data/menudaemon
new file mode 100755
index 0000000..536cf12
--- /dev/null
+++ b/data/menudaemon
@@ -0,0 +1,3 @@
+#!/bin/sh
+/usr/bin/menu-daemon &
+sleep 9
diff --git a/data/menudaemon.fast b/data/menudaemon.fast
new file mode 100755
index 0000000..4d16383
--- /dev/null
+++ b/data/menudaemon.fast
@@ -0,0 +1,2 @@
+#!/bin/sh
+/usr/bin/menu-daemon &
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..8f62a2f
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,8 @@
+menu-daemon (0.2.41) unstable; urgency=low
+
+ * Git: shared1/pkgs/m/menu-daemon
+ * Tag: menu-daemon_0.2.41
+
+ * [Modify] Copyright
+
+ -- Jin Yoon <jinny.yoon@samsung.com> Wed, 22 Feb 2012 15:14:00 +0900
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..7ed6ff8
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100755
index 0000000..7d2b2eb
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,19 @@
+Source: menu-daemon
+Section: utils
+Priority: extra
+Maintainer: Jin Yoon <jinny.yoon@samsung.com>, Youngjoo Park <yjoo93.park@samsung.com>
+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
+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
+Description: menu-daemon (Grab H/W key, Package manifest file parsing)
+
+Package: menu-daemon-dbg
+Section: debug
+Architecture: any
+Depends: menu-daemon (= ${Source-Version})
+Description: menu-ademon (Grab H/W key, Package manifest file parsing) (unstripped)
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/debian/copyright
diff --git a/debian/jobs b/debian/jobs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/debian/jobs
diff --git a/debian/menu-daemon.install.in b/debian/menu-daemon.install.in
new file mode 100644
index 0000000..bb3051a
--- /dev/null
+++ b/debian/menu-daemon.install.in
@@ -0,0 +1,2 @@
+/etc/init.d/*
+/usr/bin/*
diff --git a/debian/menu-daemon.postinst b/debian/menu-daemon.postinst
new file mode 100755
index 0000000..f0970fd
--- /dev/null
+++ b/debian/menu-daemon.postinst
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+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
+}
+
+vconf_init
+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
+
+# End of a file
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..62ff850
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,133 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+CFLAGS += -Wall -Werror -fpie
+CXXFLAGS += -Wall -Werror -fpie
+LDFLAGS ?=
+PREFIX ?= /usr
+DATADIR ?= /opt
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+ CXXFLAGS += -O0
+else
+ CFLAGS += -O2
+ CXXFLAGS += -O2
+endif
+
+ifneq (,$(findstring arm,$(DEB_HOST_ARCH)))
+ export ARCH = arm
+else
+ export ARCH = i686
+endif
+
+LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--hash-style=both -Wl,--as-needed
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+ # Add here commands to configure the package.
+ CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" cmake . -DCMAKE_INSTALL_PREFIX=$(PREFIX)
+
+ touch configure-stamp
+
+build: build-stamp
+
+build-stamp: configure-stamp
+ dh_testdir
+
+ # Add here commands to compile the package.
+ $(MAKE)
+ #docbook-to-man debian/wavplayer.sgml > wavplayer.1
+
+ for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+ cat $$f > $${f%.in}; \
+ sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
+ sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
+ done
+
+
+ touch $@
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp configure-stamp
+
+ # Add here commands to clean up after the build process.
+ -$(MAKE) clean
+ rm -rf CMakeCache.txt
+ rm -rf CMakeFiles
+ rm -rf cmake_install.cmake
+ rm -rf Makefile
+ rm -rf install_manifest.txt
+
+ rm -rf data/CMakeCache.txt
+ rm -rf data/CMakeFiles
+ rm -rf data/cmake_install.cmake
+ rm -rf data/install_manifest.txt
+ rm -rf data/Makefile
+
+ rm -rf data/*.edj
+
+ for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+ rm -f $${f%.in}; \
+ done
+
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ # Add here commands to install the package into debian/wavplayer.
+ $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+# dh_installchangelogs
+# dh_installdocs
+# dh_installexamples
+ dh_install --sourcedir=debian/tmp
+# dh_installmenu
+# dh_installdebconf
+# dh_installlogrotate
+# dh_installemacsen
+# dh_installpam
+# dh_installmime
+# dh_python
+# dh_installinit
+# dh_installcron
+# dh_installinfo
+# dh_installman
+ dh_link
+ dh_strip --dbg-package=menu-daemon-dbg
+ dh_compress
+ dh_fixperms
+# dh_perl
+ dh_makeshlibs
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/include/desktop_to_db.h b/include/desktop_to_db.h
new file mode 100644
index 0000000..1494272
--- /dev/null
+++ b/include/desktop_to_db.h
@@ -0,0 +1,73 @@
+ /*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+
+
+#define APP_INFO_DB_FILE "/opt/dbspace/.app_info.db"
+
+#define DESKTOP_FILE_PATH "/usr/share/install-info/application"
+#define ORDER_FILE_PATH "/usr/share/install-info/.order/order"
+
+#define BUF_SIZE 40960
+#define APPS_PER_PAGE 19
+
+typedef struct
+{
+ /* Origin field */
+ char* package;
+ char* exec;
+ char* name;
+ char* type;
+ char* icon;
+ char* categories;
+ char* version;
+ char* mimetype;
+ int nodisplay;
+
+ /* SLP field */
+ char* x_slp_service;
+ char* x_slp_packagetype;
+ char* x_slp_packagecategories;
+ char* x_slp_uri;
+ int x_slp_taskmanage;
+ int x_slp_multiple;
+ int x_slp_removable;
+ int x_slp_baselayoutwidth;
+ int x_slp_baselayoutheight;
+ int x_slp_ishorizontalscale;
+ int x_slp_eventnotificationsetting;
+
+ /* Invisible fields in the desktop file */
+ char* desktop;
+ int activate;
+} app_info_t;
+
+
+
+#if !defined(_MENU_COMPAT_H)
+bool desktop_add(char* desktop, void* data);
+bool desktop_update(char* desktop, void* data);
+bool desktop_remove(char* desktop, void* data);
+bool desktop_read(char *desktop, void *data);
+void load_directory(const char *directory, int update_all);
+char* desktop_to_pkgname(const char* desktop);
+#endif
+
+
+
+
+
+// End of a file
diff --git a/include/hw_key.h b/include/hw_key.h
new file mode 100644
index 0000000..594e810
--- /dev/null
+++ b/include/hw_key.h
@@ -0,0 +1,24 @@
+ /*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+
+
+extern void destroy_key_window(void);
+extern void create_key_window(void);
+
+
+
+// End of a file
diff --git a/include/parser.h b/include/parser.h
new file mode 100644
index 0000000..2dbfc56
--- /dev/null
+++ b/include/parser.h
@@ -0,0 +1,30 @@
+ /*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+
+
+#define CONF_FILE "/usr/share/install-info/desktop.conf"
+
+struct inotify_path
+{
+ int wd;
+ char *path;
+};
+
+int conf_search(struct inotify_path* paths, int number);
+
+
+// End of a file
diff --git a/include/pkg_event.h b/include/pkg_event.h
new file mode 100644
index 0000000..1cef8fb
--- /dev/null
+++ b/include/pkg_event.h
@@ -0,0 +1,50 @@
+ /*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+
+
+#ifndef __NOTIFIER_H__
+#define __NOTIFIER_H__
+#include <stdbool.h>
+
+#if !defined(PUBLIC)
+#define PUBLIC __attribute__((visibility("default"))) /**<All other from outside modules can access this typed API */
+#endif
+
+#if !defined(PROTECTED)
+#define PROTECTED __attribute__((visibility("hidden"))) /**<All other from outside modules can not access this directly */
+#endif
+
+#if !defined(PRIVATE)
+#define PRIVATE __attribute__((visibility("internal"))) /**<Does not export APIs to the other. only can be accessed in this module */
+#endif
+
+
+struct desktop_notifier {
+ struct appdata *ad;
+ struct menu_module *this_module;
+ int ifd;
+ Ecore_Fd_Handler *handler;
+};
+
+
+PRIVATE void pkg_event_init(void);
+PRIVATE void pkg_event_fini(void);
+
+PRIVATE int register_pkg_event_handler(const char *event_name, int (*event_cb)(void *ai_name, void *data, int visible), void *cb_data);
+PRIVATE int unregister_pkg_event_handler(const char *event_name, int (*event_cb)(void *ai_name, void *data, int visible));
+
+#endif
diff --git a/include/util.h b/include/util.h
new file mode 100644
index 0000000..557daaa
--- /dev/null
+++ b/include/util.h
@@ -0,0 +1,75 @@
+ /*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+
+
+#ifndef __MENU_DAEMON_UTIL_H__
+#define __MENU_DAEMON_UTIL_H__
+#include <dlog.h>
+
+#define HOME_SCREEN_PKG_NAME "org.tizen.menu-screen"
+#define MENU_PKG_VCONF_KEY "db/menuscreen/pkgname"
+#define CONF_PATH_NUMBER 1024
+
+/* Log */
+#if !defined(_W)
+#define _W(fmt, arg...) LOGW("[%s:%d] "fmt"\n", __func__, __LINE__, ##arg)
+#endif
+
+#if !defined(_D)
+#define _D(fmt, arg...) LOGD("[%s:%d] "fmt"\n", __func__, __LINE__, ##arg)
+#endif
+
+#if !defined(_E)
+#define _E(fmt, arg...) LOGE("[%s:%d] "fmt"\n", __func__, __LINE__, ##arg)
+#endif
+
+#define retv_if(expr, val) do { \
+ if(expr) { \
+ _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+ return (val); \
+ } \
+} while (0)
+
+#define ret_if(expr) do { \
+ if(expr) { \
+ _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+ return; \
+ } \
+} while (0)
+
+#define goto_if(expr, val) do { \
+ if(expr) { \
+ _E("(%s) -> goto", #expr); \
+ goto val; \
+ } \
+} while (0)
+
+#define break_if(expr) { \
+ if(expr) { \
+ _E("(%s) -> break", #expr); \
+ break; \
+ } \
+}
+
+#define continue_if(expr) { \
+ if(expr) { \
+ _E("(%s) -> continue", #expr); \
+ continue; \
+ } \
+}
+
+#endif /* __MENU_DAEMON_UTIL_H__ */
diff --git a/packaging/menu-daemon.spec b/packaging/menu-daemon.spec
new file mode 100644
index 0000000..d262f57
--- /dev/null
+++ b/packaging/menu-daemon.spec
@@ -0,0 +1,65 @@
+%define _optdir /opt
+%define _appdir %{_optdir}/apps
+%define _opt_datadir %{_optdir}/share
+
+Name: menu-daemon
+Summary: Menu daemon
+Version: 0.2.41
+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: cmake
+BuildRequires: edje-bin
+BuildRequires: embryo-bin
+BuildRequires: eet-bin
+BuildRequires: gettext-tools
+Requires(post): /usr/bin/vconftool
+
+%description
+menu-daemon (Grab H/W key, Package manifest file parsing)
+
+%prep
+%setup -q
+
+%build
+export LDFLAGS+="-Wl,--rpath=%{_prefix}/lib -Wl,--hash-style=both -Wl,--as-needed"
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+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
+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
+%{_sysconfdir}/init.d/menudaemon
+%{_sysconfdir}/init.d/menudaemon.fast
+%{_bindir}/menu-daemon
+
diff --git a/src/hw_key.c b/src/hw_key.c
new file mode 100644
index 0000000..b5470b3
--- /dev/null
+++ b/src/hw_key.c
@@ -0,0 +1,386 @@
+ /*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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 <ail.h>
+#include <bundle.h>
+#include <Elementary.h>
+#include <Ecore_X.h>
+#include <Ecore_Input.h>
+#include <syspopup_caller.h>
+#include <utilX.h>
+#include <vconf.h>
+
+#include "hw_key.h"
+#include "util.h"
+
+#define TASKMGR_PKG_NAME "org.tizen.taskmgr"
+#define CAMERA_PKG_NAME "org.tizen.camera-app"
+#define CALLLOG_PKG_NAME "org.tizen.calllog"
+#define SEARCH_PKG_NAME "org.tizen.smartsearch"
+#define MUSIC_PLAYER_PKG_NAME "org.tizen.music-player"
+
+
+
+static struct {
+ Ecore_X_Window win;
+ Ecore_Event_Handler *key_up;
+ Ecore_Event_Handler *key_down;
+ Ecore_Timer *long_press;
+ Ecore_Timer *single_timer;
+ Ecore_Timer *volume_up_long_press;
+ Ecore_Timer *volume_down_long_press;
+ Eina_Bool cancel;
+} key_info = {
+ .win = 0x0,
+ .key_up = NULL,
+ .key_down = NULL,
+ .long_press = NULL,
+ .single_timer = NULL,
+ .volume_up_long_press = NULL,
+ .volume_down_long_press = NULL,
+ .cancel = EINA_FALSE,
+};
+
+
+
+static Eina_Bool _launch_taskmgr_cb(void* data)
+{
+ _D("Launch TASKMGR");
+
+ key_info.long_press = NULL;
+
+ if (aul_open_app(TASKMGR_PKG_NAME) < 0)
+ _E("Failed to launch the taskmgr");
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+
+static Eina_Bool _launch_home_screen(void *data)
+{
+ char *package;
+
+ syspopup_destroy_all();
+ key_info.single_timer = NULL;
+
+ package = vconf_get_str(MENU_PKG_VCONF_KEY);
+ if (package) {
+ int ret;
+
+ ret = aul_open_app(package);
+ if (ret < 0) {
+ if (!strcmp(package, HOME_SCREEN_PKG_NAME)) {
+ _E("Default homescreen is not able to launch");
+ } else {
+ _E("Package %s is not exists, rollback to default home", package);
+ ret = aul_open_app(HOME_SCREEN_PKG_NAME);
+ if (ret < 0)
+ _E("Failed to launch default home");
+ }
+ }
+
+ free(package);
+ } else {
+ if (aul_open_app(HOME_SCREEN_PKG_NAME) < 0)
+ _E("Cannot open default home");
+ }
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+
+inline static void _launch_search(void)
+{
+ _D("Launch smartsearch");
+ if (aul_open_app(SEARCH_PKG_NAME) < 0)
+ _E("Cannot open Smart-search");
+
+ return;
+}
+
+
+
+inline static int _release_home_key(void)
+{
+ retv_if(NULL == key_info.long_press, EXIT_SUCCESS);
+ ecore_timer_del(key_info.long_press);
+ key_info.long_press = NULL;
+
+ if (NULL == key_info.single_timer) {
+ key_info.single_timer = ecore_timer_add(0.3, _launch_home_screen, NULL);
+ return EXIT_SUCCESS;
+ }
+ ecore_timer_del(key_info.single_timer);
+ key_info.single_timer = NULL;
+
+ syspopup_destroy_all();
+ _launch_search();
+
+ return EXIT_SUCCESS;
+}
+
+
+
+inline static void _release_multimedia_key(const char *value)
+{
+ bundle *b;
+ int ret;
+
+ _D("Multimedia key is released with %s", value);
+ ret_if(NULL == value);
+
+ b = bundle_create();
+ if (!b) {
+ _E("Cannot create bundle");
+ return;
+ }
+
+ bundle_add(b, "multimedia_key", value);
+ ret = aul_launch_app(MUSIC_PLAYER_PKG_NAME, b);
+ bundle_free(b);
+
+ if (ret < 0)
+ _E("Failed to launch the running apps, ret : %d", ret);
+}
+
+
+
+static Eina_Bool _key_release_cb(void *data, int type, void *event)
+{
+ Evas_Event_Key_Up *ev = event;
+
+ _D("Released");
+
+ if (!ev) {
+ _D("Invalid event object");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if (!strcmp(ev->keyname, KEY_END)) {
+ } else if (!strcmp(ev->keyname, KEY_CAMERA)) {
+ } else if (!strcmp(ev->keyname, KEY_SEND)) {
+ } else if (!strcmp(ev->keyname, KEY_SELECT)) {
+ _release_home_key();
+ } else if (!strcmp(ev->keyname, KEY_PAUSE)) {
+ } else if (!strcmp(ev->keyname, KEY_VOLUMEDOWN)) {
+ if (key_info.volume_down_long_press) {
+ 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");
+ return ECORE_CALLBACK_RENEW;
+ }
+ if (syspopup_launch("volume", NULL) < 0)
+ _D("Failed to launch the volume popup");
+ } else if (!strcmp(ev->keyname, KEY_VOLUMEUP)) {
+ if (key_info.volume_up_long_press) {
+ ecore_timer_del(key_info.volume_up_long_press);
+ key_info.volume_up_long_press = NULL;
+ }
+ if (syspopup_launch("volume", NULL) < 0)
+ _D("Failed to launch the volume popup");
+ } else if (!strcmp(ev->keyname, KEY_CANCEL)) {
+ _D("CANCEL Key is released");
+ key_info.cancel = EINA_FALSE;
+ } else if (!strcmp(ev->keyname, KEY_PAUSECD)) {
+ _release_multimedia_key("KEY_PAUSECD");
+ } else if (!strcmp(ev->keyname, KEY_PLAYCD)) {
+ _release_multimedia_key("KEY_PLAYCD");
+ } else if (!strcmp(ev->keyname, KEY_MEDIA)) {
+ _release_multimedia_key("KEY_PLAYCD");
+ }
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+
+
+static Eina_Bool _volume_up_cb(void* data)
+{
+ bundle *b;
+
+ _D("Long press : Volume up");
+ key_info.volume_up_long_press = NULL;
+
+ b = bundle_create();
+ if (!b) {
+ _E("Cannot create bundle");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ bundle_add(b, "LONG_PRESS", "VOLUME_UP");
+ if (syspopup_launch("volume", b) < 0)
+ _D("Failed to launch the volume popup");
+ bundle_free(b);
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+
+static Eina_Bool _volume_down_cb(void* data)
+{
+ bundle *b;
+
+ _D("Long press : Volume down");
+ key_info.volume_down_long_press = NULL;
+
+ if (key_info.cancel == EINA_TRUE)
+ return ECORE_CALLBACK_CANCEL;
+
+ b = bundle_create();
+ if (!b) {
+ _E("Cannot create bundle");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ bundle_add(b, "LONG_PRESS", "VOLUME_DOWN");
+ if (syspopup_launch("volume", b) < 0)
+ _D("Failed to launch the volume popup");
+ bundle_free(b);
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+
+static Eina_Bool _key_press_cb(void *data, int type, void *event)
+{
+ Evas_Event_Key_Down *ev = event;
+
+ _D("Pressed");
+
+ if (!ev) {
+ _D("Invalid event object");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if (!strcmp(ev->keyname, KEY_SEND)) {
+ _D("Launch calllog");
+ if (aul_open_app(CALLLOG_PKG_NAME) < 0)
+ _E("Failed to launch %s", CALLLOG_PKG_NAME);
+ } else if(!strcmp(ev->keyname, KEY_CAMERA)) {
+ _D("Launch camera");
+ if (aul_open_app(CAMERA_PKG_NAME) < 0)
+ _E("Failed to launch %s", CAMERA_PKG_NAME);
+ } else if (!strcmp(ev->keyname, KEY_VOLUMEDOWN)) {
+ key_info.cancel = EINA_FALSE;
+ if (key_info.volume_down_long_press) {
+ ecore_timer_del(key_info.volume_down_long_press);
+ key_info.volume_down_long_press = NULL;
+ }
+ key_info.volume_down_long_press = ecore_timer_add(0.5, _volume_down_cb, NULL);
+ if (NULL == key_info.volume_down_long_press)
+ _E("Cannot add timer for volume_down_cb");
+ } else if (!strcmp(ev->keyname, KEY_VOLUMEUP)) {
+ if (key_info.volume_up_long_press) {
+ ecore_timer_del(key_info.volume_up_long_press);
+ key_info.volume_up_long_press = NULL;
+ }
+ key_info.volume_up_long_press = ecore_timer_add(0.5, _volume_up_cb, NULL);
+ if (NULL == key_info.volume_up_long_press)
+ _E("Cannot add timer for volume_up_cb");
+ } else if (!strcmp(ev->keyname, KEY_SELECT)) {
+ if (key_info.long_press) {
+ ecore_timer_del(key_info.long_press);
+ key_info.long_press = NULL;
+ }
+
+ key_info.long_press = ecore_timer_add(0.5, _launch_taskmgr_cb, NULL);
+ if (!key_info.long_press)
+ _E("Failed to add timer for long press detection");
+ } else if (!strcmp(ev->keyname, KEY_CANCEL)) {
+ _D("Cancel button is pressed");
+ if (key_info.volume_down_long_press) {
+ ecore_timer_del(key_info.volume_down_long_press);
+ key_info.volume_down_long_press = NULL;
+ }
+ key_info.cancel = EINA_TRUE;
+ _D("Cancel button is pressed");
+ } else if (!strcmp(ev->keyname, KEY_PAUSECD) || !strcmp(ev->keyname, KEY_PLAYCD)) {
+ _D("Multimedia key is pressed");
+ } else if (!strcmp(ev->keyname, KEY_MEDIA)) {
+ _D("Media key is pressed");
+ }
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+
+
+void create_key_window(void)
+{
+ key_info.win = ecore_x_window_input_new(0, 0, 0, 1, 1);
+ if (!key_info.win) {
+ _D("Failed to create hidden window");
+ return;
+ }
+
+ ecore_x_icccm_title_set(key_info.win, "menudaemon,key,receiver");
+ ecore_x_netwm_name_set(key_info.win, "menudaemon,key,receiver");
+ ecore_x_netwm_pid_set(key_info.win, getpid());
+
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_SELECT, SHARED_GRAB);
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_VOLUMEDOWN, SHARED_GRAB);
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_VOLUMEUP, SHARED_GRAB);
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_CAMERA, SHARED_GRAB);
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_PAUSECD, SHARED_GRAB);
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_PLAYCD, SHARED_GRAB);
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_MEDIA, SHARED_GRAB);
+
+ key_info.key_up = ecore_event_handler_add(ECORE_EVENT_KEY_UP, _key_release_cb, NULL);
+ if (!key_info.key_up)
+ _D("Failed to register a key up event handler");
+
+ 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");
+}
+
+
+
+void destroy_key_window(void)
+{
+ utilx_ungrab_key(ecore_x_display_get(), key_info.win, KEY_SELECT);
+ utilx_ungrab_key(ecore_x_display_get(), key_info.win, KEY_VOLUMEDOWN);
+ utilx_ungrab_key(ecore_x_display_get(), key_info.win, KEY_VOLUMEUP);
+ utilx_ungrab_key(ecore_x_display_get(), key_info.win, KEY_CAMERA);
+ utilx_ungrab_key(ecore_x_display_get(), key_info.win, KEY_PAUSECD);
+ utilx_ungrab_key(ecore_x_display_get(), key_info.win, KEY_PLAYCD);
+ utilx_ungrab_key(ecore_x_display_get(), key_info.win, KEY_MEDIA);
+
+ if (key_info.key_up) {
+ ecore_event_handler_del(key_info.key_up);
+ key_info.key_up = NULL;
+ }
+
+ if (key_info.key_down) {
+ ecore_event_handler_del(key_info.key_down);
+ key_info.key_down = NULL;
+ }
+
+ ecore_x_window_delete_request_send(key_info.win);
+ key_info.win = 0x0;
+}
+
+
+
+// End of a file
diff --git a/src/menu_daemon.c b/src/menu_daemon.c
new file mode 100644
index 0000000..4b4e2cf
--- /dev/null
+++ b/src/menu_daemon.c
@@ -0,0 +1,300 @@
+ /*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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 <ail.h>
+#include <aul.h>
+#include <db-util.h>
+#include <Elementary.h>
+#include <heynoti.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <vconf.h>
+#include <errno.h>
+
+#include "desktop_to_db.h"
+#include "hw_key.h"
+#include "parser.h"
+#include "pkg_event.h"
+#include "util.h"
+
+
+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 prototype of the "hidden API of AUL"
+extern int aul_listen_app_dead_signal(int (*func)(int signal, void *data), void *data);
+
+
+
+static struct info {
+ pid_t pid;
+} s_info = {
+ .pid = -1,
+};
+
+
+
+static inline char *_get_pkgname(keynode_t *node)
+{
+ char *pkgname;
+
+ if (node)
+ pkgname = vconf_keynode_get_str(node);
+ else
+ pkgname = vconf_get_str(MENU_PKG_VCONF_KEY);
+
+ if (!pkgname) {
+ _E("Cannot get pkgname from vconf.");
+ pkgname = strdup(HOME_SCREEN_PKG_NAME);
+ if (!pkgname)
+ _E("strdup error for pkgname, %s", strerror(errno));
+ }
+
+ return pkgname;
+}
+
+
+
+static inline void _open_homescreen(const char *pkgname)
+{
+ int ret;
+ char *homescreen = (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)) {
+ ret = aul_open_app(HOME_SCREEN_PKG_NAME);
+ if (ret < 0) {
+ _E("Failed to open a default home, %s", HOME_SCREEN_PKG_NAME);
+ } else {
+ homescreen = HOME_SCREEN_PKG_NAME;
+ }
+ }
+
+ s_info.pid = ret;
+}
+
+
+
+static void _show_cb(keynode_t* node, void *data)
+{
+ int seq;
+ char *pkgname;
+
+ _D("[MENU_DAEMON] _show_cb is invoked");
+
+ pkgname = _get_pkgname(NULL);
+ if (!pkgname)
+ return;
+
+ if (node) {
+ seq = vconf_keynode_get_int(node);
+ } else {
+ if (vconf_get_int("memory/startapps/sequence", &seq) < 0) {
+ _E("Failed to get sequence info");
+ free(pkgname);
+ return;
+ }
+ }
+
+ switch (seq) {
+ case 0:
+ if (s_info.pid > 0) {
+ int pid;
+ _D("pid[%d] is terminated.", s_info.pid);
+
+ pid = s_info.pid;
+ s_info.pid = -1; /* to freeze the dead_cb */
+
+ if (aul_terminate_pid(pid) != AUL_R_OK)
+ _E("Failed to terminate %d", s_info.pid);
+ }
+ break;
+ case 1:
+ _open_homescreen(pkgname);
+ break;
+ default:
+ _E("False sequence [%d]", seq);
+ break;
+ }
+
+ free(pkgname);
+ return;
+
+}
+
+
+
+static void _pkg_changed(keynode_t* node, void *data)
+{
+ char *pkgname;
+ int seq;
+
+ if (vconf_get_int("memory/startapps/sequence", &seq) < 0) {
+ _E("Do nothing, there is no sequence info yet");
+ return;
+ }
+
+ if (seq < 1) {
+ _E("Sequence is not ready yet, do nothing");
+ return;
+ }
+
+ _D("_pkg_changed is invoked");
+
+ pkgname = _get_pkgname(node);
+ if (!pkgname)
+ return;
+
+ _D("pkg_name : %s", pkgname);
+
+ if (s_info.pid > 0) {
+ char old_pkgname[256];
+
+ if (aul_app_get_pkgname_bypid(s_info.pid, old_pkgname, sizeof(old_pkgname)) == AUL_R_OK) {
+ if (!strcmp(pkgname, old_pkgname)) {
+ _D("Package is changed but same package is selected");
+ free(pkgname);
+ return;
+ }
+ }
+
+ if (aul_terminate_pid(s_info.pid) != AUL_R_OK)
+ _D("Failed to terminate pid %d", s_info.pid);
+ } else {
+ /* If there is no running home */
+ _open_homescreen(pkgname);
+ }
+
+ /* NOTE: Dead callback will catch the termination of a current menuscreen
+ * _open_homescreen(pkgname);
+ */
+ free(pkgname);
+ return;
+}
+
+
+
+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);
+ return 0;
+ }
+
+ pkgname = _get_pkgname(NULL);
+ if (!pkgname)
+ return 0;
+
+ _D("pkg_name : %s", pkgname);
+
+ /* Relaunch */
+ _open_homescreen(pkgname);
+ free(pkgname);
+ return 0;
+}
+
+
+
+static void _hibernation_preleave_cb(void *data)
+{
+ _D( "[MENU_DAEMON]_hibernation_preleave_cb is invoked");
+
+ aul_launch_init(NULL,NULL);
+ aul_listen_app_dead_signal(_dead_cb, NULL);
+
+ create_key_window();
+ pkg_event_init();
+
+ 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)
+ _E("Failed to add callback for package change event");
+
+ if (vconf_notify_key_changed("memory/startapps/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);
+}
+
+
+
+int elm_main(int argc, char *argv[])
+{
+ FILE *fp;
+ int fd;
+
+ elm_init(argc, argv);
+ fd = heynoti_init();
+
+ system("/usr/bin/ail_initdb");
+
+ fp = fopen("/opt/etc/.hib_capturing", "r");
+ if (!fp) {
+ fprintf(stderr, "[MENU_DAEMON]hib_capturing file is not found\n");
+ _hibernation_preleave_cb(NULL);
+ } else {
+ fprintf(stderr,"\n\n\n Menu Daemon enter %s hey noti init\n", __func__);
+ if (fd < 0) {
+ fprintf(stderr, "[MENU_DAEMON]\n\n\n Hey Noti Init Failed\n");
+ } else {
+ if (heynoti_subscribe(fd, "HIBERNATION_PRELEAVE", _hibernation_preleave_cb, NULL)) {
+ 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");
+ }
+ }
+ }
+ fclose(fp);
+ }
+
+ elm_run();
+ destroy_key_window();
+ elm_exit();
+ return 0;
+}
+
+
+
+ELM_MAIN()
+
+
+
+// End of a file
diff --git a/src/parser.c b/src/parser.c
new file mode 100644
index 0000000..49d4deb
--- /dev/null
+++ b/src/parser.c
@@ -0,0 +1,95 @@
+ /*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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 <ctype.h>
+#include <Elementary.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "parser.h"
+#include "util.h"
+
+
+
+static inline char *_ltrim(char *str)
+{
+ retv_if(NULL == str, NULL);
+ while (*str && (*str == ' ' || *str == '\t' || *str == '\n')) str ++;
+ return str;
+}
+
+
+
+static inline int _rtrim(char *str)
+{
+ int len;
+
+ retv_if(NULL == str, 0);
+
+ len = strlen(str);
+ while (--len >= 0 && (str[len] == ' ' || str[len] == '\n' || str[len] == '\t')) {
+ str[len] = '\0';
+ }
+
+ return len;
+}
+
+
+
+int conf_search(struct inotify_path* paths, int number)
+{
+ char *line = NULL;
+ FILE *fp;
+ size_t size = 0;
+ ssize_t read;
+ int i = 0;
+
+ fp = fopen(CONF_FILE, "r");
+ if (NULL == fp) {
+ _E(CONF_FILE);
+ return -EFAULT;
+ }
+
+ while ((read = getline(&line, &size, fp)) != -1 && i < CONF_PATH_NUMBER - 1) {
+ char *begin;
+
+ if (size <= 0) break;
+
+ begin = _ltrim(line);
+ _rtrim(line);
+
+ if (*begin == '#' || *begin == '\0') continue;
+
+ paths[i].path = strdup(begin);
+ i++;
+ }
+
+ if (line) free(line);
+ paths[i].path = NULL;
+ fclose(fp);
+
+ return EXIT_SUCCESS;
+}
+// END
diff --git a/src/pkg_event.c b/src/pkg_event.c
new file mode 100644
index 0000000..bae1df0
--- /dev/null
+++ b/src/pkg_event.c
@@ -0,0 +1,230 @@
+ /*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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 <ail.h>
+#include <errno.h>
+#include <Elementary.h>
+#include <Ecore.h>
+#include <Ecore_File.h>
+#include <stdio.h>
+#include <sys/inotify.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <stdbool.h>
+#include <unistd.h>
+#include <vconf.h>
+
+#include "desktop_to_db.h"
+#include "parser.h"
+#include "pkg_event.h"
+#include "util.h"
+
+
+#define BUFSZE 1024
+
+
+extern int errno;
+
+struct desktop_notifier s_desktop_notifier = {
+ .ad = NULL,
+ .handler = NULL,
+ .this_module = NULL,
+};
+
+
+struct cb_item {
+ void *data;
+ int (*event_cb)(void *ai_name, void *data, int visible);
+};
+
+
+
+struct inotify_path paths[CONF_PATH_NUMBER];
+
+
+static Eina_Bool
+directory_notify(void* data, Ecore_Fd_Handler* fd_handler)
+{
+ char *buf;
+ ssize_t read_size, len, i = 0;
+ int fd;
+
+ fd = ecore_main_fd_handler_fd_get(fd_handler);
+ _D("There are some modification, ifd [%d]", fd);
+
+ if (ioctl(fd, FIONREAD, &read_size) < 0) {
+ _E("Failed to get q size");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (read_size <= 0) {
+ _E("Buffer is not ready!!!");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ buf = malloc(read_size);
+ if (!buf) {
+ _E("Failed to allocate heap for event handling");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ len = read(fd, buf, read_size);
+ if (len < 0) {
+ free(buf);
+ // Stop monitoring about this invalid file descriptor
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ while (i < len) {
+ struct inotify_event* event = (struct inotify_event*) &buf[i];
+ char *str_potksed = "potksed.";
+ char *cut;
+ char *package = NULL;
+ ssize_t idx;
+ int nev_name;
+
+ // 1. check the extension of a file
+ nev_name = strlen(event->name) - 1;
+ for (idx = 0; nev_name >= 0 && str_potksed[idx]; idx++) {
+ if (event->name[nev_name] != str_potksed[idx]) {
+ break;
+ }
+ nev_name --;
+ }
+
+ if (str_potksed[idx] != '\0') {
+ _D("This is not a desktop file : %s", event->name);
+ i += sizeof(struct inotify_event) + event->len;
+ continue;
+ }
+
+ package = strdup(event->name);
+ cut = strstr(package, ".desktop");
+ *cut = '\0';
+ _D("Package : %s", package);
+
+ // add & update
+ if (event->mask & IN_CREATE || event->mask & IN_CLOSE_WRITE || event->mask & IN_MOVED_TO) { // for moving
+ ail_appinfo_h ai = NULL;
+ ail_error_e ret;
+
+ ret = ail_package_get_appinfo(package, &ai);
+ if (ai) ail_package_destroy_appinfo(ai);
+
+
+ if (AIL_ERROR_NO_DATA == ret) {
+ if (ail_desktop_add(package) < 0) {
+ _D("Failed to add a new package (%s)", event->name);
+ }
+ } else if (AIL_ERROR_OK == ret) {
+ if (ail_desktop_update(package) < 0) {
+ _D("Failed to add a new package (%s)", event->name);
+ }
+ } else
+ ;
+ // delete
+ } else if (event->mask & IN_DELETE) { // for deleting
+ if (ail_desktop_remove(package) < 0)
+ _D("Failed to remove a package (%s)", event->name);
+ } else {
+ _D("this event is not dealt with inotify");
+ }
+
+ free(package);
+
+ i += sizeof(struct inotify_event) + event->len;
+ }
+
+ free(buf);
+ return ECORE_CALLBACK_RENEW;
+}
+
+
+
+void pkg_event_init()
+{
+ int wd = 0;
+ int i;
+
+ s_desktop_notifier.ifd = inotify_init();
+ if (s_desktop_notifier.ifd == -1) {
+ _E("inotify_init error: %s", strerror(errno));
+ return;
+ }
+
+ conf_search(paths, CONF_PATH_NUMBER);
+
+ for (i = 0; i < CONF_PATH_NUMBER && paths[i].path; i++)
+ {
+ _D("Configuration file for desktop file monitoring [%s] is added", paths[i].path);
+ if (access(paths[i].path, R_OK) != 0)
+ {
+ ecore_file_mkpath(paths[i].path);
+ if (chmod(paths[i].path, 0777) == -1) {
+ _E("cannot chmod %s", paths[i].path);
+ }
+ }
+
+ wd = inotify_add_watch(s_desktop_notifier.ifd, paths[i].path, IN_CREATE | IN_CLOSE_WRITE | IN_MOVED_TO | IN_DELETE);
+ if (wd == -1) {
+ _E("inotify_add_watch error: %s", strerror(errno));
+ close(s_desktop_notifier.ifd);
+ return;
+ }
+
+ paths[i].wd = wd;
+ }
+
+ s_desktop_notifier.handler = ecore_main_fd_handler_add(s_desktop_notifier.ifd, ECORE_FD_READ, directory_notify, NULL, NULL, NULL);
+ if (!s_desktop_notifier.handler) {
+ // TODO: Handles me.. EXCEPTION!!
+ _E("cannot add handler for inotify");
+ }
+}
+
+
+
+void pkg_event_fini(void)
+{
+ register int i;
+
+ if (s_desktop_notifier.handler) {
+ ecore_main_fd_handler_del(s_desktop_notifier.handler);
+ }
+
+ for (i = 0; i < CONF_PATH_NUMBER; i ++) {
+ if (paths[i].wd) {
+ if (inotify_rm_watch(s_desktop_notifier.ifd, paths[i].wd) < 0) {
+ char log[BUFSZE] = {0,};
+ int ret;
+
+ ret = strerror_r(errno, log, sizeof(log));
+ _E("Error: %s", ret == 0? log : "unknown error");
+ }
+ paths[i].wd = 0;
+ }
+ }
+
+ if (s_desktop_notifier.ifd) {
+ close(s_desktop_notifier.ifd);
+ s_desktop_notifier.ifd = 0;
+ }
+}
+
+
+// End of a file