4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
25 #include <sys/types.h>
31 #define TMP_FILE "/tmp/.testpkg"
38 static bundle *create_internal_bundle(int start)
42 char arg[1024] = {0, };
46 for (i = start; i < gargc - 1; i++) {
47 if ((i + 1) > gargc - 1)
48 bundle_add(kb, gargv[i], " ");
51 strncpy(arg, gargv[i + 1], 1023);
52 val_array[0] = strtok(arg,",");
55 val_array[j] = strtok(NULL,",");
56 if(val_array[j] == NULL)
61 bundle_add(kb, gargv[i], gargv[i + 1]);
63 bundle_add_str_array(kb, gargv[i],
64 (const char**)val_array, j);
77 kb = create_internal_bundle(2);
79 printf("bundle creation fail\n");
83 pid = aul_launch_app(gargv[1], kb);
85 /* Write the package name to TMP_FILE*/
86 /* fp = fopen(TMP_FILE, "w");
89 ret = fprintf(fp, "%d", pid);
97 void print_usage(char *progname)
99 printf("[usage] %s <pkgname> <key1> <val1> <key2> <val2> ...\n",
103 static int __launch_app_dead_handler(int pid, void *data)
105 int listen_pid = (int) data;
107 if(listen_pid == pid)
108 ecore_main_loop_quit();
113 static Eina_Bool run_func(void *data)
118 if ((pid = launch()) > 0) {
119 printf("... successfully launched\n");
120 str = bundle_get_val(kb, "__LAUNCH_APP_MODE__");
122 if( str && strcmp(str, "SYNC") == 0 ) {
123 aul_listen_app_dead_signal(__launch_app_dead_handler, pid);
125 ecore_main_loop_quit();
128 printf("... launch failed\n");
129 ecore_main_loop_quit();
141 int main(int argc, char **argv)
144 print_usage(argv[0]);
153 aul_launch_init(NULL, NULL);
155 ecore_idler_add(run_func, NULL);
157 ecore_main_loop_begin();