merge with master
[platform/core/api/tethering.git] / test / tethering_test.c
index a79651d..33578c6 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "tethering.h"
 
-#define INPUT_BUF_LEN          32
+#define INPUT_BUF_LEN          128
 #define DISABLE_REASON_TEXT_LEN        64
 #define COMMON_STR_BUF_LEN     32
 
@@ -538,6 +538,7 @@ void print_menu(void)
        g_print("\nTo get Wi-Fi tethering setting, enter 'get wifi_setting'");
        g_print("\nTo set Wi-Fi tethering setting, enter '[set_security_type | set_visibility] [0 | 1]'");
        g_print("\nTo set Wi-Fi tethering passphrase, enter 'set_passphrase [passphrase]'");
+       g_print("\nTo set Wi-Fi tethering SSID, enter 'set_ssid [SSID]'");
        g_print("\nTo quit, enter 'quit'\n> ");
 
        return;
@@ -560,12 +561,17 @@ gboolean input(GIOChannel *channel, GIOCondition condition, gpointer data)
        }
 #else
        GError *err = NULL;
+       GIOStatus ios;
 
-       g_io_channel_read_chars(channel, buf, INPUT_BUF_LEN, &read, &err);
+       ios = g_io_channel_read_chars(channel, buf, INPUT_BUF_LEN, &read, &err);
        if (err != NULL) {
-               g_print("g_io_channel_read is failed : %s\n", err->message);
+               g_print("g_io_channel_read_chars is failed : %s\n",
+                               err->message);
                g_error_free(err);
                return FALSE;
+       } else if (ios != G_IO_STATUS_NORMAL) {
+               g_print("g_io_channel_read_chars is failed : %d\n", ios);
+               return FALSE;
        }
 #endif
 
@@ -627,6 +633,14 @@ gboolean input(GIOChannel *channel, GIOCondition condition, gpointer data)
                goto DONE;
        }
 
+       if (!strcmp(cmd, "set_ssid")) {
+               error = tethering_wifi_set_ssid(th, param);
+               if (error != TETHERING_ERROR_NONE)
+                       g_print("tethering_wifi_set_ssid is failed [0x%X]\n",
+                                       error);
+               goto DONE;
+       }
+
        /* One parameter(type) */
        if (!strcmp(param, "USB"))
                type = TETHERING_TYPE_USB;
@@ -671,7 +685,9 @@ int main(int argc, char *argv[])
                __connection_state_changed_cb, __security_type_changed_cb,
                __ssid_visibility_changed_cb, __passphrase_changed_cb};
 
+#if !GLIB_CHECK_VERSION(2,35,0)
        g_type_init();
+#endif
 
        /* Create tethering handle */
        ret = tethering_create(&th);