return BLUETOOTH_ERROR_NONE;
}
-static bluetooth_device_info_t *__bt_get_device_info_in_message(GVariant *parameters, int *ret)
+bluetooth_device_info_t *_bt_get_device_info_in_message(GVariant *parameters, int *ret)
{
bluetooth_device_info_t *dev_info;
const char *address = NULL;
int event;
bluetooth_device_info_t *device_info;
- device_info = __bt_get_device_info_in_message(parameters,
+ device_info = _bt_get_device_info_in_message(parameters,
&result);
ret_if(device_info == NULL);
} else if (strcasecmp(signal_name, BT_BOND_CREATED) == 0) {
bluetooth_device_info_t *device_info;
- device_info = __bt_get_device_info_in_message(parameters,
+ device_info = _bt_get_device_info_in_message(parameters,
&result);
ret_if(device_info == NULL);
bluetooth_device_info_t *device_info;
bt_sdp_info_t sdp_info;
- device_info = __bt_get_device_info_in_message(parameters,
+ device_info = _bt_get_device_info_in_message(parameters,
&result);
ret_if(device_info == NULL);
g_free(cb_data);
}
-int _bt_register_event(int event_type, void *event_cb, void *user_data)
+int _bt_register_event_custom(int event_type, const char *path, const char *interface,
+ GDBusSignalCallback event_func, void *event_cb, void *user_data)
{
GDBusConnection *connection_type;
- GDBusSignalCallback event_func;
bt_event_info_t *cb_data;
- const char *path;
- const char *interface = BT_EVENT_SERVICE;
+
+ retv_if(NULL == path, BLUETOOTH_ERROR_INVALID_PARAM);
+ retv_if(NULL == interface, BLUETOOTH_ERROR_INVALID_PARAM);
+ retv_if(NULL == event_func, BLUETOOTH_ERROR_INVALID_PARAM);
+ retv_if(NULL == event_cb, BLUETOOTH_ERROR_INVALID_PARAM);
if (is_initialized == FALSE)
_bt_init_event_handler();
return BLUETOOTH_ERROR_ALREADY_INITIALIZED;
}
+ connection_type = _bt_gdbus_get_system_gconn();
+ if (connection_type == NULL)
+ return BLUETOOTH_ERROR_INTERNAL;
+
+ cb_data = g_new0(bt_event_info_t, 1);
+
+ cb_data->event_type = event_type;
+ cb_data->cb = event_cb;
+ cb_data->user_data = user_data;
+
+ cb_data->id = g_dbus_connection_signal_subscribe(connection_type,
+ NULL, interface, NULL, path, NULL, 0,
+ event_func, cb_data, NULL);
+
+ event_list = g_slist_append(event_list, cb_data);
+
+ return BLUETOOTH_ERROR_NONE;
+}
+
+int _bt_register_event(int event_type, void *event_cb, void *user_data)
+{
+ GDBusSignalCallback event_func;
+ const char *path;
+ const char *interface = BT_EVENT_SERVICE;
+
+ if (__bt_event_is_registered(event_type) == TRUE) {
+ BT_ERR("The event is already registed");
+ return BLUETOOTH_ERROR_ALREADY_INITIALIZED;
+ }
+
switch (event_type) {
case BT_ADAPTER_EVENT:
event_func = __bt_adapter_event_filter;
return BLUETOOTH_ERROR_INTERNAL;
}
- connection_type = _bt_gdbus_get_system_gconn();
- if (connection_type == NULL)
- return BLUETOOTH_ERROR_INTERNAL;
-
- cb_data = g_new0(bt_event_info_t, 1);
-
- cb_data->event_type = event_type;
- cb_data->cb = event_cb;
- cb_data->user_data = user_data;
-
- cb_data->id = g_dbus_connection_signal_subscribe(connection_type,
- NULL, interface, NULL, path, NULL, 0,
- event_func, cb_data, NULL);
-
- event_list = g_slist_append(event_list, cb_data);
-
- return BLUETOOTH_ERROR_NONE;
+ return _bt_register_event_custom(event_type, path,
+ interface, event_func, event_cb, user_data);
}
int _bt_unregister_event(int event_type)