* @{
*/
-#ifndef TIZEN_ERROR_COMP
+/**
+ * @brief The companion-manager handle.
+ * @since_tizen 5.0
+ */
+typedef void *companion_h;
+
/**
* @brief Base error codes for companion-manager.
*
* @since_tizen 5.0
*/
+#ifndef TIZEN_ERROR_COMP
#define TIZEN_ERROR_COMP -0x02F50000 /**< Base error code */
#endif
* @retval #COMP_ERROR_PERMISSION_DENIED Permission Denied
* @retval #COMP_ERROR_OUT_OF_MEMORY Out of memory
*/
-int companion_initialize();
+int companion_initialize(companion_h *handle);
/**
* @brief Deinitializes the companion-manager.
* @retval #COMP_ERROR_INVALID_OPERATION Invalid operation
* @retval #COMP_ERROR_OPERATION_FAILED Operation failed
*/
-int companion_deinitialize();
+int companion_deinitialize(companion_h handle);
/* Group Module APIs*/
*
* @since_tizen 5.0
*
+ * @param[in] handle The companion manager handle
* @param[in] group_name Group name
*
* @return 0 on success, otherwise a negative error value.
* @see companion_group_get_found_groups()
*
*/
-int companion_group_create(char *group_name);
+int companion_group_create(companion_h handle, char *group_name);
/**
* @brief Finds group resources in local and the network.
*
* @since_tizen 5.0
*
+ * @param[in] handle The companion manager handle
* @param[in] timeout Time to find
* @param[in] found_cb Callback handler to retrieve the found group resource
* @param[in] finish_cb Callback handler to know finding process finished
* @see companion_group_get_found_groups()
*
*/
-int companion_group_find(
- int timeout,
- companion_group_found_cb found_cb,
- companion_group_find_finish_cb finish_cb,
+int companion_group_find(companion_h handle, int timeout,
+ companion_group_found_cb found_cb, companion_group_find_finish_cb finish_cb,
void *user_data);
/**
*
* @since_tizen 5.0
*
+ * @param[in] handle The companion manager handle
* @param[in] groups Group resource list
* @param[out] count Number of groups
*
* @see companion_group_find()
*
*/
-int companion_group_get_found_groups(companion_group_h **groups,
- int *count);
+int companion_group_get_found_groups(companion_h handle,
+ companion_group_h **groups, int *count);
/**
* @brief Joins the remote group.
*
* @since_tizen 5.0
*
+ * @param[in] handle The companion manager handle
* @param[in] group Group resource list
* @param[in] callback Callback handler to retrieve the found group resource
* @param[in] user_data User data poiter
* @see companion_group_get_member_devices()
*
*/
-int companion_group_join(companion_group_h group,
+int companion_group_join(companion_h handle, companion_group_h group,
companion_group_find_finish_cb callback, void *user_data);
/**
*
* @since_tizen 5.0
*
+ * @param[in] handle The companion manager handle
* @param[in] group Group handle
* @param[in] callback Callback handler to retrieve the found group resource
* @param[in] user_data User data poiter
* @see companion_group_get_member_devices()
*
*/
-int companion_group_leave(companion_group_h group,
+int companion_group_leave(companion_h handle, companion_group_h group,
companion_group_find_finish_cb callback, void *user_data);
/**
*
* @since_tizen 5.0
*
+ * @param[in] handle The companion manager handle
* @param[in] group Group handle
*
*
* @see companion_group_get_member_devices()
*
*/
-int companion_group_delete(companion_group_h group);
+int companion_group_delete(companion_h handle, companion_group_h group);
/**
* @brief Combines both groups to one.
*
* @since_tizen 5.0
*
+ * @param[in] handle The companion manager handle
* @param[in] dest_group Group handle to be united
* @param[in] src_group Group handle to be merged
*
* @see companion_group_get_member_devices()
*
*/
-int companion_group_merge(companion_group_h dest_group,
+int companion_group_merge(companion_h handle, companion_group_h dest_group,
companion_group_h src_group);
/**
*
* @remarks The @devices should be released using companion_device_destroy().
*
+ * @param[in] handle The companion manager handle
* @param[in] group Group resource list
* @param[out] devices Device list
* @param[out] count Number of devices in a group
* @see companion_group_merge()
*
*/
-int companion_group_get_member_devices(companion_group_h group,
- companion_device_h **devices, int *count);
+int companion_group_get_member_devices(companion_h handle,
+ companion_group_h group, companion_device_h **devices, int *count);
/* Device Module */
*
* @since_tizen 5.0
*
+ * @param[in] handle The companion manager handle
* @param[in] timeout Time to find
* @param[in] found_cb Callback handler to retrieve the found device
* @param[in] finish_cb Callback handler to know finding process finished
* @see companion_device_get_found_devices()
*
*/
-int companion_device_find(
- int timeout,
- companion_device_found_cb found_cb,
- companion_device_find_finish_cb finish_cb,
+int companion_device_find(companion_h handle, int timeout,
+ companion_device_found_cb found_cb, companion_device_find_finish_cb finish_cb,
void *user_data);
/**
*
* @since_tizen 5.0
*
+ * @param[in] handle The companion manager handle
* @param[in] devices Device list
* @param[in] count Number of devices
*
* @see companion_device_find_mowned_device()
*
*/
-int companion_device_get_found_devices(
- companion_device_h **devices,
- int *count);
+int companion_device_get_found_devices(companion_h handle,
+ companion_device_h **devices, int *count);
/**
* @brief Finds my owned devices in the network.
*
* @since_tizen 5.0
*
+ * @param[in] handle The companion manager handle
* @param[in] timeout Time to find
* @param[in] found_cb Callback handler to retrieve the found device
* @param[in] finish_cb Callback handler to know finding process finished
* @see companion_device_get_found_mowned_devices()
*
*/
-int companion_device_find_mowned_device(
- int timeout,
- companion_device_found_cb found_cb,
- companion_device_find_finish_cb finish_cb,
+int companion_device_find_mowned_device(companion_h handle, int timeout,
+ companion_device_found_cb found_cb, companion_device_find_finish_cb finish_cb,
void *user_data);
/**
*
* @since_tizen 5.0
*
+ * @param[in] handle The companion manager handle
* @param[in] devices Device list
* @param[in] count Number of devices
*
* @see companion_device_find_mowned_device()
*
*/
-int companion_device_get_found_mowned_devices(
+int companion_device_get_found_mowned_devices(companion_h handle,
companion_device_h **devices, int *count);
/* companion_group_device_invite : Invite a remote group device to my local group. */
* @see companion_send_data()
*
*/
-int companion_device_invite(
- companion_group_h group,
- companion_device_h device,
- char *PIN,
- companion_device_invite_result_cb callback,
+int companion_device_invite(companion_h handle, companion_group_h group,
+ companion_device_h device, char *PIN, companion_device_invite_result_cb callback,
void *user_data);
/* companion_group_device_eject : Eject a remote group device from my group. */
*
* @since_tizen 5.0
*
+ * @param[in] handle The companion manager handle
* @param[in] group Group handle
* @param[in] device Device handle
* @param[in] callback Callback handler to receive the result
* @see companion_send_data()
*
*/
-int companion_device_eject(
- companion_group_h group,
- companion_device_h device,
- companion_device_eject_result_cb callback,
+int companion_device_eject(companion_h handle, companion_group_h group,
+ companion_device_h device, companion_device_eject_result_cb callback,
void *user_data);
/**
*
* @since_tizen 5.0
*
+ * @param[in] handle The companion manager handle
+ * @param[in] handle The companion manager handle
* @param[in] device Local device handle
*
* @return 0 on success, otherwise a negative error value.
* @see companion_device_get_my_uuid()
*
*/
-int companion_device_get_my_device(companion_device_h *device);
+int companion_device_get_my_device(companion_h handle,
+ companion_device_h *device);
/**
* @brief Gets my local device ID.
*
* @remarks The @uuid should not be released.
*
+ * @param[in] handle The companion manager handle
* @param[in] uuid Local device UUID
*
* @return 0 on success, otherwise a negative error value.
* @see companion_device_get_my_device()
*
*/
-int companion_device_get_my_uuid(char **uuid);
+int companion_device_get_my_uuid(companion_h handle, char **uuid);
/* Group Information Module */
*
* @since_tizen 5.0
*
+ * @param[in] handle The companion manager handle
* @param[in] device Device handle
* @param[in] data Data to send
* @param[in] len What length to send
* @see companion_request_result_callback()
*
*/
-int companion_send_data(companion_device_h device, char *data, int len,
- companion_send_data_finish_cb finish_cb, void *user_data);
+int companion_send_data(companion_h handle, companion_device_h device, char *data,
+ int len, companion_send_data_finish_cb finish_cb, void *user_data);
/**
* @brief Requests to create a group.
*
* @since_tizen 5.0
*
+ * @param[in] handle The companion manager handle
* @param[in] device Device handle
* @param[in] group_name Group name
*
* @see companion_send_data()
*
*/
-int companion_request_create_group(companion_device_h device, char *group_name);
+int companion_request_create_group(companion_h handle,
+ companion_device_h device, char *group_name);
/**
* @brief Requests to invite a device to the group.
*
* @since_tizen 5.0
*
+ * @param[in] handle The companion manager handle
* @param[in] group Group handle
* @param[in] device Device handle
* @param[in] PIN PIN number
* @see companion_send_data()
*
*/
-int companion_request_invite(companion_group_h group, companion_device_h device,
- char *PIN);
+int companion_request_invite(companion_h handle, companion_group_h group,
+ companion_device_h device, char *PIN);
/**
* @brief Requests to eject a device.
*
* @since_tizen 5.0
*
+ * @param[in] handle The companion manager handle
* @param[in] group Group handle
* @param[in] device Device handle
*
* @see companion_send_data()
*
*/
-int companion_request_eject(companion_group_h group, companion_device_h device);
+int companion_request_eject(companion_h handle, companion_group_h group,
+ companion_device_h device);
/**
* @brief Requests to delete the group.
*
* @since_tizen 5.0
*
+ * @param[in] handle The companion manager handle
* @param[in] group Group handle
*
*
* @see companion_send_data()
*
*/
-int companion_request_delete_group(companion_group_h group);
+int companion_request_delete_group(companion_h handle, companion_group_h group);
/**
* @brief Registers request result callback funtion.
*
* @since_tizen 5.0
*
+ * @param[in] handle The companion manager handle
* @param[in] callback Callback function pointer
* @param[in] user_data User data pointer
*
* @see companion_send_data()
*
*/
-int companion_request_result_callback(companion_request_result_cb callback,
- void *user_data);
+int companion_request_result_callback(companion_h handle,
+ companion_request_result_cb callback, void *user_data);
/**
* @}
#define COMP_DBUS_GROUP_PATH "/org/tizen/companion/group" /**< For group dbus */
#define COMP_DBUS_ENABLER_PATH "/org/tizen/companion/enabler" /**< dbus auto-activation */
-Group *group_proxy = NULL; /**< To receive signal from companion-manager */
-Enabler *enabler_proxy = NULL; /**< Enbler proxy */
-
-int ref_count = 0;
-bool __is_initialized = false;
+int ref_count = 0; /**< How many clients are alive */
+bool __is_initialized = false; /**< Initialize or not */
typedef struct _companion_group_t {
- char *uri_path;
- char *device_id;
- char *group_name;
- char *host_addr;
- char *resource_type;
- companion_group_type_e type;
+ char *uri_path; /**< URI Path for group resource */
+ char *device_id; /**< Device ID of the device has this group resource */
+ char *group_name; /**< Group Name (Friendly name) */
+ char *host_addr; /**< Host address */
+ char *resource_type; /**< Resource type */
+ companion_group_type_e type; /**< Mine or Remote */
} companion_group_t;
typedef struct _companion_device_t {
- char *device_id;
- char *ip;
- char *device_type;
- int port;
+ char *device_id; /**< Device ID */
+ char *ip; /**< Device IP */
+ char *device_type; /**< Device Type */
+ int port; /**< Port Number */
} companion_device_t;
typedef struct _group_found_cb_t {
companion_group_found_cb found_cb;
void *user_data;
} group_found_cb_t;
-group_found_cb_t group_found_cb;
typedef struct _device_found_cb_t {
companion_device_found_cb found_cb;
void *user_data;
} device_found_cb_t;
-device_found_cb_t device_found_cb;
typedef struct _group_find_finish_cb_t {
companion_group_find_finish_cb finish_cb;
void *user_data;
} group_find_finish_cb_t;
-group_find_finish_cb_t group_find_finish_cb;
typedef struct _device_find_finish_cb_t {
companion_device_find_finish_cb finish_cb;
void *user_data;
} device_find_finish_cb_t;
-device_find_finish_cb_t device_find_finish_cb;
typedef struct _mowned_device_found_cb_t {
companion_device_found_cb found_cb;
void *user_data;
} mowned_device_found_cb_t;
-mowned_device_found_cb_t mowned_device_found_cb;
typedef struct _mowned_device_find_finish_cb_t {
companion_device_find_finish_cb finish_cb;
void *user_data;
} mowned_device_find_finish_cb_t;
-mowned_device_find_finish_cb_t mowned_device_find_finish_cb;
typedef struct _device_invite_result_cb_t {
companion_device_invite_result_cb result_cb;
void *user_data;
} device_invite_result_cb_t;
-device_invite_result_cb_t device_invite_result_cb;
typedef struct _device_eject_result_cb_t {
companion_device_eject_result_cb result_cb;
void *user_data;
} device_eject_result_cb_t;
-device_eject_result_cb_t device_eject_result_cb;
typedef struct _send_data_finish_cb_t {
companion_send_data_finish_cb finish_cb;
void *user_data;
} send_data_finish_cb_t;
-send_data_finish_cb_t send_data_finish_cb;
typedef struct _request_result_cb_t {
companion_request_result_cb result_cb;
void *user_data;
} request_result_cb_t;
-request_result_cb_t request_result_cb;
+
+typedef struct _comp_manager_s {
+ gpointer dbus_connection;
+ GCancellable *ca;
+
+ Group *group_proxy; /**< To receive signal from companion-manager */
+ Enabler *enabler_proxy; /**< Enbler proxy */
+
+ group_found_cb_t group_found_cb;
+ device_found_cb_t device_found_cb;
+ group_find_finish_cb_t group_find_finish_cb;
+ device_find_finish_cb_t device_find_finish_cb;
+ mowned_device_found_cb_t mowned_device_found_cb;
+ mowned_device_find_finish_cb_t mowned_device_find_finish_cb;
+ device_invite_result_cb_t device_invite_result_cb;
+ device_eject_result_cb_t device_eject_result_cb;
+ send_data_finish_cb_t send_data_finish_cb;
+ request_result_cb_t request_result_cb;
+} comp_manager_s;
static companion_group_t *_create_group_handle(char *uri_path, char *device_id,
char *group_name, char *host_addr, char *resource_type, companion_group_type_e type)
{
- companion_group_t *group = g_new0(companion_group_t, 1);
+ companion_group_t *group = calloc(1, sizeof(companion_group_t));
+ if (NULL == group) {
+ /* LCOV_EXCL_START */
+ _ERR("Memory allocation failed");
+ goto CREATE_GROUP_HANDLER_ERROR;
+ /* LCOV_EXCL_STOP */
+ }
group->uri_path = g_strdup(uri_path);
group->device_id = g_strdup(device_id);
group->resource_type = g_strdup(resource_type);
group->type = type;
+ if (!group->uri_path || !group->device_id ||
+ !group->host_addr || !group->resource_type) {
+ /* LCOV_EXCL_START */
+ _ERR("Memory allocation failed");
+ goto CREATE_GROUP_HANDLER_ERROR;
+ /* LCOV_EXCL_STOP */
+ }
return group;
+
+CREATE_GROUP_HANDLER_ERROR:
+ /* LCOV_EXCL_START */
+ if (group) {
+ if (group->uri_path) {
+ free(group->uri_path);
+ group->uri_path = NULL;
+ }
+ if (group->device_id) {
+ free(group->device_id);
+ group->device_id = NULL;
+ }
+ if (group->group_name) {
+ free(group->group_name);
+ group->group_name = NULL;
+ }
+ if (group->host_addr) {
+ free(group->host_addr);
+ group->host_addr = NULL;
+ }
+ if (group->resource_type) {
+ free(group->resource_type);
+ group->resource_type = NULL;
+ }
+ free(group);
+ group = NULL;
+ }
+ return NULL;
+ /* LCOV_EXCL_STOP */
}
static companion_device_t *_create_device_handle(char *device_id, char *ip,
char *device_type, int port)
{
- companion_device_t *device = g_new0(companion_device_t, 1);
+ companion_device_t *device = calloc(1, sizeof(companion_device_t));
+ if (NULL == device) {
+ /* LCOV_EXCL_START */
+ _ERR("Memory allocation failed");
+ goto CREATE_DEVICE_HANDLER_ERROR;
+ /* LCOV_EXCL_STOP */
+ }
device->device_id = g_strdup(device_id);
device->ip = g_strdup(ip);
device->device_type = g_strdup(device_type);
device->port = port;
+ if (!device->device_id || !device->ip || !device->device_type) {
+ /* LCOV_EXCL_START */
+ _ERR("Memory allocation failed");
+ goto CREATE_DEVICE_HANDLER_ERROR;
+ /* LCOV_EXCL_STOP */
+ }
+
return device;
+
+CREATE_DEVICE_HANDLER_ERROR:
+ /* LCOV_EXCL_START */
+ if (device) {
+ if (device->device_id) {
+ free(device->device_id);
+ device->device_id = NULL;
+ }
+ if (device->ip) {
+ free(device->ip);
+ device->ip = NULL;
+ }
+ if (device->device_type) {
+ free(device->device_type);
+ device->device_type = NULL;
+ }
+ free(device);
+ device = NULL;
+ }
+ return NULL;
+ /* LCOV_EXCL_STOP */
}
static void __group_found_cb(Group *object, GVariant *va, gpointer user_data)
char *resource_type = NULL;
companion_group_type_e type = COMPANION_GROUP_TYPE_ERROR;
+ NOTUSED(object);
+
+ comp_manager_s *handle = user_data;
+ if (!handle) {
+ /* LCOV_EXCL_START */
+ _ERR("handle is null");
+ return;
+ /* LCOV_EXCL_STOP */
+ }
+
g_variant_get(va, "a{sv}", &iter);
while (g_variant_iter_loop(iter, "{sv}", &key, &key_value)) {
if (g_strcmp0(key, "URI") == 0)
group = _create_group_handle(uri_path, device_id, group_name, host_addr,
resource_type, type);
- if (group_found_cb.found_cb)
- group_found_cb.found_cb(type, group, group_found_cb.user_data);
+ if (handle->group_found_cb.found_cb)
+ handle->group_found_cb.found_cb(type, group, handle->group_found_cb.user_data);
}
static void _group_find_finish_cb(Group *object, gint ret, gpointer user_data)
{
- if (group_find_finish_cb.finish_cb)
- group_find_finish_cb.finish_cb(ret, group_find_finish_cb.user_data);
+ NOTUSED(object);
+
+ comp_manager_s *handle = user_data;
+ if (!handle) {
+ /* LCOV_EXCL_START */
+ _ERR("handle is null");
+ return;
+ /* LCOV_EXCL_STOP */
+ }
+ if (handle->group_find_finish_cb.finish_cb)
+ handle->group_find_finish_cb.finish_cb(ret,
+ handle->group_find_finish_cb.user_data);
}
static void __device_found_cb(Group *object, gint count, GVariant *va,
GVariant *key_value;
companion_device_t *device = NULL;
+ NOTUSED(object);
+
+ comp_manager_s *handle = user_data;
+ if (!handle) {
+ /* LCOV_EXCL_START */
+ _ERR("handle is null");
+ return;
+ /* LCOV_EXCL_STOP */
+ }
+
g_variant_get(va, "aa{sv}", &iter);
while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
char *device_id = NULL;
g_variant_iter_free(iter_row);
device = _create_device_handle(device_id, ip, device_type, port);
- if (device_found_cb.found_cb)
- device_found_cb.found_cb(device, device_found_cb.user_data);
+ if (handle->device_found_cb.found_cb)
+ handle->device_found_cb.found_cb(device, handle->device_found_cb.user_data);
}
g_variant_iter_free(iter);
}
static void _device_find_finish_cb(Group *object, gint ret, gpointer user_data)
{
- if (device_find_finish_cb.finish_cb)
- device_find_finish_cb.finish_cb(ret, device_find_finish_cb.user_data);
+ NOTUSED(object);
+
+ comp_manager_s *handle = user_data;
+ if (!handle) {
+ /* LCOV_EXCL_START */
+ _ERR("handle is null");
+ return;
+ /* LCOV_EXCL_STOP */
+ }
+ if (handle->device_find_finish_cb.finish_cb)
+ handle->device_find_finish_cb.finish_cb(ret,
+ handle->device_find_finish_cb.user_data);
}
static void __mowned_device_found_cb(Group *object, gint count, GVariant *va,
GVariant *key_value;
companion_device_t *device = NULL;
+ NOTUSED(object);
+
+ comp_manager_s *handle = user_data;
+ if (!handle) {
+ /* LCOV_EXCL_START */
+ _ERR("handle is null");
+ return;
+ /* LCOV_EXCL_STOP */
+ }
+
g_variant_get(va, "aa{sv}", &iter);
while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
char *device_id = NULL;
g_variant_iter_free(iter_row);
device = _create_device_handle(device_id, ip, device_type, port);
- if (mowned_device_found_cb.found_cb)
- mowned_device_found_cb.found_cb(device, mowned_device_found_cb.user_data);
+ if (handle->mowned_device_found_cb.found_cb)
+ handle->mowned_device_found_cb.found_cb(device,
+ handle->mowned_device_found_cb.user_data);
}
g_variant_iter_free(iter);
}
static void _mowned_device_find_finish_cb(Group *object, gint ret,
gpointer user_data)
{
- if (mowned_device_find_finish_cb.finish_cb)
- mowned_device_find_finish_cb.finish_cb(ret, mowned_device_find_finish_cb.user_data);
+ NOTUSED(object);
+
+ comp_manager_s *handle = user_data;
+ if (!handle) {
+ /* LCOV_EXCL_START */
+ _ERR("handle is null");
+ return;
+ /* LCOV_EXCL_STOP */
+ }
+ if (handle->mowned_device_find_finish_cb.finish_cb)
+ handle->mowned_device_find_finish_cb.finish_cb(ret,
+ handle->mowned_device_find_finish_cb.user_data);
}
static void __device_invite_result_cb(Group *object, gint ret, gpointer user_data)
{
- if (device_invite_result_cb.result_cb)
- device_invite_result_cb.result_cb(ret, device_invite_result_cb.user_data);
+ NOTUSED(object);
+
+ comp_manager_s *handle = user_data;
+ if (!handle) {
+ /* LCOV_EXCL_START */
+ _ERR("handle is null");
+ return;
+ /* LCOV_EXCL_STOP */
+ }
+ if (handle->device_invite_result_cb.result_cb)
+ handle->device_invite_result_cb.result_cb(ret,
+ handle->device_invite_result_cb.user_data);
}
static void __device_eject_result_cb(Group *object, gint ret, gpointer user_data)
{
- if (device_eject_result_cb.result_cb)
- device_eject_result_cb.result_cb(ret, device_eject_result_cb.user_data);
+ NOTUSED(object);
+
+ comp_manager_s *handle = user_data;
+ if (!handle) {
+ /* LCOV_EXCL_START */
+ _ERR("handle is null");
+ return;
+ /* LCOV_EXCL_STOP */
+ }
+ if (handle->device_eject_result_cb.result_cb)
+ handle->device_eject_result_cb.result_cb(ret,
+ handle->device_eject_result_cb.user_data);
}
static void __send_data_finish_cb(Group *object, gchar *resp_data, gint ret,
gpointer user_data)
{
- if (send_data_finish_cb.finish_cb)
- send_data_finish_cb.finish_cb(ret, resp_data, send_data_finish_cb.user_data);
+ NOTUSED(object);
+
+ comp_manager_s *handle = user_data;
+ if (!handle) {
+ /* LCOV_EXCL_START */
+ _ERR("handle is null");
+ return;
+ /* LCOV_EXCL_STOP */
+ }
+ if (handle->send_data_finish_cb.finish_cb)
+ handle->send_data_finish_cb.finish_cb(ret, resp_data,
+ handle->send_data_finish_cb.user_data);
}
static void __request_result_cb(Group *object, gchar *cmd, gchar *arg, gint ret,
gpointer user_data)
{
- if (request_result_cb.result_cb)
- request_result_cb.result_cb(cmd, arg, ret, request_result_cb.user_data);
+ NOTUSED(object);
+
+ comp_manager_s *handle = user_data;
+ if (!handle) {
+ /* LCOV_EXCL_START */
+ _ERR("handle is null");
+ return;
+ /* LCOV_EXCL_STOP */
+ }
+ if (handle->request_result_cb.result_cb)
+ handle->request_result_cb.result_cb(cmd, arg, ret,
+ handle->request_result_cb.user_data);
}
-static void _group_proxy_init(void)
+static int _group_proxy_init(comp_manager_s *handle);
+static int _enabler_proxy_init(comp_manager_s *handle);
+static void _group_proxy_deinit(comp_manager_s *handle);
+static void _enabler_proxy_deinit(comp_manager_s *handle);
+
+static int _gdbus_initialize(comp_manager_s *handle)
{
- GError *error = NULL;
+ int ret = COMP_ERROR_NONE;
- group_proxy = group_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- COMP_DBUS_SERVICE,
- COMP_DBUS_GROUP_PATH,
- NULL,
- &error);
+ _group_proxy_init(handle);
+ _enabler_proxy_init(handle);
- g_signal_connect(group_proxy,
- "group-found", G_CALLBACK(__group_found_cb), NULL);
- g_signal_connect(group_proxy,
- "group-find-finish", G_CALLBACK(_group_find_finish_cb), NULL);
- g_signal_connect(group_proxy,
- "device-found", G_CALLBACK(__device_found_cb), NULL);
- g_signal_connect(group_proxy,
- "device-find-finish", G_CALLBACK(_device_find_finish_cb), NULL);
- g_signal_connect(group_proxy,
- "mowned-device-found", G_CALLBACK(__mowned_device_found_cb), NULL);
- g_signal_connect(group_proxy,
- "mowned-device-find-finish", G_CALLBACK(_mowned_device_find_finish_cb), NULL);
- g_signal_connect(group_proxy,
- "device-invite-result", G_CALLBACK(__device_invite_result_cb), NULL);
- g_signal_connect(group_proxy,
- "device-eject-result", G_CALLBACK(__device_eject_result_cb), NULL);
- g_signal_connect(group_proxy,
- "send-data-finish", G_CALLBACK(__send_data_finish_cb), NULL);
- g_signal_connect(group_proxy,
- "request-result", G_CALLBACK(__request_result_cb), NULL);
+ if (handle->group_proxy == NULL)
+ ret = -1; /* LCOV_EXCL_LINE */
+
+ if (handle->enabler_proxy == NULL)
+ ret = -1; /* LCOV_EXCL_LINE */
+
+ handle->ca = g_cancellable_new();
+
+ return ret;
}
-static void _enabler_proxy_init(void)
+static int _gdbus_deinitialize(comp_manager_s *handle)
{
- GError *error = NULL;
+ int ret = COMP_ERROR_NONE;
+
+ _group_proxy_deinit(handle);
+ _enabler_proxy_deinit(handle);
+
+ g_cancellable_cancel(handle->ca);
+ g_object_unref(handle->ca);
+ handle->ca = NULL;
+
+ return ret;
+}
- enabler_proxy = enabler_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,
+static int _enabler_proxy_init(comp_manager_s *handle)
+{
+ int ret = COMP_ERROR_NONE;
+ GError *error = NULL;
+ handle->enabler_proxy = enabler_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE, COMP_DBUS_SERVICE,
COMP_DBUS_ENABLER_PATH, NULL, &error);
+ if (NULL == handle->enabler_proxy) {
+ /* LCOV_EXCL_START */
+ if (error != NULL) {
+ _ERR("Failed to connect to the D-BUS daemon [%s]", error->message);
+ g_error_free(error);
+ }
+ return COMP_ERROR_IO_ERROR;
+ /* LCOV_EXCL_STOP */
+ }
+ return ret;
}
-static void _group_proxy_deinit(void)
+static void _group_proxy_deinit(comp_manager_s *handle)
{
- group_proxy = NULL;
+ g_object_unref(handle->group_proxy);
+ handle->group_proxy = NULL;
}
-static void _enabler_proxy_deinit(void)
+static void _enabler_proxy_deinit(comp_manager_s *handle)
{
int ret;
- enabler_call_disable_sync(enabler_proxy, &ret, NULL, NULL);
- enabler_proxy = NULL;
+ enabler_call_disable_sync(handle->enabler_proxy, &ret, NULL, NULL);
+ g_object_unref(handle->enabler_proxy);
+ handle->enabler_proxy = NULL;
}
-static int _gdbus_initialize(void)
+/* LCOV_EXCL_START */
+static void _dbus_name_owner_notify(GObject *object, GParamSpec *pspec,
+ gpointer *user_data)
{
- int ret = 0;
-
- _group_proxy_init();
- _enabler_proxy_init();
+ GDBusProxy *proxy = G_DBUS_PROXY(object);
+ gchar *name_owner = g_dbus_proxy_get_name_owner(proxy);
+ comp_manager_s *handle = (comp_manager_s *)user_data;
+ if (!handle) {
+ _ERR("handle is null");
+ return;
+ }
- if (group_proxy == NULL)
- ret = -1; /* LCOV_EXCL_LINE */
+ LOGD("Name owner notify [%s]", name_owner);
- if (enabler_proxy == NULL)
- ret = -1; /* LCOV_EXCL_LINE */
+ if (NULL == name_owner)
+ _gdbus_deinitialize(handle);
+ free(name_owner);
- return ret;
}
+/* LCOV_EXCL_STOP */
-static int _gdbus_deinitialize(void)
+static int _group_proxy_init(comp_manager_s *handle)
{
- int ret = 0;
+ int id = -1;
+ GError *error = NULL;
+
+ handle->group_proxy = group_proxy_new_for_bus_sync(
+ G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ COMP_DBUS_SERVICE,
+ COMP_DBUS_GROUP_PATH,
+ NULL,
+ &error);
+ if (NULL == handle->group_proxy) {
+ /* LCOV_EXCL_START */
+ if (error != NULL) {
+ _ERR("Failed to connect to the D-BUS daemon [%s]", error->message);
+ g_error_free(error);
+ }
+ return COMP_ERROR_IO_ERROR;
+ /* LCOV_EXCL_STOP */
+ }
- _group_proxy_deinit();
- _enabler_proxy_deinit();
+ id = g_signal_connect(handle->group_proxy, "notify::g-name-owner",
+ G_CALLBACK(_dbus_name_owner_notify), handle);
+ if (0 == id) {
+ /* LCOV_EXCL_START */
+ _ERR("g_signal_connect() Fail");
+ g_object_unref(handle->group_proxy);
+ handle->group_proxy = NULL;
+ return COMP_ERROR_IO_ERROR;
+ /* LCOV_EXCL_STOP */
+ }
- return ret;
+ g_signal_connect(handle->group_proxy,
+ "group-found", G_CALLBACK(__group_found_cb), handle);
+ g_signal_connect(handle->group_proxy,
+ "group-find-finish", G_CALLBACK(_group_find_finish_cb), handle);
+ g_signal_connect(handle->group_proxy,
+ "device-found", G_CALLBACK(__device_found_cb), handle);
+ g_signal_connect(handle->group_proxy,
+ "device-find-finish", G_CALLBACK(_device_find_finish_cb), handle);
+ g_signal_connect(handle->group_proxy,
+ "mowned-device-found", G_CALLBACK(__mowned_device_found_cb), handle);
+ g_signal_connect(handle->group_proxy,
+ "mowned-device-find-finish", G_CALLBACK(_mowned_device_find_finish_cb), handle);
+ g_signal_connect(handle->group_proxy,
+ "device-invite-result", G_CALLBACK(__device_invite_result_cb), handle);
+ g_signal_connect(handle->group_proxy,
+ "device-eject-result", G_CALLBACK(__device_eject_result_cb), handle);
+ g_signal_connect(handle->group_proxy,
+ "send-data-finish", G_CALLBACK(__send_data_finish_cb), handle);
+ g_signal_connect(handle->group_proxy,
+ "request-result", G_CALLBACK(__request_result_cb), handle);
+
+ return COMP_ERROR_NONE;
}
-EXPORT_API int companion_initialize()
+EXPORT_API int companion_initialize(companion_h *handle)
{
- int ret = 0;
+ int ret = COMP_ERROR_NONE;
+ struct comp_manager_s *comp_manager = NULL;
+
+ if (NULL == handle) {
+ /* LCOV_EXCL_START */
+ _ERR("Invalid parameter");
+ return COMP_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
+ }
_BEGIN();
- COMPANION_LOCK;
+ comp_manager = calloc(1, sizeof(comp_manager_s));
+ if (NULL == comp_manager) {
+ /* LCOV_EXCL_START */
+ _ERR("Failed to create handle");
+ return COMP_ERROR_OUT_OF_MEMORY;
+ /* LCOV_EXCL_STOP */
+ }
+ *handle = comp_manager;
- if (__is_initialized == false) {
- ret = _gdbus_initialize();
- __is_initialized = true;
+ if (__is_initialized) {
+ _DBG("Already initialized");
+ return COMP_ERROR_ALREADY_INITIALIZED;
}
- ref_count++;
+ COMPANION_LOCK;
+ ret = _gdbus_initialize(*handle);
+ __is_initialized = true;
COMPANION_UNLOCK;
+ ref_count++;
_END();
return ret;
}
-EXPORT_API int companion_deinitialize()
+EXPORT_API int companion_deinitialize(companion_h handle)
{
- int ret = 0;
+ int ret = COMP_ERROR_NONE;
_BEGIN();
COMPANION_LOCK;
- if (ref_count > 0)
- ref_count--;
+ if (0 > --ref_count) {
+ _DBG("all connections closed\n");
+ ref_count = 0;
+ return ret;
+ }
if (__is_initialized == true && ref_count == 0) {
- ret = _gdbus_deinitialize();
+ ret = _gdbus_deinitialize(handle);
__is_initialized = false;
}
}
-EXPORT_API int companion_group_create(char *group_name)
+EXPORT_API int companion_group_create(companion_h handle, char *group_name)
{
- int ret = 0;
+ int ret = COMP_ERROR_NONE;
GError *error = NULL;
+ comp_manager_s *_handle = handle;
+ if (!handle) {
+ _ERR("handle is null");
+ return COMP_ERROR_INVALID_PARAMETER;
+ }
/* create group to daemon using gdbus */
- group_call_create_sync(group_proxy, group_name, &ret, NULL, &error);
+ group_call_create_sync(_handle->group_proxy, group_name, &ret, NULL, &error);
return ret;
}
group = NULL;
}
-EXPORT_API int companion_group_find(int timeout, companion_group_found_cb found_cb,
- companion_group_find_finish_cb finish_cb, void *user_data)
+EXPORT_API int companion_group_find(companion_h handle, int timeout,
+ companion_group_found_cb found_cb, companion_group_find_finish_cb finish_cb,
+ void *user_data)
{
- int ret = 0;
+ int ret = COMP_ERROR_NONE;
GError *error = NULL;
- group_found_cb.found_cb = found_cb;
- group_find_finish_cb.finish_cb = finish_cb;
- group_found_cb.user_data = user_data;
- group_find_finish_cb.user_data = user_data;
+ comp_manager_s *_handle = handle;
+ if (!handle) {
+ _ERR("handle is null");
+ return COMP_ERROR_INVALID_PARAMETER;
+ }
+
+ _handle->group_found_cb.found_cb = found_cb;
+ _handle->group_find_finish_cb.finish_cb = finish_cb;
+ _handle->group_found_cb.user_data = user_data;
+ _handle->group_find_finish_cb.user_data = user_data;
/* get groups from daemon using gdbus */
- group_call_find_sync(group_proxy, timeout, &ret, NULL, &error);
+ group_call_find_sync(_handle->group_proxy, timeout, &ret, NULL, &error);
return ret;
}
-EXPORT_API int companion_group_get_found_groups(companion_group_h **groups,
- int *count)
+EXPORT_API int companion_group_get_found_groups(companion_h handle,
+ companion_group_h **groups, int *count)
{
- int ret = 0;
+ int ret = COMP_ERROR_NONE;
GVariant *va = NULL;
GError *error = NULL;
+ comp_manager_s *_handle = handle;
+ if (!handle) {
+ _ERR("handle is null");
+ return COMP_ERROR_INVALID_PARAMETER;
+ }
+
/* get groups from daemon using gdbus */
- group_call_get_found_groups_sync(group_proxy, &ret, &va, NULL, &error);
+ group_call_get_found_groups_sync(_handle->group_proxy, &ret, &va, NULL, &error);
*count = g_variant_n_children(va);
_DBG("get found groups : %d", *count);
return ret;
}
-EXPORT_API int companion_group_join(companion_group_h group,
+EXPORT_API int companion_group_join(companion_h handle, companion_group_h group,
companion_group_find_finish_cb callback, void *user_data)
{
int ret = COMP_ERROR_NONE;
+
+ NOTUSED(handle);
NOTUSED(group);
NOTUSED(callback);
NOTUSED(user_data);
+
return ret;
}
-EXPORT_API int companion_group_leave(companion_group_h group,
+EXPORT_API int companion_group_leave(companion_h handle, companion_group_h group,
companion_group_find_finish_cb callback, void *user_data)
{
int ret = COMP_ERROR_NONE;
+
+ NOTUSED(handle);
NOTUSED(group);
NOTUSED(callback);
NOTUSED(user_data);
+
return ret;
}
-EXPORT_API int companion_device_find(int timeout, companion_device_found_cb found_cb,
- companion_device_find_finish_cb finish_cb, void *user_data)
+EXPORT_API int companion_device_find(companion_h handle, int timeout,
+ companion_device_found_cb found_cb, companion_device_find_finish_cb finish_cb,
+ void *user_data)
{
- int ret = 0;
+ int ret = COMP_ERROR_NONE;
GError *error = NULL;
- device_found_cb.found_cb = found_cb;
- device_found_cb.user_data = user_data;
- device_find_finish_cb.finish_cb = finish_cb;
- device_find_finish_cb.user_data = user_data;
+ comp_manager_s *_handle = handle;
+ if (!handle) {
+ _ERR("handle is null");
+ return COMP_ERROR_INVALID_PARAMETER;
+ }
+
+ _handle->device_found_cb.found_cb = found_cb;
+ _handle->device_found_cb.user_data = user_data;
+ _handle->device_find_finish_cb.finish_cb = finish_cb;
+ _handle->device_find_finish_cb.user_data = user_data;
/* get groups from daemon using gdbus */
- group_call_device_find_sync(group_proxy, timeout, &ret, NULL, &error);
+ group_call_device_find_sync(_handle->group_proxy, timeout, &ret, NULL, &error);
return ret;
}
-EXPORT_API int companion_device_find_mowned_device(int timeout,
- companion_device_found_cb found_cb, companion_device_find_finish_cb finish_cb,
- void *user_data)
+EXPORT_API int companion_device_find_mowned_device(companion_h handle,
+ int timeout, companion_device_found_cb found_cb,
+ companion_device_find_finish_cb finish_cb, void *user_data)
{
- int ret = 0;
+ int ret = COMP_ERROR_NONE;
GError *error = NULL;
+ comp_manager_s *_handle = handle;
- mowned_device_found_cb.found_cb = found_cb;
- mowned_device_found_cb.user_data = user_data;
- mowned_device_find_finish_cb.finish_cb = finish_cb;
- mowned_device_find_finish_cb.user_data = user_data;
+ _handle->mowned_device_found_cb.found_cb = found_cb;
+ _handle->mowned_device_found_cb.user_data = user_data;
+ _handle->mowned_device_find_finish_cb.finish_cb = finish_cb;
+ _handle->mowned_device_find_finish_cb.user_data = user_data;
/* get groups from daemon using gdbus */
- group_call_find_mowned_devices_sync(group_proxy, timeout, &ret, NULL, &error);
+ group_call_find_mowned_devices_sync(_handle->group_proxy, timeout, &ret, NULL, &error);
return ret;
}
-EXPORT_API int companion_send_data(companion_device_h device, char *data, int len,
- companion_send_data_finish_cb finish_cb, void *user_data)
+EXPORT_API int companion_send_data(companion_h handle, companion_device_h device,
+ char *data, int len, companion_send_data_finish_cb finish_cb, void *user_data)
{
int ret = COMP_ERROR_NONE;
char *buf = NULL;
GError *error = NULL;
+
+ comp_manager_s *_handle = handle;
+ if (!handle) {
+ _ERR("handle is null");
+ return COMP_ERROR_INVALID_PARAMETER;
+ }
+
companion_device_t *dev = (companion_device_t *)device;
+ if (!dev) {
+ _ERR("dev is null");
+ return COMP_ERROR_INVALID_PARAMETER;
+ }
buf = g_malloc0(len + 1);
if (NULL == buf) {
}
memcpy(buf, data, len);
- send_data_finish_cb.finish_cb = finish_cb;
- send_data_finish_cb.user_data = user_data;
+ _handle->send_data_finish_cb.finish_cb = finish_cb;
+ _handle->send_data_finish_cb.user_data = user_data;
- group_call_send_data_sync(group_proxy, dev->device_id, dev->ip, dev->port,
+ group_call_send_data_sync(_handle->group_proxy, dev->device_id, dev->ip, dev->port,
buf, len, &ret, NULL, &error);
free(buf);
/* companion_group_join : join to remote group. if group handle is my daemon's,
then the api return fail error */
-EXPORT_API int companion_device_get_found_devices(companion_device_h **devices,
- int *count)
+EXPORT_API int companion_device_get_found_devices(companion_h handle,
+ companion_device_h **devices, int *count)
{
int ret = 0;
int num = 0;
GVariant *va = NULL;
GError *error = NULL;
+ comp_manager_s *_handle = handle;
+
+ if (!handle) {
+ _ERR("handle is null");
+ return COMP_ERROR_INVALID_PARAMETER;
+ }
/* get groups from daemon using gdbus */
- group_call_get_remote_device_sync(group_proxy, &num, &va, NULL, &error);
+ group_call_get_remote_device_sync(_handle->group_proxy, &num, &va, NULL, &error);
/* *count = g_variant_n_children(va); */
*count = num;
}
EXPORT_API int companion_device_get_found_mowned_devices(
- companion_device_h **devices, int *count)
+ companion_h handle, companion_device_h **devices, int *count)
{
int ret = 0;
int num = 0;
GVariant *va = NULL;
GError *error = NULL;
+ comp_manager_s *_handle = handle;
+
+ if (!handle) {
+ _ERR("handle is null");
+ return COMP_ERROR_INVALID_PARAMETER;
+ }
/* get groups from daemon using gdbus */
- group_call_get_mowned_device_sync(group_proxy, &num, &va, NULL, &error);
+ group_call_get_mowned_device_sync(_handle->group_proxy, &num, &va, NULL, &error);
/* *count = g_variant_n_children(va); */
*count = num;
return ret;
}
-EXPORT_API int companion_device_get_my_device(companion_device_h *device)
+EXPORT_API int companion_device_get_my_device(companion_h handle,
+ companion_device_h *device)
{
int ret = 0;
GError *error = NULL;
char *addr = NULL;
char *ver = NULL;
int port = -1;
+ comp_manager_s *_handle = handle;
+
+ if (!handle) {
+ _ERR("handle is null");
+ return COMP_ERROR_INVALID_PARAMETER;
+ }
- group_call_get_my_mowned_device_sync(group_proxy, &va, NULL, &error);
+ group_call_get_my_mowned_device_sync(_handle->group_proxy, &va, NULL, &error);
g_variant_get(va, "a{sv}", &iter);
while (g_variant_iter_loop(iter, "{sv}", &key, &key_value)) {
device = NULL;
}
-EXPORT_API int companion_device_get_my_uuid(char **uuid)
+EXPORT_API int companion_device_get_my_uuid(companion_h handle, char **uuid)
{
int ret = 0;
GError *error = NULL;
- group_call_get_my_uuid_sync(group_proxy, uuid, NULL, &error);
+ comp_manager_s *_handle = handle;
+ if (!handle) {
+ _ERR("handle is null");
+ return COMP_ERROR_INVALID_PARAMETER;
+ }
+
+ group_call_get_my_uuid_sync(_handle->group_proxy, uuid, NULL, &error);
return ret;
}
/* group merge */
-EXPORT_API int companion_group_merge(companion_group_h dest_group,
- companion_group_h src_group)
+EXPORT_API int companion_group_merge(companion_h hadnle,
+ companion_group_h dest_group, companion_group_h src_group)
{
+ NOTUSED(dest_group);
+ NOTUSED(src_group);
return 0;
}
-EXPORT_API int companion_group_delete(companion_group_h group)
+EXPORT_API int companion_group_delete(companion_h handle, companion_group_h group)
{
+ NOTUSED(handle);
+ NOTUSED(group);
return 0;
}
-EXPORT_API int companion_group_get_member_devices(companion_group_h group,
- companion_device_h **devices, int *count)
+EXPORT_API int companion_group_get_member_devices(companion_h handle,
+ companion_group_h group, companion_device_h **devices, int *count)
{
+ NOTUSED(handle);
+ NOTUSED(group);
+ NOTUSED(devices);
+ NOTUSED(count);
+
return 0;
}
-EXPORT_API int companion_device_invite(companion_group_h group,
- companion_device_h device, char *PIN, companion_device_invite_result_cb result_cb,
- void *user_data)
+EXPORT_API int companion_device_invite(companion_h handle,
+ companion_group_h group, companion_device_h device, char *PIN,
+ companion_device_invite_result_cb result_cb, void *user_data)
{
int ret = 0;
GError *error = NULL;
- companion_device_t *dev = (companion_device_t *)device;
+
+ comp_manager_s *_handle = handle;
+ if (!handle) {
+ _ERR("handle is null");
+ return COMP_ERROR_INVALID_PARAMETER;
+ }
+
companion_group_t *grp = (companion_group_t *)group;
+ if (!grp) {
+ _ERR("grp is null");
+ return COMP_ERROR_INVALID_PARAMETER;
+ }
+
+ companion_device_t *dev = (companion_device_t *)device;
+ if (!dev) {
+ _ERR("dev is null");
+ return COMP_ERROR_INVALID_PARAMETER;
+ }
- device_invite_result_cb.result_cb = result_cb;
- device_invite_result_cb.user_data = user_data;
+ _handle->device_invite_result_cb.result_cb = result_cb;
+ _handle->device_invite_result_cb.user_data = user_data;
/* Now, for the sake of convenience, we change 'companion_device_invite' to
'group_call_invite_sync'. */
#if 0
group_call_device_invite_sync(group_proxy, dev->device_id, PIN, &ret, NULL, &error);
#else
- group_call_invite_sync(group_proxy, grp->group_name, dev->device_id, PIN, &ret,
+ group_call_invite_sync(_handle->group_proxy, grp->group_name, dev->device_id, PIN, &ret,
NULL, &error);
#endif
return ret;
}
-EXPORT_API int companion_device_eject(companion_group_h group,
- companion_device_h device, companion_device_eject_result_cb result_cb, void *user_data)
+EXPORT_API int companion_device_eject(companion_h handle,
+ companion_group_h group, companion_device_h device,
+ companion_device_eject_result_cb result_cb, void *user_data)
{
- int ret = 0;
+ int ret = COMP_ERROR_NONE;
GError *error = NULL;
+
+ comp_manager_s *_handle = handle;
+ if (!handle) {
+ _ERR("handle is null");
+ return COMP_ERROR_INVALID_PARAMETER;
+ }
+
companion_device_t *dev = (companion_device_t *)device;
+ if (!dev) {
+ _ERR("dev is null");
+ return COMP_ERROR_INVALID_PARAMETER;
+ }
- device_eject_result_cb.result_cb = result_cb;
- device_eject_result_cb.user_data = user_data;
+ _handle->device_eject_result_cb.result_cb = result_cb;
+ _handle->device_eject_result_cb.user_data = user_data;
/* Now, for the sake of convenience, we change 'companion_device_eject' to
'group_call_eject_sync'. */
#if 0
group_call_device_eject_sync(group_proxy, dev->device_id, &ret, NULL, &error);
#else
- group_call_eject_sync(group_proxy, dev->device_id, &ret, NULL, &error);
+ group_call_eject_sync(_handle->group_proxy, dev->device_id, &ret, NULL, &error);
#endif
return ret;
return 0;
}
-EXPORT_API int companion_request_create_group(companion_device_h device,
- char *group_name)
+EXPORT_API int companion_request_create_group(companion_h handle,
+ companion_device_h device, char *group_name)
{
- int ret;
+ int ret = COMP_ERROR_NONE;
GError *error = NULL;
+ comp_manager_s *_handle = handle;
companion_device_t *dev = (companion_device_t *)device;
_DBG("Device id : %s", dev->device_id);
- group_call_request_create_group_sync(group_proxy, dev->device_id,
+ group_call_request_create_group_sync(_handle->group_proxy, dev->device_id,
group_name, &ret, NULL, &error);
return ret;
}
-EXPORT_API int companion_request_invite(companion_group_h group,
- companion_device_h device, char *PIN)
+EXPORT_API int companion_request_invite(companion_h handle,
+ companion_group_h group, companion_device_h device, char *PIN)
{
- int ret = 0;
+ int ret = COMP_ERROR_NONE;
+
+ comp_manager_s *_handle = handle;
+ if (!handle) {
+ _ERR("handle is null");
+ return COMP_ERROR_INVALID_PARAMETER;
+ }
companion_group_t *grp = (companion_group_t *)group;
+ if (!grp) {
+ _ERR("grp is null");
+ return COMP_ERROR_INVALID_PARAMETER;
+ }
+
companion_device_t *dev = (companion_device_t *)device;
+ if (!dev) {
+ _ERR("dev is null");
+ return COMP_ERROR_INVALID_PARAMETER;
+ }
_DBG("%s", grp->device_id);
_DBG("%s", grp->group_name);
_DBG("%s", dev->device_id);
- group_call_request_invite(group_proxy, grp->device_id, grp->group_name,
+ group_call_request_invite(_handle->group_proxy, grp->device_id, grp->group_name,
dev->device_id, PIN,
NULL, NULL, NULL);
return ret;
}
-EXPORT_API int companion_request_eject(companion_group_h group,
- companion_device_h device)
+EXPORT_API int companion_request_eject(companion_h handle,
+ companion_group_h group, companion_device_h device)
{
- int ret = 0;
+ int ret = COMP_ERROR_NONE;
+
+ comp_manager_s *_handle = handle;
+ if (!handle) {
+ _ERR("handle is null");
+ return COMP_ERROR_INVALID_PARAMETER;
+ }
companion_group_t *grp = (companion_group_t *)group;
+ if (!grp) {
+ _ERR("grp is null");
+ return COMP_ERROR_INVALID_PARAMETER;
+ }
+
companion_device_t *dev = (companion_device_t *)device;
+ if (!dev) {
+ _ERR("dev is null");
+ return COMP_ERROR_INVALID_PARAMETER;
+ }
_DBG("%s", grp->device_id);
_DBG("%s", grp->group_name);
_DBG("%s", dev->device_id);
- group_call_request_eject(group_proxy, grp->device_id, grp->group_name, dev->device_id,
- NULL, NULL, NULL);
+ group_call_request_eject(_handle->group_proxy, grp->device_id, grp->group_name,
+ dev->device_id, NULL, NULL, NULL);
return ret;
}
-EXPORT_API int companion_request_delete_group(companion_group_h group)
+EXPORT_API int companion_request_delete_group(companion_h handle,
+ companion_group_h group)
{
- int ret = 0;
+ int ret = COMP_ERROR_NONE;
+ NOTUSED(handle);
+ NOTUSED(group);
return ret;
}
-EXPORT_API int companion_request_result_callback(
+EXPORT_API int companion_request_result_callback(companion_h handle,
companion_request_result_cb result_cb, void *user_data)
{
- int ret = 0;
+ int ret = COMP_ERROR_NONE;
+ comp_manager_s *_handle = handle;
+ if (!handle) {
+ _ERR("handle is null");
+ return COMP_ERROR_INVALID_PARAMETER;
+ }
- request_result_cb.result_cb = result_cb;
- request_result_cb.user_data = user_data;
+ _handle->request_result_cb.result_cb = result_cb;
+ _handle->request_result_cb.user_data = user_data;
return ret;
}