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 "ttd-worker-system"
24 #define WORKER_INFO_TASK "org.tizen.task-worker"
26 int ttd_worker_handle_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);
37 switch (ttd_cmd_get_command(c_data)) {
38 case TTD_CMD_INFO_GET_SYSINFO:
39 app_id = WORKER_INFO_SYS;
41 case TTD_CMD_INFO_GET_TASKINFO:
42 app_id = WORKER_INFO_TASK;
44 case TTD_CMD_INFO_GET_MAX:
50 ac_ret = app_control_create(&ac_h);
51 if (ac_ret != APP_CONTROL_ERROR_NONE) {
55 app_control_set_operation(ac_h, APP_CONTROL_OPERATION_DEFAULT);
56 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 ttd_worker_handle_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);
86 switch (ttd_cmd_get_command(c_data)) {
87 case TTD_CMD_PACKAGE_INSTALL:
89 ttd_cmd_get_data(c_data, (void *)&extra, &length);
91 case TTD_CMD_PACKAGE_REMOVE:
94 case TTD_CMD_PACKAGE_GET_APP_LIST:
97 case TTD_CMD_PACKAGE_GET_PACKAGE_LIST:
100 case TTD_CMD_PACKAGE_MAX:
102 _E("unknown command - %d", ttd_cmd_get_command(c_data));
106 ac_ret = app_control_create(&ac_h);
107 if (ac_ret != APP_CONTROL_ERROR_NONE) {
111 app_control_set_operation(ac_h, APP_CONTROL_OPERATION_DEFAULT);
112 app_control_set_app_id(ac_h, WORKER_PKG_MGR);
113 app_control_add_extra_data(ac_h, "operation", op);
114 app_control_add_extra_data(ac_h, "id", cmd_id);
117 app_control_add_extra_data(ac_h, "meta", extra);
119 ac_ret = app_control_send_launch_request(ac_h, NULL, NULL);
120 if (ac_ret != APP_CONTROL_ERROR_NONE) {
127 app_control_destroy(ac_h);