2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Flora License, Version 1.1 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <app_control.h>
22 #define WORKER_PKG_MGR "org.tizen.package-manager-worker"
23 #define WORKER_INFO_SYS "ttsd-worker-system"
24 #define WORKER_INFO_TASK "org.tizen.task-worker"
26 int __worker_launch_info(ttd_cmd_data *c_data)
28 app_control_h ac_h = NULL;
29 int ac_ret = APP_CONTROL_ERROR_NONE;
31 const char *cmd_id = NULL;
32 const char *app_id = NULL;
34 cmd_id = ttd_cmd_get_id(c_data);
36 switch (ttd_cmd_get_command(c_data)) {
37 case TTD_CMD_INFO_GET_SYSINFO:
38 app_id = WORKER_INFO_SYS;
40 case TTD_CMD_INFO_GET_TASKINFO:
41 app_id = WORKER_INFO_TASK;
43 case TTD_CMD_INFO_GET_MAX:
49 ac_ret = app_control_create(&ac_h);
50 if (ac_ret != APP_CONTROL_ERROR_NONE) {
54 app_control_set_operation(ac_h, APP_CONTROL_OPERATION_DEFAULT);
55 app_control_set_app_id(ac_h, app_id);
58 app_control_add_extra_data(ac_h, "id", cmd_id);
60 ac_ret = app_control_send_launch_request(ac_h, NULL, NULL);
61 if (ac_ret != APP_CONTROL_ERROR_NONE) {
68 app_control_destroy(ac_h);
73 int __worker_launch_pkgmgr(ttd_cmd_data *c_data)
75 app_control_h ac_h = NULL;
76 int ac_ret = APP_CONTROL_ERROR_NONE;
77 const char *op = NULL;
79 unsigned int length = 0;
80 const char *cmd_id = NULL;
83 cmd_id = ttd_cmd_get_id(c_data);
85 switch (ttd_cmd_get_command(c_data)) {
86 case TTD_CMD_PACKAGE_INSTALL:
88 ttd_cmd_get_data(c_data, (void *)&extra, &length);
90 case TTD_CMD_PACKAGE_REMOVE:
93 case TTD_CMD_PACKAGE_GET_APP_LIST:
96 case TTD_CMD_PACKAGE_GET_PACKAGE_LIST:
99 case TTD_CMD_PACKAGE_MAX:
101 _E("unknown command - %d", ttd_cmd_get_command(c_data));
105 ac_ret = app_control_create(&ac_h);
106 if (ac_ret != APP_CONTROL_ERROR_NONE) {
110 app_control_set_operation(ac_h, APP_CONTROL_OPERATION_DEFAULT);
111 app_control_set_app_id(ac_h, WORKER_PKG_MGR);
112 app_control_add_extra_data(ac_h, "operation", op);
115 app_control_add_extra_data(ac_h, "id", cmd_id);
118 app_control_add_extra_data(ac_h, "meta", extra);
120 ac_ret = app_control_send_launch_request(ac_h, NULL, NULL);
121 if (ac_ret != APP_CONTROL_ERROR_NONE) {
128 app_control_destroy(ac_h);
136 int ttd_worker_launch(void *cmd_data)
138 ttd_cmd_data *c_data = cmd_data;
140 ttd_cmd_type_e cmd_type = TTD_CMD_TYPE_UNKNOWN;
142 retv_if(!cmd_data, -1);
144 cmd_type = ttd_cmd_get_type(c_data);
146 if (cmd_type == TTD_CMD_TYPE_PACKAGE) {
147 ret = __worker_launch_pkgmgr(c_data);
148 } else if (cmd_type == TTD_CMD_TYPE_INFO) {
149 ret = __worker_launch_info(c_data);
151 _E("not supported cmd type - %d", cmd_type);