static int g_download_id;
+unsigned long long g_received_bytes = 0;
+unsigned long long g_total_content_bytes = 0;
+
typedef struct {
char* language;
int type;
elm_genlist_item_update(g_ad->selected_lang);
}
+static void __progress_cb(int download_id, unsigned long long recevied, void *user_data)
+{
+ g_received_bytes = recevied;
+ dlog_print(DLOG_INFO, LOG_TAG, "download_id(%d), received(%llu), total(%llu)", download_id, g_received_bytes, g_total_content_bytes);
+}
+
static Evas_Object * __genlist_content_get(void *data, Evas_Object *obj, const char *part)
{
item_index_e idx = (item_index_e)data;
static void __progress_popup_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
+ Ecore_Timer* timer = data;
if (NULL != g_ad->progress_popup) {
evas_object_del(g_ad->progress_popup);
g_ad->progress_popup = NULL;
}
+ if (NULL != timer) {
+ ecore_timer_del(timer);
+ timer = NULL;
+ }
+ g_received_bytes = 0;
+ g_total_content_bytes = 0;
return;
}
return;
}
+static Eina_Bool __progress_popup_timer_cb(void* data)
+{
+ double value = 0.0;
+ char percentage[7] = {'\0',};
+ Evas_Object *progressbar = data;
+ value = (double)((long double)g_received_bytes / (long double)g_total_content_bytes);
+ dlog_print(DLOG_ERROR, LOG_TAG, "recevied(%llu), tatal(%llu), value(%lf)", g_received_bytes, g_total_content_bytes, value);
+
+ elm_progressbar_value_set(progressbar, value);
+ snprintf(percentage, 7, "%d/100", (int)(value*100));
+ elm_object_part_text_set(progressbar, "elm.text.top.right", (const char*)percentage);
+
+ return ECORE_CALLBACK_RENEW;
+}
+
static void __show_progress_popup(bool failed, const char* msg)
{
if (NULL != g_ad->progress_popup) {
evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_object_part_text_set(popup, "title,text", _("IDS_DOWNLOADING"));
+ Ecore_Timer *progress_timer = NULL;
+
if (failed) {
if (NULL != msg) {
elm_object_part_text_set(popup, "default", msg);
} else {
Evas_Object *progressbar = elm_progressbar_add(popup);
- elm_object_style_set(progressbar, "process_large");
evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, 0.5);
evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_progressbar_pulse(progressbar, EINA_TRUE);
+
+ elm_progressbar_value_set(progressbar, 0.0);
+ progress_timer = ecore_timer_add(0.5, __progress_popup_timer_cb, progressbar);
+ elm_object_part_text_set(progressbar, "elm.text.top.right", "0/100");
elm_object_content_set(popup, progressbar);
evas_object_show(progressbar);
}
evas_object_smart_callback_add(popup, "block,clicked", NULL, NULL);
- evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, __progress_popup_del_cb, NULL);
+ evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, __progress_popup_del_cb, progress_timer);
eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, __progress_popup_back_cb, NULL);
g_ad->progress_popup = popup;
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_unset_state_changed_cb(download_id);
+ download_unset_progress_cb(download_id);
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_unset_state_changed_cb(download_id);
+ download_unset_progress_cb(download_id);
download_destroy(download_id);
} else if (DOWNLOAD_STATE_CANCELED == state) {
dlog_print(DLOG_INFO, LOG_TAG, "===== Download Canceled");
ecore_main_loop_thread_safe_call_sync(__download_canceled_cb, user_data);
+ download_unset_state_changed_cb(download_id);
+ download_unset_progress_cb(download_id);
download_destroy(download_id);
+ } else if (DOWNLOAD_STATE_DOWNLOADING == state) {
+ dlog_print(DLOG_INFO, LOG_TAG, "===== Downloading");
+ unsigned long long content_size;
+ int ret = download_get_content_size(download_id, &content_size);
+ if (DOWNLOAD_ERROR_NONE != ret) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "[ERROR] Fail to get contents size(%d)", ret);
+ }
+ g_total_content_bytes = content_size;
+ dlog_print(DLOG_INFO, LOG_TAG, "total size of contents(%llu)", g_total_content_bytes);
}
dlog_print(DLOG_INFO, LOG_TAG, "=====");
return;
}
+ ret = download_set_progress_cb(download_id, __progress_cb, NULL);
+ if (DOWNLOAD_ERROR_NONE != ret) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "[ERROR] Fail to set progress cb(%d)", ret);
+ __show_progress_popup(true, NULL);
+ download_unset_state_changed_cb(download_id);
+ download_destroy(download_id);
+ wifi_deinitialize();
+ return;
+ }
+
char url[1024] = {'\0',};
snprintf(url, 1024, "http://download.tizen.org/releases/resources/voice/tts/smt-language-pack/%s.tar.gz", item_data[idx][2]);
ret = download_set_url(download_id, url);
if (DOWNLOAD_ERROR_NONE != ret) {
dlog_print(DLOG_ERROR, LOG_TAG, "[ERROR] Fail to set url(%d)", ret);
__show_progress_popup(true, NULL);
+ download_unset_state_changed_cb(download_id);
+ download_unset_progress_cb(download_id);
download_destroy(download_id);
wifi_deinitialize();
return;
if (DOWNLOAD_ERROR_NONE != ret) {
dlog_print(DLOG_ERROR, LOG_TAG, "[ERROR] Fail to set destination(%d)", ret);
__show_progress_popup(true, NULL);
+ download_unset_state_changed_cb(download_id);
+ download_unset_progress_cb(download_id);
download_destroy(download_id);
wifi_deinitialize();
return;
if (DOWNLOAD_ERROR_NONE != ret) {
dlog_print(DLOG_ERROR, LOG_TAG, "[ERROR] Fail to start(%d)", ret);
__show_progress_popup(true, NULL);
+ download_unset_state_changed_cb(download_id);
+ download_unset_progress_cb(download_id);
download_destroy(download_id);
wifi_deinitialize();
return;