diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/ecore/src/lib/ecore_file/ecore_file_download.c | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/libraries/ecore/src/lib/ecore_file/ecore_file_download.c b/libraries/ecore/src/lib/ecore_file/ecore_file_download.c index c5e56bd..971493e 100644 --- a/libraries/ecore/src/lib/ecore_file/ecore_file_download.c +++ b/libraries/ecore/src/lib/ecore_file/ecore_file_download.c | |||
@@ -45,22 +45,27 @@ static Ecore_Event_Handler *_url_complete_handler = NULL; | |||
45 | static Ecore_Event_Handler *_url_progress_download = NULL; | 45 | static Ecore_Event_Handler *_url_progress_download = NULL; |
46 | static Eina_List *_job_list; | 46 | static Eina_List *_job_list; |
47 | 47 | ||
48 | static int download_init = 0; | ||
49 | |||
48 | #endif /* BUILD_ECORE_CON */ | 50 | #endif /* BUILD_ECORE_CON */ |
49 | 51 | ||
50 | int | 52 | int |
51 | ecore_file_download_init(void) | 53 | ecore_file_download_init(void) |
52 | { | 54 | { |
53 | #ifdef BUILD_ECORE_CON | 55 | #ifdef BUILD_ECORE_CON |
54 | if (!ecore_con_url_init()) | 56 | download_init++; |
55 | return 0; | 57 | if (download_init > 1) return 1; |
56 | 58 | if (!ecore_con_init()) return 0; | |
59 | if (!ecore_con_url_init()) | ||
60 | { | ||
61 | ecore_con_shutdown(); | ||
62 | return 0; | ||
63 | } | ||
57 | # ifdef HAVE_CURL | 64 | # ifdef HAVE_CURL |
58 | _url_complete_handler = ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, _ecore_file_download_url_complete_cb, NULL); | 65 | _url_complete_handler = ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, _ecore_file_download_url_complete_cb, NULL); |
59 | _url_progress_download = ecore_event_handler_add(ECORE_CON_EVENT_URL_PROGRESS, _ecore_file_download_url_progress_cb, NULL); | 66 | _url_progress_download = ecore_event_handler_add(ECORE_CON_EVENT_URL_PROGRESS, _ecore_file_download_url_progress_cb, NULL); |
60 | # endif | 67 | # endif |
61 | |||
62 | #endif /* BUILD_ECORE_CON */ | 68 | #endif /* BUILD_ECORE_CON */ |
63 | |||
64 | return 1; | 69 | return 1; |
65 | } | 70 | } |
66 | 71 | ||
@@ -68,15 +73,17 @@ void | |||
68 | ecore_file_download_shutdown(void) | 73 | ecore_file_download_shutdown(void) |
69 | { | 74 | { |
70 | #ifdef BUILD_ECORE_CON | 75 | #ifdef BUILD_ECORE_CON |
71 | if (_url_complete_handler) | 76 | download_init--; |
72 | ecore_event_handler_del(_url_complete_handler); | 77 | if (download_init > 0) return; |
73 | if (_url_progress_download) | 78 | if (_url_complete_handler) |
74 | ecore_event_handler_del(_url_progress_download); | 79 | ecore_event_handler_del(_url_complete_handler); |
75 | _url_complete_handler = NULL; | 80 | if (_url_progress_download) |
76 | _url_progress_download = NULL; | 81 | ecore_event_handler_del(_url_progress_download); |
77 | ecore_file_download_abort_all(); | 82 | _url_complete_handler = NULL; |
78 | 83 | _url_progress_download = NULL; | |
79 | ecore_con_url_shutdown(); | 84 | ecore_file_download_abort_all(); |
85 | ecore_con_url_shutdown(); | ||
86 | ecore_con_shutdown(); | ||
80 | #endif /* BUILD_ECORE_CON */ | 87 | #endif /* BUILD_ECORE_CON */ |
81 | } | 88 | } |
82 | 89 | ||
@@ -362,7 +369,6 @@ _ecore_file_download_curl(const char *url, const char *dst, | |||
362 | } | 369 | } |
363 | 370 | ||
364 | if (headers) eina_hash_foreach(headers, _ecore_file_download_headers_foreach_cb, job); | 371 | if (headers) eina_hash_foreach(headers, _ecore_file_download_headers_foreach_cb, job); |
365 | ecore_con_url_timeout_set(job->url_con, ECORE_FILE_DOWNLOAD_TIMEOUT); | ||
366 | ecore_con_url_fd_set(job->url_con, fileno(job->file)); | 372 | ecore_con_url_fd_set(job->url_con, fileno(job->file)); |
367 | ecore_con_url_data_set(job->url_con, data); | 373 | ecore_con_url_data_set(job->url_con, data); |
368 | 374 | ||