From: Youngjae Cho Date: Thu, 3 Sep 2020 03:19:41 +0000 (+0900) Subject: Use libsyscommon X-Git-Tag: accepted/tizen/unified/20201106.130151^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d0997cfca3a4268a86aa2ea3b59414c3469af2ed;p=platform%2Fcore%2Fapi%2Fdevice.git Use libsyscommon To eliminate dbus proxy in device api, use libsyscommon instead. Change-Id: I43c2c2c14278d20dc97b106842d3b536c0eb840a Signed-off-by: Youngjae Cho Signed-off-by: lokilee73 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 00c20d0..1c7a067 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ SET(PKG_MODULES capi-system-info gio-2.0 tracker + libsyscommon ) INCLUDE(FindPkgConfig) diff --git a/include/display-internal.h b/include/display-internal.h index a50b87b..2ad3811 100644 --- a/include/display-internal.h +++ b/include/display-internal.h @@ -20,6 +20,7 @@ #include +#include #include "device-error.h" #include "display-enum.h" @@ -97,8 +98,6 @@ int device_display_get_max_brightness_state(int display_index, display_state_e s */ int device_display_set_brightness_state(int display_index, display_state_e state, int brightness); -typedef void (*device_dbus_pending_cb)(void *data, GVariant *result, GError *err); - /** * @brief Change display state by a specific reason * @since_tizen @if MOBILE 5.0 @elseif WEARABLE 5.0 @endif @@ -118,7 +117,7 @@ typedef void (*device_dbus_pending_cb)(void *data, GVariant *result, GError *err * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed * @see device_display_change_state_by_reason() */ -int device_display_change_state_by_reason(display_state_e type, const char *reason, int timeout, device_dbus_pending_cb cb); +int device_display_change_state_by_reason(display_state_e type, const char *reason, int timeout, dbus_pending_cb cb); #ifdef __cplusplus } #endif diff --git a/include/touchscreen-internal.h b/include/touchscreen-internal.h index 657118e..900b41d 100644 --- a/include/touchscreen-internal.h +++ b/include/touchscreen-internal.h @@ -2,9 +2,9 @@ #define __TIZEN_SYSTEM_TOUCHSCREEN_INTERNAL_H__ #include -typedef void (*device_dbus_pending_cb)(void *data, GVariant *result, GError *err); +#include -int device_touchscreen_enable(device_dbus_pending_cb cb); -int device_touchscreen_disable(device_dbus_pending_cb cb); +int device_touchscreen_enable(dbus_pending_cb cb); +int device_touchscreen_disable(dbus_pending_cb cb); #endif diff --git a/packaging/capi-system-device.spec b/packaging/capi-system-device.spec index 090c36f..8700293 100644 --- a/packaging/capi-system-device.spec +++ b/packaging/capi-system-device.spec @@ -13,6 +13,7 @@ BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(tracker) +BuildRequires: pkgconfig(libsyscommon) %if 0%{?gcov:1} BuildRequires: lcov %endif diff --git a/src/battery.c b/src/battery.c index b628f36..8983bb9 100644 --- a/src/battery.c +++ b/src/battery.c @@ -22,11 +22,11 @@ #include #define _GNU_SOURCE #include +#include #include "battery.h" #include "battery-internal.h" #include "common.h" -#include "dbus.h" #include #define METHOD_GET_PERCENT "GetPercent" @@ -76,7 +76,7 @@ int device_battery_get_percent(int *percent) if (!ret) return DEVICE_ERROR_NOT_SUPPORTED; - ret = dbus_method_sync_var(DEVICED_BUS_NAME, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_BATTERY, DEVICED_INTERFACE_BATTERY, METHOD_GET_PERCENT, NULL); /* regard not suppoted as disconnected */ @@ -170,14 +170,12 @@ int device_battery_get_info(struct device_battery_info *info) if (!ret) return DEVICE_ERROR_NOT_SUPPORTED; - ret = dbus_method_sync_with_reply_var(DEVICED_BUS_NAME, + output = dbus_handle_method_sync_with_reply_var(DEVICED_BUS_NAME, DEVICED_PATH_BATTERY, DEVICED_INTERFACE_BATTERY, - METHOD_GET_INFO, NULL, &output); - /* regard not suppoted as disconnected */ - if (ret == -ENOTSUP) - ret = 0; //LCOV_EXCL_LINE System Error - else if (ret < 0) - return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error + METHOD_GET_INFO, NULL); + + if (!output) + return DEVICE_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE System Error g_variant_get(output, "(isssiiiiiiii)", &ret, &status, &health, &power_source, diff --git a/src/callback.c b/src/callback.c index ff96a74..5e2dd59 100644 --- a/src/callback.c +++ b/src/callback.c @@ -21,12 +21,12 @@ #include #include #include +#include #include "callback.h" #include "battery.h" #include "display.h" #include "common.h" -#include "dbus.h" #include "list.h" #define SIGNAL_FLASH_STATE "ChangeFlashState" diff --git a/src/dbus.c b/src/dbus.c deleted file mode 100644 index bf7d1fe..0000000 --- a/src/dbus.c +++ /dev/null @@ -1,566 +0,0 @@ -/* - * system-dbus - * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. - * - * 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. - */ - - -#include -#include -#include -#include -#include - -#include "common.h" -#include "dbus.h" - -#define DBUS_REPLY_TIMEOUT (-1) -#define SIGNAL_VIBRATOR_INITIATED "InitiateVibrator" -#define DBUS_MAXIMUM_NAME_LENGTH 255 - -struct pending_call_data { - device_dbus_pending_cb func; - void *data; -}; - -struct proxy_node { - GDBusProxy *proxy; - char *dest; - char *path; - char *interface; -}; - -static guint haptic_id = 0; -static GList *proxy_pool; -static pthread_mutex_t dmutex = PTHREAD_MUTEX_INITIALIZER; -static int bus_init; - -//LCOV_EXCL_START System Error -static int g_dbus_error_to_errno(int code) -{ - /** - * if device is not supported, - * deviced does not register the method call of the device. - * in this case, dbus will return UNKNOWN_METHOD error. - */ - /* refer to gio/gioenums.h */ - if (code == G_DBUS_ERROR_ACCESS_DENIED) - return -EACCES; - else if (code == G_DBUS_ERROR_UNKNOWN_METHOD) - return -ENOTSUP; - return -ECOMM; -} -//LCOV_EXCL_STOP - -static GVariant *append_g_variant(const char *sig, const char *param[]) -{ - GVariantBuilder builder; - GVariantBuilder *sub_builder; - GVariant *var; - struct dbus_int *array_int; - char *ch; - int i, j; - - if (!sig || !param) - return NULL; - - g_variant_builder_init(&builder, G_VARIANT_TYPE_TUPLE); - - for (ch = (char*)sig, i = 0; *ch != '\0'; ++i, ++ch) { - switch (*ch) { - case 'i': - g_variant_builder_add(&builder, "i", atoi(param[i])); - break; - case 'u': - g_variant_builder_add(&builder, "u", strtoul(param[i], NULL, 10)); - break; - case 't': - g_variant_builder_add(&builder, "t", atoll(param[i])); - break; - case 's': - g_variant_builder_add(&builder, "s", param[i]); - break; - case 'a': - ++ch; - switch (*ch) { - case 'i': - sub_builder = g_variant_builder_new(G_VARIANT_TYPE("ai")); - array_int = (struct dbus_int *)param[i]; - for (j = 0; j < array_int->size; j++) - g_variant_builder_add(sub_builder, "i", array_int->list[j]); - var = g_variant_new("ai", sub_builder); - g_variant_builder_unref(sub_builder); - g_variant_builder_add_value(&builder, var); - break; - default: - break; - } - break; - default: - return NULL; - } - } - - return g_variant_builder_end(&builder); -} - -static struct proxy_node *find_matched_proxy_node(const char *dest, - const char *path, - const char *interface) -{ - GList *elem; - struct proxy_node *node; - int plen; - - if (!dest || !path || !interface) - return NULL; - - plen = strlen(path) + 1; - - /* find matched proxy object */ - for (elem = proxy_pool; elem; elem = elem->next) { - node = elem->data; - if (!node) - continue; - if (!strncmp(node->dest, dest, DBUS_MAXIMUM_NAME_LENGTH) && - !strncmp(node->path, path, plen) && - !strncmp(node->interface, interface, - DBUS_MAXIMUM_NAME_LENGTH)) - return node; - } - - return NULL; -} - -//LCOV_EXCL_START Not called Callback -static void on_name_vanished(GDBusConnection *connection, - const gchar *name, - gpointer user_data) -{ - GList *elem; - GList *next; - struct proxy_node *node; - - pthread_mutex_lock(&dmutex); - for (elem = proxy_pool, next = g_list_next(elem); elem; - elem = next, next = g_list_next(elem)) { - node = elem->data; - if (!node) - continue; - proxy_pool = g_list_delete_link(proxy_pool, elem); - g_object_unref(node->proxy); - free(node->dest); - free(node->path); - free(node->interface); - free(node); - } - pthread_mutex_unlock(&dmutex); -} -//LCOV_EXCL_STOP - -static GDBusProxy *get_proxy_from_proxy_pool(const char *dest, - const char *path, - const char *interface, - GError **err) -{ - GDBusConnection *conn; - GDBusProxy *proxy; - struct proxy_node *node; - - if (!dest || !path || !interface) { -//LCOV_EXCL_START System Error - if (err) - g_set_error(err, G_IO_ERROR, - G_IO_ERROR_INVALID_ARGUMENT, - "Cannot determine destination address"); - return NULL; -//LCOV_EXCL_STOP - } - - /* find matched proxy node in proxy pool */ - node = find_matched_proxy_node(dest, path, interface); - if (node) - return node->proxy; - - conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, err); - if (!conn) - return NULL; - - if (!bus_init) { - bus_init++; - g_bus_watch_name_on_connection(conn, - DEVICED_BUS_NAME, - G_BUS_NAME_WATCHER_FLAGS_NONE, - NULL, - on_name_vanished, - NULL, - NULL); - } - - proxy = g_dbus_proxy_new_sync(conn, - G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | - G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS, - NULL, /* GDBusinterfaceinfo */ - dest, /* bus name */ - path, /* object path */ - interface, /* interface name */ - NULL, /* GCancellable */ - err); - if (!proxy) - return NULL; - - node = malloc(sizeof(struct proxy_node)); - if (!node) { -//LCOV_EXCL_START System Error - g_object_unref(proxy); - if (err) - g_set_error(err, G_IO_ERROR, - G_IO_ERROR_FAILED, - "Cannot allocate proxy_node memory"); - return NULL; -//LCOV_EXCL_STOP - } - - node->proxy = proxy; - node->dest = strdup(dest); - node->path = strdup(path); - node->interface = strdup(interface); - - proxy_pool = g_list_append(proxy_pool, node); - - return proxy; -} - -int dbus_method_sync_var(const char *dest, const char *path, - const char *interface, const char *method, GVariant *param) -{ - GDBusProxy *proxy; - GError *err = NULL; - GVariant *output; - int result; - -#if !GLIB_CHECK_VERSION(2, 35, 0) - g_type_init(); -#endif - - pthread_mutex_lock(&dmutex); - proxy = get_proxy_from_proxy_pool(dest, path, interface, &err); -//LCOV_EXCL_START System Error - if (!proxy) { - pthread_mutex_unlock(&dmutex); - _E("fail to get proxy from proxy pool : %s.%s (%d-%s)", - interface, method, err->code, err->message); - result = g_dbus_error_to_errno(err->code); - g_clear_error(&err); - return result; - } -//LCOV_EXCL_STOP - output = g_dbus_proxy_call_sync(proxy, - method, /* method name */ - param, /* parameters */ - G_DBUS_CALL_FLAGS_NONE, - DBUS_REPLY_TIMEOUT, /* timeout */ - NULL, /* GCancellable */ - &err); - pthread_mutex_unlock(&dmutex); - -//LCOV_EXCL_START System Error - if (!output) { - if (!err) { - _E("g_dbus_proxy_call_sync error : %s.%s", - interface, method); - return -EPERM; - } - _E("g_dbus_proxy_call_sync error : %s.%s (%d-%s)", - interface, method, err->code, err->message); - result = g_dbus_error_to_errno(err->code); - g_clear_error(&err); - return result; -//LCOV_EXCL_STOP - } - - /* get output value */ - g_variant_get(output, "(i)", &result); - - g_variant_unref(output); - - return result; -} - -//LCOV_EXCL_START Not used function -int dbus_method_sync(const char *dest, const char *path, - const char *interface, const char *method, - const char *sig, const char *param[]) -{ - return dbus_method_sync_var(dest, - path, - interface, - method, - append_g_variant(sig, param)); -} -//LCOV_EXCL_STOP - -int dbus_method_sync_with_reply_var(const char *dest, - const char *path, const char *interface, - const char *method, GVariant *param, GVariant **info) -{ - GDBusProxy *proxy; - GError *err = NULL; - GVariant *output; - int result; - -#if !GLIB_CHECK_VERSION(2, 35, 0) - g_type_init(); -#endif - - pthread_mutex_lock(&dmutex); - proxy = get_proxy_from_proxy_pool(dest, path, interface, &err); - if (!proxy) { -//LCOV_EXCL_START System Error - pthread_mutex_unlock(&dmutex); - _E("fail to get proxy from proxy pool : %s.%s (%d-%s)", - interface, method, err->code, err->message); - result = g_dbus_error_to_errno(err->code); - g_clear_error(&err); - return result; -//LCOV_EXCL_STOP - } - - output = g_dbus_proxy_call_sync(proxy, - method, /* method name */ - param, /* parameters */ - G_DBUS_CALL_FLAGS_NONE, - DBUS_REPLY_TIMEOUT, /* timeout */ - NULL, /* GCancellable */ - &err); - pthread_mutex_unlock(&dmutex); - if (!output) { -//LCOV_EXCL_START System Error - if (!err) { - _E("g_dbus_proxy_call_sync error : %s.%s", - interface, method); - return -EPERM; - } - _E("g_dbus_proxy_call_sync error : %s.%s (%d-%s)", - interface, method, err->code, err->message); - result = g_dbus_error_to_errno(err->code); - g_clear_error(&err); - return result; -//LCOV_EXCL_STOP - } - - *info = output; - return DEVICE_ERROR_NONE; -} - -//LCOV_EXCL_START Not used function -int dbus_method_sync_with_reply(const char *dest, - const char *path, const char *interface, - const char *method, const char *sig, - const char *param[], GVariant **info) -{ - return dbus_method_sync_with_reply_var(dest, - path, - interface, - method, - append_g_variant(sig, param), - info); -} -//LCOV_EXCL_STOP - -static void cb_pending(GDBusProxy *proxy, - GAsyncResult *res, - gpointer user_data) -{ - struct pending_call_data *data = user_data; - GError *err = NULL; - GVariant *output; - - output = g_dbus_proxy_call_finish(proxy, - res, /* GAsyncResult */ - &err); - if (!output) - _E("g_dbus_proxy_call_finish error : %d-%s", //LCOV_EXCL_LINE Logs - err?err->code:0, err?err->message:"NULL"); - - if (data && data->func) - data->func(data->data, output, err); - free(data); - - if (err) -//LCOV_EXCL_START System Error - g_clear_error(&err); -//LCOV_EXCL_STOP - if (output) - g_variant_unref(output); -} - -int dbus_method_async_with_reply_var(const char *dest, const char *path, - const char *interface, const char *method, - GVariant *param, - device_dbus_pending_cb cb, int timeout, void *data) -{ - GDBusProxy *proxy; - GError *err = NULL; - struct pending_call_data *pdata; - int result; - -#if !GLIB_CHECK_VERSION(2, 35, 0) - g_type_init(); -#endif - - pthread_mutex_lock(&dmutex); - proxy = get_proxy_from_proxy_pool(dest, path, interface, &err); - if (!proxy) { -//LCOV_EXCL_START System Error - pthread_mutex_unlock(&dmutex); - _E("fail to get proxy from proxy pool : %s.%s (%d-%s)", - interface, method, err->code, err->message); - result = g_dbus_error_to_errno(err->code); - g_clear_error(&err); - return result; -//LCOV_EXCL_STOP - } - - pdata = malloc(sizeof(struct pending_call_data)); - if (!pdata) { - pthread_mutex_unlock(&dmutex); -//LCOV_EXCL_START System Error - _E("malloc error : %s.%s", interface, method); - return -ENOMEM; -//LCOV_EXCL_STOP - } - - pdata->func = cb; - pdata->data = data; - - g_dbus_proxy_call(proxy, - method, /* method name */ - param, /* parameters */ - G_DBUS_CALL_FLAGS_NONE, - DBUS_REPLY_TIMEOUT, /* timeout */ - NULL, /* GCancellable */ - (GAsyncReadyCallback)cb_pending, /* GAsyncReadyCallback */ - pdata); /* user data */ - pthread_mutex_unlock(&dmutex); - - return 0; -} - -int dbus_method_async_with_reply(const char *dest, const char *path, - const char *interface, const char *method, - const char *sig, const char *param[], - device_dbus_pending_cb cb, int timeout, void *data) -{ - return dbus_method_async_with_reply_var(dest, - path, - interface, - method, - append_g_variant(sig, param), - cb, - timeout, - data); -} - -//LCOV_EXCL_START Not called Callback -static void haptic_signal_callback(GDBusConnection *conn, - const gchar *sender, - const gchar *path, - const gchar *iface, - const gchar *signal, - GVariant *params, - gpointer user_data) -{ - size_t iface_len, signal_len; - - if (!params || !sender || !path || !iface || !signal) - return; - - iface_len = strlen(iface) + 1; - signal_len = strlen(signal) + 1; - - if (strncmp(iface, VIBRATOR_INTERFACE_HAPTIC, iface_len)) - return; - - if (strncmp(signal, SIGNAL_VIBRATOR_INITIATED, signal_len)) - return; - - restart_callback(); -} -//LCOV_EXCL_STOP - -int register_signal_handler(void) -{ - GDBusConnection *conn; - GError *err = NULL; - int result = 0; - - conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err); - if (!conn) { -//LCOV_EXCL_START System Error - if (err) { - _E("g_bus_get_sync error : (%d-%s)", err->code, err->message); - result = g_dbus_error_to_errno(err->code); - g_clear_error(&err); - } - return result; -//LCOV_EXCL_STOP - } - - haptic_id = g_dbus_connection_signal_subscribe(conn, - NULL, - VIBRATOR_INTERFACE_HAPTIC, - NULL, - VIBRATOR_PATH_HAPTIC, - NULL, - G_DBUS_SIGNAL_FLAGS_NONE, - haptic_signal_callback, - NULL, - NULL); - - g_object_unref(conn); - if (haptic_id == 0) { -//LCOV_EXCL_START System Error - _E("Failed to subscrive bus signal"); - return -EPERM; -//LCOV_EXCL_STOP - } - - return 0; -} - -int unregister_signal_handler(void) -{ - GDBusConnection *conn; - GError *err = NULL; - int result = 0; - - conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err); - if (!conn) { -//LCOV_EXCL_START System Error - if (err) { - _E("g_bus_get_sync error : (%d-%s)", err->code, err->message); - result = g_dbus_error_to_errno(err->code); - g_clear_error(&err); - } - return result; -//LCOV_EXCL_STOP - } - - g_dbus_connection_signal_unsubscribe(conn, haptic_id); - g_object_unref(conn); - - return 0; -} diff --git a/src/dbus.h b/src/dbus.h deleted file mode 100644 index 11cde7f..0000000 --- a/src/dbus.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * system-dbus - * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. - * - * 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 __DBUS_H__ -#define __DBUS_H__ - -#include - -#define DEVICED_BUS_NAME "org.tizen.system.deviced" -#define DEVICED_OBJECT_PATH "/Org/Tizen/System/DeviceD" -#define DEVICED_INTERFACE_NAME DEVICED_BUS_NAME - -/* PmQos service: operations about pmqos */ -#define DEVICED_PATH_PMQOS DEVICED_OBJECT_PATH"/PmQos" -#define DEVICED_INTERFACE_PMQOS DEVICED_INTERFACE_NAME".PmQos" - -/* Display service: start/stop display(pm), get/set brightness operations about display */ -#define DEVICED_PATH_DISPLAY DEVICED_OBJECT_PATH"/Display" -#define DEVICED_INTERFACE_DISPLAY DEVICED_INTERFACE_NAME".display" - -/* Battery service */ -#define DEVICED_PATH_BATTERY DEVICED_OBJECT_PATH"/Battery" -#define DEVICED_INTERFACE_BATTERY DEVICED_INTERFACE_NAME".Battery" - -/* Haptic service: operations about haptic */ -#define VIBRATOR_BUS_NAME "org.tizen.system.vibrator" -#define VIBRATOR_OBJECT_PATH "/Org/Tizen/System/Vibrator" -#define VIBRATOR_INTERFACE_NAME VIBRATOR_BUS_NAME - -#define VIBRATOR_PATH_HAPTIC VIBRATOR_OBJECT_PATH"/Haptic" -#define VIBRATOR_INTERFACE_HAPTIC VIBRATOR_INTERFACE_NAME".haptic" - -/* Led service: play/stop led operations about led */ -#define DEVICED_PATH_LED DEVICED_OBJECT_PATH"/Led" -#define DEVICED_INTERFACE_LED DEVICED_INTERFACE_NAME".Led" - -/* Power service: request to reboot */ -#define DEVICED_PATH_POWER DEVICED_OBJECT_PATH"/Power" -#define DEVICED_INTERFACE_POWER DEVICED_INTERFACE_NAME".power" - -/* Reboot service: request reboot operation */ -#define DEVICED_PATH_POWEROFF DEVICED_OBJECT_PATH"/PowerOff" -#define DEVICED_INTERFACE_POWEROFF DEVICED_INTERFACE_NAME".PowerOff" - -/* IR service: transmit IR commands */ -#define DEVICED_PATH_IR DEVICED_OBJECT_PATH"/Ir" -#define DEVICED_INTERFACE_IR DEVICED_INTERFACE_NAME".ir" - -/* Thermal service: operations about temperature */ -#define DEVICED_PATH_TEMPERATURE DEVICED_OBJECT_PATH"/Temperature" -#define DEVICED_INTERFACE_TEMPERATURE DEVICED_INTERFACE_NAME".temperature" - -/* Touchscreen service: operations about touchscreen */ -#define DEVICED_PATH_TOUCH DEVICED_OBJECT_PATH"/Touch" -#define DEVICED_INTERFACE_TOUCH DEVICED_INTERFACE_NAME".touch" - -struct dbus_int { - int *list; - int size; -}; - -int dbus_method_sync_var(const char *dest, const char *path, - const char *interface, const char *method, GVariant *param); -int dbus_method_sync(const char *dest, const char *path, - const char *interface, const char *method, - const char *sig, const char *param[]); -int dbus_method_sync_with_reply_var(const char *dest, - const char *path, const char *interface, - const char *method, GVariant *param, GVariant **info); -int dbus_method_sync_with_reply(const char *dest, - const char *path, const char *interface, - const char *method, const char *sig, - const char *param[], GVariant **info); - -/** - * If result is NULL, err is set. - * Do not invoke g_variant_unref() with result. - */ -typedef void (*device_dbus_pending_cb)(void *data, GVariant *result, GError *err); - -int dbus_method_async_with_reply_var(const char *dest, const char *path, - const char *interface, const char *method, - GVariant *param, - device_dbus_pending_cb cb, int timeout, void *data); -int dbus_method_async_with_reply(const char *dest, const char *path, - const char *interface, const char *method, - const char *sig, const char *param[], device_dbus_pending_cb cb, int timeout, void *data); - -void restart_callback(void); - -int register_signal_handler(void); -int unregister_signal_handler(void); -#endif diff --git a/src/display.c b/src/display.c index 1d8dd15..315cb0e 100644 --- a/src/display.c +++ b/src/display.c @@ -18,11 +18,11 @@ #include #include #include +#include #include "display.h" #include "display-internal.h" #include "common.h" -#include "dbus.h" #define METHOD_GET_DISPLAY_COUNT "GetDisplayCount" #define METHOD_GET_MAX_BRIGHTNESS "GetMaxBrightness" @@ -73,7 +73,7 @@ int device_display_get_numbers(int *device_number) /* if it is a first request */ if (display_cnt < 0) { - ret = dbus_method_sync_var(DEVICED_BUS_NAME, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, METHOD_GET_DISPLAY_COUNT, NULL); if (ret < 0) @@ -111,7 +111,7 @@ int device_display_get_max_brightness(int display_index, int *max_brightness) return DEVICE_ERROR_OPERATION_FAILED; if (display_arr[display_index].normal_max < 0) { - ret = dbus_method_sync_var(DEVICED_BUS_NAME, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, METHOD_GET_MAX_BRIGHTNESS, g_variant_new("(i)", (int)DISPLAY_STATE_NORMAL)); if (ret < 0) @@ -143,7 +143,7 @@ int device_display_get_brightness(int display_index, int *brightness) if (display_index < 0 || display_index >= display_cnt) return DEVICE_ERROR_INVALID_PARAMETER; - ret = dbus_method_sync_var(DEVICED_BUS_NAME, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, METHOD_GET_BRIGHTNESS, g_variant_new("(i)", (int)DISPLAY_STATE_NORMAL)); if (ret < 0) @@ -176,7 +176,7 @@ int device_display_set_brightness(int display_index, int brightness) if (brightness < 0 || brightness > display_arr[display_index].normal_max) return DEVICE_ERROR_INVALID_PARAMETER; - ret = dbus_method_sync_var(DEVICED_BUS_NAME, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, METHOD_SET_BRIGHTNESS, g_variant_new("(ii)", (int)DISPLAY_STATE_NORMAL, brightness)); if (ret < 0) @@ -227,7 +227,7 @@ static char *get_state_str(display_state_e state) return NULL; } -static void change_cb(void *data, GVariant *result, GError *err) +static void change_cb(GVariant *result, void *data, GError *err) { int ret; @@ -265,7 +265,7 @@ int device_display_change_state(display_state_e state) return DEVICE_ERROR_INVALID_PARAMETER; if (privilege < 0) { - ret = dbus_method_sync_var(DEVICED_BUS_NAME, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, METHOD_CHANGE_STATE, g_variant_new("(s)", "privilege check")); //LCOV_EXCL_START System Error @@ -280,7 +280,7 @@ int device_display_change_state(display_state_e state) if (!str) return DEVICE_ERROR_INVALID_PARAMETER; - return dbus_method_async_with_reply_var(DEVICED_BUS_NAME, + return dbus_handle_method_async_with_reply_var(DEVICED_BUS_NAME, DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, METHOD_CHANGE_STATE, g_variant_new("(s)", str), change_cb, -1, NULL); } @@ -311,7 +311,7 @@ int device_display_get_max_brightness_state(int display_index, display_state_e s if (!display_arr && alloc_display() < 0) return DEVICE_ERROR_OPERATION_FAILED; - ret = dbus_method_sync_var(DEVICED_BUS_NAME, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, METHOD_GET_MAX_BRIGHTNESS, g_variant_new("(i)", (int)state)); if (ret < 0) @@ -352,7 +352,7 @@ int device_display_get_brightness_state(int display_index, display_state_e state if (display_index < 0 || display_index >= display_cnt) return DEVICE_ERROR_INVALID_PARAMETER; - ret = dbus_method_sync_var(DEVICED_BUS_NAME, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, METHOD_GET_BRIGHTNESS, g_variant_new("(i)", (int)state)); if (ret < 0) @@ -400,7 +400,7 @@ int device_display_set_brightness_state(int display_index, display_state_e state break; } - ret = dbus_method_sync_var(DEVICED_BUS_NAME, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, METHOD_SET_BRIGHTNESS, g_variant_new("(ii)", (int)state, brightness)); if (ret < 0) @@ -409,11 +409,11 @@ int device_display_set_brightness_state(int display_index, display_state_e state return DEVICE_ERROR_NONE; } -int device_display_change_state_by_reason(display_state_e type, const char *reason, int timeout, device_dbus_pending_cb cb) +int device_display_change_state_by_reason(display_state_e type, const char *reason, int timeout, dbus_pending_cb cb) { int ret; - ret = dbus_method_async_with_reply_var(DEVICED_BUS_NAME, + ret = dbus_handle_method_async_with_reply_var(DEVICED_BUS_NAME, DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, METHOD_CHANGE_STATE_BY_REASON, g_variant_new("(isi)", (int)type, reason, timeout), cb, -1, NULL); diff --git a/src/haptic.c b/src/haptic.c index 2f339dd..19d7383 100644 --- a/src/haptic.c +++ b/src/haptic.c @@ -21,12 +21,14 @@ #include #include #include +#include #include "haptic.h" #include "common.h" -#include "dbus.h" #include "list.h" +#define SIGNAL_VIBRATOR_INITIATED "InitiateVibrator" + #define METHOD_GET_COUNT "GetCount" #define METHOD_OPEN_DEVICE "OpenDevice" #define METHOD_CLOSE_DEVICE "CloseDevice" @@ -51,6 +53,7 @@ struct haptic_handle { int handle; }; +static guint haptic_id = 0; static dd_list *handle_list; static int is_haptic_supported(void) @@ -85,7 +88,7 @@ int device_haptic_get_count(int *device_number) return DEVICE_ERROR_NOT_SUPPORTED; /* request to deviced to get haptic count */ - ret = dbus_method_sync_var(VIBRATOR_BUS_NAME, + ret = dbus_handle_method_sync_var(VIBRATOR_BUS_NAME, VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC, METHOD_GET_COUNT, NULL); /** @@ -102,14 +105,14 @@ int device_haptic_get_count(int *device_number) } //LCOV_EXCL_START Not called Callback -void restart_callback(void) +static void restart_callback(void) { dd_list *elem, *elem_next; struct haptic_handle *temp; int ret; DD_LIST_FOREACH_SAFE(handle_list, elem, elem_next, temp) { - ret = dbus_method_sync_var(VIBRATOR_BUS_NAME, + ret = dbus_handle_method_sync_var(VIBRATOR_BUS_NAME, VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC, METHOD_OPEN_DEVICE, g_variant_new("(i)", temp->index)); if (ret < 0) { @@ -122,6 +125,33 @@ void restart_callback(void) } //LCOV_EXCL_STOP +//LCOV_EXCL_START Not called Callback +static void haptic_signal_callback(GDBusConnection *conn, + const gchar *sender, + const gchar *path, + const gchar *iface, + const gchar *signal, + GVariant *param, + gpointer data) +{ + size_t iface_len, signal_len; + + if (!param || !sender || !path || !iface || !signal) + return; + + iface_len = strlen(iface) + 1; + signal_len = strlen(signal) + 1; + + if (strncmp(iface, VIBRATOR_INTERFACE_HAPTIC, iface_len)) + return; + + if (strncmp(signal, SIGNAL_VIBRATOR_INITIATED, signal_len)) + return; + + restart_callback(); +} +//LCOV_EXCL_STOP + int device_haptic_open(int device_index, haptic_device_h *device_handle) { dd_list *elem, *elem_next; @@ -145,7 +175,7 @@ int device_haptic_open(int device_index, haptic_device_h *device_handle) return DEVICE_ERROR_NOT_SUPPORTED; /* request to deviced to open haptic device */ - ret = dbus_method_sync_var(VIBRATOR_BUS_NAME, + ret = dbus_handle_method_sync_var(VIBRATOR_BUS_NAME, VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC, METHOD_OPEN_DEVICE, g_variant_new("(i)", device_index)); if (ret < 0) @@ -174,8 +204,14 @@ int device_haptic_open(int device_index, haptic_device_h *device_handle) *device_handle = (haptic_device_h)handle; } if (DD_LIST_LENGTH(handle_list) == 1) { - ret = register_signal_handler(); - if (ret < 0) + haptic_id = subscribe_dbus_signal(NULL, + VIBRATOR_PATH_HAPTIC, + VIBRATOR_INTERFACE_HAPTIC, + NULL, + haptic_signal_callback, + NULL, + NULL); + if (haptic_id <= 0) _E("Faild to register signal handler"); //LCOV_EXCL_LINE Logs } @@ -209,7 +245,7 @@ int device_haptic_close(haptic_device_h device_handle) DD_LIST_REMOVE(handle_list, handle); /* request to deviced to open haptic device */ - ret = dbus_method_sync_var(VIBRATOR_BUS_NAME, + ret = dbus_handle_method_sync_var(VIBRATOR_BUS_NAME, VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC, METHOD_CLOSE_DEVICE, g_variant_new("(u)", (unsigned int)handle->handle)); @@ -218,11 +254,8 @@ int device_haptic_close(haptic_device_h device_handle) if (ret < 0) return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error - if (DD_LIST_LENGTH(handle_list) == 0) { - ret = unregister_signal_handler(); - if (ret < 0) - _E("Failed to unregister signal handler"); //LCOV_EXCL_LINE Logs - } + if (DD_LIST_LENGTH(handle_list) == 0) + unsubscribe_dbus_signal(NULL, haptic_id); return DEVICE_ERROR_NONE; } @@ -260,7 +293,7 @@ int device_haptic_vibrate(haptic_device_h device_handle, int duration, int feedb return DEVICE_ERROR_INVALID_PARAMETER; /* request to deviced to vibrate haptic device */ - ret = dbus_method_sync_var(VIBRATOR_BUS_NAME, + ret = dbus_handle_method_sync_var(VIBRATOR_BUS_NAME, VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC, METHOD_VIBRATE_MONOTONE, g_variant_new("(uiii)", (unsigned int)handle->handle, duration, feedback, priority)); @@ -300,7 +333,7 @@ int device_haptic_stop(haptic_device_h device_handle, haptic_effect_h effect_han /* TODO : support to stop haptic effect */ /* request to deviced to open haptic device */ - ret = dbus_method_sync_var(VIBRATOR_BUS_NAME, + ret = dbus_handle_method_sync_var(VIBRATOR_BUS_NAME, VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC, METHOD_STOP_DEVICE, g_variant_new("(u)", (unsigned int)handle->handle)); if (ret < 0) diff --git a/src/ir.c b/src/ir.c index eb90724..3fe7c4c 100644 --- a/src/ir.c +++ b/src/ir.c @@ -16,10 +16,10 @@ #include #include +#include #include "ir.h" #include "common.h" -#include "dbus.h" #define METHOD_IS_AVAILABLE "IRIsAvailable" #define METHOD_TRANSMIT "TransmitIR" @@ -46,7 +46,7 @@ int device_ir_is_available(bool *available) return DEVICE_ERROR_NOT_SUPPORTED; } - ret = dbus_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_IR, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_IR, DEVICED_INTERFACE_IR, METHOD_IS_AVAILABLE, NULL); @@ -95,7 +95,7 @@ int device_ir_transmit(int carrier_frequency, int *pattern, int size) for (i = 0; i < size; ++i) g_variant_builder_add(builder, "i", pattern[i]); - ret = dbus_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_IR, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_IR, DEVICED_INTERFACE_IR, METHOD_TRANSMIT, g_variant_new("(ai)", builder)); diff --git a/src/led.c b/src/led.c index 832ed26..bbb00a9 100644 --- a/src/led.c +++ b/src/led.c @@ -19,11 +19,11 @@ #include #include #include +#include #include "led.h" #include "led-internal.h" #include "common.h" -#include "dbus.h" #define METHOD_GET_MAX_BRIGHTNESS "GetMaxBrightness" #define METHOD_GET_BRIGHTNESS "GetBrightness" @@ -64,7 +64,7 @@ int device_flash_get_max_brightness(int *max_brightness) if (!max_brightness) return DEVICE_ERROR_INVALID_PARAMETER; - ret = dbus_method_sync_var(DEVICED_BUS_NAME, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_LED, DEVICED_INTERFACE_LED, METHOD_GET_MAX_BRIGHTNESS, NULL); if (ret < 0) @@ -84,7 +84,7 @@ int device_flash_get_brightness(int *brightness) if (!brightness) return DEVICE_ERROR_INVALID_PARAMETER; - ret = dbus_method_sync_var(DEVICED_BUS_NAME, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_LED, DEVICED_INTERFACE_LED, METHOD_GET_BRIGHTNESS, NULL); if (ret < 0) @@ -109,7 +109,7 @@ int device_flash_set_brightness(int brightness) return DEVICE_ERROR_INVALID_PARAMETER; /* if camera API preempt a flash device, it will return -EBUSY error. */ - ret = dbus_method_sync_var(DEVICED_BUS_NAME, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_LED, DEVICED_INTERFACE_LED, METHOD_SET_BRIGHTNESS, g_variant_new("(ii)", brightness, 0)); if (ret < 0) @@ -128,7 +128,7 @@ int device_led_play_custom(int on, int off, unsigned int color, unsigned int fla if (on < 0 || off < 0) return DEVICE_ERROR_INVALID_PARAMETER; - ret = dbus_method_sync_var(DEVICED_BUS_NAME, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_LED, DEVICED_INTERFACE_LED, METHOD_PLAY_CUSTOM, g_variant_new("(iiuu)", on, off, (unsigned int)color, (unsigned int)flags)); //LCOV_EXCL_START System Error @@ -146,7 +146,7 @@ int device_led_stop_custom(void) if (!support_front_led) return DEVICE_ERROR_NOT_SUPPORTED; - ret = dbus_method_sync_var(DEVICED_BUS_NAME, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_LED, DEVICED_INTERFACE_LED, METHOD_STOP_CUSTOM, NULL); //LCOV_EXCL_START System Error @@ -168,7 +168,7 @@ int device_multi_led_get_number(int *num_of_leds) return DEVICE_ERROR_INVALID_PARAMETER; if (number_of_devices < 0) { - ret = dbus_method_sync_var(DEVICED_BUS_NAME, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_LED, DEVICED_INTERFACE_LED, METHOD_GET_LED_NUMBER, NULL); if (ret < 0) @@ -206,6 +206,6 @@ int device_multi_led_control(unsigned int color[]) var = g_variant_new("(au)", builder); g_variant_builder_unref(builder); - return dbus_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_LED, + return dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_LED, DEVICED_INTERFACE_LED, METHOD_MULTI_LED_CONTROL, var); } diff --git a/src/pmqos.c b/src/pmqos.c index a860b52..9d732db 100644 --- a/src/pmqos.c +++ b/src/pmqos.c @@ -14,10 +14,10 @@ * limitations under the License. */ +#include #include "pmqos-internal.h" #include "common.h" -#include "dbus.h" #define METHOD_APP_LAUNCH_HOME "AppLaunchHome" #define METHOD_HOMESCREEN "HomeScreen" @@ -29,11 +29,11 @@ int device_pmqos_app_launch_home(int timeout) if (timeout < 0) return DEVICE_ERROR_INVALID_PARAMETER; - ret = dbus_method_sync_var(DEVICED_BUS_NAME, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_PMQOS, DEVICED_INTERFACE_PMQOS, METHOD_APP_LAUNCH_HOME, - g_variant_new("(i)", timeout));; + g_variant_new("(i)", timeout)); if (ret < 0) return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error @@ -47,11 +47,11 @@ int device_pmqos_homescreen(int timeout) if (timeout < 0) return DEVICE_ERROR_INVALID_PARAMETER; - ret = dbus_method_sync_var(DEVICED_BUS_NAME, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_PMQOS, DEVICED_INTERFACE_PMQOS, METHOD_HOMESCREEN, - g_variant_new("(i)", timeout));; + g_variant_new("(i)", timeout)); if (ret < 0) return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error diff --git a/src/power.c b/src/power.c index f41ca3d..0830c9a 100644 --- a/src/power.c +++ b/src/power.c @@ -23,11 +23,11 @@ #include #include #include +#include #include "power.h" #include "display.h" #include "common.h" -#include "dbus.h" /** * Parameters for device_power_request_lock() @@ -128,7 +128,7 @@ static void remove_padding_timeout(void) } //LCOV_EXCL_START Callback function -static void notice_lock_expired_done(void *data, GVariant *result, GError *err) +static void notice_lock_expired_done(GVariant *result, void *data, GError *err) { int val, ret; GList *l, *l_next; @@ -189,7 +189,7 @@ static int notice_power_lock_expired(void) return -ENOMEM; } - ret = dbus_method_async_with_reply_var( + ret = dbus_handle_method_async_with_reply_var( DEVICED_BUS_NAME, DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, @@ -324,7 +324,7 @@ static void add_off_lock_timeout(void) _E("Failed to add Power Lock timeout handler"); //LCOV_EXCL_LINE Logs } -static void lock_cb(void *data, GVariant *result, GError *err) +static void lock_cb(GVariant *result, void *data, GError *err) { int ret; @@ -363,7 +363,7 @@ static int lock_state(display_state_e state, unsigned int flag, int timeout_ms) if (privilege < 0) { arr[0] = "privilege check"; - ret = dbus_method_sync_var(DEVICED_BUS_NAME, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, METHOD_LOCK_STATE, g_variant_new("(sssi)", arr[0], arr[1], arr[2], timeout_ms)); //LCOV_EXCL_START System Error @@ -378,12 +378,12 @@ static int lock_state(display_state_e state, unsigned int flag, int timeout_ms) if (!arr[0]) return -EINVAL; - return dbus_method_async_with_reply_var(DEVICED_BUS_NAME, + return dbus_handle_method_async_with_reply_var(DEVICED_BUS_NAME, DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, METHOD_LOCK_STATE, g_variant_new("(sssi)", arr[0], arr[1], arr[2], timeout_ms), lock_cb, -1, NULL); } -static void unlock_cb(void *data, GVariant *result, GError *err) +static void unlock_cb(GVariant *result, void *data, GError *err) { int ret; @@ -416,7 +416,7 @@ static int unlock_state(display_state_e state, unsigned int flag) if (privilege < 0) { arr[0] = "privilege check"; - ret = dbus_method_sync_var(DEVICED_BUS_NAME, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, METHOD_UNLOCK_STATE, g_variant_new("(ss)", arr[0], arr[1])); //LCOV_EXCL_START System Error @@ -431,7 +431,7 @@ static int unlock_state(display_state_e state, unsigned int flag) if (!arr[0]) return -EINVAL; - return dbus_method_async_with_reply_var(DEVICED_BUS_NAME, + return dbus_handle_method_async_with_reply_var(DEVICED_BUS_NAME, DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, METHOD_UNLOCK_STATE, g_variant_new("(ss)", arr[0], arr[1]), unlock_cb, -1, NULL); } @@ -530,7 +530,7 @@ int device_power_reboot(const char *reason) param = g_variant_new("(s)", TYPE_REBOOT); } - ret = dbus_method_sync_var(DEVICED_BUS_NAME, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_POWEROFF, DEVICED_INTERFACE_POWEROFF, method, param); diff --git a/src/temperature.c b/src/temperature.c index 36e3cb9..29c9786 100644 --- a/src/temperature.c +++ b/src/temperature.c @@ -21,8 +21,9 @@ #include #include #include +#include + #include "common.h" -#include "dbus.h" #include "temperature.h" #define METHOD_GET_TEMPERATURE "GetTemperature" @@ -67,7 +68,7 @@ int device_thermal_get_temperature(device_thermal_e type, int *temp) if (!ret) return DEVICE_ERROR_NOT_SUPPORTED; - ret = dbus_method_sync_var(DEVICED_BUS_NAME, + ret = dbus_handle_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_TEMPERATURE, DEVICED_INTERFACE_TEMPERATURE, METHOD_GET_TEMPERATURE, g_variant_new("(i)", type)); diff --git a/src/touchscreen-internal.c b/src/touchscreen-internal.c index c0939f3..a0da8ec 100644 --- a/src/touchscreen-internal.c +++ b/src/touchscreen-internal.c @@ -14,29 +14,30 @@ * limitations under the License. */ +#include + #include "common.h" -#include "dbus.h" #include "touchscreen-internal.h" #define METHOD_TOUCHSCREEN_ENABLE "Enable" #define METHOD_TOUCHSCREEN_DISABLE "Disable" -int device_touchscreen_enable(device_dbus_pending_cb cb) +int device_touchscreen_enable(dbus_pending_cb cb) { int ret; - ret = dbus_method_async_with_reply(DEVICED_BUS_NAME, + ret = dbus_handle_method_async_with_reply(DEVICED_BUS_NAME, DEVICED_PATH_TOUCH, DEVICED_INTERFACE_TOUCH, METHOD_TOUCHSCREEN_ENABLE, NULL, NULL, cb, -1, NULL); return errno_to_device_error(ret); } -int device_touchscreen_disable(device_dbus_pending_cb cb) +int device_touchscreen_disable(dbus_pending_cb cb) { int ret; - ret = dbus_method_async_with_reply(DEVICED_BUS_NAME, + ret = dbus_handle_method_async_with_reply(DEVICED_BUS_NAME, DEVICED_PATH_TOUCH, DEVICED_INTERFACE_TOUCH, METHOD_TOUCHSCREEN_DISABLE, NULL, NULL, cb, -1, NULL);