Quoting from the commit message on the patch:

"
As discussed on the development mailing list, we should accept a
double
instead of a time_t for consistency with the rest of the API.

Some apidox has been added too, and as a result
ECORE_CON_URL_TIME_LASTMOD has been removed, since it does not make
much
sense (it is an HTTP response header).
"

With regard to the last bit, I don't see why libcurl accepts that
LASTMOD value, since it is sent by the server in an HTTP response, not
_to_ the server in an HTTP request.

IMO, ecore_con_url_time() should be renamed to something like
ecore_con_url_time_condition_set(), but that should be discussed a
little bit more.

Raster, I hope you can now apply the patch without going through much
pain ;)

>From 31e62f828cb3b92c6670f2b9d8553a5b6129f5d1 Mon Sep 17 00:00:00 2001
From: Raphael Kubo da Costa <[email protected]>
Date: Mon, 18 Oct 2010 14:08:21 -0200
Subject: [PATCH] Accept a double instead of a time_t in ecore_con_url_time().

As discussed on the development mailing list, we should accept a double
instead of a time_t for consistency with the rest of the API.

Some apidox has been added too, and as a result
ECORE_CON_URL_TIME_LASTMOD has been removed, since it does not make much
sense (it is an HTTP response header).
---
 src/lib/ecore_con/Ecore_Con.h         |   23 ++++++++++++++++----
 src/lib/ecore_con/ecore_con_private.h |    4 +-
 src/lib/ecore_con/ecore_con_url.c     |   37 +++++++++++++++++---------------
 3 files changed, 40 insertions(+), 24 deletions(-)

diff --git a/src/lib/ecore_con/Ecore_Con.h b/src/lib/ecore_con/Ecore_Con.h
index 2f6b0d1b..11515de 100644
--- a/src/lib/ecore_con/Ecore_Con.h
+++ b/src/lib/ecore_con/Ecore_Con.h
@@ -462,14 +462,27 @@ EAPI void              
ecore_con_client_timeout_set(Ecore_Con_Client *cl, double
 /**
  * @typedef Ecore_Con_Url_Time
  * @enum _Ecore_Con_Url_Time
- * The type of time in the object
+ * The type of condition to use when making an HTTP request dependent on time,
+ * so that headers such as "If-Modified-Since" are used.
  */
 typedef enum _Ecore_Con_Url_Time
 {
+   /**
+    * Do not place time restrictions on the HTTP requests.
+    */
    ECORE_CON_URL_TIME_NONE = 0,
+   /**
+    * Add the "If-Modified-Since" HTTP header, so that the request is performed
+    * by the server only if the target has been modified since the time value
+    * passed to it in the request.
+    */
    ECORE_CON_URL_TIME_IFMODSINCE,
-   ECORE_CON_URL_TIME_IFUNMODSINCE,
-   ECORE_CON_URL_TIME_LASTMOD
+   /**
+    * Add the "If-Unmodified-Since" HTTP header, so that the request is
+    * performed by the server only if the target has NOT been modified since
+    * the time value passed to it in the request.
+    */
+   ECORE_CON_URL_TIME_IFUNMODSINCE
 } Ecore_Con_Url_Time;
 
 EAPI int               ecore_con_url_init(void);
@@ -498,8 +511,8 @@ EAPI Eina_Bool         ecore_con_url_send(Ecore_Con_Url 
*url_con,
                                           const void *data, size_t length,
                                           const char *content_type);
 EAPI void              ecore_con_url_time(Ecore_Con_Url *url_con,
-                                          Ecore_Con_Url_Time condition,
-                                          time_t tm);
+                                          Ecore_Con_Url_Time time_condition,
+                                          double timestamp);
 
 EAPI Eina_Bool         ecore_con_url_ftp_upload(Ecore_Con_Url *url_con,
                                                 const char *filename,
diff --git a/src/lib/ecore_con/ecore_con_private.h 
b/src/lib/ecore_con/ecore_con_private.h
index 58d5da1..5eaaf47 100644
--- a/src/lib/ecore_con/ecore_con_private.h
+++ b/src/lib/ecore_con/ecore_con_private.h
@@ -168,8 +168,8 @@ struct _Ecore_Con_Url
    Eina_List *response_headers;
    char *url;
 
-   Ecore_Con_Url_Time condition;
-   time_t time;
+   Ecore_Con_Url_Time time_condition;
+   double timestamp;
    void *data;
 
    Ecore_Fd_Handler *fd_handler;
diff --git a/src/lib/ecore_con/ecore_con_url.c 
b/src/lib/ecore_con/ecore_con_url.c
index f97ff08..2ddbfad 100644
--- a/src/lib/ecore_con/ecore_con_url.c
+++ b/src/lib/ecore_con/ecore_con_url.c
@@ -615,12 +615,18 @@ ecore_con_url_data_get(Ecore_Con_Url *url_con)
 }
 
 /**
- * FIXME
- * Sets the @ref Ecore_Con_Url object's condition/time members.
+ * Sets whether HTTP requests should be conditional, dependent on
+ * modification time.
+ *
+ * @param url_con   Ecore_Con_Url to act upon.
+ * @param condition Condition to use for HTTP requests.
+ * @param timestamp Time since 1 Jan 1970 to use in the condition.
+ *
+ * @sa ecore_con_url_send()
  */
 EAPI void
 ecore_con_url_time(Ecore_Con_Url *url_con, Ecore_Con_Url_Time condition,
-                   time_t tm)
+                   double timestamp)
 {
 #ifdef HAVE_CURL
    if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL))
