SET(PREFIX ${CMAKE_INSTALL_PREFIX})
INCLUDE(FindPkgConfig)
-pkg_check_modules(hal-backend-device-battery_pkgs REQUIRED hal-backend-device-common glib-2.0 gio-2.0)
+pkg_check_modules(hal-backend-device-battery_pkgs REQUIRED hal-backend-device-common glib-2.0 gio-2.0 libsyscommon)
FOREACH(flag ${hal-backend-device-battery_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-ADD_LIBRARY(${PROJECT_NAME} MODULE battery.c ../dbus.c)
+ADD_LIBRARY(${PROJECT_NAME} MODULE battery.c)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-battery_pkgs_LDFLAGS})
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
#include <hal/hal-common-interface.h>
#include <libsyscommon/file.h>
-#include "../dbus.h"
+#include <libsyscommon/dbus-system.h>
#include </hal/include/device/hal-backend-common.h>
void *data;
} sdata = { 0, };
-static int id; /* signal handler id */
+static guint signal_id; /* signal handler id */
static int get_power_source(int online, char **src)
{
return -EEXIST;
}
- ret = register_dbus_signal(BATTERY_OBJECT,
+ signal_id = subscribe_dbus_signal(NULL, BATTERY_OBJECT,
BATTERY_IFACE, BATTERY_SIGNAL,
- signal_delivered, &sdata, &id);
- if (ret < 0) {
+ signal_delivered, &sdata, NULL);
+ if (signal_id < 0) {
_E("Failed to register signal");
return -ENOMEM;
}
static void battery_unregister_changed_event(
BatteryUpdated updated_cb)
{
- unregister_dbus_signal(&id);
+ unsubscribe_dbus_signal(NULL, signal_id);
+ signal_id = 0;
sdata.updated_cb = NULL;
sdata.data = NULL;
}
+++ /dev/null
-/*
- * device-node
- *
- * Copyright (c) 2016 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 "dbus.h"
-
-#include </hal/include/device/hal-backend-common.h>
-
-int register_dbus_signal(const char *object,
- const char *iface, const char *signal,
- GDBusSignalCallback callback, void *data, int *id)
-{
- GError *err = NULL;
- GDBusConnection *conn;
- int sid;
-
-#if !GLIB_CHECK_VERSION(2, 35, 0)
- g_type_init();
-#endif
-
- conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
- if (!conn) {
- _E("fail to get dbus connection : %s", err->message);
- g_clear_error(&err);
- return -EPERM;
- }
-
- /* subscribe signal */
- sid = g_dbus_connection_signal_subscribe(conn,
- NULL, iface, signal, object,
- NULL, G_DBUS_SIGNAL_FLAGS_NONE,
- callback, data, NULL);
- if (sid == 0) {
- _E("fail to connect %s signal", signal);
- return -EPERM;
- }
-
- if (id)
- *id = sid;
-
- return 0;
-}
-
-void unregister_dbus_signal(int *id)
-{
- GError *err = NULL;
- GDBusConnection *conn;
-
- if (!id || *id <= 0)
- return;
-
- conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
- if (!conn) {
- _E("fail to get dbus connection : %s", err->message);
- g_clear_error(&err);
- return;
- }
-
- /* unsubscribe signal */
- g_dbus_connection_signal_unsubscribe(conn, *id);
- *id = 0;
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 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 __HW_DEFAULT_DBUS_H__
-#define __HW_DEFAULT_DBUS_H__
-
-#include <stdio.h>
-#include <errno.h>
-#include <gio/gio.h>
-
-int register_dbus_signal(const char *object,
- const char *iface, const char *signal,
- GDBusSignalCallback callback, void *data, int *id);
-void unregister_dbus_signal(int *id);
-
-#endif
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
INCLUDE(FindPkgConfig)
-pkg_check_modules(hal-backend-device-external-connection_pkgs REQUIRED hal-backend-device-common glib-2.0 gio-2.0)
+pkg_check_modules(hal-backend-device-external-connection_pkgs REQUIRED hal-backend-device-common glib-2.0 gio-2.0 libsyscommon)
FOREACH(flag ${hal-backend-device-external-connection_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-ADD_LIBRARY(${PROJECT_NAME} MODULE external_connection.c ../dbus.c)
+ADD_LIBRARY(${PROJECT_NAME} MODULE external_connection.c)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-external-connection_pkgs_LDFLAGS})
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
#include <hal/hal-common-interface.h>
#include <libsyscommon/file.h>
-#include "../dbus.h"
+#include <libsyscommon/dbus-system.h>
#include </hal/include/device/hal-backend-common.h>
{ EXTCON_EARJACK, EXTERNAL_CONNECTION_HEADPHONE, EXTCON_EARJACK_PATH, },
};
-static int id; /* signal handler id */
+static guint signal_id; /* signal handler id */
static struct signal_data {
ConnectionUpdated updated_cb;
static int external_connection_register_changed_event(
ConnectionUpdated updated_cb, void *data)
{
- int ret;
-
if (sdata.updated_cb) {
_E("update callback is already registered");
return -EEXIST;
}
- ret = register_dbus_signal(EXTCON_OBJECT,
+ signal_id = subscribe_dbus_signal(NULL, EXTCON_OBJECT,
EXTCON_IFACE, EXTCON_SIGNAL,
- signal_delivered, &sdata, &id);
- if (ret < 0) {
+ signal_delivered, &sdata, NULL);
+ if (signal_id < 0) {
_E("Failed to register signal");
return -ENOMEM;
}
static void external_connection_unregister_changed_event(
ConnectionUpdated updated_cb)
{
- unregister_dbus_signal(&id);
+ unsubscribe_dbus_signal(NULL, signal_id);
+ signal_id = 0;
sdata.updated_cb = NULL;
sdata.data = NULL;
}