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.
20 #include "ttd-config.h"
21 #include "ttd-worker-handle.h"
23 static int __config_write(ttd_cmd_data *c_data)
26 unsigned int data_len = 0;
31 ret = ttd_cmd_get_data(c_data, &data, &data_len);
34 switch (ttd_cmd_get_command(c_data))
36 case TTD_CMD_CONFIG_SET_SERVER_URL:
37 ret = ttd_config_write_string("url", "server", (char *)data);
39 _E("Failed to set server url[%s]", (char *)data);
43 case TTD_CMD_CONFIG_SET_APP_ID:
44 ret = ttd_config_write_string("worker", "appid", (char *)data);
46 _E("Failed to set app id[%s]", (char *)data);
59 static int __worker_launch(ttd_cmd_data *c_data)
62 ttd_cmd_type_e cmd_type = TTD_CMD_TYPE_UNKNOWN;
66 cmd_type = ttd_cmd_get_type(c_data);
68 if (cmd_type == TTD_CMD_TYPE_PACKAGE) {
69 ret = ttd_worker_handle_pkgmgr(c_data);
70 } else if (cmd_type == TTD_CMD_TYPE_INFO) {
71 ret = ttd_worker_handle_info(c_data);
73 _E("not supported cmd type - %d", cmd_type);
79 ttd_cmd_launch_func ttd_cmd_get_launch_func(ttd_cmd_type_e type)
81 ttd_cmd_launch_func func = NULL;
84 case TTD_CMD_TYPE_POWER:
86 case TTD_CMD_TYPE_CONFIG:
87 func = __config_write;
89 case TTD_CMD_TYPE_PACKAGE:
90 case TTD_CMD_TYPE_INFO:
91 func = __worker_launch;
93 case TTD_CMD_TYPE_DIAGNOSIS:
95 case TTD_CMD_TYPE_LOCAL:
97 case TTD_CMD_TYPE_UNKNOWN:
98 case TTD_CMD_TYPE_MAX: