#endif
/**
+ * @brief Called when you get the supported channels repeatedly.
+ * @since_tizen 6.0
+ * @param[in] channel The supported channel
+ * @param[in] user_data The user data passed from the request function
+ * @return @c true to continue with the next iteration of the loop, \n
+ * @c false to break out of the loop
+ * @pre wifi_direct_foreach_supported_channel() will invoke this callback.
+ * @see wifi_direct_foreach_supported_channel()
+ */
+typedef bool(*wifi_direct_supported_channel_cb)(unsigned int channel, void *user_data);
+
+/**
* @brief Rejects the connection request from other device now in progress.
* @since_tizen 2.3
* @privlevel public
*/
int wifi_direct_accept_connection(char *mac_address);
+/**
+ * @brief Gets the list of supported channels
+ * @since_tizen 6.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/wifidirect
+ * @param[in] callback The callback function which is invoked at success
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #WIFI_DIRECT_ERROR_NONE Successful
+ * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed
+ * @retval #WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted
+ * @retval #WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported
+ * @retval #WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
+ * @pre Wi-Fi Direct service must be activated by wifi_direct_activate().
+ * @see wifi_direct_activate()
+ * @see wifi_direct_supported_channel_cb()
+ *
+ *
+ * Here is an example of the usage:
+ * @code
+ * #include <stdio.h>
+ * #include <wifi-direct.h>
+ * #include <wifi-direct-internal.h>
+ *
+ *
+ * bool callback(unsigned int channel, void *user_data)
+ * {
+ * printf("Channel [%u] is supported\n", channel);
+ * return true;
+ * }
+ *
+ * int function(void)
+ * {
+ * int ret;
+ *
+ * ret = wifi_direct_foreach_supported_channel(callback, NULL);
+ *
+ * if (ret != WIFI_DIRECT_ERROR_NONE) {
+ * printf("Failed to get supported channels\n");
+ * return -1;
+ * }
+ *
+ * return 0;
+ * }
+ *
+ * int main()
+ * {
+ * // Initialize Wi-Fi Direct.
+ * // Activate Wi-Fi Direct.
+ *
+ * function();
+ *
+ * // App must clean up Wi-Fi Direct before exiting
+ *
+ * // Deactivate Wi-Fi Direct
+ * // Deinitialize Wi-Fi Direct
+ * return 0;
+ * }
+ * @endcode
+ */
+int wifi_direct_foreach_supported_channel(wifi_direct_supported_channel_cb callback, void *user_data);
#ifdef __cplusplus
}
return WIFI_DIRECT_ERROR_NONE;
}
+int wifi_direct_foreach_supported_channel(wifi_direct_supported_channel_cb cb, void* user_data)
+{
+ __WDC_LOG_FUNC_START__;
+
+ CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
+
+ GError* error = NULL;
+ GVariant *reply = NULL;
+ GVariantIter *iter = NULL;
+ int ret = WIFI_DIRECT_ERROR_NONE;
+ unsigned int channel;
+
+ if (g_client_info.is_registered == false) {
+ WDC_LOGE("Client is NOT registered");
+ __WDC_LOG_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+ }
+
+ if (!cb) {
+ WDC_LOGE("NULL Param [callback]!");
+ __WDC_LOG_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ }
+
+ reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
+ "GetSupportedChannels",
+ NULL,
+ &error);
+
+ ret = __net_wifidirect_gerror_to_enum(error);
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ return ret;
+
+ g_variant_get(reply, "(iau)", &ret, &iter);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ __WDC_LOG_FUNC_END__;
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
+
+ WDC_LOGD("wifi_direct_foreach_supported_channel() SUCCESS");
+
+ while (g_variant_iter_loop(iter, "u", &channel)) {
+ if (!cb(channel, user_data))
+ break;
+ }
+ g_variant_iter_free(iter);
+ g_variant_unref(reply);
+
+ WDC_LOGD("%s() return : [%d]", __func__, ret);
+ __WDC_LOG_FUNC_END__;
+ return ret;
+}
+
EXPORT_API int wifi_direct_activate_pushbutton(void)
{
__WDC_LOG_FUNC_START__;