[wifi-direct]: Implement support of following CAPI 20/70420/4
authorManeesh Jain <maneesh.jain@samsung.com>
Thu, 19 May 2016 07:32:22 +0000 (13:02 +0530)
committerManeesh Jain <maneesh.jain@samsung.com>
Fri, 20 May 2016 04:20:43 +0000 (21:20 -0700)
\1. wifi_direct_get_session_timer()
\2.wifi_direct_set_session_timer()

Change-Id: I2aa3b5666337e89e99094f3a97a298a2c7a5929d
Signed-off-by: Maneesh Jain <maneesh.jain@samsung.com>
src/wifi-direct-client-proxy.c
test/test-wifi-direct.c

index d69af43..4caf727 100755 (executable)
@@ -4075,4 +4075,90 @@ int wifi_direct_get_peer_display_throughput(char *mac_address, int *throughput)
        return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
 #endif /* TIZEN_FEATURE_WIFI_DISPLAY */
 }
+
+int wifi_direct_set_session_timer(int seconds)
+{
+       __WDC_LOG_FUNC_START__;
+
+       CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
+
+       GError* error = NULL;
+       GVariant *reply = NULL;
+       GVariant *params = NULL;
+       int ret = WIFI_DIRECT_ERROR_NONE;
+
+       if (g_client_info.is_registered == false) {
+               WDC_LOGE("Client is NOT registered.");
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+       }
+       if (seconds < 0) {
+               WDC_LOGE("Negative Timer Value");
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+       }
+
+       WDC_LOGD("seconds = [%d]", seconds);
+
+       params = g_variant_new("(i)", seconds);
+       reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
+                                         "SetSessionTimer",
+                                         params,
+                                         &error);
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if(ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
+
+       WDC_LOGD("%s() SUCCESS", __func__);
+
+       __WDC_LOG_FUNC_END__;
+       return WIFI_DIRECT_ERROR_NONE;
+
+}
+
+int wifi_direct_get_session_timer(int *seconds)
+{
+       __WDC_LOG_FUNC_START__;
+
+       CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
+
+       GError* error = NULL;
+       GVariant *reply = NULL;
+       int val = 0;
+       int ret = WIFI_DIRECT_ERROR_NONE;
+
+       if (g_client_info.is_registered == false) {
+               WDC_LOGE("Client is NOT registered");
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!seconds) {
+               WDC_LOGE("Invalid Parameter");
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+       }
+
+       reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
+                                         "GetSessionTimer",
+                                         NULL,
+                                         &error);
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
+
+       g_variant_get(reply, "(ii)", &ret, &val);
+       *seconds = val;
+       g_variant_unref(reply);
+
+       WDC_LOGD("Session Timer = [%d] Seconds", *seconds);
+       WDC_LOGD("%s() return : [%d]", __func__, ret);
+       __WDC_LOG_FUNC_END__;
+       return ret;
+}
+
 //LCOV_EXCL_STOP
index a470039..39e8c1e 100755 (executable)
@@ -165,6 +165,8 @@ enum {
        CMD_GET_PEER_DISPLAY_HDCP,
        CMD_GET_PEER_DISPLAY_PORT,
        CMD_GET_PEER_DISPLAY_THROUGHPUT,
+       CMD_GET_SESSION_TIMER,
+       CMD_SET_SESSION_TIMER,
 
        CMD_INVALID = 255,
 };
@@ -272,6 +274,8 @@ menu_str_t g_menu_str[] = {
                { CMD_GET_PEER_DISPLAY_HDCP, "CMD_GET_PEER_DISPLAY_HDCP" },
                { CMD_GET_PEER_DISPLAY_PORT, "CMD_GET_PEER_DISPLAY_PORT" },
                { CMD_GET_PEER_DISPLAY_THROUGHPUT, "CMD_GET_PEER_DISPLAY_THROUGHPUT" },
+               { CMD_GET_SESSION_TIMER, "CMD_GET_SESSION_TIMER" },
+               { CMD_SET_SESSION_TIMER, "CMD_SET_SESSION_TIMER" },
 
                { -1, NULL }, };
 
@@ -2358,7 +2362,26 @@ void process_input(const char *input, gpointer user_data)
                        }
                }
                break;
+       case CMD_GET_SESSION_TIMER:
+               if (ad != NULL) {
+                       int session_timer;
+                       result = wifi_direct_get_session_timer(&session_timer);
+                       printf("wifi_direct_get_session_timer() result=[%d] session_timer[%d]\n",
+                                                       result, session_timer);
+               }
+               break;
+       case CMD_SET_SESSION_TIMER:
+               if (ad != NULL) {
+                       int session_timer;
+                       printf("Input Session Timer \n");
+                       if (scanf(" %2d", &session_timer) < 1)
+                               break;
 
+                       result = wifi_direct_set_session_timer(session_timer);
+                       printf("wifi_direct_set_session_timer() result=[%d] session_timer[%d]\n",
+                                                       result, session_timer);
+               }
+               break;
        case CMD_FULL_MENU:
                usage_full();
                break;