thanks for your comments.
I changed Eina_List to Eina_Hash.

one more attached..

On Tue, Feb 15, 2011 at 7:05 PM, Cedric BAIL <[email protected]> wrote:

> Hi,
>
> On Tue, Feb 15, 2011 at 10:47 AM, sangho park <[email protected]> wrote:
> > fine. I revised and attached again.
>
> Ok, just doing a quick review. I don't like much the Eina_List for the
> header. At least it should be more documented about what should be put
> inside this list, or we could rely on an Eina_Hash and use an iterator
> to retrieve the Key and the Value in a separated way. I do prefer the
> Eina_Hash solution.
>
> > On Tue, Feb 15, 2011 at 6:22 PM, Vincent Torri <[email protected]>
> wrote:
> >> On Tue, 15 Feb 2011, sangho park wrote:
> >>  Dear all,
> >>>
> >>> This is a patch for ecore_file_download.
> >>> - add 'ecore_file_download_with_additional_headers' API
> >>>
> >>
> >> i don't like the name.
> >>
> >> ecore_file_download_full ?
> --
> Cedric BAIL
>
Index: ecore/src/lib/ecore_file/ecore_file_download.c
===================================================================
--- ecore/src/lib/ecore_file/ecore_file_download.c      (리비전 57040)
+++ ecore/src/lib/ecore_file/ecore_file_download.c      (작업 사본)
@@ -32,7 +32,8 @@ struct _Ecore_File_Download_Job
 Ecore_File_Download_Job *_ecore_file_download_curl(const char *url, const char 
*dst,
                                                    
Ecore_File_Download_Completion_Cb completion_cb,
                                                    
Ecore_File_Download_Progress_Cb progress_cb,
-                                                   void *data);
+                                                   void *data,
+                                                   Eina_Hash *headers);
 
 static Eina_Bool _ecore_file_download_url_complete_cb(void *data, int type, 
void *event);
 static Eina_Bool _ecore_file_download_url_progress_cb(void *data, int type, 
void *event);
@@ -77,48 +78,23 @@ ecore_file_download_shutdown(void)
 #endif /* BUILD_ECORE_CON */
 }
 
