summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCheoleun Moon <chleun.moon@samsung.com>2020-04-01 16:35:04 +0900
committerCheoleun Moon <chleun.moon@samsung.com>2020-04-01 16:35:04 +0900
commitfcb7584f1f1ce1b7e5e1f2fbd4a841895e84ff6b (patch)
tree05ef7a545ae60ec9cf7fa6130412f3f2a800ac08 /src
parent57dc59bb6bdf9f3e59a7117ff8e04e15d02e3910 (diff)
downloadwifi-aware-fcb7584f1f1ce1b7e5e1f2fbd4a841895e84ff6b.tar.gz
wifi-aware-fcb7584f1f1ce1b7e5e1f2fbd4a841895e84ff6b.tar.bz2
wifi-aware-fcb7584f1f1ce1b7e5e1f2fbd4a841895e84ff6b.zip
Return errors when setting/unsetting callbacks
Diffstat (limited to 'src')
-rw-r--r--src/include/wifi-aware-private.h8
-rw-r--r--src/wifi-aware-private.c30
-rw-r--r--src/wifi-aware.c5
3 files changed, 25 insertions, 18 deletions
diff --git a/src/include/wifi-aware-private.h b/src/include/wifi-aware-private.h
index 24be508..208d595 100644
--- a/src/include/wifi-aware-private.h
+++ b/src/include/wifi-aware-private.h
@@ -88,12 +88,12 @@ int _wifi_aware_update_subscribe_request(wifi_aware_session_h session, wifi_awar
wifi_aware_subscribed_cb callback, void *user_data);
int _wifi_aware_session_cancel(wifi_aware_session_h session);
-void _wifi_aware_set_service_discovered_cb(wifi_aware_session_h session,
+int _wifi_aware_set_service_discovered_cb(wifi_aware_session_h session,
wifi_aware_service_discovered_cb callback, void *user_data);
-void _wifi_aware_unset_service_discovered_cb(wifi_aware_session_h session);
-void _wifi_aware_set_message_received_cb(wifi_aware_session_h session,
+int _wifi_aware_unset_service_discovered_cb(wifi_aware_session_h session);
+int _wifi_aware_set_message_received_cb(wifi_aware_session_h session,
wifi_aware_message_received_cb callback, void *user_data);
-void _wifi_aware_unset_message_received_cb(wifi_aware_session_h session);
+int _wifi_aware_unset_message_received_cb(wifi_aware_session_h session);
int _wifi_aware_send_message(wifi_aware_session_h session, wifi_aware_peer_h peer,
const unsigned char *message, size_t len,
diff --git a/src/wifi-aware-private.c b/src/wifi-aware-private.c
index 4cecdaa..4952be8 100644
--- a/src/wifi-aware-private.c
+++ b/src/wifi-aware-private.c
@@ -1078,25 +1078,29 @@ static void __message_received_cb(GDBusConnection *connection,
__wifi_aware_received_cb(session, peer, message, message_len);
}
-void _wifi_aware_set_service_discovered_cb(wifi_aware_session_h session,
+int _wifi_aware_set_service_discovered_cb(wifi_aware_session_h session,
wifi_aware_service_discovered_cb callback, void *user_data)
{
__WIFI_AWARE_FUNC_ENTER__;
- RET_IF(session == NULL, "wifi_aware_session_h is NULL");
- RET_IF(!_wifi_aware_session_is_subscribe_type(session), "This session is not for Subscribe");
+ RET_VAL_IF(session == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "wifi_aware_session_h is NULL");
+ RET_VAL_IF(!_wifi_aware_session_is_subscribe_type(session),
+ WIFI_AWARE_ERROR_INVALID_OPERATION, "This session is not for Subscribe");
wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
handle->discovered_cb = callback;
handle->discovered_cb_data = user_data;
handle->discovered_signal_id =
wifi_aware_gdbus_register_signal(SERVICE_DISCOVERED_SIGNAL, __service_discovered_cb, session);
+
+ return WIFI_AWARE_ERROR_NONE;
}
-void _wifi_aware_unset_service_discovered_cb(wifi_aware_session_h session)
+int _wifi_aware_unset_service_discovered_cb(wifi_aware_session_h session)
{
__WIFI_AWARE_FUNC_ENTER__;
- RET_IF(session == NULL, "wifi_aware_session_h is NULL");
- RET_IF(!_wifi_aware_session_is_subscribe_type(session), "This session is not for Subscribe");
+ RET_VAL_IF(session == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "wifi_aware_session_h is NULL");
+ RET_VAL_IF(!_wifi_aware_session_is_subscribe_type(session),
+ WIFI_AWARE_ERROR_INVALID_OPERATION, "This session is not for Subscribe");
wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
handle->discovered_cb = NULL;
@@ -1104,25 +1108,29 @@ void _wifi_aware_unset_service_discovered_cb(wifi_aware_session_h session)
if (handle->discovered_signal_id > 0)
wifi_aware_gdbus_deregister_signal(handle->discovered_signal_id);
handle->discovered_signal_id = 0;
+
+ return WIFI_AWARE_ERROR_NONE;
}
-void _wifi_aware_set_message_received_cb(wifi_aware_session_h session,
+int _wifi_aware_set_message_received_cb(wifi_aware_session_h session,
wifi_aware_message_received_cb callback, void *user_data)
{
__WIFI_AWARE_FUNC_ENTER__;
- RET_IF(session == NULL, "wifi_aware_session_h is NULL");
+ RET_VAL_IF(session == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "wifi_aware_session_h is NULL");
wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
handle->received_cb = callback;
handle->received_cb_data = user_data;
handle->received_signal_id =
wifi_aware_gdbus_register_signal(MESSAGE_RECEIVED_SIGNAL, __message_received_cb, session);
+
+ return WIFI_AWARE_ERROR_NONE;
}
-void _wifi_aware_unset_message_received_cb(wifi_aware_session_h session)
+int _wifi_aware_unset_message_received_cb(wifi_aware_session_h session)
{
__WIFI_AWARE_FUNC_ENTER__;
- RET_IF(session == NULL, "wifi_aware_session_h is NULL");
+ RET_VAL_IF(session == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "wifi_aware_session_h is NULL");
wifi_aware_session_s *handle = (wifi_aware_session_s *)session;
handle->received_cb = NULL;
@@ -1130,6 +1138,8 @@ void _wifi_aware_unset_message_received_cb(wifi_aware_session_h session)
if (handle->received_signal_id > 0)
wifi_aware_gdbus_deregister_signal(handle->received_signal_id);
handle->received_signal_id = 0;
+
+ return WIFI_AWARE_ERROR_NONE;
}
wifi_aware_message_s *__create_message_data(wifi_aware_session_h session,
diff --git a/src/wifi-aware.c b/src/wifi-aware.c
index cfdd5f2..323a8ab 100644
--- a/src/wifi-aware.c
+++ b/src/wifi-aware.c
@@ -470,7 +470,6 @@ API int wifi_aware_session_stop(wifi_aware_session_h session)
CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_WIFI_AWARE);
RET_VAL_IF(!_wifi_aware_is_initialized(), WIFI_AWARE_ERROR_NOT_INITIALIZED, "Not initialized");
RET_VAL_IF(!_wifi_aware_is_enabled(), WIFI_AWARE_ERROR_INVALID_OPERATION, "Not enabled");
- RET_VAL_IF(session == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "wifi_aware_session_h is NULL");
ret = _wifi_aware_session_cancel(session);
RET_VAL_IF(ret != WIFI_AWARE_ERROR_NONE, ret, "_wifi_aware_cancel_subscribe_request");
@@ -507,10 +506,8 @@ API int wifi_aware_session_set_service_discovered_cb(wifi_aware_session_h sessio
RET_VAL_IF(!_wifi_aware_is_initialized(), WIFI_AWARE_ERROR_NOT_INITIALIZED, "Not initialized");
RET_VAL_IF(session == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "wifi_aware_session_h is NULL");
- _wifi_aware_set_service_discovered_cb(session, callback, user_data);
-
__WIFI_AWARE_FUNC_EXIT__;
- return WIFI_AWARE_ERROR_NONE;
+ return _wifi_aware_set_service_discovered_cb(session, callback, user_data);
}
API int wifi_aware_session_unset_service_discovered_cb(wifi_aware_session_h session)