2003-09-23 01:09:32 -07:00
|
|
|
#ifndef _ECORE_CON_H
|
|
|
|
#define _ECORE_CON_H
|
|
|
|
|
2009-01-31 10:33:39 -08:00
|
|
|
#include <time.h>
|
|
|
|
#include <libgen.h>
|
2010-02-24 09:52:54 -08:00
|
|
|
#ifdef _WIN32
|
|
|
|
# include <ws2tcpip.h>
|
|
|
|
#else
|
2009-01-31 10:33:39 -08:00
|
|
|
# include <netdb.h>
|
|
|
|
#endif
|
2010-01-15 13:47:27 -08:00
|
|
|
#include <Eina.h>
|
2009-01-31 10:33:39 -08:00
|
|
|
|
2004-11-24 21:18:31 -08:00
|
|
|
#ifdef EAPI
|
2009-01-31 10:33:39 -08:00
|
|
|
# undef EAPI
|
2004-11-24 21:18:31 -08:00
|
|
|
#endif
|
2009-01-31 10:33:39 -08:00
|
|
|
|
2011-05-14 10:52:30 -07:00
|
|
|
#ifdef _WIN32
|
|
|
|
# ifdef EFL_ECORE_CON_BUILD
|
|
|
|
# ifdef DLL_EXPORT
|
|
|
|
# define EAPI __declspec(dllexport)
|
|
|
|
# else
|
|
|
|
# define EAPI
|
|
|
|
# endif
|
2004-11-24 21:18:31 -08:00
|
|
|
# else
|
|
|
|
# define EAPI __declspec(dllimport)
|
|
|
|
# endif
|
|
|
|
#else
|
2005-12-27 09:17:31 -08:00
|
|
|
# ifdef __GNUC__
|
|
|
|
# if __GNUC__ >= 4
|
|
|
|
# define EAPI __attribute__ ((visibility("default")))
|
|
|
|
# else
|
|
|
|
# define EAPI
|
|
|
|
# endif
|
2004-11-24 21:18:31 -08:00
|
|
|
# else
|
|
|
|
# define EAPI
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2004-04-29 20:10:17 -07:00
|
|
|
/**
|
2010-09-20 23:49:07 -07:00
|
|
|
* @defgroup Ecore_Con_Group Ecore_Con - Connection functions
|
2004-09-22 21:58:16 -07:00
|
|
|
*
|
|
|
|
* The Ecore Connection Library ( @c Ecore_Con ) provides simple mechanisms
|
|
|
|
* for communications between programs using reliable sockets. It saves
|
2010-09-08 04:23:42 -07:00
|
|
|
* the programmer from having to worry about file descriptors and waiting
|
2004-09-22 21:58:16 -07:00
|
|
|
* for incoming connections.
|
|
|
|
*
|
|
|
|
* There are two main objects in the @c Ecore_Con library: the @c
|
|
|
|
* Ecore_Con_Server and the @c Ecore_Con_Client.
|
|
|
|
*
|
2008-10-09 05:30:19 -07:00
|
|
|
* The @c Ecore_Con_Server represents a server that can be connected to.
|
|
|
|
* It is used regardless of whether the program is acting as a server or
|
2007-11-30 00:10:37 -08:00
|
|
|
* client itself.
|
2004-09-22 21:58:16 -07:00
|
|
|
*
|
2010-07-26 18:00:24 -07:00
|
|
|
* To create a listening server call @c ecore_con_server_add(), optionally using
|
|
|
|
* an ECORE_CON_USE_* encryption type OR'ed with the type for encryption.
|
2004-09-22 21:58:16 -07:00
|
|
|
*
|
2005-02-17 09:15:22 -08:00
|
|
|
* To connect to a server, call @c ecore_con_server_connect(). Data can
|
2004-09-22 21:58:16 -07:00
|
|
|
* then be sent to the server using the @c ecore_con_server_send().
|
2010-09-20 23:49:07 -07:00
|
|
|
*
|
2004-09-22 21:58:16 -07:00
|
|
|
* Functions are described in the following groupings:
|
|
|
|
* @li @ref Ecore_Con_Lib_Group
|
|
|
|
* @li @ref Ecore_Con_Server_Group
|
|
|
|
* @li @ref Ecore_Con_Client_Group
|
2008-02-11 15:24:11 -08:00
|
|
|
* @li @ref Ecore_Con_Url_Group
|
2010-07-28 18:28:18 -07:00
|
|
|
*
|
|
|
|
* Events are described in @ref Ecore_Con_Events_Group.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2012-04-02 16:47:00 -07:00
|
|
|
* @defgroup Ecore_Con_Events_Group Ecore Connection Events Functions
|
2010-09-22 01:03:38 -07:00
|
|
|
*
|
|
|
|
* @li ECORE_CON_CLIENT_ADD: Whenever a client connection is made to an
|
|
|
|
* @c Ecore_Con_Server, an event of this type is emitted, allowing the
|
|
|
|
* retrieval of the client's ip with @ref ecore_con_client_ip_get and
|
2010-07-28 18:28:18 -07:00
|
|
|
* associating data with the client using ecore_con_client_data_set.
|
2010-09-20 13:33:50 -07:00
|
|
|
* @li ECORE_CON_EVENT_CLIENT_DEL: Whenever a client connection to an
|
2010-07-28 18:28:18 -07:00
|
|
|
* @c Ecore_Con_Server, an event of this type is emitted. The contents of
|
|
|
|
* the data with this event are variable, but if the client object in the data
|
|
|
|
* is non-null, it must be freed with @ref ecore_con_client_del.
|
2010-09-20 13:33:50 -07:00
|
|
|
* @li ECORE_CON_EVENT_SERVER_ADD: Whenever a server object is created
|
2010-07-28 18:28:18 -07:00
|
|
|
* with @ref ecore_con_server_connect, an event of this type is emitted,
|
|
|
|
* allowing for data to be serialized and sent to the server using
|
|
|
|
* @ref ecore_con_server_send. At this point, the http handshake has
|
|
|
|
* occurred.
|
2010-09-20 13:33:50 -07:00
|
|
|
* @li ECORE_CON_EVENT_SERVER_DEL: Whenever a server object is destroyed,
|
2010-07-28 18:28:18 -07:00
|
|
|
* usually by the server connection being refused or dropped, an event of this
|
|
|
|
* type is emitted. The contents of the data with this event are variable,
|
|
|
|
* but if the server object in the data is non-null, it must be freed
|
|
|
|
* with @ref ecore_con_server_del.
|
2010-09-20 13:33:50 -07:00
|
|
|
* @li ECORE_CON_EVENT_CLIENT_DATA: Whenever a client connects to your server
|
2010-07-28 18:28:18 -07:00
|
|
|
* object and sends data, an event of this type is emitted. The data will contain both
|
|
|
|
* the size and contents of the message sent by the client. It should be noted that
|
|
|
|
* data within this object is transient, so it must be duplicated in order to be
|
|
|
|
* retained. This event will continue to occur until the client has stopped sending its
|
|
|
|
* message, so a good option for storing this data is an Eina_Strbuf. Once the message has
|
2010-09-20 13:33:50 -07:00
|
|
|
* been received in full, the client object must be freed with ecore_con_client_free.
|
|
|
|
* @li ECORE_CON_EVENT_SERVER_DATA: Whenever your server object connects to its destination
|
2010-07-28 18:28:18 -07:00
|
|
|
* and receives data, an event of this type is emitted. The data will contain both
|
|
|
|
* the size and contents of the message sent by the server. It should be noted that
|
|
|
|
* data within this object is transient, so it must be duplicated in order to be
|
|
|
|
* retained. This event will continue to occur until the server has stopped sending its
|
|
|
|
* message, so a good option for storing this data is an Eina_Strbuf. Once the message has
|
2010-09-20 13:33:50 -07:00
|
|
|
* been received in full, the server object must be freed with ecore_con_server_free.
|
2010-07-28 18:28:18 -07:00
|
|
|
*
|
2004-04-29 20:10:17 -07:00
|
|
|
*/
|
|
|
|
|
2011-08-08 02:40:36 -07:00
|
|
|
/**
|
2012-04-02 16:47:00 -07:00
|
|
|
* @defgroup Ecore_Con_Buffer Ecore Connection Buffering
|
2011-08-08 02:40:36 -07:00
|
|
|
*
|
|
|
|
* As Ecore_Con works on an event driven design, as data arrives, events will
|
|
|
|
* be produced containing the data that arrived. It is up to the user of
|
|
|
|
* Ecore_Con to either parse as they go, append to a file to later parse the
|
|
|
|
* whole file in one go, or append to memory to parse or handle leter.
|
|
|
|
*
|
|
|
|
* To help with this Eina has some handy API's. The Eina_Binbuf and
|
|
|
|
* Eina_Strbuf APIs, abstract dynamic buffer management and make it trivial
|
|
|
|
* to handle buffers at runtime, without having to manage them. Eina_Binbuf
|
|
|
|
* makes it possible to create, expand, reset and slice a blob of memory -
|
|
|
|
* all via API. No system calls, no pointer manipulations and no size
|
|
|
|
* calculation.
|
|
|
|
*
|
|
|
|
* Additional functions include adding content at specified byte positions in
|
|
|
|
* the buffer, escaping the inputs, find and replace strings. This provides
|
|
|
|
* extreme flexibility to play around, with a dynamic blob of memory.
|
|
|
|
*
|
|
|
|
* It is good to free it (using eina_binbuf_free()) after using it.
|
|
|
|
*
|
|
|
|
* Eina_Binbuf compliments Ecore_Con use cases, where dynamic sizes of data
|
|
|
|
* arrive from the network (think http download in chunks). Using
|
|
|
|
* Eina_Binbuf provides enough flexibility to handle data as it arrives and
|
|
|
|
* to defer its processing until desired, without having to think about
|
|
|
|
* where to store the temporary data and how to manage its size.
|
|
|
|
*
|
|
|
|
* An example of how to use these with Ecore_Con follows.
|
|
|
|
*
|
|
|
|
* @code
|
|
|
|
* #include <Eina.h>
|
|
|
|
* #include <Ecore.h>
|
|
|
|
* #include <Ecore_Con.h>
|
|
|
|
*
|
|
|
|
* static Eina_Bool
|
|
|
|
* data_callback(void *data, int type, void *event)
|
|
|
|
* {
|
|
|
|
* Ecore_Con_Event_Url_Data *url_data = event;
|
|
|
|
* if ( url_data->size > 0)
|
|
|
|
* {
|
|
|
|
* // append data as it arrives - don't worry where or how it gets stored.
|
|
|
|
* // Also don't worry about size, expanding, reallocing etc.
|
|
|
|
* // just keep appending - size is automatically handled.
|
|
|
|
*
|
|
|
|
* eina_binbuf_append_length(data, url_data->data, url_data->size);
|
|
|
|
*
|
|
|
|
* fprintf(stderr, "Appended %d \n", url_data->size);
|
|
|
|
* }
|
|
|
|
* return EINA_TRUE;
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* static Eina_Bool
|
|
|
|
* completion_callback(void *data, int type, void *event)
|
|
|
|
* {
|
|
|
|
* Ecore_Con_Event_Url_Complete *url_complete = event;
|
|
|
|
* printf("download completed with status code: %d\n", url_complete->status);
|
|
|
|
*
|
|
|
|
* // get the data back from Eina_Binbuf
|
|
|
|
* char *ptr = eina_binbuf_string_get(data);
|
|
|
|
* size_t size = eina_binbuf_length_get(data);
|
|
|
|
*
|
|
|
|
* // process data as required (write to file)
|
|
|
|
* fprintf(stderr, "Size of data = %d bytes\n", size);
|
|
|
|
* int fd = open("./elm.png", O_CREAT);
|
|
|
|
* write(fd, ptr, size);
|
|
|
|
* close(fd);
|
|
|
|
*
|
|
|
|
* // free it when done.
|
|
|
|
* eina_binbuf_free(data);
|
|
|
|
*
|
|
|
|
* ecore_main_loop_quit();
|
|
|
|
*
|
|
|
|
* return EINA_TRUE;
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* int
|
|
|
|
* main(int argc, char **argv)
|
|
|
|
* {
|
|
|
|
*
|
|
|
|
* const char *url = "http://www.enlightenment.org/p/index/d/logo.png";
|
|
|
|
*
|
|
|
|
* ecore_init();
|
|
|
|
* ecore_con_init();
|
|
|
|
* ecore_con_url_init();
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* // This is single additional line to manage dynamic network data.
|
|
|
|
* Eina_Binbuf *data = eina_binbuf_new();
|
|
|
|
* Ecore_Con_Url *url_con = ecore_con_url_new(url);
|
|
|
|
*
|
|
|
|
* ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE,
|
|
|
|
* completion_callback,
|
|
|
|
* data);
|
|
|
|
* ecore_event_handler_add(ECORE_CON_EVENT_URL_DATA,
|
|
|
|
* data_callback,
|
|
|
|
* data);
|
|
|
|
* ecore_con_url_get(url_con);
|
|
|
|
*
|
|
|
|
* ecore_main_loop_begin();
|
|
|
|
* return 0;
|
|
|
|
* }
|
|
|
|
* @endcode
|
|
|
|
*/
|
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2010-09-20 23:49:07 -07:00
|
|
|
#define ECORE_CON_USE_SSL ECORE_CON_USE_SSL2
|
|
|
|
#define ECORE_CON_REMOTE_SYSTEM ECORE_CON_REMOTE_TCP
|
|
|
|
|
2008-10-09 05:30:19 -07:00
|
|
|
|
2010-09-20 23:49:07 -07:00
|
|
|
/**
|
|
|
|
* @typedef Ecore_Con_Server
|
2010-07-28 18:28:18 -07:00
|
|
|
* A connection handle to a server
|
2010-09-20 23:49:07 -07:00
|
|
|
* @ingroup Ecore_Con_Server_Group
|
2010-07-28 18:28:18 -07:00
|
|
|
*/
|
|
|
|
typedef struct _Ecore_Con_Server Ecore_Con_Server;
|
2008-10-09 05:30:19 -07:00
|
|
|
|
2010-07-26 18:00:24 -07:00
|
|
|
/**
|
2010-09-20 23:49:07 -07:00
|
|
|
* @typedef Ecore_Con_Client
|
|
|
|
* A connection handle to a client
|
|
|
|
* @ingroup Ecore_Con_Client_Group
|
2010-07-26 18:00:24 -07:00
|
|
|
*/
|
2010-09-20 23:49:07 -07:00
|
|
|
typedef struct _Ecore_Con_Client Ecore_Con_Client;
|
2008-10-09 05:30:19 -07:00
|
|
|
|
2011-12-05 19:32:16 -08:00
|
|
|
/**
|
|
|
|
* @typedef Ecore_Con_Socks
|
|
|
|
* An object representing a SOCKS proxy
|
|
|
|
* @ingroup Ecore_Con_Socks_Group
|
2011-12-05 21:20:13 -08:00
|
|
|
* @since 1.2
|
2011-12-05 19:32:16 -08:00
|
|
|
*/
|
|
|
|
typedef struct Ecore_Con_Socks Ecore_Con_Socks;
|
|
|
|
|
2010-07-26 18:00:24 -07:00
|
|
|
/**
|
2010-09-20 23:49:07 -07:00
|
|
|
* @typedef Ecore_Con_Url
|
|
|
|
* A handle to an http upload/download object
|
|
|
|
* @ingroup Ecore_Con_Url_Group
|
2010-07-26 18:00:24 -07:00
|
|
|
*/
|
2010-09-20 23:49:07 -07:00
|
|
|
typedef struct _Ecore_Con_Url Ecore_Con_Url;
|
2007-09-26 09:01:04 -07:00
|
|
|
|
2010-07-26 23:30:27 -07:00
|
|
|
|
2010-07-28 18:28:18 -07:00
|
|
|
/**
|
|
|
|
* @addtogroup Ecore_Con_Events_Group Events
|
|
|
|
* @{
|
2010-07-29 05:29:19 -07:00
|
|
|
*/
|
|
|
|
|
2010-10-11 23:34:31 -07:00
|
|
|
/**
|
|
|
|
* @typedef Ecore_Con_Event_Client_Add
|
2010-07-28 18:28:18 -07:00
|
|
|
* Used as the @p data param for the corresponding event
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
typedef struct _Ecore_Con_Event_Client_Add Ecore_Con_Event_Client_Add;
|
2010-10-11 23:34:31 -07:00
|
|
|
|
2011-06-15 11:58:34 -07:00
|
|
|
/**
|
|
|
|
* @typedef Ecore_Con_Event_Client_Upgrade
|
|
|
|
* Used as the @p data param for the corresponding event
|
2011-06-15 14:57:47 -07:00
|
|
|
* @since 1.1
|
2011-06-15 11:58:34 -07:00
|
|
|
*/
|
|
|
|
typedef struct _Ecore_Con_Event_Client_Upgrade Ecore_Con_Event_Client_Upgrade;
|
|
|
|
|
2010-10-11 23:34:31 -07:00
|
|
|
/**
|
|
|
|
* @typedef Ecore_Con_Event_Client_Del
|
2010-07-28 18:28:18 -07:00
|
|
|
* Used as the @p data param for the corresponding event
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
typedef struct _Ecore_Con_Event_Client_Del Ecore_Con_Event_Client_Del;
|
2010-10-11 23:34:31 -07:00
|
|
|
|
2011-02-10 00:49:23 -08:00
|
|
|
/**
|
|
|
|
* @typedef Ecore_Con_Event_Client_Error
|
|
|
|
* Used as the @p data param for the corresponding event
|
2011-09-13 15:46:46 -07:00
|
|
|
* @since 1.1
|
2011-02-10 00:49:23 -08:00
|
|
|
*/
|
|
|
|
typedef struct _Ecore_Con_Event_Client_Error Ecore_Con_Event_Client_Error;
|
|
|
|
|
2010-10-11 23:34:31 -07:00
|
|
|
/**
|
|
|
|
* @typedef Ecore_Con_Event_Server_Add
|
2010-07-28 18:28:18 -07:00
|
|
|
* Used as the @p data param for the corresponding event
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
typedef struct _Ecore_Con_Event_Server_Add Ecore_Con_Event_Server_Add;
|
2010-10-11 23:34:31 -07:00
|
|
|
|
2011-06-15 11:58:34 -07:00
|
|
|
/**
|
|
|
|
* @typedef Ecore_Con_Event_Server_Upgrade
|
|
|
|
* Used as the @p data param for the corresponding event
|
2011-06-15 14:57:47 -07:00
|
|
|
* @since 1.1
|
2011-06-15 11:58:34 -07:00
|
|
|
*/
|
|
|
|
typedef struct _Ecore_Con_Event_Server_Upgrade Ecore_Con_Event_Server_Upgrade;
|
|
|
|
|
2010-10-11 23:34:31 -07:00
|
|
|
/**
|
|
|
|
* @typedef Ecore_Con_Event_Server_Del
|
2010-07-28 18:28:18 -07:00
|
|
|
* Used as the @p data param for the corresponding event
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
typedef struct _Ecore_Con_Event_Server_Del Ecore_Con_Event_Server_Del;
|
2010-10-11 23:34:31 -07:00
|
|
|
|
2011-02-10 00:49:23 -08:00
|
|
|
/**
|
|
|
|
* @typedef Ecore_Con_Event_Server_Error
|
|
|
|
* Used as the @p data param for the corresponding event
|
2011-09-13 15:46:46 -07:00
|
|
|
* @since 1.1
|
2011-02-10 00:49:23 -08:00
|
|
|
*/
|
|
|
|
typedef struct _Ecore_Con_Event_Server_Error Ecore_Con_Event_Server_Error;
|
|
|
|
|
2010-10-11 23:34:31 -07:00
|
|
|
/**
|
|
|
|
* @typedef Ecore_Con_Event_Client_Data
|
2010-07-28 18:28:18 -07:00
|
|
|
* Used as the @p data param for the corresponding event
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
typedef struct _Ecore_Con_Event_Client_Data Ecore_Con_Event_Client_Data;
|
2010-10-11 23:34:31 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef Ecore_Con_Event_Server_Data
|
2010-07-28 18:28:18 -07:00
|
|
|
* Used as the @p data param for the corresponding event
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
typedef struct _Ecore_Con_Event_Server_Data Ecore_Con_Event_Server_Data;
|
2010-10-11 23:34:31 -07:00
|
|
|
|
2011-09-13 16:03:26 -07:00
|
|
|
/**
|
|
|
|
* @typedef Ecore_Con_Event_Client_Write
|
|
|
|
* Used as the @p data param for the corresponding event
|
|
|
|
* @since 1.1
|
|
|
|
*/
|
|
|
|
typedef struct _Ecore_Con_Event_Client_Write Ecore_Con_Event_Client_Write;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef Ecore_Con_Event_Server_Write
|
|
|
|
* Used as the @p data param for the corresponding event
|
|
|
|
* @since 1.1
|
|
|
|
*/
|
|
|
|
typedef struct _Ecore_Con_Event_Server_Write Ecore_Con_Event_Server_Write;
|
|
|
|
|
2011-12-05 19:32:16 -08:00
|
|
|
/**
|
|
|
|
* @typedef Ecore_Con_Event_Proxy_Bind
|
|
|
|
* Used as the @p data param for the corresponding event
|
|
|
|
* @since 1.2
|
|
|
|
*/
|
|
|
|
typedef struct _Ecore_Con_Event_Proxy_Bind Ecore_Con_Event_Proxy_Bind;
|
|
|
|
|
2010-10-11 23:34:31 -07:00
|
|
|
/**
|
|
|
|
* @typedef Ecore_Con_Event_Url_Data
|
2010-07-28 18:28:18 -07:00
|
|
|
* Used as the @p data param for the corresponding event
|
2011-07-08 11:06:04 -07:00
|
|
|
* @ingroup Ecore_Con_Url_Group
|
2010-07-28 18:28:18 -07:00
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
typedef struct _Ecore_Con_Event_Url_Data Ecore_Con_Event_Url_Data;
|
2010-10-11 23:34:31 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef Ecore_Con_Event_Url_Complete
|
2010-07-28 18:28:18 -07:00
|
|
|
* Used as the @p data param for the corresponding event
|
2011-07-08 11:06:04 -07:00
|
|
|
* @ingroup Ecore_Con_Url_Group
|
2010-07-28 18:28:18 -07:00
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
typedef struct _Ecore_Con_Event_Url_Complete Ecore_Con_Event_Url_Complete;
|
2010-10-11 23:34:31 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef Ecore_Con_Event_Url_Progress
|
2010-07-28 18:28:18 -07:00
|
|
|
* Used as the @p data param for the corresponding event
|
2011-07-08 11:06:04 -07:00
|
|
|
* @ingroup Ecore_Con_Url_Group
|
2010-07-28 18:28:18 -07:00
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
typedef struct _Ecore_Con_Event_Url_Progress Ecore_Con_Event_Url_Progress;
|
|
|
|
|
2010-07-28 18:28:18 -07:00
|
|
|
/**
|
|
|
|
* @struct _Ecore_Con_Event_Client_Add
|
|
|
|
* Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_ADD event
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
struct _Ecore_Con_Event_Client_Add
|
|
|
|
{
|
2010-07-28 18:28:18 -07:00
|
|
|
Ecore_Con_Client *client; /** the client that connected */
|
2010-07-26 23:30:27 -07:00
|
|
|
};
|
|
|
|
|
2011-06-15 11:58:34 -07:00
|
|
|
/**
|
|
|
|
* @struct _Ecore_Con_Event_Client_Upgrade
|
|
|
|
* Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_UPGRADE event
|
2011-06-15 14:57:47 -07:00
|
|
|
* @since 1.1
|
2011-06-15 11:58:34 -07:00
|
|
|
*/
|
|
|
|
struct _Ecore_Con_Event_Client_Upgrade
|
|
|
|
{
|
|
|
|
Ecore_Con_Client *client; /** the client that completed handshake */
|
|
|
|
};
|
|
|
|
|
2010-07-28 18:28:18 -07:00
|
|
|
/**
|
|
|
|
* @struct _Ecore_Con_Event_Client_Del
|
|
|
|
* Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_DEL event
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
struct _Ecore_Con_Event_Client_Del
|
|
|
|
{
|
2010-07-28 18:28:18 -07:00
|
|
|
Ecore_Con_Client *client; /** the client that was lost */
|
2010-07-26 23:30:27 -07:00
|
|
|
};
|
|
|
|
|
2011-02-10 00:49:23 -08:00
|
|
|
/**
|
|
|
|
* @struct _Ecore_Con_Event_Client_Error
|
|
|
|
* Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_ERROR event
|
|
|
|
*/
|
|
|
|
struct _Ecore_Con_Event_Client_Error
|
|
|
|
{
|
|
|
|
Ecore_Con_Client *client; /** the client for which an error occurred */
|
|
|
|
char *error; /**< the error string describing what happened */
|
|
|
|
};
|
|
|
|
|
2010-07-28 18:28:18 -07:00
|
|
|
/**
|
|
|
|
* @struct _Ecore_Con_Event_Server_Add
|
|
|
|
* Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_ADD event
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
struct _Ecore_Con_Event_Server_Add
|
|
|
|
{
|
2010-07-28 18:28:18 -07:00
|
|
|
Ecore_Con_Server *server; /** the server that was connected to */
|
2010-07-26 23:30:27 -07:00
|
|
|
};
|
|
|
|
|
2011-06-15 11:58:34 -07:00
|
|
|
/**
|
|
|
|
* @struct _Ecore_Con_Event_Server_Upgrade
|
|
|
|
* Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_UPGRADE event
|
2011-06-15 14:57:47 -07:00
|
|
|
* @since 1.1
|
2011-06-15 11:58:34 -07:00
|
|
|
*/
|
|
|
|
struct _Ecore_Con_Event_Server_Upgrade
|
|
|
|
{
|
|
|
|
Ecore_Con_Server *server; /** the server that was connected to */
|
|
|
|
};
|
|
|
|
|
2010-07-28 18:28:18 -07:00
|
|
|
/**
|
|
|
|
* @struct _Ecore_Con_Event_Server_Del
|
|
|
|
* Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_DEL event
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
struct _Ecore_Con_Event_Server_Del
|
|
|
|
{
|
2010-07-28 18:28:18 -07:00
|
|
|
Ecore_Con_Server *server; /** the client that was lost */
|
2010-07-26 23:30:27 -07:00
|
|
|
};
|
|
|
|
|
2011-02-10 00:49:23 -08:00
|
|
|
/**
|
|
|
|
* @struct _Ecore_Con_Event_Server_Error
|
|
|
|
* Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_ERROR event
|
|
|
|
*/
|
|
|
|
struct _Ecore_Con_Event_Server_Error
|
|
|
|
{
|
|
|
|
Ecore_Con_Server *server; /** the server for which an error occurred */
|
|
|
|
char *error; /**< the error string describing what happened */
|
|
|
|
};
|
|
|
|
|
2010-07-28 18:28:18 -07:00
|
|
|
/**
|
|
|
|
* @struct _Ecore_Con_Event_Client_Data
|
|
|
|
* Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_DATA event
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
struct _Ecore_Con_Event_Client_Data
|
|
|
|
{
|
2010-10-11 23:34:31 -07:00
|
|
|
Ecore_Con_Client *client; /**< the client that connected */
|
|
|
|
void *data; /**< the data that the client sent */
|
|
|
|
int size; /**< the length of the data sent */
|
2010-07-26 23:30:27 -07:00
|
|
|
};
|
|
|
|
|
2010-07-28 18:28:18 -07:00
|
|
|
/**
|
|
|
|
* @struct _Ecore_Con_Event_Server_Data
|
|
|
|
* Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_DATA event
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
struct _Ecore_Con_Event_Server_Data
|
|
|
|
{
|
2010-10-11 23:34:31 -07:00
|
|
|
Ecore_Con_Server *server; /**< the server that was connected to */
|
|
|
|
void *data; /**< the data that the server sent */
|
|
|
|
int size; /**< the length of the data sent */
|
2010-07-26 23:30:27 -07:00
|
|
|
};
|
|
|
|
|
2011-09-13 16:03:26 -07:00
|
|
|
/**
|
|
|
|
* @struct _Ecore_Con_Event_Client_Write
|
|
|
|
* Used as the @p data param for the @ref ECORE_CON_EVENT_CLIENT_WRITE event
|
|
|
|
*/
|
|
|
|
struct _Ecore_Con_Event_Client_Write
|
|
|
|
{
|
|
|
|
Ecore_Con_Client *client; /**< the client that connected */
|
|
|
|
int size; /**< the length of the data sent */
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @struct _Ecore_Con_Event_Server_Write
|
|
|
|
* Used as the @p data param for the @ref ECORE_CON_EVENT_SERVER_WRITE event
|
|
|
|
*/
|
|
|
|
struct _Ecore_Con_Event_Server_Write
|
|
|
|
{
|
|
|
|
Ecore_Con_Server *server; /**< the server that was connected to */
|
|
|
|
int size; /**< the length of the data sent */
|
|
|
|
};
|
|
|
|
|
2011-12-05 19:32:16 -08:00
|
|
|
/**
|
|
|
|
* @struct _Ecore_Con_Event_Proxy_Bind
|
|
|
|
* Used as the @p data param for the @ref ECORE_CON_EVENT_PROXY_BIND event
|
|
|
|
* @ingroup Ecore_Con_Socks_Group
|
2011-12-05 21:37:29 -08:00
|
|
|
* @since 1.2
|
2011-12-05 19:32:16 -08:00
|
|
|
*/
|
|
|
|
struct _Ecore_Con_Event_Proxy_Bind
|
|
|
|
{
|
|
|
|
Ecore_Con_Server *server; /**< the server object connected to the proxy */
|
|
|
|
const char *ip; /**< the proxy-bound ip address */
|
2011-12-22 23:04:36 -08:00
|
|
|
int port; /**< the proxy-bound port */
|
2011-12-05 19:32:16 -08:00
|
|
|
};
|
|
|
|
|
2010-07-28 18:28:18 -07:00
|
|
|
/**
|
|
|
|
* @struct _Ecore_Con_Event_Url_Data
|
|
|
|
* Used as the @p data param for the @ref ECORE_CON_EVENT_URL_DATA event
|
2011-07-08 11:06:04 -07:00
|
|
|
* @ingroup Ecore_Con_Url_Group
|
2010-07-28 18:28:18 -07:00
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
struct _Ecore_Con_Event_Url_Data
|
|
|
|
{
|
2011-07-08 11:06:04 -07:00
|
|
|
Ecore_Con_Url *url_con; /**< a pointer to the connection object */
|
|
|
|
int size; /**< the size of the current received data (in bytes) */
|
|
|
|
unsigned char data[1]; /**< the data received on this event */
|
2010-07-26 23:30:27 -07:00
|
|
|
};
|
|
|
|
|
2010-07-28 18:28:18 -07:00
|
|
|
/**
|
|
|
|
* @struct _Ecore_Con_Event_Url_Complete
|
|
|
|
* Used as the @p data param for the @ref ECORE_CON_EVENT_URL_COMPLETE event
|
2011-07-08 11:06:04 -07:00
|
|
|
* @ingroup Ecore_Con_Url_Group
|
2010-07-28 18:28:18 -07:00
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
struct _Ecore_Con_Event_Url_Complete
|
|
|
|
{
|
2011-07-08 11:06:04 -07:00
|
|
|
Ecore_Con_Url *url_con; /**< a pointer to the connection object */
|
|
|
|
int status; /**< HTTP status code of the operation (200, 404, 401, etc.) */
|
2010-07-26 23:30:27 -07:00
|
|
|
};
|
|
|
|
|
2010-07-28 18:28:18 -07:00
|
|
|
/**
|
|
|
|
* @struct _Ecore_Con_Event_Url_Progress
|
|
|
|
* Used as the @p data param for the @ref ECORE_CON_EVENT_URL_PROGRESS event
|
2011-07-08 11:06:04 -07:00
|
|
|
* @ingroup Ecore_Con_Url_Group
|
2010-07-28 18:28:18 -07:00
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
struct _Ecore_Con_Event_Url_Progress
|
|
|
|
{
|
2011-07-08 11:06:04 -07:00
|
|
|
Ecore_Con_Url *url_con; /**< a pointer to the connection object */
|
2010-07-26 23:30:27 -07:00
|
|
|
struct
|
|
|
|
{
|
2011-07-08 11:06:04 -07:00
|
|
|
double total; /**< total size of the downloading data (in bytes) */
|
|
|
|
double now; /**< current size of the downloading data (in bytes) */
|
|
|
|
} down; /**< download info */
|
2010-07-26 23:30:27 -07:00
|
|
|
struct
|
|
|
|
{
|
2011-07-08 11:06:04 -07:00
|
|
|
double total; /**< total size of the uploading data (in bytes) */
|
|
|
|
double now; /**< current size of the uploading data (in bytes) */
|
|
|
|
} up; /**< upload info */
|
2010-07-26 23:30:27 -07:00
|
|
|
};
|
|
|
|
|
2010-07-30 13:33:32 -07:00
|
|
|
/** A client has connected to the server */
|
|
|
|
EAPI extern int ECORE_CON_EVENT_CLIENT_ADD;
|
|
|
|
/** A client has disconnected from the server */
|
|
|
|
EAPI extern int ECORE_CON_EVENT_CLIENT_DEL;
|
2011-09-13 16:04:18 -07:00
|
|
|
/** A client experienced an error
|
|
|
|
* @since 1.1
|
|
|
|
*/
|
2011-02-10 00:49:23 -08:00
|
|
|
EAPI extern int ECORE_CON_EVENT_CLIENT_ERROR;
|
2011-06-15 14:57:47 -07:00
|
|
|
/** A client connection has been upgraded to SSL
|
|
|
|
* @since 1.1
|
|
|
|
*/
|
2011-06-15 11:58:34 -07:00
|
|
|
EAPI extern int ECORE_CON_EVENT_CLIENT_UPGRADE;
|
2010-07-30 13:33:32 -07:00
|
|
|
/** A server was created */
|
|
|
|
EAPI extern int ECORE_CON_EVENT_SERVER_ADD;
|
2010-09-22 01:03:38 -07:00
|
|
|
/** A server connection was lost */
|
2010-07-30 13:33:32 -07:00
|
|
|
EAPI extern int ECORE_CON_EVENT_SERVER_DEL;
|
2011-09-13 16:04:18 -07:00
|
|
|
/** A server experienced an error
|
|
|
|
* @since 1.1
|
|
|
|
*/
|
2011-02-10 00:49:23 -08:00
|
|
|
EAPI extern int ECORE_CON_EVENT_SERVER_ERROR;
|
2011-06-15 14:57:47 -07:00
|
|
|
/** A server connection has been upgraded to SSL
|
|
|
|
* @since 1.1
|
|
|
|
*/
|
2011-06-15 11:58:34 -07:00
|
|
|
EAPI extern int ECORE_CON_EVENT_SERVER_UPGRADE;
|
2011-09-13 16:03:26 -07:00
|
|
|
/** A server connection has sent data to its client
|
|
|
|
* @since 1.1
|
|
|
|
*/
|
|
|
|
EAPI extern int ECORE_CON_EVENT_CLIENT_WRITE;
|
|
|
|
/** A server connection object has sent data
|
|
|
|
* @since 1.1
|
|
|
|
*/
|
|
|
|
EAPI extern int ECORE_CON_EVENT_SERVER_WRITE;
|
2010-07-30 13:33:32 -07:00
|
|
|
/** A client connected to the server has sent data */
|
|
|
|
EAPI extern int ECORE_CON_EVENT_CLIENT_DATA;
|
|
|
|
/** A server connection object has data */
|
|
|
|
EAPI extern int ECORE_CON_EVENT_SERVER_DATA;
|
2011-12-05 19:32:16 -08:00
|
|
|
/** A server connection has successfully negotiated an ip:port binding
|
|
|
|
* @since 1.2
|
|
|
|
*/
|
|
|
|
EAPI extern int ECORE_CON_EVENT_PROXY_BIND;
|
2010-07-30 13:33:32 -07:00
|
|
|
/** A URL object has data */
|
|
|
|
EAPI extern int ECORE_CON_EVENT_URL_DATA;
|
|
|
|
/** A URL object has completed its transfer to and from the server and can be reused */
|
|
|
|
EAPI extern int ECORE_CON_EVENT_URL_COMPLETE;
|
|
|
|
/** A URL object has made progress in its transfer */
|
|
|
|
EAPI extern int ECORE_CON_EVENT_URL_PROGRESS;
|
2010-09-20 23:49:07 -07:00
|
|
|
|
2010-07-28 18:28:18 -07:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
2010-09-20 23:49:07 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @defgroup Ecore_Con_Lib_Group Ecore Connection Library Functions
|
|
|
|
*
|
2011-07-05 06:09:57 -07:00
|
|
|
* Utility functions that set up and shut down the Ecore Connection
|
|
|
|
* library.
|
|
|
|
*
|
|
|
|
* There's also ecore_con_lookup() that can be used to make simple asynchronous
|
|
|
|
* DNS lookups.
|
|
|
|
*
|
|
|
|
* A simple example of how to use these functions:
|
|
|
|
* @li @ref ecore_con_lookup_example_c
|
|
|
|
*
|
2010-09-20 23:49:07 -07:00
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef Ecore_Con_Dns_Cb
|
|
|
|
* A callback type for use with @ref ecore_con_lookup.
|
|
|
|
*/
|
|
|
|
typedef void (*Ecore_Con_Dns_Cb)(const char *canonname,
|
|
|
|
const char *ip,
|
|
|
|
struct sockaddr *addr,
|
|
|
|
int addrlen,
|
|
|
|
void *data);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef Ecore_Con_Type
|
|
|
|
* @enum _Ecore_Con_Type
|
|
|
|
* Types for an ecore_con client/server object. A correct way to set this type is
|
|
|
|
* with an ECORE_CON_$TYPE, optionally OR'ed with an ECORE_CON_$USE if encryption is desired,
|
|
|
|
* and LOAD_CERT if the previously loaded certificate should be used.
|
|
|
|
* @code
|
|
|
|
* ECORE_CON_REMOTE_TCP | ECORE_CON_USE_TLS | ECORE_CON_LOAD_CERT
|
|
|
|
* @endcode
|
2011-07-12 07:37:32 -07:00
|
|
|
* @ingroup Ecore_Con_Server_Group
|
2010-09-20 23:49:07 -07:00
|
|
|
*/
|
|
|
|
typedef enum _Ecore_Con_Type
|
|
|
|
{
|
|
|
|
/** Socket in ~/.ecore */
|
|
|
|
ECORE_CON_LOCAL_USER = 0,
|
|
|
|
/** Socket in /tmp */
|
|
|
|
ECORE_CON_LOCAL_SYSTEM = 1,
|
|
|
|
/** Abstract socket */
|
|
|
|
ECORE_CON_LOCAL_ABSTRACT = 2,
|
|
|
|
/** Remote server using TCP */
|
|
|
|
ECORE_CON_REMOTE_TCP = 3,
|
|
|
|
/** Remote multicast server */
|
|
|
|
ECORE_CON_REMOTE_MCAST = 4,
|
|
|
|
/** Remote server using UDP */
|
|
|
|
ECORE_CON_REMOTE_UDP = 5,
|
|
|
|
/** Remote broadcast using UDP */
|
|
|
|
ECORE_CON_REMOTE_BROADCAST = 6,
|
2011-12-09 22:53:54 -08:00
|
|
|
/** Remote connection sending packets immediately */
|
2010-09-20 23:49:07 -07:00
|
|
|
ECORE_CON_REMOTE_NODELAY = 7,
|
2011-12-10 00:14:50 -08:00
|
|
|
/** Remote connection sending data in large chunks
|
2011-12-10 00:23:34 -08:00
|
|
|
* @note Only available on Linux
|
2011-12-10 00:14:50 -08:00
|
|
|
* @since 1.2
|
|
|
|
*/
|
|
|
|
ECORE_CON_REMOTE_CORK = 8,
|
2010-09-20 23:49:07 -07:00
|
|
|
/** Use SSL2: UNSUPPORTED. **/
|
|
|
|
ECORE_CON_USE_SSL2 = (1 << 4),
|
|
|
|
/** Use SSL3 */
|
|
|
|
ECORE_CON_USE_SSL3 = (1 << 5),
|
|
|
|
/** Use TLS */
|
|
|
|
ECORE_CON_USE_TLS = (1 << 6),
|
2010-09-21 18:26:23 -07:00
|
|
|
/** Use both TLS and SSL3 */
|
|
|
|
ECORE_CON_USE_MIXED = ECORE_CON_USE_SSL3 | ECORE_CON_USE_TLS,
|
2010-09-27 20:16:08 -07:00
|
|
|
/** Attempt to use the loaded certificate */
|
2010-09-20 23:49:07 -07:00
|
|
|
ECORE_CON_LOAD_CERT = (1 << 7)
|
|
|
|
} Ecore_Con_Type;
|
|
|
|
|
2011-07-05 06:09:57 -07:00
|
|
|
/**
|
|
|
|
* Initialises the Ecore_Con library.
|
|
|
|
* @return Number of times the library has been initialised without being
|
|
|
|
* shut down.
|
2011-07-08 11:06:19 -07:00
|
|
|
*
|
|
|
|
* @note This function already calls ecore_init() internally, so you don't need
|
|
|
|
* to call it explicitly.
|
2011-07-05 06:09:57 -07:00
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI int ecore_con_init(void);
|
2011-07-05 06:09:57 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shuts down the Ecore_Con library.
|
|
|
|
* @return Number of times the library has been initialised without being
|
|
|
|
* shut down.
|
2011-07-08 11:06:19 -07:00
|
|
|
* @note This function already calls ecore_shutdown() internally, so you don't
|
|
|
|
* need to call it explicitly unless you called ecore_init() explicitly too.
|
2011-07-05 06:09:57 -07:00
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI int ecore_con_shutdown(void);
|
2010-09-20 23:49:07 -07:00
|
|
|
|
2011-07-05 06:09:57 -07:00
|
|
|
/**
|
|
|
|
* Do an asynchronous DNS lookup.
|
|
|
|
*
|
|
|
|
* @param name IP address or server name to translate.
|
|
|
|
* @param done_cb Callback to notify when done.
|
|
|
|
* @param data User data to be given to done_cb.
|
2012-04-11 20:51:36 -07:00
|
|
|
* @return @c EINA_TRUE if the request did not fail to be set up, @c EINA_FALSE
|
|
|
|
* if it failed.
|
2011-07-05 06:09:57 -07:00
|
|
|
*
|
|
|
|
* This function performs a DNS lookup on the hostname specified by @p name,
|
|
|
|
* then calls @p done_cb with the result and the @p data given as parameter.
|
|
|
|
* The result will be given to the @p done_cb as follows:
|
|
|
|
* @li @c canonname - the canonical name of the address
|
|
|
|
* @li @c ip - the resolved ip address
|
|
|
|
* @li @c addr - a pointer to the socket address
|
|
|
|
* @li @c addrlen - the length of the socket address, in bytes
|
|
|
|
* @li @c data - the data pointer given as parameter to ecore_con_lookup()
|
|
|
|
*/
|
2010-09-20 23:49:07 -07:00
|
|
|
EAPI Eina_Bool ecore_con_lookup(const char *name,
|
|
|
|
Ecore_Con_Dns_Cb done_cb,
|
|
|
|
const void *data);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2010-09-27 20:16:08 -07:00
|
|
|
/**
|
|
|
|
* @defgroup Ecore_Con_SSL_Group Ecore Connection SSL Functions
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
EAPI int ecore_con_ssl_available_get(void);
|
|
|
|
EAPI Eina_Bool ecore_con_ssl_server_cert_add(Ecore_Con_Server *svr, const char *cert);
|
|
|
|
EAPI Eina_Bool ecore_con_ssl_server_privkey_add(Ecore_Con_Server *svr, const char *key_file);
|
|
|
|
EAPI Eina_Bool ecore_con_ssl_server_crl_add(Ecore_Con_Server *svr, const char *crl_file);
|
|
|
|
EAPI Eina_Bool ecore_con_ssl_server_cafile_add(Ecore_Con_Server *svr, const char *ca_file);
|
|
|
|
EAPI void ecore_con_ssl_server_verify(Ecore_Con_Server *svr);
|
2011-06-25 01:39:07 -07:00
|
|
|
EAPI void ecore_con_ssl_server_verify_basic(Ecore_Con_Server *svr);
|
2011-12-07 17:14:55 -08:00
|
|
|
EAPI void ecore_con_ssl_server_verify_name_set(Ecore_Con_Server *svr, const char *name);
|
|
|
|
EAPI const char *ecore_con_ssl_server_verify_name_get(Ecore_Con_Server *svr);
|
2011-06-15 11:58:34 -07:00
|
|
|
EAPI Eina_Bool ecore_con_ssl_server_upgrade(Ecore_Con_Server *svr, Ecore_Con_Type compl_type);
|
|
|
|
EAPI Eina_Bool ecore_con_ssl_client_upgrade(Ecore_Con_Client *cl, Ecore_Con_Type compl_type);
|
2010-09-27 20:16:08 -07:00
|
|
|
|
2010-10-11 23:34:31 -07:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
2010-09-27 20:16:08 -07:00
|
|
|
|
2011-12-05 19:32:16 -08:00
|
|
|
EAPI Ecore_Con_Socks *ecore_con_socks4_remote_add(const char *ip, int port, const char *username);
|
|
|
|
EAPI Eina_Bool ecore_con_socks4_remote_exists(const char *ip, int port, const char *username);
|
|
|
|
EAPI void ecore_con_socks4_remote_del(const char *ip, int port, const char *username);
|
2012-02-14 21:53:50 -08:00
|
|
|
EAPI Ecore_Con_Socks *ecore_con_socks5_remote_add(const char *ip, int port, const char *username, const char *password);
|
|
|
|
EAPI Eina_Bool ecore_con_socks5_remote_exists(const char *ip, int port, const char *username, const char *password);
|
|
|
|
EAPI void ecore_con_socks5_remote_del(const char *ip, int port, const char *username, const char *password);
|
|
|
|
EAPI void ecore_con_socks_lookup_set(Ecore_Con_Socks *ecs, Eina_Bool enable);
|
|
|
|
EAPI Eina_Bool ecore_con_socks_lookup_get(Ecore_Con_Socks *ecs);
|
2011-12-05 19:32:16 -08:00
|
|
|
EAPI void ecore_con_socks_bind_set(Ecore_Con_Socks *ecs, Eina_Bool is_bind);
|
|
|
|
EAPI Eina_Bool ecore_con_socks_bind_get(Ecore_Con_Socks *ecs);
|
|
|
|
EAPI unsigned int ecore_con_socks_version_get(Ecore_Con_Socks *ecs);
|
|
|
|
EAPI void ecore_con_socks_remote_del(Ecore_Con_Socks *ecs);
|
|
|
|
EAPI void ecore_con_socks_apply_once(Ecore_Con_Socks *ecs);
|
|
|
|
EAPI void ecore_con_socks_apply_always(Ecore_Con_Socks *ecs);
|
|
|
|
|
2010-09-20 23:49:07 -07:00
|
|
|
/**
|
|
|
|
* @defgroup Ecore_Con_Server_Group Ecore Connection Server Functions
|
|
|
|
*
|
2011-07-12 07:37:32 -07:00
|
|
|
* This group of functions is applied to an @ref Ecore_Con_Server object. It
|
|
|
|
* doesn't mean that they should be used in the server application, but on the
|
|
|
|
* server object. In fact, most of them should be used in the client
|
|
|
|
* application, when retrieving information or sending data.
|
|
|
|
*
|
|
|
|
* Setting up a server is very simple: you just need to start it with
|
|
|
|
* ecore_con_server_add() and setup some callbacks to the events
|
2012-03-05 06:59:59 -08:00
|
|
|
* @ref ECORE_CON_EVENT_CLIENT_ADD, @ref ECORE_CON_EVENT_CLIENT_DEL and
|
|
|
|
* @ref ECORE_CON_EVENT_CLIENT_DATA, that will be called when a client is
|
2011-07-12 07:37:32 -07:00
|
|
|
* communicating with the server:
|
|
|
|
*
|
|
|
|
* @code
|
|
|
|
* if (!(svr = ecore_con_server_add(ECORE_CON_REMOTE_TCP, "127.0.0.1", 8080, NULL)))
|
|
|
|
* exit(1);
|
|
|
|
*
|
|
|
|
* ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, _add_cb, NULL);
|
|
|
|
* ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, _del_cb, NULL);
|
|
|
|
* ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, _data_cb, NULL);
|
|
|
|
*
|
|
|
|
* ecore_main_loop_begin();
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
* The function ecore_con_server_connect() can be used to write a client that
|
|
|
|
* connects to a server. The resulting code will be very similar to the server
|
|
|
|
* code:
|
|
|
|
*
|
|
|
|
* @code
|
|
|
|
* if (!(svr = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, "127.0.0.1", 8080, NULL)))
|
|
|
|
* exit(1);
|
|
|
|
*
|
|
|
|
* ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, _add_cb, NULL);
|
|
|
|
* ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, _del_cb, NULL);
|
|
|
|
* ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, _data_cb, NULL);
|
|
|
|
*
|
|
|
|
* ecore_main_loop_begin();
|
|
|
|
* @endcode
|
|
|
|
*
|
2011-07-13 12:04:27 -07:00
|
|
|
* After these two pieces of code are executed, respectively, in the server and
|
|
|
|
* client code, the server will be up and running and the client will try to
|
|
|
|
* connect to it. The connection, with its subsequent messages being sent from
|
|
|
|
* server to client and client to server, can be represented in the following
|
|
|
|
* sequence diagram:
|
|
|
|
*
|
2011-07-18 11:26:35 -07:00
|
|
|
* @htmlonly
|
2011-07-13 12:04:27 -07:00
|
|
|
* <img src="ecore_con-client-server.png" style="max-width: 400px"/>
|
|
|
|
* <a href="ecore_con-client-server.png">Full size</a>
|
2011-07-18 11:26:35 -07:00
|
|
|
* @endhtmlonly
|
2011-07-13 12:04:27 -07:00
|
|
|
*
|
|
|
|
* @image rtf ecore_con-client-server.png
|
|
|
|
* @image latex ecore_con-client-server.eps width=\textwidth
|
|
|
|
*
|
2011-07-12 07:37:32 -07:00
|
|
|
* Please notice the important difference between these two codes: the first is
|
|
|
|
* used for writing a @b server, while the second should be used for writing a
|
|
|
|
* @b client.
|
|
|
|
*
|
|
|
|
* A reference for the @c client functions can be found at @ref
|
|
|
|
* Ecore_Con_Client_Group.
|
|
|
|
*
|
|
|
|
* Examples of usage for this API can be found here:
|
|
|
|
* @li @ref ecore_con_server_simple_example_c
|
|
|
|
* @li @ref ecore_con_client_simple_example_c
|
|
|
|
*
|
2010-09-20 23:49:07 -07:00
|
|
|
* @{
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
|
2011-07-12 07:36:58 -07:00
|
|
|
/**
|
|
|
|
* Creates a server to listen for connections.
|
|
|
|
*
|
2011-07-12 07:37:32 -07:00
|
|
|
* @param type The connection type.
|
2011-07-12 07:36:58 -07:00
|
|
|
* @param name Name to associate with the socket. It is used when
|
|
|
|
* generating the socket name of a Unix socket, or for
|
|
|
|
* determining what host to listen on for TCP sockets.
|
|
|
|
* @c NULL will not be accepted.
|
|
|
|
* @param port Number to identify socket. When a Unix socket is used,
|
|
|
|
* it becomes part of the socket name. When a TCP socket
|
|
|
|
* is used, it is used as the TCP port.
|
|
|
|
* @param data Data to associate with the created Ecore_Con_Server
|
|
|
|
* object.
|
|
|
|
* @return A new Ecore_Con_Server.
|
2011-07-12 07:37:32 -07:00
|
|
|
*
|
|
|
|
* The socket on which the server listens depends on the connection
|
|
|
|
* type:
|
|
|
|
* @li If @a type is @c ECORE_CON_LOCAL_USER, the server will listen on
|
|
|
|
* the Unix socket "~/.ecore/[name]/[port]".
|
|
|
|
* @li If @a type is @c ECORE_CON_LOCAL_SYSTEM, the server will listen
|
|
|
|
* on Unix socket "/tmp/.ecore_service|[name]|[port]".
|
|
|
|
* @li If @a type is @c ECORE_CON_REMOTE_TCP, the server will listen
|
|
|
|
* on TCP port @c port.
|
|
|
|
*
|
|
|
|
* More information about the @p type can be found at @ref _Ecore_Con_Type.
|
|
|
|
*
|
|
|
|
* The @p data parameter can be fetched later using ecore_con_server_data_get()
|
|
|
|
* or changed with ecore_con_server_data_set().
|
2011-07-12 07:36:58 -07:00
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI Ecore_Con_Server *ecore_con_server_add(Ecore_Con_Type type,
|
|
|
|
const char *name, int port,
|
|
|
|
const void *data);
|
|
|
|
|
2011-07-12 07:36:58 -07:00
|
|
|
/**
|
|
|
|
* Creates a connection to the specified server and returns an associated object.
|
|
|
|
*
|
2011-07-12 07:37:32 -07:00
|
|
|
* @param type The connection type.
|
2011-07-12 07:36:58 -07:00
|
|
|
* @param name Name used when determining what socket to connect to.
|
|
|
|
* It is used to generate the socket name when the socket
|
|
|
|
* is a Unix socket. It is used as the hostname when
|
|
|
|
* connecting with a TCP socket.
|
|
|
|
* @param port Number to identify the socket to connect to. Used when
|
|
|
|
* generating the socket name for a Unix socket, or as the
|
|
|
|
* TCP port when connecting to a TCP socket.
|
|
|
|
* @param data Data to associate with the created Ecore_Con_Server
|
|
|
|
* object.
|
|
|
|
* @return A new Ecore_Con_Server.
|
2011-07-12 07:37:32 -07:00
|
|
|
*
|
|
|
|
* The socket to which the connection is made depends on the connection type:
|
|
|
|
* @li If @a type is @c ECORE_CON_LOCAL_USER, the function will
|
|
|
|
* connect to the server at the Unix socket
|
|
|
|
* "~/.ecore/[name]/[port]".
|
|
|
|
* @li If @a type is @c ECORE_CON_LOCAL_SYSTEM, the function will
|
|
|
|
* connect to the server at the Unix socket
|
|
|
|
* "/tmp/.ecore_service|[name]|[port]".
|
|
|
|
* @li If @a type is @c ECORE_CON_REMOTE_TCP, the function will
|
|
|
|
* connect to the server at the TCP port "[name]:[port]".
|
|
|
|
*
|
|
|
|
* More information about the @p type can be found at @ref _Ecore_Con_Type.
|
|
|
|
*
|
|
|
|
* This function won't block. It will either succeed, or fail due to invalid
|
|
|
|
* parameters, failed memory allocation, etc., returning @c NULL on that case.
|
|
|
|
*
|
|
|
|
* However, even if this call returns a valid @ref Ecore_Con_Server, the
|
|
|
|
* connection will only be successfully completed if an event of type
|
2012-03-05 06:59:59 -08:00
|
|
|
* @ref ECORE_CON_EVENT_SERVER_ADD is received. If it fails to complete, an
|
|
|
|
* @ref ECORE_CON_EVENT_SERVER_DEL will be received.
|
2011-07-12 07:37:32 -07:00
|
|
|
*
|
|
|
|
* The @p data parameter can be fetched later using ecore_con_server_data_get()
|
|
|
|
* or changed with ecore_con_server_data_set().
|
2011-07-12 07:36:58 -07:00
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI Ecore_Con_Server *ecore_con_server_connect(Ecore_Con_Type type,
|
|
|
|
const char *name, int port,
|
|
|
|
const void *data);
|
2011-07-12 07:36:58 -07:00
|
|
|
/**
|
|
|
|
* Closes the connection and frees the given server.
|
|
|
|
*
|
|
|
|
* @param svr The given server.
|
|
|
|
* @return Data associated with the server when it was created.
|
|
|
|
*
|
|
|
|
* All the clients connected to this server will be disconnected.
|
|
|
|
*
|
|
|
|
* @see ecore_con_server_add, ecore_con_server_connect
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI void * ecore_con_server_del(Ecore_Con_Server *svr);
|
2011-07-12 07:36:58 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the data associated with the given server.
|
|
|
|
*
|
|
|
|
* @param svr The given server.
|
|
|
|
* @return The associated data.
|
2011-07-12 07:37:32 -07:00
|
|
|
*
|
|
|
|
* @see ecore_con_server_data_set()
|
2011-07-12 07:36:58 -07:00
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI void * ecore_con_server_data_get(Ecore_Con_Server *svr);
|
2011-07-12 07:36:58 -07:00
|
|
|
/**
|
|
|
|
* Sets the data associated with the given server.
|
|
|
|
*
|
|
|
|
* @param svr The given server.
|
|
|
|
* @param data The data to associate with @p svr
|
|
|
|
* @return The previously associated data, if any.
|
2011-07-12 07:37:32 -07:00
|
|
|
*
|
|
|
|
* @see ecore_con_server_data_get()
|
2011-07-12 07:36:58 -07:00
|
|
|
*/
|
2010-07-28 18:28:18 -07:00
|
|
|
EAPI void * ecore_con_server_data_set(Ecore_Con_Server *svr,
|
|
|
|
void *data);
|
2011-07-12 07:36:58 -07:00
|
|
|
/**
|
|
|
|
* Retrieves whether the given server is currently connected.
|
|
|
|
*
|
|
|
|
* @param svr The given server.
|
2012-04-11 20:51:36 -07:00
|
|
|
* @return @c EINA_TRUE if the server is connected, @c EINA_FALSE otherwise.
|
2011-07-12 07:36:58 -07:00
|
|
|
*/
|
2010-09-20 18:48:46 -07:00
|
|
|
EAPI Eina_Bool ecore_con_server_connected_get(Ecore_Con_Server *svr);
|
2011-07-12 07:36:58 -07:00
|
|
|
/**
|
|
|
|
* Retrieves the current list of clients.
|
|
|
|
*
|
|
|
|
* @param svr The given server.
|
|
|
|
* @return The list of clients on this server.
|
|
|
|
*
|
2011-07-12 07:37:08 -07:00
|
|
|
* Each node in the returned list points to an @ref Ecore_Con_Client. This list
|
|
|
|
* cannot be modified or freed. It can also change if new clients are connected
|
|
|
|
* or disconnected, and will become invalid when the server is deleted/freed.
|
2011-07-12 07:36:58 -07:00
|
|
|
*/
|
2011-07-12 07:37:08 -07:00
|
|
|
EAPI const Eina_List * ecore_con_server_clients_get(Ecore_Con_Server *svr);
|
2011-07-12 07:36:58 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the name of server.
|
|
|
|
*
|
|
|
|
* @param svr The given server.
|
|
|
|
* @return The name of the server.
|
2011-07-12 07:37:32 -07:00
|
|
|
*
|
|
|
|
* The name returned is the name used to connect on this server.
|
2011-07-12 07:36:58 -07:00
|
|
|
*/
|
2010-08-26 22:16:00 -07:00
|
|
|
EAPI const char * ecore_con_server_name_get(Ecore_Con_Server *svr);
|
2011-07-12 07:36:58 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the server port in use.
|
|
|
|
*
|
|
|
|
* @param svr The given server.
|
|
|
|
* @return The server port in use.
|
|
|
|
*
|
|
|
|
* The port where the server is listening for connections.
|
|
|
|
*/
|
2010-08-26 22:16:00 -07:00
|
|
|
EAPI int ecore_con_server_port_get(Ecore_Con_Server *svr);
|
2011-07-12 07:36:58 -07:00
|
|
|
/**
|
|
|
|
* @brief Check how long a server has been connected
|
|
|
|
*
|
|
|
|
* @param svr The server to check
|
|
|
|
* @return The total time, in seconds, that the server has been
|
|
|
|
* connected/running
|
|
|
|
*
|
2011-07-12 07:37:32 -07:00
|
|
|
* This function is used to find out the time that has been elapsed since
|
|
|
|
* ecore_con_server_add() succeeded.
|
2011-07-12 07:36:58 -07:00
|
|
|
*/
|
2010-09-21 21:48:09 -07:00
|
|
|
EAPI double ecore_con_server_uptime_get(Ecore_Con_Server *svr);
|
2011-07-12 07:36:58 -07:00
|
|
|
/**
|
|
|
|
* Sends the given data to the given server.
|
|
|
|
*
|
|
|
|
* @param svr The given server.
|
|
|
|
* @param data The given data.
|
|
|
|
* @param size Length of the data, in bytes, to send.
|
|
|
|
* @return The number of bytes sent. @c 0 will be returned if there is an
|
|
|
|
* error.
|
2011-07-12 07:37:32 -07:00
|
|
|
*
|
|
|
|
* This function will send the given data to the server as soon as the program
|
|
|
|
* is back to the main loop. Thus, this function returns immediately
|
|
|
|
* (non-blocking). If the data needs to be sent @b now, call
|
|
|
|
* ecore_con_server_flush() after this one.
|
|
|
|
*
|
|
|
|
* @see ecore_con_client_send()
|
|
|
|
* @see ecore_con_server_flush()
|
2011-07-12 07:36:58 -07:00
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI int ecore_con_server_send(Ecore_Con_Server *svr,
|
|
|
|
const void *data,
|
|
|
|
int size);
|
2011-07-12 07:36:58 -07:00
|
|
|
/**
|
|
|
|
* Sets a limit on the number of clients that can be handled concurrently
|
|
|
|
* by the given server, and a policy on what to do if excess clients try to
|
|
|
|
* connect.
|
|
|
|
*
|
|
|
|
* @param svr The given server.
|
|
|
|
* @param client_limit The maximum number of clients to handle
|
|
|
|
* concurrently. -1 means unlimited (default). 0
|
|
|
|
* effectively disables the server.
|
|
|
|
* @param reject_excess_clients Set to 1 to automatically disconnect
|
|
|
|
* excess clients as soon as they connect if you are
|
|
|
|
* already handling client_limit clients. Set to 0
|
|
|
|
* (default) to just hold off on the "accept()"
|
|
|
|
* system call until the number of active clients
|
|
|
|
* drops. This causes the kernel to queue up to 4096
|
|
|
|
* connections (or your kernel's limit, whichever is
|
|
|
|
* lower).
|
|
|
|
*
|
|
|
|
* Beware that if you set this once ecore is already running, you may
|
|
|
|
* already have pending CLIENT_ADD events in your event queue. Those
|
|
|
|
* clients have already connected and will not be affected by this call.
|
|
|
|
* Only clients subsequently trying to connect will be affected.
|
|
|
|
*/
|
2010-09-20 23:49:07 -07:00
|
|
|
EAPI void ecore_con_server_client_limit_set(Ecore_Con_Server *svr,
|
|
|
|
int client_limit,
|
|
|
|
char reject_excess_clients);
|
2011-07-12 07:36:58 -07:00
|
|
|
/**
|
|
|
|
* Gets the IP address of a server that has been connected to.
|
|
|
|
*
|
|
|
|
* @param svr The given server.
|
|
|
|
* @return A pointer to an internal string that contains the IP address of
|
|
|
|
* the connected server in the form "XXX.YYY.ZZZ.AAA" IP notation.
|
|
|
|
* This string should not be modified or trusted to stay valid after
|
2012-04-11 20:51:36 -07:00
|
|
|
* deletion for the @p svr object. If no IP is known @c NULL is
|
|
|
|
* returned.
|
2011-07-12 07:36:58 -07:00
|
|
|
*/
|
2010-07-28 15:32:39 -07:00
|
|
|
EAPI const char * ecore_con_server_ip_get(Ecore_Con_Server *svr);
|
2011-07-12 07:36:58 -07:00
|
|
|
/**
|
2011-07-12 07:37:32 -07:00
|
|
|
* Flushes all pending data to the given server.
|
2011-07-12 07:36:58 -07:00
|
|
|
*
|
|
|
|
* @param svr The given server.
|
2011-07-12 07:37:32 -07:00
|
|
|
*
|
|
|
|
* This function will block until all data is sent to the server.
|
|
|
|
*
|
|
|
|
* @see ecore_con_server_send()
|
|
|
|
* @see ecore_con_client_flush()
|
2011-07-12 07:36:58 -07:00
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI void ecore_con_server_flush(Ecore_Con_Server *svr);
|
2011-07-12 07:36:58 -07:00
|
|
|
/**
|
|
|
|
* Set the default time after which an inactive client will be disconnected
|
|
|
|
*
|
|
|
|
* @param svr The server object
|
|
|
|
* @param timeout The timeout, in seconds, to disconnect after
|
|
|
|
*
|
2011-07-12 07:37:32 -07:00
|
|
|
* This function is used by the server to set the default idle timeout on
|
|
|
|
* clients. If the any of the clients becomes idle for a time higher than this
|
|
|
|
* value, it will be disconnected. A value of < 1 disables the idle timeout.
|
2011-07-12 07:36:58 -07:00
|
|
|
*
|
2011-07-12 07:37:14 -07:00
|
|
|
* This timeout is not affected by the one set by
|
|
|
|
* ecore_con_client_timeout_set(). A client will be disconnected whenever the
|
2011-07-12 07:37:32 -07:00
|
|
|
* client or the server timeout is reached. That means, the lower timeout value
|
|
|
|
* will be used for that client if ecore_con_client_timeout_set() is used on it.
|
2011-07-12 07:37:14 -07:00
|
|
|
*
|
2011-07-12 07:36:58 -07:00
|
|
|
* @see ecore_con_server_timeout_get()
|
|
|
|
* @see ecore_con_client_timeout_set()
|
|
|
|
*/
|
2010-09-21 21:48:09 -07:00
|
|
|
EAPI void ecore_con_server_timeout_set(Ecore_Con_Server *svr, double timeout);
|
2011-07-12 07:36:58 -07:00
|
|
|
/**
|
|
|
|
* Get the default time after which an inactive client will be disconnected
|
|
|
|
*
|
|
|
|
* @param svr The server object
|
|
|
|
* @return The timeout, in seconds, to disconnect after
|
|
|
|
*
|
|
|
|
* This function is used to get the idle timeout for clients. A value of < 1
|
|
|
|
* means the idle timeout is disabled.
|
|
|
|
*
|
|
|
|
* @see ecore_con_server_timeout_set()
|
|
|
|
* @see ecore_con_client_timeout_get()
|
|
|
|
*/
|
2010-09-21 21:48:09 -07:00
|
|
|
EAPI double ecore_con_server_timeout_get(Ecore_Con_Server *svr);
|
2010-09-20 23:49:07 -07:00
|
|
|
|
2011-09-12 01:30:22 -07:00
|
|
|
/**
|
|
|
|
* Get the fd that the server is connected to
|
|
|
|
*
|
|
|
|
* @param svr The server object
|
|
|
|
* @return The fd, or -1 on failure
|
|
|
|
*
|
|
|
|
* This function returns the fd which is used by the underlying server connection.
|
|
|
|
* It should not be tampered with unless you REALLY know what you are doing.
|
|
|
|
* @note This function is only valid for servers created with ecore_con_server_connect()
|
2011-11-04 07:44:30 -07:00
|
|
|
* @warning Seriously. Don't use this unless you know what you are doing.
|
2011-09-12 01:30:22 -07:00
|
|
|
* @since 1.1
|
|
|
|
*/
|
|
|
|
EAPI int ecore_con_server_fd_get(Ecore_Con_Server *svr);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the fd that the client is connected to
|
|
|
|
*
|
|
|
|
* @param cl The client object
|
|
|
|
* @return The fd, or -1 on failure
|
|
|
|
*
|
|
|
|
* This function returns the fd which is used by the underlying client connection.
|
|
|
|
* It should not be tampered with unless you REALLY know what you are doing.
|
|
|
|
* @since 1.1
|
|
|
|
*/
|
|
|
|
EAPI int ecore_con_client_fd_get(Ecore_Con_Client *cl);
|
2010-09-20 23:49:07 -07:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @defgroup Ecore_Con_Client_Group Ecore Connection Client Functions
|
|
|
|
*
|
2011-07-12 07:37:32 -07:00
|
|
|
* Functions to communicate with and/or set options on a client.
|
|
|
|
*
|
|
|
|
* This set of functions, as explained in @ref Ecore_Con_Server_Group, is used
|
|
|
|
* to send data to a client, or to set options and get information about this
|
|
|
|
* client. Most of them should be used on the server, applied on the client
|
|
|
|
* object.
|
|
|
|
*
|
|
|
|
* If you need to implement a client, the way to connect to a server is
|
|
|
|
* described in @ref Ecore_Con_Server_Group.
|
|
|
|
*
|
|
|
|
* An example of usage of these functions can be found at:
|
|
|
|
* @li @ref ecore_con_client_simple_example_c
|
|
|
|
*
|
2010-09-20 23:49:07 -07:00
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2011-07-12 07:36:58 -07:00
|
|
|
/**
|
|
|
|
* Sends the given data to the given client.
|
|
|
|
*
|
|
|
|
* @param cl The given client.
|
|
|
|
* @param data The given data.
|
|
|
|
* @param size Length of the data, in bytes, to send.
|
|
|
|
* @return The number of bytes sent. @c 0 will be returned if there is an
|
|
|
|
* error.
|
2011-07-12 07:37:32 -07:00
|
|
|
*
|
|
|
|
* This function will send the given data to the client as soon as the program
|
|
|
|
* is back to the main loop. Thus, this function returns immediately
|
|
|
|
* (non-blocking). If the data needs to be sent @b now, call
|
|
|
|
* ecore_con_client_flush() after this one.
|
|
|
|
*
|
|
|
|
* @see ecore_con_server_send()
|
|
|
|
* @see ecore_con_client_flush()
|
2011-07-12 07:36:58 -07:00
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI int ecore_con_client_send(Ecore_Con_Client *cl,
|
|
|
|
const void *data,
|
|
|
|
int size);
|
2011-07-12 07:36:58 -07:00
|
|
|
/**
|
|
|
|
* Retrieves the server representing the socket the client has
|
|
|
|
* connected to.
|
|
|
|
*
|
|
|
|
* @param cl The given client.
|
|
|
|
* @return The server that the client connected to.
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI Ecore_Con_Server *ecore_con_client_server_get(Ecore_Con_Client *cl);
|
2011-07-12 07:36:58 -07:00
|
|
|
/**
|
|
|
|
* Closes the connection and frees memory allocated to the given client.
|
|
|
|
*
|
|
|
|
* @param cl The given client.
|
|
|
|
* @return Data associated with the client.
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI void * ecore_con_client_del(Ecore_Con_Client *cl);
|
2011-07-12 07:36:58 -07:00
|
|
|
/**
|
|
|
|
* Sets the data associated with the given client to @p data.
|
|
|
|
*
|
|
|
|
* @param cl The given client.
|
|
|
|
* @param data What to set the data to.
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI void ecore_con_client_data_set(Ecore_Con_Client *cl,
|
2011-07-12 07:36:58 -07:00
|
|
|
const void *data);
|
|
|
|
/**
|
|
|
|
* Retrieves the data associated with the given client.
|
|
|
|
*
|
|
|
|
* @param cl The given client.
|
|
|
|
* @return The data associated with @p cl.
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI void * ecore_con_client_data_get(Ecore_Con_Client *cl);
|
2011-07-12 07:36:58 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the IP address of a client that has connected.
|
|
|
|
*
|
|
|
|
* @param cl The given client.
|
|
|
|
* @return A pointer to an internal string that contains the IP address of
|
|
|
|
* the connected client in the form "XXX.YYY.ZZZ.AAA" IP notation.
|
|
|
|
*
|
|
|
|
* The returned string should not be modified, freed or trusted to stay valid
|
2012-04-11 20:51:36 -07:00
|
|
|
* after deletion for the @p cl object. If no IP is known @c NULL is returned.
|
2011-07-12 07:36:58 -07:00
|
|
|
*/
|
2010-07-28 15:32:39 -07:00
|
|
|
EAPI const char * ecore_con_client_ip_get(Ecore_Con_Client *cl);
|
2011-07-12 07:36:58 -07:00
|
|
|
/**
|
2011-07-12 07:37:32 -07:00
|
|
|
* Flushes all pending data to the given client.
|
2011-07-12 07:36:58 -07:00
|
|
|
*
|
|
|
|
* @param cl The given client.
|
2011-07-12 07:37:32 -07:00
|
|
|
*
|
|
|
|
* This function will block until all data is sent to the server.
|
|
|
|
*
|
|
|
|
* @see ecore_con_client_send()
|
|
|
|
* @see ecore_con_server_flush()
|
2011-07-12 07:36:58 -07:00
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI void ecore_con_client_flush(Ecore_Con_Client *cl);
|
2011-07-12 07:36:58 -07:00
|
|
|
/**
|
|
|
|
* @brief Check how long a client has been connected
|
|
|
|
*
|
|
|
|
* @param cl The client to check
|
|
|
|
* @return The total time, in seconds, that the client has been connected to
|
|
|
|
* the server
|
|
|
|
*
|
|
|
|
* This function is used to find out how long a client has been connected for.
|
|
|
|
*/
|
2010-09-21 21:48:09 -07:00
|
|
|
EAPI double ecore_con_client_uptime_get(Ecore_Con_Client *cl);
|
2011-07-12 07:36:58 -07:00
|
|
|
/**
|
|
|
|
* Get the default time after which the client will be disconnected when
|
|
|
|
* inactive
|
|
|
|
*
|
|
|
|
* @param cl The client object
|
|
|
|
* @return The timeout, in seconds, to disconnect after
|
|
|
|
*
|
|
|
|
* This function is used to get the idle timeout for a client. A value of < 1
|
|
|
|
* means the idle timeout is disabled.
|
2011-07-12 07:37:14 -07:00
|
|
|
*
|
|
|
|
* @see ecore_con_client_timeout_set()
|
2011-07-12 07:36:58 -07:00
|
|
|
*/
|
2010-09-21 21:48:09 -07:00
|
|
|
EAPI double ecore_con_client_timeout_get(Ecore_Con_Client *cl);
|
2011-07-12 07:36:58 -07:00
|
|
|
/**
|
|
|
|
* Set the time after which the client will be disconnected when inactive
|
|
|
|
*
|
|
|
|
* @param cl The client object
|
|
|
|
* @param timeout The timeout, in seconds, to disconnect after
|
|
|
|
*
|
2011-07-12 07:37:32 -07:00
|
|
|
* This function is used by the server to set the idle timeout on a specific
|
|
|
|
* client. If the client becomes idle for a time higher than this value, it will
|
|
|
|
* be disconnected. A value of < 1 disables the idle timeout.
|
2011-07-12 07:37:14 -07:00
|
|
|
*
|
|
|
|
* This timeout is not affected by the one set by
|
|
|
|
* ecore_con_server_timeout_set(). A client will be disconnected whenever the
|
2011-07-12 07:37:32 -07:00
|
|
|
* client or the server timeout is reached. That means, the lower timeout value
|
|
|
|
* will be used for that client if ecore_con_server_timeout_set() is used on the
|
|
|
|
* server.
|
|
|
|
*
|
2011-07-12 07:37:14 -07:00
|
|
|
* @see ecore_con_client_timeout_get()
|
|
|
|
* @see ecore_con_server_timeout_set()
|
2011-07-12 07:36:58 -07:00
|
|
|
*/
|
2010-09-21 21:48:09 -07:00
|
|
|
EAPI void ecore_con_client_timeout_set(Ecore_Con_Client *cl, double timeout);
|
2011-07-12 07:36:58 -07:00
|
|
|
/**
|
|
|
|
* Returns whether the client is still connected
|
|
|
|
*
|
|
|
|
* @param cl The given client.
|
2012-04-11 20:51:36 -07:00
|
|
|
* @return @c EINA_TRUE if connected, @c EINA_FALSE otherwise.
|
2011-07-12 07:36:58 -07:00
|
|
|
*/
|
2010-11-05 17:17:04 -07:00
|
|
|
EAPI Eina_Bool ecore_con_client_connected_get(Ecore_Con_Client *cl);
|
2011-07-12 07:36:58 -07:00
|
|
|
/**
|
|
|
|
* @brief Return the port that the client has connected to
|
|
|
|
*
|
|
|
|
* @param cl The client
|
|
|
|
* @return The port that @p cl has connected to, or -1 on error
|
|
|
|
* Use this function to return the port on which a given client has connected.
|
|
|
|
*/
|
2011-02-10 23:38:27 -08:00
|
|
|
EAPI int ecore_con_client_port_get(Ecore_Con_Client *cl);
|
2010-10-11 23:34:31 -07:00
|
|
|
|
2011-12-05 19:32:16 -08:00
|
|
|
|
|
|
|
|
2010-09-20 23:49:07 -07:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
|
2010-09-20 23:49:07 -07:00
|
|
|
/**
|
|
|
|
* @defgroup Ecore_Con_Url_Group Ecore URL Connection Functions
|
|
|
|
*
|
2011-07-08 11:06:04 -07:00
|
|
|
* Utility functions that set up, use and shut down the Ecore URL
|
|
|
|
* Connection library.
|
|
|
|
*
|
2011-07-08 11:06:19 -07:00
|
|
|
* These functions are a shortcut to make it easy to perform http requests
|
|
|
|
* (POST, GET, etc).
|
|
|
|
*
|
|
|
|
* Brief usage:
|
|
|
|
* 1. Create an Ecore_Con_Url object with ecore_con_url_new(url);
|
|
|
|
* 2. Register to receive the #ECORE_CON_EVENT_URL_COMPLETE event
|
|
|
|
* (and optionally the #ECORE_CON_EVENT_URL_DATA and
|
|
|
|
* #ECORE_CON_EVENT_URL_PROGRESS event to receive
|
|
|
|
* the response, e.g. for HTTP/FTP downloads)
|
|
|
|
* 3. Perform the operation with ecore_con_url_get(...);
|
|
|
|
*
|
|
|
|
* Note that it is good to reuse @ref Ecore_Con_Url objects wherever possible,
|
|
|
|
* but bear in mind that each one can only perform one operation at a time. You
|
|
|
|
* need to wait for the #ECORE_CON_EVENT_URL_COMPLETE event before re-using or
|
|
|
|
* destroying the object.
|
|
|
|
*
|
|
|
|
* If it's necessary to change the @ref Ecore_Con_Url object url, use
|
|
|
|
* ecore_con_url_url_set().
|
|
|
|
*
|
|
|
|
* Simple Usage 1 (HTTP GET):
|
|
|
|
* @code
|
|
|
|
* ecore_con_url_url_set(url_con, "http://www.google.com");
|
|
|
|
* ecore_con_url_get(url_con);
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
* Simple usage 2 (HTTP POST):
|
|
|
|
* @code
|
|
|
|
* ecore_con_url_url_set(url_con, "http://www.example.com/post_handler.cgi");
|
|
|
|
* ecore_con_url_post(url_con, data, data_length, "multipart/form-data");
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
* Simple Usage 3 (FTP download):
|
|
|
|
* @code
|
|
|
|
* fd = creat(filename, 0644)
|
|
|
|
* ecore_con_url_url_set(url_con, "ftp://ftp.example.com/pub/myfile");
|
|
|
|
* ecore_con_url_fd_set(url_con, fd);
|
|
|
|
* ecore_con_url_get(url_con);
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
* Simple Usage 4 (FTP upload as ftp://ftp.example.com/file):
|
|
|
|
* @code
|
|
|
|
* ecore_con_url_url_set(url_con, "ftp://ftp.example.com");
|
|
|
|
* ecore_con_url_ftp_upload(url_con, "/tmp/file", "user", "pass", NULL);
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
* Simple Usage 5 (FTP upload as ftp://ftp.example.com/dir/file):
|
|
|
|
* @code
|
|
|
|
* ecore_con_url_url_set(url_con, "ftp://ftp.example.com");
|
|
|
|
* ecore_con_url_ftp_upload(url_con, "/tmp/file", "user", "pass","dir");
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
* These are complete examples for the API:
|
|
|
|
* @li @ref ecore_con_url_download_example.c "Downloading a file"
|
|
|
|
* @li @ref ecore_con_url_headers_example.c "Setting many options for the
|
|
|
|
* connection"
|
2011-07-08 11:06:04 -07:00
|
|
|
*
|
2010-09-20 23:49:07 -07:00
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef Ecore_Con_Url_Time
|
|
|
|
* @enum _Ecore_Con_Url_Time
|
2010-10-18 09:39:12 -07:00
|
|
|
* The type of condition to use when making an HTTP request dependent on time,
|
|
|
|
* so that headers such as "If-Modified-Since" are used.
|
2010-09-20 23:49:07 -07:00
|
|
|
*/
|
|
|
|
typedef enum _Ecore_Con_Url_Time
|
|
|
|
{
|
2010-10-18 09:39:12 -07:00
|
|
|
/**
|
|
|
|
* Do not place time restrictions on the HTTP requests.
|
|
|
|
*/
|
2010-09-20 23:49:07 -07:00
|
|
|
ECORE_CON_URL_TIME_NONE = 0,
|
2010-10-18 09:39:12 -07:00
|
|
|
/**
|
|
|
|
* Add the "If-Modified-Since" HTTP header, so that the request is performed
|
|
|
|
* by the server only if the target has been modified since the time value
|
|
|
|
* passed to it in the request.
|
|
|
|
*/
|
2010-09-20 23:49:07 -07:00
|
|
|
ECORE_CON_URL_TIME_IFMODSINCE,
|
2010-10-18 09:39:12 -07:00
|
|
|
/**
|
|
|
|
* Add the "If-Unmodified-Since" HTTP header, so that the request is
|
|
|
|
* performed by the server only if the target has NOT been modified since
|
|
|
|
* the time value passed to it in the request.
|
|
|
|
*/
|
|
|
|
ECORE_CON_URL_TIME_IFUNMODSINCE
|
2010-09-20 23:49:07 -07:00
|
|
|
} Ecore_Con_Url_Time;
|
2010-07-26 23:30:27 -07:00
|
|
|
|
2012-02-08 05:25:08 -08:00
|
|
|
/**
|
|
|
|
* @typedef Ecore_Con_Url_Http_Version
|
|
|
|
* @enum _Ecore_Con_Url_Http_Version
|
|
|
|
* The http version to use
|
2012-02-08 14:58:07 -08:00
|
|
|
* @since 1.2
|
2012-02-08 05:25:08 -08:00
|
|
|
*/
|
|
|
|
typedef enum _Ecore_Con_Url_Http_Version
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* HTTP version 1.0
|
2012-02-08 14:58:07 -08:00
|
|
|
* @since 1.2
|
2012-02-08 05:25:08 -08:00
|
|
|
*/
|
|
|
|
ECORE_CON_URL_HTTP_VERSION_1_0,
|
|
|
|
/**
|
|
|
|
* HTTP version 1.1 (default)
|
2012-02-08 14:58:07 -08:00
|
|
|
* @since 1.2
|
2012-02-08 05:25:08 -08:00
|
|
|
*/
|
|
|
|
ECORE_CON_URL_HTTP_VERSION_1_1
|
|
|
|
} Ecore_Con_Url_Http_Version;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Change the HTTP version used for the request
|
2012-03-31 05:03:05 -07:00
|
|
|
* @param url_con Connection object through which the request will be sent.
|
2012-02-08 05:25:08 -08:00
|
|
|
* @param version The version to be used
|
2012-04-11 20:51:36 -07:00
|
|
|
* @return @c EINA_TRUE on success, @c EINA_FALSE on failure to change version.
|
2012-02-08 14:58:07 -08:00
|
|
|
* @since 1.2
|
2012-02-08 05:25:08 -08:00
|
|
|
* @see ecore_con_url_pipeline_get()
|
|
|
|
*/
|
|
|
|
EAPI Eina_Bool ecore_con_url_http_version_set(Ecore_Con_Url *url_con, Ecore_Con_Url_Http_Version version);
|
|
|
|
|
2011-07-08 11:06:04 -07:00
|
|
|
/**
|
|
|
|
* Initialises the Ecore_Con_Url library.
|
|
|
|
* @return Number of times the library has been initialised without being
|
|
|
|
* shut down.
|
|
|
|
*
|
|
|
|
* @note This function doesn't call ecore_con_init(). You still need to call it
|
|
|
|
* explicitly before calling this one.
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI int ecore_con_url_init(void);
|
2011-07-08 11:06:04 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shuts down the Ecore_Con_Url library.
|
|
|
|
* @return Number of calls that still uses Ecore_Con_Url
|
|
|
|
*
|
|
|
|
* @note This function doesn't call ecore_con_shutdown(). You still need to call
|
|
|
|
* it explicitly after calling this one.
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI int ecore_con_url_shutdown(void);
|
2011-04-01 09:37:55 -07:00
|
|
|
|
2011-07-08 11:06:04 -07:00
|
|
|
/**
|
|
|
|
* Enable or disable HTTP 1.1 pipelining.
|
2012-04-11 20:51:36 -07:00
|
|
|
* @param enable @c EINA_TRUE will turn it on, @c EINA_FALSE will disable it.
|
2011-07-08 11:06:19 -07:00
|
|
|
*
|
|
|
|
* Pipelining allows to send one request after another one, without having to
|
|
|
|
* wait for the reply of the first request. The respective replies are received
|
|
|
|
* in the order that the requests were sent.
|
|
|
|
*
|
|
|
|
* Enabling this feature will be valid for all requests done using @c
|
|
|
|
* ecore_con_url.
|
|
|
|
*
|
|
|
|
* See http://en.wikipedia.org/wiki/HTTP_pipelining for more info.
|
|
|
|
*
|
|
|
|
* @see ecore_con_url_pipeline_get()
|
2011-07-08 11:06:04 -07:00
|
|
|
*/
|
2011-04-01 09:37:55 -07:00
|
|
|
EAPI void ecore_con_url_pipeline_set(Eina_Bool enable);
|
2011-07-08 11:06:04 -07:00
|
|
|
/**
|
|
|
|
* Is HTTP 1.1 pipelining enable ?
|
2012-04-11 20:51:36 -07:00
|
|
|
* @return @c EINA_TRUE if it is enable.
|
2011-07-08 11:06:19 -07:00
|
|
|
*
|
|
|
|
* @see ecore_con_url_pipeline_set()
|
2011-07-08 11:06:04 -07:00
|
|
|
*/
|
2011-04-01 09:37:55 -07:00
|
|
|
EAPI Eina_Bool ecore_con_url_pipeline_get(void);
|
|
|
|
|
2011-07-08 11:06:04 -07:00
|
|
|
/**
|
|
|
|
* Creates and initializes a new Ecore_Con_Url connection object.
|
|
|
|
*
|
|
|
|
* @param url URL that will receive requests. Can be changed using
|
|
|
|
* ecore_con_url_url_set.
|
|
|
|
*
|
2012-04-11 20:51:36 -07:00
|
|
|
* @return @c NULL on error, a new Ecore_Con_Url on success.
|
2011-07-08 11:06:04 -07:00
|
|
|
*
|
2011-07-08 11:06:19 -07:00
|
|
|
* Creates and initializes a new Ecore_Con_Url connection object that can be
|
|
|
|
* used for sending requests.
|
2011-07-08 11:06:04 -07:00
|
|
|
*
|
|
|
|
* @see ecore_con_url_custom_new()
|
|
|
|
* @see ecore_con_url_url_set()
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI Ecore_Con_Url * ecore_con_url_new(const char *url);
|
2011-07-08 11:06:04 -07:00
|
|
|
/**
|
|
|
|
* Creates a custom connection object.
|
|
|
|
*
|
|
|
|
* @param url URL that will receive requests
|
|
|
|
* @param custom_request Custom request (e.g. GET, POST, HEAD, PUT, etc)
|
|
|
|
*
|
2012-04-11 20:51:36 -07:00
|
|
|
* @return @c NULL on error, a new Ecore_Con_Url on success.
|
2011-07-08 11:06:04 -07:00
|
|
|
*
|
2011-07-08 11:06:19 -07:00
|
|
|
* Creates and initializes a new Ecore_Con_Url for a custom request (e.g. HEAD,
|
|
|
|
* SUBSCRIBE and other obscure HTTP requests). This object should be used like
|
|
|
|
* one created with ecore_con_url_new().
|
2011-07-08 11:06:04 -07:00
|
|
|
*
|
|
|
|
* @see ecore_con_url_new()
|
|
|
|
* @see ecore_con_url_url_set()
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI Ecore_Con_Url * ecore_con_url_custom_new(const char *url,
|
|
|
|
const char *custom_request);
|
2011-07-08 11:06:04 -07:00
|
|
|
/**
|
|
|
|
* Destroys a Ecore_Con_Url connection object.
|
|
|
|
*
|
|
|
|
* @param url_con Connection object to free.
|
|
|
|
*
|
|
|
|
* @see ecore_con_url_new()
|
|
|
|
*/
|
2010-09-20 23:49:07 -07:00
|
|
|
EAPI void ecore_con_url_free(Ecore_Con_Url *url_con);
|
2011-07-08 11:06:04 -07:00
|
|
|
/**
|
|
|
|
* Sets the URL to send the request to.
|
|
|
|
*
|
|
|
|
* @param url_con Connection object through which the request will be sent.
|
|
|
|
* @param url URL that will receive the request
|
|
|
|
*
|
2012-04-11 20:51:36 -07:00
|
|
|
* @return @c EINA_TRUE on success, @c EINA_FALSE on error.
|
2011-07-08 11:06:04 -07:00
|
|
|
*/
|
2010-09-20 23:49:07 -07:00
|
|
|
EAPI Eina_Bool ecore_con_url_url_set(Ecore_Con_Url *url_con,
|
|
|
|
const char *url);
|
2011-07-22 20:14:42 -07:00
|
|
|
/**
|
|
|
|
* Gets the URL to send the request to.
|
|
|
|
*
|
|
|
|
* @param url_con Connection object through which the request will be sent.
|
2012-04-11 20:51:36 -07:00
|
|
|
* @return URL that will receive the request, @c NULL on failure. URL is
|
|
|
|
* stringshared.
|
2011-07-22 20:14:42 -07:00
|
|
|
* @since 1.1
|
|
|
|
*/
|
|
|
|
EAPI const char *ecore_con_url_url_get(Ecore_Con_Url *url_con);
|
2011-07-08 11:06:04 -07:00
|
|
|
/**
|
|
|
|
* Associates data with a connection object.
|
|
|
|
*
|
|
|
|
* @param url_con Connection object to associate data.
|
|
|
|
* @param data Data to be set.
|
|
|
|
*
|
2011-07-08 11:06:19 -07:00
|
|
|
* Associates data with a connection object, which can be retrieved later with
|
|
|
|
* ecore_con_url_data_get()).
|
2011-07-08 11:06:04 -07:00
|
|
|
*
|
|
|
|
* @see ecore_con_url_data_get()
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI void ecore_con_url_data_set(Ecore_Con_Url *url_con,
|
|
|
|
void *data);
|
2011-07-08 11:06:04 -07:00
|
|
|
/**
|
|
|
|
* Retrieves data associated with a Ecore_Con_Url connection object.
|
|
|
|
*
|
|
|
|
* @param url_con Connection object to retrieve data from.
|
|
|
|
*
|
|
|
|
* @return Data associated with the given object.
|
|
|
|
*
|
2011-07-08 11:06:19 -07:00
|
|
|
* Retrieves data associated with a Ecore_Con_Url connection object (previously
|
|
|
|
* set with ecore_con_url_data_set()).
|
2011-07-08 11:06:04 -07:00
|
|
|
*
|
|
|
|
* @see ecore_con_url_data_set()
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI void * ecore_con_url_data_get(Ecore_Con_Url *url_con);
|
2011-07-08 11:06:04 -07:00
|
|
|
/**
|
|
|
|
* Adds an additional header to the request connection object.
|
|
|
|
*
|
|
|
|
* @param url_con Connection object
|
|
|
|
* @param key Header key
|
|
|
|
* @param value Header value
|
|
|
|
*
|
2011-07-08 11:06:19 -07:00
|
|
|
* Adds an additional header (User-Agent, Content-Type, etc.) to the request
|
|
|
|
* connection object. This addition will be valid for only one
|
|
|
|
* ecore_con_url_get() or ecore_con_url_post() call.
|
|
|
|
*
|
|
|
|
* Some functions like ecore_con_url_time() also add headers to the request.
|
2011-07-08 11:06:04 -07:00
|
|
|
*
|
|
|
|
* @see ecore_con_url_get()
|
|
|
|
* @see ecore_con_url_post()
|
|
|
|
* @see ecore_con_url_additional_headers_clear()
|
|
|
|
*/
|
2010-09-20 20:08:35 -07:00
|
|
|
EAPI void ecore_con_url_additional_header_add(Ecore_Con_Url *url_con,
|
|
|
|
const char *key,
|
|
|
|
const char *value);
|
2011-07-08 11:06:04 -07:00
|
|
|
/**
|
|
|
|
* Cleans additional headers.
|
|
|
|
*
|
|
|
|
* @param url_con Connection object to clean additional headers.
|
|
|
|
*
|
2011-07-08 11:06:19 -07:00
|
|
|
* Cleans additional headers associated with a connection object (previously
|
|
|
|
* added with ecore_con_url_additional_header_add()).
|
2011-07-08 11:06:04 -07:00
|
|
|
*
|
|
|
|
* @see ecore_con_url_additional_header_add()
|
|
|
|
* @see ecore_con_url_get()
|
|
|
|
* @see ecore_con_url_post()
|
|
|
|
*/
|
2010-09-20 20:08:35 -07:00
|
|
|
EAPI void ecore_con_url_additional_headers_clear(Ecore_Con_Url *url_con);
|
2011-07-08 11:06:04 -07:00
|
|
|
/**
|
|
|
|
* Retrieves headers from last request sent.
|
|
|
|
*
|
2011-07-08 11:06:19 -07:00
|
|
|
* @param url_con Connection object to retrieve response headers from.
|
|
|
|
*
|
2011-07-08 11:06:04 -07:00
|
|
|
* Retrieves a list containing the response headers. This function should be
|
|
|
|
* used after an ECORE_CON_EVENT_URL_COMPLETE event (headers should normally be
|
|
|
|
* ready at that time).
|
|
|
|
*
|
|
|
|
* @return List of response headers. This list must not be modified by the user.
|
|
|
|
*/
|
2010-09-20 20:08:35 -07:00
|
|
|
EAPI const Eina_List * ecore_con_url_response_headers_get(Ecore_Con_Url *url_con);
|
2011-07-08 11:06:04 -07:00
|
|
|
/**
|
|
|
|
* Setup a file for receiving response data.
|
|
|
|
*
|
|
|
|
* @param url_con Connection object to set file
|
|
|
|
* @param fd File descriptor associated with the file. A negative value will
|
|
|
|
* unset any previously set fd.
|
|
|
|
*
|
2011-07-08 11:06:19 -07:00
|
|
|
* Sets up a file to have response data written into. Note that
|
|
|
|
* ECORE_CON_EVENT_URL_DATA events will not be emitted if a file has been set to
|
|
|
|
* receive the response data.
|
|
|
|
*
|
|
|
|
* This call can be used to easily setup a file where the downloaded data will
|
|
|
|
* be saved.
|
2011-07-08 11:06:04 -07:00
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI void ecore_con_url_fd_set(Ecore_Con_Url *url_con, int fd);
|
2011-07-08 11:06:04 -07:00
|
|
|
/**
|
|
|
|
* Retrieves the number of bytes received.
|
|
|
|
*
|
|
|
|
* Retrieves the number of bytes received on the last request of the given
|
|
|
|
* connection object.
|
|
|
|
*
|
|
|
|
* @param url_con Connection object which the request was sent on.
|
|
|
|
*
|
|
|
|
* @return Number of bytes received on request.
|
|
|
|
*
|
|
|
|
* @see ecore_con_url_get()
|
|
|
|
* @see ecore_con_url_post()
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI int ecore_con_url_received_bytes_get(Ecore_Con_Url *url_con);
|
2011-07-08 11:06:04 -07:00
|
|
|
/**
|
|
|
|
* Sets url_con to use http auth, with given username and password, "safely" or not.
|
|
|
|
*
|
|
|
|
* @param url_con Connection object to perform a request on, previously created
|
|
|
|
* with ecore_con_url_new() or ecore_con_url_custom_new().
|
|
|
|
* @param username Username to use in authentication
|
|
|
|
* @param password Password to use in authentication
|
|
|
|
* @param safe Whether to use "safer" methods (eg, NOT http basic auth)
|
|
|
|
*
|
2012-04-11 20:51:36 -07:00
|
|
|
* @return @c EINA_TRUE on success, @c EINA_FALSE on error.
|
2011-07-08 11:06:04 -07:00
|
|
|
*
|
2012-04-11 20:51:36 -07:00
|
|
|
* @attention Requires libcurl >= 7.19.1 to work, otherwise will always return
|
|
|
|
* @c 0.
|
2011-07-08 11:06:04 -07:00
|
|
|
*/
|
2010-09-20 20:14:46 -07:00
|
|
|
EAPI Eina_Bool ecore_con_url_httpauth_set(Ecore_Con_Url *url_con,
|
2010-07-26 23:30:27 -07:00
|
|
|
const char *username,
|
|
|
|
const char *password,
|
|
|
|
Eina_Bool safe);
|
2011-07-08 11:06:04 -07:00
|
|
|
/**
|
|
|
|
* Sends a get request.
|
|
|
|
*
|
|
|
|
* @param url_con Connection object to perform a request on, previously created
|
|
|
|
*
|
2012-04-11 20:51:36 -07:00
|
|
|
* @return @c EINA_TRUE on success, @c EINA_FALSE on error.
|
2011-07-08 11:06:04 -07:00
|
|
|
*
|
2011-07-08 11:06:19 -07:00
|
|
|
* The request is performed immediately, but you need to setup event handlers
|
|
|
|
* for #ECORE_CON_EVENT_URL_DATA, #ECORE_CON_EVENT_URL_COMPLETE or
|
|
|
|
* #ECORE_CON_EVENT_URL_PROGRESS to get more information about its result.
|
|
|
|
*
|
2011-07-08 11:06:04 -07:00
|
|
|
* @see ecore_con_url_custom_new()
|
|
|
|
* @see ecore_con_url_additional_headers_clear()
|
|
|
|
* @see ecore_con_url_additional_header_add()
|
|
|
|
* @see ecore_con_url_data_set()
|
|
|
|
* @see ecore_con_url_data_get()
|
|
|
|
* @see ecore_con_url_response_headers_get()
|
|
|
|
* @see ecore_con_url_time()
|
|
|
|
* @see ecore_con_url_post()
|
|
|
|
*/
|
2011-01-27 18:24:24 -08:00
|
|
|
EAPI Eina_Bool ecore_con_url_get(Ecore_Con_Url *url_con);
|
2011-07-08 11:06:04 -07:00
|
|
|
/**
|
|
|
|
* Sends a post request.
|
|
|
|
*
|
|
|
|
* @param url_con Connection object to perform a request on, previously created
|
|
|
|
* with ecore_con_url_new() or ecore_con_url_custom_new().
|
2011-07-08 11:06:19 -07:00
|
|
|
* @param data Payload (data sent on the request). Can be @c NULL.
|
2011-07-08 11:06:04 -07:00
|
|
|
* @param length Payload length. If @c -1, rely on automatic length
|
|
|
|
* calculation via @c strlen() on @p data.
|
2011-07-08 11:06:19 -07:00
|
|
|
* @param content_type Content type of the payload (e.g. text/xml). Can be @c
|
|
|
|
* NULL.
|
2011-07-08 11:06:04 -07:00
|
|
|
*
|
2012-04-11 20:51:36 -07:00
|
|
|
* @return @c EINA_TRUE on success, @c EINA_FALSE on error.
|
2011-07-08 11:06:04 -07:00
|
|
|
*
|
2011-07-08 11:06:19 -07:00
|
|
|
* The request starts immediately, but you need to setup event handlers
|
|
|
|
* for #ECORE_CON_EVENT_URL_DATA, #ECORE_CON_EVENT_URL_COMPLETE or
|
|
|
|
* #ECORE_CON_EVENT_URL_PROGRESS to get more information about its result.
|
|
|
|
*
|
|
|
|
* This call won't block your main loop.
|
|
|
|
*
|
2011-07-08 11:06:04 -07:00
|
|
|
* @see ecore_con_url_custom_new()
|
|
|
|
* @see ecore_con_url_additional_headers_clear()
|
|
|
|
* @see ecore_con_url_additional_header_add()
|
|
|
|
* @see ecore_con_url_data_set()
|
|
|
|
* @see ecore_con_url_data_get()
|
|
|
|
* @see ecore_con_url_response_headers_get()
|
|
|
|
* @see ecore_con_url_time()
|
|
|
|
* @see ecore_con_url_get()
|
|
|
|
*/
|
2011-01-05 22:33:25 -08:00
|
|
|
EAPI Eina_Bool ecore_con_url_post(Ecore_Con_Url *url_con,
|
2010-10-24 19:53:06 -07:00
|
|
|
const void *data, long length,
|
2010-07-26 23:30:27 -07:00
|
|
|
const char *content_type);
|
2011-07-08 11:06:04 -07:00
|
|
|
/**
|
|
|
|
* Sets whether HTTP requests should be conditional, dependent on
|
|
|
|
* modification time.
|
|
|
|
*
|
|
|
|
* @param url_con Ecore_Con_Url to act upon.
|
2012-01-17 03:37:35 -08:00
|
|
|
* @param time_condition Condition to use for HTTP requests.
|
2011-07-08 11:06:04 -07:00
|
|
|
* @param timestamp Time since 1 Jan 1970 to use in the condition.
|
|
|
|
*
|
2011-07-08 11:06:19 -07:00
|
|
|
* This function may set the header "If-Modified-Since" or
|
|
|
|
* "If-Unmodified-Since", depending on the value of @p time_condition, with the
|
|
|
|
* value @p timestamp.
|
|
|
|
*
|
2011-07-08 11:06:04 -07:00
|
|
|
* @sa ecore_con_url_get()
|
|
|
|
* @sa ecore_con_url_post()
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI void ecore_con_url_time(Ecore_Con_Url *url_con,
|
2010-10-18 09:39:12 -07:00
|
|
|
Ecore_Con_Url_Time time_condition,
|
|
|
|
double timestamp);
|
2010-07-26 23:30:27 -07:00
|
|
|
|
2011-07-08 11:06:04 -07:00
|
|
|
/**
|
|
|
|
* @brief Uploads a file to an ftp site.
|
2012-04-11 20:51:36 -07:00
|
|
|
*
|
2011-07-08 11:06:04 -07:00
|
|
|
* @param url_con The Ecore_Con_Url object to send with
|
|
|
|
* @param filename The path to the file to send
|
|
|
|
* @param user The username to log in with
|
|
|
|
* @param pass The password to log in with
|
|
|
|
* @param upload_dir The directory to which the file should be uploaded
|
2012-04-11 20:51:36 -07:00
|
|
|
* @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
|
|
|
|
*
|
2011-07-08 11:06:04 -07:00
|
|
|
* Upload @p filename to an ftp server set in @p url_con using @p user
|
|
|
|
* and @p pass to directory @p upload_dir
|
|
|
|
*/
|
2010-09-20 20:14:46 -07:00
|
|
|
EAPI Eina_Bool ecore_con_url_ftp_upload(Ecore_Con_Url *url_con,
|
2010-07-26 23:30:27 -07:00
|
|
|
const char *filename,
|
|
|
|
const char *user,
|
|
|
|
const char *pass,
|
|
|
|
const char *upload_dir);
|
2011-07-08 11:06:04 -07:00
|
|
|
/**
|
|
|
|
* Toggle libcurl's verbose output.
|
|
|
|
*
|
2011-07-08 11:06:19 -07:00
|
|
|
* @param url_con Ecore_Con_Url instance which will be acted upon.
|
|
|
|
* @param verbose Whether or not to enable libcurl's verbose output.
|
|
|
|
*
|
2011-07-08 11:06:04 -07:00
|
|
|
* If @p verbose is @c EINA_TRUE, libcurl will output a lot of verbose
|
|
|
|
* information about its operations, which is useful for
|
|
|
|
* debugging. The verbose information will be sent to stderr.
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI void ecore_con_url_verbose_set(Ecore_Con_Url *url_con,
|
2010-10-08 08:17:01 -07:00
|
|
|
Eina_Bool verbose);
|
2011-07-08 11:06:04 -07:00
|
|
|
/**
|
|
|
|
* Enable or disable EPSV extension
|
|
|
|
* @return FIXME: To be more documented.
|
|
|
|
*/
|
2010-07-26 23:30:27 -07:00
|
|
|
EAPI void ecore_con_url_ftp_use_epsv_set(Ecore_Con_Url *url_con,
|
2010-10-08 11:41:49 -07:00
|
|
|
Eina_Bool use_epsv);
|
2005-08-16 02:25:02 -07:00
|
|
|
|
2011-07-13 12:04:10 -07:00
|
|
|
/**
|
|
|
|
* Enables the cookie engine for subsequent HTTP requests.
|
|
|
|
*
|
|
|
|
* @param url_con Ecore_Con_Url instance which will be acted upon.
|
|
|
|
*
|
|
|
|
* After this function is called, cookies set by the server in HTTP responses
|
|
|
|
* will be parsed and stored, as well as sent back to the server in new HTTP
|
|
|
|
* requests.
|
|
|
|
*
|
|
|
|
* @note Even though this function is called @c ecore_con_url_cookies_init(),
|
|
|
|
* there is no symmetrical shutdown operation.
|
|
|
|
*/
|
2011-01-06 08:10:38 -08:00
|
|
|
EAPI void ecore_con_url_cookies_init(Ecore_Con_Url *url_con);
|
2011-07-13 12:04:10 -07:00
|
|
|
/**
|
|
|
|
* Controls whether session cookies from previous sessions shall be loaded.
|
|
|
|
*
|
|
|
|
* @param url_con Ecore_Con_Url instance which will be acted upon.
|
|
|
|
* @param ignore If @c EINA_TRUE, ignore session cookies when loading cookies
|
|
|
|
* from files. If @c EINA_FALSE, all cookies will be loaded.
|
|
|
|
*
|
|
|
|
* Session cookies are cookies with no expire date set, which usually means
|
|
|
|
* they are removed after the current session is closed.
|
|
|
|
*
|
|
|
|
* By default, when Ecore_Con_Url loads cookies from a file, all cookies are
|
|
|
|
* loaded, including session cookies, which, most of the time, were supposed
|
|
|
|
* to be loaded and valid only for that session.
|
|
|
|
*
|
|
|
|
* If @p ignore is set to @c EINA_TRUE, when Ecore_Con_Url loads cookies from
|
|
|
|
* the files passed to @c ecore_con_url_cookies_file_add(), session cookies
|
|
|
|
* will not be loaded.
|
|
|
|
*
|
|
|
|
* @see ecore_con_url_cookies_file_add()
|
|
|
|
*/
|
2011-01-06 08:10:38 -08:00
|
|
|
EAPI void ecore_con_url_cookies_ignore_old_session_set(Ecore_Con_Url *url_con,
|
|
|
|
Eina_Bool ignore);
|
2011-07-13 12:04:10 -07:00
|
|
|
/**
|
|
|
|
* Clears currently loaded cookies.
|
|
|
|
* @param url_con Ecore_Con_Url instance which will be acted upon.
|
|
|
|
*
|
|
|
|
* The cleared cookies are removed and will not be sent in subsequent HTTP
|
|
|
|
* requests, nor will they be written to the cookiejar file set via
|
|
|
|
* @c ecore_con_url_cookies_jar_file_set().
|
|
|
|
*
|
|
|
|
* @note This function will initialize the cookie engine if it has not been
|
|
|
|
* initialized yet.
|
|
|
|
* @note The cookie files set by ecore_con_url_cookies_file_add() aren't loaded
|
|
|
|
* immediately, just when the request is started. Thus, if you ask to
|
|
|
|
* clear the cookies, but has a file already set by that function, the
|
|
|
|
* cookies will then be loaded and you will have old cookies set. In order
|
|
|
|
* to don't have any old cookie set, you need to don't call
|
|
|
|
* ecore_con_url_cookies_file_add() ever on the @p url_con handler, and
|
|
|
|
* call this function to clear any cookie set by a previous request on
|
|
|
|
* this handler.
|
|
|
|
*
|
|
|
|
* @see ecore_con_url_cookies_session_clear()
|
|
|
|
* @see ecore_con_url_cookies_ignore_old_session_set()
|
|
|
|
*/
|
2011-01-06 08:10:38 -08:00
|
|
|
EAPI void ecore_con_url_cookies_clear(Ecore_Con_Url *url_con);
|
2011-07-13 12:04:10 -07:00
|
|
|
/**
|
|
|
|
* Clears currently loaded session cookies.
|
|
|
|
*
|
|
|
|
* @param url_con Ecore_Con_Url instance which will be acted upon.
|
|
|
|
*
|
|
|
|
* Session cookies are cookies with no expire date set, which usually means
|
|
|
|
* they are removed after the current session is closed.
|
|
|
|
*
|
|
|
|
* The cleared cookies are removed and will not be sent in subsequent HTTP
|
|
|
|
* requests, nor will they be written to the cookiejar file set via
|
|
|
|
* @c ecore_con_url_cookies_jar_file_set().
|
|
|
|
*
|
|
|
|
* @note This function will initialize the cookie engine if it has not been
|
|
|
|
* initialized yet.
|
|
|
|
* @note The cookie files set by ecore_con_url_cookies_file_add() aren't loaded
|
|
|
|
* immediately, just when the request is started. Thus, if you ask to
|
|
|
|
* clear the session cookies, but has a file already set by that function,
|
|
|
|
* the session cookies will then be loaded and you will have old cookies
|
|
|
|
* set. In order to don't have any old session cookie set, you need to
|
|
|
|
* don't call ecore_con_url_cookies_file_add() ever on the @p url_con
|
|
|
|
* handler, and call this function to clear any session cookie set by a
|
|
|
|
* previous request on this handler. An easier way to don't use old
|
|
|
|
* session cookies is by using the function
|
|
|
|
* ecore_con_url_cookies_ignore_old_session_set().
|
|
|
|
*
|
|
|
|
* @see ecore_con_url_cookies_clear()
|
|
|
|
* @see ecore_con_url_cookies_ignore_old_session_set()
|
|
|
|
*/
|
2011-01-06 08:10:38 -08:00
|
|
|
EAPI void ecore_con_url_cookies_session_clear(Ecore_Con_Url *url_con);
|
2011-07-13 12:04:10 -07:00
|
|
|
/**
|
|
|
|
* Adds a file to the list of files from which to load cookies.
|
|
|
|
*
|
|
|
|
* @param url_con Ecore_Con_Url instance which will be acted upon.
|
|
|
|
* @param file_name Name of the file that will be added to the list.
|
|
|
|
*
|
|
|
|
* Files must contain cookies defined according to two possible formats:
|
|
|
|
*
|
|
|
|
* @li HTTP-style header ("Set-Cookie: ...").
|
|
|
|
* @li <a href="http://www.cookiecentral.com/faq/#3.5">Netscape/Mozilla cookie data format.</a>
|
|
|
|
*
|
|
|
|
* Cookies will only be @b read from this file. If you want to save cookies to a
|
|
|
|
* file, use ecore_con_url_cookies_jar_file_set(). Also notice that this
|
|
|
|
* function supports the both types of cookie file cited above, while
|
|
|
|
* ecore_con_url_cookies_jar_file_set() will save only in the Netscape/Mozilla's
|
|
|
|
* format.
|
|
|
|
*
|
|
|
|
* Please notice that the file will not be read immediately, but rather added
|
|
|
|
* to a list of files that will be loaded and parsed at a later time.
|
|
|
|
*
|
|
|
|
* @note This function will initialize the cookie engine if it has not been
|
|
|
|
* initialized yet.
|
|
|
|
*
|
|
|
|
* @see ecore_con_url_cookies_ignore_old_session_set()
|
|
|
|
* @see ecore_con_url_cookies_jar_file_set()
|
|
|
|
*/
|
2011-01-06 08:10:38 -08:00
|
|
|
EAPI void ecore_con_url_cookies_file_add(Ecore_Con_Url *url_con,
|
|
|
|
const char * const file_name);
|
2011-07-13 12:04:10 -07:00
|
|
|
/**
|
|
|
|
* Sets the name of the file to which all current cookies will be written when
|
|
|
|
* either cookies are flushed or Ecore_Con is shut down.
|
|
|
|
*
|
|
|
|
* @param url_con Ecore_Con_Url instance which will be acted upon.
|
|
|
|
* @param cookiejar_file File to which the cookies will be written.
|
|
|
|
*
|
|
|
|
* @return @c EINA_TRUE is the file name has been set successfully,
|
|
|
|
* @c EINA_FALSE otherwise.
|
|
|
|
*
|
|
|
|
* Cookies are written following Netscape/Mozilla's data format, also known as
|
|
|
|
* cookie-jar.
|
|
|
|
*
|
|
|
|
* Cookies will only be @b saved to this file. If you need to read cookies from
|
|
|
|
* a file, use ecore_con_url_cookies_file_add() instead.
|
|
|
|
*
|
|
|
|
* @note This function will initialize the cookie engine if it has not been
|
|
|
|
* initialized yet.
|
|
|
|
*
|
|
|
|
* @see ecore_con_url_cookies_jar_write()
|
|
|
|
*/
|
2011-01-06 08:10:38 -08:00
|
|
|
EAPI Eina_Bool ecore_con_url_cookies_jar_file_set(Ecore_Con_Url *url_con,
|
|
|
|
const char * const cookiejar_file);
|
2011-07-13 12:04:10 -07:00
|
|
|
/**
|
|
|
|
* Writes all current cookies to the cookie jar immediately.
|
|
|
|
*
|
|
|
|
* @param url_con Ecore_Con_Url instance which will be acted upon.
|
|
|
|
*
|
|
|
|
* A cookie-jar file must have been previously set by
|
|
|
|
* @c ecore_con_url_jar_file_set, otherwise nothing will be done.
|
|
|
|
*
|
|
|
|
* @note This function will initialize the cookie engine if it has not been
|
|
|
|
* initialized yet.
|
|
|
|
*
|
|
|
|
* @see ecore_con_url_cookies_jar_file_set()
|
|
|
|
*/
|
2011-01-06 08:10:38 -08:00
|
|
|
EAPI void ecore_con_url_cookies_jar_write(Ecore_Con_Url *url_con);
|
|
|
|
|
2011-03-01 01:51:51 -08:00
|
|
|
EAPI void ecore_con_url_ssl_verify_peer_set(Ecore_Con_Url *url_con,
|
|
|
|
Eina_Bool verify);
|
2011-03-30 02:15:24 -07:00
|
|
|
EAPI int ecore_con_url_ssl_ca_set(Ecore_Con_Url *url_con,
|
|
|
|
const char *ca_path);
|
2011-03-01 01:51:51 -08:00
|
|
|
|
2011-12-20 22:18:25 -08:00
|
|
|
/**
|
|
|
|
* Set HTTP proxy to use.
|
|
|
|
*
|
|
|
|
* The parameter should be a char * to a zero terminated string holding
|
|
|
|
* the host name or dotted IP address. To specify port number in this string,
|
|
|
|
* append :[port] to the end of the host name.
|
|
|
|
* The proxy string may be prefixed with [protocol]:// since any such prefix
|
|
|
|
* will be ignored.
|
|
|
|
* The proxy's port number may optionally be specified with the separate option.
|
|
|
|
* If not specified, libcurl will default to using port 1080 for proxies.
|
|
|
|
*
|
|
|
|
* @param url_con Connection object that will use the proxy.
|
|
|
|
* @param proxy Porxy string or @c NULL to disable
|
|
|
|
*
|
2012-04-11 20:51:36 -07:00
|
|
|
* @return @c EINA_TRUE on success, @c EINA_FALSE on error.
|
2011-12-20 22:18:25 -08:00
|
|
|
* @since 1.2
|
|
|
|
*/
|
|
|
|
EAPI Eina_Bool ecore_con_url_proxy_set(Ecore_Con_Url *url_con, const char *proxy);
|
|
|
|
|
2011-12-22 00:06:51 -08:00
|
|
|
/**
|
|
|
|
* Set zero terminated username to use for proxy.
|
|
|
|
*
|
|
|
|
* if socks protocol is used for proxy, protocol should be socks5 and above.
|
|
|
|
*
|
|
|
|
* @param url_con Connection object that will use the proxy.
|
|
|
|
* @param username Username string.
|
|
|
|
*
|
2012-04-11 20:51:36 -07:00
|
|
|
* @return @c EINA_TRUE on success, @c EINA_FALSE on error.
|
2011-12-22 00:06:51 -08:00
|
|
|
*
|
|
|
|
* @see ecore_con_url_proxy_set()
|
|
|
|
*
|
2011-12-22 23:04:36 -08:00
|
|
|
* @since 1.2
|
2011-12-22 00:06:51 -08:00
|
|
|
*/
|
|
|
|
EAPI Eina_Bool ecore_con_url_proxy_username_set(Ecore_Con_Url *url_con, const char *username);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set zero terminated password to use for proxy.
|
|
|
|
*
|
|
|
|
* if socks protocol is used for proxy, protocol should be socks5 and above.
|
|
|
|
*
|
|
|
|
* @param url_con Connection object that will use the proxy.
|
|
|
|
* @param password Password string.
|
|
|
|
*
|
2012-04-11 20:51:36 -07:00
|
|
|
* @return @c EINA_TRUE on success, @c EINA_FALSE on error.
|
2011-12-22 00:06:51 -08:00
|
|
|
*
|
|
|
|
* @see ecore_con_url_proxy_set()
|
|
|
|
*
|
|
|
|
* @since 1.2
|
|
|
|
*/
|
|
|
|
EAPI Eina_Bool ecore_con_url_proxy_password_set(Ecore_Con_Url *url_con, const char *password);
|
|
|
|
|
2011-12-20 22:18:25 -08:00
|
|
|
/**
|
|
|
|
* Set timeout in seconds.
|
|
|
|
*
|
|
|
|
* the maximum time in seconds that you allow the ecore con url transfer
|
|
|
|
* operation to take. Normally, name lookups can take a considerable time
|
|
|
|
* and limiting operations to less than a few minutes risk aborting perfectly
|
|
|
|
* normal operations.
|
|
|
|
*
|
|
|
|
* @param url_con Connection object that will use the timeout.
|
|
|
|
* @param timeout time in seconds.
|
2011-12-22 00:06:51 -08:00
|
|
|
*
|
|
|
|
* @see ecore_con_url_cookies_jar_file_set()
|
|
|
|
*
|
2011-12-20 22:18:25 -08:00
|
|
|
* @since 1.2
|
|
|
|
*/
|
|
|
|
EAPI void ecore_con_url_timeout_set(Ecore_Con_Url *url_con, double timeout);
|
|
|
|
|
2012-03-07 09:15:01 -08:00
|
|
|
/**
|
|
|
|
* Get the returned HTTP STATUS code
|
|
|
|
*
|
|
|
|
* This is used to, at any time, try to return the status code for a transmission.
|
|
|
|
* @param url_con Connection object
|
2012-03-07 23:46:42 -08:00
|
|
|
* @return A valid HTTP STATUS code, or 0 on failure
|
2012-03-07 09:15:01 -08:00
|
|
|
*
|
|
|
|
* @since 1.2
|
|
|
|
*/
|
|
|
|
EAPI int ecore_con_url_status_code_get(Ecore_Con_Url *url_con);
|
2010-09-20 23:49:07 -07:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|