-/**
- * @addtogroup Ecore_File_Group Ecore_File - Files and directories convenience 
functions
- *
- * @{
- */
+static Eina_Bool
+_headers_foreach_cb(const Eina_Hash *hash __UNUSED__, const void *key, void 
*data, void *fdata)
+{
+   Ecore_File_Download_Job *job = fdata;
+   ecore_con_url_additional_header_add(job->url_con, key, data);
 
-/**
- * @brief Download the given url to the given destination.
- *
- * @param  url The complete url to download.
- * @param  dst The local file to save the downloaded to.
- * @param  completion_cb A callback called on download complete.
- * @param  progress_cb A callback called during the download operation.
- * @param  data User data passed to both callbacks.
- * @param  job_ret Job used to abort the download.
- * @return EINA_TRUE if the download start or EINA_FALSE on failure
- *
- * This function starts the download of the URL @p url and saves it to
- * @p dst. @p url must provide the protocol, including 'http://',
- * 'ftp://' or 'file://'. Ecore_File must be compiled with CURL to
- * download using http and ftp protocols. If @p dst is ill-formed, or
- * if it already exists, the function returns EINA_FALSE. When the
- * download is complete, the callback @p completion_cb is called and
- * @p data is passed to it. The @p status parameter of @p completion_cb 
- * will be filled with the status of the download (200, 404,...). The
- * @p progress_cb is called during the download operation, each time a
- * packet is received or when CURL wants. It can be used to display the
- * percentage of the downloaded file. Return 0 from this callback, if provided,
- * to continue the operation or anything else to abort the download. The only
- * operations that can be aborted are those with protocol 'http' or 'ftp'. In 
- * that case @p job_ret can be filled. It can be used with
- * ecore_file_download_abort() or ecore_file_download_abort_all() to
- * respectively abort one or all download operations. This function returns
- * EINA_TRUE if the download starts, EINA_FALSE otherwise.
- */
-EAPI Eina_Bool
-ecore_file_download(const char *url,
-                    const char *dst,
-                    Ecore_File_Download_Completion_Cb completion_cb,
-                    Ecore_File_Download_Progress_Cb progress_cb,
-                    void *data,
-                    Ecore_File_Download_Job **job_ret)
+   return EINA_TRUE;
+}
+
+static Eina_Bool
+_ecore_file_download(const char *url,
+                     const char *dst,
+                     Ecore_File_Download_Completion_Cb completion_cb,
+                     Ecore_File_Download_Progress_Cb progress_cb,
+                     void *data,
+                     Ecore_File_Download_Job **job_ret,
+                     Eina_Hash *headers)
 {
 #ifdef BUILD_ECORE_CON
    char *dir = ecore_file_dir_get(dst);
@@ -154,7 +130,7 @@ ecore_file_download_shutdown(void)
         /* download */
         Ecore_File_Download_Job *job;
 
-        job = _ecore_file_download_curl(url, dst, completion_cb, progress_cb, 
data);
+       job = _ecore_file_download_curl(url, dst, completion_cb, progress_cb, 
data, headers);
         if(job_ret) *job_ret = job;
         if(job)
           return EINA_TRUE;
@@ -189,6 +165,76 @@ ecore_file_download_shutdown(void)
 }
 
 /**
+ * @addtogroup Ecore_File_Group Ecore_File - Files and directories convenience 
functions
+ *
+ * @{
+ */
+
+/**
+ * @brief Download the given url to the given destination.
+ *
+ * @param  url The complete url to download.
+ * @param  dst The local file to save the downloaded to.
+ * @param  completion_cb A callback called on download complete.
+ * @param  progress_cb A callback called during the download operation.
+ * @param  data User data passed to both callbacks.
+ * @param  job_ret Job used to abort the download.
+ * @return EINA_TRUE if the download start or EINA_FALSE on failure
+ *
+ * This function starts the download of the URL @p url and saves it to
+ * @p dst. @p url must provide the protocol, including 'http://',
+ * 'ftp://' or 'file://'. Ecore_File must be compiled with CURL to
+ * download using http and ftp protocols. If @p dst is ill-formed, or
+ * if it already exists, the function returns EINA_FALSE. When the
+ * download is complete, the callback @p completion_cb is called and
+ * @p data is passed to it. The @p status parameter of @p completion_cb 
+ * will be filled with the status of the download (200, 404,...). The
+ * @p progress_cb is called during the download operation, each time a
+ * packet is received or when CURL wants. It can be used to display the
+ * percentage of the downloaded file. Return 0 from this callback, if provided,
+ * to continue the operation or anything else to abort the download. The only
+ * operations that can be aborted are those with protocol 'http' or 'ftp'. In 
+ * that case @p job_ret can be filled. It can be used with
+ * ecore_file_download_abort() or ecore_file_download_abort_all() to
+ * respectively abort one or all download operations. This function returns
+ * EINA_TRUE if the download starts, EINA_FALSE otherwise.
+ */
+EAPI Eina_Bool
+ecore_file_download(const char *url,
+                    const char *dst,
+                    Ecore_File_Download_Completion_Cb completion_cb,
+                    Ecore_File_Download_Progress_Cb progress_cb,
+                    void *data,
+                    Ecore_File_Download_Job **job_ret)
+{
+   _ecore_file_download(url, dst, completion_cb, progress_cb, data, job_ret, 
NULL);
+}
+
+/**
+ * @brief Download the given url to the given destination with additional 
headers.
+ *
+ * @param  url The complete url to download.
+ * @param  dst The local file to save the downloaded to.
+ * @param  completion_cb A callback called on download complete.
+ * @param  progress_cb A callback called during the download operation.
+ * @param  data User data passed to both callbacks.
+ * @param  job_ret Job used to abort the download.
+ * @param  headers pointer of header lists.
+ * @return EINA_TRUE if the download start or EINA_FALSE on failure
+ */
+EAPI Eina_Bool
+ecore_file_download_full(const char *url,
+                         const char *dst,
+                         Ecore_File_Download_Completion_Cb completion_cb,
+                         Ecore_File_Download_Progress_Cb progress_cb,
+                         void *data,
+                         Ecore_File_Download_Job **job_ret,
+                         Eina_Hash *headers)
+{
+   _ecore_file_download(url, dst, completion_cb, progress_cb, data, job_ret, 
headers);
+}
+
+/**
  * @brief Check if the given protocol is available.
  *
  * @param  protocol The protocol to check.
@@ -278,7 +324,8 @@ Ecore_File_Download_Job *
 _ecore_file_download_curl(const char *url, const char *dst,
                           Ecore_File_Download_Completion_Cb completion_cb,
                           Ecore_File_Download_Progress_Cb progress_cb,
-                          void *data)
+                          void *data,
+                          Eina_Hash *headers)
 {
    Ecore_File_Download_Job *job;
 
@@ -301,6 +348,7 @@ _ecore_file_download_curl(const char *url, const c
         return NULL;
      }
 
+   eina_hash_foreach(headers, _headers_foreach_cb, job);
    ecore_con_url_fd_set(job->url_con, fileno(job->file));
    ecore_con_url_data_set(job->url_con, data);
 
Index: ecore/src/lib/ecore_file/Ecore_File.h
===================================================================
--- ecore/src/lib/ecore_file/Ecore_File.h       (리비전 57040)
+++ ecore/src/lib/ecore_file/Ecore_File.h       (작업 사본)
@@ -166,6 +166,14 @@ EAPI Eina_Bool ecore_file_download(const char *url
                                    Ecore_File_Download_Progress_Cb progress_cb,
                                    void *data,
                                    Ecore_File_Download_Job **job_ret);
+EAPI Eina_Bool ecore_file_download_full(const char *url,
+                                        const char *dst,
+                                        Ecore_File_Download_Completion_Cb 
completion_cb,
+                                        Ecore_File_Download_Progress_Cb 
progress_cb,
+                                        void *data,
+                                        Ecore_File_Download_Job **job_ret,
+                                        Eina_Hash *headers);
+
 EAPI void      ecore_file_download_abort_all(void);
 EAPI void      ecore_file_download_abort(Ecore_File_Download_Job *job);
 EAPI Eina_Bool ecore_file_download_protocol_available(const char *protocol);
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to