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.
26 #include <sys/types.h>
29 #include <bundle_internal.h>
33 #define TMP_FILE "/tmp/.testpkg"
40 static bundle *create_internal_bundle(int start)
44 char arg[1024] = {0, };
48 for (i = start; i < gargc - 1; i++) {
49 if ((i + 1) > gargc - 1)
50 bundle_add(kb, gargv[i], " ");
53 strncpy(arg, gargv[i + 1], 1023);
54 val_array[0] = strtok(arg,",");
57 val_array[j] = strtok(NULL,",");
58 if(val_array[j] == NULL)
63 bundle_add(kb, gargv[i], gargv[i + 1]);
65 bundle_add_str_array(kb, gargv[i],
66 (const char**)val_array, j);
79 kb = create_internal_bundle(2);
81 printf("bundle creation fail\n");
85 pid = aul_open_app(gargv[1]);
87 /* Write the package name to TMP_FILE*/
88 fp = fopen(TMP_FILE, "w");
91 ret = fprintf(fp, "%d", pid);
99 void print_usage(char *progname)
101 printf("[usage] %s <appid>\n",
105 static int __launch_app_dead_handler(int pid, void *data)
107 int listen_pid = (int) data;
109 if(listen_pid == pid)
110 ecore_main_loop_quit();
115 static Eina_Bool run_func(void *data)
118 const char *str = NULL;
119 if ((pid = launch()) > 0) {
120 printf("... successfully launched\n");
122 printf("... launch failed\n");
125 str = bundle_get_val(kb, "__LAUNCH_APP_MODE__");
127 if( str && strcmp(str, "SYNC") == 0 ) {
128 aul_listen_app_dead_signal(__launch_app_dead_handler, (void *)pid);
130 ecore_main_loop_quit();
141 int main(int argc, char **argv)
144 print_usage(argv[0]);
153 ecore_idler_add(run_func, NULL);
155 ecore_main_loop_begin();