From: Kwangyoun Kim Date: Wed, 22 Jun 2016 08:44:55 +0000 (+0900) Subject: Add download api error handling X-Git-Tag: submit/tizen_mobile/20160621.085622^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=904fc776b95180115c6d82d708f1bb514b9aa7ee;p=platform%2Fcore%2Fuifw%2Flibttssmt.git Add download api error handling Change-Id: I3ef9a1a49b01062c6bf550a04a5548d4873a551f --- diff --git a/setting-app/src/ttssmt_setting_main.c b/setting-app/src/ttssmt_setting_main.c index a4556b3..f9f3aea 100644 --- a/setting-app/src/ttssmt_setting_main.c +++ b/setting-app/src/ttssmt_setting_main.c @@ -306,7 +306,7 @@ static bool __installed_lang(int idx) snprintf(filepath, 1024, "%s/%s", data_path, item_data[idx][1]); if (EN_US_FEMALE == idx || KO_KR_FEMALE == idx || DE_DE_FEMALE == idx || FR_FR_FEMALE == idx || IT_IT_FEMALE == idx || ES_ES_FEMALE == idx) { - return true; + return true; } else { if (0 != access(filepath, F_OK)) { return false; @@ -492,9 +492,11 @@ static void __download_state_changed_cb(int download_id, download_state_e state, if (DOWNLOAD_STATE_COMPLETED == state) { dlog_print(DLOG_INFO, LOG_TAG, "===== Download Completed"); ecore_main_loop_thread_safe_call_sync(__download_completed_cb, user_data); + download_destroy(download_id); } else if (DOWNLOAD_STATE_FAILED == state) { dlog_print(DLOG_INFO, LOG_TAG, "===== Download Failed"); ecore_main_loop_thread_safe_call_sync(__download_failed_cb, user_data); + download_destroy(download_id); } dlog_print(DLOG_INFO, LOG_TAG, "====="); @@ -509,7 +511,7 @@ static void __lang_item_clicked_cb(void *data, Evas_Object *obj, void *event_inf intptr_t pidx = (intptr_t)data; int idx = (int)pidx; dlog_print(DLOG_INFO, LOG_TAG, "[%d] item clicked", idx); - + /* download */ if (false == __installed_lang(idx)) { dlog_print(DLOG_INFO, LOG_TAG, ">> Download <<"); @@ -519,10 +521,15 @@ static void __lang_item_clicked_cb(void *data, Evas_Object *obj, void *event_inf error = download_create(&download_id); if (DOWNLOAD_ERROR_NONE != error) { dlog_print(DLOG_ERROR, LOG_TAG, "[ERROR] create"); + __show_progress_popup(true); + return; } error = download_set_state_changed_cb(download_id, __download_state_changed_cb, (void *)pidx); if (DOWNLOAD_ERROR_NONE != error) { dlog_print(DLOG_ERROR, LOG_TAG, "[ERROR] set state cb"); + __show_progress_popup(true); + download_destroy(download_id); + return; } char url[1024] = {'\0',}; @@ -530,6 +537,9 @@ static void __lang_item_clicked_cb(void *data, Evas_Object *obj, void *event_inf error = download_set_url(download_id, url); if (DOWNLOAD_ERROR_NONE != error) { dlog_print(DLOG_ERROR, LOG_TAG, "[ERROR] set url"); + __show_progress_popup(true); + download_destroy(download_id); + return; } //char *data_path = app_get_data_path(); @@ -537,14 +547,20 @@ static void __lang_item_clicked_cb(void *data, Evas_Object *obj, void *event_inf error = download_set_destination(download_id, data_path); if (DOWNLOAD_ERROR_NONE != error) { dlog_print(DLOG_ERROR, LOG_TAG, "[ERROR] set destination"); + __show_progress_popup(true); + download_destroy(download_id); + return; } //free(data_path); error = download_start(download_id); if (DOWNLOAD_ERROR_NONE != error) { dlog_print(DLOG_ERROR, LOG_TAG, "[ERROR] start"); + __show_progress_popup(true); + download_destroy(download_id); + return; } - + __show_progress_popup(false); dlog_print(DLOG_INFO, LOG_TAG, "<< End >>"); @@ -582,7 +598,7 @@ static void create_contents(appdata_s *ad) ad->genlist = elm_genlist_add(ad->naviframe); elm_genlist_mode_set(ad->genlist, ELM_LIST_COMPRESS); elm_genlist_homogeneous_set(ad->genlist, EINA_TRUE); - + g_itc_group_title = elm_genlist_item_class_new(); if (NULL == g_itc_group_title) { dlog_print(DLOG_ERROR, LOG_TAG, "Fail to item class new"); @@ -673,9 +689,9 @@ static void create_base_gui(appdata_s *ad) static bool app_create(void *data) { /* Hook to take necessary actions before main event loop starts - Initialize UI resources and application's data - If this function returns true, the main loop of application starts - If this function returns false, the application is terminated */ + Initialize UI resources and application's data + If this function returns true, the main loop of application starts + If this function returns false, the application is terminated */ appdata_s *ad = data; create_base_gui(ad);