e_info: code clean up of buffer_flush option 31/172531/2
authorJunSeok, Kim <juns.kim@samsung.com>
Wed, 14 Mar 2018 09:16:28 +0000 (18:16 +0900)
committerJuyeon Lee <juyeonne.lee@samsung.com>
Wed, 14 Mar 2018 09:21:24 +0000 (09:21 +0000)
option change from [0/1] to [on/off/show] and, clean up logic

Change-Id: I6b370bf88801808180bc5998b31449e54e0cfd9e

src/bin/e_info_client.c
src/bin/e_info_server.c

index 0baba527170d7c670b80024fe013cf761097c687..2612bc02b5bbfbf9845bc4e9d66bf1d3a3c14e4c 100644 (file)
@@ -4291,29 +4291,51 @@ finish:
 static void
 _e_info_client_proc_buffer_flush(int argc, char **argv)
 {
-   int buffer_flush_option = -1;
-   if ((argc != 3) || ((argv[2][0] != '0') && (argv[2][0] != '1')))
+   Eina_Bool res = EINA_FALSE;
+
+   EINA_SAFETY_ON_FALSE_GOTO((argc == 3), usage);
+   EINA_SAFETY_ON_FALSE_GOTO((!strcmp(argv[2], "on")) ||
+                             (!strcmp(argv[2], "off")) ||
+                             (!strcmp(argv[2], "show")), usage);
+
+   if (!strcmp(argv[2], "on"))
      {
-        _e_info_client_eldbus_message_with_args("buffer_flush",
-                                                _e_info_client_cb_buffer_flush,
-                                                "i",
-                                                2);
-        goto usage;
+        res = _e_info_client_eldbus_message_with_args("buffer_flush",
+                                                      _e_info_client_cb_buffer_flush,
+                                                      "i",
+                                                      1);
      }
-   else
+   else if (!strcmp(argv[2], "off"))
      {
-        buffer_flush_option = atoi(argv[2]);
-        _e_info_client_eldbus_message_with_args("buffer_flush",
-                                                _e_info_client_cb_buffer_flush,
-                                                "i",
-                                                buffer_flush_option);
-        goto finish;
+        res = _e_info_client_eldbus_message_with_args("buffer_flush",
+                                                      _e_info_client_cb_buffer_flush,
+                                                      "i",
+                                                      0);
+     }
+   else if (!strcmp(argv[2], "show"))
+     {
+        res = _e_info_client_eldbus_message_with_args("buffer_flush",
+                                                      _e_info_client_cb_buffer_flush,
+                                                      "i",
+                                                      2);
      }
+   else
+     goto usage;
+
+   EINA_SAFETY_ON_FALSE_GOTO(res, error);
+
+   return;
+
+error:
+   printf("Error occured while send send message\n\n");
 
 usage:
-   printf("Usage : %s %s [<0:off>/<1:on>]\n", argv[0], argv[1]);
+   printf("Usage : %s %s [on / off / show]\n\n"
+          "\t on : turn on buffer_flush option\n"
+          "\t off : turn off buffer_flush option\n"
+          "\t show : show buffer_flush configuration\n",
+          argv[0], argv[1]);
 
-finish:
    return;
 }
 
@@ -4629,7 +4651,7 @@ static struct
    },
    {
       "buffer_flush",
-      "[0:off / 1:on]",
+      "[on / off / show]",
       "set buffer_flush configure",
       _e_info_client_proc_buffer_flush
    },
index 5de435d6b6dbe4351bad1e1d5b21ea74b0ee8b8d..b071524743f6d4aba9a3fb23f9a8597d9fa8eb77 100644 (file)
@@ -5251,12 +5251,12 @@ _e_info_server_cb_buffer_flush(const Eldbus_Service_Interface *iface EINA_UNUSED
                 {
                    ec->exp_iconify.buffer_flush = msg_from_client;
                 }
-              snprintf(msg_to_client, sizeof(msg_to_client), "Successfully changed!  e_config->buffer_flush : %d",
-                       e_config->use_buffer_flush);
+              snprintf(msg_to_client, sizeof(msg_to_client), "Successfully changed!  e_config->buffer_flush : %s",
+                       e_config->use_buffer_flush ? "on" : "off");
               break;
            default:
-              snprintf(msg_to_client, sizeof(msg_to_client), "Not changed!  e_config->buffer_flush : %d",
-                       e_config->use_buffer_flush);
+              snprintf(msg_to_client, sizeof(msg_to_client), "Current option: e_config->buffer_flush : %s",
+                       e_config->use_buffer_flush ? "on" : "off");
               break;
           }
      }