{
msg("_request_result_cb is called");
- if (cmd != NULL) {
- if (strcmp("1", cmd) == 0) {
- msgp("[CMD] Request Create Group [%s(0x%X)]", comp_error_to_string(ret), ret);
- if (ret == 0 && arg != NULL) {
- msgb("Created Group name is %s", arg);
- run_group_find(NULL, NULL);
- run_devices_find(NULL, NULL);
- }
- } else if (strcmp("2", cmd) == 0) {
- msgp("[CMD] Request Invite [%s(0x%X)]", comp_error_to_string(ret), ret);
- if (ret == 0 && arg != NULL)
- msgb("Invited Device ID is %s", arg);
- } else if (strcmp("3", cmd) == 0) {
- msgp("[CMD] Request Eject [%s(0x%X)]", comp_error_to_string(ret), ret);
- if (ret == 0 && arg != NULL)
- msgb("Ejected Device ID is %s", arg);
- } else if (strcmp("4", cmd) == 0) {
- msgp("[CMD] Request Delete Group [%s(0x%X)]", comp_error_to_string(ret), ret);
- if (ret == 0 && arg != NULL)
- msgb("Deleted Group name is %s", arg);
- } else {
- msgp("[Recv][%d] %s", strlen(arg), arg);
+ if (cmd == NULL) {
+ msgp("cmd is null [%s(0x%X)]", comp_error_to_string(ret), ret);
+ return;
+ }
+
+ if (strcmp("1", cmd) == 0) {
+ msgp("[CMD] Request Create Group [%s(0x%X)]", comp_error_to_string(ret), ret);
+ if (ret == COMP_ERROR_NONE && arg != NULL) {
+ msgb("Created Group name is %s", arg);
+ run_group_find(NULL, NULL);
+ run_devices_find(NULL, NULL);
}
+ } else if (strcmp("2", cmd) == 0) {
+ msgp("[CMD] Request Invite [%s(0x%X)]", comp_error_to_string(ret), ret);
+ if (ret == COMP_ERROR_NONE && arg != NULL)
+ msgb("Invited Device ID is %s", arg);
+ } else if (strcmp("3", cmd) == 0) {
+ msgp("[CMD] Request Eject [%s(0x%X)]", comp_error_to_string(ret), ret);
+ if (ret == COMP_ERROR_NONE && arg != NULL)
+ msgb("Ejected Device ID is %s", arg);
+ } else if (strcmp("4", cmd) == 0) {
+ msgp("[CMD] Request Delete Group [%s(0x%X)]", comp_error_to_string(ret), ret);
+ if (ret == COMP_ERROR_NONE && arg != NULL)
+ msgb("Deleted Group name is %s", arg);
+ } else {
+ msgp("[Recv][%d] %s", strlen(arg), arg);
}
}
return RET_SUCCESS;
}
-static void _group_leave_finish_cb(int result, void *user_data)
-{
- msgb("\rleave operation finished");
-}
-
static int run_group_leave(MManager *mm, struct menu_data *menu)
{
int ret;
}
}
- ret = companion_request_leave_group (handle, group, _group_leave_finish_cb, NULL);
+ ret = companion_request_leave_group (handle, group, receive_request_result, NULL);
if (COMP_ERROR_NONE != ret) {
msgr("Failed to Leave Group: [%s(0x%X)]", comp_error_to_string(ret), ret);
return RET_FAILURE;
return RET_SUCCESS;
}
-static void _group_join_finish_cb(int result, void *user_data)
-{
- msgp("\rjoin operation finished");
-}
-
static int run_group_join(MManager *mm, struct menu_data *menu)
{
int ret;
}
}
- ret = companion_request_join_group(handle, group, _group_join_finish_cb, NULL);
+ ret = companion_request_join_group(handle, group, receive_request_result, NULL);
if (COMP_ERROR_NONE != ret) {
msgr("Failed to Join Group: [%s(0x%X)]", comp_error_to_string(ret), ret);
return RET_FAILURE;
return RET_SUCCESS;
}
-static void _group_create_finish_cb(int result, void *user_data)
-{
- msgb("\rCreate operation finished");
-}
-
static int run_request_create_group(MManager *mm, struct menu_data *menu)
{
int ret = 0;
}
ret = companion_request_create_group(handle, device, request_groupid,
- _group_create_finish_cb, NULL);
+ receive_request_result, NULL);
if (COMP_ERROR_NONE != ret) {
msgr("Failed to Request Create Group: [%s(0x%X)]",
comp_error_to_string(ret), ret);
return RET_SUCCESS;
}
-static void _group_invite_finish_cb(int result, void *user_data)
-{
- msgb("\rInvite operation finished");
-}
-
static int run_request_invite(MManager *mm, struct menu_data *menu)
{
int ret = 0;
}
ret = companion_request_invite_device(handle, group, device, pin,
- _group_invite_finish_cb, NULL);
+ receive_request_result, NULL);
if (COMP_ERROR_NONE != ret) {
msgr("Failed to Request Invite: [%s(0x%X)]", comp_error_to_string(ret), ret);
return RET_FAILURE;
return RET_SUCCESS;
}
-static void _group_eject_finish_cb(int result, void *user_data)
-{
- msgb("\rEject operation finished");
-}
-
static int run_request_eject(MManager *mm, struct menu_data *menu)
{
int ret = 0;
}
}
- ret = companion_request_eject_device(handle, group, device, _group_eject_finish_cb,
+ ret = companion_request_eject_device(handle, group, device, receive_request_result,
NULL);
if (COMP_ERROR_NONE != ret) {
msgr("Failed to Request Eject: [%s(0x%X)]", comp_error_to_string(ret), ret);
return RET_SUCCESS;
}
-static void _group_delete_finish_cb(int result, void *user_data)
-{
- msgb("\rDelete operation finished");
-}
-
static int run_request_delete_group(MManager *mm, struct menu_data *menu)
{
int ret = 0;
}
}
- ret = companion_request_delete_group(handle, group, _group_delete_finish_cb, NULL);
+ ret = companion_request_delete_group(handle, group, receive_request_result, NULL);
if (COMP_ERROR_NONE != ret) {
msgr("Failed to Request Delete Group: [%s(0x%X)]",
comp_error_to_string(ret), ret);
comp_error_to_string(ret), ret);
return RET_FAILURE;
}
- companion_request_result_callback(handle, receive_request_result, NULL);
return RET_SUCCESS;
}
*/
/**
- * @defgroup CAPI_NETWORK_COMPANION_GROUP_MODULE Local Group Management
+ * @defgroup CAPI_NETWORK_COMPANION_GROUP_MODULE Group Management
* @brief The Companion API provides functions for device management.
* @ingroup CAPI_NETWORK_COMPANION_MODULE
*
*/
/**
- * @brief Callback function potiner to be regsitered by calling request to remote groups.
+ * @brief Callback function potiner to be regsitered after sending requests.
*
* @since_tizen 5.0
* @privlevel public
* @privilege %http://tizen.org/privilege/internet
*
+ * @remarks The @a cmd, @arg should not be released.
+ * @remarks The @a cmd, @arg can be used only in the callback. To use outside, make a copy.
*
- * @param[out] result Return code
+ * @param[out] cmd Command
+ * @param[out] arg Argument
+ * @param[out] ret Return code
* @param[out] user_data User data pointer
*
- * @see companion_request_join_group()
- * @see companion_request_leave_group()
- * @see companion_device_send_data()
- * @see companion_device_send_data()
+ * @pre The callback must be registered with companion_request_result_callback()
+ *
+ * @see companion_request_result_callback()
*/
-typedef void (*companion_request_done_cb)(int result, void *user_data);
+typedef void (*companion_request_result_cb)(char *cmd, char *arg, int ret,
+ void *user_data);
/**
* @brief Requests my device to be joined to remote group.
*
*/
int companion_request_join_group(companion_h handle, companion_group_h group,
- companion_request_done_cb cb, void *user_data);
+ companion_request_result_cb cb, void *user_data);
/**
* @brief Requests my device to be exit from remote group.
*
*/
int companion_request_leave_group (companion_h handle, companion_group_h group,
- companion_request_done_cb cb, void *user_data);
+ companion_request_result_cb cb, void *user_data);
/**
* @brief Requests to create a group.
*
*/
int companion_request_create_group(companion_h handle,
- companion_device_h device, char *group_name, companion_request_done_cb cb,
+ companion_device_h device, char *group_name, companion_request_result_cb cb,
void *user_data);
/**
*
*/
int companion_request_invite_device(companion_h handle, companion_group_h group,
- companion_device_h device, char *PIN, companion_request_done_cb cb,
+ companion_device_h device, char *PIN, companion_request_result_cb cb,
void *user_data);
/**
*
*/
int companion_request_eject_device(companion_h handle, companion_group_h group,
- companion_device_h device, companion_request_done_cb cb, void *user_data);
+ companion_device_h device, companion_request_result_cb cb, void *user_data);
/**
* @brief Requests to delete the group.
*
*/
int companion_request_delete_group(companion_h handle, companion_group_h group,
- companion_request_done_cb cb, void *user_data);
-
-/**
- * @brief Callback function potiner to be regsitered by calling
- * companion_request_result_callback().
- *
- * @since_tizen 5.0
- * @privlevel public
- * @privilege %http://tizen.org/privilege/internet
- *
- * @remarks The @a cmd, @arg should not be released.
- * @remarks The @a cmd, @arg can be used only in the callback. To use outside, make a copy.
- *
- * @param[out] cmd Command
- * @param[out] arg Argument
- * @param[out] ret Return code
- * @param[out] user_data User data pointer
- *
- * @pre The callback must be registered with companion_request_result_callback()
- *
- * @see companion_request_result_callback()
- */
-typedef void (*companion_request_result_cb)(char *cmd, char *arg, int ret,
- void *user_data);
-
-/**
- * @brief Registers request result callback funtion.
- * @details This function registers the callback function for requested group management
- * functions and receive processing results after the request complete.
- *
- * @since_tizen 5.0
- *
- * @param[in] handle The companion manager handle
- * @param[in] callback Callback function pointer
- * @param[in] user_data User data pointer
- *
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #COMP_ERROR_NONE Successful
- * @retval #COMP_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @see companion_request_create_group()
- * @see companion_request_invite_device()
- * @see companion_request_eject_device()
- * @see companion_request_delete_group()
- * @see companion_device_send_data()
- *
- */
-int companion_request_result_callback(companion_h handle,
- companion_request_result_cb callback, void *user_data);
+ companion_request_result_cb cb, void *user_data);
/**
* @}
*/
/**
- * @brief Creates a group handle.
- *
- * @since_tizen 5.0
- *
- * @remarks The @a group should be released using companion_group_information_destroy().
- *
- * @param[in] group Group handle
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #COMP_ERROR_NONE Successful
- * @retval #COMP_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @see companion_group_information_clone()
- * @see companion_group_information_destroy()
- * @see companion_group_information_get_type()
- * @see companion_group_information_get_resource_type()
- * @see companion_group_information_get_uri_path()
- * @see companion_group_information_get_name()
- * @see companion_group_information_get_host_addr()
- *
- */
-int companion_group_information_create(companion_group_h* group);
-
-/**
* @brief Clones the group handle.
*
* @since_tizen 5.0
* @{
*/
-/**
- * @brief Creates a device handle.
- *
- * @since_tizen 5.0
- *
- * @remarks The @a device should be released using companion_device_information_destroy().
- *
- * @param[out] device Device handle
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #COMP_ERROR_NONE Successful
- * @retval #COMP_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @see companion_device_information_clone()
- * @see companion_device_information_destroy()
- * @see companion_device_information_get_device_id()
- * @see companion_device_information_get_ip()
- * @see companion_device_information_get_device_type()
- *
- */
-int companion_device_information_create(companion_device_h* device);
/**
* @brief Clones the device handle.
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 __TIZEN_NETWORK_COMPANION_INTERNAL_H__
+#define __TIZEN_NETWORK_COMPANION_INTERNAL_H__
+
+#include <companion.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Creates a group handle.
+ *
+ * @since_tizen 5.0
+ *
+ * @remarks The @a group should be released using companion_group_information_destroy().
+ *
+ * @param[in] group Group handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #COMP_ERROR_NONE Successful
+ * @retval #COMP_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see companion_group_information_clone()
+ * @see companion_group_information_destroy()
+ * @see companion_group_information_get_type()
+ * @see companion_group_information_get_resource_type()
+ * @see companion_group_information_get_uri_path()
+ * @see companion_group_information_get_name()
+ * @see companion_group_information_get_host_addr()
+ *
+ */
+int companion_group_information_create(companion_group_h* group);
+
+
+/**
+ * @brief Creates a device handle.
+ *
+ * @since_tizen 5.0
+ *
+ * @remarks The @a device should be released using companion_device_information_destroy().
+ *
+ * @param[out] device Device handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #COMP_ERROR_NONE Successful
+ * @retval #COMP_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see companion_device_information_clone()
+ * @see companion_device_information_destroy()
+ * @see companion_device_information_get_device_id()
+ * @see companion_device_information_get_ip()
+ * @see companion_device_information_get_device_type()
+ *
+ */
+int companion_device_information_create(companion_device_h* device);
+
+/**
+ * @brief Registers request result callback funtion.
+ * @details This function registers the callback function for requested group management
+ * functions and receive processing results after the request complete.
+ *
+ * @since_tizen 5.0
+ *
+ * @param[in] handle The companion manager handle
+ * @param[in] callback Callback function pointer
+ * @param[in] user_data User data pointer
+ *
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #COMP_ERROR_NONE Successful
+ * @retval #COMP_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see companion_request_create_group()
+ * @see companion_request_invite_device()
+ * @see companion_request_eject_device()
+ * @see companion_request_delete_group()
+ * @see companion_device_send_data()
+ *
+ */
+int companion_request_result_callback(companion_h handle,
+ companion_request_result_cb callback, void *user_data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_NETWORK_COMPANION_INTERNAL_H__ */
return ret;
}
-EXPORT_API int companion_request_join_group(companion_h handle, companion_group_h group,
- companion_group_find_finish_cb callback, void *user_data)
-{
- int ret = COMP_ERROR_NONE;
-
- CHECK_FEATURE_SUPPORTED(COMPANION_FEATURE);
-
- NOTUSED(handle);
- NOTUSED(group);
- NOTUSED(callback);
- NOTUSED(user_data);
-
- return ret;
-}
-
-EXPORT_API int companion_request_leave_group (companion_h handle,
- companion_group_h group, companion_group_find_finish_cb callback, void *user_data)
-{
- int ret = COMP_ERROR_NONE;
-
- CHECK_FEATURE_SUPPORTED(COMPANION_FEATURE);
-
- NOTUSED(handle);
- NOTUSED(group);
- NOTUSED(callback);
- NOTUSED(user_data);
-
- return ret;
-}
-
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)
}
EXPORT_API int companion_request_create_group(companion_h handle,
- companion_device_h device, char *group_name, companion_request_done_cb cb,
+ companion_device_h device, char *group_name, companion_request_result_cb cb,
void *user_data)
{
int ret = COMP_ERROR_NONE;
return ret;
}
+EXPORT_API int companion_request_join_group(companion_h handle, companion_group_h group,
+ companion_request_result_cb callback, void *user_data)
+{
+ int ret = COMP_ERROR_NONE;
+
+ CHECK_FEATURE_SUPPORTED(COMPANION_FEATURE);
+
+ NOTUSED(handle);
+ NOTUSED(group);
+ NOTUSED(callback);
+ NOTUSED(user_data);
+
+ return ret;
+}
+
+EXPORT_API int companion_request_leave_group (companion_h handle,
+ companion_group_h group, companion_request_result_cb callback, void *user_data)
+{
+ int ret = COMP_ERROR_NONE;
+
+ CHECK_FEATURE_SUPPORTED(COMPANION_FEATURE);
+
+ NOTUSED(handle);
+ NOTUSED(group);
+ NOTUSED(callback);
+ NOTUSED(user_data);
+
+ return ret;
+}
+
EXPORT_API int companion_request_invite_device(companion_h handle,
companion_group_h group, companion_device_h device, char *PIN,
- companion_request_done_cb cb, void *user_data)
+ companion_request_result_cb cb, void *user_data)
{
int ret = COMP_ERROR_NONE;
}
EXPORT_API int companion_request_eject_device(companion_h handle,
- companion_group_h group, companion_device_h device, companion_request_done_cb cb,
+ companion_group_h group, companion_device_h device, companion_request_result_cb cb,
void *user_data)
{
int ret = COMP_ERROR_NONE;
}
EXPORT_API int companion_request_delete_group(companion_h handle,
- companion_group_h group, companion_request_done_cb cb, void *user_data)
+ companion_group_h group, companion_request_result_cb cb, void *user_data)
{
int ret = COMP_ERROR_NONE;