static void __get_taskinfo(int duration, int period, unsigned long id, idm_result_cb result_cb_func, void *data);
-static char *__make_request(int duration, int period)
+static char *__make_taskinfo_request(int duration, int period)
{
char *request_json = NULL;
return request_json;
}
+static char *__make_log_archive_request(const char *log_path_arr[], const char *archive_file)
+{
+ char *request_json = NULL;
+ char *log_path_str = NULL;
+
+ log_path_str = g_strjoinv("\", \"", log_path_arr);
+
+ request_json = g_strdup_printf("{ \"logPath\" : [ \"%s\" ], \"archiveFile\" : \"%s\" }", log_path_str, archive_file);
+
+ return request_json;
+}
+
+// static void __make_temp_logs()
+// Make temporary log directories and files using app_get_data_path() API
+
static void __reboot_result_callback(idm_command_h command, idm_result_e result, idm_reason_e reason, const char *detail, void *data)
{
app_data *ad = data;
}
}
+static void __get_log_archive_result_cb(idm_command_h command, idm_result_e result, idm_reason_e reason, const char *detail, void *data)
+{
+ unsigned long id;
+ idm_command_get_id(command, &id);
+
+ _D("[%d] result : %d, reason : %d, detail : %s", id, result, reason, detail ? detail : "None");
+
+ if (result != IDM_RESULT_RUNNING) {
+ app_data *ad = data;
+ idm_command_free(command);
+ ad->command = NULL;
+ }
+}
+
+static void __get_log_archive(const char *log_path_arr[], const char *archive_file, unsigned long id, idm_result_cb result_cb_func, void *data)
+{
+ app_data *ad = data;
+ idm_command_h command = NULL;
+ char *request = NULL;
+ int ret = -1;
+
+ idm_command_new(&command);
+ ret_if(!command);
+
+ idm_command_set_id(command, id);
+ ad->command = command;
+
+ request = __make_log_archive_request(log_path_arr, archive_file);
+ if (!request) {
+ _E("failed to make request");
+ idm_command_free(command);
+ ad->command = NULL;
+ return;
+ }
+
+ ret = idm_command_set_diagnosis_cmd(command, IDM_CMD_DIAGNOSIS_GET_LOG, request);
+
+ g_free(request);
+ request = NULL;
+
+ if (ret != 0) {
+ _E("failed to idm_command_set_info_cmd");
+ idm_command_stop(ad->command);
+ idm_command_free(command);
+ ad->command = NULL;
+ return;
+ }
+
+ ret = idm_command_run(command, result_cb_func, ad);
+ if (ret != 0) {
+ _E("failed to idm_command_run");
+ idm_command_stop(ad->command);
+ idm_command_free(command);
+ ad->command = NULL;
+ return;
+ }
+}
+
+static void __get_log_archive_result_cb(idm_command_h command, idm_result_e result, idm_reason_e reason, const char *detail, void *data)
+{
+ unsigned long id;
+ idm_command_get_id(command, &id);
+
+ _D("[%d] result : %d, reason : %d, detail : %s", id, result, reason, detail ? detail : "None");
+
+ if (result != IDM_RESULT_RUNNING) {
+ app_data *ad = data;
+ idm_command_free(command);
+ ad->command = NULL;
+ }
+}
+
+static void __get_log_archive(const char *log_path_arr[], const char *archive_file, unsigned long id, idm_result_cb result_cb_func, void *data)
+{
+ app_data *ad = data;
+ idm_command_h command = NULL;
+ char *request = NULL;
+ int ret = -1;
+
+ idm_command_new(&command);
+ ret_if(!command);
+
+ idm_command_set_id(command, id);
+ ad->command = command;
+
+ request = __make_log_archive_request(log_path_arr, archive_file);
+ if (!request) {
+ _E("failed to make request");
+ idm_command_free(command);
+ ad->command = NULL;
+ return;
+ }
+
+ ret = idm_command_set_diagnosis_cmd(command, IDM_CMD_DIAGNOSIS_GET_LOG, request);
+
+ g_free(request);
+ request = NULL;
+
+ if (ret != 0) {
+ _E("failed to idm_command_set_info_cmd");
+ idm_command_stop(ad->command);
+ idm_command_free(command);
+ ad->command = NULL;
+ return;
+ }
+
+ ret = idm_command_run(command, result_cb_func, ad);
+ if (ret != 0) {
+ _E("failed to idm_command_run");
+ idm_command_stop(ad->command);
+ idm_command_free(command);
+ ad->command = NULL;
+ return;
+ }
+}
+
static Eina_Bool __command_stop(void *data)
{
app_data *ad = data;
+ char log_path_arr[][2] = {
+ "/TBD/",
+ "/TBD/",
+ NULL
+ }; // The last item of this array must be NULL
+ char *archive_file = "/TBD/log.zip"
if (ad->command) {
idm_command_stop(ad->command);
}
ad->timer = NULL;
+ // Get log archive
+ __get_log_archive(log_path_arr, archive_file, 3, __get_log_archive_result_cb, ad);
+
// 3. reboot cmd 실행
__reboot(ad);
idm_command_set_id(command, id);
ad->command = command;
- request = __make_request(duration, period);
+ request = __make_taskinfo_request(duration, period);
if (!request) {
_E("failed to make request");
idm_command_free(command);