fix issue of duplicate args of wrt-launcher
authorShao Changbin <changbin.shao@intel.com>
Mon, 21 Jan 2013 07:15:42 +0000 (02:15 -0500)
committerShao Changbin <changbin.shao@intel.com>
Mon, 21 Jan 2013 07:17:01 +0000 (02:17 -0500)
[Title] fix issue of duplicate args of wrt-launcher
[Issue#] N/A
[Problem] wrt-launcher doesn't handle duplicate arguments, for instance,
         "wrt-launcher -l -l", it will print widget list twice.
[Cause] doesn't check argument before using
[Solution] check whether the argument has already parsed

Change-Id: Ic54605d1d55f79baf69526ce6dffcd784ecec46e

src/wrt-launcher/wrt-launcher.cpp

index 57fae6c..a1c2fa7 100644 (file)
@@ -203,6 +203,8 @@ int main(int argc, char* argv[])
         char op = '\0';
         bool isDebugMode = false;
         struct sigaction sigact;
+        bool dispHelp = false;
+        bool dispList = false;
 
         service_h serviceHandle = NULL;
         int ret = SERVICE_ERROR_NONE;
@@ -250,14 +252,20 @@ int main(int argc, char* argv[])
 
             switch (next_opt) {
             case 'h':
-                print_help(stdout, 0);
+                if(!dispHelp){
+                    print_help(stdout, 0);
+                    dispHelp = true;
+                 }
                 break;
 
             case 'l':
+                if(dispList)
+                    break;
                 if (!display_widget_info()) {
                     printf("Fail to display the list of installed widgets");
                     return -1;
                 }
+                dispList = true;
                 break;
 
             case 's':