Hi,
I merged with recent revision.
Please review this :p.
2011/12/16 Bluezery <[email protected]>:
> I fixed doc & ChangeLog & News.
>
> 2011/12/16 Carsten Haitzler <[email protected]>:
>>
>> if they want to dynamically adjust the feature should be in ecore_con to
>> track
>> the changes and adjust automatically :)
>
> --
> BRs,
> Kim.
--
BRs,
Kim.
Index: src/lib/ecore_con/ecore_con_url.c
===================================================================
--- src/lib/ecore_con/ecore_con_url.c (리비전 66325)
+++ src/lib/ecore_con/ecore_con_url.c (작업 사본)
@@ -57,6 +57,7 @@ static void _ecore_con_event_url_fr
void *ev);
static Eina_Bool _ecore_con_url_idler_handler(void *data);
static Eina_Bool _ecore_con_url_fd_handler(void *data __UNUSED__, Ecore_Fd_Handler *fd_handler __UNUSED__);
+static Eina_Bool _ecore_con_url_timeout_cb(void *data);
static Eina_List *_url_con_list = NULL;
static Eina_List *_fd_hd_list = NULL;
@@ -294,12 +295,13 @@ ecore_con_url_free(Ecore_Con_Url *url_co
{
ret = curl_multi_remove_handle(_curlm, url_con->curl_easy);
if (ret != CURLM_OK) ERR("curl_multi_remove_handle failed: %s", curl_multi_strerror(ret));
+ _url_con_list = eina_list_remove(_url_con_list, url_con);
}
curl_easy_cleanup(url_con->curl_easy);
}
+ if (url_con->timer) ecore_timer_del(url_con->timer);
- _url_con_list = eina_list_remove(_url_con_list, url_con);
curl_slist_free_all(url_con->headers);
EINA_LIST_FREE(url_con->additional_headers, s)
free(s);
@@ -1067,12 +1069,85 @@ ecore_con_url_ssl_ca_set(Ecore_Con_Url *
return res;
}
+EAPI int
+ecore_con_url_proxy_set(Ecore_Con_Url *url_con, const char *proxy)
+{
+#ifdef HAVE_CURL
+ int res = -1;
+ if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL))
+ {
+ ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_proxy_set");
+ return -1;
+ }
+
+ if (eina_list_data_find(_url_con_list, url_con)) return -1;
+ if (!url_con->url) return -1;
+ if (proxy == NULL) res = curl_easy_setopt(url_con->curl_easy, CURLOPT_PROXY, "");
+ else res = curl_easy_setopt(url_con->curl_easy, CURLOPT_PROXY, proxy);
+#else
+ return -1;
+ (void)url_con;
+ (void)proxy;
+#endif
+ return res;
+}
+
+EAPI void
+ecore_con_url_timeout_set(Ecore_Con_Url *url_con, double timeout)
+{
+#ifdef HAVE_CURL
+ if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL))
+ {
+ ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_timeout_set");
+ return;
+ }
+
+ if (eina_list_data_find(_url_con_list, url_con)) return;
+ if (!url_con->url || timeout < 0) return;
+ if (url_con->timer) ecore_timer_del(url_con->timer);
+ url_con->timer = ecore_timer_add(timeout, _ecore_con_url_timeout_cb, url_con);
+#else
+ return;
+ (void)url_con;
+ (void)timeout;
+#endif
+}
/**
* @}
*/
#ifdef HAVE_CURL
+static Eina_Bool
+_ecore_con_url_timeout_cb(void *data)
+{
+ Ecore_Con_Url *url_con = data;
+ CURLMcode ret;
+ Ecore_Con_Event_Url_Complete *e;
+
+ if (!url_con) return ECORE_CALLBACK_CANCEL;
+ if (!url_con->curl_easy) return ECORE_CALLBACK_CANCEL;
+ if (!eina_list_data_find(_url_con_list, url_con)) return ECORE_CALLBACK_CANCEL;
+
+ ret = curl_multi_remove_handle(_curlm, url_con->curl_easy);
+ if (ret != CURLM_OK) ERR("curl_multi_remove_handle failed: %s", curl_multi_strerror(ret));
+ _url_con_list = eina_list_remove(_url_con_list, url_con);
+
+ curl_slist_free_all(url_con->headers);
+ url_con->headers = NULL;
+
+ url_con->timer = NULL;
+
+ e = calloc(1, sizeof(Ecore_Con_Event_Url_Complete));
+ if (e)
+ {
+ e->url_con = url_con;
+ e->status = 0;
+ ecore_event_add(ECORE_CON_EVENT_URL_COMPLETE, e, _ecore_con_event_url_free, NULL);
+ }
+ return ECORE_CALLBACK_CANCEL;
+}
+
static size_t
_ecore_con_url_data_cb(void *buffer,
size_t size,
Index: src/lib/ecore_con/Ecore_Con.h
===================================================================
--- src/lib/ecore_con/Ecore_Con.h (리비전 66325)
+++ src/lib/ecore_con/Ecore_Con.h (작업 사본)
@@ -1845,6 +1845,40 @@ EAPI int ecore_con_url_ssl
const char *ca_path);
/**
+ * Set HTTP proxy to use.
+ *
+ * The parameter should be a char * to a zero terminated string holding
+ * the host name or dotted IP address. To specify port number in this string,
+ * append :[port] to the end of the host name.
+ * The proxy string may be prefixed with [protocol]:// since any such prefix
+ * will be ignored.
+ * The proxy's port number may optionally be specified with the separate option.
+ * If not specified, libcurl will default to using port 1080 for proxies.
+ *
+ * @param url_con Connection object that will use the proxy.
+ * @param proxy Porxy string or @c NULL to disable
+ *
+ * @return @c 0 on success. When cURL is used, non-zero return values
+ * are equal to cURL error codes.
+ * @since 1.2
+ */
+EAPI int ecore_con_url_proxy_set(Ecore_Con_Url *url_con, const char *proxy);
+
+/**
+ * Set timeout in seconds.
+ *
+ * the maximum time in seconds that you allow the ecore con url transfer
+ * operation to take. Normally, name lookups can take a considerable time
+ * and limiting operations to less than a few minutes risk aborting perfectly
+ * normal operations.
+ *
+ * @param url_con Connection object that will use the timeout.
+ * @param timeout time in seconds.
+ * @since 1.2
+ */
+EAPI void ecore_con_url_timeout_set(Ecore_Con_Url *url_con, double timeout);
+
+/**
* @}
*/
Index: src/lib/ecore_con/ecore_con_private.h
===================================================================
--- src/lib/ecore_con/ecore_con_private.h (리비전 66325)
+++ src/lib/ecore_con/ecore_con_private.h (작업 사본)
@@ -204,6 +204,8 @@ struct _Ecore_Con_Url
Eina_List *response_headers;
const char *url;
+ Ecore_Timer *timer;
+
Ecore_Con_Url_Time time_condition;
double timestamp;
void *data;
Index: src/lib/ecore_file/ecore_file_download.c
===================================================================
--- src/lib/ecore_file/ecore_file_download.c (리비전 66325)
+++ src/lib/ecore_file/ecore_file_download.c (작업 사본)
@@ -15,6 +15,7 @@
#ifdef BUILD_ECORE_CON
#define ECORE_MAGIC_FILE_DOWNLOAD_JOB 0xf7427cb8
+#define ECORE_FILE_DOWNLOAD_TIMEOUT 30
struct _Ecore_File_Download_Job
{
@@ -361,6 +362,7 @@ _ecore_file_download_curl(const char *ur
}
if (headers) eina_hash_foreach(headers, _ecore_file_download_headers_foreach_cb, job);
+ ecore_con_url_timeout_set(job->url_con, ECORE_FILE_DOWNLOAD_TIMEOUT);
ecore_con_url_fd_set(job->url_con, fileno(job->file));
ecore_con_url_data_set(job->url_con, data);
Index: NEWS
===================================================================
--- NEWS (리비전 66325)
+++ NEWS (작업 사본)
@@ -11,6 +11,8 @@ Additions:
- ecore_con_ssl_server_verify_name_set/get
- ecore_con_ssl_server_cafile_add() now accepts directories
- ECORE_CON_REMOTE_CORK
+ - ecore_con_url_proxy_set()
+ - ecore_con_url_timeout_set()
* ecore_x:
- ecore_x_randr_output_backlight_available()
Index: ChangeLog
===================================================================
--- ChangeLog (리비전 66325)
+++ ChangeLog (작업 사본)
@@ -421,3 +421,7 @@
2011-12-16 Mike Blumenkrantz
* Fix possible 0 byte allocation in ecore-x
+
+2011-12-19 Tae-Hwan Kim (Bluezery)
+
+ * Add proxy set and timeout set functions in ecore_con.
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel