libeventsystem : initail commit 30/40030/1 accepted/tizen_3.0.2015.q2_common tizen_3.0.2015.q2_common accepted/tizen/3.0.2015.q2/common/20150609.181925 accepted/tizen/common/20150609.084322 accepted/tizen/mobile/20150609.085840 accepted/tizen/tv/20150612.003524 accepted/tizen/wearable/20150609.085901 submit/tizen/20150601.084214 submit/tizen/20150602.063407 submit/tizen/20150602.110936 submit/tizen/20150605.114228 submit/tizen_3.0.2015.q2_common/20150609.170642 submit/tizen_tv/20150602.000000 submit/tizen_tv/20150611.000000
authorJiwoong Im <jiwoong.im@samsung.com>
Thu, 28 May 2015 01:45:43 +0000 (10:45 +0900)
committerJiwoong Im <jiwoong.im@samsung.com>
Thu, 28 May 2015 01:45:43 +0000 (10:45 +0900)
This package provides new event-system API.

Event Publication
- Can broadcast the specific event and it’s data to all the listeners.
  (sender/receiver)
On-Event-Launch (service-application only)
- Can launch the dedicated application when the specific event occurs.

JIRA ticket : TC-2473

Change-Id: I1990ed0d028f245c2edfdb540a0641534bdb7398
Signed-off-by: Jiwoong Im <jiwoong.im@samsung.com>
AUTHORS [new file with mode: 0644]
CMakeLists.txt [new file with mode: 0755]
LICENSE [new file with mode: 0644]
eventsystem.manifest.in [new file with mode: 0644]
eventsystem.pc.in [new file with mode: 0644]
include/eventsystem.h [new file with mode: 0755]
include/eventsystem_internal.h [new file with mode: 0644]
packaging/eventsystem.spec [new file with mode: 0755]
src/eventsystem.c [new file with mode: 0755]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..cf4d288
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,2 @@
+Jongmyeong Ko <jongmyeong.ko@samsung.com>
+Jusung Son <jusung07.son@samsung.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..4d0280e
--- /dev/null
@@ -0,0 +1,54 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+PROJECT(eventsystem C)
+
+SET(VERSION 0.0.1)
+SET(VERSION_MAJOR 0)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(LIBDIR "\${prefix}/lib")
+SET(INCLUDEDIR "\${prefix}/include")
+
+set(CMAKE_SKIP_BUILD_RPATH true)
+
+### Local include directories
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src)
+
+### Required packages
+INCLUDE(FindPkgConfig)
+
+pkg_check_modules(libpkgs REQUIRED dlog bundle openssl glib-2.0)
+
+#FIND_LIBRARY(LIB_DL dl)
+
+FOREACH(flag ${libpkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+## Additional flag
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -Wall")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+## Linker flags
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+## build eventsystem library
+add_library(eventsystem SHARED
+               src/eventsystem.c
+               )
+
+#TARGET_LINK_LIBRARIES(eventsystem "-ldl")
+TARGET_LINK_LIBRARIES(eventsystem ${libpkgs_LDFLAGS})
+SET_TARGET_PROPERTIES(eventsystem PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(eventsystem PROPERTIES VERSION ${VERSION})
+
+# pkgconfig file
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/eventsystem.pc.in ${CMAKE_BINARY_DIR}/eventsystem.pc @ONLY)
+configure_file(eventsystem.manifest.in eventsystem.manifest @ONLY)
+
+INSTALL(TARGETS eventsystem DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/eventsystem.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/eventsystem.h DESTINATION include)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/eventsystem_internal.h DESTINATION include)
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..9c13a9b
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,204 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+                                 Apache License\r
+                           Version 2.0, January 2004\r
+                        http://www.apache.org/licenses/\r
+\r
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+   1. Definitions.\r
+\r
+      "License" shall mean the terms and conditions for use, reproduction,\r
+      and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+      "Licensor" shall mean the copyright owner or entity authorized by\r
+      the copyright owner that is granting the License.\r
+\r
+      "Legal Entity" shall mean the union of the acting entity and all\r
+      other entities that control, are controlled by, or are under common\r
+      control with that entity. For the purposes of this definition,\r
+      "control" means (i) the power, direct or indirect, to cause the\r
+      direction or management of such entity, whether by contract or\r
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+      outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+      "You" (or "Your") shall mean an individual or Legal Entity\r
+      exercising permissions granted by this License.\r
+\r
+      "Source" form shall mean the preferred form for making modifications,\r
+      including but not limited to software source code, documentation\r
+      source, and configuration files.\r
+\r
+      "Object" form shall mean any form resulting from mechanical\r
+      transformation or translation of a Source form, including but\r
+      not limited to compiled object code, generated documentation,\r
+      and conversions to other media types.\r
+\r
+      "Work" shall mean the work of authorship, whether in Source or\r
+      Object form, made available under the License, as indicated by a\r
+      copyright notice that is included in or attached to the work\r
+      (an example is provided in the Appendix below).\r
+\r
+      "Derivative Works" shall mean any work, whether in Source or Object\r
+      form, that is based on (or derived from) the Work and for which the\r
+      editorial revisions, annotations, elaborations, or other modifications\r
+      represent, as a whole, an original work of authorship. For the purposes\r
+      of this License, Derivative Works shall not include works that remain\r
+      separable from, or merely link (or bind by name) to the interfaces of,\r
+      the Work and Derivative Works thereof.\r
+\r
+      "Contribution" shall mean any work of authorship, including\r
+      the original version of the Work and any modifications or additions\r
+      to that Work or Derivative Works thereof, that is intentionally\r
+      submitted to Licensor for inclusion in the Work by the copyright owner\r
+      or by an individual or Legal Entity authorized to submit on behalf of\r
+      the copyright owner. For the purposes of this definition, "submitted"\r
+      means any form of electronic, verbal, or written communication sent\r
+      to the Licensor or its representatives, including but not limited to\r
+      communication on electronic mailing lists, source code control systems,\r
+      and issue tracking systems that are managed by, or on behalf of, the\r
+      Licensor for the purpose of discussing and improving the Work, but\r
+      excluding communication that is conspicuously marked or otherwise\r
+      designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+      "Contributor" shall mean Licensor and any individual or Legal Entity\r
+      on behalf of whom a Contribution has been received by Licensor and\r
+      subsequently incorporated within the Work.\r
+\r
+   2. Grant of Copyright License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      copyright license to reproduce, prepare Derivative Works of,\r
+      publicly display, publicly perform, sublicense, and distribute the\r
+      Work and such Derivative Works in Source or Object form.\r
+\r
+   3. Grant of Patent License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      (except as stated in this section) patent license to make, have made,\r
+      use, offer to sell, sell, import, and otherwise transfer the Work,\r
+      where such license applies only to those patent claims licensable\r
+      by such Contributor that are necessarily infringed by their\r
+      Contribution(s) alone or by combination of their Contribution(s)\r
+      with the Work to which such Contribution(s) was submitted. If You\r
+      institute patent litigation against any entity (including a\r
+      cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+      or a Contribution incorporated within the Work constitutes direct\r
+      or contributory patent infringement, then any patent licenses\r
+      granted to You under this License for that Work shall terminate\r
+      as of the date such litigation is filed.\r
+\r
+   4. Redistribution. You may reproduce and distribute copies of the\r
+      Work or Derivative Works thereof in any medium, with or without\r
+      modifications, and in Source or Object form, provided that You\r
+      meet the following conditions:\r
+\r
+      (a) You must give any other recipients of the Work or\r
+          Derivative Works a copy of this License; and\r
+\r
+      (b) You must cause any modified files to carry prominent notices\r
+          stating that You changed the files; and\r
+\r
+      (c) You must retain, in the Source form of any Derivative Works\r
+          that You distribute, all copyright, patent, trademark, and\r
+          attribution notices from the Source form of the Work,\r
+          excluding those notices that do not pertain to any part of\r
+          the Derivative Works; and\r
+\r
+      (d) If the Work includes a "NOTICE" text file as part of its\r
+          distribution, then any Derivative Works that You distribute must\r
+          include a readable copy of the attribution notices contained\r
+          within such NOTICE file, excluding those notices that do not\r
+          pertain to any part of the Derivative Works, in at least one\r
+          of the following places: within a NOTICE text file distributed\r
+          as part of the Derivative Works; within the Source form or\r
+          documentation, if provided along with the Derivative Works; or,\r
+          within a display generated by the Derivative Works, if and\r
+          wherever such third-party notices normally appear. The contents\r
+          of the NOTICE file are for informational purposes only and\r
+          do not modify the License. You may add Your own attribution\r
+          notices within Derivative Works that You distribute, alongside\r
+          or as an addendum to the NOTICE text from the Work, provided\r
+          that such additional attribution notices cannot be construed\r
+          as modifying the License.\r
+\r
+      You may add Your own copyright statement to Your modifications and\r
+      may provide additional or different license terms and conditions\r
+      for use, reproduction, or distribution of Your modifications, or\r
+      for any such Derivative Works as a whole, provided Your use,\r
+      reproduction, and distribution of the Work otherwise complies with\r
+      the conditions stated in this License.\r
+\r
+   5. Submission of Contributions. Unless You explicitly state otherwise,\r
+      any Contribution intentionally submitted for inclusion in the Work\r
+      by You to the Licensor shall be under the terms and conditions of\r
+      this License, without any additional terms or conditions.\r
+      Notwithstanding the above, nothing herein shall supersede or modify\r
+      the terms of any separate license agreement you may have executed\r
+      with Licensor regarding such Contributions.\r
+\r
+   6. Trademarks. This License does not grant permission to use the trade\r
+      names, trademarks, service marks, or product names of the Licensor,\r
+      except as required for reasonable and customary use in describing the\r
+      origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+   7. Disclaimer of Warranty. Unless required by applicable law or\r
+      agreed to in writing, Licensor provides the Work (and each\r
+      Contributor provides its Contributions) on an "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+      implied, including, without limitation, any warranties or conditions\r
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+      PARTICULAR PURPOSE. You are solely responsible for determining the\r
+      appropriateness of using or redistributing the Work and assume any\r
+      risks associated with Your exercise of permissions under this License.\r
+\r
+   8. Limitation of Liability. In no event and under no legal theory,\r
+      whether in tort (including negligence), contract, or otherwise,\r
+      unless required by applicable law (such as deliberate and grossly\r
+      negligent acts) or agreed to in writing, shall any Contributor be\r
+      liable to You for damages, including any direct, indirect, special,\r
+      incidental, or consequential damages of any character arising as a\r
+      result of this License or out of the use or inability to use the\r
+      Work (including but not limited to damages for loss of goodwill,\r
+      work stoppage, computer failure or malfunction, or any and all\r
+      other commercial damages or losses), even if such Contributor\r
+      has been advised of the possibility of such damages.\r
+\r
+   9. Accepting Warranty or Additional Liability. While redistributing\r
+      the Work or Derivative Works thereof, You may choose to offer,\r
+      and charge a fee for, acceptance of support, warranty, indemnity,\r
+      or other liability obligations and/or rights consistent with this\r
+      License. However, in accepting such obligations, You may act only\r
+      on Your own behalf and on Your sole responsibility, not on behalf\r
+      of any other Contributor, and only if You agree to indemnify,\r
+      defend, and hold each Contributor harmless for any liability\r
+      incurred by, or claims asserted against, such Contributor by reason\r
+      of your accepting any such warranty or additional liability.\r
+\r
+   END OF TERMS AND CONDITIONS\r
+\r
+   APPENDIX: How to apply the Apache License to your work.\r
+\r
+      To apply the Apache License to your work, attach the following\r
+      boilerplate notice, with the fields enclosed by brackets "[]"\r
+      replaced with your own identifying information. (Don't include\r
+      the brackets!)  The text should be enclosed in the appropriate\r
+      comment syntax for the file format. We also recommend that a\r
+      file or class name and description of purpose be included on the\r
+      same "printed page" as the copyright notice for easier\r
+      identification within third-party archives.\r
+\r
+   Copyright [yyyy] [name of copyright owner]\r
+\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
diff --git a/eventsystem.manifest.in b/eventsystem.manifest.in
new file mode 100644 (file)
index 0000000..97e8c31
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_"/>
+       </request>
+</manifest>
diff --git a/eventsystem.pc.in b/eventsystem.pc.in
new file mode 100644 (file)
index 0000000..85881d4
--- /dev/null
@@ -0,0 +1,13 @@
+# Package Information for pkg-config
+
+prefix=/usr
+exec_prefix=${prefix}
+libdir=@LIB_INSTALL_DIR@
+includedir=${prefix}/include
+
+Name: libeventsystem
+Description: event system library
+Version: @VERSION@
+Requires: bundle openssl glib-2.0 gio-2.0
+Libs: -L${libdir} -leventsystem
+Cflags: -I${includedir}
diff --git a/include/eventsystem.h b/include/eventsystem.h
new file mode 100755 (executable)
index 0000000..ae4b723
--- /dev/null
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 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.
+ */
+
+#ifndef __EVENT_SYSTEM_H__
+#define __EVENT_SYSTEM_H__
+
+/**
+ * header file for eventsystem
+ */
+
+#include <stdbool.h>
+#include <eventsystem_internal.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define APPFW_EVENT_SYSTEM_EARLIER_FEATURE
+
+typedef enum _eventsystem_return_val {
+       ES_R_ENOTPERMITTED = -4,        /* Not permitted */
+       ES_R_ENOMEM = -3,               /* Memory allocation error */
+       ES_R_EINVAL = -2,               /* Invalid argument */
+       ES_R_ERROR = -1,                /* General error */
+       ES_R_OK = 0,                    /* General success */
+       ES_R_REMOVE = 1                 /* Neet to remove something */
+} eventsystem_return_val;
+
+typedef enum _eventsystem_event_type {
+       ES_TYPE_UNKNOWN = 0,    /* unknown event */
+       ES_TYPE_USER,           /* user event */
+       ES_TYPE_SYSTEM          /* system event */
+} eventsystem_event_type;
+
+#define FREE_AND_NULL(ptr) do { \
+       if (ptr) { \
+               free((void *)ptr); \
+               ptr = NULL; \
+       } \
+} while (0)
+
+
+/**
+ * APIs for Application Framework.
+ */
+
+/**
+ * interface : Callback for app core
+ */
+typedef void (*eventsystem_cb)(const char *event_name, bundle_raw *event_data,
+               int len, void *user_data);
+
+/**
+ * function : Send the user-event
+ */
+API int eventsystem_send_user_event(const char *event_name, bundle *data, bool is_trusted);
+
+/**
+ * function : Register the event of the application
+ */
+API int eventsystem_register_application_event(const char *event_name, unsigned int *reg_id,
+               int *event_type, eventsystem_cb callback, void *user_data);
+
+/**
+ * function : Unregister the event of the application
+ */
+API int eventsystem_unregister_application_event(unsigned int reg_id);
+
+/**
+ *function : Finalizer for releasing all resources
+ */
+API int eventsystem_application_finalize(void);
+
+
+/**
+ * APIs for Internal-Use (daemon or privileged app for sending system-event)
+ */
+
+/**
+ * interface : Callback for internal use
+ *
+ * example :
+#include <eventsystem.h>
+#include <bundle.h>
+void battery_level_event_handler(const char *event_name, bundle *data, void *user_data)
+{
+       const char *batt_level_status = NULL;
+       _I("battery event(%s) received", event_name);
+
+       batt_level_status = bundle_get_val(data, EVT_KEY_BATTERY_LEVEL_STATUS);
+       _I("batt_level_status(%s)", batt_level_status);
+}
+ *
+ */
+
+typedef void (*eventsystem_handler)(const char *event_name, bundle *data, void *user_data);
+
+/**
+ * function : Register the event
+ *
+ * example :
+#include <eventsystem.h>
+static void init_func(void *user_data)
+{
+       int ret = 0;
+       ret = eventsystem_register_event(SYS_EVENT_BATTERY_LEVEL_STATUS,
+               &batt_level_reg_id,
+               (eventsystem_handler)battery_level_event_handler,
+               user_data);
+       if (ret != ES_R_OK) {
+               printf("error");
+       }
+}
+ *
+ */
+API int eventsystem_register_event(const char *event_name, unsigned int *reg_id,
+               eventsystem_handler callback, void *user_data);
+
+/**
+ * function : Unregister the event
+ *
+ * example :
+static void exit_func(void *data)
+{
+       int ret = 0;
+       ret = eventsystem_unregister_event(batt_level_reg_id);
+       if (ret != ES_R_OK) {
+               printf("error");
+       }
+}
+ *
+ */
+API int eventsystem_unregister_event(unsigned int reg_id);
+
+/**
+ * function : Send the system-event
+ *
+ * example :
+static void send_func(void *user_data)
+{
+       bundle *b = NULL;
+       b = bundle_create();
+       bundle_add_str(b, EVT_KEY_BATTERY_LEVEL_STATUS, EVT_VAL_BATTERY_LEVEL_HIGH);
+       eventsystem_send_system_event(SYS_EVENT_BATTERY_LEVEL_STATUS, b);
+       bundle_free(b);
+}
+ *
+ */
+API int eventsystem_send_system_event(const char *event_name, bundle *data);
+
+/**
+ * function : Request sending the event
+ * note : This API is only for privileged application which can not use eventsystem_send_system_event() API because of dbus policy. This API need a privilege.
+ * example : similar to event_send_system_event().
+ *
+ */
+API int eventsystem_request_sending_system_event(const char *event_name, bundle *data);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __EVENT_SYSTEM_H__ */
diff --git a/include/eventsystem_internal.h b/include/eventsystem_internal.h
new file mode 100644 (file)
index 0000000..358882b
--- /dev/null
@@ -0,0 +1,273 @@
+/*
+ * Copyright (c) 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.
+ */
+
+#ifndef __EVENTSYSTEM_INTERNAL_H__
+#define ___EVENTSYSTEM_INTERNAL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define ESD_BUS_NAME "tizen.system.event.app2esd"
+#define ESD_OBJECT_PATH "/tizen/system/event/app2esd"
+#define ESD_INTERFACE_NAME "tizen.system.event.app2esd"
+
+#define USER_EVENT_NAME_PREFIX "event."
+
+/**
+ * system-event definitions
+ */
+
+/** esd : for checking esd available */
+#define SYS_EVENT_ESD_STATUS "tizen.system.event.esd_status"
+/* key */
+#define EVT_KEY_ESD_STATUS "esd_status"
+/* value */
+#define EVT_VAL_ESD_STARTED "started"
+#define EVT_VAL_ESD_STOPPED "stopped"
+
+/** battery : charger status */
+#define SYS_EVENT_BATTERY_CHARGER_STATUS "tizen.system.event.battery_charger_status"
+/* key */
+#define EVT_KEY_BATTERY_CHARGER_STATUS "battery_charger_status"
+/* value */
+#define EVT_VAL_BATTERY_CHARGER_DISCONNECTED "disconnected"
+#define EVT_VAL_BATTERY_CHARGER_CONNECTED "connected"
+#define EVT_VAL_BATTERY_CHARGER_CHARGING "charging"
+
+/** battery : level status */
+#define SYS_EVENT_BATTERY_LEVEL_STATUS "tizen.system.event.battery_level_status"
+/* key */
+#define EVT_KEY_BATTERY_LEVEL_STATUS "battery_level_status"
+/* value */
+#define EVT_VAL_BATTERY_LEVEL_EMPTY "empty"
+#define EVT_VAL_BATTERY_LEVEL_CRITICAL "critical"
+#define EVT_VAL_BATTERY_LEVEL_LOW "low"
+#define EVT_VAL_BATTERY_LEVEL_HIGH "high"
+#define EVT_VAL_BATTERY_LEVEL_FULL "full"
+
+/** usb : status of usb connection */
+#define SYS_EVENT_USB_STATUS "tizen.system.event.usb_status"
+/* key */
+#define EVT_KEY_USB_STATUS "usb_status"
+/* value */
+#define EVT_VAL_USB_DISCONNECTED "disconnected"
+#define EVT_VAL_USB_CONNECTED "connected"
+#define EVT_VAL_USB_AVAILABLE "available"
+
+/** ear-jack : status of ear-jack connection */
+#define SYS_EVENT_EARJACK_STATUS "tizen.system.event.earjack_status"
+/* key */
+#define EVT_KEY_EARJACK_STATUS "earjack_status"
+/* value */
+#define EVT_VAL_EARJACK_DISCONNECTED "disconnected"
+#define EVT_VAL_EARJACK_CONNECTED "connected"
+
+/** display : state of display */
+#define SYS_EVENT_DISPLAY_STATE "tizen.system.event.display_state"
+/* key */
+#define EVT_KEY_DISPLAY_STATE "display_state"
+/* value */
+#define EVT_VAL_DISPLAY_NORMAL "normal"
+#define EVT_VAL_DISPLAY_DIM "dim"
+#define EVT_VAL_DISPLAY_OFF "off"
+
+/** system : boot completion */
+#define SYS_EVENT_BOOT_COMPLETED "tizen.system.event.boot_completed"
+/* key */
+#define EVT_KEY_BOOT_COMPLETED "boot_completed"
+/* value */
+#define EVT_VAL_BOOT_COMPLETED_TRUE "true"
+
+/** system : shutdown */
+#define SYS_EVENT_SYSTEM_SHUTDOWN "tizen.system.event.system_shutdown"
+/* key */
+#define EVT_KEY_SYSTEM_SHUTDOWN "system_shutdown"
+/* value */
+#define EVT_VAL_SYSTEM_SHUTDOWN_TRUE "true" /* go to shutdown */
+
+/** resource : low memory */
+#define SYS_EVENT_LOW_MEMORY "tizen.system.event.low_memory"
+/* key */
+#define EVT_KEY_LOW_MEMORY "low_memory"
+/* value */
+#define EVT_VAL_MEMORY_NORMAL "normal"
+#define EVT_VAL_MEMORY_SOFT_WARNING "soft_warning"
+#define EVT_VAL_MEMORY_HARD_WARNING "hard_warning"
+
+/** wifi : state of wifi */
+#define SYS_EVENT_WIFI_STATE "tizen.system.event.wifi_state"
+/* key */
+#define EVT_KEY_WIFI_STATE "wifi_state"
+/* value */
+#define EVT_VAL_WIFI_OFF "off"
+#define EVT_VAL_WIFI_ON "on"
+#define EVT_VAL_WIFI_CONNECTED "connected"
+
+/** bluetooth : state of bluetooth */
+#define SYS_EVENT_BT_STATE "tizen.system.event.bt_state"
+/* key */
+#define EVT_KEY_BT_STATE "bt_state"
+/* value */
+#define EVT_VAL_BT_OFF "off"
+#define EVT_VAL_BT_ON "on"
+/* key */
+#define EVT_KEY_BT_LE_STATE "bt_le_state"
+/* value */
+#define EVT_VAL_BT_LE_OFF "off"
+#define EVT_VAL_BT_LE_ON "on"
+/* key */
+#define EVT_KEY_BT_TRANSFERING_STATE "bt_transfering_state"
+/* value */
+#define EVT_VAL_BT_NON_TRANSFERING "non_transfering"
+#define EVT_VAL_BT_TRANSFERING "transfering"
+
+/** location : enable state of location */
+#define SYS_EVENT_LOCATION_ENABLE_STATE "tizen.system.event.location_enable_state"
+/* key */
+#define EVT_KEY_LOCATION_ENABLE_STATE "location_enable_state"
+/* value */
+#define EVT_VAL_LOCATION_DISABLED "disabled"
+#define EVT_VAL_LOCATION_ENABLED "enabled"
+
+/** location : enable state of gps */
+#define SYS_EVENT_GPS_ENABLE_STATE "tizen.system.event.gps_enable_state"
+/* key */
+#define EVT_KEY_GPS_ENABLE_STATE "gps_enable_state"
+/* value */
+#define EVT_VAL_GPS_DISABLED "disabled"
+#define EVT_VAL_GPS_ENABLED "enabled"
+
+/** location : enable state of nps */
+#define SYS_EVENT_NPS_ENABLE_STATE "tizen.system.event.nps_enable_state"
+/* key */
+#define EVT_KEY_NPS_ENABLE_STATE "nps_enable_state"
+/* value */
+#define EVT_VAL_NPS_DISABLED "disabled"
+#define EVT_VAL_NPS_ENABLED "enabled"
+
+/** message : incoming msg */
+#define SYS_EVENT_INCOMMING_MSG "tizen.system.event.incoming_msg"
+/* key */
+#define EVT_KEY_MSG_TYPE "msg_type"
+/* value */
+#define EVT_VAL_SMS "sms"
+#define EVT_VAL_PUSH "push"
+#define EVT_VAL_CB "cb"
+/* key */
+#define EVT_KEY_MSG_ID "msg_id"
+/* value description
+ *"{unsigned int value}" : new message id
+ */
+
+/** setting : time changed */
+#define SYS_EVENT_TIME_CHANGED "tizen.system.event.time_changed"
+/* key */
+#define EVT_KEY_TIME_CHANGED "time_changed"
+/* value */
+/* do not set "false", just set "true" for broadcasting time_changed */
+#define EVT_VAL_TIME_CHANGED_TRUE "true"
+
+/** setting : timezone setting */
+#define SYS_EVENT_TIME_ZONE "tizen.system.event.time_zone"
+/* key */
+#define EVT_KEY_TIME_ZONE "time_zone"
+/* vlaue description
+ * "Asia/Seoul" : tzpaht value
+ */
+
+/** setting : hour format */
+#define SYS_EVENT_HOUR_FORMAT "tizen.system.event.hour_format"
+/* key */
+#define EVT_KEY_HOUR_FORMAT "hour_format"
+/* value */
+#define EVT_VAL_HOURFORMAT_12 "12"
+#define EVT_VAL_HOURFORMAT_24 "24"
+
+/** setting : language setting */
+#define SYS_EVENT_LANGUAGE_SET "tizen.system.event.language_set"
+/* key */
+#define EVT_KEY_LANGUAGE_SET "language_set"
+/* value description
+ * "ko_KR.UTF8" : in case of Korean language
+ * "en_US.UTF8" : in case of USA language
+ * ...
+ */
+
+/** setting : region format */
+#define SYS_EVENT_REGION_FORMAT "tizen.system.event.region_format"
+/* key */
+#define EVT_KEY_REGION_FORMAT "region_format"
+/* value description
+ * "ko_KR.UTF8" : in case of Korean region format
+ * "en_US.UTF8" : in case of USA region format
+ * "en_UK.UTF8" : in case of United Kingdom
+ * ...
+ */
+
+/** setting : silent mode */
+#define SYS_EVENT_SILENT_MODE "tizen.system.event.silent_mode"
+/* key */
+#define EVT_KEY_SILENT_MODE "silent_mode"
+/* value */
+#define EVT_VAL_SILENTMODE_ON "on"
+#define EVT_VAL_SILENTMODE_OFF "off"
+
+/** setting : state of vibration */
+#define SYS_EVENT_VIBRATION_STATE "tizen.system.event.vibration_state"
+/* key */
+#define EVT_KEY_VIBRATION_STATE "vibration_state"
+/* value */
+#define EVT_VAL_VIBRATION_ON "on"
+#define EVT_VAL_VIBRATION_OFF "off"
+
+/** setting : state of screen's auto-rotation */
+#define SYS_EVENT_SCREEN_AUTOROTATE_STATE "tizen.system.event.screen_autorotate_state"
+/* key */
+#define EVT_KEY_SCREEN_AUTOROTATE_STATE "screen_autorotate_state"
+/* value */
+#define EVT_VAL_SCREEN_AUTOROTATE_ON "on"
+#define EVT_VAL_SCREEN_AUTOROTATE_OFF "off"
+
+/** setting : state of mobile data */
+#define SYS_EVENT_MOBILE_DATA_STATE "tizen.system.event.mobile_data_state"
+/* key */
+#define EVT_KEY_MOBILE_DATA_STATE "mobile_data_state"
+/* value */
+#define EVT_VAL_MOBILE_DATA_OFF "off"
+#define EVT_VAL_MOBILE_DATA_ON "on"
+
+/** setting : state of data roaming */
+#define SYS_EVENT_DATA_ROAMING_STATE "tizen.system.event.data_roaming_state"
+/* key */
+#define EVT_KEY_DATA_ROAMING_STATE "data_roaming_state"
+/* value */
+#define EVT_VAL_DATA_ROAMING_OFF "off"
+#define EVT_VAL_DATA_ROAMING_ON "on"
+
+/** setting : font setting */
+#define SYS_EVENT_FONT_SET "tizen.system.event.font_set"
+/* key */
+#define EVT_KEY_FONT_SET "font_set"
+/* value description
+ * font name of string type by font-config.
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __EVENTSYSTEM_INTERNAL_H__ */
diff --git a/packaging/eventsystem.spec b/packaging/eventsystem.spec
new file mode 100755 (executable)
index 0000000..0f09994
--- /dev/null
@@ -0,0 +1,63 @@
+Name:       eventsystem
+Summary:    Event system library
+Version:    0.0.1
+Release:    1
+Group:      System/Libraries
+License:    Apache-2.0
+Source0:    %{name}-%{version}.tar.gz
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(ecore)
+BuildRequires:  pkgconfig(bundle)
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(gio-2.0)
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(openssl)
+
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description
+Event System Library
+
+%package devel
+Summary:    Event system library (devel)
+Group:      Development/Libraries
+Requires:   %{name} = %{version}-%{release}
+
+%description devel
+Event system library (devel)
+
+%prep
+%setup -q
+
+%build
+export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
+export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
+
+
+%cmake .
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+mkdir -p %{buildroot}/usr/share/license
+cp LICENSE %{buildroot}/usr/share/license/%{name}
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest eventsystem.manifest
+%defattr(-,root,root,-)
+%{_libdir}/libeventsystem.so.*
+/usr/share/license/%{name}
+
+%files devel
+%defattr(-,root,root,-)
+%{_includedir}/*.h
+%{_libdir}/libeventsystem.so
+%{_libdir}/pkgconfig/eventsystem.pc
diff --git a/src/eventsystem.c b/src/eventsystem.c
new file mode 100755 (executable)
index 0000000..8e0491d
--- /dev/null
@@ -0,0 +1,1579 @@
+/**
+ * event system low-level API
+ */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <dlog.h>
+#include <bundle.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <eventsystem.h>
+#include <openssl/md5.h>
+#include <fcntl.h>
+
+#undef LOG_TAG
+#define LOG_TAG "eventsystem"
+
+#define SYS_EVENT_NAME_PREFIX "tizen.system.event"
+#define EVENT_SYSTEM_PREFIX "eventsystem.id_"
+#define EVENT_SYSTEM_PREFIX_LEN 15
+#define EVENT_SYSTEM_MEMBER "eventsystem"
+#define VALID_COUNT_OF_EVENTNAME_TOKEN 3
+#define VALID_LAST_COUNT_FOR_EVENTNAME (VALID_COUNT_OF_EVENTNAME_TOKEN + 1)
+#define MAX_COUNT_FOR_EVENTNAME_CHECK (VALID_LAST_COUNT_FOR_EVENTNAME + 1)
+
+#define _E(fmt, arg...) LOGE(fmt, ##arg)
+#define _D(fmt, arg...) LOGD(fmt, ##arg)
+#define _W(fmt, arg...) LOGW(fmt, ##arg)
+#define _I(fmt, arg...) LOGI(fmt, ##arg)
+
+#define retvm_if(expr, val, fmt, arg...) do { \
+       if (expr) { \
+               _E(fmt, ##arg); \
+               _E("(%s) -> %s() return", #expr, __func__); \
+               return val; \
+       } \
+} while (0)
+
+#define retv_if(expr, val) do { \
+       if (expr) { \
+               _E("(%s) -> %s() return", #expr, __func__); \
+               return val; \
+       } \
+} while (0)
+
+pthread_mutex_t send_sync_lock = PTHREAD_MUTEX_INITIALIZER;
+
+static GList *system_event_list;
+static int _initialized;
+static GHashTable *filter_tbl;
+static GHashTable *check_tbl;
+
+typedef struct eventmap {
+       char *event_name;
+       char *interface_name;
+       char *member_name;
+       guint reg_id;
+       GBusType bus_type;
+       int event_type;
+       union {
+               eventsystem_cb es_cb;
+               eventsystem_handler ep_cb;
+       };
+} eventmap_s;
+
+typedef struct eventinfo {
+       char *event_name;
+       char *interface_name;
+       char *object_path;
+       char *member_name;
+       bool is_user_event;
+       gboolean is_trusted;
+       bundle *event_data;
+} eventinfo_s;
+
+typedef struct sysevent_info {
+       guint owner_id;
+       guint owner_id_session;
+} sysevent_info_s;
+static sysevent_info_s s_info;
+
+static int __eventsystem_request_event_launch(const char *event_name, bundle *data);
+static bool __eventsystem_check_sender_validation_userevent(GDBusConnection *connection,
+               char *sender_name);
+static int __eventsystem_check_user_send_validation(const char *event_name);
+static int __eventsystem_check_user_certificate(int sender_pid);
+
+static int __event_compare_name_cb(gconstpointer a, gconstpointer b)
+{
+       eventmap_s *key1 = (eventmap_s *)a;
+       eventmap_s *key2 = (eventmap_s *)b;
+       return strcmp(key1->interface_name, key2->interface_name) |
+                       strcmp(key1->member_name, key2->member_name);
+}
+
+static int __event_compare_reg_id_cb(gconstpointer a, gconstpointer b)
+{
+       eventmap_s *key1 = (eventmap_s *)a;
+       eventmap_s *key2 = (eventmap_s *)b;
+       return !(key1->reg_id == key2->reg_id);
+}
+
+static void __initialize(void)
+{
+       g_type_init();
+       _initialized = 1;
+}
+
+static char *__get_object_path(char *interface_name)
+{
+       int i;
+       char *object_path = (char *)calloc(strlen(interface_name), sizeof(char)+2);
+
+       if (object_path == NULL) {
+               _E("failed to allocate memory");
+               return NULL;
+       }
+
+       object_path[0] = '/';
+
+       for (i = 0 ; interface_name[i] ; i++) {
+
+               if (interface_name[i] == '.') {
+                       object_path[i+1] = '/';
+               } else {
+                       object_path[i+1] = interface_name[i];
+               }
+       }
+
+       return object_path;
+}
+
+static char *__get_encoded_interface_name(char *interface_name)
+{
+       unsigned char c[MD5_DIGEST_LENGTH] = {0, };
+       char *md5_evtid = NULL;
+       char *temp;
+       int index = 0;
+       MD5_CTX mdContext;
+
+       MD5_Init(&mdContext);
+       MD5_Update(&mdContext, interface_name, strlen(interface_name));
+       MD5_Final(c, &mdContext);
+
+       md5_evtid = (char *)calloc(EVENT_SYSTEM_PREFIX_LEN + (MD5_DIGEST_LENGTH * 2) + 1,
+               sizeof(char));
+       if (md5_evtid == NULL) {
+               _D("Malloc failed!!");
+               return NULL;
+       }
+
+       sprintf(md5_evtid, "%s", EVENT_SYSTEM_PREFIX);
+
+       temp = md5_evtid;
+
+       temp += EVENT_SYSTEM_PREFIX_LEN;
+
+       for (index = 0; index < MD5_DIGEST_LENGTH; index++) {
+               sprintf(temp, "%02x", c[index]);
+               temp += 2;
+       }
+
+       return md5_evtid;
+}
+
+static char *__get_member_name_from_eventname(char *event_name)
+{
+       char *ptr = NULL;
+       char *ptr_last = NULL;
+       char *temp_name = NULL;
+       char *member_name = NULL;
+       int count = 0;
+
+       temp_name = strdup(event_name);
+       if (temp_name == NULL) {
+               _E("out of memory");
+               return NULL;
+       }
+
+       ptr = strtok(temp_name, ".");
+       if (ptr == NULL) {
+               _E("invalid event_name(%s), count(%d)", event_name, count);
+               return NULL;
+       }
+       count++;
+
+       while (count < MAX_COUNT_FOR_EVENTNAME_CHECK) {
+               ptr = strtok(NULL, ".");
+               if (ptr == NULL)
+                       break;
+               /* _D("(%d)ptr(%s)(%d)", count, ptr, strlen(ptr)); */
+               ptr_last = ptr;
+               count++;
+       }
+       FREE_AND_NULL(temp_name);
+
+       if (count != VALID_LAST_COUNT_FOR_EVENTNAME) {
+               _E("invalid event_name(%s), count(%d)", event_name, count);
+               return NULL;
+       }
+
+       if (ptr_last) {
+               /* _D("new member_name(%s)(%d)", ptr_last, strlen(ptr_last)); */
+               member_name = strdup(ptr_last);
+               if (!member_name) {
+                       _E("out_of_memory");
+                       return NULL;
+               }
+       } else {
+               _E("ptr_last is NULL");
+               return NULL;
+       }
+
+       _D("member_name(%s)", member_name);
+
+       return member_name;
+}
+
+static int __check_validation_user_defined_name(const char *event_name)
+{
+       char *event_id = NULL;
+       char *key = NULL;
+       int ret = 1;
+
+       if (check_tbl == NULL) {
+               check_tbl = g_hash_table_new(g_str_hash, g_str_equal);
+       }
+
+       event_id = (char *)g_hash_table_lookup(check_tbl, event_name);
+
+       if (event_id == NULL) {
+               if (__eventsystem_check_user_send_validation(event_name) < 0) {
+                       _E("invalid user-event name");
+                       ret = 0;
+               } else {
+                       key = strdup(event_name);
+                       if (key == NULL) {
+                               _E("out_of_memory");
+                               ret = 0;
+                       } else {
+                               g_hash_table_insert(check_tbl, key, key);
+                       }
+               }
+       }
+
+       return ret;
+}
+
+static int __check_eventname_validation_user(char *event_name)
+{
+       int ret = 1;
+       int len = strlen(USER_EVENT_NAME_PREFIX);
+
+       if (strncmp(event_name, USER_EVENT_NAME_PREFIX, len) != 0) {
+               ret = 0;
+       }
+
+       return ret;
+}
+
+static int __check_eventname_validation_system(char *event_name)
+{
+       int ret = 1;
+       int len = strlen(SYS_EVENT_NAME_PREFIX);
+
+       if (strncmp(event_name, SYS_EVENT_NAME_PREFIX, len) != 0) {
+               ret = 0;
+       }
+
+       return ret;
+}
+
+static int __get_proc_status_by_pid(const char *what, int pid)
+{
+       int fd = 0;
+       int ret = 0;
+       int i = 0;
+       char ch = 0;
+       char _path[128] = {0, };
+       char _buf[1024] = {0, };
+       char *pval;
+       char *ptr;
+
+       snprintf(_path, 128, "/proc/%d/status", pid);
+
+       fd = open(_path, O_RDONLY);
+       if (fd < 0) {
+               _E("open file(%s) error(%d), pid(%d)", _path, fd, pid);
+               return fd;
+       }
+
+       ret = read(fd, _buf, 1024);
+       if (ret < 0) {
+               _E("read file(%s) error(%d), pid(%d)", _path, ret, pid);
+               goto error;
+       }
+
+       pval = strstr(_buf, what);
+       if (pval == NULL) {
+               _E("pval is NULL");
+               ret = -1;
+               goto error;
+       }
+
+       for (i = 0; i < strlen(pval); i++) {
+               ch = *pval;
+               if (ch == ' ' || ch == '\t') {
+                       ret = (int)strtol(pval, &ptr, 10);
+                       if (ret == 0) {
+                               if ((int)strlen(ptr) >= (int)strlen(pval)) {
+                                       _E("wrong 0 value");
+                                       ret = -2;
+                               }
+                       }
+                       break;
+               } else if (ch == '\n')
+                       break;
+               pval++;
+       }
+
+error:
+       close(fd);
+
+       return ret;
+}
+
+static int __get_gdbus_shared_connection(GDBusConnection **connection,
+               GBusType bus_type, const char *interface_name)
+{
+       GError *error = NULL;
+       guint owner_id = 0;
+
+       if (!_initialized) {
+               __initialize();
+       }
+
+       *connection = g_bus_get_sync(bus_type, NULL, &error);
+       if (*connection == NULL) {
+               if (error != NULL) {
+                       _E("Failed to get dbus [%s], bus_type [%d]",
+                               error->message, bus_type);
+                       g_error_free(error);
+               }
+               return ES_R_ERROR;
+       }
+
+       if (interface_name &&
+               ((bus_type == G_BUS_TYPE_SYSTEM && !s_info.owner_id) ||
+               (bus_type == G_BUS_TYPE_SESSION && !s_info.owner_id_session))) {
+               char own_name[128] = {0, };
+               snprintf(own_name, 128, "%s_%d_%d", interface_name,
+                       bus_type, getpid());
+               _D("own_name is [%s]", own_name);
+               owner_id = g_bus_own_name_on_connection(*connection, own_name,
+                       G_BUS_NAME_OWNER_FLAGS_NONE,
+                       NULL, NULL, NULL, NULL);
+               if (!owner_id) {
+                       _E("g_bus_own_name_on_connection, error");
+                       return ES_R_ERROR;
+               }
+               if (bus_type == G_BUS_TYPE_SESSION) {
+                       s_info.owner_id_session = owner_id;
+               } else {
+                       s_info.owner_id = owner_id;
+               }
+       }
+
+       return ES_R_OK;
+}
+
+static int __get_sender_pid(GDBusConnection *conn, const char *sender_name)
+{
+       GDBusMessage *msg = NULL;
+       GDBusMessage *reply = NULL;
+       GError *err = NULL;
+       GVariant *body;
+       int pid = 0;
+
+       msg = g_dbus_message_new_method_call("org.freedesktop.DBus", "/org/freedesktop/DBus",
+               "org.freedesktop.DBus", "GetConnectionUnixProcessID");
+       if (!msg) {
+               _D("Can't allocate new method call");
+               goto out;
+       }
+
+       g_dbus_message_set_body(msg, g_variant_new ("(s)", sender_name));
+       reply = g_dbus_connection_send_message_with_reply_sync(conn, msg,
+               G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &err);
+
+       if (!reply) {
+               if (err != NULL) {
+                       _E("Failed to get pid [%s]", err->message);
+                       g_error_free(err);
+               }
+               goto out;
+       }
+
+       body = g_dbus_message_get_body(reply);
+       g_variant_get(body, "(u)", &pid);
+
+out:
+       if (msg)
+               g_object_unref(msg);
+       if (reply)
+               g_object_unref(reply);
+
+  return pid;
+}
+
+static void __eventsystem_event_handler(GDBusConnection *connection,
+               const gchar *sender_name, const gchar *object_path,
+               const gchar *interface_name, const gchar *signal_name,
+               GVariant *parameters, gpointer user_data)
+{
+       int len;
+       eventmap_s em;
+       GList *cb_list = NULL;
+       bundle *buf = NULL;
+       bundle_raw *raw = NULL;
+       gboolean is_trusted = FALSE;
+
+       em.interface_name = (char *)interface_name;
+       em.member_name = (char *)signal_name;
+
+       _D("sender_name(%s), interface_name(%s), signal_name(%s)",
+               sender_name, interface_name, signal_name);
+
+       cb_list = g_list_find_custom(system_event_list, &em,
+               (GCompareFunc)__event_compare_name_cb);
+       if (cb_list == NULL) {
+               return;
+       }
+
+       g_variant_get(parameters, "(bus)", &is_trusted, &len, &raw);
+
+       buf = bundle_decode((bundle_raw *)raw, len);
+
+       em.event_name = ((eventmap_s *)cb_list->data)->event_name;
+       em.ep_cb = ((eventmap_s *)cb_list->data)->ep_cb;
+       if (em.ep_cb) {
+               em.ep_cb(em.event_name, buf, user_data);
+       }
+
+       bundle_free_encoded_rawdata(&raw);
+       bundle_free(buf);
+}
+
+static void __eventsystem_application_event_handler(GDBusConnection *connection,
+               const gchar *sender_name, const gchar *object_path,
+               const gchar *interface_name, const gchar *signal_name,
+               GVariant *parameters, gpointer user_data)
+{
+       GList *cb_list = NULL;
+       eventmap_s em;
+       bundle_raw *raw = NULL;
+       int len;
+
+       em.interface_name = (char *)interface_name;
+       em.member_name = (char *)signal_name;
+
+       _D("sender_name(%s), interface_name(%s), signal_name(%s)",
+               sender_name, interface_name, signal_name);
+
+       cb_list = g_list_find_custom(system_event_list, &em,
+               (GCompareFunc)__event_compare_name_cb);
+
+       if (cb_list == NULL) {
+               return;
+       }
+
+       g_variant_get(parameters, "(bus)", NULL, &len, &raw);
+
+       em.event_name = ((eventmap_s *)cb_list->data)->event_name;
+       em.es_cb = ((eventmap_s *)cb_list->data)->es_cb;
+       if (em.es_cb) {
+               em.es_cb(em.event_name, raw, len, user_data);
+       }
+
+       bundle_free_encoded_rawdata(&raw);
+}
+
+static bool __eventsystem_check_sender_validation_userevent(GDBusConnection *connection,
+               char *sender_name)
+{
+       char *sender_id = NULL;
+       char *key = NULL;
+       int sender_pid = 0;
+
+       if (filter_tbl == NULL) {
+               filter_tbl = g_hash_table_new(g_str_hash, g_str_equal);
+       }
+
+       sender_id = (char *)g_hash_table_lookup(filter_tbl, sender_name);
+
+       if (sender_id == NULL) {
+               sender_pid = __get_sender_pid(connection, sender_name);
+
+               if (sender_pid > 0) {
+                       if (__eventsystem_check_user_certificate(sender_pid) < 0) {
+                               _E("not match");
+                               return false;
+                       }
+
+                       key = strdup(sender_name);
+                       if (key == NULL) {
+                               _E("out_of_memory");
+                               return false;
+                       }
+                       g_hash_table_insert(filter_tbl, key, key);
+               } else {
+                       _E("failed to get sender_pid");
+                       return false;
+               }
+       } else {
+               _D("sender_id(%s)", sender_id);
+       }
+
+       return true;
+}
+
+/**
+ * application-use filter for user-event
+ */
+static void __eventsystem_filter_userevent_for_application(GDBusConnection *connection,
+               const gchar *sender_name, const gchar *object_path,
+               const gchar *interface_name, const gchar *signal_name,
+               GVariant *parameters, gpointer user_data)
+{
+       gboolean is_trusted = FALSE;
+
+       _D("sender_name(%s), interface_name(%s)", sender_name, interface_name);
+
+       g_variant_get(parameters, "(bus)", &is_trusted, NULL, NULL);
+
+       /* check signature */
+       if (is_trusted &&
+               __eventsystem_check_sender_validation_userevent(connection,
+                       (char *)sender_name) == false) {
+               return;
+       }
+
+       __eventsystem_application_event_handler(connection, sender_name,
+               object_path, interface_name, signal_name, parameters, user_data);
+}
+
+/**
+ * application-use filter for system-event
+ */
+static void __eventsystem_filter_sysevent_for_application(GDBusConnection *connection,
+               const gchar *sender_name, const gchar *object_path,
+               const gchar *interface_name, const gchar *signal_name,
+               GVariant *parameters, gpointer user_data)
+{
+       _D("sender_name(%s), interface_name(%s)", sender_name, interface_name);
+
+       __eventsystem_application_event_handler(connection, sender_name,
+               object_path, interface_name, signal_name, parameters, user_data);
+}
+
+/**
+ * internal-use filter for user-event
+ */
+static void __eventsystem_filter_userevent_for_internal(GDBusConnection *connection,
+               const gchar *sender_name, const gchar *object_path,
+               const gchar *interface_name, const gchar *signal_name,
+               GVariant *parameters, gpointer user_data)
+{
+       _D("sender_name(%s), interface_name(%s), signal_name(%s)",
+               sender_name, interface_name, signal_name);
+
+       __eventsystem_event_handler(connection, sender_name,
+               object_path, interface_name, signal_name, parameters, user_data);
+}
+
+/**
+ * internal-use filter for system-event
+ */
+static void __eventsystem_filter_sysevent_for_internal(GDBusConnection *connection,
+               const gchar *sender_name, const gchar *object_path,
+               const gchar *interface_name, const gchar *signal_name,
+               GVariant *parameters, gpointer user_data)
+{
+       _D("sender_name(%s), interface_name(%s), signal_name(%s)",
+               sender_name, interface_name, signal_name);
+
+       __eventsystem_event_handler(connection, sender_name,
+               object_path, interface_name, signal_name, parameters, user_data);
+}
+
+static int __eventsystem_register_event_internal(const char *event_name,
+               eventmap_s **em_s, void *user_data)
+{
+       eventmap_s *em = NULL;
+       char *interface_name = NULL;
+       char *object_path = NULL;
+       char *member_name = NULL;
+       char *sender_name = NULL;
+       GDBusSignalCallback filter;
+       GBusType bus_type;
+       guint subscription_id = 0;
+       int ret = 0;
+       int evt_type = ES_TYPE_UNKNOWN;
+       GDBusConnection *conn = NULL;
+
+       if (__check_eventname_validation_system((char *)event_name)) {
+               evt_type = ES_TYPE_SYSTEM;
+       } else if (__check_eventname_validation_user((char *)event_name)) {
+               evt_type = ES_TYPE_USER;
+       } else {
+               evt_type = ES_TYPE_UNKNOWN;
+               _E("unknown type event(%s)", event_name);
+               return ES_R_EINVAL;
+       }
+
+       if (evt_type == ES_TYPE_SYSTEM) {
+               interface_name = strdup(SYS_EVENT_NAME_PREFIX);
+               if (interface_name == NULL) {
+                       _E("out of memory");
+                       ret = ES_R_ENOMEM;
+                       goto out_1;
+               }
+
+               member_name = __get_member_name_from_eventname((char *)event_name);
+               if (member_name == NULL) {
+                       _E("invalid member_name");
+                       ret = ES_R_ERROR;
+                       goto out_2;
+               }
+
+               if (!g_dbus_is_member_name(member_name)) {
+                       _E("invalid member name");
+                       ret = ES_R_EINVAL;
+                       goto out_3;
+               }
+               filter = __eventsystem_filter_sysevent_for_internal;
+       } else {
+               interface_name = __get_encoded_interface_name((char *)event_name);
+               if (!interface_name) {
+                       _E("interface_name is NULL");
+                       ret = ES_R_ERROR;
+                       goto out_1;
+               }
+               if (!g_dbus_is_interface_name(interface_name)) {
+                       _E("invalid interface_name(%s)", interface_name);
+                       ret = ES_R_EINVAL;
+                       goto out_2;
+               }
+               member_name = strdup(EVENT_SYSTEM_MEMBER);
+               if (!member_name) {
+                       _E("out_of_memory");
+                       ret = ES_R_ERROR;
+                       goto out_2;
+               }
+               filter = __eventsystem_filter_userevent_for_internal;
+       }
+
+       object_path = __get_object_path(interface_name);
+       if (!object_path) {
+               _E("object_path is NULL");
+               ret = ES_R_ERROR;
+               goto out_3;
+       }
+       sender_name = NULL;
+
+       bus_type = G_BUS_TYPE_SYSTEM;
+
+       if (__get_gdbus_shared_connection(&conn, bus_type, interface_name) < 0) {
+               _E("getting gdbus-connetion error");
+               goto out_4;
+       }
+
+       subscription_id = g_dbus_connection_signal_subscribe(conn,
+               sender_name, /* sender */
+               interface_name,
+               member_name, /* member */
+               object_path, /* object_path */
+               NULL, /* arg0 */
+               G_DBUS_SIGNAL_FLAGS_NONE,
+               filter,
+               user_data,
+               NULL); /* user_data_free_func */
+
+       _D("event_name(%s), interface_name(%s)", event_name, interface_name);
+       _D("member_name(%s), subscription_id(%d), bus_type(%d)",
+               member_name, subscription_id, bus_type);
+
+       if (subscription_id != 0) {
+               em = calloc(1, sizeof(eventmap_s));
+               if (!em) {
+                       _E("memory alloc failed");
+                       ret = ES_R_ENOMEM;
+               } else {
+                       em->interface_name = strdup(interface_name);
+                       em->member_name = strdup(member_name);
+                       em->event_name = strdup(event_name);
+                       em->bus_type = bus_type;
+                       em->reg_id = subscription_id;
+                       em->event_type = evt_type;
+
+                       if (!em->interface_name || !em->member_name || !em->event_name) {
+                               _E("out_of_memory");
+                               FREE_AND_NULL(em->interface_name);
+                               FREE_AND_NULL(em->member_name);
+                               FREE_AND_NULL(em->event_name);
+                               FREE_AND_NULL(em);
+                               ret = ES_R_ENOMEM;
+                               goto out_4;
+                       }
+
+                       *em_s = em;
+                       ret = ES_R_OK;
+               }
+       } else {
+               _D("dbus subscribe: error(%d), event(%s)", subscription_id, event_name);
+               ret = ES_R_ERROR;
+       }
+
+out_4:
+       FREE_AND_NULL(object_path);
+out_3:
+       FREE_AND_NULL(member_name);
+out_2:
+       FREE_AND_NULL(interface_name);
+out_1:
+       if (conn) {
+               g_object_unref(conn);
+       }
+
+       return ret;
+}
+
+/**
+ * function : register the event
+ */
+int eventsystem_register_event(const char *event_name, unsigned int *reg_id,
+               eventsystem_handler callback, void *user_data)
+{
+       eventmap_s *em = NULL;
+       int ret = ES_R_ERROR;
+
+       retvm_if(!g_dbus_is_interface_name(event_name), ES_R_EINVAL,
+               "Invalid argument : event_name(%s)", event_name);
+       retvm_if(!reg_id, ES_R_EINVAL, "Invalid argument : reg_id");
+       retvm_if(!callback, ES_R_EINVAL, "Invalid argument : callback");
+
+       if (!_initialized) {
+               __initialize();
+       }
+
+       ret = __eventsystem_register_event_internal(event_name, &em, user_data);
+
+       if (ret == ES_R_OK && em) {
+               em->ep_cb = callback;
+               system_event_list = g_list_append(system_event_list, em);
+               *reg_id = em->reg_id;
+               ret = ES_R_OK;
+       } else {
+               _E("error, ret(%d), em(%s)", ret, em);
+       }
+
+       return ret;
+}
+
+/**
+ * function : unregister the event
+ */
+int eventsystem_unregister_event(unsigned int reg_id)
+{
+       eventmap_s em;
+       eventmap_s *em_data = NULL;
+       GBusType bus_type;
+       GList *cb_list = NULL;
+       GDBusConnection *conn = NULL;
+
+       retvm_if(reg_id == 0, ES_R_EINVAL, "Invalid argument : reg_id");
+
+       if (!_initialized) {
+               __initialize();
+       }
+
+       em.reg_id = reg_id;
+       cb_list = g_list_find_custom(system_event_list, &em,
+               (GCompareFunc)__event_compare_reg_id_cb);
+       if (cb_list) {
+               em_data = (eventmap_s *)cb_list->data;
+
+               bus_type = em_data->bus_type;
+
+               _D("unsubscribe: reg_id(%d), bus_type(%d)", reg_id, bus_type);
+
+               if (__get_gdbus_shared_connection(&conn, bus_type, em_data->interface_name) < 0) {
+                       _E("getting gdbus-connetion error");
+                       return ES_R_ERROR;
+               }
+               g_dbus_connection_signal_unsubscribe(conn, reg_id);
+
+               system_event_list = g_list_remove(system_event_list, cb_list->data);
+
+               FREE_AND_NULL(em_data->interface_name);
+               FREE_AND_NULL(em_data->member_name);
+               FREE_AND_NULL(em_data->event_name);
+               FREE_AND_NULL(em_data);
+               g_object_unref(conn);
+       }
+
+       return ES_R_OK;
+}
+
+static int eventsystem_send_event(GDBusConnection *conn, eventinfo_s *evti, bundle *data)
+{
+       GError *error = NULL;
+       GVariant *param = NULL;
+       gboolean ret;
+
+       bundle_raw *raw = NULL;
+       bundle *buf = data;
+       int len;
+
+       bundle_encode(buf, &raw, &len);
+
+       if (!evti->is_user_event)
+               evti->is_trusted = FALSE;
+
+       param = g_variant_new("(bus)", evti->is_trusted, len, raw);
+       ret = g_dbus_connection_emit_signal(conn,
+               NULL,
+               evti->object_path,
+               evti->interface_name,
+               evti->member_name,
+               param,
+               &error);
+
+       _D("interface_name(%s)", evti->interface_name);
+       _D("object_path(%s)", evti->object_path);
+       _D("member_name(%s)", evti->member_name);
+
+       bundle_free_encoded_rawdata(&raw);
+
+       if (ret == FALSE) {
+               _E("Unable to connect to dbus: %s", error->message);
+               g_error_free(error);
+               return ES_R_ERROR;
+       }
+
+       return ES_R_OK;
+}
+
+/**
+ * function : send the user-event
+ */
+int eventsystem_send_user_event(const char *event_name, bundle *data, bool is_trusted)
+{
+       int ret = 0;
+
+       /* check validation */
+       retvm_if(!event_name, ES_R_EINVAL, "Invalid argument : event_name is NULL");
+       retvm_if(!data, ES_R_EINVAL, "Invalid argument : data is NULL");
+       retvm_if(!__check_eventname_validation_user((char *)event_name), ES_R_EINVAL,
+               "Invalid argument : event_name(%s)", event_name);
+
+       if (!__check_validation_user_defined_name(event_name)) {
+               _E("Invalid event name(%s)", event_name);
+               return ES_R_EINVAL;
+       }
+
+       eventinfo_s *evti = NULL;
+       evti = calloc(1, sizeof(eventinfo_s));
+       if (!evti) {
+               _E("memory alloc failed");
+               return ES_R_ENOMEM;
+       }
+       evti->event_name = strdup(event_name);
+       if (!evti->event_name) {
+               _E("memory alloc failed");
+               ret = ES_R_ENOMEM;
+               goto out_1;
+       }
+
+       evti->interface_name = __get_encoded_interface_name(evti->event_name);
+       if (!evti->interface_name) {
+               _E("interface_name is NULL");
+               ret = ES_R_ERROR;
+               goto out_2;
+       }
+       evti->member_name = strdup(EVENT_SYSTEM_MEMBER);
+       if (!evti->member_name) {
+               _E("memory alloc failed");
+               ret = ES_R_ENOMEM;
+               goto out_3;
+       }
+
+       evti->object_path = __get_object_path(evti->interface_name);
+       if (!evti->object_path) {
+               _E("object_path is NULL");
+               ret = ES_R_ERROR;
+               goto out_4;
+       }
+
+       evti->is_user_event = true;
+       evti->is_trusted = (gboolean)is_trusted;
+
+       GDBusConnection *conn = NULL;
+       if (__get_gdbus_shared_connection(&conn, G_BUS_TYPE_SESSION,
+               evti->interface_name) == ES_R_OK) {
+               ret = eventsystem_send_event(conn, evti, data);
+
+               if (ret == ES_R_OK) {
+                       __eventsystem_request_event_launch(evti->event_name, data);
+               }
+       } else {
+               _E("getting gdbus-connetion error");
+               ret = ES_R_ERROR;
+       }
+
+       if (conn) {
+               g_object_unref(conn);
+       }
+       FREE_AND_NULL(evti->object_path);
+out_4:
+       FREE_AND_NULL(evti->member_name);
+out_3:
+       FREE_AND_NULL(evti->interface_name);
+out_2:
+       FREE_AND_NULL(evti->event_name);
+out_1:
+       FREE_AND_NULL(evti);
+
+       return ret;
+}
+
+/**
+ * function : send the system-event
+ */
+int eventsystem_send_system_event(const char *event_name, bundle *data)
+{
+       int ret = 0;
+
+       pthread_mutex_lock(&send_sync_lock);
+
+       /* check validation */
+       retvm_if(!event_name, ES_R_EINVAL, "Invalid argument : event_name is NULL");
+       retvm_if(!data, ES_R_EINVAL, "Invalid argument : data is NULL");
+       retvm_if(!__check_eventname_validation_system((char *)event_name), ES_R_EINVAL,
+               "Invalid argument : event_name(%s)", event_name);
+       retvm_if(!g_dbus_is_interface_name(event_name), ES_R_EINVAL,
+               "Invalid argument : event_name(%s)", event_name);
+
+       /* only permitted process could send the system-evnet */
+       int pid = getpid();
+       int sender_ppid = __get_proc_status_by_pid("PPid:", pid);
+       int sender_uid = __get_proc_status_by_pid("Uid:", pid);
+
+       _D("event_name(%s), pid(%d), sender_ppid(%d), sender_uid(%d)",
+               event_name, pid, sender_ppid, sender_uid);
+
+       eventinfo_s *evti = NULL;
+       evti = calloc(1, sizeof(eventinfo_s));
+       if (!evti) {
+               _E("memory alloc failed");
+               pthread_mutex_unlock(&send_sync_lock);
+               return ES_R_ENOMEM;
+       }
+       evti->event_name = strdup(event_name);
+       if (!evti->event_name) {
+               _E("out_of_memory");
+               ret = ES_R_ENOMEM;
+               goto out_1;
+       }
+       evti->interface_name = strdup(SYS_EVENT_NAME_PREFIX);
+       if (!evti->interface_name) {
+               _E("out of memory");
+               ret = ES_R_ENOMEM;
+               goto out_2;
+       }
+       evti->member_name = __get_member_name_from_eventname(evti->event_name);
+       if (!evti->member_name) {
+               _E("member_name is NULL");
+               ret = ES_R_ERROR;
+               goto out_3;
+       }
+       if (!g_dbus_is_member_name(evti->member_name)) {
+               _E("Invalid member_name(%s)", evti->member_name);
+               ret = ES_R_EINVAL;
+               goto out_4;
+       }
+       evti->object_path = __get_object_path(evti->interface_name);
+       if (!evti->object_path) {
+               _E("object_path is NULL");
+               ret = ES_R_ERROR;
+               goto out_4;
+       }
+       evti->is_user_event = false;
+       evti->is_trusted = FALSE;
+
+       GDBusConnection *conn = NULL;
+       if (__get_gdbus_shared_connection(&conn, G_BUS_TYPE_SYSTEM, evti->interface_name) == ES_R_OK) {
+               ret = eventsystem_send_event(conn, evti, data);
+       } else {
+               _E("getting gdbus-connection error");
+               ret = ES_R_ERROR;
+       }
+
+       if (conn) {
+               g_object_unref(conn);
+       }
+       FREE_AND_NULL(evti->object_path);
+out_4:
+       FREE_AND_NULL(evti->member_name);
+out_3:
+       FREE_AND_NULL(evti->interface_name);
+out_2:
+       FREE_AND_NULL(evti->event_name);
+out_1:
+       FREE_AND_NULL(evti);
+
+       pthread_mutex_unlock(&send_sync_lock);
+
+       return ret;
+}
+
+/**
+ * function : request sending the event
+ */
+int eventsystem_request_sending_system_event(const char *event_name, bundle *data)
+{
+       int ret = 0;
+       GDBusConnection *conn = NULL;
+       GError *error = NULL;
+       GDBusProxy *proxy = NULL;
+       GVariant *param = NULL;
+       GVariant *value = NULL;
+       gint result = 0;
+       bundle_raw *raw = NULL;
+       int len = 0;
+
+       _D("event_name(%s)", event_name);
+
+       if (!_initialized) {
+               __initialize();
+       }
+
+       if (__get_gdbus_shared_connection(&conn, G_BUS_TYPE_SYSTEM, NULL) < 0) {
+               _E("getting gdbus-connetion error");
+               ret = ES_R_ERROR;
+               goto out_1;
+       }
+
+       proxy = g_dbus_proxy_new_sync(conn,
+               G_DBUS_PROXY_FLAGS_NONE, NULL,
+               ESD_BUS_NAME, ESD_OBJECT_PATH, ESD_INTERFACE_NAME,
+               NULL, &error);
+       if (proxy == NULL) {
+               _E("failed to create new proxy, error(%s)", error->message);
+               g_error_free(error);
+               ret = ES_R_ERROR;
+               goto out_1;
+       }
+
+       bundle_encode(data, &raw, &len);
+
+       param = g_variant_new("(ssi)", event_name, raw, len);
+       value = g_dbus_proxy_call_sync(proxy, "RequestSendingEvent", param,
+               G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+       if (error != NULL) {
+               _E("proxy call sync error(%s)", error->message);
+               g_error_free(error);
+               ret = ES_R_ERROR;
+               goto out_2;
+       }
+
+       g_variant_get(value, "(i)", &result);
+
+       _D("result(%d)", result);
+
+       ret = ES_R_OK;
+
+out_2:
+       g_variant_unref(value);
+out_1:
+       if (conn) {
+               g_object_unref(conn);
+       }
+
+       return ret;
+}
+
+static int __eventsystem_request_event_launch(const char *event_name, bundle *data)
+{
+       int ret = 0;
+       GDBusConnection *conn = NULL;
+       GError *error = NULL;
+       GDBusProxy *proxy = NULL;
+       GVariant *param = NULL;
+       GVariant *value = NULL;
+       gint result = 0;
+       bundle_raw *raw = NULL;
+       int len = 0;
+
+       _D("event_name(%s)", event_name);
+
+       if (!_initialized) {
+               __initialize();
+       }
+
+       if (__get_gdbus_shared_connection(&conn, G_BUS_TYPE_SYSTEM, NULL) < 0) {
+               _E("getting gdbus-connetion error");
+               ret = ES_R_ERROR;
+               goto out_1;
+       }
+
+       proxy = g_dbus_proxy_new_sync(conn,
+               G_DBUS_PROXY_FLAGS_NONE, NULL,
+               ESD_BUS_NAME, ESD_OBJECT_PATH, ESD_INTERFACE_NAME,
+               NULL, &error);
+       if (proxy == NULL) {
+               _E("failed to create new proxy, error(%s)", error->message);
+               g_error_free(error);
+               ret = ES_R_ERROR;
+               goto out_1;
+       }
+
+       bundle_encode(data, &raw, &len);
+
+       param = g_variant_new("(ssi)", event_name, raw, len);
+       value = g_dbus_proxy_call_sync(proxy, "RequestEventLaunch", param,
+               G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+       if (error != NULL) {
+               _E("proxy call sync error(%s)", error->message);
+               g_error_free(error);
+               ret = ES_R_ERROR;
+               goto out_2;
+       }
+
+       g_variant_get(value, "(i)", &result);
+
+       _D("result(%d)", result);
+
+       ret = ES_R_OK;
+
+out_2:
+       g_variant_unref(value);
+out_1:
+       if (conn) {
+               g_object_unref(conn);
+       }
+
+       return ret;
+}
+
+static int __eventsystem_check_user_certificate(int sender_pid)
+{
+       int ret = 0;
+       GDBusConnection *conn = NULL;
+       GError *error = NULL;
+       GDBusProxy *proxy = NULL;
+       GVariant *param = NULL;
+       GVariant *value = NULL;
+       gint result = ES_R_ERROR;;
+
+       if (!_initialized) {
+               __initialize();
+       }
+
+       if (__get_gdbus_shared_connection(&conn, G_BUS_TYPE_SYSTEM, NULL) < 0) {
+               _E("getting gdbus-connetion error");
+               ret = ES_R_ERROR;
+               goto out_1;
+       }
+
+       proxy = g_dbus_proxy_new_sync(conn,
+               G_DBUS_PROXY_FLAGS_NONE, NULL,
+               ESD_BUS_NAME, ESD_OBJECT_PATH, ESD_INTERFACE_NAME,
+               NULL, &error);
+       if (proxy == NULL) {
+               _E("failed to create new proxy, error(%s)", error->message);
+               g_error_free(error);
+               ret = ES_R_ERROR;
+               goto out_1;
+       }
+
+       param = g_variant_new("(i)", sender_pid);
+       value = g_dbus_proxy_call_sync(proxy, "CheckUserCertValidation", param,
+               G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+       if (error != NULL) {
+               _E("proxy call sync error(%s)", error->message);
+               g_error_free(error);
+               ret = ES_R_ERROR;
+               goto out_2;
+       }
+
+       g_variant_get(value, "(i)", &result);
+
+       _D("result(%d)", result);
+
+       if (result == 1) {
+               ret = ES_R_OK;
+       }
+out_2:
+       g_variant_unref(value);
+out_1:
+       if (conn) {
+               g_object_unref(conn);
+       }
+
+       return ret;
+}
+
+static int __eventsystem_check_user_send_validation(const char *event_name)
+{
+       int ret = 0;
+       GDBusConnection *conn = NULL;
+       GError *error = NULL;
+       GDBusProxy *proxy = NULL;
+       GVariant *param = NULL;
+       GVariant *value = NULL;
+       gint result = ES_R_ERROR;;
+
+       if (!_initialized) {
+               __initialize();
+       }
+
+       if (__get_gdbus_shared_connection(&conn, G_BUS_TYPE_SYSTEM, NULL) < 0) {
+               _E("getting gdbus-connetion error");
+               ret = ES_R_ERROR;
+               goto out_1;
+       }
+
+       proxy = g_dbus_proxy_new_sync(conn,
+               G_DBUS_PROXY_FLAGS_NONE, NULL,
+               ESD_BUS_NAME, ESD_OBJECT_PATH, ESD_INTERFACE_NAME,
+               NULL, &error);
+       if (proxy == NULL) {
+               _E("failed to create new proxy, error(%s)", error->message);
+               g_error_free(error);
+               ret = ES_R_ERROR;
+               goto out_1;
+       }
+
+       param = g_variant_new("(s)", event_name);
+       value = g_dbus_proxy_call_sync(proxy, "CheckUserSendValidation", param,
+               G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+       if (error != NULL) {
+               _E("proxy call sync error(%s)", error->message);
+               g_error_free(error);
+               ret = ES_R_ERROR;
+               goto out_2;
+       }
+
+       g_variant_get(value, "(i)", &result);
+
+       _D("result(%d)", result);
+
+       if (result == 1) {
+               ret = ES_R_OK;
+       }
+out_2:
+       g_variant_unref(value);
+out_1:
+       if (conn) {
+               g_object_unref(conn);
+       }
+
+       return ret;
+}
+#ifdef APPFW_EVENT_SYSTEM_EARLIER_FEATURE
+static int __eventsystem_request_earlier_data(const char *event_name,
+               eventsystem_cb callback, void *user_data)
+{
+       int ret = 0;
+       GDBusConnection *conn = NULL;
+       GError *error = NULL;
+       GDBusProxy *proxy = NULL;
+       GVariant *param = NULL;
+       gint result = 0;
+       bundle_raw *raw = NULL;
+       int len = 0;
+
+       if (!_initialized) {
+               __initialize();
+       }
+
+       if (__get_gdbus_shared_connection(&conn, G_BUS_TYPE_SYSTEM, NULL) < 0) {
+               _E("getting gdbus-connetion error");
+               ret = ES_R_ERROR;
+               goto out_1;
+       }
+
+       proxy = g_dbus_proxy_new_sync(conn,
+               G_DBUS_PROXY_FLAGS_NONE, NULL,
+               ESD_BUS_NAME, ESD_OBJECT_PATH, ESD_INTERFACE_NAME,
+               NULL, &error);
+
+       if (proxy == NULL) {
+               _E("failed to create new proxy, error(%s)", error->message);
+               g_error_free(error);
+               ret = ES_R_ERROR;
+               goto out_1;
+       }
+
+       param = g_variant_new("(s)", event_name);
+       GVariant *value = g_dbus_proxy_call_sync(proxy, "GetEarlierData", param,
+               G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+       if (error != NULL) {
+               _E("proxy call sync error(%s)", error->message);
+               g_error_free(error);
+               ret = ES_R_ERROR;
+               goto out_2;
+       }
+
+       g_variant_get(value, "(iis)", &result, &len, &raw);
+       g_variant_unref(value);
+
+       _D("result(%d), len(%d)", result, len);
+
+       if (!result && raw && len > 0) {
+               callback(event_name, raw, len, user_data);
+               bundle_free_encoded_rawdata(&raw);
+       }
+
+       ret = ES_R_OK;
+
+out_2:
+       g_variant_unref(value);
+out_1:
+       if (conn) {
+               g_object_unref(conn);
+       }
+
+       return ret;
+}
+#endif
+
+int eventsystem_register_application_event(const char *event_name, unsigned int *reg_id,
+               int *event_type, eventsystem_cb callback, void *user_data)
+{
+       eventmap_s *em;
+       char *interface_name = NULL;
+       char *object_path = NULL;
+       char *member_name = NULL;
+       char *sender_name = NULL;
+       GDBusSignalCallback filter;
+       GBusType bus_type;
+       guint  subscription_id  = 0;
+       int ret = 0;
+       GDBusConnection *conn = NULL;
+
+       if (!_initialized) {
+               __initialize();
+       }
+
+       if (__check_eventname_validation_system((char *)event_name)) {
+               *event_type = ES_TYPE_SYSTEM;
+       } else if (__check_eventname_validation_user((char *)event_name)) {
+               *event_type = ES_TYPE_USER;
+       } else {
+               *event_type = ES_TYPE_UNKNOWN;
+               _E("unknown type event(%s)", event_name);
+               return ES_R_EINVAL;
+       }
+
+       if (*event_type == ES_TYPE_SYSTEM) {
+               interface_name = strdup(SYS_EVENT_NAME_PREFIX);
+               if (interface_name == NULL) {
+                       _E("out of memory");
+                       return ES_R_ENOMEM;
+               }
+               if (!g_dbus_is_interface_name(interface_name)) {
+                       _E("invalid interface_name(%s)", interface_name);
+                       FREE_AND_NULL(interface_name);
+                       return ES_R_EINVAL;
+               }
+               member_name = __get_member_name_from_eventname((char *)event_name);
+               if (member_name == NULL) {
+                       _E("member_name is NULL(%s)", event_name);
+                       FREE_AND_NULL(interface_name);
+                       return ES_R_ERROR;
+               }
+               if (!g_dbus_is_member_name(member_name)) {
+                       _E("Invalid member_name(%s)", member_name);
+                       FREE_AND_NULL(interface_name);
+                       FREE_AND_NULL(member_name);
+                       return ES_R_ERROR;
+               }
+               filter = __eventsystem_filter_sysevent_for_application;
+               bus_type = G_BUS_TYPE_SYSTEM;
+       } else {
+               interface_name = __get_encoded_interface_name((char *)event_name);
+               if (!interface_name) {
+                       _E("interface_name is NULL");
+                       return ES_R_ERROR;
+               }
+               if (!g_dbus_is_interface_name(interface_name)) {
+                       _E("invalid interface_name(%s)", interface_name);
+                       FREE_AND_NULL(interface_name);
+                       return ES_R_EINVAL;
+               }
+               member_name = strdup(EVENT_SYSTEM_MEMBER);
+               if (!member_name) {
+                       _E("out_of_memory");
+                       FREE_AND_NULL(interface_name);
+                       return ES_R_ERROR;
+               }
+               filter = __eventsystem_filter_userevent_for_application;
+               bus_type = G_BUS_TYPE_SESSION;
+       }
+
+       object_path = __get_object_path(interface_name);
+       if (!object_path) {
+               _E("failed get object_path");
+               FREE_AND_NULL(interface_name);
+               FREE_AND_NULL(member_name);
+               return ES_R_ERROR;
+       }
+       sender_name = NULL;
+
+       _D("interface_name(%s), object_path(%s)", interface_name, object_path);
+       _D(" member_name(%s), sender_name(%s), type(%d), bus_type(%d)",
+               member_name, sender_name, *event_type, bus_type);
+
+       if (__get_gdbus_shared_connection(&conn, bus_type, interface_name) < 0) {
+               _E("getting gdbus-connetion error");
+               FREE_AND_NULL(interface_name);
+               FREE_AND_NULL(object_path);
+               FREE_AND_NULL(member_name);
+               return ES_R_ERROR;
+       }
+
+#ifdef APPFW_EVENT_SYSTEM_EARLIER_FEATURE
+       __eventsystem_request_earlier_data(event_name, callback, user_data);
+#endif
+
+       subscription_id = g_dbus_connection_signal_subscribe(conn,
+               sender_name, /* sender */
+               interface_name,
+               member_name, /* member */
+               object_path, /* object_path */
+               NULL, /* arg0 */
+               G_DBUS_SIGNAL_FLAGS_NONE,
+               filter,
+               user_data,
+               NULL); /* user_data_free_func */
+
+       _D("event_name(%s), subscription_id(%d)", event_name, subscription_id);
+
+       if (subscription_id != 0) {
+               em = calloc(1, sizeof(eventmap_s));
+               if (!em) {
+                       _E("memory alloc failed");
+                       ret = ES_R_ENOMEM;
+               } else {
+                       em->interface_name = strdup(interface_name);
+                       em->member_name = strdup(member_name);
+                       em->event_name = strdup(event_name);
+                       em->es_cb = callback;
+                       em->bus_type = bus_type;
+                       em->reg_id = subscription_id;
+                       em->event_type = *event_type;
+
+                       if (!em->interface_name || !em->member_name ||
+                               !em->event_name) {
+                               _E("out_of_memory");
+                               FREE_AND_NULL(em->interface_name);
+                               FREE_AND_NULL(em->member_name);
+                               FREE_AND_NULL(em->event_name);
+                               FREE_AND_NULL(em);
+                               ret = ES_R_ENOMEM;
+                       } else {
+                               system_event_list =
+                                       g_list_append(system_event_list, em);
+                               *reg_id = subscription_id;
+                               ret = ES_R_OK;
+                       }
+               }
+       } else {
+               _D("dbus subscribe: error(%d)", subscription_id);
+               ret = ES_R_ERROR;
+       }
+
+       FREE_AND_NULL(interface_name);
+       FREE_AND_NULL(object_path);
+       FREE_AND_NULL(member_name);
+       if (conn) {
+               g_object_unref(conn);
+       }
+
+       return ret;
+}
+
+int eventsystem_unregister_application_event(unsigned int reg_id)
+{
+       eventmap_s em;
+       eventmap_s *em_data = NULL;
+       GBusType bus_type;
+       GList *cb_list = NULL;
+       GDBusConnection *conn = NULL;
+
+       retvm_if(reg_id == 0, ES_R_EINVAL, "Invalid argument : reg_id");
+
+       if (!_initialized) {
+               __initialize();
+       }
+
+       em.reg_id = reg_id;
+       cb_list = g_list_find_custom(system_event_list, &em,
+               (GCompareFunc)__event_compare_reg_id_cb);
+       if (cb_list) {
+               em_data = (eventmap_s *)cb_list->data;
+
+               bus_type = em_data->bus_type;
+
+               _D("unsubscribe: reg_id(%d), bus_type(%d)", reg_id, bus_type);
+
+               if (__get_gdbus_shared_connection(&conn, bus_type, em_data->interface_name) < 0) {
+                       _E("getting gdbus-connetion error");
+                       return ES_R_ERROR;
+               }
+               g_dbus_connection_signal_unsubscribe(conn, reg_id);
+
+               system_event_list = g_list_remove(system_event_list, cb_list->data);
+
+               FREE_AND_NULL(em_data->interface_name);
+               FREE_AND_NULL(em_data->member_name);
+               FREE_AND_NULL(em_data->event_name);
+               FREE_AND_NULL(em_data);
+               g_object_unref(conn);
+       } else {
+               _E("not found matched item");
+               return ES_R_ERROR;
+       }
+
+       return ES_R_OK;
+}
+
+int eventsystem_application_finalize(void)
+{
+       gpointer key, value;
+
+       _D("release all resouces");
+
+       if (system_event_list) {
+               g_list_free(system_event_list);
+       }
+
+       if (filter_tbl) {
+               GHashTableIter iter;
+
+               g_hash_table_iter_init(&iter, filter_tbl);
+
+               while (g_hash_table_iter_next(&iter, &key, &value)) {
+                       char *val_item = (char *)value;
+                       if (val_item) {
+                               free(val_item);
+                       } else {
+                               _E("filter_tbl, val_item is NULL");
+                       }
+                       g_hash_table_iter_remove(&iter);
+               }
+               g_hash_table_unref(filter_tbl);
+       }
+
+       if (check_tbl) {
+               GHashTableIter iter;
+
+               g_hash_table_iter_init(&iter, check_tbl);
+
+               while (g_hash_table_iter_next(&iter, &key, &value)) {
+                       char *val_item = (char *)value;
+                       if (val_item) {
+                               free(val_item);
+                       } else {
+                               _E("check_tbl, val_item is NULL");
+                       }
+                       g_hash_table_iter_remove(&iter);
+               }
+               g_hash_table_unref(check_tbl);
+       }
+
+       return 0;
+}