Add dbus method call for cooldown mode 26/204526/2 accepted/tizen/unified/20190425.014514 submit/tizen/20190424.090717
authorsinikang <sinikang@samsung.com>
Wed, 24 Apr 2019 06:33:35 +0000 (15:33 +0900)
committersinikang <sinikang@samsung.com>
Wed, 24 Apr 2019 08:52:51 +0000 (17:52 +0900)
Change-Id: I5f646721e0c179534993bff45f4adfe1397c8343
Signed-off-by: sinikang <sinikang@samsung.com>
introspection/call-manager.xml
module/include/callmgr-cooldown.h
module/src/callmgr-cooldown.c
packaging/call-manager.spec
service/src/callmgr-core.c
service/src/callmgr-dbus.c

index bc13989e287c11c183b2f6fcbc8430a9aa450737..6062a176e0d088734539c90915f68003fb7f3962 100644 (file)
                        <arg direction="out" type="i" name="err" />
                </method>
 
+               <method name="SetCoolDownStatus">
+                       <arg direction="in" type="s" name="status" />
+                       <arg direction="out" type="i" name="ret" />
+               </method>
+
                <!--signal list -->
 
                <signal name="CallEvent">
index 095aa3f5e9d4a88d38e919b59d36e30b08634051..bbca4182a895474755198acb3d8f9f638ee70cfa 100644 (file)
@@ -37,6 +37,7 @@ typedef enum {
 
 typedef void (*callmgr_cooldown_event_cb)(callmgr_cooldown_event_e event, const void *event_data, void *user_data);
 int _callmgr_cooldown_get_cooldown_status(callmgr_cooldown_h handle, callmgr_cooldown_status_e *status);
+int _callmgr_cooldown_set_cooldown_status(callmgr_cooldown_h handle, const char *status);
 int _callmgr_cooldown_init(callmgr_cooldown_h *cooldown_handle, callmgr_cooldown_event_cb cb, void *user_data);
 void _callmgr_cooldown_deinit(callmgr_cooldown_h cooldown_handle);
 
index e2d6ae905b9f79aae609c9268d3e62cefd73fd90..42467656b4a288a56c8df262c99d43e041c68513 100644 (file)
 #include "callmgr-util.h"
 #include "callmgr-log.h"
 
+#define COOLDOWN_STATUS_LIMIT          "limit"
+#define COOLDOWN_STATUS_RELEASE        "release"
+
 struct __cooldown_data {
        callmgr_cooldown_event_cb event_cb;
        void *user_data;
-
-       GDBusConnection *dbus_conn;
        callmgr_cooldown_status_e cooldown_status;
-       guint cooldown_subs_id;
 };
 
 int _callmgr_cooldown_get_cooldown_status(callmgr_cooldown_h handle, callmgr_cooldown_status_e *status)
@@ -35,80 +35,44 @@ int _callmgr_cooldown_get_cooldown_status(callmgr_cooldown_h handle, callmgr_coo
        return 0;
 }
 
-static void __callmgr_cooldown_subscribe_cooldown_signal_cb(GDBusConnection *connection,
-       const gchar *sender_name, const gchar *object_path,
-       const gchar *interface_name, const gchar *signal_name,
-       GVariant *parameters, gpointer user_data)
+int _callmgr_cooldown_set_cooldown_status(callmgr_cooldown_h handle, const char *status)
 {
-       gchar *cooldown_string = NULL;
-       callmgr_cooldown_h handle = user_data;
-
-       CM_RETURN_IF_FAIL(handle);
-       dbg("__callmgr_cooldown_subscribe_cooldown_signal_cb");
-
-       if (g_strcmp0(signal_name, DBUS_SIGNAL_COOLDOWN_CHANGED) == 0) {
-               g_variant_get(parameters, "(s)", &cooldown_string);
-               if (cooldown_string) {
-                       dbg("cooldown status: %s", cooldown_string);
-                       if (strncasecmp(cooldown_string, "LimitAction", strlen("LimitAction")) == 0) {
-                               handle->cooldown_status = CALLMGR_COOLDOWN_STATUS_LIMIT;
-                               handle->event_cb(CALLMGR_COOLDOWN_EVENT_LIMIT_ACTION, NULL, handle->user_data);
-                       } else if (strncasecmp(cooldown_string, "ReleaseAction", strlen("ReleaseAction")) == 0) {
-                               handle->cooldown_status = CALLMGR_COOLDOWN_STATUS_RELEASE;
-                       }
-               } else {
-                       err("Failed to get cooldown status.");
-               }
-               g_free(cooldown_string);
-       }
-}
+       int result =0;
 
-static void __callmgr_cooldown_subscribe_cooldown_signal(callmgr_cooldown_h handle)
-{
-       CM_RETURN_IF_FAIL(handle);
-       dbg("__callmgr_cooldown_subscribe_cooldown_signal");
-
-       if (!handle->dbus_conn) {
-               GError *error = NULL;
-               handle->dbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
-               if (!handle->dbus_conn) {
-                       err("g_bus_get_sync() is failed. (%s)", error->message);
-                       g_error_free(error);
-                       return;
-               }
+       CM_RETURN_VAL_IF_FAIL(handle, -1);
+       CM_RETURN_VAL_IF_FAIL(status, -1);
+
+       dbg("__cooldown status: %s", status);
+       if (g_strcmp0(status, COOLDOWN_STATUS_LIMIT) == 0) {
+               handle->cooldown_status = CALLMGR_COOLDOWN_STATUS_LIMIT;
+               handle->event_cb(CALLMGR_COOLDOWN_EVENT_LIMIT_ACTION, NULL, handle->user_data);
+       } else if (g_strcmp0(status, COOLDOWN_STATUS_RELEASE) == 0) {
+               handle->cooldown_status = CALLMGR_COOLDOWN_STATUS_RELEASE;
+       } else {
+               err("Unknown type");
+               result = -1;
        }
 
-       handle->cooldown_subs_id = g_dbus_connection_signal_subscribe(handle->dbus_conn,
-               NULL,
-               DBUS_INTERFACE_DEVICED_SYSNOTI,
-               DBUS_SIGNAL_COOLDOWN_CHANGED,
-               DBUS_PATH_DEVICED_SYSNOTI,
-               NULL, G_DBUS_SIGNAL_FLAGS_NONE,
-               __callmgr_cooldown_subscribe_cooldown_signal_cb, handle, NULL);
-       if (handle->cooldown_subs_id == 0) {
-               err("g_dbus_connection_signal_subscribe() is failed.");
-               g_object_unref(handle->dbus_conn);
-       }
+       return result;
 }
 
 static void __callmgr_cooldown_get_cooldown_status(callmgr_cooldown_h handle)
 {
        GError *error = NULL;
        GVariant *dbus_result;
+       GDBusConnection *dbus_conn = NULL;
 
        CM_RETURN_IF_FAIL(handle);
        dbg("__callmgr_cooldown_get_cooldown_status");
 
-       if (!handle->dbus_conn) {
-               handle->dbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
-               if (!handle->dbus_conn) {
-                       err("g_bus_get_sync() is failed. (%s)", error->message);
-                       g_error_free(error);
-                       return;
-               }
+       dbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+       if (!dbus_conn) {
+               err("g_bus_get_sync() is failed. (%s)", error->message);
+               g_error_free(error);
+               return;
        }
 
-       dbus_result = g_dbus_connection_call_sync(handle->dbus_conn,
+       dbus_result = g_dbus_connection_call_sync(dbus_conn,
                DBUS_NAME_DEVICED,
                DBUS_PATH_DEVICED_SYSNOTI,
                DBUS_INTERFACE_DEVICED_SYSNOTI,
@@ -130,6 +94,9 @@ static void __callmgr_cooldown_get_cooldown_status(callmgr_cooldown_h handle)
                err("g_dbus_connection_call_sync() is failed. (%s)", error->message);
                g_error_free(error);
        }
+
+       g_object_unref(dbus_conn);
+
 }
 
 int _callmgr_cooldown_init(callmgr_cooldown_h *cooldown_handle, callmgr_cooldown_event_cb cb, void *user_data)
@@ -146,7 +113,6 @@ int _callmgr_cooldown_init(callmgr_cooldown_h *cooldown_handle, callmgr_cooldown
        handle->user_data = user_data;
        handle->cooldown_status = CALLMGR_COOLDOWN_STATUS_RELEASE;
        __callmgr_cooldown_get_cooldown_status(handle);
-       __callmgr_cooldown_subscribe_cooldown_signal(handle);
        *cooldown_handle = handle;
 
        return 0;
@@ -157,15 +123,7 @@ void _callmgr_cooldown_deinit(callmgr_cooldown_h cooldown_handle)
        CM_RETURN_IF_FAIL(cooldown_handle);
        dbg("_callmgr_cooldown_deinit");
 
-       if (cooldown_handle->cooldown_subs_id) {
-               g_dbus_connection_signal_unsubscribe(cooldown_handle->dbus_conn,
-                       cooldown_handle->cooldown_subs_id);
-               cooldown_handle->cooldown_subs_id = 0;
-       }
-
-       if (cooldown_handle->dbus_conn) {
-               g_object_unref(cooldown_handle->dbus_conn);
-               cooldown_handle->dbus_conn = NULL;
-       }
+       g_free(cooldown_handle);
+       cooldown_handle = NULL;
 }
 
index 0973783776faff7d14521e30ad056fec4e8485c3..63ebf62a56db9d33da9572ce1070e914fd6dd687 100644 (file)
@@ -1,6 +1,6 @@
 %define major 0
 %define minor 2
-%define patchlevel 57
+%define patchlevel 58
 %define ext_feature 0
 
 Name:           call-manager
index 8aef9a2dd92a27e595111fdab40420cb319c25cd..b187d6b62219ca76b4566e2c997213488abce6a5 100644 (file)
@@ -2193,39 +2193,7 @@ int _callmgr_core_deinit(callmgr_core_data_t *core_data)
        g_free(core_data);
        return 0;
 }
-/*
-int _callmgr_core_get_audio_state(callmgr_core_data_t *core_data, callmgr_path_type_e *o_audio_state)
-{
-       CM_RETURN_VAL_IF_FAIL(core_data, -1);
-       dbg("_callmgr_core_get_audio_state is called");
-       callmgr_audio_device_e active_device = CALLMGR_AUDIO_DEVICE_NONE_E;
-       if (_callmgr_audio_get_active_device(core_data->audio_handle, &active_device) < 0) {
-               err("_callmgr_audio_get_active_device() failed");
-               return -1;
-       }
 
-       switch(active_device) {
-               case CALLMGR_AUDIO_DEVICE_SPEAKER_E:
-                       *o_audio_state = CALL_AUDIO_PATH_SPEAKER_E;
-                       break;
-               case CALLMGR_AUDIO_DEVICE_RECEIVER_E:
-                       *o_audio_state = CALL_AUDIO_PATH_RECEIVER_E;
-                       break;
-               case CALLMGR_AUDIO_DEVICE_EARJACK_E:
-                       *o_audio_state = CALL_AUDIO_PATH_EARJACK_E;
-                       break;
-               case CALLMGR_AUDIO_DEVICE_BT_E:
-                       *o_audio_state = CALL_AUDIO_PATH_BT_E;
-                       break;
-               default:
-                       err("Invalid device type: [%d]", active_device);
-                       *o_audio_state = CALL_AUDIO_PATH_NONE_E;
-                       break;
-       }
-
-       return 0;
-}
-*/
 int _callmgr_core_get_audio_state(callmgr_core_data_t *core_data, callmgr_path_type_e *o_audio_state)
 {
        CM_RETURN_VAL_IF_FAIL(core_data, -1);
index e8c6e7ef04be577f55395c999d7f915d5f1db7a4..e4d77fee94a73eb7940e700e4d2214288b87c481 100644 (file)
@@ -939,6 +939,22 @@ static gboolean __set_popup_result_handler(GDBusInterfaceSkeleton *di,
        return TRUE;
 }
 
+static gboolean __set_cool_down_status_handler(GDBusInterfaceSkeleton *di,
+       GDBusMethodInvocation *invoc, const gchar *status, gpointer user_data)
+{
+       int result = 0;
+
+       dbg("__set_cool_down_status_handler() is called");
+       callmgr_core_data_t *core_data = (callmgr_core_data_t *)user_data;
+       CM_RETURN_VAL_IF_FAIL(core_data, FALSE);
+
+       result = _callmgr_cooldown_set_cooldown_status(core_data->cooldown_handle, status);
+       g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", result));
+
+       return TRUE;
+}
+
+
 /********************************************/
 static gchar *__callmgr_dbus_convert_name_to_path(const gchar *name)
 {
@@ -1054,6 +1070,7 @@ static int __callmgr_dbus_init_handlers(callmgr_core_data_t *core_data)
        g_signal_connect(di, "handle-get-answering-machine-status", G_CALLBACK(__get_answering_machine_status_handler), core_data);
        g_signal_connect(di, "handle-get-video-recording-status", G_CALLBACK(__get_video_recording_status_handler), core_data);
        g_signal_connect(di, "handle-set-popup-result", G_CALLBACK(__set_popup_result_handler), core_data);
+       g_signal_connect(di, "handle-set-cool-down-status", G_CALLBACK(__set_cool_down_status_handler), core_data);
 
        __callmgr_dbus_object_export(core_data, di, CALLMGR_DBUS_PATH);
        core_data->dbus_skeleton_interface = di;