Merge branch 'devel/tizen' into tizen
[platform/core/system/sensord.git] / src / server / dbus_util.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 662be73..0aa0b90
  *
  */
 
-#include <common.h>
+#include <sensor_log.h>
 #include <dbus_util.h>
 #include <gio/gio.h>
 
-#define SENSORD_BUS_NAME              "org.tizen.system.sensord"
-#define SENSORD_OBJECT_PATH           "/Org/Tizen/System/SensorD"
-#define SENSORD_INTERFACE_NAME        SENSORD_BUS_NAME
+static int wrist_up_total_cnt;
+static int wrist_up_lcdon_cnt;
+static int wrist_up_algo;
 
 static GDBusNodeInfo *introspection_data = NULL;
 static guint owner_id;
@@ -34,6 +34,15 @@ static const gchar introspection_xml[] =
 "       <method name='check_privilege'>"
 "         <arg type='i' name='response' direction='out'/>"
 "       </method>"
+"       <method name='wristup_lcdon_cnt'>"
+"         <arg type='i' name='response' direction='out'/>"
+"       </method>"
+"       <method name='wristup_total_cnt'>"
+"         <arg type='i' name='response' direction='out'/>"
+"       </method>"
+"       <method name='wristup_algo'>"
+"         <arg type='i' name='response' direction='out'/>"
+"       </method>"
 "  </interface>"
 "</node>";
 
@@ -48,6 +57,15 @@ static void method_call_handler(GDBusConnection *conn,
        if (g_strcmp0(method_name, "check_privilege") == 0) {
                _D("check_privilege called");
                ret = DBUS_SUCCESS;
+       } else if (g_strcmp0(method_name, "wristup_lcdon_cnt") == 0) {
+               _D("wristup_lcdon_cnt called, %d", wrist_up_lcdon_cnt);
+               ret = wrist_up_lcdon_cnt;
+       } else if (g_strcmp0(method_name, "wristup_total_cnt") == 0) {
+               _D("wristup_total_cnt called, %d", wrist_up_total_cnt);
+               ret = wrist_up_total_cnt;
+       } else if (g_strcmp0(method_name, "wristup_algo") == 0) {
+               _D("wristup_algo called, %d", wrist_up_algo);
+               ret = wrist_up_algo;
        } else {
                _D("No matched method call");
                ret = DBUS_FAILED;
@@ -55,7 +73,6 @@ static void method_call_handler(GDBusConnection *conn,
 
        g_dbus_method_invocation_return_value(invocation,
                                        g_variant_new("(i)", ret));
-
 }
 
 static const GDBusInterfaceVTable interface_vtable =
@@ -65,9 +82,9 @@ static const GDBusInterfaceVTable interface_vtable =
        NULL
 };
 
-static void on_bus_acquired (GDBusConnection *connection,
-               const gchar     *name,
-               gpointer         user_data)
+static void on_bus_acquired(GDBusConnection *connection,
+               const gchar *name,
+               gpointer user_data)
 {
        guint registration_id;
 
@@ -101,12 +118,46 @@ static void on_name_lost(GDBusConnection *conn,
        _E("Dbus name is lost!");
 }
 
-void init_dbus(void)
+int get_lcdon_count(void)
 {
+       return wrist_up_lcdon_cnt;
+}
+
+void increase_lcdon_count(void)
+{
+       wrist_up_lcdon_cnt++;
+}
+
+void reset_lcdon_count(void)
+{
+       wrist_up_lcdon_cnt = 0;
+}
 
-       #ifndef GLIB_VERSION_2_36
+int get_total_count(void)
+{
+       return wrist_up_total_cnt;
+}
+
+void increase_total_count(void)
+{
+       wrist_up_total_cnt++;
+}
+
+void reset_total_count(void)
+{
+       wrist_up_total_cnt = 0;
+}
+
+void set_wrist_up_algo(int mode)
+{
+       wrist_up_algo = mode;
+}
+
+void init_dbus(void)
+{
+#ifndef GLIB_VERSION_2_36
        g_type_init();
-       #endif
+#endif
 
        introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
        if (introspection_data == NULL) {
@@ -123,6 +174,8 @@ void init_dbus(void)
                                                           on_name_lost,
                                                           NULL,
                                                           NULL);
+       wrist_up_total_cnt = 0;
+       wrist_up_lcdon_cnt = 0;
 }
 
 void fini_dbus(void)