/*****************************************************************************
* Global Variables
*****************************************************************************/
-wifi_direct_client_info_s g_client_info = {
- .is_registered = FALSE,
- .client_id = -1,
- .sync_sockfd = -1,
- .async_sockfd = -1,
- .activation_cb = NULL,
- .discover_cb = NULL,
- .connection_cb = NULL,
- .ip_assigned_cb = NULL,
- .peer_found_cb = NULL,
- .user_data_for_cb_activation = NULL,
- .user_data_for_cb_discover = NULL,
- .user_data_for_cb_connection = NULL,
- .user_data_for_cb_ip_assigned = NULL,
- .user_data_for_cb_peer_found = NULL,
- .user_data_for_cb_device_name = NULL,
-#ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
- .service_cb = NULL,
- .user_data_for_cb_service = NULL,
-#endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
- .mutex = PTHREAD_MUTEX_INITIALIZER
-};
+static __thread wifi_direct_client_info_s g_client_info = {0, };
/*****************************************************************************
* Local Functions Definition
return &g_client_info;
}
+static int __net_wifidirect_gerror_to_enum(GError* error)
+{
+ int ret = WIFI_DIRECT_ERROR_NONE;
+ if (error == NULL) {
+ WDC_LOGI("GError is NULL!!");
+ return ret;
+ }
+
+ WDC_LOGE("wifi_direct_dbus_method_call_sync() failed. error [%d: %s]",
+ error->code, error->message);
+
+ if (NULL == strstr(error->message, "net.wifidirect.Error")) {
+//LCOV_EXCL_START
+ if (NULL != strstr(error->message, ".AccessDenied")) {
+ WDC_LOGE("Client doesn't have wifidirect privilege");
+ ret = WIFI_DIRECT_ERROR_PERMISSION_DENIED;
+ } else {
+ WDC_LOGE("DBus failure");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
+//LCOV_EXCL_STOP
+ } else {
+ if (NULL != strstr(error->message, "InvalidParameter"))
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ else if (NULL != strstr(error->message, "NotPermitted"))
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ else if (NULL != strstr(error->message, "OperationFailed"))
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+//LCOV_EXCL_START
+ else if (NULL != strstr(error->message, "TooManyClient"))
+ ret = WIFI_DIRECT_ERROR_TOO_MANY_CLIENT;
+ else
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+//LCOV_EXCL_STOP
+ }
+ g_error_free(error);
+ return ret;
+}
+
+//LCOV_EXCL_START
+void __wfd_vconf_state_changed_cb(keynode_t *key, void *data)
+{
+ __WDC_LOG_FUNC_START__;
+ int state = 0;
+ int res = 0;
+
+ if (!g_client_info.state_cb) {
+ WDC_LOGI("g_state_cb is NULL!!");
+ __WDC_LOG_FUNC_END__;
+ return; //LCOV_EXCL_LINE
+ }
+
+ res = vconf_get_int(VCONFKEY_WIFI_DIRECT_STATE, &state);
+ if (res < 0) {
+ WDC_LOGE("Failed to get vconf value [%s]\n",
+ VCONFKEY_WIFI_DIRECT_STATE);
+ __WDC_LOG_FUNC_END__;
+ return;
+ }
+
+ if (state == VCONFKEY_WIFI_DIRECT_ACTIVATED) {
+ state = WIFI_DIRECT_STATE_ACTIVATED;
+ } else if (state == VCONFKEY_WIFI_DIRECT_DEACTIVATED) {
+ state = WIFI_DIRECT_STATE_DEACTIVATED;
+ } else if (state == VCONFKEY_WIFI_DIRECT_CONNECTED) {
+ state = WIFI_DIRECT_STATE_CONNECTED;
+ } else if (state == VCONFKEY_WIFI_DIRECT_GROUP_OWNER) {
+ state = WIFI_DIRECT_STATE_CONNECTED;
+ } else if (state == VCONFKEY_WIFI_DIRECT_DISCOVERING) {
+ state = WIFI_DIRECT_STATE_DISCOVERING;
+ } else {
+ WDC_LOGE("This state cannot be set as wifi_direct vconf state[%d]", state);
+ __WDC_LOG_FUNC_END__;
+ return;
+ }
+
+ g_client_info.state_cb(state, g_client_info.user_data_for_cb_state);
+
+ __WDC_LOG_FUNC_END__;
+ return;
+}
+//LCOV_EXCL_STOP
+
/* Manage */
void wifi_direct_process_manage_activation(GDBusConnection *connection,
- const gchar *object_path, GVariant *parameters)
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface,
+ const gchar *signal,
+ GVariant *parameters,
+ gpointer user_data)
{
__WDC_LOG_FUNC_START__;
int error_code;
if (!client->activation_cb) {
WDC_LOGI("activation_cb is NULL!!");
- return;
+ return; //LCOV_EXCL_LINE
}
if (!parameters) {
}
void wifi_direct_process_manage_deactivation(GDBusConnection *connection,
- const gchar *object_path, GVariant *parameters)
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface,
+ const gchar *signal,
+ GVariant *parameters,
+ gpointer user_data)
{
__WDC_LOG_FUNC_START__;
int error_code;
if (!parameters) {
__WDC_LOG_FUNC_END__;
- return;
+ return; //LCOV_EXCL_LINE
}
if (!client->activation_cb) {
__WDC_LOG_FUNC_END__;
}
+//LCOV_EXCL_START
void wifi_direct_process_manage_connection(GDBusConnection *connection,
- const gchar *object_path, GVariant *parameters)
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface,
+ const gchar *signal,
+ GVariant *parameters,
+ gpointer user_data)
{
__WDC_LOG_FUNC_START__;
int error_code;
}
void wifi_direct_process_manage_disconnection(GDBusConnection *connection,
- const gchar *object_path, GVariant *parameters)
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface,
+ const gchar *signal,
+ GVariant *parameters,
+ gpointer user_data)
{
__WDC_LOG_FUNC_START__;
int error_code;
}
void wifi_direct_process_manage_peer_ip_assigned(GDBusConnection *connection,
- const gchar *object_path, GVariant *parameters)
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface,
+ const gchar *signal,
+ GVariant *parameters,
+ gpointer user_data)
{
__WDC_LOG_FUNC_START__;
char *get_str = NULL;
return;
}
- g_variant_get(reply, "(i&s)", ret ,&get_str);
+ g_variant_get(reply, "(i&s)", ret, &get_str);
g_variant_unref(reply);
WDC_LOGD("Interface Name = [%s]", get_str);
}
void wifi_direct_process_manage_listen_started(GDBusConnection *connection,
- const gchar *object_path, GVariant *parameters)
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface,
+ const gchar *signal,
+ GVariant *parameters,
+ gpointer user_data)
{
__WDC_LOG_FUNC_START__;
wifi_direct_client_info_s *client = __wfd_get_control();
}
void wifi_direct_process_manage_discovery_started(GDBusConnection *connection,
- const gchar *object_path, GVariant *parameters)
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface,
+ const gchar *signal,
+ GVariant *parameters,
+ gpointer user_data)
{
__WDC_LOG_FUNC_START__;
wifi_direct_client_info_s *client = __wfd_get_control();
}
void wifi_direct_process_manage_discovery_finished(GDBusConnection *connection,
- const gchar *object_path, GVariant *parameters)
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface,
+ const gchar *signal,
+ GVariant *parameters,
+ gpointer user_data)
{
__WDC_LOG_FUNC_START__;
wifi_direct_client_info_s *client = __wfd_get_control();
}
void wifi_direct_process_manage_peer_found(GDBusConnection *connection,
- const gchar *object_path, GVariant *parameters)
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface,
+ const gchar *signal,
+ GVariant *parameters,
+ gpointer user_data)
{
__WDC_LOG_FUNC_START__;
const gchar *peer_mac_address = NULL;
}
void wifi_direct_process_manage_peer_lost(GDBusConnection *connection,
- const gchar *object_path, GVariant *parameters)
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface,
+ const gchar *signal,
+ GVariant *parameters,
+ gpointer user_data)
{
__WDC_LOG_FUNC_START__;
const gchar *peer_mac_address = NULL;
/* Group */
void wifi_direct_process_group_created(GDBusConnection *connection,
- const gchar *object_path, GVariant *parameters)
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface,
+ const gchar *signal,
+ GVariant *parameters,
+ gpointer user_data)
{
__WDC_LOG_FUNC_START__;
wifi_direct_client_info_s *client = __wfd_get_control();
}
void wifi_direct_process_group_destroyed(GDBusConnection *connection,
- const gchar *object_path, GVariant *parameters)
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface,
+ const gchar *signal,
+ GVariant *parameters,
+ gpointer user_data)
{
__WDC_LOG_FUNC_START__;
wifi_direct_client_info_s *client = __wfd_get_control();
#ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
/* Service */
void wifi_direct_process_service_discovery_started(GDBusConnection *connection,
- const gchar *object_path, GVariant *parameters)
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface,
+ const gchar *signal,
+ GVariant *parameters,
+ gpointer user_data)
{
__WDC_LOG_FUNC_START__;
wifi_direct_client_info_s *client = __wfd_get_control();
}
void wifi_direct_process_service_discovery_found(GDBusConnection *connection,
- const gchar *object_path, GVariant *parameters)
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface,
+ const gchar *signal,
+ GVariant *parameters,
+ gpointer user_data)
{
__WDC_LOG_FUNC_START__;
wifi_direct_service_type_e service_type;
}
void wifi_direct_process_service_discovery_finished(GDBusConnection *connection,
- const gchar *object_path, GVariant *parameters)
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface,
+ const gchar *signal,
+ GVariant *parameters,
+ gpointer user_data)
{
__WDC_LOG_FUNC_START__;
wifi_direct_client_info_s *client = __wfd_get_control();
int i = 0;
WDC_LOGD("------------------------------------------");
- for (i = 0; i < num; i++)
- {
+ for (i = 0; i < num; i++) {
WDC_LOGD("== Peer index : %d ==", i);
WDC_LOGD("is Group Owner ? %s", list[i].is_group_owner ? "YES" : "NO");
WDC_LOGD("device_name : %s", list[i].device_name);
}
WDC_LOGD("------------------------------------------\n");
}
+//LCOV_EXCL_STOP
int wifi_direct_initialize(void)
{
CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
+ GError* error = NULL;
+ GVariant *reply = NULL;
bool wifi_direct_enable;
+ bool val;
int res = 0;
if (g_client_info.is_registered == TRUE) {
if (res < 0) {
WDC_LOGE("Failed to get sys info");
__WDC_LOG_FUNC_END__;
- return res;
+ return res; //LCOV_EXCL_LINE
}
if (!wifi_direct_enable) {
WDC_LOGE("Wi-Fi Direct not supported");
- return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
+ return WIFI_DIRECT_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
}
if (wifi_direct_dbus_init() == FALSE) {
WDC_LOGW("Failed to initialize dbus");
__WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
}
+ reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_GROUP_INTERFACE,
+ "IsGroupOwner", NULL, &error);
+
+ res = __net_wifidirect_gerror_to_enum(error);
+ if (res != WIFI_DIRECT_ERROR_NONE)
+ return res;
+
+ g_variant_get(reply, "(b)", &val);
+ WDC_LOGD("is group owner [%s]", val ? "YES" : "NO");
+
g_client_info.is_registered = TRUE;
/* Initialize callbacks */
g_client_info.activation_cb = NULL;
+ g_client_info.user_data_for_cb_activation = NULL;
+
g_client_info.discover_cb = NULL;
+ g_client_info.user_data_for_cb_discover = NULL;
+
g_client_info.connection_cb = NULL;
+ g_client_info.user_data_for_cb_connection = NULL;
+
g_client_info.ip_assigned_cb = NULL;
+ g_client_info.user_data_for_cb_ip_assigned = NULL;
g_client_info.peer_found_cb = NULL;
- g_client_info.user_data_for_cb_activation = NULL;
- g_client_info.user_data_for_cb_discover = NULL;
- g_client_info.user_data_for_cb_connection = NULL;
- g_client_info.user_data_for_cb_ip_assigned = NULL;
g_client_info.user_data_for_cb_peer_found = NULL;
- g_client_info.user_data_for_cb_device_name = NULL;
#ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
g_client_info.service_cb = NULL;
- g_client_info.user_data_for_cb_service= NULL;
+ g_client_info.user_data_for_cb_service = NULL;
#endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
__WDC_LOG_FUNC_END__;
wifi_direct_dbus_deinit();
g_client_info.activation_cb = NULL;
- g_client_info.discover_cb = NULL;
- g_client_info.connection_cb = NULL;
- g_client_info.ip_assigned_cb = NULL;
- g_client_info.peer_found_cb = NULL;
g_client_info.user_data_for_cb_activation = NULL;
+
+ g_client_info.discover_cb = NULL;
g_client_info.user_data_for_cb_discover = NULL;
+
+ g_client_info.connection_cb = NULL;
g_client_info.user_data_for_cb_connection = NULL;
+
+ g_client_info.ip_assigned_cb = NULL;
g_client_info.user_data_for_cb_ip_assigned = NULL;
+
+ g_client_info.peer_found_cb = NULL;
g_client_info.user_data_for_cb_peer_found = NULL;
#ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
CHECK_FEATURE_SUPPORTED(WIFIDIRECT_SERVICE_DISCOVERY_FEATURE);
+//LCOV_EXCL_START
if (!cb) {
WDC_LOGE("Callback is NULL.");
__WDC_LOG_FUNC_END__;
__WDC_LOG_FUNC_END__;
return WIFI_DIRECT_ERROR_NONE;
+//LCOV_EXCL_STOP
#else /* TIZEN_FEATURE_SERVICE_DISCOVERY */
return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
#endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
CHECK_FEATURE_SUPPORTED(WIFIDIRECT_SERVICE_DISCOVERY_FEATURE);
+//LCOV_EXCL_START
if (g_client_info.is_registered == false) {
WDC_LOGE("Client is not initialized.");
__WDC_LOG_FUNC_END__;
__WDC_LOG_FUNC_END__;
return WIFI_DIRECT_ERROR_NONE;
+//LCOV_EXCL_STOP
#else /* TIZEN_FEATURE_SERVICE_DISCOVERY */
return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
#endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
return WIFI_DIRECT_ERROR_NONE;
}
+int wifi_direct_set_state_changed_cb(wifi_direct_state_changed_cb cb, void *user_data)
+{
+ __WDC_LOG_FUNC_START__;
+ int ret = WIFI_DIRECT_ERROR_NONE;
+
+ CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
+
+ if (!cb) {
+ WDC_LOGE("Callback is NULL");
+ __WDC_LOG_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = vconf_notify_key_changed(VCONFKEY_WIFI_DIRECT_STATE,
+ __wfd_vconf_state_changed_cb, NULL);
+ if (ret) {
+ WDC_LOGE("Failed to set vconf notification callback");
+ __WDC_LOG_FUNC_END__;
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
+
+ g_client_info.state_cb = cb;
+ g_client_info.user_data_for_cb_state = user_data;
+
+ __WDC_LOG_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NONE;
+}
+
+int wifi_direct_unset_state_changed_cb(void)
+{
+ __WDC_LOG_FUNC_START__;
+ int ret = WIFI_DIRECT_ERROR_NONE;
+
+ CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
+
+ ret = vconf_ignore_key_changed(VCONFKEY_WIFI_DIRECT_STATE,
+ __wfd_vconf_state_changed_cb);
+ if (ret) {
+ WDC_LOGE("Failed to ignore vconf notification callback");
+ __WDC_LOG_FUNC_END__;
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
+
+ g_client_info.state_cb = NULL;
+ g_client_info.user_data_for_cb_state = NULL;
+
+ __WDC_LOG_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NONE;
+}
+
int wifi_direct_activate(void)
{
__WDC_LOG_FUNC_START__;
reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
"Activate", NULL, &error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
"Deactivate", NULL, &error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
}
- builder = g_variant_builder_new(G_VARIANT_TYPE ("a{sv}"));
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
g_variant_builder_add(builder, "{sv}", "Mode", g_variant_new("b", listen_only));
g_variant_builder_add(builder, "{sv}", "Timeout", g_variant_new("i", timeout));
params = g_variant_new("(a{sv})", builder);
reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
"StartDiscovery", params, &error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
}
- builder = g_variant_builder_new(G_VARIANT_TYPE ("a{sv}"));
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
g_variant_builder_add(builder, "{sv}", "Mode", g_variant_new("b", listen_only));
g_variant_builder_add(builder, "{sv}", "Timeout", g_variant_new("i", timeout));
g_variant_builder_add(builder, "{sv}", "Channel", g_variant_new("i", channel));
reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
"StartDiscovery", params, &error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
"StopDiscovery", NULL, &error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
return ret;
}
-#ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
+#if 0
static char **get_service_list(char *services, unsigned int *count)
{
__WDC_LOG_FUNC_START__;
unsigned int cnt = 0;
unsigned int i = 0;
unsigned int j = 0;
+ char *saveptr = NULL;
if (!count || !services || (services && strlen(services) <= 0)) {
WDC_LOGE("Invalid parameters.");
pos1 = services;
pos2 = g_strdup(services);
- pos1 = strtok (pos1,",\n");
+ pos1 = strtok_r(pos1, ",\n", &saveptr);
while (pos1) {
cnt++;
- pos1 = strtok (NULL, ",\n");
+ pos1 = strtok_r(NULL, ",\n", &saveptr);
}
WDC_LOGD("Total Service Count = %d", cnt);
g_free(pos2);
return NULL;
}
- pos2 = strtok (pos2,",\n");
+ pos2 = strtok_r(pos2, ",\n", &saveptr);
while (pos2 != NULL) {
char *s = strchr(pos2, ' ');
if (s) {
*s = '\0';
result[i++] = strdup(pos2);
- pos2 = strtok (NULL, ",\n");
+ pos2 = strtok_r(NULL, ",\n", &saveptr);
}
}
}
} else {
*count = 0;
if (result) {
- for (j=0; j<i && result[j] != NULL; j++)
+ for (j = 0; j < i && result[j] != NULL; j++)
free(result[j]);
free(result);
}
reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
"GetDiscoveredPeers", params, &error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
g_variant_get(reply, "(iaa{sv})", &ret, &iter_peers);
if (ret != WIFI_DIRECT_ERROR_NONE) {
}
WDC_LOGD("wifi_direct_foreach_discovered_peers() SUCCESS");
-
- while(g_variant_iter_loop(iter_peers, "a{sv}", &iter_peer)) {
+//LCOV_EXCL_START
+ while (g_variant_iter_loop(iter_peers, "a{sv}", &iter_peer)) {
wifi_direct_discovered_peer_info_s *peer_list = NULL;
peer_list = (wifi_direct_discovered_peer_info_s *) g_try_malloc0(sizeof(wifi_direct_discovered_peer_info_s));
}
}
- //__wfd_client_print_entry_list(peer_list, 1);
+ /* __wfd_client_print_entry_list(peer_list, 1); */
if (!cb(peer_list, user_data)) {
g_variant_iter_free(iter_peer);
break;
}
}
-
+//LCOV_EXCL_STOP
g_variant_iter_free(iter_peers);
g_variant_unref(reply);
__WDC_LOG_FUNC_END__;
params = g_variant_new("(s)", mac_address);
reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
"Connect", params, &error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
return ret;
}
+//LCOV_EXCL_START
int wifi_direct_cancel_connection(char *mac_address)
{
__WDC_LOG_FUNC_START__;
params = g_variant_new("(s)", mac_address);
reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
"CancelConnection", params, &error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
params = g_variant_new("(s)", mac_address);
reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
"RejectConnection", params, &error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
return ret;
}
-
+//LCOV_EXCL_STOP
int wifi_direct_disconnect_all(void)
{
reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
"DisconnectAll", NULL, &error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
return ret;
}
-
+//LCOV_EXCL_START
int wifi_direct_disconnect(char *mac_address)
{
__WDC_LOG_FUNC_START__;
params = g_variant_new("(s)", mac_address);
reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
"Disconnect", params, &error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
params = g_variant_new("(s)", mac_address);
reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
"AcceptConnection", params, &error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
return ret;
}
-
+//LCOV_EXCL_STOP
int wifi_direct_foreach_connected_peers(wifi_direct_connected_peer_cb cb,
void *user_data)
return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
}
+//LCOV_EXCL_START
reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
"GetConnectedPeers", params, &error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
g_variant_get(reply, "(iaa{sv})", &ret, &iter_peers);
if (ret != WIFI_DIRECT_ERROR_NONE) {
WDC_LOGD("wifi_direct_foreach_connected_peers() SUCCESS");
- while(g_variant_iter_loop(iter_peers, "a{sv}", &iter_peer)) {
+ while (g_variant_iter_loop(iter_peers, "a{sv}", &iter_peer)) {
wifi_direct_connected_peer_info_s *peer_list = NULL;
peer_list = (wifi_direct_connected_peer_info_s *) g_try_malloc0(sizeof(wifi_direct_connected_peer_info_s));
}
}
- //__wfd_client_print_connected_peer_info(peer_list, 1);
+ /* __wfd_client_print_connected_peer_info(peer_list, 1); */
if (!cb(peer_list, user_data)) {
g_variant_iter_free(iter_peer);
break;
g_variant_iter_free(iter_peers);
g_variant_unref(reply);
+//LCOV_EXCL_STOP
__WDC_LOG_FUNC_END__;
return WIFI_DIRECT_ERROR_NONE;
}
reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_GROUP_INTERFACE,
"CreateGroup", NULL, &error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_GROUP_INTERFACE,
"DestroyGroup", NULL, &error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
GError* error = NULL;
GVariant *reply = NULL;
+ int ret = WIFI_DIRECT_ERROR_NONE;
bool val;
if (g_client_info.is_registered == false) {
"IsGroupOwner",
NULL,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
+
WDC_LOGD("%s() SUCCESS", __func__);
g_variant_get(reply, "(b)", &val);
*owner = val;
GError* error = NULL;
GVariant *reply = NULL;
+ int ret = WIFI_DIRECT_ERROR_NONE;
bool val;
if (g_client_info.is_registered == false) {
"IsAutoGroup",
NULL,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
+
WDC_LOGD("%s() SUCCESS", __func__);
g_variant_get(reply, "(b)", &val);
*autonomous_group = val;
"SetGoIntent",
params,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
"GetGoIntent",
NULL,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
g_variant_get(reply, "(ii)", &ret, &val);
*intent = val;
"SetMaxClient",
params,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
"GetMaxClient",
NULL,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
g_variant_get(reply, "(ii)", &ret, &val);
*max = val;
"GetOperatingChannel",
NULL,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
g_variant_get(reply, "(ii)", &ret, &val);
*channel = val;
"ActivatePushButton",
NULL,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- WDC_LOGD("%s() SUCCESS", __func__);
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
"SetWpsPin",
params,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
"GetWpsPin",
NULL,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
g_variant_get(reply, "(i&s)", &ret, &str);
- if(pin != NULL && str != NULL)
+ if (pin != NULL && str != NULL)
*pin = g_strdup(str);
g_variant_unref(reply);
"GetSupportedWpsMode",
NULL,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
g_variant_get(reply, "(ii)", &ret, &mode);
*wps_mode = mode;
"GetSupportedWpsMode",
NULL,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
g_variant_get(reply, "(ii)", &ret, &wps_mode);
g_variant_unref(reply);
"GetLocalWpsMode",
NULL,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
g_variant_get(reply, "(ii)", &ret, &mode);
*type = mode;
"SetReqWpsMode",
params,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
"GetReqWpsMode",
NULL,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
g_variant_get(reply, "(ii)", &ret, &mode);
*type = mode;
"GetDeviceName",
NULL,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
g_variant_get(reply, "(i&s)", &ret, &str);
*ssid = g_strdup(str);
"GetDeviceName",
NULL,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
g_variant_get(reply, "(i&s)", &ret, &str);
*device_name = g_strdup(str);
"SetDeviceName",
params,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
return ret;
}
+//LCOV_EXCL_START
int wifi_direct_get_network_interface_name(char **name)
{
__WDC_LOG_FUNC_START__;
"GetInterfaceName",
NULL,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i&s)", ret ,&get_str);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
+
+ g_variant_get(reply, "(i&s)", ret, &get_str);
*name = g_strdup(get_str);
g_variant_unref(reply);
"GetIPAddress",
NULL,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i&s)", ret ,&str);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
+
+ g_variant_get(reply, "(i&s)", ret, &str);
*ip_address = g_strdup(str);
g_variant_unref(reply);
ret = wifi_direct_get_state(&status);
WDC_LOGD("wifi_direct_get_state() state=[%d], ret=[%d]", status, ret);
- if( status < WIFI_DIRECT_STATE_CONNECTED) {
+ if (status < WIFI_DIRECT_STATE_CONNECTED) {
WDC_LOGE("Device is not connected!");
__WDC_LOG_FUNC_END__;
return WIFI_DIRECT_ERROR_NOT_PERMITTED;
"GetSubnetMask",
NULL,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i&s)", ret ,&get_str);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
+
+ g_variant_get(reply, "(i&s)", ret, &get_str);
*subnet_mask = g_strdup(get_str);
g_variant_unref(reply);
ret = wifi_direct_get_state(&status);
WDC_LOGD("wifi_direct_get_state() state=[%d], ret=[%d]", status, ret);
- if(status < WIFI_DIRECT_STATE_CONNECTED) {
+ if (status < WIFI_DIRECT_STATE_CONNECTED) {
WDC_LOGE("Device is not connected!");
__WDC_LOG_FUNC_END__;
return WIFI_DIRECT_ERROR_NOT_PERMITTED;
"GetGateway",
NULL,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i&s)", ret ,&get_str);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
+
+ g_variant_get(reply, "(i&s)", ret, &get_str);
*gateway_address = g_strdup(get_str);
g_variant_unref(reply);
__WDC_LOG_FUNC_END__;
return WIFI_DIRECT_ERROR_NONE;
}
+//LCOV_EXCL_STOP
int wifi_direct_get_mac_address(char **mac_address)
{
"GetMacAddress",
NULL,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
g_variant_get(reply, "(i&s)", &ret, &str);
*mac_address = g_strdup(str);
return ret;
}
-
int wifi_direct_get_state(wifi_direct_state_e *state)
{
__WDC_LOG_FUNC_START__;
CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
- GError* error = NULL;
- GVariant *reply = NULL;
int val = 0;
int ret = WIFI_DIRECT_ERROR_NONE;
- if (g_client_info.is_registered == false) {
- WDC_LOGE("Client is NOT registered");
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
- }
-
if (!state) {
WDC_LOGE("Invalid Parameter");
__WDC_LOG_FUNC_END__;
return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
}
- reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
- "GetState", NULL, &error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
+ ret = vconf_get_int(VCONFKEY_WIFI_DIRECT_STATE, &val);
+ if (ret < 0) {
+ WDC_LOGE("Failed to get vconf value [%s]\n", VCONFKEY_WIFI_DIRECT_STATE);
__WDC_LOG_FUNC_END__;
return WIFI_DIRECT_ERROR_OPERATION_FAILED;
}
- g_variant_get(reply, "(ii)", &ret, &val);
- *state = (wifi_direct_state_e) val;
- /* for CAPI : there is no WIFI_DIRECT_STATE_GROUP_OWNER type in CAPI */
- if(*state == WIFI_DIRECT_STATE_GROUP_OWNER)
+ if (val == VCONFKEY_WIFI_DIRECT_ACTIVATED) {
+ *state = WIFI_DIRECT_STATE_ACTIVATED;
+ } else if (val == VCONFKEY_WIFI_DIRECT_DEACTIVATED) {
+ *state = WIFI_DIRECT_STATE_DEACTIVATED;
+ } else if (val == VCONFKEY_WIFI_DIRECT_CONNECTED) {
*state = WIFI_DIRECT_STATE_CONNECTED;
-
- g_variant_unref(reply);
+ } else if (val == VCONFKEY_WIFI_DIRECT_GROUP_OWNER) {
+ *state = WIFI_DIRECT_STATE_CONNECTED;
+ } else if (val == VCONFKEY_WIFI_DIRECT_DISCOVERING) {
+ *state = WIFI_DIRECT_STATE_DISCOVERING;
+ } else {
+ WDC_LOGE("This state cannot be set as wifi_direct vconf state[%d]", val);
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
WDC_LOGD("State = [%d]", *state);
WDC_LOGD("%s() return : [%d]", __func__, ret);
return ret;
}
-
int wifi_direct_is_discoverable(bool* discoverable)
{
__WDC_LOG_FUNC_START__;
GError* error = NULL;
GVariant *reply = NULL;
+ int ret = WIFI_DIRECT_ERROR_NONE;
if (g_client_info.is_registered == false) {
WDC_LOGE("Client is NOT registered");
reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
"IsDiscoverable", NULL, &error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
g_variant_get(reply, "(b)", discoverable);
- WDC_LOGD("Discoverable = [%s]", *discoverable ? "Yes":"No");
+ WDC_LOGD("Discoverable = [%s]", *discoverable ? "Yes" : "No");
WDC_LOGD("%s() SUCCESS", __func__);
g_variant_unref(reply);
GError* error = NULL;
GVariant *reply = NULL;
+ int ret = WIFI_DIRECT_ERROR_NONE;
if (g_client_info.is_registered == false) {
WDC_LOGE("Client is NOT registered");
reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
"IsListeningOnly", NULL, &error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
g_variant_get(reply, "(b)", listen_only);
- WDC_LOGD("Is listen only = [%s]", *listen_only ? "Yes":"No");
+ WDC_LOGD("Is listen only = [%s]", *listen_only ? "Yes" : "No");
WDC_LOGD("%s() SUCCESS", __func__);
g_variant_unref(reply);
CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
- if (!type) {
- WDC_LOGE("NULL Param [type]!");
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- }
+ GError* error = NULL;
+ GVariant *reply = NULL;
+ int ret = WIFI_DIRECT_ERROR_NONE;
+ int primary_device_type = 0;
if (g_client_info.is_registered == false) {
WDC_LOGE("Client is NOT registered");
return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
-#ifdef TIZEN_TV
- WDC_LOGD("Current primary_dev_type [%d]", WIFI_DIRECT_PRIMARY_DEVICE_TYPE_DISPLAY);
- *type = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_DISPLAY;
-#else /* TIZEN_TV */
- WDC_LOGD("Current primary_dev_type [%d]", WIFI_DIRECT_PRIMARY_DEVICE_TYPE_TELEPHONE);
- *type = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_TELEPHONE;
-#endif /* TIZEN_TV */
+ if (type == NULL) {
+ WDC_LOGE("NULL Param [type]!");
+ __WDC_LOG_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ }
+
+ reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
+ "GetPrimaryDevType",
+ NULL, &error);
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
+
+ WDC_LOGD("%s() SUCCESS", __func__);
+ g_variant_get(reply, "(ii)", &ret, &primary_device_type);
+ g_variant_unref(reply);
+ *type = primary_device_type;
__WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_NONE;
+ return ret;
}
int wifi_direct_get_secondary_device_type(wifi_direct_secondary_device_type_e* type)
CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
+ GError* error = NULL;
+ GVariant *reply = NULL;
+ int ret = WIFI_DIRECT_ERROR_NONE;
+ int secondary_device_type = 0;
+
if (g_client_info.is_registered == false) {
WDC_LOGE("Client is NOT registered");
__WDC_LOG_FUNC_END__;
return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
- if (NULL == type) {
+ if (type == NULL) {
WDC_LOGE("NULL Param [type]!");
__WDC_LOG_FUNC_END__;
return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
}
-#ifdef TIZEN_TV
- WDC_LOGD("Current second_dev_type [%d]", WIFI_DIRECT_SECONDARY_DEVICE_TYPE_DISPLAY_TV);
- *type = WIFI_DIRECT_SECONDARY_DEVICE_TYPE_DISPLAY_TV;
-#else /* TIZEN_TV */
- WDC_LOGD("Current second_dev_type [%d]", WIFI_DIRECT_SECONDARY_DEVICE_TYPE_TELEPHONE_SMARTPHONE_DUAL);
- *type = WIFI_DIRECT_SECONDARY_DEVICE_TYPE_TELEPHONE_SMARTPHONE_DUAL; /* smart phone dual mode (wifi and cellular) */
-#endif /* TIZEN_TV */
+ reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
+ "GetSecondaryDevType",
+ NULL, &error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_NONE;
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
+
+ WDC_LOGD("%s() SUCCESS", __func__);
+ g_variant_get(reply, "(ii)", &ret, &secondary_device_type);
+ g_variant_unref(reply);
+ *type = secondary_device_type;
+
+ __WDC_LOG_FUNC_END__;
+ return ret;
}
int wifi_direct_set_autoconnection_mode(bool mode)
"SetAutoConnectionMode",
params,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
"IsAutoConnectionMode",
NULL,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
g_variant_get(reply, "(ib)", &ret, &val);
*mode = val;
GError* error = NULL;
GVariant *reply = NULL;
GVariant *params = NULL;
+ int ret = WIFI_DIRECT_ERROR_NONE;
if (g_client_info.is_registered == false) {
WDC_LOGE("Client is NOT registered");
"SetPersistentGroupEnabled",
params,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
}
- WDC_LOGD("%s() SUCCESS", __func__);
- g_variant_unref(reply);
+ WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
return WIFI_DIRECT_ERROR_NONE;
GError* error = NULL;
GVariant *reply = NULL;
+ int ret = WIFI_DIRECT_ERROR_NONE;
bool val;
if (g_client_info.is_registered == false) {
"IsPersistentGroupEnabled",
NULL,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
+
WDC_LOGD("%s() SUCCESS", __func__);
g_variant_get(reply, "(b)", &val);
*enabled = val;
reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_GROUP_INTERFACE,
"GetPersistentGroups", params, &error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
g_variant_get(reply, "(iaa{sv})", &ret, &iter_groups);
if (ret != WIFI_DIRECT_ERROR_NONE) {
}
WDC_LOGD("wifi_direct_foreach_persistent_groups() SUCCESS");
-
- while(g_variant_iter_loop(iter_groups, "a{sv}", &iter_group)) {
+//LCOV_EXCL_START
+ while (g_variant_iter_loop(iter_groups, "a{sv}", &iter_group)) {
const char *ssid = NULL;
char *go_mac_address = NULL;
break;
}
}
-
+//LCOV_EXCL_STOP
g_variant_iter_free(iter_groups);
__WDC_LOG_FUNC_END__;
return WIFI_DIRECT_ERROR_NONE;
}
+//LCOV_EXCL_START
int wifi_direct_remove_persistent_group(char *mac_address, const char *ssid)
{
__WDC_LOG_FUNC_START__;
GError* error = NULL;
GVariant *reply = NULL;
GVariant *params = NULL;
+ int ret = WIFI_DIRECT_ERROR_NONE;
if (g_client_info.is_registered == false) {
WDC_LOGE("Client is NOT registered");
"RemovePersistentGroup",
params,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- WDC_LOGD("%s() SUCCESS", __func__);
- g_variant_unref(reply);
-
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_NONE;
-}
-
-int wifi_direct_set_p2poem_loglevel(int increase_log_level)
-{
- __WDC_LOG_FUNC_START__;
-/* TODO:
- wifi_direct_client_request_s req;
- wifi_direct_client_response_s rsp;
- int res = WIFI_DIRECT_ERROR_NONE;
-
- if (g_client_info.is_registered == false) {
- WDC_LOGE("Client is NOT registered");
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
}
- memset(&req, 0, sizeof(wifi_direct_client_request_s));
- memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
-
- req.cmd = WIFI_DIRECT_CMD_SET_OEM_LOGLEVEL;
- req.client_id = g_client_info.client_id;
- if (increase_log_level == 0)
- req.data.int1 = false;
- else
- req.data.int1 = true;
+ WDC_LOGD("%s() return : [%d]", __func__, ret);
- res = __wfd_client_send_request(g_client_info.sync_sockfd, &req, &rsp);
- if (res != WIFI_DIRECT_ERROR_NONE) {
- __WDC_LOG_FUNC_END__;
- return res;
- }
-*/
__WDC_LOG_FUNC_END__;
return WIFI_DIRECT_ERROR_NONE;
}
+//LCOV_EXCL_STOP
int wifi_direct_start_service_discovery(char *mac_address,
wifi_direct_service_type_e type)
CHECK_FEATURE_SUPPORTED(WIFIDIRECT_SERVICE_DISCOVERY_FEATURE);
+//LCOV_EXCL_START
+
GError* error = NULL;
GVariant *reply = NULL;
GVariant *params = NULL;
"StartDiscovery",
params,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
return ret;
+//LCOV_EXCL_STOP
#else /* TIZEN_FEATURE_SERVICE_DISCOVERY */
return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
#endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
__WDC_LOG_FUNC_START__;
CHECK_FEATURE_SUPPORTED(WIFIDIRECT_SERVICE_DISCOVERY_FEATURE);
-
+//LCOV_EXCL_START
GError* error = NULL;
GVariant *reply = NULL;
GVariant *params = NULL;
"StopDiscovery",
params,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
return ret;
+//LCOV_EXCL_STOP
#else /* TIZEN_FEATURE_SERVICE_DISCOVERY */
return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
#endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
__WDC_LOG_FUNC_START__;
CHECK_FEATURE_SUPPORTED(WIFIDIRECT_SERVICE_DISCOVERY_FEATURE);
-
+//LCOV_EXCL_START
GError* error = NULL;
GVariant *reply = NULL;
GVariant *params = NULL;
"Register",
params,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ g_free(buf);
+ return ret;
}
g_variant_get(reply, "(ii)", &ret, service_id);
g_variant_unref(reply);
+ g_free(buf);
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
return ret;
+//LCOV_EXCL_STOP
#else /* TIZEN_FEATURE_SERVICE_DISCOVERY */
return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
#endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
__WDC_LOG_FUNC_START__;
CHECK_FEATURE_SUPPORTED(WIFIDIRECT_SERVICE_DISCOVERY_FEATURE);
-
+//LCOV_EXCL_START
GError* error = NULL;
GVariant *reply = NULL;
GVariant *params = NULL;
"Deregister",
params,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
return ret;
+//LCOV_EXCL_STOP
#else /* TIZEN_FEATURE_SERVICE_DISCOVERY */
return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
#endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
__WDC_LOG_FUNC_START__;
int ret = WIFI_DIRECT_ERROR_NONE;
- if(enable)
+ if (enable)
ret = wifi_direct_init_display();
else
ret = wifi_direct_deinit_display();
__WDC_LOG_FUNC_END__;
return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
}
-
+//LCOV_EXCL_START
params = g_variant_new("(s)", mac_address);
reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
"GetPeerInfo", params, &error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
g_variant_get(reply, "(ia{sv})", &ret, &iter_peer);
if (ret != WIFI_DIRECT_ERROR_NONE) {
peer->device_name = g_strndup(device_name, WIFI_DIRECT_MAX_DEVICE_NAME_LEN+1);
} else if (!g_strcmp0(key, "DeviceAddress")) {
- unsigned char mac_address[MACADDR_LEN] = {0, };
+ unsigned char l_mac_address[MACADDR_LEN] = {0, };
- wifi_direct_dbus_unpack_ay(mac_address, var, MACADDR_LEN);
+ wifi_direct_dbus_unpack_ay(l_mac_address, var, MACADDR_LEN);
peer->mac_address = (char*) g_try_malloc0(MACSTR_LEN);
if (peer->mac_address)
- g_snprintf(peer->mac_address, MACSTR_LEN, MACSTR, MAC2STR(mac_address));
+ g_snprintf(peer->mac_address, MACSTR_LEN, MACSTR, MAC2STR(l_mac_address));
} else if (!g_strcmp0(key, "InterfaceAddress")) {
unsigned char intf_address[MACADDR_LEN] = {0, };
*peer_info = peer;
g_variant_unref(reply);
+//LCOV_EXCL_STOP
__WDC_LOG_FUNC_END__;
return WIFI_DIRECT_ERROR_NONE;
}
GError* error = NULL;
GVariant *reply = NULL;
GVariant *params = NULL;
+ int ret = WIFI_DIRECT_ERROR_NONE;
if (g_client_info.is_registered == false) {
WDC_LOGE("Client is NOT registered.");
"SetPassphrase",
params,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
}
- WDC_LOGD("%s() SUCCESS", __func__);
- g_variant_unref(reply);
+ WDC_LOGD("%s() SUCCESS", __func__);
__WDC_LOG_FUNC_END__;
return WIFI_DIRECT_ERROR_NONE;
return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
- if(!passphrase){
+ if (!passphrase) {
WDC_LOGE("NULL Param [passphrase]!");
__WDC_LOG_FUNC_END__;
return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
"GetPassphrase",
NULL,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
+
WDC_LOGD("%s() SUCCESS", __func__);
g_variant_get(reply, "(i&s)", &ret, &val);
*passphrase = g_strdup(val);
"SetAutoConnectionPeer",
params,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
"Init",
NULL,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
"Deinit",
NULL,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
"SetConfig",
params,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
"SetAvailiability",
params,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- g_variant_get(reply, "(i)", &ret);
- g_variant_unref(reply);
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
WDC_LOGD("%s() return : [%d]", __func__, ret);
__WDC_LOG_FUNC_END__;
#endif /* TIZEN_FEATURE_WIFI_DISPLAY */
}
+//LCOV_EXCL_START
int wifi_direct_get_peer_display_type(char *mac_address, wifi_direct_display_type_e *type)
{
__WDC_LOG_FUNC_START__;
"GetPeerType",
params,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
g_variant_get(reply, "(ii)", &ret, &val);
*type = val;
"GetPeerAvailability",
params,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
g_variant_get(reply, "(ii)", &ret, &val);
*availability = val;
"GetPeerHdcp",
params,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
g_variant_get(reply, "(ii)", &ret, &val);
*hdcp = val;
"GetPeerPort",
params,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
g_variant_get(reply, "(ii)", &ret, &val);
*port = val;
"GetPeerThroughput",
params,
&error);
- if (error != NULL) {
- WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
- "error [%d: %s]", error->code, error->message);
- g_error_free(error);
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
g_variant_get(reply, "(ii)", &ret, &val);
*throughput = val;
return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
#endif /* TIZEN_FEATURE_WIFI_DISPLAY */
}
+
+int wifi_direct_set_session_timer(int seconds)
+{
+ __WDC_LOG_FUNC_START__;
+
+ CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
+
+ GError* error = NULL;
+ GVariant *reply = NULL;
+ GVariant *params = NULL;
+ int ret = WIFI_DIRECT_ERROR_NONE;
+
+ if (g_client_info.is_registered == false) {
+ WDC_LOGE("Client is NOT registered.");
+ __WDC_LOG_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+ }
+ if (seconds < 0) {
+ WDC_LOGE("Negative Timer Value");
+ __WDC_LOG_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ }
+
+ WDC_LOGD("seconds = [%d]", seconds);
+
+ params = g_variant_new("(i)", seconds);
+ reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
+ "SetSessionTimer",
+ params,
+ &error);
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
+
+ WDC_LOGD("%s() SUCCESS", __func__);
+
+ __WDC_LOG_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NONE;
+
+}
+
+int wifi_direct_get_session_timer(int *seconds)
+{
+ __WDC_LOG_FUNC_START__;
+
+ CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
+
+ GError* error = NULL;
+ GVariant *reply = NULL;
+ int val = 0;
+ int ret = WIFI_DIRECT_ERROR_NONE;
+
+ if (g_client_info.is_registered == false) {
+ WDC_LOGE("Client is NOT registered");
+ __WDC_LOG_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+ }
+
+ if (!seconds) {
+ WDC_LOGE("Invalid Parameter");
+ __WDC_LOG_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ }
+
+ reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
+ "GetSessionTimer",
+ NULL,
+ &error);
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
+
+ g_variant_get(reply, "(ii)", &ret, &val);
+ *seconds = val;
+ g_variant_unref(reply);
+
+ WDC_LOGD("Session Timer = [%d] Seconds", *seconds);
+ WDC_LOGD("%s() return : [%d]", __func__, ret);
+
+ __WDC_LOG_FUNC_END__;
+ return ret;
+}
+
+int wifi_direct_set_auto_group_removal(bool enable)
+{
+ __WDC_LOG_FUNC_START__;
+
+ CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
+
+ GError* error = NULL;
+ GVariant *reply = NULL;
+ GVariant *params = NULL;
+ int ret = WIFI_DIRECT_ERROR_NONE;
+
+ if (g_client_info.is_registered == false) {
+ WDC_LOGE("Client is NOT registered");
+ __WDC_LOG_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+ }
+
+ params = g_variant_new("(b)", enable);
+ reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
+ "SetAutoGroupRemoval",
+ params,
+ &error);
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ g_variant_get(reply, "(i)", &ret);
+ g_variant_unref(reply);
+ }
+
+ WDC_LOGD("%s() return : [%d]", __func__, ret);
+ __WDC_LOG_FUNC_END__;
+ return ret;
+}
+//LCOV_EXCL_STOP