Add a new command for checking widget running in wrt-launcher.
authorTaejeong Lee <taejeong.lee@samsung.com>
Fri, 18 Jan 2013 08:03:56 +0000 (17:03 +0900)
committerTaejeong Lee <taejeong.lee@samsung.com>
Fri, 18 Jan 2013 08:42:01 +0000 (17:42 +0900)
 * "-r" or "--is-running" option checks whether widget is running.

[Issue#] N/A
[Problem] There was no way to checking whether widget is terminated normally from SDK.
[Cause] N/A
[Solution] Add a new command for checking widget running in wrt-launcher.

Change-Id: Icb5d700024cd019643e48cf4d174a2d6ba0ff379

src/wrt-launcher/wrt-launcher.cpp

index 8322190..57fae6c 100644 (file)
@@ -177,6 +177,8 @@ static void print_help(FILE *stream, int /*exit_code*/)
             "   -l                       --list              Display installed widgets list\n"
             "   -s [GUID]or[PkgName]     --start             Launch widget with package name or GUID\n"
             "   -k [GUID]or[PkgName]     --kill              Kill widget with package name or GUID\n"
+            "   -r [GUID]or[PkgName]     --is-running        Check whether widget is running by package name or GUID,\n"
+            "                                                If widget is running, 0(zero) will be returned.\n"
             "   -d                       --debug             Activate debug mode\n"
             "   -t [second]              --timeout           Set timeout of response from widget in debug mode\n"
             "   -v [1]or[0]              --developer-mode    Set developermode\n"
@@ -212,6 +214,7 @@ int main(int argc, char* argv[])
             {"list", no_argument, 0, 'l'},
             {"start", required_argument, 0, 's'},
             {"kill", required_argument, 0, 'k'},
+            {"is-running", required_argument, 0, 'r'},
             {"debug", no_argument, 0, 'd'},
             {"timeout", required_argument, 0, 't'},
             {"developer-mode", required_argument, 0, 'v'},
@@ -241,7 +244,7 @@ int main(int argc, char* argv[])
         do {
             next_opt = getopt_long(argc,
                                    argv,
-                                   "hls:k:dt:v:c:i:m:",
+                                   "hls:k:r:dt:v:c:i:m:",
                                    long_options,
                                    &opt_idx);
 
@@ -259,6 +262,7 @@ int main(int argc, char* argv[])
 
             case 's':
             case 'k':
+            case 'r':
                 strncpy(temp_arg, optarg, strlen(optarg));
                 op = next_opt;
                 break;
@@ -339,7 +343,7 @@ int main(int argc, char* argv[])
             }
         } while (next_opt != -1);
 
-        if ((op == 's') || (op == 'k')) {
+        if ((op == 's') || (op == 'k') || (op =='r')) {
             std::string temp;
 
             if (NULL == g_dbConnection.get()) {
@@ -485,6 +489,23 @@ int main(int argc, char* argv[])
                 printf("result: %s\n", "App isn't running");
                 return 0;
             }
+        } else if (op == 'r') {
+            bool isRunning = false;
+
+            ret = app_manager_is_running(pkgname, &isRunning);
+
+            if (APP_MANAGER_ERROR_NONE != ret) {
+                printf("result: %s\n", "failed");
+                return -1;
+            }
+
+            if (true == isRunning) {
+                printf("result: %s\n", "running");
+                return 0;
+            } else {
+                printf("result: %s\n", "not running");
+                return -1;
+            }
         }
 
         return 0;