4 * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
22 static int launch_app(char *appname,
23 char *key1, char *value1,
24 char *key2, char *value2,
25 char *key3, char *value3)
39 ret = bundle_add(b, key1, value1);
45 ret = bundle_add(b, key2, value2);
51 ret = bundle_add(b, key3, value3);
56 ret = aul_launch_app(appname, b);
58 _E("FAIL: aul_launch_app(%s)", appname);
65 static int launch_app_raw(char *path, char **argv)
70 if (!path || access(path, X_OK) != 0) {
71 _E("Cannot execute (%s)", path);
77 _E("Failed to fork (%d)", errno);
81 if (pid > 0) { /* Parent */
86 ret = execvp(path, argv);
89 _E("Failed execvp(ret: %d, errno: %d)", ret, errno);
93 DBusMessage *launch_app_no_param(E_DBus_Object *obj,
94 DBusMessage *msg, char *appname)
105 _I("launch app (%s)", appname);
107 ret = launch_app(appname, NULL, NULL, NULL, NULL, NULL, NULL);
109 _E("FAIL: launch_app(): %d", ret);
112 reply = dbus_message_new_method_return(msg);
113 dbus_message_iter_init_append(reply, &iter);
114 dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
119 DBusMessage *launch_app_single_param(E_DBus_Object *obj,
120 DBusMessage *msg, char *appname)
123 DBusMessageIter iter;
134 _I("launch app (%s)", appname);
136 dbus_error_init(&err);
138 if (!dbus_message_get_args(msg, &err,
139 DBUS_TYPE_STRING, &key,
140 DBUS_TYPE_STRING, &value,
141 DBUS_TYPE_INVALID)) {
142 _E("there is no message");
147 if (!key || !value) {
148 _E("message is invalid!");
153 ret = launch_app(appname, key, value, NULL, NULL, NULL, NULL);
155 _E("FAIL: launch_app(): %d", ret);
158 reply = dbus_message_new_method_return(msg);
159 dbus_message_iter_init_append(reply, &iter);
160 dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
165 DBusMessage *terminate_app_by_pid(E_DBus_Object *obj, DBusMessage *msg)
168 DBusMessageIter iter;
173 dbus_error_init(&err);
175 if (!dbus_message_get_args(msg, &err,
176 DBUS_TYPE_INT32, &pid,
177 DBUS_TYPE_INVALID)) {
178 _E("there is no message");
184 _E("message is invalid!");
189 ret = aul_terminate_pid(pid);
191 _E("FAIL: aul_terminate_pid(): %d", ret);
194 reply = dbus_message_new_method_return(msg);
195 dbus_message_iter_init_append(reply, &iter);
196 dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
201 DBusMessage *launch_system_servant_app(E_DBus_Object *obj, DBusMessage *msg, char **argv)
203 DBusMessageIter iter;
212 _I("launch app raw(%s)", argv[0]);
214 ret = launch_app_raw(argv[0], argv);
216 _E("FAIL: launch_app_raw: %d", ret);
219 reply = dbus_message_new_method_return(msg);
220 dbus_message_iter_init_append(reply, &iter);
221 dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);