1 #ifndef _ECORE_CON_H
2 #define _ECORE_CON_H
3 
4 #include <time.h>
5 #include <libgen.h>
6 #ifdef _WIN32
7 # include <ws2tcpip.h>
8 #else
9 # include <netdb.h>
10 #endif
11 #include <Eina.h>
12 #include <Eo.h>
13 
14 #ifdef EFL_BETA_API_SUPPORT
15 #include "Efl_Net.h"
16 #endif
17 
18 #ifdef EAPI
19 # undef EAPI
20 #endif
21 
22 #ifdef _WIN32
23 # ifdef EFL_BUILD
24 #  ifdef DLL_EXPORT
25 #   define EAPI __declspec(dllexport)
26 #  else
27 #   define EAPI
28 #  endif
29 # else
30 #  define EAPI __declspec(dllimport)
31 # endif
32 #else
33 # ifdef __GNUC__
34 #  if __GNUC__ >= 4
35 #   define EAPI __attribute__ ((visibility("default")))
36 #  else
37 #   define EAPI
38 #  endif
39 # else
40 #  define EAPI
41 # endif
42 #endif
43 
44 /**
45  * @defgroup Ecore_Con_Group Ecore_Con - Connection functions
46  * @ingroup Ecore
47  *
48  * The Ecore Connection Library ( @c Ecore_Con ) provides simple mechanisms
49  * for communications between programs using reliable sockets.  It saves
50  * the programmer from having to worry about file descriptors and waiting
51  * for incoming connections.
52  *
53  * There are two main objects in the @c Ecore_Con library: the @c
54  * Ecore_Con_Server and the @c Ecore_Con_Client.
55  *
56  * The @c Ecore_Con_Server represents a server that can be connected to.
57  * It is used regardless of whether the program is acting as a server or
58  * client itself.
59  *
60  * To create a listening server call @c ecore_con_server_add(), optionally using
61  * an ECORE_CON_USE_* encryption type OR'ed with the type for encryption.
62  *
63  * To connect to a server, call @c ecore_con_server_connect(). Data can
64  * then be sent to the server using the @c ecore_con_server_send().
65  *
66  * Functions are described in the following groupings:
67  * @li @ref Ecore_Con_Lib_Group
68  * @li @ref Ecore_Con_Server_Group
69  * @li @ref Ecore_Con_Client_Group
70  * @li @ref Ecore_Con_Url_Group
71  *
72  * Events are described in @ref Ecore_Con_Events_Group.
73  */
74 
75 
76 /**
77  * @defgroup Ecore_Con_Events_Group Ecore Connection Events Functions
78  * @ingroup Ecore_Con_Group
79  *
80  * The Ecore Con events can be categorized into Server side events
81  * and Client side events.
82  * Server side events:
83  * @li ECORE_CON_CLIENT_ADD: Whenever a client connection is made to an
84  * @c Ecore_Con_Server, an event of this type is emitted, allowing the
85  * retrieval of the client's ip with @ref ecore_con_client_ip_get and
86  * associating data with the client using ecore_con_client_data_set.
87  * @li ECORE_CON_EVENT_CLIENT_DEL: Whenever a client connection to an
88  * @c Ecore_Con_Server is destroyed, an event of this type is emitted. The contents of
89  * the data with this event are variable, but if the client object in the data
90  * is non-null, it must be freed with @ref ecore_con_client_del.
91  * @li ECORE_CON_EVENT_CLIENT_DATA: Whenever a server object receives
92  * data, then an event of this type is emitted. The data will contain
93  * the size and contents of the message sent by the client. It should be noted that
94  * data within this object is transient, so it must be duplicated in order to be
95  * retained. This event will continue to occur until the client has stopped sending its
96  * message, so a good option for storing this data is an Eina_Strbuf. Once the message has
97  * been received in full, the client object must be freed with ecore_con_client_free.
98  *
99  * Client side events:
100  * @li ECORE_CON_EVENT_SERVER_ADD: Whenever a server object is created
101  * with @ref ecore_con_server_connect, an event of this type is emitted,
102  * allowing for data to be serialized and sent to the server using
103  * @ref ecore_con_server_send. At this point, the http handshake has
104  * occurred.
105  * @li ECORE_CON_EVENT_SERVER_DEL: Whenever a server object is destroyed,
106  * usually by the server connection being refused or dropped, an event of this
107  * type is emitted. The contents of the data with this event are variable,
108  * but if the server object in the data is non-null, it must be freed
109  * with @ref ecore_con_server_del.
110  * @li ECORE_CON_EVENT_SERVER_DATA: Whenever client object receives
111  * data from the server, an event of this type is emitted. The data will contain both
112  * the size and contents of the message sent by the server. It should be noted that
113  * data within this object is transient, so it must be duplicated in order to be
114  * retained. This event will continue to occur until the server has stopped sending its
115  * message, so a good option for storing this data is an Eina_Strbuf. Once the message has
116  * been received in full, the server object must be freed with ecore_con_server_free.
117  *
118  */
119 
120 /**
121  * @defgroup Ecore_Con_Buffer Ecore Connection Buffering
122  * @ingroup Ecore_Con_Group
123  *
124  * As Ecore_Con works on an event driven design, as data arrives, events will
125  * be produced containing the data that arrived. It is up to the user of
126  * Ecore_Con to either parse as they go, append to a file to later parse the
127  * whole file in one go, or append to memory to parse or handle later.
128  *
129  * To help with this Eina has some handy API's. The Eina_Binbuf and
130  * Eina_Strbuf APIs, abstract dynamic buffer management and make it trivial
131  * to handle buffers at runtime, without having to manage them. Eina_Binbuf
132  * makes it possible to create, expand, reset and slice a blob of memory -
133  * all via API. No system calls, no pointer manipulations and no size
134  * calculation.
135  *
136  * Additional functions include adding content at specified byte positions in
137  * the buffer, escaping the inputs, find and replace strings. This provides
138  * extreme flexibility to play around, with a dynamic blob of memory.
139  *
140  * It is good to free it (using eina_binbuf_free()) after using it.
141  *
142  * Eina_Binbuf compliments Ecore_Con use cases, where dynamic sizes of data
143  * arrive from the network (think http download in chunks). Using
144  * Eina_Binbuf provides enough flexibility to handle data as it arrives and
145  * to defer its processing until desired, without having to think about
146  * where to store the temporary data and how to manage its size.
147  *
148  * An example of how to use these with Ecore_Con follows.
149  *
150  * @code
151  * #include <Eina.h>
152  * #include <Ecore.h>
153  * #include <Ecore_Con.h>
154  *
155  * static Eina_Bool
156  * data_callback(void *data, int type, void *event)
157  * {
158  *    Ecore_Con_Event_Url_Data *url_data = event;
159  *    if ( url_data->size > 0)
160  *      {
161  *         // append data as it arrives - don't worry where or how it gets stored.
162  *         // Also don't worry about size, expanding, reallocing etc.
163  *         // just keep appending - size is automatically handled.
164  *
165  *         eina_binbuf_append_length(data, url_data->data, url_data->size);
166  *
167  *         fprintf(stderr, "Appended %d \n", url_data->size);
168  *      }
169  *    return EINA_TRUE;
170  * }
171  *
172  *
173  *
174  * static Eina_Bool
175  * completion_callback(void *data, int type, void *event)
176  * {
177  *    Ecore_Con_Event_Url_Complete *url_complete = event;
178  *    printf("download completed with status code: %d\n", url_complete->status);
179  *
180  *    // get the data back from Eina_Binbuf
181  *    char *ptr = eina_binbuf_string_get(data);
182  *    size_t size = eina_binbuf_length_get(data);
183  *
184  *    // process data as required (write to file)
185  *    fprintf(stderr, "Size of data = %d bytes\n", size);
186  *    int fd = open("./elm.png", O_CREAT);
187  *    write(fd, ptr, size);
188  *    close(fd);
189  *
190  *    // free it when done.
191  *    eina_binbuf_free(data);
192  *
193  *    ecore_main_loop_quit();
194  *
195  *    return EINA_TRUE;
196  * }
197  *
198  *
199  * int
200  * main(int argc, char **argv)
201  * {
202  *
203  *    const char *url = "http://www.enlightenment.org/p/index/d/logo.png";
204  *
205  *    ecore_init();
206  *    ecore_con_init();
207  *    ecore_con_url_init();
208  *
209  *
210  *    // This is single additional line to manage dynamic network data.
211  *    Eina_Binbuf *data = eina_binbuf_new();
212  *    Ecore_Con_Url *url_con = ecore_con_url_new(url);
213  *
214  *    ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE,
215  *                                                       completion_callback,
216  *                                                       data);
217  *    ecore_event_handler_add(ECORE_CON_EVENT_URL_DATA,
218  *                                                       data_callback,
219  *                                                       data);
220  *    ecore_con_url_get(url_con);
221  *
222  *    ecore_main_loop_begin();
223  *    return 0;
224  * }
225  * @endcode
226  */
227 
228 #ifdef __cplusplus
229 extern "C" {
230 #endif
231 #define ECORE_CON_USE_SSL ECORE_CON_USE_SSL2
232 #define ECORE_CON_REMOTE_SYSTEM ECORE_CON_REMOTE_TCP
233 
234 /** Types for an ecore_con client/server object.  A correct way to set this
235  * type is with an ECORE_CON_$TYPE, optionally OR'ed with an ECORE_CON_$USE if
236  * encryption is desired, and LOAD_CERT if the previously loaded certificate
237  * should be used.
238  *
239  * @ingroup Ecore_Con
240  */
241 typedef enum
242 {
243   ECORE_CON_LOCAL_USER = 0, /** Socket in "~/.ecore" */
244   ECORE_CON_LOCAL_SYSTEM = 1, /** Socket in /tmp */
245   ECORE_CON_LOCAL_ABSTRACT = 2, /** Abstract socket */
246   ECORE_CON_REMOTE_TCP = 3, /** Remote server using TCP */
247   ECORE_CON_REMOTE_MCAST = 4, /** Remote multicast UDP server (ecore_con_server_add() only) */
248   ECORE_CON_REMOTE_UDP = 5, /** Remote server using UDP */
249   ECORE_CON_REMOTE_BROADCAST = 6, /** Remote broadcast using UDP (ecore_con_server_connect() only) */
250   ECORE_CON_REMOTE_NODELAY = 7, /** Remote TCP connection sending packets
251                                  * immediately */
252   ECORE_CON_REMOTE_CORK = 8, /** Remote TCP connection sending data in large chunks
253                               * Note: Only available on Linux
254                               *
255                               * @since 1.2 */
256   ECORE_CON_USE_SSL2 = 16 /* 1 << 4 */, /** Use SSL2: UNSUPPORTED. */
257   ECORE_CON_USE_SSL3 = 32 /* 1 << 5 */, /** Use SSL3: UNSUPPORTED. */
258   ECORE_CON_USE_TLS = 64 /* 1 << 6 */, /** Use TLS */
259   ECORE_CON_USE_MIXED = 96 /* Ecore.Con.Type.use_tls | Ecore.Con.Type.use_ssl3 */, /** Use both TLS and SSL3 */
260   ECORE_CON_LOAD_CERT = 128 /* 1 << 7 */, /** Attempt to use the loaded
261                                            * certificate */
262   ECORE_CON_NO_PROXY = 256 /* 1 << 8 */, /** Disable all types of proxy on the
263                                           * server Note: Only functional for
264                                           * clients
265                                           *
266                                           * @since 1.2 */
267   ECORE_CON_SOCKET_ACTIVATE = 512 /* 1 << 9 */
268 } Ecore_Con_Type;
269 
270 /**
271  * @typedef Ecore_Con_Socks
272  * An object representing a SOCKS proxy
273  * @ingroup Ecore_Con_Socks_Group
274  * @since 1.2
275  */
276 typedef struct Ecore_Con_Socks Ecore_Con_Socks;
277 
278 /**
279  * @defgroup Ecore_Con_Lib_Group Ecore Connection Library Functions
280  * @ingroup Ecore_Con_Group
281  *
282  * Utility functions that set up and shut down the Ecore Connection
283  * library.
284  *
285  * There's also ecore_con_lookup() that can be used to make simple asynchronous
286  * DNS lookups.
287  *
288  * A simple example of how to use these functions:
289  * @li @ref ecore_con_lookup_example_c
290  *
291  * @{
292  */
293 
294 /**
295  * @typedef Ecore_Con_Dns_Cb
296  * A callback type for use with @ref ecore_con_lookup.
297  */
298 typedef void (*Ecore_Con_Dns_Cb)(const char *canonname,
299                                  const char *ip,
300                                  struct sockaddr *addr,
301                                  int addrlen,
302                                  void *data);
303 
304 /** @} */
305 
306 /**
307  * @struct _Ecore_Con_Server
308  * Used to provide legacy ABI/ABI compatibility with non-Eo applications.
309  * @ingroup Ecore_Con_Server_Group
310  */
311 struct _Ecore_Con_Server;
312 
313 /**
314  * @typedef Ecore_Con_Server
315  * Used to provide legacy API/ABI compatibility with non-Eo applications.
316  * @ingroup Ecore_Con_Server_Group
317  */
318 typedef struct _Ecore_Con_Server Ecore_Con_Server;
319 
320 /**
321  * @struct _Ecore_Con_Client
322  * Used to provide legacy ABI/ABI compatibility with non-Eo applications.
323  * @ingroup Ecore_Con_Client_Group
324  */
325 struct _Ecore_Con_Client;
326 
327 /**
328  * @typedef Ecore_Con_Client
329  * Used to provide legacy API/ABI compatibility with non-Eo applications.
330  * @ingroup Ecore_Con_Client_Group
331  */
332 typedef struct _Ecore_Con_Client Ecore_Con_Client;
333 
334 
335 /**
336  * @struct _Ecore_Con_Url
337  * Used to provide legacy ABI/ABI compatibility with non-Eo applications.
338  * @ingroup Ecore_Con_Url_Group
339  */
340 struct _Ecore_Con_Url;
341 
342 /**
343  * @typedef Ecore_Con_Url
344  * Used to provide legacy API/ABI compatibility with non-Eo applications.
345  * @ingroup Ecore_Con_Url_Group
346  */
347 typedef struct _Ecore_Con_Url Ecore_Con_Url;
348 
349 
350 /**
351  * @addtogroup Ecore_Con_Events_Group
352  * @{
353  */
354 
355 /**
356  * @typedef Ecore_Con_Event_Client_Add
357  * Used as the @p data param for the corresponding event.
358  */
359 typedef struct _Ecore_Con_Event_Client_Add Ecore_Con_Event_Client_Add;
360 
361 /**
362  * @typedef Ecore_Con_Event_Client_Upgrade
363  * Used as the @p data param for the corresponding event.
364  * @since 1.1
365  */
366 typedef struct _Ecore_Con_Event_Client_Upgrade Ecore_Con_Event_Client_Upgrade;
367 
368 /**
369  * @typedef Ecore_Con_Event_Client_Del
370  * Used as the @p data param for the corresponding event.
371  */
372 typedef struct _Ecore_Con_Event_Client_Del Ecore_Con_Event_Client_Del;
373 
374 /**
375  * @typedef Ecore_Con_Event_Client_Error
376  * Used as the @p data param for the corresponding event.
377  * @since 1.1
378  */
379 typedef struct _Ecore_Con_Event_Client_Error Ecore_Con_Event_Client_Error;
380 
381 /**
382  * @typedef Ecore_Con_Event_Server_Add
383  * Used as the @p data param for the corresponding event.
384  */
385 typedef struct _Ecore_Con_Event_Server_Add Ecore_Con_Event_Server_Add;
386 
387 /**
388  * @typedef Ecore_Con_Event_Server_Upgrade
389  * Used as the @p data param for the corresponding event.
390  * @since 1.1
391  */
392 typedef struct _Ecore_Con_Event_Server_Upgrade Ecore_Con_Event_Server_Upgrade;
393 
394 /**
395  * @typedef Ecore_Con_Event_Server_Del
396  * Used as the @p data param for the corresponding event.
397  */
398 typedef struct _Ecore_Con_Event_Server_Del Ecore_Con_Event_Server_Del;
399 
400 /**
401  * @typedef Ecore_Con_Event_Server_Error
402  * Used as the @p data param for the corresponding event.
403  * @since 1.1
404  */
405 typedef struct _Ecore_Con_Event_Server_Error Ecore_Con_Event_Server_Error;
406 
407 /**
408  * @typedef Ecore_Con_Event_Client_Data
409  * Used as the @p data param for the corresponding event.
410  */
411 typedef struct _Ecore_Con_Event_Client_Data Ecore_Con_Event_Client_Data;
412 
413 /**
414  * @typedef Ecore_Con_Event_Server_Data
415  * Used as the @p data param for the corresponding event.
416  */
417 typedef struct _Ecore_Con_Event_Server_Data Ecore_Con_Event_Server_Data;
418 
419 /**
420  * @typedef Ecore_Con_Event_Client_Write
421  * Used as the @p data param for the corresponding event.
422  * @since 1.1
423  */
424 typedef struct _Ecore_Con_Event_Client_Write Ecore_Con_Event_Client_Write;
425 
426 /**
427  * @typedef Ecore_Con_Event_Server_Write
428  * Used as the @p data param for the corresponding event.
429  * @since 1.1
430  */
431 typedef struct _Ecore_Con_Event_Server_Write Ecore_Con_Event_Server_Write;
432 
433 /**
434  * @typedef Ecore_Con_Event_Proxy_Bind
435  * Used as the @p data param for the corresponding event.
436  * @since 1.2
437  */
438 typedef struct _Ecore_Con_Event_Proxy_Bind Ecore_Con_Event_Proxy_Bind;
439 
440 /**
441  * @typedef Ecore_Con_Event_Url_Data
442  * Used as the @p data param for the corresponding event.
443  * @ingroup Ecore_Con_Url_Group
444  */
445 typedef struct _Ecore_Con_Event_Url_Data Ecore_Con_Event_Url_Data;
446 
447 /**
448  * @typedef Ecore_Con_Event_Url_Complete
449  * Used as the @p data param for the corresponding event.
450  * @ingroup Ecore_Con_Url_Group
451  */
452 typedef struct _Ecore_Con_Event_Url_Complete Ecore_Con_Event_Url_Complete;
453 
454 /**
455  * @typedef Ecore_Con_Event_Url_Progress
456  * Used as the @p data param for the corresponding event.
457  * @ingroup Ecore_Con_Url_Group
458  */
459 typedef struct _Ecore_Con_Event_Url_Progress Ecore_Con_Event_Url_Progress;
460 
461 /**
462  * @struct _Ecore_Con_Event_Client_Add
463  * Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_ADD event.
464  */
465 struct _Ecore_Con_Event_Client_Add
466 {
467    Ecore_Con_Client *client; /**< the client that connected */
468 };
469 
470 /**
471  * @struct _Ecore_Con_Event_Client_Upgrade
472  * Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_UPGRADE event.
473  * @since 1.1
474  */
475 struct _Ecore_Con_Event_Client_Upgrade
476 {
477    Ecore_Con_Client *client; /**< the client that completed handshake */
478 };
479 
480 /**
481  * @struct _Ecore_Con_Event_Client_Del
482  * Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_DEL event.
483  */
484 struct _Ecore_Con_Event_Client_Del
485 {
486    Ecore_Con_Client *client; /**< the client that was lost */
487 };
488 
489 /**
490  * @struct _Ecore_Con_Event_Client_Error
491  * Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_ERROR event.
492  */
493 struct _Ecore_Con_Event_Client_Error
494 {
495    Ecore_Con_Client *client; /**< the client for which an error occurred */
496    char *error; /**< the error string describing what happened */
497 };
498 
499 /**
500  * @struct _Ecore_Con_Event_Server_Add
501  * Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_ADD event.
502  */
503 struct _Ecore_Con_Event_Server_Add
504 {
505    Ecore_Con_Server *server; /**< the server that was connected to */
506 };
507 
508 /**
509  * @struct _Ecore_Con_Event_Server_Upgrade
510  * Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_UPGRADE event.
511  * @since 1.1
512  */
513 struct _Ecore_Con_Event_Server_Upgrade
514 {
515    Ecore_Con_Server *server; /**< the server that was connected to */
516 };
517 
518 /**
519  * @struct _Ecore_Con_Event_Server_Del
520  * Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_DEL event.
521  */
522 struct _Ecore_Con_Event_Server_Del
523 {
524    Ecore_Con_Server *server; /**< the client that was lost */
525 };
526 
527 /**
528  * @struct _Ecore_Con_Event_Server_Error
529  * Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_ERROR event.
530  */
531 struct _Ecore_Con_Event_Server_Error
532 {
533    Ecore_Con_Server *server; /**< the server for which an error occurred */
534    char *error; /**< the error string describing what happened */
535 };
536 
537 /**
538  * @struct _Ecore_Con_Event_Client_Data
539  * Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_DATA event.
540  */
541 struct _Ecore_Con_Event_Client_Data
542 {
543    Ecore_Con_Client *client; /**< the client that connected */
544    void *data;               /**< the data that the client sent */
545    int size;                 /**< the length of the data sent */
546 };
547 
548 /**
549  * @struct _Ecore_Con_Event_Server_Data
550  * Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_DATA event
551  */
552 struct _Ecore_Con_Event_Server_Data
553 {
554    Ecore_Con_Server *server; /**< the server that was connected to */
555    void *data;               /**< the data that the server sent */
556    int size;                 /**< the length of the data sent */
557 };
558 
559 /**
560  * @struct _Ecore_Con_Event_Client_Write
561  * Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_WRITE event.
562  */
563 struct _Ecore_Con_Event_Client_Write
564 {
565    Ecore_Con_Client *client; /**< the client that connected */
566    int size;                 /**< the length of the data sent */
567 };
568 
569 /**
570  * @struct _Ecore_Con_Event_Server_Write
571  * Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_WRITE event
572  */
573 struct _Ecore_Con_Event_Server_Write
574 {
575    Ecore_Con_Server *server; /**< the server that was connected to */
576    int size;                 /**< the length of the data sent */
577 };
578 
579 /**
580  * @struct _Ecore_Con_Event_Proxy_Bind
581  * Used as the @p data param for the @ref ECORE_CON_EVENT_PROXY_BIND event.
582  * @ingroup Ecore_Con_Socks_Group
583  * @since 1.2
584  */
585 struct _Ecore_Con_Event_Proxy_Bind
586 {
587    Ecore_Con_Server *server; /**< the server object connected to the proxy */
588    const char *ip;           /**< the proxy-bound ip address */
589    int port;                 /**< the proxy-bound port */
590 };
591 
592 /**
593  * @struct _Ecore_Con_Event_Url_Data
594  * Used as the @p data param for the @ref ECORE_CON_EVENT_URL_DATA event.
595  * @ingroup Ecore_Con_Url_Group
596  */
597 struct _Ecore_Con_Event_Url_Data
598 {
599    Ecore_Con_Url *url_con; /**< a pointer to the connection object */
600    int size; /**< the size of the current received data (in bytes) */
601    unsigned char data[1]; /**< the data received on this event */
602 };
603 
604 /**
605  * @struct _Ecore_Con_Event_Url_Complete
606  * Used as the @p data param for the @ref ECORE_CON_EVENT_URL_COMPLETE event.
607  * @ingroup Ecore_Con_Url_Group
608  */
609 struct _Ecore_Con_Event_Url_Complete
610 {
611    Ecore_Con_Url *url_con; /**< a pointer to the connection object */
612    int status; /**< HTTP status code of the operation (200, 404, 401, etc.) */
613 };
614 
615 /**
616  * @struct _Ecore_Con_Event_Url_Progress
617  * Used as the @p data param for the @ref ECORE_CON_EVENT_URL_PROGRESS event.
618  * @ingroup Ecore_Con_Url_Group
619  */
620 struct _Ecore_Con_Event_Url_Progress
621 {
622    Ecore_Con_Url *url_con; /**< a pointer to the connection object */
623    struct
624    {
625       double total; /**< total size of the downloading data (in bytes) */
626       double now; /**< current size of the downloading data (in bytes) */
627    } down; /**< download info */
628    struct
629    {
630       double total; /**< total size of the uploading data (in bytes) */
631       double now; /**< current size of the uploading data (in bytes) */
632    } up; /**< upload info */
633 };
634 
635 /** A client has connected to the server. */
636 EAPI extern int ECORE_CON_EVENT_CLIENT_ADD;
637 /** A client has disconnected from the server. */
638 EAPI extern int ECORE_CON_EVENT_CLIENT_DEL;
639 /** A client experienced an error.
640  * @since 1.1
641  */
642 EAPI extern int ECORE_CON_EVENT_CLIENT_ERROR;
643 /** A client connection has been upgraded to SSL.
644  * @since 1.1
645  */
646 EAPI extern int ECORE_CON_EVENT_CLIENT_UPGRADE;
647 /** A server was created. */
648 EAPI extern int ECORE_CON_EVENT_SERVER_ADD;
649 /** A server connection was lost. */
650 EAPI extern int ECORE_CON_EVENT_SERVER_DEL;
651 /** A server experienced an error.
652  * @since 1.1
653  */
654 EAPI extern int ECORE_CON_EVENT_SERVER_ERROR;
655 /** A server connection has been upgraded to SSL.
656  * @since 1.1
657  */
658 EAPI extern int ECORE_CON_EVENT_SERVER_UPGRADE;
659 /** A server connection has sent data to its client.
660  * @since 1.1
661  */
662 EAPI extern int ECORE_CON_EVENT_CLIENT_WRITE;
663 /** A server connection object has sent data.
664  * @since 1.1
665  */
666 EAPI extern int ECORE_CON_EVENT_SERVER_WRITE;
667 /** A client connected to the server has sent data. */
668 EAPI extern int ECORE_CON_EVENT_CLIENT_DATA;
669 /** A server connection object has data.*/
670 EAPI extern int ECORE_CON_EVENT_SERVER_DATA;
671 /** A server connection has successfully negotiated an ip:port binding.
672  * @since 1.2
673  */
674 EAPI extern int ECORE_CON_EVENT_PROXY_BIND;
675 /** A URL object has data. */
676 EAPI extern int ECORE_CON_EVENT_URL_DATA;
677 /** A URL object has completed its transfer to and from the server and can be reused. */
678 EAPI extern int ECORE_CON_EVENT_URL_COMPLETE;
679 /** A URL object has made progress in its transfer. */
680 EAPI extern int ECORE_CON_EVENT_URL_PROGRESS;
681 
682 /**
683  * @}
684  */
685 
686 /**
687  * @addtogroup Ecore_Con_Lib_Group
688  * @ingroup Ecore_Con_Group
689  *
690  * @{
691  */
692 
693 /**
694  * @brief Initializes the Ecore_Con library.
695  * @return  Number of times the library has been initialised without being
696  *          shut down.
697  *
698  * @note This function already calls ecore_init() internally, so you don't need
699  * to call it explicitly.
700  */
701 EAPI int               ecore_con_init(void);
702 
703 /**
704  * @brief Shuts down the Ecore_Con library.
705  * @return  Number of times the library has been initialised without being
706  *          shut down.
707  * @note This function already calls ecore_shutdown() internally, so you don't
708  * need to call it explicitly unless you called ecore_init() explicitly too.
709  */
710 EAPI int               ecore_con_shutdown(void);
711 
712 /**
713  * @brief Do an asynchronous DNS lookup.
714  *
715  * This function performs a DNS lookup on the hostname specified by name, then
716  * calls done_cb with the result and the data given as parameter. The result
717  * will be given to the done_cb as follows:
718  *
719  * canonname - the canonical name of the address, ip - the resolved ip address,
720  * addr - a pointer to the socket address, addrlen - the length of the socket
721  * address, in bytes, data - the data pointer given as parameter.
722  *
723  * @param[in] name IP address or server name to translate.
724  * @param[in] done_cb Callback to notify when done.
725  * @param[in] data User data to be given to done_cb.
726  *
727  * @return @c true if the request did not fail to be set up, @c false
728  * otherwise.
729  */
730 EAPI Eina_Bool ecore_con_lookup(const char *name, Ecore_Con_Dns_Cb done_cb, const void *data) EINA_ARG_NONNULL(1);
731 
732 /**
733  * @}
734  */
735 
736 /**
737  * @defgroup Ecore_Con_SSL_Group Ecore Connection SSL Functions
738  * @ingroup Ecore_Con_Group
739  *
740  * Functions that operate on Ecore connection objects pertaining to SSL.
741  *
742  * @{
743  */
744 
745 /**
746  * @brief Returns if SSL support is available.
747  * @return @c 1 if SSL is available and provided by gnutls,
748  *         @c 2 if SSL is available and provided by openssl,
749  *         @c 0 if it is not available.
750  */
751 EAPI int               ecore_con_ssl_available_get(void);
752 
753 /**
754  * @brief Adds an SSL certificate for use in ecore_con functions.
755  *
756  * Use this function to add a SSL PEM certificate.
757  * Simply specify the cert here to use it in the server object for connecting or listening.
758  * If there is an error loading the certificate, an error will automatically be logged.
759  * @param svr The server object
760  * @param cert The path to the certificate.
761  * @return @c EINA_FALSE if the file cannot be loaded, otherwise @c EINA_TRUE.
762  */
763 EAPI Eina_Bool         ecore_con_ssl_server_cert_add(Ecore_Con_Server *svr, const char *cert);
764 
765 /**
766  * @brief Adds an SSL private key for use in ecore_con functions.
767  *
768  * Use this function to add a SSL PEM private key.
769  * Simply specify the key file here to use it in the server object for connecting or listening.
770  * If there is an error loading the key, an error will automatically be logged.
771  * @param svr The server object.
772  * @param key_file The path to the key file.
773  * @return @c EINA_FALSE if the file cannot be loaded, otherwise @c EINA_TRUE.
774  */
775 EAPI Eina_Bool         ecore_con_ssl_server_privkey_add(Ecore_Con_Server *svr, const char *key_file);
776 
777 /**
778  * @brief Adds an SSL CRL for use in ecore_con functions.
779  *
780  * Use this function to add a SSL PEM CRL file.
781  * Simply specify the CRL file here to use it in the server object for connecting or listening.
782  * If there is an error loading the CRL, an error will automatically be logged.
783  * @param svr The server object.
784  * @param crl_file The path to the CRL file.
785  * @return @c EINA_FALSE if the file cannot be loaded, otherwise @c EINA_TRUE.
786  */
787 EAPI Eina_Bool         ecore_con_ssl_server_crl_add(Ecore_Con_Server *svr, const char *crl_file);
788 
789 /**
790  * @brief Adds an SSL CA file for use in ecore_con functions.
791  *
792  * Use this function to add a SSL PEM CA file.
793  * Simply specify the file here to use it in the server object for connecting or listening.
794  * If there is an error loading the CAs, an error will automatically be logged.
795  * @param svr The server object.
796  * @param ca_file The path to the CA file.
797  * @return @c EINA_FALSE if the file cannot be loaded, otherwise @c EINA_TRUE.
798  * @note since 1.2, this function can load directories.
799  */
800 EAPI Eina_Bool         ecore_con_ssl_server_cafile_add(Ecore_Con_Server *svr, const char *ca_file);
801 
802 /**
803  * @brief Enables certificate verification on a server object.
804  *
805  * Call this function on a server object before main loop has started
806  * to enable verification of certificates against loaded certificates.
807  * @param svr The server object
808  */
809 EAPI void              ecore_con_ssl_server_verify(Ecore_Con_Server *svr);
810 
811 /**
812  * @brief Enables hostname-based certificate verification on a server object.
813  *
814  * Call this function on a server object before main loop has started
815  * to enable verification of certificates using ONLY their hostnames.
816  * @param svr The server object.
817  * @note This function has no effect when used on a listening server created by
818  * ecore_con_server_add.
819  * @since 1.1
820  */
821 EAPI void              ecore_con_ssl_server_verify_basic(Ecore_Con_Server *svr);
822 
823 /**
824  * @brief Sets the hostname to verify against in certificate verification.
825  *
826  * Sometimes the certificate hostname will not match the hostname that you are
827  * connecting to, and will instead match a different name. An example of this is
828  * that if you connect to talk.google.com to use Google Talk, you receive Google's
829  * certificate for gmail.com. This certificate should be trusted, and so you must call
830  * this function with "gmail.com" as @p name.
831  * See RFC2818 for more details.
832  * @param svr The server object.
833  * @param name The hostname to verify against
834  * @since 1.2
835  */
836 EAPI void              ecore_con_ssl_server_verify_name_set(Ecore_Con_Server *svr, const char *name);
837 
838 /**
839  * @brief Gets the hostname to verify against in certificate verification.
840  *
841  * This function returns the name which will be used to validate the SSL certificate
842  * common name (CN) or alt name (subjectAltName). It will default to the @p name
843  * param in ecore_con_server_connect(), but can be changed with ecore_con_ssl_server_verify_name_set().
844  * @param svr The server object.
845  * @return The hostname which will be used
846  * @since 1.2
847  */
848 EAPI const char       *ecore_con_ssl_server_verify_name_get(Ecore_Con_Server *svr);
849 
850 /**
851  * @brief Upgrades a connection to a specified level of encryption.
852  *
853  * Use this function to begin an SSL handshake on a connection (STARTTLS or similar).
854  * Once the upgrade has been completed, an ECORE_CON_EVENT_SERVER_UPGRADE event will be emitted.
855  * The connection should be treated as disconnected until the next event.
856  * @param svr The server object.
857  * @param ssl_type The SSL connection type (ONLY).
858  * @return @c EINA_FALSE if the connection cannot be upgraded, otherwise @c EINA_TRUE.
859  * @note This function is NEVER to be used on a server object created with ecore_con_server_add.
860  * @warning Setting a wrong value for @p ssl_type WILL mess up your program.
861  * @since 1.1
862  */
863 EAPI Eina_Bool         ecore_con_ssl_server_upgrade(Ecore_Con_Server *svr, Ecore_Con_Type ssl_type);
864 
865 /**
866  * @brief Upgrades a connection to a specified level of encryption.
867  *
868  * Use this function to begin an SSL handshake on a connection (STARTTLS or similar).
869  * Once the upgrade has been completed, an ECORE_CON_EVENT_CLIENT_UPGRADE event will be emitted.
870  * The connection should be treated as disconnected until the next event.
871  * @param cl The client object.
872  * @param ssl_type The SSL connection type (ONLY).
873  * @return @c EINA_FALSE if the connection cannot be upgraded, otherwise @c EINA_TRUE.
874  * @warning Setting a wrong value for @p ssl_type WILL mess up your program.
875  * @since 1.1
876  */
877 EAPI Eina_Bool         ecore_con_ssl_client_upgrade(Ecore_Con_Client *cl, Ecore_Con_Type ssl_type);
878 
879 /**
880  * @}
881  */
882 
883 /**
884  * @defgroup Ecore_Con_Socks_Group Ecore Connection SOCKS functions
885  * @ingroup Ecore_Con_Group
886  * @{
887  */
888 
889 /**
890  * @brief Adds a SOCKS v4 proxy to the proxy list.
891  *
892  * Use this to create (or return, if previously added) a SOCKS proxy
893  * object which can be used by any ecore_con servers.
894  * @param ip The ip address of the proxy. (NOT DOMAIN NAME. IP ADDRESS.)
895  * @param port The port to connect to on the proxy.
896  * @param username The username to use for the proxy. (OPTIONAL)
897  * @return An allocated proxy object, or @c NULL on failure.
898  * @note This object NEVER needs to be explicitly freed.
899  * @since 1.2
900  */
901 EAPI Ecore_Con_Socks *ecore_con_socks4_remote_add(const char *ip, int port, const char *username);
902 
903 /**
904  * @brief Finds a SOCKS v4 proxy in the proxy list.
905  *
906  * Use this to determine if a SOCKS proxy was previously added by checking
907  * the proxy list against the parameters given.
908  * @param ip The ip address of the proxy. (NOT DOMAIN NAME. IP ADDRESS.)
909  * @param port The port to connect to on the proxy, or -1 to match the first proxy with @p ip
910  * @param username The username used for the proxy. (OPTIONAL)
911  * @return True only if a proxy exists matching the given params.
912  * @note This function matches slightly more loosely than ecore_con_socks4_remote_add(), and
913  * ecore_con_socks4_remote_add() should be used to return the actual object.
914  * @since 1.2
915  */
916 EAPI Eina_Bool        ecore_con_socks4_remote_exists(const char *ip, int port, const char *username);
917 
918 /**
919  * @brief Removes a SOCKS v4 proxy from the proxy list and delete it.
920  *
921  * Use this to remove a SOCKS proxy from the proxy list by checking
922  * the list against the parameters given. The proxy will then be deleted.
923  * @param ip The ip address of the proxy. (NOT DOMAIN NAME. IP ADDRESS.)
924  * @param port The port to connect to on the proxy, or -1 to match the first proxy with @p ip
925  * @param username The username used for the proxy. (OPTIONAL)
926  * @note This function matches in the same way as ecore_con_socks4_remote_exists().
927  * @warning Be aware that deleting a proxy which is being used WILL ruin your life.
928  * @since 1.2
929  */
930 EAPI void             ecore_con_socks4_remote_del(const char *ip, int port, const char *username);
931 
932 /**
933  * @brief Adds a SOCKS v5 proxy to the proxy list.
934  *
935  * Use this to create (or return, if previously added) a SOCKS proxy
936  * object which can be used by any ecore_con servers.
937  * @param ip The ip address of the proxy. (NOT DOMAIN NAME. IP ADDRESS.)
938  * @param port The port to connect to on the proxy.
939  * @param username The username to use for the proxy. (OPTIONAL)
940  * @param password The password to use for the proxy. (OPTIONAL)
941  * @return An allocated proxy object, or @c NULL on failure.
942  * @note This object NEVER needs to be explicitly freed.
943  * @since 1.2
944  */
945 EAPI Ecore_Con_Socks *ecore_con_socks5_remote_add(const char *ip, int port, const char *username, const char *password);
946 
947 /**
948  * @brief Finds a SOCKS v5 proxy in the proxy list.
949  *
950  * Use this to determine if a SOCKS proxy was previously added by checking
951  * the proxy list against the parameters given.
952  * @param ip The ip address of the proxy. (NOT DOMAIN NAME. IP ADDRESS.)
953  * @param port The port to connect to on the proxy, or -1 to match the first proxy with @p ip
954  * @param username The username used for the proxy. (OPTIONAL)
955  * @param password The password used for the proxy. (OPTIONAL)
956  * @return True only if a proxy exists matching the given params.
957  * @note This function matches slightly more loosely than ecore_con_socks5_remote_add(), and
958  * ecore_con_socks5_remote_add() should be used to return the actual object.
959  * @since 1.2
960  */
961 EAPI Eina_Bool        ecore_con_socks5_remote_exists(const char *ip, int port, const char *username, const char *password);
962 
963 /**
964  * @brief Removes a SOCKS v5 proxy from the proxy list and delete it.
965  *
966  * Use this to remove a SOCKS proxy from the proxy list by checking
967  * the list against the parameters given. The proxy will then be deleted.
968  * @param ip The ip address of the proxy. (NOT DOMAIN NAME. IP ADDRESS.)
969  * @param port The port to connect to on the proxy, or -1 to match the first proxy with @p ip
970  * @param username The username used for the proxy. (OPTIONAL)
971  * @param password The password used for the proxy. (OPTIONAL)
972  * @note This function matches in the same way as ecore_con_socks4_remote_exists().
973  * @warning Be aware that deleting a proxy which is being used WILL ruin your life.
974  * @since 1.2
975  */
976 EAPI void             ecore_con_socks5_remote_del(const char *ip, int port, const char *username, const char *password);
977 
978 /**
979  * @brief Sets DNS lookup mode on an existing SOCKS proxy.
980  *
981  * According to RFC, SOCKS v4 does not require that a proxy perform
982  * its own DNS lookups for addresses. SOCKS v4a specifies the protocol
983  * for this. SOCKS v5 allows DNS lookups.
984  * If you want to enable remote DNS lookup and are sure that your
985  * proxy supports it, use this function.
986  * @param ecs The proxy object.
987  * @param enable If true, the proxy will perform the dns lookup.
988  * @note By default, this setting is DISABLED.
989  * @since 1.2
990  */
991 EAPI void             ecore_con_socks_lookup_set(Ecore_Con_Socks *ecs, Eina_Bool enable);
992 
993 /**
994  * @brief Gets DNS lookup mode on an existing SOCKS proxy.
995  *
996  * According to RFC, SOCKS v4 does not require that a proxy perform
997  * its own DNS lookups for addresses. SOCKS v4a specifies the protocol
998  * for this. SOCKS v5 allows DNS lookups.
999  * This function returns whether lookups are enabled on a proxy object.
1000  * @param ecs The proxy object.
1001  * @return If true, the proxy will perform the dns lookup.
1002  * @note By default, this setting is DISABLED.
1003  * @since 1.2
1004  */
1005 EAPI Eina_Bool        ecore_con_socks_lookup_get(Ecore_Con_Socks *ecs);
1006 
1007 /**
1008  * @brief Enables bind mode on a SOCKS proxy.
1009  *
1010  * Use this function to enable binding a remote port for use with a remote server.
1011  * For more information, see http://ufasoft.com/doc/socks4_protocol.htm
1012  * @param ecs The proxy object.
1013  * @param is_bind If true, the connection established will be a port binding.
1014  * @warning Be aware that changing the operation mode of an active proxy may result in undefined behavior
1015  * @since 1.2
1016  */
1017 EAPI void             ecore_con_socks_bind_set(Ecore_Con_Socks *ecs, Eina_Bool is_bind);
1018 
1019 /**
1020  * @brief Returns bind mode of a SOCKS proxy.
1021  *
1022  * Use this function to return bind mode of a proxy (binding a remote port for use with a remote server).
1023  * For more information, see http://ufasoft.com/doc/socks4_protocol.htm
1024  * @param ecs The proxy object.
1025  * @return If true, the connection established will be a port binding.
1026  * @since 1.2
1027  */
1028 EAPI Eina_Bool        ecore_con_socks_bind_get(Ecore_Con_Socks *ecs);
1029 
1030 /**
1031  * @brief Returns SOCKS version of a SOCKS proxy.
1032  *
1033  * Use this function to return the SOCKS protocol version of a proxy.
1034  * @param ecs The proxy object.
1035  * @return @c 0 on error, else @c 4/5
1036  * @since 1.2
1037  */
1038 EAPI unsigned int     ecore_con_socks_version_get(Ecore_Con_Socks *ecs);
1039 
1040 /**
1041  * @brief Removes a SOCKS v4 proxy from the proxy list and delete it.
1042  *
1043  * Use this to remove a SOCKS proxy from the proxy list by directly deleting the object given.
1044  * @param ecs The proxy object to delete
1045  * @warning Be aware that deleting a proxy which is being used WILL ruin your life.
1046  * @since 1.2
1047  */
1048 EAPI void             ecore_con_socks_remote_del(Ecore_Con_Socks *ecs);
1049 
1050 /**
1051  * @brief Sets a proxy object to be used with the next server created with ecore_con_server_connect().
1052  *
1053  * This function sets a proxy for the next ecore_con connection. After the next server is created,
1054  * the proxy will NEVER be applied again unless explicitly enabled.
1055  * @param ecs The proxy object
1056  * @see ecore_con_socks_apply_always()
1057  * @since 1.2
1058  */
1059 EAPI void             ecore_con_socks_apply_once(Ecore_Con_Socks *ecs);
1060 
1061 /**
1062  * @brief Sets a proxy object to be used with all servers created with ecore_con_server_connect().
1063  *
1064  * This function sets a proxy for all ecore_con connections. It will always be used.
1065  * @param ecs The proxy object.
1066  * @see ecore_con_socks_apply_once().
1067  * @since 1.2
1068  * @note ecore-con supports setting this through environment variables like so:
1069  *   ECORE_CON_SOCKS_V4=[user@]server-port:lookup
1070  *   ECORE_CON_SOCKS_V5=[user@]server-port:lookup
1071  * user is the OPTIONAL string that would be passed to the proxy as the username.
1072  * server is the IP_ADDRESS of the proxy server.
1073  * port is the port to connect to on the proxy server.
1074  * lookup is 1 if the proxy should perform all DNS lookups, otherwise 0 or omitted.
1075  */
1076 EAPI void             ecore_con_socks_apply_always(Ecore_Con_Socks *ecs);
1077 
1078 /**
1079  * @}
1080  */
1081 
1082 /**
1083  * @defgroup Ecore_Con_Server_Group Ecore Connection Server Functions
1084  * @ingroup Ecore_Con_Group
1085  *
1086  * This group of functions is applied to an @ref Ecore_Con_Server object. It
1087  * doesn't mean that they should be used in the server application, but on the
1088  * server object. In fact, most of them should be used in the client
1089  * application, when retrieving information or sending data.
1090  *
1091  * Setting up a server is very simple: you just need to start it with
1092  * ecore_con_server_add() and setup some callbacks to the events
1093  * @ref ECORE_CON_EVENT_CLIENT_ADD, @ref ECORE_CON_EVENT_CLIENT_DEL and
1094  * @ref ECORE_CON_EVENT_CLIENT_DATA, that will be called when a client is
1095  * communicating with the server:
1096  *
1097  * @code
1098  * if (!(svr = ecore_con_server_add(ECORE_CON_REMOTE_TCP, "127.0.0.1", 8080, NULL)))
1099  *   exit(1);
1100  *
1101  * ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, _add_cb, NULL);
1102  * ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, _del_cb, NULL);
1103  * ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, _data_cb, NULL);
1104  *
1105  * ecore_main_loop_begin();
1106  * @endcode
1107  *
1108  * The function ecore_con_server_connect() can be used to write a client that
1109  * connects to a server. The resulting code will be very similar to the server
1110  * code:
1111  *
1112  * @code
1113  * if (!(svr = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, "127.0.0.1", 8080, NULL)))
1114  *   exit(1);
1115  *
1116  * ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, _add_cb, NULL);
1117  * ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, _del_cb, NULL);
1118  * ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, _data_cb, NULL);
1119  *
1120  * ecore_main_loop_begin();
1121  * @endcode
1122  *
1123  * After these two pieces of code are executed, respectively, in the server and
1124  * client code, the server will be up and running and the client will try to
1125  * connect to it. The connection, with its subsequent messages being sent from
1126  * server to client and client to server, can be represented in the following
1127  * sequence diagram:
1128  *
1129  * @image rtf ecore_con-client-server.png
1130  * @image html ecore_con-client-server.png
1131  * @image latex ecore_con-client-server.eps width=\\textwidth
1132  *
1133  * Please notice the important difference between these two codes: the first is
1134  * used for writing a @b server, while the second should be used for writing a
1135  * @b client.
1136  *
1137  * A reference for the @c client functions can be found at @ref
1138  * Ecore_Con_Client_Group.
1139  *
1140  * Examples of usage for this API can be found here:
1141  * @li @ref ecore_con_server_simple_example_c
1142  * @li @ref ecore_con_client_simple_example_c
1143  *
1144  * @{
1145  */
1146 
1147 /**
1148  * @brief Creates a local path to connect the socket.
1149  *
1150  * In the old API, ecore_con_server_add() and
1151  * ecore_con_server_connect() calculated a local path for connections
1152  * using @c ECORE_CON_LOCAL_USER and @c ECORE_CON_LOCAL_SYSTEM, this
1153  * function returns that path allocated so it can be used in
1154  * applications that want to connect to that path without replicating
1155  * its logic.
1156  *
1157  * @li If @a type is @c ECORE_CON_LOCAL_USER, the server will connect to
1158  *     the Unix socket. The path to the socket is taken from XDG_RUNTIME_DIR,
1159  *     if that is not set, then from HOME, even if this is not set, then from
1160  *     TMPDIR. If none is set, then path would be /tmp. From this path the
1161  *     function would connect to socket at "[path]/.ecore/[name]/[port]". If
1162  *     port is negative, then to socket at "[path]/.ecore/[name]".
1163  * @li If @a type is @c ECORE_CON_LOCAL_SYSTEM, the server will connect to
1164  *     Unix socket at "/tmp/.ecore_service|[name]|[port]". If port is negative,
1165  *     then to Unix socket at "/tmp/.ecore_service|[name]".
1166  *
1167  * @param  is_system  If #EINA_TRUE, will be a system wide socket
1168  *                    similar to @c ECORE_CON_LOCAL_SYSTEM. If #EINA_FALSE,
1169  *                    then it's similar to @c ECORE_CON_LOCAL_USER.
1170  * @param  name       Name to associate with the socket.  It is used when
1171  *                    generating the socket name of a Unix socket,
1172  *                    @c NULL will not be accepted.
1173  * @param  port       Number to identify socket.  When a Unix socket is used,
1174  *                    it becomes part of the socket name.
1175  *
1176  * @return NULL on failure or newly allocated path string on success,
1177  * remember to free() it after usage.
1178  *
1179  * @since 1.19
1180  */
1181 EAPI char *ecore_con_local_path_new(Eina_Bool is_system, const char *name, int port) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_ARG_NONNULL(2);
1182 
1183 /**
1184  * @brief Creates a server to listen for connections.
1185  *
1186  * @param  type The connection type.
1187  * @param  name       Name to associate with the socket. It is used when
1188  *                    generating the socket name of a Unix socket, or for
1189  *                    determining what host to listen on for TCP sockets.
1190  *                    @c NULL will not be accepted.
1191  * @param  port       Number to identify socket. When a Unix socket is used,
1192  *                    it becomes part of the socket name. When a TCP socket
1193  *                    is used, it is used as the TCP port.
1194  * @param  data       Data to associate with the created Ecore_Con_Server
1195  *                    object.
1196  * @return A new Ecore_Con_Server.
1197  *
1198  * The socket on which the server listens depends on the connection
1199  * type:
1200  * @li If @a type is @c ECORE_CON_LOCAL_USER, the server will listen on
1201  *     the Unix socket. The path to the socket is taken from XDG_RUNTIME_DIR,
1202  *     if that is not set, then from HOME, even if this is not set, then from
1203  *     TMPDIR. If none is set, then path would be /tmp. From this path socket
1204  *     would be created as "[path]/.ecore/[name]/[port]". If port is negative,
1205  *     then "[path]/.ecore/[name]".
1206  * @li If @a type is @c ECORE_CON_LOCAL_SYSTEM, the server will listen
1207  *     on Unix socket "/tmp/.ecore_service|[name]|[port]". If port is negative,
1208  *     then "/tmp/.ecore_service|[name]".
1209  * @li If @a type is @c ECORE_CON_LOCAL_ABSTRACT, then port number is not
1210  *     considered while creating the socket.
1211  * @li If @a type is @c ECORE_CON_REMOTE_TCP, the server will listen
1212  *     on TCP port @c port.
1213  *
1214  * More information about the @p type can be found at @ref _Ecore_Con_Type.
1215  *
1216  * The @p data parameter can be fetched later using ecore_con_server_data_get()
1217  * or changed with ecore_con_server_data_set().
1218  *
1219  * @see ecore_con_local_path_new()
1220  *
1221  * @note This API is deprecated and new code should use
1222  *       #EFL_NET_SERVER_SIMPLE_CLASS.
1223  *       See @li @ref efl_net_server_simple_example.c
1224  */
1225 EAPI Ecore_Con_Server *ecore_con_server_add(Ecore_Con_Type type,
1226                                             const char *name, int port,
1227                                             const void *data);
1228 
1229 /**
1230  * @brief Creates a connection to the specified server and return an associated object.
1231  *
1232  * @param  type The connection type.
1233  * @param  name       Name used when determining what socket to connect to.
1234  *                    It is used to generate the socket name when the socket
1235  *                    is a Unix socket. It is used as the hostname when
1236  *                    connecting with a TCP socket.
1237  * @param  port       Number to identify the socket to connect to. Used when
1238  *                    generating the socket name for a Unix socket, or as the
1239  *                    TCP port when connecting to a TCP socket.
1240  * @param  data       Data to associate with the created Ecore_Con_Server
1241  *                    object.
1242  * @return A new Ecore_Con_Server.
1243  *
1244  * The socket to which the connection is made depends on the connection type:
1245  * @li If @a type is @c ECORE_CON_LOCAL_USER, the server will connect to
1246  *     the Unix socket. The path to the socket is taken from XDG_RUNTIME_DIR,
1247  *     if that is not set, then from HOME, even if this is not set, then from
1248  *     TMPDIR. If none is set, then path would be /tmp. From this path the
1249  *     function would connect to socket at "[path]/.ecore/[name]/[port]". If
1250  *     port is negative, then to socket at "[path]/.ecore/[name]".
1251  * @li If @a type is @c ECORE_CON_LOCAL_SYSTEM, the server will connect to
1252  *     Unix socket at "/tmp/.ecore_service|[name]|[port]". If port is negative,
1253  *     then to Unix socket at "/tmp/.ecore_service|[name]".
1254  * @li If @a type is @c ECORE_CON_LOCAL_ABSTRACT, then port number is not
1255  *     considered while connecting to socket.
1256  * @li If @a type is @c ECORE_CON_REMOTE_TCP, the server will listen
1257  *     on TCP port @c port.
1258  *
1259  * More information about the @p type can be found at @ref _Ecore_Con_Type.
1260  *
1261  * This function won't block. It will either succeed, or fail due to invalid
1262  * parameters, failed memory allocation, etc., returning @c NULL on that case.
1263  *
1264  * However, even if this call returns a valid @ref Ecore_Con_Server, the
1265  * connection will only be successfully completed if an event of type
1266  * @ref ECORE_CON_EVENT_SERVER_ADD is received. If it fails to complete, an
1267  * @ref ECORE_CON_EVENT_SERVER_DEL will be received.
1268  *
1269  * The created object gets deleted automatically if the connection to the
1270  * server is lost.
1271  *
1272  * The @p data parameter can be fetched later using ecore_con_server_data_get()
1273  * or changed with ecore_con_server_data_set().
1274  *
1275  * @see ecore_con_local_path_new()
1276  *
1277  * @note This API is deprecated and new code should use
1278  *       #EFL_NET_DIALER_SIMPLE_CLASS.
1279  *       See @li @ref efl_net_dialer_simple_example.c
1280  */
1281 EAPI Ecore_Con_Server *ecore_con_server_connect(Ecore_Con_Type type,
1282                                                 const char *name, int port,
1283                                                 const void *data);
1284 /**
1285  * @brief Closes the connection and free the given server.
1286  *
1287  * @param   svr The given server.
1288  * @return  Data associated with the server when it was created.
1289  *
1290  * All the clients connected to this server will be disconnected.
1291  *
1292  * @see ecore_con_server_add, ecore_con_server_connect
1293  */
1294 EAPI void *            ecore_con_server_del(Ecore_Con_Server *svr);
1295 
1296 /**
1297  * @brief Retrieves the name of server.
1298  *
1299  * The name returned is the name used to connect on this server.
1300  *
1301  * @param svr The given server.
1302  * @return The name of the server.
1303  *
1304  * @ingroup Efl_Network_Server
1305  */
1306 EAPI const char *ecore_con_server_name_get(const Ecore_Con_Server *svr);
1307 
1308 /**
1309  * @brief Retrieves the data associated with the given server.
1310  *
1311  * @param   svr The given server.
1312  * @return  The associated data.
1313  *
1314  * @see ecore_con_server_data_set()
1315  */
1316 EAPI void *            ecore_con_server_data_get(Ecore_Con_Server *svr);
1317 /**
1318  * @brief Sets the data associated with the given server.
1319  *
1320  * @param svr The given server.
1321  * @param data The data to associate with @p svr.
1322  * @return  The previously associated data, if any.
1323  *
1324  * @see ecore_con_server_data_get()
1325  */
1326 EAPI void *            ecore_con_server_data_set(Ecore_Con_Server *svr,
1327                                                  void *data);
1328 /**
1329  * @brief Retrieves whether the given server is currently connected.
1330  *
1331  * @param   svr The given server.
1332  * @return @c EINA_TRUE if the server is connected, @c EINA_FALSE otherwise.
1333  */
1334 EAPI Eina_Bool         ecore_con_server_connected_get(const Ecore_Con_Server *svr);
1335 
1336 /**
1337  * @brief Retrieves the server port in use.
1338  *
1339  * @param   svr The given server.
1340  * @return  The server port in use.
1341  *
1342  * The port where the server is listening for connections.
1343  */
1344 EAPI int               ecore_con_server_port_get(const Ecore_Con_Server *svr);
1345 /**
1346  * @brief Checks how long a server has been connected.
1347  *
1348  * @param svr The server to check
1349  * @return The total time, in seconds, that the server has been
1350  * connected/running.
1351  *
1352  * This function is used to find out the time that has been elapsed since
1353  * ecore_con_server_add() succeeded.
1354  */
1355 EAPI double            ecore_con_server_uptime_get(const Ecore_Con_Server *svr);
1356 /**
1357  * @brief Sends the given data to the given server.
1358  *
1359  * @param   svr  The given server.
1360  * @param   data The given data.
1361  * @param   size Length of the data, in bytes, to send.
1362  * @return  The number of bytes sent.  @c 0 will be returned if there is an
1363  *          error.
1364  *
1365  * This function will send the given data to the server as soon as the program
1366  * is back to the main loop. Thus, this function returns immediately
1367  * (non-blocking). If the data needs to be sent @b now, call
1368  * ecore_con_server_flush() after this one.
1369  *
1370  * @see ecore_con_client_send()
1371  * @see ecore_con_server_flush()
1372  */
1373 EAPI int               ecore_con_server_send(Ecore_Con_Server *svr,
1374                                              const void *data,
1375                                              int size);
1376 /**
1377  * @brief Sets a limit on the number of clients that can be handled concurrently
1378  * by the given server, and a policy on what to do if excess clients try to
1379  * connect.
1380  *
1381  * @param   svr           The given server.
1382  * @param   client_limit  The maximum number of clients to handle
1383  *                        concurrently.  -1 means unlimited (default).  0
1384  *                        effectively disables the server.
1385  * @param   reject_excess_clients  Set to 1 to automatically disconnect
1386  *                        excess clients as soon as they connect if you are
1387  *                        already handling client_limit clients. Set to 0
1388  *                        (default) to just hold off on the "accept()"
1389  *                        system call until the number of active clients
1390  *                        drops. This causes the kernel to queue up to 4096
1391  *                        connections (or your kernel's limit, whichever is
1392  *                        lower).
1393  *
1394  * Beware that if you set this once ecore is already running, you may
1395  * already have pending CLIENT_ADD events in your event queue.  Those
1396  * clients have already connected and will not be affected by this call.
1397  * Only clients subsequently trying to connect will be affected.
1398  */
1399 EAPI void              ecore_con_server_client_limit_set(Ecore_Con_Server *svr,
1400                                                          int client_limit,
1401                                                          char reject_excess_clients);
1402 
1403 /**
1404  * @brief Retrieves the current list of clients.
1405  *
1406  * Each node in the returned list points to an @ref Efl_Network_Client. This
1407  * list cannot be modified or freed. It can also change if new clients are
1408  * connected or disconnected, and will become invalid when the server is
1409  * deleted/freed.
1410  *
1411  * @param svr The given server.
1412  * @return The list of clients on this server.
1413  *
1414  */
1415 EAPI const Eina_List *ecore_con_server_clients_get(const Ecore_Con_Server *svr);
1416 
1417 /**
1418  * @brief Gets the IP address of a server that has been connected to.
1419  *
1420  * @param   svr           The given server.
1421  * @return  A pointer to an internal string that contains the IP address of
1422  *          the connected server in the form "XXX.YYY.ZZZ.AAA" IP notation.
1423  *          This string should not be modified or trusted to stay valid after
1424  *          deletion for the @p svr object. If no IP is known @c NULL is
1425  *          returned.
1426  */
1427 EAPI const char *      ecore_con_server_ip_get(const Ecore_Con_Server *svr);
1428 /**
1429  * @brief Flushes all pending data to the given server.
1430  *
1431  * @param   svr           The given server.
1432  *
1433  * This function will block until all data is sent to the server.
1434  *
1435  * @see ecore_con_server_send()
1436  * @see ecore_con_client_flush()
1437  */
1438 EAPI void              ecore_con_server_flush(Ecore_Con_Server *svr);
1439 /**
1440  * @brief Sets the default time after which an inactive client will be disconnected.
1441  *
1442  * @param svr The server object.
1443  * @param timeout The timeout, in seconds, to disconnect after.
1444  *
1445  * This function is used by the server to set the default idle timeout on
1446  * clients. If the any of the clients becomes idle for a time higher than this
1447  * value, it will be disconnected. A value of < 1 disables the idle timeout.
1448  *
1449  * This timeout is not affected by the one set by
1450  * ecore_con_client_timeout_set(). A client will be disconnected whenever the
1451  * client or the server timeout is reached. That means, the lower timeout value
1452  * will be used for that client if ecore_con_client_timeout_set() is used on it.
1453  *
1454  * @see ecore_con_server_timeout_get()
1455  * @see ecore_con_client_timeout_set()
1456  */
1457 EAPI void              ecore_con_server_timeout_set(Ecore_Con_Server *svr, double timeout);
1458 /**
1459  * @brief Gets the default time after which an inactive client will be disconnected.
1460  *
1461  * @param svr The server object.
1462  * @return The timeout, in seconds, to disconnect after.
1463  *
1464  * This function is used to get the idle timeout for clients.  A value of < 1
1465  * means the idle timeout is disabled.
1466  *
1467  * @see ecore_con_server_timeout_set()
1468  * @see ecore_con_client_timeout_get()
1469  */
1470 EAPI double            ecore_con_server_timeout_get(const Ecore_Con_Server *svr);
1471 
1472 /**
1473  * @brief Gets the fd that the server is connected to.
1474  *
1475  * @param svr The server object
1476  * @return The fd, or @c -1 on failure
1477  *
1478  * This function returns the fd which is used by the underlying server connection.
1479  * It should not be tampered with unless you REALLY know what you are doing.
1480  * @note This function is only valid for servers created with ecore_con_server_connect().
1481  * @warning Seriously. Don't use this unless you know what you are doing.
1482  * @since 1.1
1483  */
1484 EAPI int               ecore_con_server_fd_get(const Ecore_Con_Server *svr);
1485 
1486 /**
1487  * @brief Gets the fd that the client is connected to.
1488  *
1489  * @param cl The client object
1490  * @return The fd, or @c -1 on failure
1491  *
1492  * This function returns the fd which is used by the underlying client connection.
1493  * It should not be tampered with unless you REALLY know what you are doing.
1494  * @since 1.1
1495  */
1496 EAPI int               ecore_con_client_fd_get(const Ecore_Con_Client *cl);
1497 /**
1498  * @}
1499  */
1500 
1501 /**
1502  * @defgroup Ecore_Con_Client_Group Ecore Connection Client Functions
1503  * @ingroup Ecore_Con_Group
1504  *
1505  * Functions to communicate with and/or set options on a client.
1506  *
1507  * This set of functions, as explained in @ref Ecore_Con_Server_Group, is used
1508  * to send data to a client, or to set options and get information about this
1509  * client. Most of them should be used on the server, applied on the client
1510  * object.
1511  *
1512  * If you need to implement a client, the way to connect to a server is
1513  * described in @ref Ecore_Con_Server_Group.
1514  *
1515  * An example of usage of these functions can be found at:
1516  * @li @ref ecore_con_client_simple_example_c
1517  *
1518  * @{
1519  */
1520 
1521 /**
1522  * @brief Sends the given data to the given client.
1523  *
1524  * @param   cl   The given client.
1525  * @param   data The given data.
1526  * @param   size Length of the data, in bytes, to send.
1527  * @return  The number of bytes sent.  @c 0 will be returned if there is an
1528  *          error.
1529  *
1530  * This function will send the given data to the client as soon as the program
1531  * is back to the main loop. Thus, this function returns immediately
1532  * (non-blocking). If the data needs to be sent @b now, call
1533  * ecore_con_client_flush() after this one.
1534  *
1535  * @see ecore_con_server_send()
1536  * @see ecore_con_client_flush()
1537  */
1538 EAPI int               ecore_con_client_send(Ecore_Con_Client *cl,
1539                                              const void *data,
1540                                              int size);
1541 /**
1542  * @brief Closes the connection and free memory allocated to the given client.
1543  *
1544  * @param   cl The given client.
1545  * @return  Data associated with the client.
1546  */
1547 EAPI void *            ecore_con_client_del(Ecore_Con_Client *cl);
1548 /**
1549  * @brief Sets the data associated with the given client to @p data.
1550  *
1551  * @param   cl   The given client.
1552  * @param   data What to set the data to.
1553  */
1554 EAPI void              ecore_con_client_data_set(Ecore_Con_Client *cl,
1555                                                  const void       *data);
1556 /**
1557  * @brief Retrieves the data associated with the given client.
1558  *
1559  * @param   cl The given client.
1560  * @return  The data associated with @p cl.
1561  */
1562 EAPI void *            ecore_con_client_data_get(Ecore_Con_Client *cl);
1563 
1564 /**
1565  * @brief Gets the IP address of a client that has connected.
1566  *
1567  * @param   cl            The given client.
1568  * @return  A pointer to an internal string that contains the IP address of
1569  *          the connected client in the form "XXX.YYY.ZZZ.AAA" IP notation.
1570  *
1571  * The returned string should not be modified, freed or trusted to stay valid
1572  * after deletion for the @p cl object. If no IP is known @c NULL is returned.
1573  */
1574 EAPI const char *      ecore_con_client_ip_get(const Ecore_Con_Client *cl);
1575 /**
1576  * @brief Flushes all pending data to the given client.
1577  *
1578  * @param   cl            The given client.
1579  *
1580  * This function will block until all data is sent to the server.
1581  *
1582  * @see ecore_con_client_send()
1583  * @see ecore_con_server_flush()
1584  */
1585 EAPI void              ecore_con_client_flush(Ecore_Con_Client *cl);
1586 /**
1587  * @brief Checks how long a client has been connected.
1588  *
1589  * @param cl The client to check
1590  * @return The total time, in seconds, that the client has been connected to
1591  * the server
1592  *
1593  * This function is used to find out how long a client has been connected for.
1594  */
1595 EAPI double            ecore_con_client_uptime_get(const Ecore_Con_Client *cl);
1596 /**
1597  * @brief Gets the default time after which the client will be disconnected when
1598  * inactive.
1599  *
1600  * @param cl The client object.
1601  * @return The timeout, in seconds, to disconnect after.
1602  *
1603  * This function is used to get the idle timeout for a client.  A value of < 1
1604  * means the idle timeout is disabled.
1605  *
1606  * @see ecore_con_client_timeout_set()
1607  */
1608 EAPI double            ecore_con_client_timeout_get(const Ecore_Con_Client *cl);
1609 /**
1610  * @brief Sets the time after which the client will be disconnected when inactive.
1611  *
1612  * @param cl The client object
1613  * @param timeout The timeout, in seconds, to disconnect after
1614  *
1615  * This function is used by the server to set the idle timeout on a specific
1616  * client. If the client becomes idle for a time higher than this value, it will
1617  * be disconnected. A value of < 1 disables the idle timeout.
1618  *
1619  * This timeout is not affected by the one set by
1620  * ecore_con_server_timeout_set(). A client will be disconnected whenever the
1621  * client or the server timeout is reached. That means, the lower timeout value
1622  * will be used for that client if ecore_con_server_timeout_set() is used on the
1623  * server.
1624  *
1625  * @see ecore_con_client_timeout_get()
1626  * @see ecore_con_server_timeout_set()
1627  */
1628 EAPI void              ecore_con_client_timeout_set(Ecore_Con_Client *cl, double timeout);
1629 /**
1630  * @brief Returns whether the client is still connected.
1631  *
1632  * @param   cl The given client.
1633  * @return @c EINA_TRUE if connected, @c EINA_FALSE otherwise.
1634  */
1635 EAPI Eina_Bool         ecore_con_client_connected_get(const Ecore_Con_Client *cl);
1636 /**
1637  * @brief Returns the port that the client has connected to.
1638  *
1639  * @param cl The client
1640  * @return The port that @p cl has connected to, or @c -1 on error
1641  * Use this function to return the port on which a given client has connected.
1642  */
1643 EAPI int               ecore_con_client_port_get(const Ecore_Con_Client *cl);
1644 
1645 /**
1646  * @brief The server the client is connected to.
1647  *
1648  * @param cl The client
1649  * @return The server the client is connected to.
1650  */
1651 EAPI Ecore_Con_Server *ecore_con_client_server_get(const Ecore_Con_Client *cl);
1652 
1653 /**
1654  * @}
1655  */
1656 
1657 /**
1658  * @defgroup Ecore_Con_Url_Group Ecore URL Connection Functions
1659  * @ingroup Ecore_Con_Group
1660  *
1661  * Utility functions that set up, use and shut down the Ecore URL
1662  * Connection library.
1663  *
1664  * These functions are a shortcut to make it easy to perform http requests
1665  * (POST, GET, etc).
1666  *
1667  * Brief usage:
1668  * 1. Create an Ecore_Con_Url object with ecore_con_url_new(url);
1669  * 2. Register to receive the #ECORE_CON_EVENT_URL_COMPLETE event
1670  *    (and optionally the #ECORE_CON_EVENT_URL_DATA and
1671  *    #ECORE_CON_EVENT_URL_PROGRESS event to receive
1672  *    the response, e.g. for HTTP/FTP downloads)
1673  * 3. Perform the operation with ecore_con_url_get(...);
1674  *
1675  * Note that it is good to reuse @ref Ecore_Con_Url objects wherever possible,
1676  * but bear in mind that each one can only perform one operation at a time.  You
1677  * need to wait for the #ECORE_CON_EVENT_URL_COMPLETE event before re-using or
1678  * destroying the object.
1679  *
1680  * If it's necessary to change the @ref Ecore_Con_Url object url, use
1681  * ecore_con_url_url_set().
1682  *
1683  * Simple Usage 1 (HTTP GET):
1684  * @code
1685  *   ecore_con_url_url_set(url_con, "http://www.google.com");
1686  *   ecore_con_url_get(url_con);
1687  * @endcode
1688  *
1689  * Simple usage 2 (HTTP POST):
1690  * @code
1691  *   ecore_con_url_url_set(url_con, "http://www.example.com/post_handler.cgi");
1692  *   ecore_con_url_post(url_con, data, data_length, "multipart/form-data");
1693  * @endcode
1694  *
1695  * Simple Usage 3 (FTP download):
1696  * @code
1697  *   fd = creat(filename, 0644)
1698  *   ecore_con_url_url_set(url_con, "ftp://ftp.example.com/pub/myfile");
1699  *   ecore_con_url_fd_set(url_con, fd);
1700  *   ecore_con_url_get(url_con);
1701  * @endcode
1702  *
1703  * Simple Usage 4 (FTP upload as ftp://ftp.example.com/file):
1704  * @code
1705  *   ecore_con_url_url_set(url_con, "ftp://ftp.example.com");
1706  *   ecore_con_url_ftp_upload(url_con, "/tmp/file", "user", "pass", NULL);
1707  * @endcode
1708  *
1709  * Simple Usage 5 (FTP upload as ftp://ftp.example.com/dir/file):
1710  * @code
1711  *   ecore_con_url_url_set(url_con, "ftp://ftp.example.com");
1712  *   ecore_con_url_ftp_upload(url_con, "/tmp/file", "user", "pass","dir");
1713  * @endcode
1714  *
1715  * These are complete examples for the API:
1716  * @li @ref ecore_con_url_download_example.c "Downloading a file"
1717  * @li @ref ecore_con_url_headers_example.c "Setting many options for the connection"
1718  *
1719  * @{
1720  */
1721 
1722 /**
1723  * @typedef Ecore_Con_Url_Time
1724  * @enum _Ecore_Con_Url_Time
1725  * The type of condition to use when making an HTTP request dependent on time,
1726  * so that headers such as "If-Modified-Since" are used.
1727  */
1728 typedef enum _Ecore_Con_Url_Time
1729 {
1730    /**
1731     * Do not place time restrictions on the HTTP requests.
1732     */
1733    ECORE_CON_URL_TIME_NONE = 0,
1734    /**
1735     * Add the "If-Modified-Since" HTTP header, so that the request is performed
1736     * by the server only if the target has been modified since the time value
1737     * passed to it in the request.
1738     */
1739    ECORE_CON_URL_TIME_IFMODSINCE,
1740    /**
1741     * Add the "If-Unmodified-Since" HTTP header, so that the request is
1742     * performed by the server only if the target has NOT been modified since
1743     * the time value passed to it in the request.
1744     */
1745    ECORE_CON_URL_TIME_IFUNMODSINCE
1746 } Ecore_Con_Url_Time;
1747 
1748 /**
1749  * @typedef Ecore_Con_Url_Http_Version
1750  * @enum _Ecore_Con_Url_Http_Version
1751  * The http version to use
1752  * @since 1.2
1753  */
1754 typedef enum _Ecore_Con_Url_Http_Version
1755 {
1756    /**
1757     * HTTP version 1.0
1758     * @since 1.2
1759     */
1760    ECORE_CON_URL_HTTP_VERSION_1_0,
1761    /**
1762     * HTTP version 1.1 (default)
1763     * @since 1.2
1764     */
1765    ECORE_CON_URL_HTTP_VERSION_1_1
1766 } Ecore_Con_Url_Http_Version;
1767 
1768 /**
1769  * @brief Changes the HTTP version used for the request.
1770  * @param url_con Connection object through which the request will be sent.
1771  * @param version The version to be used.
1772  * @return @c EINA_TRUE on success, @c EINA_FALSE on failure to change version.
1773  * @since 1.2
1774  * @see ecore_con_url_pipeline_get()
1775  */
1776 EAPI Eina_Bool         ecore_con_url_http_version_set(Ecore_Con_Url *url_con, Ecore_Con_Url_Http_Version version);
1777 
1778 /**
1779  * @brief Initializes the Ecore_Con_Url library.
1780  * @return Number of times the library has been initialised without being
1781  *          shut down.
1782  *
1783  * @note This function doesn't call ecore_con_init(). You still need to call it
1784  * explicitly before calling this one.
1785  */
1786 EAPI int               ecore_con_url_init(void);
1787 
1788 /**
1789  * @brief Shuts down the Ecore_Con_Url library.
1790  * @return  Number of calls that still uses Ecore_Con_Url
1791  *
1792  * @note This function doesn't call ecore_con_shutdown(). You still need to call
1793  * it explicitly after calling this one.
1794  */
1795 EAPI int               ecore_con_url_shutdown(void);
1796 
1797 /**
1798  * @brief Enables or disable HTTP 1.1 pipelining.
1799  * @param enable @c EINA_TRUE will turn it on, @c EINA_FALSE will disable it.
1800  *
1801  * Pipelining allows to send one request after another one, without having to
1802  * wait for the reply of the first request. The respective replies are received
1803  * in the order that the requests were sent.
1804  *
1805  * Enabling this feature will be valid for all requests done using @c
1806  * ecore_con_url.
1807  *
1808  * See http://en.wikipedia.org/wiki/HTTP_pipelining for more info.
1809  *
1810  * @see ecore_con_url_pipeline_get()
1811  */
1812 EAPI void              ecore_con_url_pipeline_set(Eina_Bool enable);
1813 /**
1814  * @brief Is HTTP 1.1 pipelining enable ?
1815  * @return @c EINA_TRUE if it is enable.
1816  *
1817  * @see ecore_con_url_pipeline_set()
1818  */
1819 EAPI Eina_Bool         ecore_con_url_pipeline_get(void);
1820 
1821 /**
1822  * @brief Creates and initializes a new Ecore_Con_Url connection object.
1823  *
1824  * @param url URL that will receive requests. Can be changed using
1825  *            ecore_con_url_url_set.
1826  *
1827  * @return @c NULL on error, a new Ecore_Con_Url on success.
1828  *
1829  * Create and initialize a new Ecore_Con_Url connection object that can be
1830  * used for sending requests.
1831  *
1832  * @see ecore_con_url_custom_new()
1833  * @see ecore_con_url_url_set()
1834  */
1835 EAPI Ecore_Con_Url *   ecore_con_url_new(const char *url);
1836 
1837 
1838 /**
1839  * @brief Change the URL assigned to this handle.
1840  *
1841  * @param url_con Connection object to change URL.
1842  * @param url the new URL.
1843  * @return @c EINA_TRUE on success, @c EINA_FALSE on errors.
1844  */
1845 EAPI Eina_Bool ecore_con_url_url_set(Ecore_Con_Url *url_con,
1846                                      const char *url);
1847 
1848 /**
1849  * @brief Retrieve the URL assigned to this handle.
1850  *
1851  * @param url_con the Connection object to retrieve URL.
1852  * @return @c NULL on error, read-only URL string on success.
1853  */
1854 EAPI const char *ecore_con_url_url_get(Ecore_Con_Url *url_con);
1855 
1856 /**
1857  * @brief Creates a custom connection object.
1858  *
1859  * @param url URL that will receive requests
1860  * @param custom_request Custom request (e.g. GET, POST, HEAD, PUT, etc)
1861  *
1862  * @return @c NULL on error, a new Ecore_Con_Url on success.
1863  *
1864  * Create and initialize a new Ecore_Con_Url for a custom request (e.g. HEAD,
1865  * SUBSCRIBE and other obscure HTTP requests). This object should be used like
1866  * one created with ecore_con_url_new().
1867  *
1868  * @see ecore_con_url_new()
1869  * @see ecore_con_url_url_set()
1870  */
1871 EAPI Ecore_Con_Url *   ecore_con_url_custom_new(const char *url,
1872                                                 const char *custom_request);
1873 /**
1874  * @brief Destroys an Ecore_Con_Url connection object.
1875  *
1876  * @param url_con Connection object to free.
1877  *
1878  * @see ecore_con_url_new()
1879  */
1880 EAPI void              ecore_con_url_free(Ecore_Con_Url *url_con);
1881 
1882 /**
1883  * @brief Associates data with a connection object.
1884  *
1885  * @param url_con Connection object to associate data.
1886  * @param data Data to be set.
1887  *
1888  * Associate data with a connection object, which can be retrieved later with
1889  * ecore_con_url_data_get()).
1890  *
1891  * @see ecore_con_url_data_get()
1892  */
1893 EAPI void              ecore_con_url_data_set(Ecore_Con_Url *url_con,
1894                                               void *data);
1895 /**
1896  * @brief Retrieves data associated with a Ecore_Con_Url connection object.
1897  *
1898  * @param url_con Connection object to retrieve data from.
1899  *
1900  * @return Data associated with the given object.
1901  *
1902  * Retrieve data associated with a Ecore_Con_Url connection object (previously
1903  * set with ecore_con_url_data_set()).
1904  *
1905  * @see ecore_con_url_data_set()
1906  */
1907 EAPI void *            ecore_con_url_data_get(Ecore_Con_Url *url_con);
1908 /**
1909  * @brief Adds an additional header to the request connection object.
1910  *
1911  * @param url_con Connection object
1912  * @param key Header key
1913  * @param value Header value
1914  *
1915  * Add an additional header (User-Agent, Content-Type, etc.) to the request
1916  * connection object. This addition will be valid for only one
1917  * ecore_con_url_get() or ecore_con_url_post() call.
1918  *
1919  * Some functions like ecore_con_url_time() also add headers to the request.
1920  *
1921  * @see ecore_con_url_get()
1922  * @see ecore_con_url_post()
1923  * @see ecore_con_url_additional_headers_clear()
1924  */
1925 EAPI void              ecore_con_url_additional_header_add(Ecore_Con_Url *url_con,
1926                                                            const char *key,
1927                                                            const char *value);
1928 /**
1929  * @brief Cleans additional headers.
1930  *
1931  * @param url_con Connection object to clean additional headers.
1932  *
1933  * Clean additional headers associated with a connection object (previously
1934  * added with ecore_con_url_additional_header_add()).
1935  *
1936  * @see ecore_con_url_additional_header_add()
1937  * @see ecore_con_url_get()
1938  * @see ecore_con_url_post()
1939  */
1940 EAPI void              ecore_con_url_additional_headers_clear(Ecore_Con_Url *url_con);
1941 /**
1942  * @brief Retrieves headers from last request sent.
1943  *
1944  * @param url_con Connection object to retrieve response headers from.
1945  *
1946  * Retrieve a list containing the response headers. This function should be
1947  * used after an ECORE_CON_EVENT_URL_COMPLETE event (headers should normally be
1948  * ready at that time).
1949  *
1950  * @return List of response headers. This list must not be modified by the user.
1951  */
1952 EAPI const Eina_List * ecore_con_url_response_headers_get(Ecore_Con_Url *url_con);
1953 /**
1954  * @brief Sets up a file for receiving response data.
1955  *
1956  * @param url_con Connection object to set file
1957  * @param fd File descriptor associated with the file. A negative value will
1958  * unset any previously set fd.
1959  *
1960  * Set up a file to have response data written into. Note that
1961  * ECORE_CON_EVENT_URL_DATA events will not be emitted if a file has been set to
1962  * receive the response data.
1963  *
1964  * This call can be used to easily setup a file where the downloaded data will
1965  * be saved.
1966  */
1967 EAPI void              ecore_con_url_fd_set(Ecore_Con_Url *url_con, int fd);
1968 /**
1969  * @brief Retrieves the number of bytes received.
1970  *
1971  * Retrieve the number of bytes received on the last request of the given
1972  * connection object.
1973  *
1974  * @param url_con Connection object which the request was sent on.
1975  *
1976  * @return Number of bytes received on request.
1977  *
1978  * @see ecore_con_url_get()
1979  * @see ecore_con_url_post()
1980  */
1981 EAPI int               ecore_con_url_received_bytes_get(Ecore_Con_Url *url_con);
1982 /**
1983  * @brief Sets url_con to use http auth, with given username and password, "safely" or not.
1984  *
1985  * @param url_con Connection object to perform a request on, previously created
1986  *    with ecore_con_url_new() or ecore_con_url_custom_new().
1987  * @param username Username to use in authentication
1988  * @param password Password to use in authentication
1989  * @param safe Whether to use "safer" methods (eg, NOT http basic auth)
1990  *
1991  * @return @c EINA_TRUE on success, @c EINA_FALSE on error.
1992  *
1993  * @attention Require libcurl >= 7.19.1 to work, otherwise will always return
1994  * @c 0.
1995  */
1996 EAPI Eina_Bool         ecore_con_url_httpauth_set(Ecore_Con_Url *url_con,
1997                                                   const char *username,
1998                                                   const char *password,
1999                                                   Eina_Bool safe);
2000 /**
2001  * @brief Sends a get request.
2002  *
2003  * @param url_con Connection object to perform a request on, previously created
2004  *
2005  * @return @c EINA_TRUE on success, @c EINA_FALSE on error.
2006  *
2007  * The request is performed immediately, but you need to setup event handlers
2008  * for #ECORE_CON_EVENT_URL_DATA, #ECORE_CON_EVENT_URL_COMPLETE or
2009  * #ECORE_CON_EVENT_URL_PROGRESS to get more information about its result.
2010  *
2011  * @see ecore_con_url_custom_new()
2012  * @see ecore_con_url_additional_headers_clear()
2013  * @see ecore_con_url_additional_header_add()
2014  * @see ecore_con_url_data_set()
2015  * @see ecore_con_url_data_get()
2016  * @see ecore_con_url_response_headers_get()
2017  * @see ecore_con_url_time()
2018  * @see ecore_con_url_post()
2019  */
2020 EAPI Eina_Bool         ecore_con_url_get(Ecore_Con_Url *url_con);
2021 /**
2022  * @brief Sends a HEAD request.
2023  *
2024  * @param url_con Connection object to perform a request on, previously created
2025  *
2026  * @return @c EINA_TRUE on success, @c EINA_FALSE on error.
2027  *
2028  * The request is performed immediately, but you need to setup event handlers
2029  * for #ECORE_CON_EVENT_URL_COMPLETE or #ECORE_CON_EVENT_URL_PROGRESS to get
2030  * more information about its result.
2031  *
2032  * @see ecore_con_url_custom_new()
2033  * @see ecore_con_url_additional_headers_clear()
2034  * @see ecore_con_url_additional_header_add()
2035  * @see ecore_con_url_response_headers_get()
2036  * @see ecore_con_url_time()
2037  * @see ecore_con_url_post()
2038  * @since 1.14
2039  */
2040 EAPI Eina_Bool         ecore_con_url_head(Ecore_Con_Url *url_con);
2041 /**
2042  * @brief Sends a post request.
2043  *
2044  * @param url_con Connection object to perform a request on, previously created
2045  *                with ecore_con_url_new() or ecore_con_url_custom_new().
2046  * @param data    Payload (data sent on the request). Can be @c NULL.
2047  * @param length  Payload length. If @c -1, rely on automatic length
2048  *                calculation via @c strlen() on @p data.
2049  * @param content_type Content type of the payload (e.g. text/xml). Can be @c
2050  * NULL.
2051  *
2052  * @return @c EINA_TRUE on success, @c EINA_FALSE on error.
2053  *
2054  * The request starts immediately, but you need to setup event handlers
2055  * for #ECORE_CON_EVENT_URL_DATA, #ECORE_CON_EVENT_URL_COMPLETE or
2056  * #ECORE_CON_EVENT_URL_PROGRESS to get more information about its result.
2057  *
2058  * This call won't block your main loop.
2059  *
2060  * @see ecore_con_url_custom_new()
2061  * @see ecore_con_url_additional_headers_clear()
2062  * @see ecore_con_url_additional_header_add()
2063  * @see ecore_con_url_data_set()
2064  * @see ecore_con_url_data_get()
2065  * @see ecore_con_url_response_headers_get()
2066  * @see ecore_con_url_time()
2067  * @see ecore_con_url_get()
2068  */
2069 EAPI Eina_Bool         ecore_con_url_post(Ecore_Con_Url *url_con,
2070                                           const void *data, long length,
2071                                           const char *content_type);
2072 /**
2073  * @brief Sets whether HTTP requests should be conditional, dependent on
2074  * modification time.
2075  *
2076  * @param url_con   Ecore_Con_Url to act upon.
2077  * @param time_condition Condition to use for HTTP requests.
2078  * @param timestamp Time since 1 Jan 1970 to use in the condition.
2079  *
2080  * This function may set the header "If-Modified-Since" or
2081  * "If-Unmodified-Since", depending on the value of @p time_condition, with the
2082  * value @p timestamp.
2083  *
2084  * @sa ecore_con_url_get()
2085  * @sa ecore_con_url_post()
2086  */
2087 EAPI void              ecore_con_url_time(Ecore_Con_Url *url_con,
2088                                           Ecore_Con_Url_Time time_condition,
2089                                           double timestamp);
2090 
2091 /**
2092  * @brief Uploads a file to an ftp site.
2093  *
2094  * @param url_con The Ecore_Con_Url object to send with
2095  * @param filename The path to the file to send
2096  * @param user The username to log in with
2097  * @param pass The password to log in with
2098  * @param upload_dir The directory to which the file should be uploaded
2099  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
2100  *
2101  * Upload @p filename to an ftp server set in @p url_con using @p user
2102  * and @p pass to directory @p upload_dir
2103  */
2104 EAPI Eina_Bool         ecore_con_url_ftp_upload(Ecore_Con_Url *url_con,
2105                                                 const char *filename,
2106                                                 const char *user,
2107                                                 const char *pass,
2108                                                 const char *upload_dir);
2109 /**
2110  * @brief Toggles libcurl's verbose output.
2111  *
2112  * @param url_con Ecore_Con_Url instance which will be acted upon.
2113  * @param verbose Whether or not to enable libcurl's verbose output.
2114  *
2115  * If @p verbose is @c EINA_TRUE, libcurl will output a lot of verbose
2116  * information about its operations, which is useful for
2117  * debugging. The verbose information will be sent to stderr.
2118  */
2119 EAPI void              ecore_con_url_verbose_set(Ecore_Con_Url *url_con,
2120                                                  Eina_Bool verbose);
2121 /**
2122  * @brief Enables or disables EPSV extension.
2123  * @param url_con  The Ecore_Con_Url instance which will be acted upon.
2124  * @param use_epsv Boolean to enable/disable the EPSV extension.
2125  */
2126 EAPI void              ecore_con_url_ftp_use_epsv_set(Ecore_Con_Url *url_con,
2127                                                       Eina_Bool use_epsv);
2128 
2129 /**
2130  * @brief Enables the cookie engine for subsequent HTTP requests.
2131  *
2132  * @param url_con Ecore_Con_Url instance which will be acted upon.
2133  *
2134  * After this function is called, cookies set by the server in HTTP responses
2135  * will be parsed and stored, as well as sent back to the server in new HTTP
2136  * requests.
2137  *
2138  * @note Even though this function is called @c ecore_con_url_cookies_init(),
2139  * there is no symmetrical shutdown operation.
2140  */
2141 EAPI void              ecore_con_url_cookies_init(Ecore_Con_Url *url_con);
2142 /**
2143  * @brief Controls whether session cookies from previous sessions shall be loaded.
2144  *
2145  * @param url_con Ecore_Con_Url instance which will be acted upon.
2146  * @param ignore  If @c EINA_TRUE, ignore session cookies when loading cookies
2147  *                from files. If @c EINA_FALSE, all cookies will be loaded.
2148  *
2149  * Session cookies are cookies with no expire date set, which usually means
2150  * they are removed after the current session is closed.
2151  *
2152  * By default, when Ecore_Con_Url loads cookies from a file, all cookies are
2153  * loaded, including session cookies, which, most of the time, were supposed
2154  * to be loaded and valid only for that session.
2155  *
2156  * If @p ignore is set to @c EINA_TRUE, when Ecore_Con_Url loads cookies from
2157  * the files passed to @c ecore_con_url_cookies_file_add(), session cookies
2158  * will not be loaded.
2159  *
2160  * @see ecore_con_url_cookies_file_add()
2161  */
2162 EAPI void              ecore_con_url_cookies_ignore_old_session_set(Ecore_Con_Url *url_con,
2163                                                                     Eina_Bool ignore);
2164 /**
2165  * @brief Clears currently loaded cookies.
2166  * @param url_con      Ecore_Con_Url instance which will be acted upon.
2167  *
2168  * The cleared cookies are removed and will not be sent in subsequent HTTP
2169  * requests, nor will they be written to the cookiejar file set via
2170  * @c ecore_con_url_cookies_jar_file_set().
2171  *
2172  * @note This function will initialize the cookie engine if it has not been
2173  *       initialized yet.
2174  * @note The cookie files set by ecore_con_url_cookies_file_add() aren't loaded
2175  *       immediately, just when the request is started. Thus, if you ask to
2176  *       clear the cookies, but has a file already set by that function, the
2177  *       cookies will then be loaded and you will have old cookies set. In order
2178  *       to don't have any old cookie set, you need to don't call
2179  *       ecore_con_url_cookies_file_add() ever on the @p url_con handler, and
2180  *       call this function to clear any cookie set by a previous request on
2181  *       this handler.
2182  *
2183  * @see ecore_con_url_cookies_session_clear()
2184  * @see ecore_con_url_cookies_ignore_old_session_set()
2185  */
2186 EAPI void              ecore_con_url_cookies_clear(Ecore_Con_Url *url_con);
2187 /**
2188  * @brief Clears currently loaded session cookies.
2189  *
2190  * @param url_con      Ecore_Con_Url instance which will be acted upon.
2191  *
2192  * Session cookies are cookies with no expire date set, which usually means
2193  * they are removed after the current session is closed.
2194  *
2195  * The cleared cookies are removed and will not be sent in subsequent HTTP
2196  * requests, nor will they be written to the cookiejar file set via
2197  * @c ecore_con_url_cookies_jar_file_set().
2198  *
2199  * @note This function will initialize the cookie engine if it has not been
2200  *       initialized yet.
2201  * @note The cookie files set by ecore_con_url_cookies_file_add() aren't loaded
2202  *       immediately, just when the request is started. Thus, if you ask to
2203  *       clear the session cookies, but has a file already set by that function,
2204  *       the session cookies will then be loaded and you will have old cookies
2205  *       set.  In order to don't have any old session cookie set, you need to
2206  *       don't call ecore_con_url_cookies_file_add() ever on the @p url_con
2207  *       handler, and call this function to clear any session cookie set by a
2208  *       previous request on this handler. An easier way to don't use old
2209  *       session cookies is by using the function
2210  *       ecore_con_url_cookies_ignore_old_session_set().
2211  *
2212  * @see ecore_con_url_cookies_clear()
2213  * @see ecore_con_url_cookies_ignore_old_session_set()
2214  */
2215 EAPI void              ecore_con_url_cookies_session_clear(Ecore_Con_Url *url_con);
2216 /**
2217  * @brief Adds a file to the list of files from which to load cookies.
2218  *
2219  * @param url_con   Ecore_Con_Url instance which will be acted upon.
2220  * @param file_name Name of the file that will be added to the list.
2221  *
2222  * Files must contain cookies defined according to two possible formats:
2223  *
2224  * @li HTTP-style header ("Set-Cookie: ...").
2225  * @li <a href="http://www.cookiecentral.com/faq/#3.5">Netscape/Mozilla cookie data format.</a>
2226  *
2227  * Cookies will only be @b read from this file. If you want to save cookies to a
2228  * file, use ecore_con_url_cookies_jar_file_set(). Also notice that this
2229  * function supports the both types of cookie file cited above, while
2230  * ecore_con_url_cookies_jar_file_set() will save only in the Netscape/Mozilla's
2231  * format.
2232  *
2233  * Please notice that the file will not be read immediately, but rather added
2234  * to a list of files that will be loaded and parsed at a later time.
2235  *
2236  * @note This function will initialize the cookie engine if it has not been
2237  *       initialized yet.
2238  *
2239  * @see ecore_con_url_cookies_ignore_old_session_set()
2240  * @see ecore_con_url_cookies_jar_file_set()
2241  */
2242 EAPI void              ecore_con_url_cookies_file_add(Ecore_Con_Url *url_con,
2243                                                       const char * const file_name);
2244 /**
2245  * @brief Sets the name of the file to which all current cookies will be written when
2246  * either cookies are flushed or Ecore_Con is shut down.
2247  *
2248  * @param url_con        Ecore_Con_Url instance which will be acted upon.
2249  * @param cookiejar_file File to which the cookies will be written.
2250  *
2251  * @return @c EINA_TRUE is the file name has been set successfully,
2252  *         @c EINA_FALSE otherwise.
2253  *
2254  * Cookies are written following Netscape/Mozilla's data format, also known as
2255  * cookie-jar.
2256  *
2257  * Cookies will only be @b saved to this file. If you need to read cookies from
2258  * a file, use ecore_con_url_cookies_file_add() instead.
2259  *
2260  * @note This function will initialize the cookie engine if it has not been
2261  *       initialized yet.
2262  *
2263  * @see ecore_con_url_cookies_jar_write()
2264  */
2265 EAPI Eina_Bool         ecore_con_url_cookies_jar_file_set(Ecore_Con_Url *url_con,
2266                                                           const char * const cookiejar_file);
2267 /**
2268  * @brief Writes all current cookies to the cookie jar immediately.
2269  *
2270  * @param url_con Ecore_Con_Url instance which will be acted upon.
2271  *
2272  * A cookie-jar file must have been previously set by
2273  * @c ecore_con_url_jar_file_set, otherwise nothing will be done.
2274  *
2275  * @note This function will initialize the cookie engine if it has not been
2276  *       initialized yet.
2277  *
2278  * @see ecore_con_url_cookies_jar_file_set()
2279  */
2280 EAPI void              ecore_con_url_cookies_jar_write(Ecore_Con_Url *url_con);
2281 
2282 /**
2283  * Toggle libcurl's verify peer's certificate option.
2284  *
2285  * If @p verify is @c EINA_TRUE, libcurl will verify
2286  * the authenticity of the peer's certificate, otherwise
2287  * it will not. Default behavior of libcurl is to check
2288  * peer's certificate.
2289  *
2290  * @param url_con Ecore_Con_Url instance which will be acted upon.
2291  * @param verify Whether or not libcurl will check peer's certificate.
2292  * @since 1.1.0
2293  */
2294 EAPI void              ecore_con_url_ssl_verify_peer_set(Ecore_Con_Url *url_con,
2295                                                          Eina_Bool verify);
2296 /**
2297  * Set a custom CA to trust for SSL/TLS connections.
2298  *
2299  * Specify the path of a file (in PEM format) containing one or more
2300  * CA certificate(s) to use for the validation of the server certificate.
2301  *
2302  * This function can also disable CA validation if @p ca_path is @c NULL.
2303  * However, the server certificate still needs to be valid for the connection
2304  * to succeed (i.e., the certificate must concern the server the
2305  * connection is made to).
2306  *
2307  * @param url_con Connection object that will use the custom CA.
2308  * @param ca_path Path to a CA certificate(s) file or @c NULL to disable
2309  *                CA validation.
2310  *
2311  * @return  @c 0 on success. When cURL is used, non-zero return values
2312  *          are equal to cURL error codes.
2313  */
2314 EAPI int               ecore_con_url_ssl_ca_set(Ecore_Con_Url *url_con,
2315                                                 const char *ca_path);
2316 
2317 /**
2318  * @brief Sets HTTP proxy to use.
2319  *
2320  * The parameter should be a char * to a zero terminated string holding
2321  * the host name or dotted IP address. To specify port number in this string,
2322  * append :[port] to the end of the host name.
2323  * The proxy string may be prefixed with [protocol]:// since any such prefix
2324  * will be ignored.
2325  * The proxy's port number may optionally be specified with the separate option.
2326  * If not specified, libcurl will default to using port 1080 for proxies.
2327  *
2328  * @param url_con Connection object that will use the proxy.
2329  * @param proxy Proxy string or @c NULL to disable
2330  *
2331  * @return @c EINA_TRUE on success, @c EINA_FALSE on error.
2332  * @since 1.2
2333  */
2334 EAPI Eina_Bool ecore_con_url_proxy_set(Ecore_Con_Url *url_con, const char *proxy);
2335 
2336 /**
2337  * @brief Sets zero terminated username to use for proxy.
2338  *
2339  * If socks protocol is used for proxy, protocol should be socks5 and above.
2340  *
2341  * @param url_con Connection object that will use the proxy.
2342  * @param username Username string.
2343  *
2344  * @return @c EINA_TRUE on success, @c EINA_FALSE on error.
2345  *
2346  * @see ecore_con_url_proxy_set()
2347  *
2348  * @since 1.2
2349  */
2350 EAPI Eina_Bool ecore_con_url_proxy_username_set(Ecore_Con_Url *url_con, const char *username);
2351 
2352 /**
2353  * @brief Sets zero terminated password to use for proxy.
2354  *
2355  * If socks protocol is used for proxy, protocol should be socks5 and above.
2356  *
2357  * @param url_con Connection object that will use the proxy.
2358  * @param password Password string.
2359  *
2360  * @return @c EINA_TRUE on success, @c EINA_FALSE on error.
2361  *
2362  * @see ecore_con_url_proxy_set()
2363  *
2364  * @since 1.2
2365  */
2366 EAPI Eina_Bool ecore_con_url_proxy_password_set(Ecore_Con_Url *url_con, const char *password);
2367 
2368 /**
2369  * @brief Sets timeout in seconds.
2370  *
2371  * The maximum time in seconds that you allow the ecore con url transfer
2372  * operation to take. Normally, name lookups can take a considerable time
2373  * and limiting operations to less than a few minutes risk aborting perfectly
2374  * normal operations.
2375  *
2376  * @param url_con Connection object that will use the timeout.
2377  * @param timeout time in seconds.
2378  *
2379  * @see ecore_con_url_cookies_jar_file_set()
2380  *
2381  * @since 1.2
2382  */
2383 EAPI void ecore_con_url_timeout_set(Ecore_Con_Url *url_con, double timeout);
2384 
2385 /**
2386  * @brief Gets the returned HTTP STATUS code.
2387  *
2388  * This is used to, at any time, try to return the status code for a transmission.
2389  * @param url_con Connection object
2390  * @return A valid HTTP STATUS code, or 0 on failure
2391  *
2392  * @since 1.2
2393  */
2394 EAPI int ecore_con_url_status_code_get(Ecore_Con_Url *url_con);
2395 
2396 /**
2397  * @brief Sets a maximum upload speed.
2398  *
2399  * @param url_obj Connection object
2400  * @param max_speed Maximum upload speed, in bytes per second
2401  */
2402 EAPI void ecore_con_url_limit_upload_speed(Ecore_Con_Url *url_obj, off_t max_speed);
2403 
2404 /**
2405  * @brief Sets a maximum download speed.
2406  *
2407  * @param url_obj Connection object
2408  * @param max_speed Maximum download speed, in bytes per second
2409  */
2410 EAPI void ecore_con_url_limit_download_speed(Ecore_Con_Url *url_obj, off_t max_speed);
2411 
2412 /**
2413  * @}
2414  */
2415 
2416 #ifdef __cplusplus
2417 }
2418 #endif
2419 
2420 #undef EAPI
2421 #define EAPI
2422 
2423 #endif
2424