4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Sungsik Jang <sungsik.jang@samsung.com>, Dongwook Lee <dwmax.lee@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
23 /*****************************************************************************
25 *****************************************************************************/
32 #include <sys/socket.h>
37 #include <sys/ioctl.h>
39 #include <linux/unistd.h>
47 /*****************************************************************************
49 *****************************************************************************/
51 #include <system_info.h>
53 /*****************************************************************************
54 * Wi-Fi Direct Service headers
55 *****************************************************************************/
56 #include "wifi-direct.h"
57 #include "wifi-direct-internal.h"
58 #include "wifi-direct-client-proxy.h"
59 #include "wifi-direct-ipc.h"
60 #include "wifi-direct-log.h"
61 #include "wifi-direct-dbus.h"
63 /*****************************************************************************
65 *****************************************************************************/
67 /*****************************************************************************
69 *****************************************************************************/
70 wifi_direct_client_info_s g_client_info = {
71 .is_registered = FALSE,
75 .activation_cb = NULL,
77 .connection_cb = NULL,
78 .ip_assigned_cb = NULL,
79 .peer_found_cb = NULL,
80 .user_data_for_cb_activation = NULL,
81 .user_data_for_cb_discover = NULL,
82 .user_data_for_cb_connection = NULL,
83 .user_data_for_cb_ip_assigned = NULL,
84 .user_data_for_cb_peer_found = NULL,
85 .user_data_for_cb_device_name = NULL,
86 #ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
88 .user_data_for_cb_service = NULL,
89 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
91 .mutex = PTHREAD_MUTEX_INITIALIZER
94 /*****************************************************************************
95 * Local Functions Definition
96 *****************************************************************************/
98 static wifi_direct_client_info_s *__wfd_get_control()
100 return &g_client_info;
104 void wifi_direct_process_manage_activation(GDBusConnection *connection,
105 const gchar *object_path, GVariant *parameters)
107 __WDC_LOG_FUNC_START__;
109 wifi_direct_client_info_s *client = __wfd_get_control();
111 if (!client->activation_cb) {
112 WDC_LOGI("activation_cb is NULL!!");
117 __WDC_LOG_FUNC_END__;
121 g_variant_get(parameters, "(i)", &error_code);
123 client->activation_cb(error_code,
124 WIFI_DIRECT_DEVICE_STATE_ACTIVATED,
125 client->user_data_for_cb_activation);
127 __WDC_LOG_FUNC_END__;
130 void wifi_direct_process_manage_deactivation(GDBusConnection *connection,
131 const gchar *object_path, GVariant *parameters)
133 __WDC_LOG_FUNC_START__;
135 wifi_direct_client_info_s *client = __wfd_get_control();
138 __WDC_LOG_FUNC_END__;
142 if (!client->activation_cb) {
143 WDC_LOGI("activation_cb is NULL!!");
144 __WDC_LOG_FUNC_END__;
148 g_variant_get(parameters, "(i)", &error_code);
150 client->activation_cb(error_code,
151 WIFI_DIRECT_DEVICE_STATE_DEACTIVATED,
152 client->user_data_for_cb_activation);
154 __WDC_LOG_FUNC_END__;
157 void wifi_direct_process_manage_connection(GDBusConnection *connection,
158 const gchar *object_path, GVariant *parameters)
160 __WDC_LOG_FUNC_START__;
162 wifi_direct_connection_state_e connection_state;
163 const gchar *peer_mac_address = NULL;
164 wifi_direct_client_info_s *client = __wfd_get_control();
167 __WDC_LOG_FUNC_END__;
171 if (!client->connection_cb) {
172 WDC_LOGI("connection_cb is NULL!!");
173 __WDC_LOG_FUNC_END__;
177 g_variant_get(parameters, "(ii&s)",
178 &error_code, &connection_state, &peer_mac_address);
180 client->connection_cb(error_code,
183 client->user_data_for_cb_connection);
185 __WDC_LOG_FUNC_END__;
188 void wifi_direct_process_manage_disconnection(GDBusConnection *connection,
189 const gchar *object_path, GVariant *parameters)
191 __WDC_LOG_FUNC_START__;
193 wifi_direct_connection_state_e connection_state;
194 const gchar *peer_mac_address = NULL;
195 wifi_direct_client_info_s *client = __wfd_get_control();
198 __WDC_LOG_FUNC_END__;
202 if (!client->connection_cb) {
203 WDC_LOGI("connection_cb is NULL!!");
204 __WDC_LOG_FUNC_END__;
208 g_variant_get(parameters, "(ii&s)",
209 &error_code, &connection_state, &peer_mac_address);
211 client->connection_cb(error_code,
214 client->user_data_for_cb_connection);
216 __WDC_LOG_FUNC_END__;
219 void wifi_direct_process_manage_peer_ip_assigned(GDBusConnection *connection,
220 const gchar *object_path, GVariant *parameters)
222 __WDC_LOG_FUNC_START__;
223 char *get_str = NULL;
224 GError* error = NULL;
225 GVariant *reply = NULL;
226 const gchar *peer_mac_address = NULL;
227 const gchar *assigned_ip_address = NULL;
229 wifi_direct_client_info_s *client = __wfd_get_control();
232 __WDC_LOG_FUNC_END__;
236 g_variant_get(parameters, "(&s&s)",
237 &peer_mac_address, &assigned_ip_address);
239 if (!client->ip_assigned_cb) {
240 WDC_LOGI("ip_assigned_cb is NULL!!");
241 __WDC_LOG_FUNC_END__;
245 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
250 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
251 "error [%d: %s]", error->code, error->message);
253 __WDC_LOG_FUNC_END__;
257 g_variant_get(reply, "(i&s)", ret ,&get_str);
258 g_variant_unref(reply);
260 WDC_LOGD("Interface Name = [%s]", get_str);
261 WDC_LOGD("%s() return : [%d]", __func__, ret);
263 client->ip_assigned_cb(peer_mac_address, assigned_ip_address, get_str,
264 client->user_data_for_cb_ip_assigned);
266 __WDC_LOG_FUNC_END__;
269 void wifi_direct_process_manage_listen_started(GDBusConnection *connection,
270 const gchar *object_path, GVariant *parameters)
272 __WDC_LOG_FUNC_START__;
273 wifi_direct_client_info_s *client = __wfd_get_control();
275 if (!client->discover_cb) {
276 WDC_LOGI("discover_cb is NULL!!");
277 __WDC_LOG_FUNC_END__;
281 client->discover_cb(WIFI_DIRECT_ERROR_NONE,
282 WIFI_DIRECT_ONLY_LISTEN_STARTED,
283 client->user_data_for_cb_discover);
285 __WDC_LOG_FUNC_END__;
288 void wifi_direct_process_manage_discovery_started(GDBusConnection *connection,
289 const gchar *object_path, GVariant *parameters)
291 __WDC_LOG_FUNC_START__;
292 wifi_direct_client_info_s *client = __wfd_get_control();
294 if (!client->discover_cb) {
295 WDC_LOGI("discover_cb is NULL!!");
296 __WDC_LOG_FUNC_END__;
300 client->discover_cb(WIFI_DIRECT_ERROR_NONE,
301 WIFI_DIRECT_DISCOVERY_STARTED,
302 client->user_data_for_cb_discover);
304 __WDC_LOG_FUNC_END__;
307 void wifi_direct_process_manage_discovery_finished(GDBusConnection *connection,
308 const gchar *object_path, GVariant *parameters)
310 __WDC_LOG_FUNC_START__;
311 wifi_direct_client_info_s *client = __wfd_get_control();
313 if (!client->discover_cb) {
314 WDC_LOGI("discover_cb is NULL!!");
315 __WDC_LOG_FUNC_END__;
319 client->discover_cb(WIFI_DIRECT_ERROR_NONE,
320 WIFI_DIRECT_DISCOVERY_FINISHED,
321 client->user_data_for_cb_discover);
323 __WDC_LOG_FUNC_END__;
326 void wifi_direct_process_manage_peer_found(GDBusConnection *connection,
327 const gchar *object_path, GVariant *parameters)
329 __WDC_LOG_FUNC_START__;
330 const gchar *peer_mac_address = NULL;
331 wifi_direct_client_info_s *client = __wfd_get_control();
334 __WDC_LOG_FUNC_END__;
338 g_variant_get(parameters, "(&s)", &peer_mac_address);
340 if (client->peer_found_cb) {
341 client->peer_found_cb(WIFI_DIRECT_ERROR_NONE,
342 WIFI_DIRECT_DISCOVERY_FOUND,
344 client->user_data_for_cb_discover);
346 WDC_LOGI("peer_found_cb is NULL!!");
349 if (!client->discover_cb) {
350 WDC_LOGI("discover_cb is NULL!!");
351 __WDC_LOG_FUNC_END__;
355 client->discover_cb(WIFI_DIRECT_ERROR_NONE,
356 WIFI_DIRECT_DISCOVERY_FOUND,
357 client->user_data_for_cb_discover);
359 __WDC_LOG_FUNC_END__;
362 void wifi_direct_process_manage_peer_lost(GDBusConnection *connection,
363 const gchar *object_path, GVariant *parameters)
365 __WDC_LOG_FUNC_START__;
366 const gchar *peer_mac_address = NULL;
367 wifi_direct_client_info_s *client = __wfd_get_control();
370 __WDC_LOG_FUNC_END__;
374 g_variant_get(parameters, "(&s)", &peer_mac_address);
376 if (client->peer_found_cb) {
377 client->peer_found_cb(WIFI_DIRECT_ERROR_NONE,
378 WIFI_DIRECT_DISCOVERY_LOST,
380 client->user_data_for_cb_discover);
382 WDC_LOGI("peer_found_cb is NULL!!");
385 if (!client->discover_cb) {
386 WDC_LOGI("discover_cb is NULL!!");
387 __WDC_LOG_FUNC_END__;
391 client->discover_cb(WIFI_DIRECT_ERROR_NONE,
392 WIFI_DIRECT_DISCOVERY_LOST,
393 client->user_data_for_cb_discover);
395 __WDC_LOG_FUNC_END__;
399 void wifi_direct_process_group_created(GDBusConnection *connection,
400 const gchar *object_path, GVariant *parameters)
402 __WDC_LOG_FUNC_START__;
403 wifi_direct_client_info_s *client = __wfd_get_control();
405 if (!client->connection_cb) {
406 WDC_LOGI("connection_cb is NULL!!");
407 __WDC_LOG_FUNC_END__;
411 client->connection_cb(WIFI_DIRECT_ERROR_NONE,
412 WIFI_DIRECT_GROUP_CREATED,
414 client->user_data_for_cb_connection);
416 __WDC_LOG_FUNC_END__;
419 void wifi_direct_process_group_destroyed(GDBusConnection *connection,
420 const gchar *object_path, GVariant *parameters)
422 __WDC_LOG_FUNC_START__;
423 wifi_direct_client_info_s *client = __wfd_get_control();
425 if (!client->connection_cb) {
426 WDC_LOGI("connection_cb is NULL!!");
427 __WDC_LOG_FUNC_END__;
431 client->connection_cb(WIFI_DIRECT_ERROR_NONE,
432 WIFI_DIRECT_GROUP_DESTROYED,
434 client->user_data_for_cb_connection);
436 __WDC_LOG_FUNC_END__;
439 #ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
441 void wifi_direct_process_service_discovery_started(GDBusConnection *connection,
442 const gchar *object_path, GVariant *parameters)
444 __WDC_LOG_FUNC_START__;
445 wifi_direct_client_info_s *client = __wfd_get_control();
447 if (!client->service_cb) {
448 WDC_LOGI("service_cb is NULL!!\n");
449 __WDC_LOG_FUNC_END__;
453 client->service_cb(WIFI_DIRECT_ERROR_NONE,
454 WIFI_DIRECT_SERVICE_DISCOVERY_STARTED,
455 WIFI_DIRECT_SERVICE_TYPE_ALL,
458 client->user_data_for_cb_service);
460 __WDC_LOG_FUNC_END__;
463 void wifi_direct_process_service_discovery_found(GDBusConnection *connection,
464 const gchar *object_path, GVariant *parameters)
466 __WDC_LOG_FUNC_START__;
467 wifi_direct_service_type_e service_type;
468 const gchar* response_data = NULL;
469 const gchar* peer_mac_address = NULL;
470 wifi_direct_client_info_s *client = __wfd_get_control();
473 __WDC_LOG_FUNC_END__;
477 g_variant_get(parameters, "(i&s&s)",
478 &service_type, &response_data, &peer_mac_address);
480 if (!client->service_cb) {
481 WDC_LOGI("service_cb is NULL!!\n");
482 __WDC_LOG_FUNC_END__;
486 client->service_cb(WIFI_DIRECT_ERROR_NONE,
487 WIFI_DIRECT_SERVICE_DISCOVERY_FOUND,
489 (void *) response_data,
491 client->user_data_for_cb_service);
493 __WDC_LOG_FUNC_END__;
496 void wifi_direct_process_service_discovery_finished(GDBusConnection *connection,
497 const gchar *object_path, GVariant *parameters)
499 __WDC_LOG_FUNC_START__;
500 wifi_direct_client_info_s *client = __wfd_get_control();
502 if (!client->service_cb) {
503 WDC_LOGI("service_cb is NULL!!\n");
504 __WDC_LOG_FUNC_END__;
508 client->service_cb(WIFI_DIRECT_ERROR_NONE,
509 WIFI_DIRECT_SERVICE_DISCOVERY_FINISHED,
510 WIFI_DIRECT_SERVICE_TYPE_ALL,
513 client->user_data_for_cb_service);
515 __WDC_LOG_FUNC_END__;
517 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
519 void __wfd_client_print_entry_list(wfd_discovery_entry_s *list, int num)
523 WDC_LOGD("------------------------------------------");
524 for (i = 0; i < num; i++)
526 WDC_LOGD("== Peer index : %d ==", i);
527 WDC_LOGD("is Group Owner ? %s", list[i].is_group_owner ? "YES" : "NO");
528 WDC_LOGD("device_name : %s", list[i].device_name);
529 WDC_LOGD("MAC address : "MACSECSTR, MAC2SECSTR(list[i].mac_address));
530 WDC_LOGD("wps cfg method : %x", list[i].wps_cfg_methods);
531 WDC_LOGD("Device Type: %d - %d", list[i].category, list[i].subcategory);
532 WDC_LOGD("Listen channel: %d", list[i].channel);
534 WDC_LOGD("------------------------------------------");
537 void __wfd_client_print_connected_peer_info(wfd_connected_peer_info_s *list, int num)
541 WDC_LOGD("------------------------------------------\n");
542 for (i = 0; i < num; i++) {
543 WDC_LOGD("== Peer index : %d ==\n", i);
544 WDC_LOGD("device_name : %s\n", list[i].device_name);
545 WDC_LOGD("Device MAC : " MACSECSTR "\n", MAC2SECSTR(list[i].mac_address));
546 WDC_LOGD("Device Type: %d - %d", list[i].category, list[i].subcategory);
547 WDC_LOGD("channel : %d\n", list[i].channel);
548 WDC_LOGD("IP ["IPSECSTR"]\n", IP2SECSTR(list[i].ip_address));
550 WDC_LOGD("------------------------------------------\n");
553 void __wfd_client_print_persistent_group_info(wfd_persistent_group_info_s *list, int num)
557 WDC_LOGD("------------------------------------------\n");
558 for (i = 0; i < num; i++) {
559 WDC_LOGD("== Persistent Group index : %d ==", i);
560 WDC_LOGD("ssid : %s", list[i].ssid);
561 WDC_LOGD("GO MAC : " MACSECSTR, MAC2SECSTR(list[i].go_mac_address));
563 WDC_LOGD("------------------------------------------\n");
566 static int __wfd_client_launch_server_dbus(void)
568 GDBusConnection *netconfig_bus = NULL;
569 GError *g_error = NULL;
571 #if !GLIB_CHECK_VERSION(2,36,0)
574 netconfig_bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &g_error);
575 if (netconfig_bus == NULL) {
576 if(g_error != NULL) {
577 WDC_LOGE("Couldn't connect to system bus "
578 "error [%d: %s]", g_error->code, g_error->message);
579 g_error_free(g_error);
581 return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
584 g_dbus_connection_call_sync(netconfig_bus,
587 NETCONFIG_WIFI_INTERFACE,
588 NETCONFIG_WIFI_LAUNCHDIRECT,
591 G_DBUS_CALL_FLAGS_NONE,
597 WDC_LOGE("g_dbus_connection_call_sync() failed"
598 "error [%d: %s]", g_error->code, g_error->message);
599 g_error_free(g_error);
600 return WIFI_DIRECT_ERROR_PERMISSION_DENIED;
603 g_object_unref(netconfig_bus);
605 WDC_LOGD("Successfully launched wfd-manager");
606 return WIFI_DIRECT_ERROR_NONE;
609 int wifi_direct_initialize(void)
611 __WDC_LOG_FUNC_START__;
613 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
615 bool wifi_direct_enable;
618 if (g_client_info.is_registered == TRUE) {
619 WDC_LOGW("Warning!!! Already registered\nUpdate user data and callback!");
620 __WDC_LOG_FUNC_END__;
621 return WIFI_DIRECT_ERROR_ALREADY_INITIALIZED;
624 res = system_info_get_platform_bool("tizen.org/feature/network.wifi.direct", &wifi_direct_enable);
626 WDC_LOGE("Failed to get sys info");
627 __WDC_LOG_FUNC_END__;
631 if(!wifi_direct_enable) {
632 WDC_LOGE("Wi-Fi Direct not supported");
633 return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
636 wifi_direct_dbus_init();
638 WDC_LOGD("Launching wfd-server..\n");
639 res = __wfd_client_launch_server_dbus();
640 if (res != WIFI_DIRECT_ERROR_NONE)
641 WDC_LOGE("Failed to send dbus msg[%s]", strerror(errno));
643 g_client_info.is_registered = TRUE;
645 /* Initialize callbacks */
646 g_client_info.activation_cb = NULL;
647 g_client_info.discover_cb = NULL;
648 g_client_info.connection_cb = NULL;
649 g_client_info.ip_assigned_cb = NULL;
651 g_client_info.peer_found_cb = NULL;
652 g_client_info.user_data_for_cb_activation = NULL;
653 g_client_info.user_data_for_cb_discover = NULL;
654 g_client_info.user_data_for_cb_connection = NULL;
655 g_client_info.user_data_for_cb_ip_assigned = NULL;
656 g_client_info.user_data_for_cb_peer_found = NULL;
657 g_client_info.user_data_for_cb_device_name = NULL;
659 #ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
660 g_client_info.service_cb = NULL;
661 g_client_info.user_data_for_cb_service= NULL;
662 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
664 __WDC_LOG_FUNC_END__;
665 return WIFI_DIRECT_ERROR_NONE;
668 int wifi_direct_deinitialize(void)
670 __WDC_LOG_FUNC_START__;
672 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
674 if (g_client_info.is_registered == false) {
675 WDC_LOGE("Client is already deregistered");
676 __WDC_LOG_FUNC_END__;
677 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
680 wifi_direct_dbus_deinit();
682 g_client_info.activation_cb = NULL;
683 g_client_info.discover_cb = NULL;
684 g_client_info.connection_cb = NULL;
685 g_client_info.ip_assigned_cb = NULL;
686 g_client_info.peer_found_cb = NULL;
687 g_client_info.user_data_for_cb_activation = NULL;
688 g_client_info.user_data_for_cb_discover = NULL;
689 g_client_info.user_data_for_cb_connection = NULL;
690 g_client_info.user_data_for_cb_ip_assigned = NULL;
691 g_client_info.user_data_for_cb_peer_found = NULL;
693 #ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
694 g_client_info.service_cb = NULL;
695 g_client_info.user_data_for_cb_service = NULL;
696 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
698 g_client_info.is_registered = FALSE;
700 __WDC_LOG_FUNC_END__;
701 return WIFI_DIRECT_ERROR_NONE;
705 int wifi_direct_set_device_state_changed_cb(wifi_direct_device_state_changed_cb cb,
708 __WDC_LOG_FUNC_START__;
710 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
713 WDC_LOGE("Invalid parameter");
714 __WDC_LOG_FUNC_END__;
715 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
718 if (g_client_info.is_registered == false) {
719 WDC_LOGE("Client is not initialized.");
720 __WDC_LOG_FUNC_END__;
721 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
724 g_client_info.activation_cb = cb;
725 g_client_info.user_data_for_cb_activation = user_data;
727 __WDC_LOG_FUNC_END__;
728 return WIFI_DIRECT_ERROR_NONE;
732 int wifi_direct_unset_device_state_changed_cb(void)
734 __WDC_LOG_FUNC_START__;
736 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
738 if (g_client_info.is_registered == false) {
739 WDC_LOGE("Client is not initialized.\n");
740 __WDC_LOG_FUNC_END__;
741 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
744 g_client_info.activation_cb = NULL;
745 g_client_info.user_data_for_cb_activation = NULL;
747 __WDC_LOG_FUNC_END__;
748 return WIFI_DIRECT_ERROR_NONE;
753 wifi_direct_set_discovery_state_changed_cb(wifi_direct_discovery_state_chagned_cb cb,
756 __WDC_LOG_FUNC_START__;
758 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
761 WDC_LOGE("Callback is NULL.\n");
762 __WDC_LOG_FUNC_END__;
763 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
766 if (g_client_info.is_registered == false) {
767 WDC_LOGE("Client is not initialized.\n");
768 __WDC_LOG_FUNC_END__;
769 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
772 g_client_info.discover_cb = cb;
773 g_client_info.user_data_for_cb_discover = user_data;
775 __WDC_LOG_FUNC_END__;
776 return WIFI_DIRECT_ERROR_NONE;
780 int wifi_direct_unset_discovery_state_changed_cb(void)
782 __WDC_LOG_FUNC_START__;
784 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
786 if (g_client_info.is_registered == false) {
787 WDC_LOGE("Client is not initialized.\n");
788 __WDC_LOG_FUNC_END__;
789 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
792 g_client_info.discover_cb = NULL;
793 g_client_info.user_data_for_cb_discover = NULL;
795 __WDC_LOG_FUNC_END__;
796 return WIFI_DIRECT_ERROR_NONE;
799 int wifi_direct_set_peer_found_cb(wifi_direct_peer_found_cb cb,
802 __WDC_LOG_FUNC_START__;
804 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
807 WDC_LOGE("Callback is NULL.\n");
808 __WDC_LOG_FUNC_END__;
809 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
812 if (g_client_info.is_registered == false) {
813 WDC_LOGE("Client is not initialized.\n");
814 __WDC_LOG_FUNC_END__;
815 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
818 g_client_info.peer_found_cb = cb;
819 g_client_info.user_data_for_cb_peer_found = user_data;
821 __WDC_LOG_FUNC_END__;
822 return WIFI_DIRECT_ERROR_NONE;
826 int wifi_direct_unset_peer_found_cb(void)
828 __WDC_LOG_FUNC_START__;
830 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
832 if (g_client_info.is_registered == false) {
833 WDC_LOGE("Client is not initialized.\n");
834 __WDC_LOG_FUNC_END__;
835 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
838 g_client_info.peer_found_cb = NULL;
839 g_client_info.user_data_for_cb_peer_found = NULL;
841 __WDC_LOG_FUNC_END__;
842 return WIFI_DIRECT_ERROR_NONE;
845 int wifi_direct_set_service_state_changed_cb(wifi_direct_service_state_changed_cb cb,
848 #ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
849 __WDC_LOG_FUNC_START__;
851 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_SERVICE_DISCOVERY_FEATURE);
854 WDC_LOGE("Callback is NULL.");
855 __WDC_LOG_FUNC_END__;
856 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
859 if (g_client_info.is_registered == false) {
860 WDC_LOGE("Client is not initialized.");
861 __WDC_LOG_FUNC_END__;
862 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
865 g_client_info.service_cb = cb;
866 g_client_info.user_data_for_cb_service = user_data;
868 __WDC_LOG_FUNC_END__;
869 return WIFI_DIRECT_ERROR_NONE;
870 #else /* TIZEN_FEATURE_SERVICE_DISCOVERY */
871 return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
872 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
876 int wifi_direct_unset_service_state_changed_cb(void)
878 #ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
879 __WDC_LOG_FUNC_START__;
881 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_SERVICE_DISCOVERY_FEATURE);
883 if (g_client_info.is_registered == false) {
884 WDC_LOGE("Client is not initialized.");
885 __WDC_LOG_FUNC_END__;
886 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
889 g_client_info.service_cb = NULL;
890 g_client_info.user_data_for_cb_service = NULL;
892 __WDC_LOG_FUNC_END__;
893 return WIFI_DIRECT_ERROR_NONE;
894 #else /* TIZEN_FEATURE_SERVICE_DISCOVERY */
895 return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
896 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
899 int wifi_direct_set_connection_state_changed_cb(wifi_direct_connection_state_changed_cb cb,
902 __WDC_LOG_FUNC_START__;
904 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
907 WDC_LOGE("Callback is NULL.\n");
908 __WDC_LOG_FUNC_END__;
909 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
912 if (g_client_info.is_registered == false) {
913 WDC_LOGE("Client is not initialized.\n");
914 __WDC_LOG_FUNC_END__;
915 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
918 g_client_info.connection_cb = cb;
919 g_client_info.user_data_for_cb_connection = user_data;
921 __WDC_LOG_FUNC_END__;
922 return WIFI_DIRECT_ERROR_NONE;
926 int wifi_direct_unset_connection_state_changed_cb(void)
928 __WDC_LOG_FUNC_START__;
930 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
932 if (g_client_info.is_registered == false) {
933 WDC_LOGE("Client is not initialized");
934 __WDC_LOG_FUNC_END__;
935 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
938 g_client_info.connection_cb = NULL;
939 g_client_info.user_data_for_cb_connection = NULL;
941 __WDC_LOG_FUNC_END__;
942 return WIFI_DIRECT_ERROR_NONE;
946 int wifi_direct_set_client_ip_address_assigned_cb(wifi_direct_client_ip_address_assigned_cb cb,
949 __WDC_LOG_FUNC_START__;
951 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
954 WDC_LOGE("Callback is NULL");
955 __WDC_LOG_FUNC_END__;
956 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
959 if (g_client_info.is_registered == false) {
960 WDC_LOGE("Client is not initialized");
961 __WDC_LOG_FUNC_END__;
962 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
965 g_client_info.ip_assigned_cb = cb;
966 g_client_info.user_data_for_cb_ip_assigned = user_data;
968 __WDC_LOG_FUNC_END__;
969 return WIFI_DIRECT_ERROR_NONE;
972 int wifi_direct_unset_client_ip_address_assigned_cb(void)
974 __WDC_LOG_FUNC_START__;
976 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
978 if (g_client_info.is_registered == false) {
979 WDC_LOGE("Client is not initialized");
980 __WDC_LOG_FUNC_END__;
981 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
984 g_client_info.ip_assigned_cb = NULL;
985 g_client_info.user_data_for_cb_ip_assigned = NULL;
987 __WDC_LOG_FUNC_END__;
988 return WIFI_DIRECT_ERROR_NONE;
991 int wifi_direct_activate(void)
993 __WDC_LOG_FUNC_START__;
994 GError *error = NULL;
995 GVariant *reply = NULL;
996 int ret = WIFI_DIRECT_ERROR_NONE;
998 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
1000 if (g_client_info.is_registered == false) {
1001 WDC_LOGE("Client is NOT registered");
1002 __WDC_LOG_FUNC_END__;
1003 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
1006 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
1007 "Activate", NULL, &error);
1008 if (error != NULL) {
1009 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
1010 "error [%d: %s]", error->code, error->message);
1011 g_error_free(error);
1012 __WDC_LOG_FUNC_END__;
1013 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
1016 g_variant_get(reply, "(i)", &ret);
1017 g_variant_unref(reply);
1019 WDC_LOGD("%s() return : [%d]", __func__, ret);
1020 __WDC_LOG_FUNC_END__;
1024 int wifi_direct_deactivate(void)
1026 __WDC_LOG_FUNC_START__;
1027 GError *error = NULL;
1028 GVariant *reply = NULL;
1029 int ret = WIFI_DIRECT_ERROR_NONE;
1031 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
1033 if (g_client_info.is_registered == false) {
1034 WDC_LOGE("Client is NOT registered");
1035 __WDC_LOG_FUNC_END__;
1036 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
1039 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
1040 "Deactivate", NULL, &error);
1041 if (error != NULL) {
1042 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
1043 "error [%d: %s]", error->code, error->message);
1044 g_error_free(error);
1045 __WDC_LOG_FUNC_END__;
1046 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
1049 g_variant_get(reply, "(i)", &ret);
1050 g_variant_unref(reply);
1052 WDC_LOGD("%s() return : [%d]", __func__, ret);
1053 __WDC_LOG_FUNC_END__;
1057 int wifi_direct_start_discovery(bool listen_only, int timeout)
1059 __WDC_LOG_FUNC_START__;
1060 GVariantBuilder *builder = NULL;
1061 GVariant *params = NULL;
1062 GError *error = NULL;
1063 GVariant *reply = NULL;
1064 int ret = WIFI_DIRECT_ERROR_NONE;
1066 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
1068 if (g_client_info.is_registered == false) {
1069 WDC_LOGE("Client is NOT registered");
1070 __WDC_LOG_FUNC_END__;
1071 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
1075 WDC_LOGE("Negative value. Param [timeout]!");
1076 __WDC_LOG_FUNC_END__;
1077 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
1080 builder = g_variant_builder_new(G_VARIANT_TYPE ("a{sv}"));
1081 g_variant_builder_add(builder, "{sv}", "Mode", g_variant_new("b", listen_only));
1082 g_variant_builder_add(builder, "{sv}", "Timeout", g_variant_new("i", timeout));
1083 params = g_variant_new("(a{sv})", builder);
1084 g_variant_builder_unref(builder);
1085 WDC_LOGI("listen only (%d) timeout (%d)", listen_only, timeout);
1087 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
1088 "StartDiscovery", params, &error);
1089 if (error != NULL) {
1090 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
1091 "error [%d: %s]", error->code, error->message);
1092 g_error_free(error);
1093 __WDC_LOG_FUNC_END__;
1094 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
1097 g_variant_get(reply, "(i)", &ret);
1098 g_variant_unref(reply);
1100 WDC_LOGD("%s() return : [%d]", __func__, ret);
1101 __WDC_LOG_FUNC_END__;
1105 int wifi_direct_start_discovery_specific_channel(bool listen_only,
1107 wifi_direct_discovery_channel_e channel)
1109 __WDC_LOG_FUNC_START__;
1110 GVariantBuilder *builder = NULL;
1111 GVariant *params = NULL;
1112 GError *error = NULL;
1113 GVariant *reply = NULL;
1114 int ret = WIFI_DIRECT_ERROR_NONE;
1116 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
1118 if (g_client_info.is_registered == false) {
1119 WDC_LOGE("Client is NOT registered");
1120 __WDC_LOG_FUNC_END__;
1121 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
1125 WDC_LOGE("Negative value. Param [timeout]!");
1126 __WDC_LOG_FUNC_END__;
1127 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
1130 builder = g_variant_builder_new(G_VARIANT_TYPE ("a{sv}"));
1131 g_variant_builder_add(builder, "{sv}", "Mode", g_variant_new("b", listen_only));
1132 g_variant_builder_add(builder, "{sv}", "Timeout", g_variant_new("i", timeout));
1133 g_variant_builder_add(builder, "{sv}", "Channel", g_variant_new("i", channel));
1134 params = g_variant_new("(a{sv})", builder);
1135 g_variant_builder_unref(builder);
1136 WDC_LOGI("listen only (%d) timeout (%d)", listen_only, timeout);
1138 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
1139 "StartDiscovery", params, &error);
1140 if (error != NULL) {
1141 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
1142 "error [%d: %s]", error->code, error->message);
1143 g_error_free(error);
1144 __WDC_LOG_FUNC_END__;
1145 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
1148 g_variant_get(reply, "(i)", &ret);
1149 g_variant_unref(reply);
1151 WDC_LOGD("%s() return : [%d]", __func__, ret);
1152 __WDC_LOG_FUNC_END__;
1156 int wifi_direct_cancel_discovery(void)
1158 __WDC_LOG_FUNC_START__;
1159 GError *error = NULL;
1160 GVariant *reply = NULL;
1161 int ret = WIFI_DIRECT_ERROR_NONE;
1163 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
1165 if (g_client_info.is_registered == false) {
1166 WDC_LOGE("Client is NOT registered");
1167 __WDC_LOG_FUNC_END__;
1168 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
1171 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
1172 "StopDiscovery", NULL, &error);
1173 if (error != NULL) {
1174 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
1175 "error [%d: %s]", error->code, error->message);
1176 g_error_free(error);
1177 __WDC_LOG_FUNC_END__;
1178 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
1181 g_variant_get(reply, "(i)", &ret);
1182 g_variant_unref(reply);
1184 WDC_LOGD("%s() return : [%d]", __func__, ret);
1185 __WDC_LOG_FUNC_END__;
1189 #ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
1190 static char **get_service_list(char *services, unsigned int *count)
1192 __WDC_LOG_FUNC_START__;
1193 char **result = NULL;
1196 unsigned int cnt = 0;
1200 if (!count || !services || (services && strlen(services) <= 0)) {
1201 WDC_LOGE("Invalid parameters.");
1202 __WDC_LOG_FUNC_END__;
1207 pos2 = g_strdup(services);
1209 pos1 = strtok (pos1,",\n");
1212 pos1 = strtok (NULL, ",\n");
1214 WDC_LOGD("Total Service Count = %d", cnt);
1217 result = (char**) g_try_malloc0_n(cnt, sizeof(char *));
1219 WDC_LOGE("Failed to allocate memory for result");
1223 pos2 = strtok (pos2,",\n");
1224 while (pos2 != NULL) {
1225 char *s = strchr(pos2, ' ');
1228 result[i++] = strdup(pos2);
1229 pos2 = strtok (NULL, ",\n");
1243 for (j=0; j<i && result[j] != NULL; j++)
1250 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
1252 int wifi_direct_foreach_discovered_peers(wifi_direct_discovered_peer_cb cb,
1255 __WDC_LOG_FUNC_START__;
1257 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
1259 GVariant *params = NULL;
1260 GError *error = NULL;
1261 GVariant *reply = NULL;
1262 GVariantIter *iter_peers = NULL;
1263 GVariantIter *iter_peer = NULL;
1264 GVariant *var = NULL;
1266 int ret = WIFI_DIRECT_ERROR_NONE;
1268 if (g_client_info.is_registered == false) {
1269 WDC_LOGE("Client is NOT registered");
1270 __WDC_LOG_FUNC_END__;
1271 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
1275 WDC_LOGE("NULL Param [callback]!");
1276 __WDC_LOG_FUNC_END__;
1277 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
1280 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
1281 "GetDiscoveredPeers", params, &error);
1282 if (error != NULL) {
1283 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
1284 "error [%d: %s]", error->code, error->message);
1285 g_error_free(error);
1286 __WDC_LOG_FUNC_END__;
1287 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
1290 g_variant_get(reply, "(iaa{sv})", &ret, &iter_peers);
1291 if (ret != WIFI_DIRECT_ERROR_NONE) {
1292 __WDC_LOG_FUNC_END__;
1293 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
1296 WDC_LOGD("wifi_direct_foreach_discovered_peers() SUCCESS");
1298 while(g_variant_iter_loop(iter_peers, "a{sv}", &iter_peer)) {
1299 wifi_direct_discovered_peer_info_s *peer_list = NULL;
1301 peer_list = (wifi_direct_discovered_peer_info_s *) g_try_malloc0(sizeof(wifi_direct_discovered_peer_info_s));
1303 WDC_LOGE("Failed to allocate memory");
1307 while (g_variant_iter_loop(iter_peer, "{sv}", &key, &var)) {
1308 if (!g_strcmp0(key, "DeviceName")) {
1309 const char *device_name = NULL;
1311 g_variant_get(var, "&s", &device_name);
1312 peer_list->device_name = g_strndup(device_name, WIFI_DIRECT_MAX_DEVICE_NAME_LEN+1);
1314 } else if (!g_strcmp0(key, "DeviceAddress")) {
1315 unsigned char mac_address[MACADDR_LEN] = {0, };
1317 wifi_direct_dbus_unpack_ay(mac_address, var, MACADDR_LEN);
1318 peer_list->mac_address = (char*) g_try_malloc0(MACSTR_LEN);
1319 if (peer_list->mac_address)
1320 g_snprintf(peer_list->mac_address, MACSTR_LEN, MACSTR, MAC2STR(mac_address));
1322 } else if (!g_strcmp0(key, "InterfaceAddress")) {
1323 unsigned char intf_address[MACADDR_LEN] = {0, };
1325 wifi_direct_dbus_unpack_ay(intf_address, var, MACADDR_LEN);
1326 peer_list->interface_address = (char*) g_try_malloc0(MACSTR_LEN);
1327 if (peer_list->interface_address)
1328 g_snprintf(peer_list->interface_address, MACSTR_LEN, MACSTR, MAC2STR(intf_address));
1330 } else if (!g_strcmp0(key, "Channel")) {
1331 peer_list->channel = g_variant_get_uint16(var);
1333 } else if (!g_strcmp0(key, "IsGroupOwner")) {
1334 peer_list->is_group_owner = g_variant_get_boolean(var);
1336 } else if (!g_strcmp0(key, "IsPersistentGO")) {
1337 peer_list->is_persistent_group_owner = g_variant_get_boolean(var);
1339 } else if (!g_strcmp0(key, "IsConnected")) {
1340 peer_list->is_connected = g_variant_get_boolean(var);
1342 } else if (!g_strcmp0(key, "Category")) {
1343 peer_list->primary_device_type = g_variant_get_uint16(var);
1345 } else if (!g_strcmp0(key, "SubCategory")) {
1346 peer_list->secondary_device_type = g_variant_get_uint16(var);
1348 } else if (!g_strcmp0(key, "IsWfdDevice")) {
1349 #ifdef TIZEN_FEATURE_WIFI_DISPLAY
1350 peer_list->is_miracast_device = g_variant_get_boolean(var);
1351 #endif /* TIZEN_FEATURE_WIFI_DISPLAY */
1357 //__wfd_client_print_entry_list(peer_list, 1);
1358 if (!cb(peer_list, user_data)) {
1359 g_variant_iter_free(iter_peer);
1364 g_variant_iter_free(iter_peers);
1365 g_variant_unref(reply);
1366 __WDC_LOG_FUNC_END__;
1367 return WIFI_DIRECT_ERROR_NONE;
1370 int wifi_direct_connect(char *mac_address)
1372 __WDC_LOG_FUNC_START__;
1374 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
1376 GVariant *params = NULL;
1377 GError *error = NULL;
1378 GVariant *reply = NULL;
1379 int ret = WIFI_DIRECT_ERROR_NONE;
1381 if (g_client_info.is_registered == false) {
1382 WDC_LOGE("Client is NOT registered");
1383 __WDC_LOG_FUNC_END__;
1384 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
1388 WDC_LOGE("mac_addr is NULL");
1389 __WDC_LOG_FUNC_END__;
1390 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
1393 params = g_variant_new("(s)", mac_address);
1394 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
1395 "Connect", params, &error);
1396 if (error != NULL) {
1397 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
1398 "error [%d: %s]", error->code, error->message);
1399 g_error_free(error);
1400 __WDC_LOG_FUNC_END__;
1401 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
1404 g_variant_get(reply, "(i)", &ret);
1405 g_variant_unref(reply);
1407 WDC_LOGD("%s() return : [%d]", __func__, ret);
1408 __WDC_LOG_FUNC_END__;
1412 int wifi_direct_cancel_connection(char *mac_address)
1414 __WDC_LOG_FUNC_START__;
1416 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
1418 GVariant *params = NULL;
1419 GError *error = NULL;
1420 GVariant *reply = NULL;
1421 int ret = WIFI_DIRECT_ERROR_NONE;
1423 if (g_client_info.is_registered == false) {
1424 WDC_LOGE("Client is NOT registered");
1425 __WDC_LOG_FUNC_END__;
1426 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
1430 WDC_LOGE("mac_addr is NULL");
1431 __WDC_LOG_FUNC_END__;
1432 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
1435 params = g_variant_new("(s)", mac_address);
1436 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
1437 "CancelConnection", params, &error);
1438 if (error != NULL) {
1439 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
1440 "error [%d: %s]", error->code, error->message);
1441 g_error_free(error);
1442 __WDC_LOG_FUNC_END__;
1443 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
1446 g_variant_get(reply, "(i)", &ret);
1447 g_variant_unref(reply);
1449 WDC_LOGD("%s() return : [%d]", __func__, ret);
1450 __WDC_LOG_FUNC_END__;
1455 int wifi_direct_reject_connection(char *mac_address)
1457 __WDC_LOG_FUNC_START__;
1459 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
1461 GVariant *params = NULL;
1462 GError *error = NULL;
1463 GVariant *reply = NULL;
1464 int ret = WIFI_DIRECT_ERROR_NONE;
1466 if (g_client_info.is_registered == false) {
1467 WDC_LOGE("Client is NOT registered");
1468 __WDC_LOG_FUNC_END__;
1469 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
1473 WDC_LOGE("mac_addr is NULL");
1474 __WDC_LOG_FUNC_END__;
1475 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
1478 params = g_variant_new("(s)", mac_address);
1479 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
1480 "RejectConnection", params, &error);
1481 if (error != NULL) {
1482 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
1483 "error [%d: %s]", error->code, error->message);
1484 g_error_free(error);
1485 __WDC_LOG_FUNC_END__;
1486 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
1489 g_variant_get(reply, "(i)", &ret);
1490 g_variant_unref(reply);
1492 WDC_LOGD("%s() return : [%d]", __func__, ret);
1493 __WDC_LOG_FUNC_END__;
1498 int wifi_direct_disconnect_all(void)
1500 __WDC_LOG_FUNC_START__;
1502 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
1504 GError *error = NULL;
1505 GVariant *reply = NULL;
1506 int ret = WIFI_DIRECT_ERROR_NONE;
1508 if (g_client_info.is_registered == false) {
1509 WDC_LOGE("Client is NOT registered");
1510 __WDC_LOG_FUNC_END__;
1511 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
1514 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
1515 "DisconnectAll", NULL, &error);
1516 if (error != NULL) {
1517 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
1518 "error [%d: %s]", error->code, error->message);
1519 g_error_free(error);
1520 __WDC_LOG_FUNC_END__;
1521 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
1524 g_variant_get(reply, "(i)", &ret);
1525 g_variant_unref(reply);
1527 WDC_LOGD("%s() return : [%d]", __func__, ret);
1528 __WDC_LOG_FUNC_END__;
1533 int wifi_direct_disconnect(char *mac_address)
1535 __WDC_LOG_FUNC_START__;
1537 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
1539 GVariant *params = NULL;
1540 GError *error = NULL;
1541 GVariant *reply = NULL;
1542 int ret = WIFI_DIRECT_ERROR_NONE;
1544 if (g_client_info.is_registered == false) {
1545 WDC_LOGE("Client is NOT registered");
1546 __WDC_LOG_FUNC_END__;
1547 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
1551 WDC_LOGE("mac_addr is NULL");
1552 __WDC_LOG_FUNC_END__;
1553 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
1556 params = g_variant_new("(s)", mac_address);
1557 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
1558 "Disconnect", params, &error);
1559 if (error != NULL) {
1560 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
1561 "error [%d: %s]", error->code, error->message);
1562 g_error_free(error);
1563 __WDC_LOG_FUNC_END__;
1564 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
1567 g_variant_get(reply, "(i)", &ret);
1568 g_variant_unref(reply);
1570 WDC_LOGD("%s() return : [%d]", __func__, ret);
1571 __WDC_LOG_FUNC_END__;
1575 int wifi_direct_accept_connection(char *mac_address)
1577 __WDC_LOG_FUNC_START__;
1579 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
1581 GVariant *params = NULL;
1582 GError *error = NULL;
1583 GVariant *reply = NULL;
1584 int ret = WIFI_DIRECT_ERROR_NONE;
1586 if (g_client_info.is_registered == false) {
1587 WDC_LOGE("Client is NOT registered");
1588 __WDC_LOG_FUNC_END__;
1589 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
1593 WDC_LOGE("mac_addr is NULL");
1594 __WDC_LOG_FUNC_END__;
1595 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
1598 params = g_variant_new("(s)", mac_address);
1599 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
1600 "AcceptConnection", params, &error);
1601 if (error != NULL) {
1602 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
1603 "error [%d: %s]", error->code, error->message);
1604 g_error_free(error);
1605 __WDC_LOG_FUNC_END__;
1606 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
1609 g_variant_get(reply, "(i)", &ret);
1610 g_variant_unref(reply);
1612 WDC_LOGD("%s() return : [%d]", __func__, ret);
1613 __WDC_LOG_FUNC_END__;
1618 int wifi_direct_foreach_connected_peers(wifi_direct_connected_peer_cb cb,
1621 __WDC_LOG_FUNC_START__;
1623 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
1625 GVariant *params = NULL;
1626 GError *error = NULL;
1627 GVariant *reply = NULL;
1628 GVariantIter *iter_peers = NULL;
1629 GVariantIter *iter_peer = NULL;
1630 GVariant *var = NULL;
1632 int ret = WIFI_DIRECT_ERROR_NONE;
1634 if (g_client_info.is_registered == false) {
1635 WDC_LOGE("Client is NOT registered");
1636 __WDC_LOG_FUNC_END__;
1637 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
1641 WDC_LOGE("NULL Param [callback]!");
1642 __WDC_LOG_FUNC_END__;
1643 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
1646 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
1647 "GetConnectedPeers", params, &error);
1648 if (error != NULL) {
1649 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
1650 "error [%d: %s]", error->code, error->message);
1651 g_error_free(error);
1652 __WDC_LOG_FUNC_END__;
1653 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
1656 g_variant_get(reply, "(iaa{sv})", &ret, &iter_peers);
1657 if (ret != WIFI_DIRECT_ERROR_NONE) {
1658 __WDC_LOG_FUNC_END__;
1659 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
1662 WDC_LOGD("wifi_direct_foreach_connected_peers() SUCCESS");
1664 while(g_variant_iter_loop(iter_peers, "a{sv}", &iter_peer)) {
1665 wifi_direct_connected_peer_info_s *peer_list = NULL;
1667 peer_list = (wifi_direct_connected_peer_info_s *) g_try_malloc0(sizeof(wifi_direct_connected_peer_info_s));
1669 WDC_LOGE("Failed to allocate memory");
1673 while (g_variant_iter_loop(iter_peer, "{sv}", &key, &var)) {
1674 if (!g_strcmp0(key, "DeviceName")) {
1675 const char *device_name = NULL;
1677 g_variant_get(var, "&s", &device_name);
1678 peer_list->device_name = g_strndup(device_name, WIFI_DIRECT_MAX_DEVICE_NAME_LEN+1);
1680 } else if (!g_strcmp0(key, "DeviceAddress")) {
1681 unsigned char mac_address[MACADDR_LEN] = {0, };
1683 wifi_direct_dbus_unpack_ay(mac_address, var, MACADDR_LEN);
1684 peer_list->mac_address = (char*) g_try_malloc0(MACSTR_LEN);
1685 if (peer_list->mac_address)
1686 g_snprintf(peer_list->mac_address, MACSTR_LEN, MACSTR, MAC2STR(mac_address));
1688 } else if (!g_strcmp0(key, "InterfaceAddress")) {
1689 unsigned char intf_address[MACADDR_LEN] = {0, };
1691 wifi_direct_dbus_unpack_ay(intf_address, var, MACADDR_LEN);
1692 peer_list->interface_address = (char*) g_try_malloc0(MACSTR_LEN);
1693 if (peer_list->interface_address)
1694 g_snprintf(peer_list->interface_address, MACSTR_LEN, MACSTR, MAC2STR(intf_address));
1696 } else if (!g_strcmp0(key, "IPAddress")) {
1697 unsigned char ip_address[IPADDR_LEN] = {0, };
1699 wifi_direct_dbus_unpack_ay(ip_address, var, IPADDR_LEN);
1700 peer_list->ip_address = (char*) g_try_malloc0(IPSTR_LEN);
1701 if (peer_list->ip_address)
1702 g_snprintf(peer_list->ip_address, IPSTR_LEN, IPSTR, IP2STR(ip_address));
1704 } else if (!g_strcmp0(key, "Channel")) {
1705 peer_list->channel = g_variant_get_uint16(var);
1707 } else if (!g_strcmp0(key, "Category")) {
1708 peer_list->primary_device_type = g_variant_get_uint16(var);
1710 } else if (!g_strcmp0(key, "SubCategory")) {
1711 peer_list->secondary_device_type = g_variant_get_uint16(var);
1713 } else if (!g_strcmp0(key, "IsWfdDevice")) {
1714 #ifdef TIZEN_FEATURE_WIFI_DISPLAY
1715 peer_list->is_miracast_device = g_variant_get_boolean(var);
1716 #endif /* TIZEN_FEATURE_WIFI_DISPLAY */
1717 } else if (!g_strcmp0(key, "IsP2P")) {
1718 peer_list->p2p_supported = g_variant_get_boolean(var);
1725 //__wfd_client_print_connected_peer_info(peer_list, 1);
1726 if (!cb(peer_list, user_data)) {
1727 g_variant_iter_free(iter_peer);
1732 g_variant_iter_free(iter_peers);
1733 g_variant_unref(reply);
1734 __WDC_LOG_FUNC_END__;
1735 return WIFI_DIRECT_ERROR_NONE;
1739 int wifi_direct_create_group(void)
1741 __WDC_LOG_FUNC_START__;
1743 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
1745 GError *error = NULL;
1746 GVariant *reply = NULL;
1747 int ret = WIFI_DIRECT_ERROR_NONE;
1749 if (g_client_info.is_registered == false) {
1750 WDC_LOGE("Client is NOT registered");
1751 __WDC_LOG_FUNC_END__;
1752 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
1755 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_GROUP_INTERFACE,
1756 "CreateGroup", NULL, &error);
1757 if (error != NULL) {
1758 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
1759 "error [%d: %s]", error->code, error->message);
1760 g_error_free(error);
1761 __WDC_LOG_FUNC_END__;
1762 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
1765 g_variant_get(reply, "(i)", &ret);
1766 g_variant_unref(reply);
1768 WDC_LOGD("%s() return : [%d]", __func__, ret);
1769 __WDC_LOG_FUNC_END__;
1774 int wifi_direct_destroy_group(void)
1776 __WDC_LOG_FUNC_START__;
1778 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
1780 GError *error = NULL;
1781 GVariant *reply = NULL;
1782 int ret = WIFI_DIRECT_ERROR_NONE;
1784 if (g_client_info.is_registered == false) {
1785 WDC_LOGE("Client is NOT registered");
1786 __WDC_LOG_FUNC_END__;
1787 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
1790 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_GROUP_INTERFACE,
1791 "DestroyGroup", NULL, &error);
1792 if (error != NULL) {
1793 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
1794 "error [%d: %s]", error->code, error->message);
1795 g_error_free(error);
1796 __WDC_LOG_FUNC_END__;
1797 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
1800 g_variant_get(reply, "(i)", &ret);
1801 g_variant_unref(reply);
1803 WDC_LOGD("%s() return : [%d]", __func__, ret);
1804 __WDC_LOG_FUNC_END__;
1809 int wifi_direct_is_group_owner(bool *owner)
1811 __WDC_LOG_FUNC_START__;
1813 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
1815 GError* error = NULL;
1816 GVariant *reply = NULL;
1819 if (g_client_info.is_registered == false) {
1820 WDC_LOGE("Client is NOT registered");
1821 __WDC_LOG_FUNC_END__;
1822 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
1826 WDC_LOGE("NULL Param [owner]!");
1827 __WDC_LOG_FUNC_END__;
1828 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
1831 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_GROUP_INTERFACE,
1835 if (error != NULL) {
1836 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
1837 "error [%d: %s]", error->code, error->message);
1838 g_error_free(error);
1839 __WDC_LOG_FUNC_END__;
1840 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
1842 WDC_LOGD("%s() SUCCESS", __func__);
1843 g_variant_get(reply, "(b)", &val);
1845 g_variant_unref(reply);
1847 __WDC_LOG_FUNC_END__;
1848 return WIFI_DIRECT_ERROR_NONE;
1851 int wifi_direct_is_autonomous_group(bool *autonomous_group)
1853 __WDC_LOG_FUNC_START__;
1855 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
1857 GError* error = NULL;
1858 GVariant *reply = NULL;
1861 if (g_client_info.is_registered == false) {
1862 WDC_LOGE("Client is NOT registered");
1863 __WDC_LOG_FUNC_END__;
1864 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
1867 if (!autonomous_group) {
1868 WDC_LOGE("NULL Param [autonomous_group]!\n");
1869 __WDC_LOG_FUNC_END__;
1870 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
1873 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_GROUP_INTERFACE,
1877 if (error != NULL) {
1878 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
1879 "error [%d: %s]", error->code, error->message);
1880 g_error_free(error);
1881 __WDC_LOG_FUNC_END__;
1882 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
1884 WDC_LOGD("%s() SUCCESS", __func__);
1885 g_variant_get(reply, "(b)", &val);
1886 *autonomous_group = val;
1887 g_variant_unref(reply);
1889 __WDC_LOG_FUNC_END__;
1890 return WIFI_DIRECT_ERROR_NONE;
1894 int wifi_direct_set_group_owner_intent(int intent)
1896 __WDC_LOG_FUNC_START__;
1898 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
1900 GError* error = NULL;
1901 GVariant *reply = NULL;
1902 GVariant *params = NULL;
1903 int ret = WIFI_DIRECT_ERROR_NONE;
1905 if (g_client_info.is_registered == false) {
1906 WDC_LOGE("Client is NOT registered");
1907 __WDC_LOG_FUNC_END__;
1908 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
1911 if (intent < 0 || intent > 15) {
1912 WDC_LOGE("Invalid Param : intent[%d]", intent);
1913 __WDC_LOG_FUNC_END__;
1914 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
1917 params = g_variant_new("(i)", intent);
1918 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
1922 if (error != NULL) {
1923 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
1924 "error [%d: %s]", error->code, error->message);
1925 g_error_free(error);
1926 __WDC_LOG_FUNC_END__;
1927 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
1930 g_variant_get(reply, "(i)", &ret);
1931 g_variant_unref(reply);
1933 WDC_LOGD("%s() return : [%d]", __func__, ret);
1934 __WDC_LOG_FUNC_END__;
1938 int wifi_direct_get_group_owner_intent(int *intent)
1940 __WDC_LOG_FUNC_START__;
1942 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
1944 GError* error = NULL;
1945 GVariant *reply = NULL;
1947 int ret = WIFI_DIRECT_ERROR_NONE;
1949 if (g_client_info.is_registered == false) {
1950 WDC_LOGE("Client is NOT registered");
1951 __WDC_LOG_FUNC_END__;
1952 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
1956 WDC_LOGE("Invalid Parameter");
1957 __WDC_LOG_FUNC_END__;
1958 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
1961 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
1965 if (error != NULL) {
1966 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
1967 "error [%d: %s]", error->code, error->message);
1968 g_error_free(error);
1969 __WDC_LOG_FUNC_END__;
1970 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
1973 g_variant_get(reply, "(ii)", &ret, &val);
1975 g_variant_unref(reply);
1977 WDC_LOGD("Intent = [%d]", *intent);
1978 WDC_LOGD("%s() return : [%d]", __func__, ret);
1979 __WDC_LOG_FUNC_END__;
1983 int wifi_direct_set_max_clients(int max)
1985 __WDC_LOG_FUNC_START__;
1987 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
1989 GError* error = NULL;
1990 GVariant *reply = NULL;
1991 GVariant *params = NULL;
1992 int ret = WIFI_DIRECT_ERROR_NONE;
1994 if (g_client_info.is_registered == false) {
1995 WDC_LOGE("Client is NOT registered");
1996 __WDC_LOG_FUNC_END__;
1997 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
1999 WDC_LOGD("max client [%d]\n", max);
2001 params = g_variant_new("(i)", max);
2002 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
2006 if (error != NULL) {
2007 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
2008 "error [%d: %s]", error->code, error->message);
2009 g_error_free(error);
2010 __WDC_LOG_FUNC_END__;
2011 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
2014 g_variant_get(reply, "(i)", &ret);
2015 g_variant_unref(reply);
2017 WDC_LOGD("%s() return : [%d]", __func__, ret);
2018 __WDC_LOG_FUNC_END__;
2022 int wifi_direct_get_max_clients(int *max)
2024 __WDC_LOG_FUNC_START__;
2026 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
2028 GError* error = NULL;
2029 GVariant *reply = NULL;
2031 int ret = WIFI_DIRECT_ERROR_NONE;
2033 if (g_client_info.is_registered == false) {
2034 WDC_LOGE("Client is NOT registered");
2035 __WDC_LOG_FUNC_END__;
2036 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
2040 WDC_LOGE("Invalid Parameter");
2041 __WDC_LOG_FUNC_END__;
2042 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
2045 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
2049 if (error != NULL) {
2050 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
2051 "error [%d: %s]", error->code, error->message);
2052 g_error_free(error);
2053 __WDC_LOG_FUNC_END__;
2054 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
2057 g_variant_get(reply, "(ii)", &ret, &val);
2059 g_variant_unref(reply);
2061 WDC_LOGD("max_client = [%d]", *max);
2062 WDC_LOGD("%s() return : [%d]", __func__, ret);
2063 __WDC_LOG_FUNC_END__;
2064 return WIFI_DIRECT_ERROR_NONE;
2067 int wifi_direct_get_operating_channel(int *channel)
2069 __WDC_LOG_FUNC_START__;
2071 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
2073 GError* error = NULL;
2074 GVariant *reply = NULL;
2076 int ret = WIFI_DIRECT_ERROR_NONE;
2078 if (g_client_info.is_registered == false) {
2079 WDC_LOGE("Client is NOT registered");
2080 __WDC_LOG_FUNC_END__;
2081 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
2085 WDC_LOGE("NULL Param [channel]!\n");
2086 __WDC_LOG_FUNC_END__;
2087 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
2090 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
2091 "GetOperatingChannel",
2094 if (error != NULL) {
2095 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
2096 "error [%d: %s]", error->code, error->message);
2097 g_error_free(error);
2098 __WDC_LOG_FUNC_END__;
2099 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
2102 g_variant_get(reply, "(ii)", &ret, &val);
2104 g_variant_unref(reply);
2106 WDC_LOGD("channel = [%d]", *channel);
2107 WDC_LOGD("%s() return : [%d]", __func__, ret);
2108 __WDC_LOG_FUNC_END__;
2109 return WIFI_DIRECT_ERROR_NONE;
2112 int wifi_direct_activate_pushbutton(void)
2114 __WDC_LOG_FUNC_START__;
2116 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
2118 GError* error = NULL;
2119 GVariant *reply = NULL;
2120 int ret = WIFI_DIRECT_ERROR_NONE;
2122 if (g_client_info.is_registered == false) {
2123 WDC_LOGE("Client is NOT registered");
2124 __WDC_LOG_FUNC_END__;
2125 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
2128 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_GROUP_INTERFACE,
2129 "ActivatePushButton",
2132 if (error != NULL) {
2133 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
2134 "error [%d: %s]", error->code, error->message);
2135 g_error_free(error);
2136 __WDC_LOG_FUNC_END__;
2137 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
2139 WDC_LOGD("%s() SUCCESS", __func__);
2141 g_variant_get(reply, "(i)", &ret);
2142 g_variant_unref(reply);
2144 WDC_LOGD("%s() return : [%d]", __func__, ret);
2145 __WDC_LOG_FUNC_END__;
2149 int wifi_direct_set_wps_pin(char *pin)
2151 __WDC_LOG_FUNC_START__;
2153 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
2155 GError* error = NULL;
2156 GVariant *reply = NULL;
2157 GVariant *params = NULL;
2158 int ret = WIFI_DIRECT_ERROR_NONE;
2160 if (g_client_info.is_registered == false) {
2161 WDC_LOGE("Client is NOT registered");
2162 __WDC_LOG_FUNC_END__;
2163 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
2167 WDC_LOGE("NULL Param [pin]!");
2168 __WDC_LOG_FUNC_END__;
2169 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
2171 WDC_LOGE("pin = [%s]\n", pin);
2173 params = g_variant_new("(s)", pin);
2174 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
2178 if (error != NULL) {
2179 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
2180 "error [%d: %s]", error->code, error->message);
2181 g_error_free(error);
2182 __WDC_LOG_FUNC_END__;
2183 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
2186 g_variant_get(reply, "(i)", &ret);
2187 g_variant_unref(reply);
2189 WDC_LOGD("%s() return : [%d]", __func__, ret);
2190 __WDC_LOG_FUNC_END__;
2195 int wifi_direct_get_wps_pin(char **pin)
2197 __WDC_LOG_FUNC_START__;
2199 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
2201 GError* error = NULL;
2202 GVariant *reply = NULL;
2203 const char *str = NULL;
2204 int ret = WIFI_DIRECT_ERROR_NONE;
2206 if (g_client_info.is_registered == false) {
2207 WDC_LOGE("Client is NOT registered");
2208 __WDC_LOG_FUNC_END__;
2209 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
2212 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
2216 if (error != NULL) {
2217 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
2218 "error [%d: %s]", error->code, error->message);
2219 g_error_free(error);
2220 __WDC_LOG_FUNC_END__;
2221 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
2224 g_variant_get(reply, "(i&s)", &ret, &str);
2225 if(pin != NULL && str != NULL)
2226 *pin = g_strdup(str);
2227 g_variant_unref(reply);
2229 WDC_LOGD("%s() return : [%d]", __func__, ret);
2230 __WDC_LOG_FUNC_END__;
2234 int wifi_direct_get_supported_wps_mode(int *wps_mode)
2236 __WDC_LOG_FUNC_START__;
2238 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
2240 GError* error = NULL;
2241 GVariant *reply = NULL;
2243 int ret = WIFI_DIRECT_ERROR_NONE;
2245 if (g_client_info.is_registered == false) {
2246 WDC_LOGE("Client is NOT registered");
2247 __WDC_LOG_FUNC_END__;
2248 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
2252 WDC_LOGE("NULL Param [wps_mode]!");
2253 __WDC_LOG_FUNC_END__;
2254 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
2257 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
2258 "GetSupportedWpsMode",
2261 if (error != NULL) {
2262 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
2263 "error [%d: %s]", error->code, error->message);
2264 g_error_free(error);
2265 __WDC_LOG_FUNC_END__;
2266 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
2269 g_variant_get(reply, "(ii)", &ret, &mode);
2271 g_variant_unref(reply);
2273 WDC_LOGD("%s() return : [%d]", __func__, ret);
2274 __WDC_LOG_FUNC_END__;
2278 int wifi_direct_foreach_supported_wps_types(wifi_direct_supported_wps_type_cb cb, void* user_data)
2280 __WDC_LOG_FUNC_START__;
2282 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
2284 GError* error = NULL;
2285 GVariant *reply = NULL;
2287 int ret = WIFI_DIRECT_ERROR_NONE;
2288 gboolean result = FALSE;
2290 if (g_client_info.is_registered == false) {
2291 WDC_LOGE("Client is NOT registered");
2292 __WDC_LOG_FUNC_END__;
2293 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
2297 WDC_LOGE("NULL Param [callback]!");
2298 __WDC_LOG_FUNC_END__;
2299 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
2302 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
2303 "GetSupportedWpsMode",
2306 if (error != NULL) {
2307 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
2308 "error [%d: %s]", error->code, error->message);
2309 g_error_free(error);
2310 __WDC_LOG_FUNC_END__;
2311 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
2314 g_variant_get(reply, "(ii)", &ret, &wps_mode);
2315 g_variant_unref(reply);
2317 if (wps_mode & WIFI_DIRECT_WPS_TYPE_PBC)
2318 result = cb(WIFI_DIRECT_WPS_TYPE_PBC, user_data);
2319 if ((result == TRUE) && (wps_mode & WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY))
2320 result = cb(WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY, user_data);
2321 if ((result == TRUE) && (wps_mode & WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD))
2322 result = cb(WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD, user_data);
2324 WDC_LOGD("%s() return : [%d]", __func__, ret);
2325 __WDC_LOG_FUNC_END__;
2329 int wifi_direct_get_local_wps_type(wifi_direct_wps_type_e *type)
2331 __WDC_LOG_FUNC_START__;
2333 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
2335 GError* error = NULL;
2336 GVariant *reply = NULL;
2338 int ret = WIFI_DIRECT_ERROR_NONE;
2340 if (g_client_info.is_registered == false) {
2341 WDC_LOGE("Client is NOT registered");
2342 __WDC_LOG_FUNC_END__;
2343 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
2347 WDC_LOGE("NULL Param [type]!\n");
2348 __WDC_LOG_FUNC_END__;
2349 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
2352 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
2356 if (error != NULL) {
2357 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
2358 "error [%d: %s]", error->code, error->message);
2359 g_error_free(error);
2360 __WDC_LOG_FUNC_END__;
2361 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
2364 g_variant_get(reply, "(ii)", &ret, &mode);
2366 g_variant_unref(reply);
2368 WDC_LOGD("%s() return : [%d]", __func__, ret);
2369 __WDC_LOG_FUNC_END__;
2373 int wifi_direct_set_req_wps_type(wifi_direct_wps_type_e type)
2375 __WDC_LOG_FUNC_START__;
2377 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
2379 GError* error = NULL;
2380 GVariant *reply = NULL;
2381 GVariant *params = NULL;
2382 int ret = WIFI_DIRECT_ERROR_NONE;
2384 if (g_client_info.is_registered == false) {
2385 WDC_LOGE("Client is NOT registered");
2386 __WDC_LOG_FUNC_END__;
2387 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
2390 if (type == WIFI_DIRECT_WPS_TYPE_PBC ||
2391 type == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY ||
2392 type == WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD) {
2393 WDC_LOGD("Param wps_mode [%d]", type);
2395 WDC_LOGE("Invalid Param [wps_mode]!");
2396 __WDC_LOG_FUNC_END__;
2397 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
2400 params = g_variant_new("(i)", type);
2401 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
2405 if (error != NULL) {
2406 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
2407 "error [%d: %s]", error->code, error->message);
2408 g_error_free(error);
2409 __WDC_LOG_FUNC_END__;
2410 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
2413 g_variant_get(reply, "(i)", &ret);
2414 g_variant_unref(reply);
2416 WDC_LOGD("%s() return : [%d]", __func__, ret);
2417 __WDC_LOG_FUNC_END__;
2421 int wifi_direct_get_req_wps_type(wifi_direct_wps_type_e *type)
2423 __WDC_LOG_FUNC_START__;
2425 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
2427 GError* error = NULL;
2428 GVariant *reply = NULL;
2432 if (g_client_info.is_registered == false) {
2433 WDC_LOGE("Client is NOT registered");
2434 __WDC_LOG_FUNC_END__;
2435 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
2439 WDC_LOGE("NULL Param [type]!\n");
2440 __WDC_LOG_FUNC_END__;
2441 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
2444 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
2448 if (error != NULL) {
2449 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
2450 "error [%d: %s]", error->code, error->message);
2451 g_error_free(error);
2452 __WDC_LOG_FUNC_END__;
2453 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
2456 g_variant_get(reply, "(ii)", &ret, &mode);
2458 g_variant_unref(reply);
2460 WDC_LOGD("%s() return : [%d]", __func__, ret);
2461 __WDC_LOG_FUNC_END__;
2465 int wifi_direct_get_ssid(char **ssid)
2467 __WDC_LOG_FUNC_START__;
2469 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
2471 GError* error = NULL;
2472 GVariant *reply = NULL;
2473 const char *str = NULL;
2474 int ret = WIFI_DIRECT_ERROR_NONE;
2476 if (g_client_info.is_registered == false) {
2477 WDC_LOGE("Client is NOT registered");
2478 __WDC_LOG_FUNC_END__;
2479 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
2483 WDC_LOGE("Invalid Parameter");
2484 __WDC_LOG_FUNC_END__;
2485 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
2488 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
2492 if (error != NULL) {
2493 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
2494 "error [%d: %s]", error->code, error->message);
2495 g_error_free(error);
2496 __WDC_LOG_FUNC_END__;
2497 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
2500 g_variant_get(reply, "(i&s)", &ret, &str);
2501 *ssid = g_strdup(str);
2502 g_variant_unref(reply);
2504 WDC_LOGD("%s() return : [%d]", __func__, ret);
2505 __WDC_LOG_FUNC_END__;
2509 int wifi_direct_get_device_name(char **device_name)
2511 __WDC_LOG_FUNC_START__;
2513 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
2515 GError* error = NULL;
2516 GVariant *reply = NULL;
2517 const char *str = NULL;
2518 int ret = WIFI_DIRECT_ERROR_NONE;
2520 if (g_client_info.is_registered == false) {
2521 WDC_LOGE("Client is NOT registered");
2522 __WDC_LOG_FUNC_END__;
2523 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
2527 WDC_LOGE("Invalid Parameter");
2528 __WDC_LOG_FUNC_END__;
2529 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
2532 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
2536 if (error != NULL) {
2537 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
2538 "error [%d: %s]", error->code, error->message);
2539 g_error_free(error);
2540 __WDC_LOG_FUNC_END__;
2541 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
2544 g_variant_get(reply, "(i&s)", &ret, &str);
2545 *device_name = g_strdup(str);
2546 g_variant_unref(reply);
2548 WDC_LOGD("%s() return : [%d]", __func__, ret);
2549 __WDC_LOG_FUNC_END__;
2553 int wifi_direct_set_device_name(const char *device_name)
2555 __WDC_LOG_FUNC_START__;
2557 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
2559 GError* error = NULL;
2560 GVariant *reply = NULL;
2561 GVariant *params = NULL;
2562 int ret = WIFI_DIRECT_ERROR_NONE;
2564 if (g_client_info.is_registered == false) {
2565 WDC_LOGE("Client is NOT registered");
2566 __WDC_LOG_FUNC_END__;
2567 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
2571 WDC_LOGE("NULL Param [device_name]!");
2572 __WDC_LOG_FUNC_END__;
2573 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
2575 WDC_LOGE("device_name = [%s]", device_name);
2577 params = g_variant_new("(s)", device_name);
2578 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
2582 if (error != NULL) {
2583 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
2584 "error [%d: %s]", error->code, error->message);
2585 g_error_free(error);
2586 __WDC_LOG_FUNC_END__;
2587 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
2590 g_variant_get(reply, "(i)", &ret);
2591 g_variant_unref(reply);
2593 WDC_LOGD("%s() return : [%d]", __func__, ret);
2594 __WDC_LOG_FUNC_END__;
2598 int wifi_direct_get_network_interface_name(char **name)
2600 __WDC_LOG_FUNC_START__;
2602 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
2604 wifi_direct_state_e status = 0;
2605 char *get_str = NULL;
2606 GError* error = NULL;
2607 GVariant *reply = NULL;
2608 int ret = WIFI_DIRECT_ERROR_NONE;
2610 if (g_client_info.is_registered == false) {
2611 WDC_LOGE("Client is NOT registered");
2612 __WDC_LOG_FUNC_END__;
2613 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
2617 WDC_LOGE("NULL Param [name]!\n");
2618 __WDC_LOG_FUNC_END__;
2619 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
2622 ret = wifi_direct_get_state(&status);
2623 WDC_LOGD("wifi_direct_get_state() state=[%d], ret=[%d]\n", status, ret);
2625 if (status < WIFI_DIRECT_STATE_CONNECTED) {
2626 WDC_LOGE("Device is not connected!\n");
2627 __WDC_LOG_FUNC_END__;
2628 return WIFI_DIRECT_ERROR_NOT_PERMITTED;
2631 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
2635 if (error != NULL) {
2636 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
2637 "error [%d: %s]", error->code, error->message);
2638 g_error_free(error);
2639 __WDC_LOG_FUNC_END__;
2640 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
2643 g_variant_get(reply, "(i&s)", ret ,&get_str);
2644 *name = g_strdup(get_str);
2645 g_variant_unref(reply);
2647 WDC_LOGD("Interface Name = [%s]", *name);
2648 WDC_LOGD("%s() return : [%d]", __func__, ret);
2650 __WDC_LOG_FUNC_END__;
2651 return WIFI_DIRECT_ERROR_NONE;
2654 int wifi_direct_get_ip_address(char **ip_address)
2656 __WDC_LOG_FUNC_START__;
2658 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
2660 GError* error = NULL;
2661 GVariant *reply = NULL;
2662 const char *str = NULL;
2663 int ret = WIFI_DIRECT_ERROR_NONE;
2665 if (g_client_info.is_registered == false) {
2666 WDC_LOGE("Client is NOT registered");
2667 __WDC_LOG_FUNC_END__;
2668 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
2672 WDC_LOGE("NULL Param [ip_address]!\n");
2673 __WDC_LOG_FUNC_END__;
2674 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
2677 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
2681 if (error != NULL) {
2682 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
2683 "error [%d: %s]", error->code, error->message);
2684 g_error_free(error);
2685 __WDC_LOG_FUNC_END__;
2686 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
2689 g_variant_get(reply, "(i&s)", ret ,&str);
2690 *ip_address = g_strdup(str);
2691 g_variant_unref(reply);
2693 WDC_LOGD("IP address = [%s]", *ip_address);
2694 WDC_LOGD("%s() return : [%d]", __func__, ret);
2695 __WDC_LOG_FUNC_END__;
2699 int wifi_direct_get_subnet_mask(char **subnet_mask)
2701 __WDC_LOG_FUNC_START__;
2703 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
2705 wifi_direct_state_e status = 0;
2706 GError* error = NULL;
2707 GVariant *reply = NULL;
2708 char *get_str = NULL;
2709 int ret = WIFI_DIRECT_ERROR_NONE;
2711 if (g_client_info.is_registered == false) {
2712 WDC_LOGE("Client is NOT registered");
2713 __WDC_LOG_FUNC_END__;
2714 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
2718 WDC_LOGE("NULL Param [subnet_mask]!");
2719 __WDC_LOG_FUNC_END__;
2720 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
2723 ret = wifi_direct_get_state(&status);
2724 WDC_LOGD("wifi_direct_get_state() state=[%d], ret=[%d]", status, ret);
2725 if( status < WIFI_DIRECT_STATE_CONNECTED) {
2726 WDC_LOGE("Device is not connected!");
2727 __WDC_LOG_FUNC_END__;
2728 return WIFI_DIRECT_ERROR_NOT_PERMITTED;
2731 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
2735 if (error != NULL) {
2736 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
2737 "error [%d: %s]", error->code, error->message);
2738 g_error_free(error);
2739 __WDC_LOG_FUNC_END__;
2740 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
2743 g_variant_get(reply, "(i&s)", ret ,&get_str);
2744 *subnet_mask = g_strdup(get_str);
2745 g_variant_unref(reply);
2747 WDC_LOGD("Subnet Mask = [%s]", *subnet_mask);
2748 WDC_LOGD("%s() return : [%d]", __func__, ret);
2750 __WDC_LOG_FUNC_END__;
2751 return WIFI_DIRECT_ERROR_NONE;
2754 int wifi_direct_get_gateway_address(char **gateway_address)
2756 __WDC_LOG_FUNC_START__;
2758 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
2760 wifi_direct_state_e status = 0;
2761 GError* error = NULL;
2762 GVariant *reply = NULL;
2763 char *get_str = NULL;
2764 int ret = WIFI_DIRECT_ERROR_NONE;
2766 if (g_client_info.is_registered == false) {
2767 WDC_LOGE("Client is NOT registered");
2768 __WDC_LOG_FUNC_END__;
2769 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
2772 if (!gateway_address) {
2773 WDC_LOGE("NULL Param [gateway_address]!");
2774 __WDC_LOG_FUNC_END__;
2775 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
2778 ret = wifi_direct_get_state(&status);
2779 WDC_LOGD("wifi_direct_get_state() state=[%d], ret=[%d]", status, ret);
2780 if(status < WIFI_DIRECT_STATE_CONNECTED) {
2781 WDC_LOGE("Device is not connected!");
2782 __WDC_LOG_FUNC_END__;
2783 return WIFI_DIRECT_ERROR_NOT_PERMITTED;
2786 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
2790 if (error != NULL) {
2791 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
2792 "error [%d: %s]", error->code, error->message);
2793 g_error_free(error);
2794 __WDC_LOG_FUNC_END__;
2795 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
2798 g_variant_get(reply, "(i&s)", ret ,&get_str);
2799 *gateway_address = g_strdup(get_str);
2800 g_variant_unref(reply);
2802 WDC_LOGD("Gateway Address = [%s]", *gateway_address);
2803 WDC_LOGD("%s() return : [%d]", __func__, ret);
2805 __WDC_LOG_FUNC_END__;
2806 return WIFI_DIRECT_ERROR_NONE;
2809 int wifi_direct_get_mac_address(char **mac_address)
2811 __WDC_LOG_FUNC_START__;
2813 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
2815 GError* error = NULL;
2816 GVariant *reply = NULL;
2817 const char *str = NULL;
2818 int ret = WIFI_DIRECT_ERROR_NONE;
2820 if (g_client_info.is_registered == false) {
2821 WDC_LOGE("Client is NOT registered");
2822 __WDC_LOG_FUNC_END__;
2823 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
2827 WDC_LOGE("NULL Param [mac_address]!");
2828 __WDC_LOG_FUNC_END__;
2829 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
2832 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
2836 if (error != NULL) {
2837 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
2838 "error [%d: %s]", error->code, error->message);
2839 g_error_free(error);
2840 __WDC_LOG_FUNC_END__;
2841 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
2844 g_variant_get(reply, "(i&s)", &ret, &str);
2845 *mac_address = g_strdup(str);
2846 g_variant_unref(reply);
2848 WDC_SECLOGD("MAC address = [%s]", *mac_address);
2849 WDC_LOGD("%s() return : [%d]", __func__, ret);
2850 __WDC_LOG_FUNC_END__;
2855 int wifi_direct_get_state(wifi_direct_state_e *state)
2857 __WDC_LOG_FUNC_START__;
2859 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
2861 GError* error = NULL;
2862 GVariant *reply = NULL;
2864 int ret = WIFI_DIRECT_ERROR_NONE;
2866 if (g_client_info.is_registered == false) {
2867 WDC_LOGE("Client is NOT registered");
2868 __WDC_LOG_FUNC_END__;
2869 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
2873 WDC_LOGE("Invalid Parameter");
2874 __WDC_LOG_FUNC_END__;
2875 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
2878 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
2879 "GetState", NULL, &error);
2880 if (error != NULL) {
2881 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
2882 "error [%d: %s]", error->code, error->message);
2883 g_error_free(error);
2884 __WDC_LOG_FUNC_END__;
2885 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
2888 g_variant_get(reply, "(ii)", &ret, &val);
2889 *state = (wifi_direct_state_e) val;
2890 /* for CAPI : there is no WIFI_DIRECT_STATE_GROUP_OWNER type in CAPI */
2891 if(*state == WIFI_DIRECT_STATE_GROUP_OWNER)
2892 *state = WIFI_DIRECT_STATE_CONNECTED;
2894 g_variant_unref(reply);
2896 WDC_LOGD("State = [%d]", *state);
2897 WDC_LOGD("%s() return : [%d]", __func__, ret);
2898 __WDC_LOG_FUNC_END__;
2903 int wifi_direct_is_discoverable(bool* discoverable)
2905 __WDC_LOG_FUNC_START__;
2907 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
2909 GError* error = NULL;
2910 GVariant *reply = NULL;
2912 if (g_client_info.is_registered == false) {
2913 WDC_LOGE("Client is NOT registered");
2914 __WDC_LOG_FUNC_END__;
2915 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
2918 if (!discoverable) {
2919 WDC_LOGE("Invalid Parameter");
2920 __WDC_LOG_FUNC_END__;
2921 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
2924 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
2925 "IsDiscoverable", NULL, &error);
2926 if (error != NULL) {
2927 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
2928 "error [%d: %s]", error->code, error->message);
2929 g_error_free(error);
2930 __WDC_LOG_FUNC_END__;
2931 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
2934 g_variant_get(reply, "(b)", discoverable);
2935 WDC_LOGD("Discoverable = [%s]", *discoverable ? "Yes":"No");
2937 WDC_LOGD("%s() SUCCESS", __func__);
2938 g_variant_unref(reply);
2940 __WDC_LOG_FUNC_END__;
2941 return WIFI_DIRECT_ERROR_NONE;
2944 int wifi_direct_is_listening_only(bool* listen_only)
2946 __WDC_LOG_FUNC_START__;
2948 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
2950 GError* error = NULL;
2951 GVariant *reply = NULL;
2953 if (g_client_info.is_registered == false) {
2954 WDC_LOGE("Client is NOT registered");
2955 __WDC_LOG_FUNC_END__;
2956 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
2960 WDC_LOGE("Invalid Parameter");
2961 __WDC_LOG_FUNC_END__;
2962 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
2965 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
2966 "IsListeningOnly", NULL, &error);
2967 if (error != NULL) {
2968 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
2969 "error [%d: %s]", error->code, error->message);
2970 g_error_free(error);
2971 __WDC_LOG_FUNC_END__;
2972 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
2975 g_variant_get(reply, "(b)", listen_only);
2977 WDC_LOGD("Is listen only = [%s]", *listen_only ? "Yes":"No");
2978 WDC_LOGD("%s() SUCCESS", __func__);
2979 g_variant_unref(reply);
2981 __WDC_LOG_FUNC_END__;
2982 return WIFI_DIRECT_ERROR_NONE;
2986 int wifi_direct_get_primary_device_type(wifi_direct_primary_device_type_e* type)
2988 __WDC_LOG_FUNC_START__;
2990 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
2993 WDC_LOGE("NULL Param [type]!");
2994 __WDC_LOG_FUNC_END__;
2995 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
2998 if (g_client_info.is_registered == false) {
2999 WDC_LOGE("Client is NOT registered");
3000 __WDC_LOG_FUNC_END__;
3001 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
3005 WDC_LOGD("Current primary_dev_type [%d]", WIFI_DIRECT_PRIMARY_DEVICE_TYPE_DISPLAY);
3006 *type = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_DISPLAY;
3007 #else /* TIZEN_TV */
3008 WDC_LOGD("Current primary_dev_type [%d]", WIFI_DIRECT_PRIMARY_DEVICE_TYPE_TELEPHONE);
3009 *type = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_TELEPHONE;
3010 #endif /* TIZEN_TV */
3012 __WDC_LOG_FUNC_END__;
3013 return WIFI_DIRECT_ERROR_NONE;
3016 int wifi_direct_get_secondary_device_type(wifi_direct_secondary_device_type_e* type)
3018 __WDC_LOG_FUNC_START__;
3020 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
3022 if (g_client_info.is_registered == false) {
3023 WDC_LOGE("Client is NOT registered");
3024 __WDC_LOG_FUNC_END__;
3025 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
3029 WDC_LOGE("NULL Param [type]!");
3030 __WDC_LOG_FUNC_END__;
3031 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
3035 WDC_LOGD("Current second_dev_type [%d]", WIFI_DIRECT_SECONDARY_DEVICE_TYPE_DISPLAY_TV);
3036 *type = WIFI_DIRECT_SECONDARY_DEVICE_TYPE_DISPLAY_TV;
3037 #else /* TIZEN_TV */
3038 WDC_LOGD("Current second_dev_type [%d]", WIFI_DIRECT_SECONDARY_DEVICE_TYPE_TELEPHONE_SMARTPHONE_DUAL);
3039 *type = WIFI_DIRECT_SECONDARY_DEVICE_TYPE_TELEPHONE_SMARTPHONE_DUAL; /* smart phone dual mode (wifi and cellular) */
3040 #endif /* TIZEN_TV */
3042 __WDC_LOG_FUNC_END__;
3043 return WIFI_DIRECT_ERROR_NONE;
3046 int wifi_direct_set_autoconnection_mode(bool mode)
3048 __WDC_LOG_FUNC_START__;
3050 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
3052 GError* error = NULL;
3053 GVariant *reply = NULL;
3054 GVariant *params = NULL;
3055 int ret = WIFI_DIRECT_ERROR_NONE;
3057 if (g_client_info.is_registered == false) {
3058 WDC_LOGE("Client is NOT registered");
3059 __WDC_LOG_FUNC_END__;
3060 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
3063 params = g_variant_new("(b)", mode);
3064 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
3065 "SetAutoConnectionMode",
3068 if (error != NULL) {
3069 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
3070 "error [%d: %s]", error->code, error->message);
3071 g_error_free(error);
3072 __WDC_LOG_FUNC_END__;
3073 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
3076 g_variant_get(reply, "(i)", &ret);
3077 g_variant_unref(reply);
3079 WDC_LOGD("%s() return : [%d]", __func__, ret);
3080 __WDC_LOG_FUNC_END__;
3084 int wifi_direct_is_autoconnection_mode(bool *mode)
3086 __WDC_LOG_FUNC_START__;
3088 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
3090 GError* error = NULL;
3091 GVariant *reply = NULL;
3093 int ret = WIFI_DIRECT_ERROR_NONE;
3095 if (g_client_info.is_registered == false) {
3096 WDC_LOGE("Client is NOT registered");
3097 __WDC_LOG_FUNC_END__;
3098 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
3102 WDC_LOGE("NULL Param [mode]!");
3103 __WDC_LOG_FUNC_END__;
3104 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
3107 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
3108 "IsAutoConnectionMode",
3111 if (error != NULL) {
3112 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
3113 "error [%d: %s]", error->code, error->message);
3114 g_error_free(error);
3115 __WDC_LOG_FUNC_END__;
3116 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
3119 g_variant_get(reply, "(ib)", &ret, &val);
3121 g_variant_unref(reply);
3123 WDC_LOGD("%s() return : [%d]", __func__, ret);
3124 __WDC_LOG_FUNC_END__;
3129 int wifi_direct_set_persistent_group_enabled(bool enabled)
3131 __WDC_LOG_FUNC_START__;
3133 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
3135 GError* error = NULL;
3136 GVariant *reply = NULL;
3137 GVariant *params = NULL;
3139 if (g_client_info.is_registered == false) {
3140 WDC_LOGE("Client is NOT registered");
3141 __WDC_LOG_FUNC_END__;
3142 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
3145 params = g_variant_new("(b)", enabled);
3146 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_GROUP_INTERFACE,
3147 "SetPersistentGroupEnabled",
3150 if (error != NULL) {
3151 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
3152 "error [%d: %s]", error->code, error->message);
3153 g_error_free(error);
3154 __WDC_LOG_FUNC_END__;
3155 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
3157 WDC_LOGD("%s() SUCCESS", __func__);
3159 g_variant_unref(reply);
3161 __WDC_LOG_FUNC_END__;
3162 return WIFI_DIRECT_ERROR_NONE;
3166 int wifi_direct_is_persistent_group_enabled(bool *enabled)
3168 __WDC_LOG_FUNC_START__;
3170 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
3172 GError* error = NULL;
3173 GVariant *reply = NULL;
3176 if (g_client_info.is_registered == false) {
3177 WDC_LOGE("Client is NOT registered");
3178 __WDC_LOG_FUNC_END__;
3179 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
3183 WDC_LOGE("NULL Param [enabled]!");
3184 __WDC_LOG_FUNC_END__;
3185 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
3188 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_GROUP_INTERFACE,
3189 "IsPersistentGroupEnabled",
3192 if (error != NULL) {
3193 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
3194 "error [%d: %s]", error->code, error->message);
3195 g_error_free(error);
3196 __WDC_LOG_FUNC_END__;
3197 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
3199 WDC_LOGD("%s() SUCCESS", __func__);
3200 g_variant_get(reply, "(b)", &val);
3202 g_variant_unref(reply);
3204 __WDC_LOG_FUNC_END__;
3205 return WIFI_DIRECT_ERROR_NONE;
3208 int wifi_direct_foreach_persistent_groups(wifi_direct_persistent_group_cb cb,
3211 __WDC_LOG_FUNC_START__;
3213 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
3215 GVariant *params = NULL;
3216 GError *error = NULL;
3217 GVariant *reply = NULL;
3218 GVariantIter *iter_groups = NULL;
3219 GVariantIter *iter_group = NULL;
3220 GVariant *var = NULL;
3222 int ret = WIFI_DIRECT_ERROR_NONE;
3224 if (g_client_info.is_registered == false) {
3225 WDC_LOGE("Client is NOT registered");
3226 __WDC_LOG_FUNC_END__;
3227 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
3231 WDC_LOGE("NULL Param [callback]!");
3232 __WDC_LOG_FUNC_END__;
3233 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
3236 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_GROUP_INTERFACE,
3237 "GetPersistentGroups", params, &error);
3238 if (error != NULL) {
3239 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
3240 "error [%d: %s]", error->code, error->message);
3241 g_error_free(error);
3242 __WDC_LOG_FUNC_END__;
3243 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
3246 g_variant_get(reply, "(iaa{sv})", &ret, &iter_groups);
3247 if (ret != WIFI_DIRECT_ERROR_NONE) {
3248 __WDC_LOG_FUNC_END__;
3249 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
3252 WDC_LOGD("wifi_direct_foreach_persistent_groups() SUCCESS");
3254 while(g_variant_iter_loop(iter_groups, "a{sv}", &iter_group)) {
3255 const char *ssid = NULL;
3256 char *go_mac_address = NULL;
3258 while (g_variant_iter_loop(iter_group, "{sv}", &key, &var)) {
3259 if (!g_strcmp0(key, "SSID")) {
3260 g_variant_get(var, "&s", &ssid);
3262 } else if (!g_strcmp0(key, "GOMacAddress")) {
3263 unsigned char mac_address[MACADDR_LEN] = {0, };
3265 wifi_direct_dbus_unpack_ay(mac_address, var, MACADDR_LEN);
3266 go_mac_address = (char*) g_try_malloc0(MACSTR_LEN);
3268 g_snprintf(go_mac_address, MACSTR_LEN, MACSTR, MAC2STR(mac_address));
3275 ret = cb(go_mac_address, ssid, user_data);
3276 g_free(go_mac_address);
3277 go_mac_address = NULL;
3279 g_variant_iter_free(iter_group);
3284 g_variant_iter_free(iter_groups);
3285 __WDC_LOG_FUNC_END__;
3286 return WIFI_DIRECT_ERROR_NONE;
3289 int wifi_direct_remove_persistent_group(char *mac_address, const char *ssid)
3291 __WDC_LOG_FUNC_START__;
3293 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
3295 GError* error = NULL;
3296 GVariant *reply = NULL;
3297 GVariant *params = NULL;
3299 if (g_client_info.is_registered == false) {
3300 WDC_LOGE("Client is NOT registered");
3301 __WDC_LOG_FUNC_END__;
3302 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
3305 if (!mac_address || !ssid) {
3306 WDC_LOGE("NULL Param");
3307 __WDC_LOG_FUNC_END__;
3308 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
3311 params = g_variant_new("(ss)", mac_address, ssid);
3312 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_GROUP_INTERFACE,
3313 "RemovePersistentGroup",
3316 if (error != NULL) {
3317 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
3318 "error [%d: %s]", error->code, error->message);
3319 g_error_free(error);
3320 __WDC_LOG_FUNC_END__;
3321 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
3323 WDC_LOGD("%s() SUCCESS", __func__);
3325 g_variant_unref(reply);
3327 __WDC_LOG_FUNC_END__;
3328 return WIFI_DIRECT_ERROR_NONE;
3331 int wifi_direct_set_p2poem_loglevel(int increase_log_level)
3333 __WDC_LOG_FUNC_START__;
3335 wifi_direct_client_request_s req;
3336 wifi_direct_client_response_s rsp;
3337 int res = WIFI_DIRECT_ERROR_NONE;
3339 if (g_client_info.is_registered == false) {
3340 WDC_LOGE("Client is NOT registered");
3341 __WDC_LOG_FUNC_END__;
3342 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
3345 memset(&req, 0, sizeof(wifi_direct_client_request_s));
3346 memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
3348 req.cmd = WIFI_DIRECT_CMD_SET_OEM_LOGLEVEL;
3349 req.client_id = g_client_info.client_id;
3350 if (increase_log_level == 0)
3351 req.data.int1 = false;
3353 req.data.int1 = true;
3355 res = __wfd_client_send_request(g_client_info.sync_sockfd, &req, &rsp);
3356 if (res != WIFI_DIRECT_ERROR_NONE) {
3357 __WDC_LOG_FUNC_END__;
3361 __WDC_LOG_FUNC_END__;
3362 return WIFI_DIRECT_ERROR_NONE;
3365 int wifi_direct_start_service_discovery(char *mac_address,
3366 wifi_direct_service_type_e type)
3368 #ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
3369 __WDC_LOG_FUNC_START__;
3371 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_SERVICE_DISCOVERY_FEATURE);
3373 GError* error = NULL;
3374 GVariant *reply = NULL;
3375 GVariant *params = NULL;
3376 int ret = WIFI_DIRECT_ERROR_NONE;
3378 if (g_client_info.is_registered == false) {
3379 WDC_LOGE("Client is NOT registered.");
3380 __WDC_LOG_FUNC_END__;
3381 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
3384 if (type >= WIFI_DIRECT_SERVICE_TYPE_ALL &&
3385 type <= WIFI_DIRECT_SERVICE_TYPE_CONTACT_INFO) {
3386 WDC_LOGD("Param service_type [%d]", type);
3388 WDC_LOGE("Invalid Param [type]!");
3389 __WDC_LOG_FUNC_END__;
3390 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
3394 params = g_variant_new("(is)", type, mac_address);
3396 params = g_variant_new("(is)", type, "00:00:00:00:00:00");
3398 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_SERVICE_INTERFACE,
3402 if (error != NULL) {
3403 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
3404 "error [%d: %s]", error->code, error->message);
3405 g_error_free(error);
3406 __WDC_LOG_FUNC_END__;
3407 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
3410 g_variant_get(reply, "(i)", &ret);
3411 g_variant_unref(reply);
3413 WDC_LOGD("%s() return : [%d]", __func__, ret);
3414 __WDC_LOG_FUNC_END__;
3416 #else /* TIZEN_FEATURE_SERVICE_DISCOVERY */
3417 return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
3418 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
3422 int wifi_direct_cancel_service_discovery(char *mac_address,
3423 wifi_direct_service_type_e type)
3425 #ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
3426 __WDC_LOG_FUNC_START__;
3428 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_SERVICE_DISCOVERY_FEATURE);
3430 GError* error = NULL;
3431 GVariant *reply = NULL;
3432 GVariant *params = NULL;
3433 int ret = WIFI_DIRECT_ERROR_NONE;
3435 if (g_client_info.is_registered == false) {
3436 WDC_LOGE("Client is NOT registered.");
3437 __WDC_LOG_FUNC_END__;
3438 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
3441 if (type >= WIFI_DIRECT_SERVICE_TYPE_ALL &&
3442 type <= WIFI_DIRECT_SERVICE_TYPE_CONTACT_INFO) {
3443 WDC_LOGD("Param service_type [%d]", type);
3445 WDC_LOGE("Invalid Param [type]!");
3446 __WDC_LOG_FUNC_END__;
3447 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
3451 params = g_variant_new("(is)", type, mac_address);
3453 params = g_variant_new("(is)", type, "00:00:00:00:00:00");
3455 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_SERVICE_INTERFACE,
3459 if (error != NULL) {
3460 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
3461 "error [%d: %s]", error->code, error->message);
3462 g_error_free(error);
3463 __WDC_LOG_FUNC_END__;
3464 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
3467 g_variant_get(reply, "(i)", &ret);
3468 g_variant_unref(reply);
3470 WDC_LOGD("%s() return : [%d]", __func__, ret);
3471 __WDC_LOG_FUNC_END__;
3473 #else /* TIZEN_FEATURE_SERVICE_DISCOVERY */
3474 return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
3475 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
3478 int wifi_direct_register_service(wifi_direct_service_type_e type, char *info1, char *info2, unsigned int *service_id)
3480 #ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
3481 __WDC_LOG_FUNC_START__;
3483 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_SERVICE_DISCOVERY_FEATURE);
3485 GError* error = NULL;
3486 GVariant *reply = NULL;
3487 GVariant *params = NULL;
3489 int ret = WIFI_DIRECT_ERROR_NONE;
3492 if (g_client_info.is_registered == false) {
3493 WDC_LOGE("Client is NOT registered.");
3494 __WDC_LOG_FUNC_END__;
3495 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
3498 if (!info1 || !info2) {
3499 WDC_LOGE("info1 or info2 is NULL");
3500 __WDC_LOG_FUNC_END__;
3501 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
3504 if (type < WIFI_DIRECT_SERVICE_TYPE_ALL ||
3505 type > WIFI_DIRECT_SERVICE_TYPE_VENDOR) {
3506 WDC_LOGE("Invalid Param [type]!");
3507 __WDC_LOG_FUNC_END__;
3508 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
3512 WDC_LOGE("Invalid Param [service_id]!");
3513 __WDC_LOG_FUNC_END__;
3514 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
3517 WDC_LOGD("Service type [%d]", type);
3519 len = strlen(info1) + strlen(info2) + 2;
3520 WDC_LOGD("info [%s|%s], len [%d]", info1, info2, len);
3522 buf = g_try_malloc0(len);
3524 WDC_LOGE("Failed to allocate memory for buf");
3525 return WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
3528 g_snprintf(buf, len, "%s|%s", info1, info2);
3530 params = g_variant_new("(is)", type, buf);
3531 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_SERVICE_INTERFACE,
3535 if (error != NULL) {
3536 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
3537 "error [%d: %s]", error->code, error->message);
3538 g_error_free(error);
3539 __WDC_LOG_FUNC_END__;
3540 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
3543 g_variant_get(reply, "(ii)", &ret, service_id);
3544 g_variant_unref(reply);
3546 WDC_LOGD("%s() return : [%d]", __func__, ret);
3547 __WDC_LOG_FUNC_END__;
3549 #else /* TIZEN_FEATURE_SERVICE_DISCOVERY */
3550 return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
3551 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
3554 int wifi_direct_deregister_service(unsigned int service_id)
3556 #ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
3557 __WDC_LOG_FUNC_START__;
3559 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_SERVICE_DISCOVERY_FEATURE);
3561 GError* error = NULL;
3562 GVariant *reply = NULL;
3563 GVariant *params = NULL;
3564 int ret = WIFI_DIRECT_ERROR_NONE;
3566 if (g_client_info.is_registered == false) {
3567 WDC_LOGE("Client is NOT registered.");
3568 __WDC_LOG_FUNC_END__;
3569 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
3572 params = g_variant_new("(i)", service_id);
3573 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_SERVICE_INTERFACE,
3577 if (error != NULL) {
3578 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
3579 "error [%d: %s]", error->code, error->message);
3580 g_error_free(error);
3581 __WDC_LOG_FUNC_END__;
3582 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
3585 g_variant_get(reply, "(i)", &ret);
3586 g_variant_unref(reply);
3588 WDC_LOGD("%s() return : [%d]", __func__, ret);
3589 __WDC_LOG_FUNC_END__;
3591 #else /* TIZEN_FEATURE_SERVICE_DISCOVERY */
3592 return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
3593 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
3596 int wifi_direct_init_miracast(bool enable)
3598 __WDC_LOG_FUNC_START__;
3599 int ret = WIFI_DIRECT_ERROR_NONE;
3602 ret = wifi_direct_init_display();
3604 ret = wifi_direct_deinit_display();
3606 __WDC_LOG_FUNC_END__;
3610 int wifi_direct_get_peer_info(char* mac_address, wifi_direct_discovered_peer_info_s** peer_info)
3612 __WDC_LOG_FUNC_START__;
3614 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
3616 GVariant *params = NULL;
3617 GError *error = NULL;
3618 GVariant *reply = NULL;
3619 GVariantIter *iter_peer = NULL;
3620 GVariant *var = NULL;
3622 int ret = WIFI_DIRECT_ERROR_NONE;
3624 if (g_client_info.is_registered == false) {
3625 WDC_LOGE("Client is NOT registered");
3626 __WDC_LOG_FUNC_END__;
3627 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
3631 WDC_LOGE("mac_addr is NULL");
3632 __WDC_LOG_FUNC_END__;
3633 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
3637 WDC_LOGE("peer_info is NULL");
3638 __WDC_LOG_FUNC_END__;
3639 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
3642 params = g_variant_new("(s)", mac_address);
3643 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
3644 "GetPeerInfo", params, &error);
3645 if (error != NULL) {
3646 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
3647 "error [%d: %s]", error->code, error->message);
3648 g_error_free(error);
3649 __WDC_LOG_FUNC_END__;
3650 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
3653 g_variant_get(reply, "(ia{sv})", &ret, &iter_peer);
3654 if (ret != WIFI_DIRECT_ERROR_NONE) {
3655 __WDC_LOG_FUNC_END__;
3656 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
3659 WDC_LOGD("wifi_direct_get_peer() SUCCESS");
3661 wifi_direct_discovered_peer_info_s *peer = NULL;
3663 peer = (wifi_direct_discovered_peer_info_s *) g_try_malloc0(sizeof(wifi_direct_discovered_peer_info_s));
3665 WDC_LOGE("Failed to allocate memory");
3666 __WDC_LOG_FUNC_END__;
3667 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
3670 while (g_variant_iter_loop(iter_peer, "{sv}", &key, &var)) {
3671 if (!g_strcmp0(key, "DeviceName")) {
3672 const char *device_name = NULL;
3674 g_variant_get(var, "&s", &device_name);
3675 peer->device_name = g_strndup(device_name, WIFI_DIRECT_MAX_DEVICE_NAME_LEN+1);
3677 } else if (!g_strcmp0(key, "DeviceAddress")) {
3678 unsigned char mac_address[MACADDR_LEN] = {0, };
3680 wifi_direct_dbus_unpack_ay(mac_address, var, MACADDR_LEN);
3681 peer->mac_address = (char*) g_try_malloc0(MACSTR_LEN);
3682 if (peer->mac_address)
3683 g_snprintf(peer->mac_address, MACSTR_LEN, MACSTR, MAC2STR(mac_address));
3685 } else if (!g_strcmp0(key, "InterfaceAddress")) {
3686 unsigned char intf_address[MACADDR_LEN] = {0, };
3688 wifi_direct_dbus_unpack_ay(intf_address, var, MACADDR_LEN);
3689 peer->interface_address = (char*) g_try_malloc0(MACSTR_LEN);
3690 if (peer->interface_address)
3691 g_snprintf(peer->interface_address, MACSTR_LEN, MACSTR, MAC2STR(intf_address));
3693 } else if (!g_strcmp0(key, "Channel")) {
3694 peer->channel = g_variant_get_uint16(var);
3696 } else if (!g_strcmp0(key, "IsGroupOwner")) {
3697 peer->is_group_owner = g_variant_get_boolean(var);
3699 } else if (!g_strcmp0(key, "IsPersistentGO")) {
3700 peer->is_persistent_group_owner = g_variant_get_boolean(var);
3702 } else if (!g_strcmp0(key, "IsConnected")) {
3703 peer->is_connected = g_variant_get_boolean(var);
3705 } else if (!g_strcmp0(key, "Category")) {
3706 peer->primary_device_type = g_variant_get_uint16(var);
3708 } else if (!g_strcmp0(key, "SubCategory")) {
3709 peer->secondary_device_type = g_variant_get_uint16(var);
3711 } else if (!g_strcmp0(key, "IsWfdDevice")) {
3712 #ifdef TIZEN_FEATURE_WIFI_DISPLAY
3713 peer->is_miracast_device = g_variant_get_boolean(var);
3714 #endif /* TIZEN_FEATURE_WIFI_DISPLAY */
3722 g_variant_unref(reply);
3723 __WDC_LOG_FUNC_END__;
3724 return WIFI_DIRECT_ERROR_NONE;
3727 int wifi_direct_set_passphrase(const char *passphrase)
3729 __WDC_LOG_FUNC_START__;
3731 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
3733 GError* error = NULL;
3734 GVariant *reply = NULL;
3735 GVariant *params = NULL;
3737 if (g_client_info.is_registered == false) {
3738 WDC_LOGE("Client is NOT registered.");
3739 __WDC_LOG_FUNC_END__;
3740 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
3744 WDC_LOGE("NULL Param [passphrase]!");
3745 __WDC_LOG_FUNC_END__;
3746 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
3748 WDC_LOGD("passphrase = [%s]", passphrase);
3750 params = g_variant_new("(s)", passphrase);
3751 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_GROUP_INTERFACE,
3755 if (error != NULL) {
3756 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
3757 "error [%d: %s]", error->code, error->message);
3758 g_error_free(error);
3759 __WDC_LOG_FUNC_END__;
3760 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
3762 WDC_LOGD("%s() SUCCESS", __func__);
3764 g_variant_unref(reply);
3766 __WDC_LOG_FUNC_END__;
3767 return WIFI_DIRECT_ERROR_NONE;
3770 int wifi_direct_get_passphrase(char** passphrase)
3772 __WDC_LOG_FUNC_START__;
3774 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
3776 GError* error = NULL;
3777 GVariant *reply = NULL;
3778 const char *val = NULL;
3779 int ret = WIFI_DIRECT_ERROR_NONE;
3781 if (g_client_info.is_registered == false) {
3782 WDC_LOGE("Client is NOT registered.");
3783 __WDC_LOG_FUNC_END__;
3784 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
3788 WDC_LOGE("NULL Param [passphrase]!");
3789 __WDC_LOG_FUNC_END__;
3790 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
3793 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_GROUP_INTERFACE,
3797 if (error != NULL) {
3798 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
3799 "error [%d: %s]", error->code, error->message);
3800 g_error_free(error);
3801 __WDC_LOG_FUNC_END__;
3802 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
3804 WDC_LOGD("%s() SUCCESS", __func__);
3805 g_variant_get(reply, "(i&s)", &ret, &val);
3806 *passphrase = g_strdup(val);
3807 g_variant_unref(reply);
3809 WDC_LOGD("%s() return : [%d]", __func__, ret);
3810 __WDC_LOG_FUNC_END__;
3814 int wifi_direct_set_autoconnection_peer(char *mac_address)
3816 __WDC_LOG_FUNC_START__;
3818 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
3820 GError* error = NULL;
3821 GVariant *reply = NULL;
3822 GVariant *params = NULL;
3823 int ret = WIFI_DIRECT_ERROR_NONE;
3825 if (g_client_info.is_registered == false) {
3826 WDC_LOGE("Client is NOT registered.");
3827 __WDC_LOG_FUNC_END__;
3828 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
3832 WDC_LOGE("NULL Param!");
3833 __WDC_LOG_FUNC_END__;
3834 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
3837 params = g_variant_new("(s)", mac_address);
3838 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
3839 "SetAutoConnectionPeer",
3842 if (error != NULL) {
3843 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
3844 "error [%d: %s]", error->code, error->message);
3845 g_error_free(error);
3846 __WDC_LOG_FUNC_END__;
3847 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
3850 g_variant_get(reply, "(i)", &ret);
3851 g_variant_unref(reply);
3853 WDC_LOGD("%s() return : [%d]", __func__, ret);
3854 __WDC_LOG_FUNC_END__;
3858 int wifi_direct_init_display(void)
3860 __WDC_LOG_FUNC_START__;
3861 #ifdef TIZEN_FEATURE_WIFI_DISPLAY
3863 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_DISPLAY_FEATURE);
3865 GError* error = NULL;
3866 GVariant *reply = NULL;
3867 int ret = WIFI_DIRECT_ERROR_NONE;
3869 if (g_client_info.is_registered == false) {
3870 WDC_LOGE("Client is NOT registered.");
3871 __WDC_LOG_FUNC_END__;
3872 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
3875 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_DISPLAY_INTERFACE,
3879 if (error != NULL) {
3880 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
3881 "error [%d: %s]", error->code, error->message);
3882 g_error_free(error);
3883 __WDC_LOG_FUNC_END__;
3884 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
3887 g_variant_get(reply, "(i)", &ret);
3888 g_variant_unref(reply);
3890 WDC_LOGD("%s() return : [%d]", __func__, ret);
3891 __WDC_LOG_FUNC_END__;
3893 #else /* TIZEN_FEATURE_WIFI_DISPLAY */
3894 return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
3895 #endif /* TIZEN_FEATURE_WIFI_DISPLAY */
3898 int wifi_direct_deinit_display(void)
3900 __WDC_LOG_FUNC_START__;
3901 #ifdef TIZEN_FEATURE_WIFI_DISPLAY
3903 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_DISPLAY_FEATURE);
3905 GError* error = NULL;
3906 GVariant *reply = NULL;
3907 int ret = WIFI_DIRECT_ERROR_NONE;
3909 if (g_client_info.is_registered == false) {
3910 WDC_LOGE("Client is NOT registered");
3911 __WDC_LOG_FUNC_END__;
3912 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
3915 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_DISPLAY_INTERFACE,
3919 if (error != NULL) {
3920 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
3921 "error [%d: %s]", error->code, error->message);
3922 g_error_free(error);
3923 __WDC_LOG_FUNC_END__;
3924 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
3927 g_variant_get(reply, "(i)", &ret);
3928 g_variant_unref(reply);
3930 WDC_LOGD("%s() return : [%d]", __func__, ret);
3931 __WDC_LOG_FUNC_END__;
3933 #else /* TIZEN_FEATURE_WIFI_DISPLAY */
3934 return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
3935 #endif /* TIZEN_FEATURE_WIFI_DISPLAY */
3938 int wifi_direct_set_display(wifi_direct_display_type_e type, int port, int hdcp)
3940 __WDC_LOG_FUNC_START__;
3941 #ifdef TIZEN_FEATURE_WIFI_DISPLAY
3943 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_DISPLAY_FEATURE);
3945 GError* error = NULL;
3946 GVariant *reply = NULL;
3947 GVariant *params = NULL;
3948 int ret = WIFI_DIRECT_ERROR_NONE;
3950 if (g_client_info.is_registered == false) {
3951 WDC_LOGE("Client is NOT registered");
3952 __WDC_LOG_FUNC_END__;
3953 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
3956 if (type < WIFI_DIRECT_DISPLAY_TYPE_SOURCE ||
3957 type > WIFI_DIRECT_DISPLAY_TYPE_DUAL || port < 0 ||
3959 WDC_LOGE("Invalid paramaeters passed type[%d], port[%d], hdcp[%d]!");
3960 __WDC_LOG_FUNC_END__;
3961 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
3964 params = g_variant_new("(iii)", type, port, hdcp);
3965 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_DISPLAY_INTERFACE,
3969 if (error != NULL) {
3970 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
3971 "error [%d: %s]", error->code, error->message);
3972 g_error_free(error);
3973 __WDC_LOG_FUNC_END__;
3974 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
3977 g_variant_get(reply, "(i)", &ret);
3978 g_variant_unref(reply);
3980 WDC_LOGD("%s() return : [%d]", __func__, ret);
3981 __WDC_LOG_FUNC_END__;
3983 #else /* TIZEN_FEATURE_WIFI_DISPLAY */
3984 return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
3985 #endif /* TIZEN_FEATURE_WIFI_DISPLAY */
3988 int wifi_direct_set_display_availability(bool availability)
3990 __WDC_LOG_FUNC_START__;
3991 #ifdef TIZEN_FEATURE_WIFI_DISPLAY
3993 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_DISPLAY_FEATURE);
3995 GError* error = NULL;
3996 GVariant *reply = NULL;
3997 GVariant *params = NULL;
3998 int ret = WIFI_DIRECT_ERROR_NONE;
4000 if (g_client_info.is_registered == false) {
4001 WDC_LOGE("Client is NOT registered.");
4002 __WDC_LOG_FUNC_END__;
4003 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
4007 params = g_variant_new("(i)", availability);
4008 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_DISPLAY_INTERFACE,
4012 if (error != NULL) {
4013 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
4014 "error [%d: %s]", error->code, error->message);
4015 g_error_free(error);
4016 __WDC_LOG_FUNC_END__;
4017 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
4020 g_variant_get(reply, "(i)", &ret);
4021 g_variant_unref(reply);
4023 WDC_LOGD("%s() return : [%d]", __func__, ret);
4024 __WDC_LOG_FUNC_END__;
4026 #else /* TIZEN_FEATURE_WIFI_DISPLAY */
4027 return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
4028 #endif /* TIZEN_FEATURE_WIFI_DISPLAY */
4031 int wifi_direct_get_peer_display_type(char *mac_address, wifi_direct_display_type_e *type)
4033 __WDC_LOG_FUNC_START__;
4034 #ifdef TIZEN_FEATURE_WIFI_DISPLAY
4036 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_DISPLAY_FEATURE);
4038 GError* error = NULL;
4039 GVariant *reply = NULL;
4040 GVariant *params = NULL;
4042 int ret = WIFI_DIRECT_ERROR_NONE;
4044 if (g_client_info.is_registered == false) {
4045 WDC_LOGE("Client is NOT registered");
4046 __WDC_LOG_FUNC_END__;
4047 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
4050 if (!mac_address || !type) {
4051 WDC_LOGE("NULL Param!");
4052 __WDC_LOG_FUNC_END__;
4053 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
4056 params = g_variant_new("(s)", mac_address);
4057 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_DISPLAY_INTERFACE,
4061 if (error != NULL) {
4062 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
4063 "error [%d: %s]", error->code, error->message);
4064 g_error_free(error);
4065 __WDC_LOG_FUNC_END__;
4066 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
4069 g_variant_get(reply, "(ii)", &ret, &val);
4071 g_variant_unref(reply);
4073 WDC_LOGD("%s() return : [%d]", __func__, ret);
4074 __WDC_LOG_FUNC_END__;
4076 #else /* TIZEN_FEATURE_WIFI_DISPLAY */
4077 return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
4078 #endif /* TIZEN_FEATURE_WIFI_DISPLAY */
4081 int wifi_direct_get_peer_display_availability(char *mac_address, bool *availability)
4083 __WDC_LOG_FUNC_START__;
4084 #ifdef TIZEN_FEATURE_WIFI_DISPLAY
4086 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_DISPLAY_FEATURE);
4088 GError* error = NULL;
4089 GVariant *reply = NULL;
4090 GVariant *params = NULL;
4092 int ret = WIFI_DIRECT_ERROR_NONE;
4094 if (g_client_info.is_registered == false) {
4095 WDC_LOGE("Client is NOT registered");
4096 __WDC_LOG_FUNC_END__;
4097 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
4100 if (!mac_address || !availability) {
4101 WDC_LOGE("NULL Param!");
4102 __WDC_LOG_FUNC_END__;
4103 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
4106 params = g_variant_new("(s)", mac_address);
4107 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_DISPLAY_INTERFACE,
4108 "GetPeerAvailability",
4111 if (error != NULL) {
4112 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
4113 "error [%d: %s]", error->code, error->message);
4114 g_error_free(error);
4115 __WDC_LOG_FUNC_END__;
4116 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
4119 g_variant_get(reply, "(ii)", &ret, &val);
4120 *availability = val;
4121 g_variant_unref(reply);
4123 WDC_LOGD("%s() return : [%d]", __func__, ret);
4124 __WDC_LOG_FUNC_END__;
4126 #else /* TIZEN_FEATURE_WIFI_DISPLAY */
4127 return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
4128 #endif /* TIZEN_FEATURE_WIFI_DISPLAY */
4131 int wifi_direct_get_peer_display_hdcp(char *mac_address, int *hdcp)
4133 __WDC_LOG_FUNC_START__;
4134 #ifdef TIZEN_FEATURE_WIFI_DISPLAY
4136 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_DISPLAY_FEATURE);
4138 GError* error = NULL;
4139 GVariant *reply = NULL;
4140 GVariant *params = NULL;
4142 int ret = WIFI_DIRECT_ERROR_NONE;
4144 if (g_client_info.is_registered == false) {
4145 WDC_LOGE("Client is NOT registered");
4146 __WDC_LOG_FUNC_END__;
4147 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
4150 if (!mac_address || !hdcp) {
4151 WDC_LOGE("NULL Param!");
4152 __WDC_LOG_FUNC_END__;
4153 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
4156 params = g_variant_new("(s)", mac_address);
4157 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_DISPLAY_INTERFACE,
4161 if (error != NULL) {
4162 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
4163 "error [%d: %s]", error->code, error->message);
4164 g_error_free(error);
4165 __WDC_LOG_FUNC_END__;
4166 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
4169 g_variant_get(reply, "(ii)", &ret, &val);
4171 g_variant_unref(reply);
4173 WDC_LOGD("%s() return : [%d]", __func__, ret);
4174 __WDC_LOG_FUNC_END__;
4176 #else /* TIZEN_FEATURE_WIFI_DISPLAY */
4177 return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
4178 #endif /* TIZEN_FEATURE_WIFI_DISPLAY */
4181 int wifi_direct_get_peer_display_port(char *mac_address, int *port)
4183 __WDC_LOG_FUNC_START__;
4184 #ifdef TIZEN_FEATURE_WIFI_DISPLAY
4186 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_DISPLAY_FEATURE);
4188 GError* error = NULL;
4189 GVariant *reply = NULL;
4190 GVariant *params = NULL;
4192 int ret = WIFI_DIRECT_ERROR_NONE;
4194 if (g_client_info.is_registered == false) {
4195 WDC_LOGE("Client is NOT registered");
4196 __WDC_LOG_FUNC_END__;
4197 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
4200 if (!mac_address || !port) {
4201 WDC_LOGE("NULL Param!");
4202 __WDC_LOG_FUNC_END__;
4203 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
4206 params = g_variant_new("(s)", mac_address);
4207 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_DISPLAY_INTERFACE,
4211 if (error != NULL) {
4212 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
4213 "error [%d: %s]", error->code, error->message);
4214 g_error_free(error);
4215 __WDC_LOG_FUNC_END__;
4216 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
4219 g_variant_get(reply, "(ii)", &ret, &val);
4221 g_variant_unref(reply);
4223 WDC_LOGD("%s() return : [%d]", __func__, ret);
4224 __WDC_LOG_FUNC_END__;
4226 #else /* TIZEN_FEATURE_WIFI_DISPLAY */
4227 return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
4228 #endif /* TIZEN_FEATURE_WIFI_DISPLAY */
4231 int wifi_direct_get_peer_display_throughput(char *mac_address, int *throughput)
4233 __WDC_LOG_FUNC_START__;
4234 #ifdef TIZEN_FEATURE_WIFI_DISPLAY
4236 CHECK_FEATURE_SUPPORTED(WIFIDIRECT_DISPLAY_FEATURE);
4238 GError* error = NULL;
4239 GVariant *reply = NULL;
4240 GVariant *params = NULL;
4242 int ret = WIFI_DIRECT_ERROR_NONE;
4244 if (g_client_info.is_registered == false) {
4245 WDC_LOGE("Client is NOT registered");
4246 __WDC_LOG_FUNC_END__;
4247 return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
4250 if (!mac_address || !throughput) {
4251 WDC_LOGE("NULL Param!");
4252 __WDC_LOG_FUNC_END__;
4253 return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
4256 params = g_variant_new("(s)", mac_address);
4257 reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_DISPLAY_INTERFACE,
4258 "GetPeerThroughput",
4261 if (error != NULL) {
4262 WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
4263 "error [%d: %s]", error->code, error->message);
4264 g_error_free(error);
4265 __WDC_LOG_FUNC_END__;
4266 return WIFI_DIRECT_ERROR_OPERATION_FAILED;
4269 g_variant_get(reply, "(ii)", &ret, &val);
4271 g_variant_unref(reply);
4273 WDC_LOGD("%s() return : [%d]", __func__, ret);
4274 __WDC_LOG_FUNC_END__;
4276 #else /* TIZEN_FEATURE_WIFI_DISPLAY */
4277 return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
4278 #endif /* TIZEN_FEATURE_WIFI_DISPLAY */