idm_command_h command;
} app_data;
-static void __get_taskinfo(int duration, int period, unsigned long id, idm_result_cb result_cb_func, void *data);
-static Eina_Bool __command_stop(void *data);
+static char *__make_id_request(void)
+{
+ char *request_json = NULL;
+ request_json = g_strdup_printf("{ \"idSeed\" : \"%s\" }", "testSeed");
+ return request_json;
+}
static char *__make_sysinfo_request(void)
{
return file_path;
}
-static void __get_tinfo_result_cb(idm_command_h command, idm_result_e result, idm_reason_e reason, const char *detail, void *data)
+static void __reboot(app_data *ad, idm_result_cb result_cb_func)
{
- 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;
-
- if (id == 1) {
- // 3. 2초 간격으로 20초간 task info 받도록 cmd 실행하고, 10초 뒤에 cmd stop 호출
- __get_taskinfo(20, 2, 2, __get_tinfo_result_cb, ad);
-
- if (ad->timer)
- ecore_timer_del(ad->timer);
- ad->timer = ecore_timer_add(10.0, __command_stop, ad);
- }
- }
-}
-
-static void __sysinfo_result_cb(idm_command_h command, idm_result_e result, idm_reason_e reason, const char *detail, void *data)
-{
- app_data *ad = data;
-
- _D("result : %d, reason : %d, detail : %s", result, reason, detail ? detail : "None");
-
- if (result != IDM_RESULT_RUNNING) {
- idm_command_free(command);
- ad->command = NULL;
-
- // 2. 1초 간격으로 10초간 task info 받도록 cmd 실행
- __get_taskinfo(10, 1, 1, __get_tinfo_result_cb, ad);
- }
-}
-
-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;
-
- _D("result : %d, reason : %d, detail : %s", result, reason, detail ? detail : "None");
-
- if (result != IDM_RESULT_RUNNING) {
- idm_command_free(command);
- ad->command = NULL;
- }
-}
-
-static void __reboot(void *data)
-{
- app_data *ad = data;
idm_command_h command = NULL;
int ret = -1;
return;
}
- ret = idm_command_run(command, __reboot_result_callback, ad);
+ ret = idm_command_run(command, result_cb_func, ad);
if (ret != 0) {
_E("failed to idm_command_run");
idm_command_free(command);
}
}
-static void __get_log_archive_result_cb(idm_command_h command, idm_result_e result, idm_reason_e reason, const char *detail, void *data)
+static void __reboot_result_cb(idm_command_h command, idm_result_e result, idm_reason_e reason, const char *detail, void *data)
{
app_data *ad = data;
- unsigned long id;
- idm_command_get_id(command, &id);
-
- _D("[%d] result : %d, reason : %d, detail : %s", id, result, reason, detail ? detail : "None");
+ _D("result : %d, reason : %d, detail : %s", result, reason, detail ? detail : "None");
if (result != IDM_RESULT_RUNNING) {
idm_command_free(command);
ad->command = NULL;
-
- // 4. reboot cmd 실행
- __reboot(ad);
}
}
-static void __get_log_archive(char *log_path_arr[], const char *archive_file, unsigned long id, idm_result_cb result_cb_func, void *data)
+static void __get_log_archive(char *log_path_arr[], const char *archive_file, unsigned long id, idm_result_cb result_cb_func, app_data *ad)
{
- app_data *ad = data;
idm_command_h command = NULL;
char *request = NULL;
int ret = -1;
}
}
+static void __get_log_archive_result_cb(idm_command_h command, idm_result_e result, idm_reason_e reason, const char *detail, void *data)
+{
+ app_data *ad = 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) {
+ idm_command_free(command);
+ ad->command = NULL;
+
+ __reboot(ad, __reboot_result_cb);
+ }
+}
+
static Eina_Bool __command_stop(void *data)
{
app_data *ad = data;
return ECORE_CALLBACK_CANCEL;
}
-static void __get_taskinfo(int duration, int period, unsigned long id, idm_result_cb result_cb_func, void *data)
+static void __get_taskinfo(int duration, int period, unsigned long id, idm_result_cb result_cb_func, app_data *ad)
{
- app_data *ad = data;
idm_command_h command = NULL;
char *request = NULL;
int ret = -1;
}
}
-static bool service_app_create(void *data)
+static void __get_tinfo_result_cb(idm_command_h command, idm_result_e result, idm_reason_e reason, const char *detail, void *data)
{
- _D("app create");
- return true;
+ 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;
+
+ if (id == 1) {
+ __get_taskinfo(20, 2, 2, __get_tinfo_result_cb, ad);
+
+ if (ad->timer)
+ ecore_timer_del(ad->timer);
+ ad->timer = ecore_timer_add(10.0, __command_stop, ad);
+ }
+ }
}
-static void service_app_terminate(void *data)
+static void __get_sysinfo(idm_result_cb result_cb_func, app_data *ad)
{
- _D("app terminate");
- app_data *ad = data;
+ idm_command_h command = NULL;
+ char *request = NULL;
+ int ret = -1;
- if (ad->command) {
- idm_command_stop(ad->command);
- idm_command_free(ad->command);
+ idm_command_new(&command);
+ ret_if(!command);
+ ad->command = command;
+
+ request = __make_sysinfo_request();
+ if (!request) {
+ _E("failed to make request");
+ idm_command_free(command);
ad->command = NULL;
+ return;
}
- if (ad->timer) {
- ecore_timer_del(ad->timer);
- ad->timer = NULL;
+ ret = idm_command_set_cmd_detail(command, IDM_CMD_GET_SYSINFO, request);
+
+ g_free(request);
+ request = NULL;
+
+ if (ret != 0) {
+ _E("failed to idm_command_set_info_cmd");
+ idm_command_free(command);
+ ad->command = NULL;
+ return;
}
- return;
+ ret = idm_command_run(command, result_cb_func, ad);
+ if (ret != 0) {
+ _E("failed to idm_command_run");
+ idm_command_free(command);
+ ad->command = NULL;
+ return;
+ }
}
-static void __get_sysinfo(idm_result_cb result_cb_func, void *data)
+static void __sysinfo_result_cb(idm_command_h command, idm_result_e result, idm_reason_e reason, const char *detail, void *data)
{
app_data *ad = data;
+
+ _D("result : %d, reason : %d, detail : %s", result, reason, detail ? detail : "None");
+
+ if (result != IDM_RESULT_RUNNING) {
+ idm_command_free(command);
+ ad->command = NULL;
+
+ __get_taskinfo(10, 1, 1, __get_tinfo_result_cb, ad);
+ }
+}
+
+static void __get_id(idm_result_cb result_cb_func, app_data *ad)
+{
idm_command_h command = NULL;
char *request = NULL;
int ret = -1;
ret_if(!command);
ad->command = command;
- request = __make_sysinfo_request();
+ request = __make_id_request();
if (!request) {
_E("failed to make request");
idm_command_free(command);
return;
}
- ret = idm_command_set_cmd_detail(command, IDM_CMD_GET_SYSINFO, request);
+ ret = idm_command_set_cmd_detail(command, IDM_CMD_GET_ID, request);
g_free(request);
request = NULL;
if (ret != 0) {
- _E("failed to idm_command_set_info_cmd");
+ _E("failed to idm_command_set_cmd_detail");
idm_command_free(command);
ad->command = NULL;
return;
}
}
+static void __get_id_result_cb(idm_command_h command, idm_result_e result, idm_reason_e reason, const char *detail, void *data)
+{
+ app_data *ad = 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)
+ return;
+
+ idm_command_free(command);
+ ad->command = NULL;
+ __get_sysinfo(__sysinfo_result_cb, ad);
+}
+
+static bool service_app_create(void *data)
+{
+ _D("app create");
+ return true;
+}
+
+static void service_app_terminate(void *data)
+{
+ _D("app terminate");
+ app_data *ad = data;
+
+ if (ad->command) {
+ idm_command_stop(ad->command);
+ idm_command_free(ad->command);
+ ad->command = NULL;
+ }
+
+ if (ad->timer) {
+ ecore_timer_del(ad->timer);
+ ad->timer = NULL;
+ }
+
+ return;
+}
+
static void service_app_control(app_control_h app_control, void *data)
{
_D("app control");
ad->timer = NULL;
}
- // 1. request로 요청된 system info를 result_cb으로 받기
- __get_sysinfo(__sysinfo_result_cb, ad);
+ __get_id(__get_id_result_cb, ad);
return;
}