summaryrefslogtreecommitdiff
path: root/src/lib/ecore_file/ecore_file_download.c
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2012-12-03 08:35:53 +0000
committerVincent Torri <vincent.torri@gmail.com>2012-12-03 08:35:53 +0000
commitdc0c272d2f87b9e5eefac1c4c3e9cbf97fd5a07d (patch)
tree84414b2acedbfdcab18d072722b13c02c5ebf87f /src/lib/ecore_file/ecore_file_download.c
parenta154c405e1a2a96ee672bb6ccf457b5f9824b933 (diff)
ecore: remove useless ECORE_HAVE_EET, remove old XCB code and remove BUILD_ECORE_CON checks as ecore_con is always compiled anyway
SVN revision: 80024
Diffstat (limited to 'src/lib/ecore_file/ecore_file_download.c')
-rw-r--r--src/lib/ecore_file/ecore_file_download.c52
1 files changed, 9 insertions, 43 deletions
diff --git a/src/lib/ecore_file/ecore_file_download.c b/src/lib/ecore_file/ecore_file_download.c
index 98d4a1f972..028276407c 100644
--- a/src/lib/ecore_file/ecore_file_download.c
+++ b/src/lib/ecore_file/ecore_file_download.c
@@ -6,14 +6,10 @@
6#include <stdio.h> 6#include <stdio.h>
7#include <string.h> 7#include <string.h>
8 8
9#ifdef BUILD_ECORE_CON
10# include "Ecore_Con.h" 9# include "Ecore_Con.h"
11#endif
12 10
13#include "ecore_file_private.h" 11#include "ecore_file_private.h"
14 12
15#ifdef BUILD_ECORE_CON
16
17#define ECORE_MAGIC_FILE_DOWNLOAD_JOB 0xf7427cb8 13#define ECORE_MAGIC_FILE_DOWNLOAD_JOB 0xf7427cb8
18#define ECORE_FILE_DOWNLOAD_TIMEOUT 30 14#define ECORE_FILE_DOWNLOAD_TIMEOUT 30
19 15
@@ -47,12 +43,9 @@ static Eina_List *_job_list;
47 43
48static int download_init = 0; 44static int download_init = 0;
49 45
50#endif /* BUILD_ECORE_CON */
51
52int 46int
53ecore_file_download_init(void) 47ecore_file_download_init(void)
54{ 48{
55#ifdef BUILD_ECORE_CON
56 download_init++; 49 download_init++;
57 if (download_init > 1) return 1; 50 if (download_init > 1) return 1;
58 if (!ecore_con_init()) return 0; 51 if (!ecore_con_init()) return 0;
@@ -61,18 +54,16 @@ ecore_file_download_init(void)
61 ecore_con_shutdown(); 54 ecore_con_shutdown();
62 return 0; 55 return 0;
63 } 56 }
64# ifdef HAVE_CURL 57#ifdef HAVE_CURL
65 _url_complete_handler = ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, _ecore_file_download_url_complete_cb, NULL); 58 _url_complete_handler = ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, _ecore_file_download_url_complete_cb, NULL);
66 _url_progress_download = ecore_event_handler_add(ECORE_CON_EVENT_URL_PROGRESS, _ecore_file_download_url_progress_cb, NULL); 59 _url_progress_download = ecore_event_handler_add(ECORE_CON_EVENT_URL_PROGRESS, _ecore_file_download_url_progress_cb, NULL);
67# endif 60#endif
68#endif /* BUILD_ECORE_CON */
69 return 1; 61 return 1;
70} 62}
71 63
72void 64void
73ecore_file_download_shutdown(void) 65ecore_file_download_shutdown(void)
74{ 66{
75#ifdef BUILD_ECORE_CON
76 download_init--; 67 download_init--;
77 if (download_init > 0) return; 68 if (download_init > 0) return;
78 if (_url_complete_handler) 69 if (_url_complete_handler)
@@ -84,10 +75,8 @@ ecore_file_download_shutdown(void)
84 ecore_file_download_abort_all(); 75 ecore_file_download_abort_all();
85 ecore_con_url_shutdown(); 76 ecore_con_url_shutdown();
86 ecore_con_shutdown(); 77 ecore_con_shutdown();
87#endif /* BUILD_ECORE_CON */
88} 78}
89 79
90#ifdef BUILD_ECORE_CON
91# ifdef HAVE_CURL 80# ifdef HAVE_CURL
92static Eina_Bool 81static Eina_Bool
93_ecore_file_download_headers_foreach_cb(const Eina_Hash *hash EINA_UNUSED, const void *key, void *data, void *fdata) 82_ecore_file_download_headers_foreach_cb(const Eina_Hash *hash EINA_UNUSED, const void *key, void *data, void *fdata)
@@ -98,7 +87,6 @@ _ecore_file_download_headers_foreach_cb(const Eina_Hash *hash EINA_UNUSED, const
98 return EINA_TRUE; 87 return EINA_TRUE;
99} 88}
100# endif 89# endif
101#endif
102 90
103static Eina_Bool 91static Eina_Bool
104_ecore_file_download(const char *url, 92_ecore_file_download(const char *url,
@@ -109,7 +97,6 @@ _ecore_file_download(const char *url,
109 Ecore_File_Download_Job **job_ret, 97 Ecore_File_Download_Job **job_ret,
110 Eina_Hash *headers) 98 Eina_Hash *headers)
111{ 99{
112#ifdef BUILD_ECORE_CON
113 if (!url) 100 if (!url)
114 { 101 {
115 CRIT("Download URL is null"); 102 CRIT("Download URL is null");
@@ -142,7 +129,7 @@ _ecore_file_download(const char *url,
142 url = strchr(url, '/'); 129 url = strchr(url, '/');
143 return ecore_file_cp(url, dst); 130 return ecore_file_cp(url, dst);
144 } 131 }
145# ifdef HAVE_CURL 132#ifdef HAVE_CURL
146 else if ((!strncmp(url, "http://", 7)) || (!strncmp(url, "https://", 8)) || 133 else if ((!strncmp(url, "http://", 7)) || (!strncmp(url, "https://", 8)) ||
147 (!strncmp(url, "ftp://", 6))) 134 (!strncmp(url, "ftp://", 6)))
148 { 135 {
@@ -160,7 +147,7 @@ _ecore_file_download(const char *url,
160 } 147 }
161 return job ? EINA_TRUE : EINA_FALSE; 148 return job ? EINA_TRUE : EINA_FALSE;
162 } 149 }
163# else 150#else
164 else if ((!strncmp(url, "http://", 7)) || (!strncmp(url, "https://", 8)) || 151 else if ((!strncmp(url, "http://", 7)) || (!strncmp(url, "https://", 8)) ||
165 (!strncmp(url, "ftp://", 6))) 152 (!strncmp(url, "ftp://", 6)))
166 { 153 {
@@ -171,21 +158,11 @@ _ecore_file_download(const char *url,
171 (void)headers; 158 (void)headers;
172 return EINA_FALSE; 159 return EINA_FALSE;
173 } 160 }
174# endif 161#endif
175 else 162 else
176 { 163 {
177 return EINA_FALSE; 164 return EINA_FALSE;
178 } 165 }
179#else
180 (void)url;
181 (void)dst;
182 (void)completion_cb;
183 (void)progress_cb;
184 (void)data;
185 (void)job_ret;
186 (void)headers;
187 return EINA_FALSE;
188#endif /* BUILD_ECORE_CON */
189} 166}
190 167
191/** 168/**
@@ -272,21 +249,15 @@ ecore_file_download_full(const char *url,
272EAPI Eina_Bool 249EAPI Eina_Bool
273ecore_file_download_protocol_available(const char *protocol) 250ecore_file_download_protocol_available(const char *protocol)
274{ 251{
275#ifdef BUILD_ECORE_CON
276 if (!strncmp(protocol, "file://", 7)) return EINA_TRUE; 252 if (!strncmp(protocol, "file://", 7)) return EINA_TRUE;
277# ifdef HAVE_CURL 253#ifdef HAVE_CURL
278 else if (!strncmp(protocol, "http://", 7)) return EINA_TRUE; 254 else if (!strncmp(protocol, "http://", 7)) return EINA_TRUE;
279 else if (!strncmp(protocol, "ftp://", 6)) return EINA_TRUE; 255 else if (!strncmp(protocol, "ftp://", 6)) return EINA_TRUE;
280# endif 256#endif
281#else
282 (void)protocol;
283#endif /* BUILD_ECORE_CON */
284 257
285 return EINA_FALSE; 258 return EINA_FALSE;
286} 259}
287 260
288#ifdef BUILD_ECORE_CON
289
290# ifdef HAVE_CURL 261# ifdef HAVE_CURL
291static int 262static int
292_ecore_file_download_url_compare_job(const void *data1, const void *data2) 263_ecore_file_download_url_compare_job(const void *data1, const void *data2)
@@ -397,7 +368,6 @@ _ecore_file_download_curl(const char *url, const char *dst,
397 368
398 return job; 369 return job;
399} 370}
400# endif
401#endif 371#endif
402 372
403/** 373/**
@@ -418,17 +388,15 @@ ecore_file_download_abort(Ecore_File_Download_Job *job)
418 if (!job) 388 if (!job)
419 return; 389 return;
420 390
421#ifdef BUILD_ECORE_CON
422 if (job->completion_cb) 391 if (job->completion_cb)
423 job->completion_cb(ecore_con_url_data_get(job->url_con), job->dst, 1); 392 job->completion_cb(ecore_con_url_data_get(job->url_con), job->dst, 1);
424# ifdef HAVE_CURL 393#ifdef HAVE_CURL
425 ecore_con_url_free(job->url_con); 394 ecore_con_url_free(job->url_con);
426# endif 395#endif
427 _job_list = eina_list_remove(_job_list, job); 396 _job_list = eina_list_remove(_job_list, job);
428 fclose(job->file); 397 fclose(job->file);
429 free(job->dst); 398 free(job->dst);
430 free(job); 399 free(job);
431#endif /* BUILD_ECORE_CON */
432} 400}
433 401
434/** 402/**
@@ -442,12 +410,10 @@ ecore_file_download_abort(Ecore_File_Download_Job *job)
442EAPI void 410EAPI void
443ecore_file_download_abort_all(void) 411ecore_file_download_abort_all(void)
444{ 412{
445#ifdef BUILD_ECORE_CON
446 Ecore_File_Download_Job *job; 413 Ecore_File_Download_Job *job;
447 414
448 EINA_LIST_FREE(_job_list, job) 415 EINA_LIST_FREE(_job_list, job)
449 ecore_file_download_abort(job); 416 ecore_file_download_abort(job);
450#endif /* BUILD_ECORE_CON */
451} 417}
452 418
453/** 419/**