@@ -629,13 +635,13 @@ ecore_con_url_time(Ecore_Con_Url *url_con, 
Ecore_Con_Url_Time condition,
         return;
      }
 
-   url_con->condition = condition;
-   url_con->time = tm;
+   url_con->time_condition = condition;
+   url_con->timestamp = timestamp;
 #else
    return;
-   url_con = NULL;
-   condition = 0;
-   tm = 0;
+   (void)url_con;
+   (void)condition;
+   (void)timestamp;
 #endif
 }
 
@@ -793,6 +799,7 @@ ecore_con_url_httpauth_set(Ecore_Con_Url *url_con, const 
char *username,
  * @see ecore_con_url_data_set()
  * @see ecore_con_url_data_get()
  * @see ecore_con_url_response_headers_get()
+ * @see ecore_con_url_time()
  */
 EAPI Eina_Bool
 ecore_con_url_send(Ecore_Con_Url *url_con, const void *data, size_t length,
@@ -838,7 +845,7 @@ ecore_con_url_send(Ecore_Con_Url *url_con, const void 
*data, size_t length,
         url_con->headers = curl_slist_append(url_con->headers, tmp);
      }
 
-   switch (url_con->condition)
+   switch (url_con->time_condition)
      {
       case ECORE_CON_URL_TIME_NONE:
          curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMECONDITION,
@@ -848,19 +855,15 @@ ecore_con_url_send(Ecore_Con_Url *url_con, const void 
*data, size_t length,
       case ECORE_CON_URL_TIME_IFMODSINCE:
          curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMECONDITION,
                           CURL_TIMECOND_IFMODSINCE);
-         curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMEVALUE, 
url_con->time);
+         curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMEVALUE,
+                          (long)url_con->timestamp);
          break;
 
       case ECORE_CON_URL_TIME_IFUNMODSINCE:
          curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMECONDITION,
                           CURL_TIMECOND_IFUNMODSINCE);
-         curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMEVALUE, 
url_con->time);
-         break;
-
-      case ECORE_CON_URL_TIME_LASTMOD:
-         curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMECONDITION,
-                          CURL_TIMECOND_LASTMOD);
-         curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMEVALUE, 
url_con->time);
+         curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMEVALUE,
+                          (long)url_con->timestamp);
          break;
      }
 
-- 
1.7.3.1

--
Raphael Kubo da Costa
ProFUSION embedded systems
http://profusion.mobi
------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to