forked from enlightenment/efl
Ecore con client: Migrate to eo.
This commit is contained in:
parent
218e76fd30
commit
d9b5f192d4
|
@ -1,14 +1,21 @@
|
||||||
|
|
||||||
### Library
|
### Library
|
||||||
|
|
||||||
BUILT_SOURCES += \
|
ecorecon_eobuiltheaders = \
|
||||||
lib/ecore_con/ecore_con.eo.c \
|
|
||||||
lib/ecore_con/ecore_con.eo.h \
|
lib/ecore_con/ecore_con.eo.h \
|
||||||
lib/ecore_con/ecore_con.eo.legacy.h
|
lib/ecore_con/ecore_con.eo.legacy.h \
|
||||||
|
lib/ecore_con/ecore_con_client.eo.h \
|
||||||
|
lib/ecore_con/ecore_con_client.eo.legacy.h
|
||||||
|
|
||||||
|
BUILT_SOURCES += \
|
||||||
|
${ecorecon_eobuiltheaders} \
|
||||||
|
lib/ecore_con/ecore_con.eo.c \
|
||||||
|
lib/ecore_con/ecore_con_client.eo.c
|
||||||
|
|
||||||
ecoreconeolianfilesdir = $(datadir)/eolian/include/ecore-@VMAJ@
|
ecoreconeolianfilesdir = $(datadir)/eolian/include/ecore-@VMAJ@
|
||||||
ecoreconeolianfiles_DATA = \
|
ecoreconeolianfiles_DATA = \
|
||||||
lib/ecore_con/ecore_con.eo
|
lib/ecore_con/ecore_con.eo \
|
||||||
|
lib/ecore_con/ecore_con_client.eo
|
||||||
|
|
||||||
EXTRA_DIST += \
|
EXTRA_DIST += \
|
||||||
${ecoreconeolianfiles_DATA}
|
${ecoreconeolianfiles_DATA}
|
||||||
|
@ -23,7 +30,7 @@ lib/ecore_con/Ecore_Con_Eo.h \
|
||||||
lib/ecore_con/Ecore_Con_Eet.h
|
lib/ecore_con/Ecore_Con_Eet.h
|
||||||
|
|
||||||
nodist_installed_ecoreconmainheaders_DATA = \
|
nodist_installed_ecoreconmainheaders_DATA = \
|
||||||
lib/ecore_con/ecore_con.eo.h
|
${ecorecon_eobuiltheaders}
|
||||||
|
|
||||||
lib_ecore_con_libecore_con_la_SOURCES = \
|
lib_ecore_con_libecore_con_la_SOURCES = \
|
||||||
lib/ecore_con/ecore_con_alloc.c \
|
lib/ecore_con/ecore_con_alloc.c \
|
||||||
|
|
|
@ -230,13 +230,6 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
typedef struct _Ecore_Con_Server Ecore_Con_Server;
|
typedef struct _Ecore_Con_Server Ecore_Con_Server;
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef Ecore_Con_Client
|
|
||||||
* A connection handle to a client
|
|
||||||
* @ingroup Ecore_Con_Client_Group
|
|
||||||
*/
|
|
||||||
typedef struct _Ecore_Con_Client Ecore_Con_Client;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef Ecore_Con_Socks
|
* @typedef Ecore_Con_Socks
|
||||||
* An object representing a SOCKS proxy
|
* An object representing a SOCKS proxy
|
||||||
|
@ -252,6 +245,12 @@ typedef struct Ecore_Con_Socks Ecore_Con_Socks;
|
||||||
*/
|
*/
|
||||||
typedef struct _Ecore_Con_Url Ecore_Con_Url;
|
typedef struct _Ecore_Con_Url Ecore_Con_Url;
|
||||||
|
|
||||||
|
#ifndef EFL_NOLEGACY_API_SUPPORT
|
||||||
|
#include "Ecore_Con_Legacy.h"
|
||||||
|
#endif
|
||||||
|
#ifdef EFL_EO_API_SUPPORT
|
||||||
|
#include "Ecore_Con_Eo.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup Ecore_Con_Events_Group
|
* @addtogroup Ecore_Con_Events_Group
|
||||||
|
@ -605,16 +604,6 @@ EAPI extern int ECORE_CON_EVENT_URL_PROGRESS;
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
* @typedef Ecore_Con_Type
|
||||||
* @enum _Ecore_Con_Type
|
* @enum _Ecore_Con_Type
|
||||||
|
@ -1076,7 +1065,7 @@ EAPI int ecore_con_server_fd_get(Ecore_Con_Server *svr);
|
||||||
* It should not be tampered with unless you REALLY know what you are doing.
|
* It should not be tampered with unless you REALLY know what you are doing.
|
||||||
* @since 1.1
|
* @since 1.1
|
||||||
*/
|
*/
|
||||||
EAPI int ecore_con_client_fd_get(Ecore_Con_Client *cl);
|
EAPI int ecore_con_client_fd_get(const Ecore_Con_Client *cl);
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
@ -1121,14 +1110,6 @@ EAPI int ecore_con_client_fd_get(Ecore_Con_Client *cl);
|
||||||
EAPI int ecore_con_client_send(Ecore_Con_Client *cl,
|
EAPI int ecore_con_client_send(Ecore_Con_Client *cl,
|
||||||
const void *data,
|
const void *data,
|
||||||
int size);
|
int size);
|
||||||
/**
|
|
||||||
* Retrieves the server representing the socket the client has
|
|
||||||
* connected to.
|
|
||||||
*
|
|
||||||
* @param cl The given client.
|
|
||||||
* @return The server that the client connected to.
|
|
||||||
*/
|
|
||||||
EAPI Ecore_Con_Server *ecore_con_client_server_get(Ecore_Con_Client *cl);
|
|
||||||
/**
|
/**
|
||||||
* Closes the connection and frees memory allocated to the given client.
|
* Closes the connection and frees memory allocated to the given client.
|
||||||
*
|
*
|
||||||
|
@ -1162,7 +1143,7 @@ EAPI void * ecore_con_client_data_get(Ecore_Con_Client *cl);
|
||||||
* The returned string should not be modified, freed or trusted to stay valid
|
* The returned string should not be modified, freed or trusted to stay valid
|
||||||
* after deletion for the @p cl object. If no IP is known @c NULL is returned.
|
* after deletion for the @p cl object. If no IP is known @c NULL is returned.
|
||||||
*/
|
*/
|
||||||
EAPI const char * ecore_con_client_ip_get(Ecore_Con_Client *cl);
|
EAPI const char * ecore_con_client_ip_get(const Ecore_Con_Client *cl);
|
||||||
/**
|
/**
|
||||||
* Flushes all pending data to the given client.
|
* Flushes all pending data to the given client.
|
||||||
*
|
*
|
||||||
|
@ -1183,7 +1164,7 @@ EAPI void ecore_con_client_flush(Ecore_Con_Client *cl);
|
||||||
*
|
*
|
||||||
* This function is used to find out how long a client has been connected for.
|
* This function is used to find out how long a client has been connected for.
|
||||||
*/
|
*/
|
||||||
EAPI double ecore_con_client_uptime_get(Ecore_Con_Client *cl);
|
EAPI double ecore_con_client_uptime_get(const Ecore_Con_Client *cl);
|
||||||
/**
|
/**
|
||||||
* Get the default time after which the client will be disconnected when
|
* Get the default time after which the client will be disconnected when
|
||||||
* inactive
|
* inactive
|
||||||
|
@ -1196,7 +1177,7 @@ EAPI double ecore_con_client_uptime_get(Ecore_Con_Client *cl);
|
||||||
*
|
*
|
||||||
* @see ecore_con_client_timeout_set()
|
* @see ecore_con_client_timeout_set()
|
||||||
*/
|
*/
|
||||||
EAPI double ecore_con_client_timeout_get(Ecore_Con_Client *cl);
|
EAPI double ecore_con_client_timeout_get(const Ecore_Con_Client *cl);
|
||||||
/**
|
/**
|
||||||
* Set the time after which the client will be disconnected when inactive
|
* Set the time after which the client will be disconnected when inactive
|
||||||
*
|
*
|
||||||
|
@ -1223,7 +1204,7 @@ EAPI void ecore_con_client_timeout_set(Ecore_Con_Client *cl, double
|
||||||
* @param cl The given client.
|
* @param cl The given client.
|
||||||
* @return @c EINA_TRUE if connected, @c EINA_FALSE otherwise.
|
* @return @c EINA_TRUE if connected, @c EINA_FALSE otherwise.
|
||||||
*/
|
*/
|
||||||
EAPI Eina_Bool ecore_con_client_connected_get(Ecore_Con_Client *cl);
|
EAPI Eina_Bool ecore_con_client_connected_get(const Ecore_Con_Client *cl);
|
||||||
/**
|
/**
|
||||||
* @brief Return the port that the client has connected to
|
* @brief Return the port that the client has connected to
|
||||||
*
|
*
|
||||||
|
@ -1231,7 +1212,7 @@ EAPI Eina_Bool ecore_con_client_connected_get(Ecore_Con_Client *cl);
|
||||||
* @return The port that @p cl has connected to, or -1 on error
|
* @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.
|
* Use this function to return the port on which a given client has connected.
|
||||||
*/
|
*/
|
||||||
EAPI int ecore_con_client_port_get(Ecore_Con_Client *cl);
|
EAPI int ecore_con_client_port_get(const Ecore_Con_Client *cl);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1929,13 +1910,6 @@ EAPI int ecore_con_url_status_code_get(Ecore_Con_Url *url_con);
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef EFL_NOLEGACY_API_SUPPORT
|
|
||||||
#include "Ecore_Con_Legacy.h"
|
|
||||||
#endif
|
|
||||||
#ifdef EFL_EO_API_SUPPORT
|
|
||||||
#include "Ecore_Con_Eo.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
#include "ecore_con.eo.h"
|
#include "ecore_con.eo.h"
|
||||||
|
#include "ecore_con_client.eo.h"
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
#include "ecore_con.eo.legacy.h"
|
#include "ecore_con.eo.legacy.h"
|
||||||
|
#include "ecore_con_client.eo.legacy.h"
|
||||||
|
|
|
@ -79,7 +79,7 @@ static Eina_Bool _ecore_con_svr_cl_handler(void *data,
|
||||||
Ecore_Fd_Handler *fd_handler);
|
Ecore_Fd_Handler *fd_handler);
|
||||||
|
|
||||||
static void _ecore_con_server_flush(Ecore_Con_Server *svr);
|
static void _ecore_con_server_flush(Ecore_Con_Server *svr);
|
||||||
static void _ecore_con_client_flush(Ecore_Con_Client *cl);
|
static void _ecore_con_client_flush(Ecore_Con_Client *obj);
|
||||||
|
|
||||||
static void _ecore_con_event_client_add_free(Ecore_Con_Server *svr,
|
static void _ecore_con_event_client_add_free(Ecore_Con_Server *svr,
|
||||||
void *ev);
|
void *ev);
|
||||||
|
@ -113,13 +113,14 @@ int sd_fd_max = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
_ecore_con_client_kill(Ecore_Con_Client *cl)
|
_ecore_con_client_kill(Ecore_Con_Client *obj)
|
||||||
{
|
{
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(obj, ECORE_CON_CLIENT_CLASS);
|
||||||
if (cl->delete_me)
|
if (cl->delete_me)
|
||||||
DBG("Multi kill request for client %p", cl);
|
DBG("Multi kill request for client %p", cl);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ecore_con_event_client_del(cl);
|
ecore_con_event_client_del(obj);
|
||||||
if (cl->buf) return;
|
if (cl->buf) return;
|
||||||
}
|
}
|
||||||
INF("Lost client %s", (cl->ip) ? cl->ip : "");
|
INF("Lost client %s", (cl->ip) ? cl->ip : "");
|
||||||
|
@ -749,16 +750,14 @@ ecore_con_server_flush(Ecore_Con_Server *svr)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
EAPI int
|
EAPI int
|
||||||
ecore_con_client_send(Ecore_Con_Client *cl,
|
ecore_con_client_send(Ecore_Con *obj, const void *data, int size)
|
||||||
const void *data,
|
|
||||||
int size)
|
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
return eo_do((Ecore_Con *)obj, ecore_con_obj_send(data, size));
|
||||||
{
|
|
||||||
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_send");
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EOLIAN static int
|
||||||
|
_ecore_con_client_ecore_con_send(Eo *obj EINA_UNUSED, Ecore_Con_Client_Data *cl, const void *data, int size)
|
||||||
|
{
|
||||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(cl->delete_me, 0);
|
EINA_SAFETY_ON_TRUE_RETURN_VAL(cl->delete_me, 0);
|
||||||
|
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(data, 0);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(data, 0);
|
||||||
|
@ -793,121 +792,100 @@ ecore_con_client_send(Ecore_Con_Client *cl,
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI Ecore_Con_Server *
|
EOLIAN static Ecore_Con_Server *
|
||||||
ecore_con_client_server_get(Ecore_Con_Client *cl)
|
_ecore_con_client_server_get(Eo *obj EINA_UNUSED, Ecore_Con_Client_Data *cl)
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
|
||||||
{
|
|
||||||
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT,
|
|
||||||
"ecore_con_client_server_get");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return cl->host_server;
|
return cl->host_server;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI Eina_Bool
|
EOLIAN static Eina_Bool
|
||||||
ecore_con_client_connected_get(Ecore_Con_Client *cl)
|
_ecore_con_client_ecore_con_connected_get(Eo *obj EINA_UNUSED, Ecore_Con_Client_Data *cl)
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
|
||||||
{
|
|
||||||
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT,
|
|
||||||
"ecore_con_client_connected_get");
|
|
||||||
return EINA_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return !cl->delete_me;
|
return !cl->delete_me;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI Eina_Bool
|
||||||
ecore_con_client_timeout_set(Ecore_Con_Client *cl,
|
ecore_con_client_connected_get(const Ecore_Con *obj)
|
||||||
double timeout)
|
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
return eo_do((Ecore_Con *)obj, ecore_con_obj_connected_get());
|
||||||
{
|
|
||||||
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT,
|
|
||||||
"ecore_con_client_timeout_set");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EOLIAN static void
|
||||||
|
_ecore_con_client_ecore_con_timeout_set(Eo *obj, Ecore_Con_Client_Data *cl, double timeout)
|
||||||
|
{
|
||||||
cl->disconnect_time = timeout;
|
cl->disconnect_time = timeout;
|
||||||
|
|
||||||
_ecore_con_cl_timer_update(cl);
|
_ecore_con_cl_timer_update(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI double
|
EAPI void
|
||||||
ecore_con_client_timeout_get(Ecore_Con_Client *cl)
|
ecore_con_client_timeout_set(Ecore_Con *obj, double timeout)
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
eo_do((Ecore_Con *)obj, ecore_con_obj_timeout_set(timeout));
|
||||||
{
|
|
||||||
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_timeout_get");
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EOLIAN static double
|
||||||
|
_ecore_con_client_ecore_con_timeout_get(Eo *obj EINA_UNUSED, Ecore_Con_Client_Data *cl)
|
||||||
|
{
|
||||||
return cl->disconnect_time;
|
return cl->disconnect_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void *
|
EAPI double
|
||||||
ecore_con_client_del(Ecore_Con_Client *cl)
|
ecore_con_client_timeout_get(const Ecore_Con *obj)
|
||||||
{
|
{
|
||||||
if (!cl) return NULL;
|
return eo_do((Ecore_Con *)obj, ecore_con_obj_timeout_get());
|
||||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
|
||||||
{
|
|
||||||
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_del");
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_ecore_con_client_kill(cl);
|
EAPI void *
|
||||||
|
ecore_con_client_del(Ecore_Con_Client *obj)
|
||||||
|
{
|
||||||
|
if (!obj) return NULL;
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(obj, ECORE_CON_CLIENT_CLASS);
|
||||||
|
if (!cl) return NULL;
|
||||||
|
|
||||||
|
_ecore_con_client_kill(obj);
|
||||||
return cl->data;
|
return cl->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
ecore_con_client_data_set(Ecore_Con_Client *cl,
|
ecore_con_client_data_set(Ecore_Con_Client *obj,
|
||||||
const void *data)
|
const void *data)
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(obj, ECORE_CON_CLIENT_CLASS);
|
||||||
{
|
if (!cl)
|
||||||
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_data_set");
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
cl->data = (void *)data;
|
cl->data = (void *)data;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void *
|
EAPI void *
|
||||||
ecore_con_client_data_get(Ecore_Con_Client *cl)
|
ecore_con_client_data_get(Ecore_Con_Client *obj)
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(obj, ECORE_CON_CLIENT_CLASS);
|
||||||
{
|
if (!cl)
|
||||||
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_data_get");
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
return cl->data;
|
return cl->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI const char *
|
EOLIAN static const char *
|
||||||
ecore_con_client_ip_get(Ecore_Con_Client *cl)
|
_ecore_con_client_ecore_con_ip_get(Eo *obj EINA_UNUSED, Ecore_Con_Client_Data *cl)
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
|
||||||
{
|
|
||||||
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_ip_get");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (!cl->ip)
|
if (!cl->ip)
|
||||||
cl->ip = _ecore_con_pretty_ip(cl->client_addr);
|
cl->ip = _ecore_con_pretty_ip(cl->client_addr);
|
||||||
|
|
||||||
return cl->ip;
|
return cl->ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI int
|
EAPI const char *
|
||||||
ecore_con_client_port_get(Ecore_Con_Client *cl)
|
ecore_con_client_ip_get(const Ecore_Con *obj)
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
return eo_do(obj, ecore_con_obj_ip_get());
|
||||||
{
|
|
||||||
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_port_get");
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EOLIAN static int
|
||||||
|
_ecore_con_client_ecore_con_port_get(Eo *obj EINA_UNUSED, Ecore_Con_Client_Data *cl)
|
||||||
|
{
|
||||||
if (cl->client_addr->sa_family == AF_INET)
|
if (cl->client_addr->sa_family == AF_INET)
|
||||||
return ((struct sockaddr_in *)cl->client_addr)->sin_port;
|
return ((struct sockaddr_in *)cl->client_addr)->sin_port;
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
|
@ -917,28 +895,34 @@ ecore_con_client_port_get(Ecore_Con_Client *cl)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI double
|
EAPI int
|
||||||
ecore_con_client_uptime_get(Ecore_Con_Client *cl)
|
ecore_con_client_port_get(const Ecore_Con *obj)
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
return eo_do((Ecore_Con *)obj, ecore_con_obj_port_get());
|
||||||
{
|
|
||||||
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_uptime_get");
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EOLIAN static double
|
||||||
|
_ecore_con_client_ecore_con_uptime_get(Eo *obj EINA_UNUSED, Ecore_Con_Client_Data *cl)
|
||||||
|
{
|
||||||
return ecore_time_get() - cl->start_time;
|
return ecore_time_get() - cl->start_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI double
|
||||||
ecore_con_client_flush(Ecore_Con_Client *cl)
|
ecore_con_client_uptime_get(const Ecore_Con *obj)
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
return eo_do(obj, ecore_con_obj_uptime_get());
|
||||||
{
|
|
||||||
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_flush");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_ecore_con_client_flush(cl);
|
EOLIAN static void
|
||||||
|
_ecore_con_client_ecore_con_flush(Eo *obj, Ecore_Con_Client_Data *cl EINA_UNUSED)
|
||||||
|
{
|
||||||
|
_ecore_con_client_flush(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
ecore_con_client_flush(Ecore_Con *obj)
|
||||||
|
{
|
||||||
|
eo_do((Ecore_Con *)obj, ecore_con_obj_flush());
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI int
|
EAPI int
|
||||||
|
@ -954,17 +938,18 @@ ecore_con_server_fd_get(Ecore_Con_Server *svr)
|
||||||
return ecore_main_fd_handler_fd_get(svr->fd_handler);
|
return ecore_main_fd_handler_fd_get(svr->fd_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI int
|
EOLIAN static int
|
||||||
ecore_con_client_fd_get(Ecore_Con_Client *cl)
|
_ecore_con_client_ecore_con_fd_get(Eo *obj EINA_UNUSED, Ecore_Con_Client_Data *cl)
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
|
||||||
{
|
|
||||||
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, __func__);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return ecore_main_fd_handler_fd_get(cl->fd_handler);
|
return ecore_main_fd_handler_fd_get(cl->fd_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI int
|
||||||
|
ecore_con_client_fd_get(const Ecore_Con *obj)
|
||||||
|
{
|
||||||
|
return eo_do((Ecore_Con *)obj, ecore_con_obj_fd_get());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
@ -1081,8 +1066,9 @@ ecore_con_event_server_data(Ecore_Con_Server *svr, unsigned char *buf, int num,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ecore_con_event_client_add(Ecore_Con_Client *cl)
|
ecore_con_event_client_add(Ecore_Con_Client *obj)
|
||||||
{
|
{
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(obj, ECORE_CON_CLIENT_CLASS);
|
||||||
Ecore_Con_Event_Client_Add *e;
|
Ecore_Con_Event_Client_Add *e;
|
||||||
int ev = ECORE_CON_EVENT_CLIENT_ADD;
|
int ev = ECORE_CON_EVENT_CLIENT_ADD;
|
||||||
|
|
||||||
|
@ -1091,9 +1077,9 @@ ecore_con_event_client_add(Ecore_Con_Client *cl)
|
||||||
|
|
||||||
cl->event_count = eina_list_append(cl->event_count, e);
|
cl->event_count = eina_list_append(cl->event_count, e);
|
||||||
cl->host_server->event_count = eina_list_append(cl->host_server->event_count, e);
|
cl->host_server->event_count = eina_list_append(cl->host_server->event_count, e);
|
||||||
_ecore_con_cl_timer_update(cl);
|
_ecore_con_cl_timer_update(obj);
|
||||||
cl->start_time = ecore_time_get();
|
cl->start_time = ecore_time_get();
|
||||||
e->client = cl;
|
e->client = obj;
|
||||||
if (cl->upgrade) ev = ECORE_CON_EVENT_CLIENT_UPGRADE;
|
if (cl->upgrade) ev = ECORE_CON_EVENT_CLIENT_UPGRADE;
|
||||||
ecore_event_add(ev, e,
|
ecore_event_add(ev, e,
|
||||||
(Ecore_End_Cb)_ecore_con_event_client_add_free, cl->host_server);
|
(Ecore_End_Cb)_ecore_con_event_client_add_free, cl->host_server);
|
||||||
|
@ -1101,8 +1087,9 @@ ecore_con_event_client_add(Ecore_Con_Client *cl)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ecore_con_event_client_del(Ecore_Con_Client *cl)
|
ecore_con_event_client_del(Ecore_Con_Client *obj)
|
||||||
{
|
{
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(obj, ECORE_CON_CLIENT_CLASS);
|
||||||
Ecore_Con_Event_Client_Del *e;
|
Ecore_Con_Event_Client_Del *e;
|
||||||
|
|
||||||
if (!cl) return;
|
if (!cl) return;
|
||||||
|
@ -1113,16 +1100,17 @@ ecore_con_event_client_del(Ecore_Con_Client *cl)
|
||||||
cl->event_count = eina_list_append(cl->event_count, e);
|
cl->event_count = eina_list_append(cl->event_count, e);
|
||||||
|
|
||||||
cl->host_server->event_count = eina_list_append(cl->host_server->event_count, e);
|
cl->host_server->event_count = eina_list_append(cl->host_server->event_count, e);
|
||||||
_ecore_con_cl_timer_update(cl);
|
_ecore_con_cl_timer_update(obj);
|
||||||
e->client = cl;
|
e->client = obj;
|
||||||
ecore_event_add(ECORE_CON_EVENT_CLIENT_DEL, e,
|
ecore_event_add(ECORE_CON_EVENT_CLIENT_DEL, e,
|
||||||
(Ecore_End_Cb)_ecore_con_event_client_del_free, cl->host_server);
|
(Ecore_End_Cb)_ecore_con_event_client_del_free, cl->host_server);
|
||||||
_ecore_con_event_count++;
|
_ecore_con_event_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ecore_con_event_client_write(Ecore_Con_Client *cl, int num)
|
ecore_con_event_client_write(Ecore_Con_Client *obj, int num)
|
||||||
{
|
{
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(obj, ECORE_CON_CLIENT_CLASS);
|
||||||
Ecore_Con_Event_Client_Write *e;
|
Ecore_Con_Event_Client_Write *e;
|
||||||
|
|
||||||
e = ecore_con_event_client_write_alloc();
|
e = ecore_con_event_client_write_alloc();
|
||||||
|
@ -1130,7 +1118,7 @@ ecore_con_event_client_write(Ecore_Con_Client *cl, int num)
|
||||||
|
|
||||||
cl->event_count = eina_list_append(cl->event_count, e);
|
cl->event_count = eina_list_append(cl->event_count, e);
|
||||||
cl->host_server->event_count = eina_list_append(cl->host_server->event_count, e);
|
cl->host_server->event_count = eina_list_append(cl->host_server->event_count, e);
|
||||||
e->client = cl;
|
e->client = obj;
|
||||||
e->size = num;
|
e->size = num;
|
||||||
ecore_event_add(ECORE_CON_EVENT_CLIENT_WRITE, e,
|
ecore_event_add(ECORE_CON_EVENT_CLIENT_WRITE, e,
|
||||||
(Ecore_End_Cb)_ecore_con_event_client_write_free, cl->host_server);
|
(Ecore_End_Cb)_ecore_con_event_client_write_free, cl->host_server);
|
||||||
|
@ -1138,8 +1126,9 @@ ecore_con_event_client_write(Ecore_Con_Client *cl, int num)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ecore_con_event_client_data(Ecore_Con_Client *cl, unsigned char *buf, int num, Eina_Bool duplicate)
|
ecore_con_event_client_data(Ecore_Con_Client *obj, unsigned char *buf, int num, Eina_Bool duplicate)
|
||||||
{
|
{
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(obj, ECORE_CON_CLIENT_CLASS);
|
||||||
Ecore_Con_Event_Client_Data *e;
|
Ecore_Con_Event_Client_Data *e;
|
||||||
|
|
||||||
e = ecore_con_event_client_data_alloc();
|
e = ecore_con_event_client_data_alloc();
|
||||||
|
@ -1147,8 +1136,8 @@ ecore_con_event_client_data(Ecore_Con_Client *cl, unsigned char *buf, int num, E
|
||||||
|
|
||||||
cl->event_count = eina_list_append(cl->event_count, e);
|
cl->event_count = eina_list_append(cl->event_count, e);
|
||||||
cl->host_server->event_count = eina_list_append(cl->host_server->event_count, e);
|
cl->host_server->event_count = eina_list_append(cl->host_server->event_count, e);
|
||||||
_ecore_con_cl_timer_update(cl);
|
_ecore_con_cl_timer_update(obj);
|
||||||
e->client = cl;
|
e->client = obj;
|
||||||
if ((duplicate) && (num > 0))
|
if ((duplicate) && (num > 0))
|
||||||
{
|
{
|
||||||
e->data = malloc(num);
|
e->data = malloc(num);
|
||||||
|
@ -1191,14 +1180,15 @@ _ecore_con_event_server_error(Ecore_Con_Server *svr, char *error, Eina_Bool dupl
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ecore_con_event_client_error(Ecore_Con_Client *cl, const char *error)
|
ecore_con_event_client_error(Ecore_Con_Client *obj, const char *error)
|
||||||
{
|
{
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(obj, ECORE_CON_CLIENT_CLASS);
|
||||||
Ecore_Con_Event_Client_Error *e;
|
Ecore_Con_Event_Client_Error *e;
|
||||||
|
|
||||||
e = ecore_con_event_client_error_alloc();
|
e = ecore_con_event_client_error_alloc();
|
||||||
EINA_SAFETY_ON_NULL_RETURN(e);
|
EINA_SAFETY_ON_NULL_RETURN(e);
|
||||||
|
|
||||||
e->client = cl;
|
e->client = obj;
|
||||||
e->error = strdup(error);
|
e->error = strdup(error);
|
||||||
DBG("%s", error);
|
DBG("%s", error);
|
||||||
cl->event_count = eina_list_append(cl->event_count, e);
|
cl->event_count = eina_list_append(cl->event_count, e);
|
||||||
|
@ -1210,7 +1200,7 @@ ecore_con_event_client_error(Ecore_Con_Client *cl, const char *error)
|
||||||
static void
|
static void
|
||||||
_ecore_con_server_free(Ecore_Con_Server *svr)
|
_ecore_con_server_free(Ecore_Con_Server *svr)
|
||||||
{
|
{
|
||||||
Ecore_Con_Client *cl;
|
Ecore_Con_Client *cl_obj;
|
||||||
double t_start, t;
|
double t_start, t;
|
||||||
|
|
||||||
if (svr->event_count) return;
|
if (svr->event_count) return;
|
||||||
|
@ -1245,8 +1235,9 @@ _ecore_con_server_free(Ecore_Con_Server *svr)
|
||||||
if (svr->buf)
|
if (svr->buf)
|
||||||
eina_binbuf_free(svr->buf);
|
eina_binbuf_free(svr->buf);
|
||||||
|
|
||||||
EINA_LIST_FREE(svr->clients, cl)
|
EINA_LIST_FREE(svr->clients, cl_obj)
|
||||||
{
|
{
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(cl_obj, ECORE_CON_CLIENT_CLASS);
|
||||||
Ecore_Con_Event_Server_Add *ev;
|
Ecore_Con_Event_Server_Add *ev;
|
||||||
|
|
||||||
/* some pointer hacks here to prevent double frees if people are being stupid */
|
/* some pointer hacks here to prevent double frees if people are being stupid */
|
||||||
|
@ -1254,7 +1245,7 @@ _ecore_con_server_free(Ecore_Con_Server *svr)
|
||||||
ev->server = NULL;
|
ev->server = NULL;
|
||||||
cl->delete_me = EINA_TRUE;
|
cl->delete_me = EINA_TRUE;
|
||||||
INF("cl %p is dead", cl);
|
INF("cl %p is dead", cl);
|
||||||
_ecore_con_client_free(cl);
|
_ecore_con_client_free(cl_obj);
|
||||||
}
|
}
|
||||||
if ((svr->created) && (svr->path) && (svr->ppid == getpid()))
|
if ((svr->created) && (svr->path) && (svr->ppid == getpid()))
|
||||||
unlink(svr->path);
|
unlink(svr->path);
|
||||||
|
@ -1285,7 +1276,13 @@ _ecore_con_server_free(Ecore_Con_Server *svr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_con_client_free(Ecore_Con_Client *cl)
|
_ecore_con_client_free(Ecore_Con_Client *obj)
|
||||||
|
{
|
||||||
|
eo_del(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
EOLIAN static void
|
||||||
|
_ecore_con_client_eo_base_destructor(Eo *obj, Ecore_Con_Client_Data *cl)
|
||||||
{
|
{
|
||||||
double t_start, t;
|
double t_start, t;
|
||||||
|
|
||||||
|
@ -1294,7 +1291,7 @@ _ecore_con_client_free(Ecore_Con_Client *cl)
|
||||||
t_start = ecore_time_get();
|
t_start = ecore_time_get();
|
||||||
while ((cl->buf) && (!cl->delete_me))
|
while ((cl->buf) && (!cl->delete_me))
|
||||||
{
|
{
|
||||||
_ecore_con_client_flush(cl);
|
_ecore_con_client_flush(obj);
|
||||||
t = ecore_time_get();
|
t = ecore_time_get();
|
||||||
if ((t - t_start) > 0.5)
|
if ((t - t_start) > 0.5)
|
||||||
{
|
{
|
||||||
|
@ -1305,7 +1302,7 @@ _ecore_con_client_free(Ecore_Con_Client *cl)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cl->host_server->clients = eina_list_remove(cl->host_server->clients, cl);
|
cl->host_server->clients = eina_list_remove(cl->host_server->clients, obj);
|
||||||
--cl->host_server->client_count;
|
--cl->host_server->client_count;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -1313,12 +1310,11 @@ _ecore_con_client_free(Ecore_Con_Client *cl)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (cl->event_count) return;
|
if (cl->event_count) return;
|
||||||
ECORE_MAGIC_SET(cl, ECORE_MAGIC_NONE);
|
|
||||||
|
|
||||||
if (cl->buf) eina_binbuf_free(cl->buf);
|
if (cl->buf) eina_binbuf_free(cl->buf);
|
||||||
|
|
||||||
if (cl->host_server->type & ECORE_CON_SSL)
|
if (cl->host_server->type & ECORE_CON_SSL)
|
||||||
ecore_con_ssl_client_shutdown(cl);
|
ecore_con_ssl_client_shutdown(obj);
|
||||||
|
|
||||||
if (cl->fd_handler)
|
if (cl->fd_handler)
|
||||||
ecore_main_fd_handler_del(cl->fd_handler);
|
ecore_main_fd_handler_del(cl->fd_handler);
|
||||||
|
@ -1334,8 +1330,8 @@ _ecore_con_client_free(Ecore_Con_Client *cl)
|
||||||
|
|
||||||
eina_stringshare_del(cl->ip);
|
eina_stringshare_del(cl->ip);
|
||||||
cl->data = NULL;
|
cl->data = NULL;
|
||||||
free(cl);
|
|
||||||
return;
|
eo_do_super(obj, ECORE_CON_CLIENT_CLASS, eo_destructor());
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
|
@ -1379,17 +1375,19 @@ _ecore_con_server_timer_update(Ecore_Con_Server *svr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_client_timer(Ecore_Con_Client *cl)
|
_ecore_con_client_timer(Ecore_Con_Client *obj)
|
||||||
{
|
{
|
||||||
ecore_con_client_del(cl);
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(obj, ECORE_CON_CLIENT_CLASS);
|
||||||
|
ecore_con_client_del(obj);
|
||||||
|
|
||||||
cl->until_deletion = NULL;
|
cl->until_deletion = NULL;
|
||||||
return ECORE_CALLBACK_CANCEL;
|
return ECORE_CALLBACK_CANCEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_con_cl_timer_update(Ecore_Con_Client *cl)
|
_ecore_con_cl_timer_update(Ecore_Con_Client *obj)
|
||||||
{
|
{
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(obj, ECORE_CON_CLIENT_CLASS);
|
||||||
if (cl->disconnect_time)
|
if (cl->disconnect_time)
|
||||||
{
|
{
|
||||||
if (cl->disconnect_time > 0)
|
if (cl->disconnect_time > 0)
|
||||||
|
@ -1890,7 +1888,7 @@ _ecore_con_svr_tcp_handler(void *data,
|
||||||
Ecore_Fd_Handler *fd_handler EINA_UNUSED)
|
Ecore_Fd_Handler *fd_handler EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Ecore_Con_Server *svr;
|
Ecore_Con_Server *svr;
|
||||||
Ecore_Con_Client *cl = NULL;
|
Ecore_Con_Client *obj = NULL;
|
||||||
unsigned char client_addr[256];
|
unsigned char client_addr[256];
|
||||||
unsigned int client_addr_len;
|
unsigned int client_addr_len;
|
||||||
const char *clerr = NULL;
|
const char *clerr = NULL;
|
||||||
|
@ -1905,7 +1903,8 @@ _ecore_con_svr_tcp_handler(void *data,
|
||||||
|
|
||||||
/* a new client */
|
/* a new client */
|
||||||
|
|
||||||
cl = calloc(1, sizeof(Ecore_Con_Client));
|
obj = eo_add(ECORE_CON_CLIENT_CLASS, NULL);
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(obj, ECORE_CON_CLIENT_CLASS);
|
||||||
if (!cl)
|
if (!cl)
|
||||||
{
|
{
|
||||||
ecore_con_event_server_error(svr, "Memory allocation failure when attempting to add a new client");
|
ecore_con_event_server_error(svr, "Memory allocation failure when attempting to add a new client");
|
||||||
|
@ -1927,15 +1926,14 @@ _ecore_con_svr_tcp_handler(void *data,
|
||||||
if (fcntl(cl->fd, F_SETFL, O_NONBLOCK) < 0) goto error;
|
if (fcntl(cl->fd, F_SETFL, O_NONBLOCK) < 0) goto error;
|
||||||
if (fcntl(cl->fd, F_SETFD, FD_CLOEXEC) < 0) goto error;
|
if (fcntl(cl->fd, F_SETFD, FD_CLOEXEC) < 0) goto error;
|
||||||
cl->fd_handler = ecore_main_fd_handler_add(cl->fd, ECORE_FD_READ,
|
cl->fd_handler = ecore_main_fd_handler_add(cl->fd, ECORE_FD_READ,
|
||||||
_ecore_con_svr_cl_handler, cl, NULL, NULL);
|
_ecore_con_svr_cl_handler, obj, NULL, NULL);
|
||||||
if (!cl->fd_handler) goto error;
|
if (!cl->fd_handler) goto error;
|
||||||
ECORE_MAGIC_SET(cl, ECORE_MAGIC_CON_CLIENT);
|
|
||||||
|
|
||||||
if ((!svr->upgrade) && (svr->type & ECORE_CON_SSL))
|
if ((!svr->upgrade) && (svr->type & ECORE_CON_SSL))
|
||||||
{
|
{
|
||||||
cl->handshaking = EINA_TRUE;
|
cl->handshaking = EINA_TRUE;
|
||||||
cl->ssl_state = ECORE_CON_SSL_STATE_INIT;
|
cl->ssl_state = ECORE_CON_SSL_STATE_INIT;
|
||||||
if (ecore_con_ssl_client_init(cl))
|
if (ecore_con_ssl_client_init(obj))
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1948,11 +1946,11 @@ _ecore_con_svr_tcp_handler(void *data,
|
||||||
cl->client_addr_len = client_addr_len;
|
cl->client_addr_len = client_addr_len;
|
||||||
memcpy(cl->client_addr, &client_addr, client_addr_len);
|
memcpy(cl->client_addr, &client_addr, client_addr_len);
|
||||||
|
|
||||||
svr->clients = eina_list_append(svr->clients, cl);
|
svr->clients = eina_list_append(svr->clients, obj);
|
||||||
svr->client_count++;
|
svr->client_count++;
|
||||||
|
|
||||||
if ((!cl->delete_me) && (!cl->handshaking))
|
if ((!cl->delete_me) && (!cl->handshaking))
|
||||||
ecore_con_event_client_add(cl);
|
ecore_con_event_client_add(obj);
|
||||||
|
|
||||||
return ECORE_CALLBACK_RENEW;
|
return ECORE_CALLBACK_RENEW;
|
||||||
|
|
||||||
|
@ -2129,7 +2127,7 @@ _ecore_con_svr_udp_handler(void *data,
|
||||||
socklen_t client_addr_len = sizeof(client_addr);
|
socklen_t client_addr_len = sizeof(client_addr);
|
||||||
int num;
|
int num;
|
||||||
Ecore_Con_Server *svr;
|
Ecore_Con_Server *svr;
|
||||||
Ecore_Con_Client *cl = NULL;
|
Ecore_Con_Client *obj = NULL;
|
||||||
|
|
||||||
svr = data;
|
svr = data;
|
||||||
|
|
||||||
|
@ -2165,7 +2163,8 @@ _ecore_con_svr_udp_handler(void *data,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a new client for use in the client data event */
|
/* Create a new client for use in the client data event */
|
||||||
cl = calloc(1, sizeof(Ecore_Con_Client));
|
obj = eo_add(ECORE_CON_CLIENT_CLASS, NULL);
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(obj, ECORE_CON_CLIENT_CLASS);
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(cl, ECORE_CALLBACK_RENEW);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(cl, ECORE_CALLBACK_RENEW);
|
||||||
|
|
||||||
cl->host_server = svr;
|
cl->host_server = svr;
|
||||||
|
@ -2178,19 +2177,19 @@ _ecore_con_svr_udp_handler(void *data,
|
||||||
cl->client_addr_len = client_addr_len;
|
cl->client_addr_len = client_addr_len;
|
||||||
|
|
||||||
memcpy(cl->client_addr, &client_addr, client_addr_len);
|
memcpy(cl->client_addr, &client_addr, client_addr_len);
|
||||||
ECORE_MAGIC_SET(cl, ECORE_MAGIC_CON_CLIENT);
|
svr->clients = eina_list_append(svr->clients, obj);
|
||||||
svr->clients = eina_list_append(svr->clients, cl);
|
|
||||||
svr->client_count++;
|
svr->client_count++;
|
||||||
|
|
||||||
ecore_con_event_client_add(cl);
|
ecore_con_event_client_add(obj);
|
||||||
ecore_con_event_client_data(cl, buf, num, EINA_TRUE);
|
ecore_con_event_client_data(obj, buf, num, EINA_TRUE);
|
||||||
|
|
||||||
return ECORE_CALLBACK_RENEW;
|
return ECORE_CALLBACK_RENEW;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_con_svr_cl_read(Ecore_Con_Client *cl)
|
_ecore_con_svr_cl_read(Ecore_Con_Client *obj)
|
||||||
{
|
{
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(obj, ECORE_CON_CLIENT_CLASS);
|
||||||
int num = 0;
|
int num = 0;
|
||||||
Eina_Bool lost_client = EINA_TRUE;
|
Eina_Bool lost_client = EINA_TRUE;
|
||||||
unsigned char buf[READBUFSIZ];
|
unsigned char buf[READBUFSIZ];
|
||||||
|
@ -2202,10 +2201,10 @@ _ecore_con_svr_cl_read(Ecore_Con_Client *cl)
|
||||||
/* add an extra handshake attempt just before read, even though
|
/* add an extra handshake attempt just before read, even though
|
||||||
* read also attempts to handshake, to try to finish sooner
|
* read also attempts to handshake, to try to finish sooner
|
||||||
*/
|
*/
|
||||||
if (ecore_con_ssl_client_init(cl))
|
if (ecore_con_ssl_client_init(obj))
|
||||||
lost_client = EINA_FALSE;
|
lost_client = EINA_FALSE;
|
||||||
|
|
||||||
_ecore_con_cl_timer_update(cl);
|
_ecore_con_cl_timer_update(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(cl->host_server->type & ECORE_CON_SSL) && (!cl->upgrade))
|
if (!(cl->host_server->type & ECORE_CON_SSL) && (!cl->upgrade))
|
||||||
|
@ -2215,48 +2214,48 @@ _ecore_con_svr_cl_read(Ecore_Con_Client *cl)
|
||||||
if ((num > 0) || ((num < 0) && ((errno == EAGAIN) || (errno == EINTR))))
|
if ((num > 0) || ((num < 0) && ((errno == EAGAIN) || (errno == EINTR))))
|
||||||
lost_client = EINA_FALSE;
|
lost_client = EINA_FALSE;
|
||||||
else if (num < 0)
|
else if (num < 0)
|
||||||
ecore_con_event_client_error(cl, strerror(errno));
|
ecore_con_event_client_error(obj, strerror(errno));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
num = ecore_con_ssl_client_read(cl, buf, sizeof(buf));
|
num = ecore_con_ssl_client_read(obj, buf, sizeof(buf));
|
||||||
/* this is not an actual 0 return, 0 here just means non-fatal error such as EAGAIN */
|
/* this is not an actual 0 return, 0 here just means non-fatal error such as EAGAIN */
|
||||||
if (num >= 0)
|
if (num >= 0)
|
||||||
lost_client = EINA_FALSE;
|
lost_client = EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!cl->delete_me) && (num > 0))
|
if ((!cl->delete_me) && (num > 0))
|
||||||
ecore_con_event_client_data(cl, buf, num, EINA_TRUE);
|
ecore_con_event_client_data(obj, buf, num, EINA_TRUE);
|
||||||
|
|
||||||
if (lost_client) _ecore_con_client_kill(cl);
|
if (lost_client) _ecore_con_client_kill(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_ecore_con_svr_cl_handler(void *data,
|
_ecore_con_svr_cl_handler(void *data,
|
||||||
Ecore_Fd_Handler *fd_handler)
|
Ecore_Fd_Handler *fd_handler)
|
||||||
{
|
{
|
||||||
Ecore_Con_Client *cl;
|
Ecore_Con_Client *obj = data;
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(obj, ECORE_CON_CLIENT_CLASS);
|
||||||
|
|
||||||
cl = data;
|
|
||||||
if (cl->delete_me)
|
if (cl->delete_me)
|
||||||
return ECORE_CALLBACK_RENEW;
|
return ECORE_CALLBACK_RENEW;
|
||||||
|
|
||||||
if (cl->handshaking && ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ | ECORE_FD_WRITE))
|
if (cl->handshaking && ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ | ECORE_FD_WRITE))
|
||||||
{
|
{
|
||||||
if (ecore_con_ssl_client_init(cl))
|
if (ecore_con_ssl_client_init(obj))
|
||||||
{
|
{
|
||||||
ERR("ssl handshaking failed!");
|
ERR("ssl handshaking failed!");
|
||||||
_ecore_con_client_kill(cl);
|
_ecore_con_client_kill(obj);
|
||||||
return ECORE_CALLBACK_RENEW;
|
return ECORE_CALLBACK_RENEW;
|
||||||
}
|
}
|
||||||
else if (!cl->ssl_state)
|
else if (!cl->ssl_state)
|
||||||
ecore_con_event_client_add(cl);
|
ecore_con_event_client_add(obj);
|
||||||
}
|
}
|
||||||
else if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))
|
else if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))
|
||||||
_ecore_con_svr_cl_read(cl);
|
_ecore_con_svr_cl_read(obj);
|
||||||
|
|
||||||
else if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_WRITE))
|
else if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_WRITE))
|
||||||
_ecore_con_client_flush(cl);
|
_ecore_con_client_flush(obj);
|
||||||
|
|
||||||
return ECORE_CALLBACK_RENEW;
|
return ECORE_CALLBACK_RENEW;
|
||||||
}
|
}
|
||||||
|
@ -2372,8 +2371,9 @@ _ecore_con_server_flush(Ecore_Con_Server *svr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_con_client_flush(Ecore_Con_Client *cl)
|
_ecore_con_client_flush(Ecore_Con_Client *obj)
|
||||||
{
|
{
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(obj, ECORE_CON_CLIENT_CLASS);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
size_t num = 0;
|
size_t num = 0;
|
||||||
|
|
||||||
|
@ -2391,10 +2391,10 @@ _ecore_con_client_flush(Ecore_Con_Client *cl)
|
||||||
|
|
||||||
if (cl->handshaking)
|
if (cl->handshaking)
|
||||||
{
|
{
|
||||||
if (ecore_con_ssl_client_init(cl))
|
if (ecore_con_ssl_client_init(obj))
|
||||||
count = -1;
|
count = -1;
|
||||||
|
|
||||||
_ecore_con_cl_timer_update(cl);
|
_ecore_con_cl_timer_update(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!count)
|
if (!count)
|
||||||
|
@ -2405,21 +2405,21 @@ _ecore_con_client_flush(Ecore_Con_Client *cl)
|
||||||
if (!(cl->host_server->type & ECORE_CON_SSL) && (!cl->upgrade))
|
if (!(cl->host_server->type & ECORE_CON_SSL) && (!cl->upgrade))
|
||||||
count = write(cl->fd, eina_binbuf_string_get(cl->buf) + cl->buf_offset, num);
|
count = write(cl->fd, eina_binbuf_string_get(cl->buf) + cl->buf_offset, num);
|
||||||
else
|
else
|
||||||
count = ecore_con_ssl_client_write(cl, eina_binbuf_string_get(cl->buf) + cl->buf_offset, num);
|
count = ecore_con_ssl_client_write(obj, eina_binbuf_string_get(cl->buf) + cl->buf_offset, num);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count < 0)
|
if (count < 0)
|
||||||
{
|
{
|
||||||
if ((errno != EAGAIN) && (errno != EINTR) && (!cl->delete_me))
|
if ((errno != EAGAIN) && (errno != EINTR) && (!cl->delete_me))
|
||||||
{
|
{
|
||||||
ecore_con_event_client_error(cl, strerror(errno));
|
ecore_con_event_client_error(obj, strerror(errno));
|
||||||
_ecore_con_client_kill(cl);
|
_ecore_con_client_kill(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count) ecore_con_event_client_write(cl, count);
|
if (count) ecore_con_event_client_write(obj, count);
|
||||||
cl->buf_offset += count, num -= count;
|
cl->buf_offset += count, num -= count;
|
||||||
if (cl->buf_offset >= eina_binbuf_length_get(cl->buf))
|
if (cl->buf_offset >= eina_binbuf_length_get(cl->buf))
|
||||||
{
|
{
|
||||||
|
@ -2451,12 +2451,13 @@ _ecore_con_event_client_add_free(Ecore_Con_Server *svr,
|
||||||
e = ev;
|
e = ev;
|
||||||
if (e->client)
|
if (e->client)
|
||||||
{
|
{
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(e->client, ECORE_CON_CLIENT_CLASS);
|
||||||
Eina_Bool svrfreed = EINA_FALSE;
|
Eina_Bool svrfreed = EINA_FALSE;
|
||||||
|
|
||||||
e->client->event_count = eina_list_remove(e->client->event_count, e);
|
cl->event_count = eina_list_remove(cl->event_count, e);
|
||||||
if (e->client->host_server)
|
if (cl->host_server)
|
||||||
{
|
{
|
||||||
e->client->host_server->event_count = eina_list_remove(e->client->host_server->event_count, ev);
|
cl->host_server->event_count = eina_list_remove(cl->host_server->event_count, ev);
|
||||||
if ((!svr->event_count) && (svr->delete_me))
|
if ((!svr->event_count) && (svr->delete_me))
|
||||||
{
|
{
|
||||||
_ecore_con_server_free(svr);
|
_ecore_con_server_free(svr);
|
||||||
|
@ -2465,7 +2466,7 @@ _ecore_con_event_client_add_free(Ecore_Con_Server *svr,
|
||||||
}
|
}
|
||||||
if (!svrfreed)
|
if (!svrfreed)
|
||||||
{
|
{
|
||||||
if ((!e->client->event_count) && (e->client->delete_me))
|
if ((!cl->event_count) && (cl->delete_me))
|
||||||
ecore_con_client_del(e->client);
|
ecore_con_client_del(e->client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2485,12 +2486,13 @@ _ecore_con_event_client_del_free(Ecore_Con_Server *svr,
|
||||||
e = ev;
|
e = ev;
|
||||||
if (e->client)
|
if (e->client)
|
||||||
{
|
{
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(e->client, ECORE_CON_CLIENT_CLASS);
|
||||||
Eina_Bool svrfreed = EINA_FALSE;
|
Eina_Bool svrfreed = EINA_FALSE;
|
||||||
|
|
||||||
e->client->event_count = eina_list_remove(e->client->event_count, e);
|
cl->event_count = eina_list_remove(cl->event_count, e);
|
||||||
if (e->client->host_server)
|
if (cl->host_server)
|
||||||
{
|
{
|
||||||
e->client->host_server->event_count = eina_list_remove(e->client->host_server->event_count, ev);
|
cl->host_server->event_count = eina_list_remove(cl->host_server->event_count, ev);
|
||||||
if ((!svr->event_count) && (svr->delete_me))
|
if ((!svr->event_count) && (svr->delete_me))
|
||||||
{
|
{
|
||||||
_ecore_con_server_free(svr);
|
_ecore_con_server_free(svr);
|
||||||
|
@ -2499,7 +2501,7 @@ _ecore_con_event_client_del_free(Ecore_Con_Server *svr,
|
||||||
}
|
}
|
||||||
if (!svrfreed)
|
if (!svrfreed)
|
||||||
{
|
{
|
||||||
if (!e->client->event_count)
|
if (!cl->event_count)
|
||||||
_ecore_con_client_free(e->client);
|
_ecore_con_client_free(e->client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2515,12 +2517,13 @@ _ecore_con_event_client_write_free(Ecore_Con_Server *svr,
|
||||||
{
|
{
|
||||||
if (e->client)
|
if (e->client)
|
||||||
{
|
{
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(e->client, ECORE_CON_CLIENT_CLASS);
|
||||||
Eina_Bool svrfreed = EINA_FALSE;
|
Eina_Bool svrfreed = EINA_FALSE;
|
||||||
|
|
||||||
e->client->event_count = eina_list_remove(e->client->event_count, e);
|
cl->event_count = eina_list_remove(cl->event_count, e);
|
||||||
if (e->client->host_server)
|
if (cl->host_server)
|
||||||
{
|
{
|
||||||
e->client->host_server->event_count = eina_list_remove(e->client->host_server->event_count, e);
|
cl->host_server->event_count = eina_list_remove(cl->host_server->event_count, e);
|
||||||
if ((!svr->event_count) && (svr->delete_me))
|
if ((!svr->event_count) && (svr->delete_me))
|
||||||
{
|
{
|
||||||
_ecore_con_server_free(svr);
|
_ecore_con_server_free(svr);
|
||||||
|
@ -2529,10 +2532,10 @@ _ecore_con_event_client_write_free(Ecore_Con_Server *svr,
|
||||||
}
|
}
|
||||||
if (!svrfreed)
|
if (!svrfreed)
|
||||||
{
|
{
|
||||||
if (((!e->client->event_count) && (e->client->delete_me)) ||
|
if (((!cl->event_count) && (cl->delete_me)) ||
|
||||||
((e->client->host_server &&
|
((cl->host_server &&
|
||||||
((e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP ||
|
((cl->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP ||
|
||||||
(e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST))))
|
(cl->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST))))
|
||||||
ecore_con_client_del(e->client);
|
ecore_con_client_del(e->client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2551,12 +2554,13 @@ _ecore_con_event_client_data_free(Ecore_Con_Server *svr,
|
||||||
e = ev;
|
e = ev;
|
||||||
if (e->client)
|
if (e->client)
|
||||||
{
|
{
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(e->client, ECORE_CON_CLIENT_CLASS);
|
||||||
Eina_Bool svrfreed = EINA_FALSE;
|
Eina_Bool svrfreed = EINA_FALSE;
|
||||||
|
|
||||||
e->client->event_count = eina_list_remove(e->client->event_count, e);
|
cl->event_count = eina_list_remove(cl->event_count, e);
|
||||||
if (e->client->host_server)
|
if (cl->host_server)
|
||||||
{
|
{
|
||||||
e->client->host_server->event_count = eina_list_remove(e->client->host_server->event_count, ev);
|
cl->host_server->event_count = eina_list_remove(cl->host_server->event_count, ev);
|
||||||
}
|
}
|
||||||
if ((!svr->event_count) && (svr->delete_me))
|
if ((!svr->event_count) && (svr->delete_me))
|
||||||
{
|
{
|
||||||
|
@ -2565,10 +2569,10 @@ _ecore_con_event_client_data_free(Ecore_Con_Server *svr,
|
||||||
}
|
}
|
||||||
if (!svrfreed)
|
if (!svrfreed)
|
||||||
{
|
{
|
||||||
if (((!e->client->event_count) && (e->client->delete_me)) ||
|
if (((!cl->event_count) && (cl->delete_me)) ||
|
||||||
((e->client->host_server &&
|
((cl->host_server &&
|
||||||
((e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP ||
|
((cl->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP ||
|
||||||
(e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST))))
|
(cl->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST))))
|
||||||
ecore_con_client_del(e->client);
|
ecore_con_client_del(e->client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2676,12 +2680,13 @@ _ecore_con_event_client_error_free(Ecore_Con_Server *svr, Ecore_Con_Event_Client
|
||||||
{
|
{
|
||||||
if (e->client)
|
if (e->client)
|
||||||
{
|
{
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(e->client, ECORE_CON_CLIENT_CLASS);
|
||||||
Eina_Bool svrfreed = EINA_FALSE;
|
Eina_Bool svrfreed = EINA_FALSE;
|
||||||
|
|
||||||
if (eina_list_data_find(svr->clients, e->client))
|
if (eina_list_data_find(svr->clients, e->client))
|
||||||
{
|
{
|
||||||
e->client->event_count = eina_list_remove(e->client->event_count, e);
|
cl->event_count = eina_list_remove(cl->event_count, e);
|
||||||
if ((!e->client->event_count) && (e->client->delete_me))
|
if ((!cl->event_count) && (cl->delete_me))
|
||||||
{
|
{
|
||||||
_ecore_con_client_free(e->client);
|
_ecore_con_client_free(e->client);
|
||||||
svrfreed = EINA_TRUE;
|
svrfreed = EINA_TRUE;
|
||||||
|
@ -2724,3 +2729,4 @@ _ecore_con_lookup_done(void *data,
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "ecore_con.eo.c"
|
#include "ecore_con.eo.c"
|
||||||
|
#include "ecore_con_client.eo.c"
|
||||||
|
|
|
@ -164,3 +164,20 @@ abstract Ecore.Con (Eo.Base) {
|
||||||
virtual.send;
|
virtual.send;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Ecore_Con_Dns_Cb: func void (const(char) *,
|
||||||
|
const(char) *,
|
||||||
|
struct sockaddr *,
|
||||||
|
int,
|
||||||
|
void *);
|
||||||
|
|
||||||
|
/* FIXME: Ecore_Con_Dns_Cb should be like this:
|
||||||
|
type Ecore_Con_Dns_Cb: func void (const(char) *canonname,
|
||||||
|
const(char) *ip,
|
||||||
|
struct sockaddr *addr,
|
||||||
|
int addrlen,
|
||||||
|
void *data);
|
||||||
|
|
||||||
|
|
||||||
|
* Add events
|
||||||
|
*/
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
class Ecore.Con.Client (Ecore.Con) {
|
||||||
|
eo_prefix: ecore_con_client_obj;
|
||||||
|
properties {
|
||||||
|
server {
|
||||||
|
/**
|
||||||
|
* Controls the server representing the socket the client has
|
||||||
|
* connected to.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
get {
|
||||||
|
}
|
||||||
|
values {
|
||||||
|
/* FIXME: Should be Ecore.Con.Server. */
|
||||||
|
Ecore_Con_Server *svr; /*@ The server the client is connected to. */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
implements {
|
||||||
|
Eo.Base.destructor;
|
||||||
|
Ecore.Con.ip.get;
|
||||||
|
Ecore.Con.uptime.get;
|
||||||
|
Ecore.Con.port.get;
|
||||||
|
Ecore.Con.fd.get;
|
||||||
|
Ecore.Con.connected.get;
|
||||||
|
Ecore.Con.timeout.set;
|
||||||
|
Ecore.Con.timeout.get;
|
||||||
|
Ecore.Con.flush;
|
||||||
|
Ecore.Con.send;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIXME: Should SSL inherit from client? What's exactly the interaction here?
|
||||||
|
Fix clients to be children of server when created .*/
|
|
@ -94,9 +94,8 @@ typedef enum Ecore_Con_Proxy_State
|
||||||
ECORE_CON_PROXY_STATE_CONFIRM,
|
ECORE_CON_PROXY_STATE_CONFIRM,
|
||||||
} Ecore_Con_Proxy_State;
|
} Ecore_Con_Proxy_State;
|
||||||
|
|
||||||
struct _Ecore_Con_Client
|
struct _Ecore_Con_Client_Data
|
||||||
{
|
{
|
||||||
ECORE_MAGIC;
|
|
||||||
int fd;
|
int fd;
|
||||||
Ecore_Con_Server *host_server;
|
Ecore_Con_Server *host_server;
|
||||||
void *data;
|
void *data;
|
||||||
|
@ -123,6 +122,8 @@ struct _Ecore_Con_Client
|
||||||
Eina_Bool delete_me : 1; /* del event has been queued */
|
Eina_Bool delete_me : 1; /* del event has been queued */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct _Ecore_Con_Client_Data Ecore_Con_Client_Data;
|
||||||
|
|
||||||
struct _Ecore_Con_Server
|
struct _Ecore_Con_Server
|
||||||
{
|
{
|
||||||
ECORE_MAGIC;
|
ECORE_MAGIC;
|
||||||
|
|
|
@ -518,19 +518,21 @@ ecore_con_ssl_server_write(Ecore_Con_Server *svr,
|
||||||
}
|
}
|
||||||
|
|
||||||
Ecore_Con_Ssl_Error
|
Ecore_Con_Ssl_Error
|
||||||
ecore_con_ssl_client_init(Ecore_Con_Client *cl)
|
ecore_con_ssl_client_init(Ecore_Con_Client *obj)
|
||||||
{
|
{
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(obj, ECORE_CON_CLIENT_CLASS);
|
||||||
if (!(cl->host_server->type & ECORE_CON_SSL))
|
if (!(cl->host_server->type & ECORE_CON_SSL))
|
||||||
return ECORE_CON_SSL_ERROR_NONE;
|
return ECORE_CON_SSL_ERROR_NONE;
|
||||||
return SSL_SUFFIX(_ecore_con_ssl_client_init) (cl);
|
return SSL_SUFFIX(_ecore_con_ssl_client_init) (obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ecore_Con_Ssl_Error
|
Ecore_Con_Ssl_Error
|
||||||
ecore_con_ssl_client_shutdown(Ecore_Con_Client *cl)
|
ecore_con_ssl_client_shutdown(Ecore_Con_Client *obj)
|
||||||
{
|
{
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(obj, ECORE_CON_CLIENT_CLASS);
|
||||||
if (!(cl->host_server->type & ECORE_CON_SSL))
|
if (!(cl->host_server->type & ECORE_CON_SSL))
|
||||||
return ECORE_CON_SSL_ERROR_NONE;
|
return ECORE_CON_SSL_ERROR_NONE;
|
||||||
return SSL_SUFFIX(_ecore_con_ssl_client_shutdown) (cl);
|
return SSL_SUFFIX(_ecore_con_ssl_client_shutdown) (obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -835,11 +837,11 @@ ecore_con_ssl_server_upgrade(Ecore_Con_Server *svr, Ecore_Con_Type ssl_type)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
EAPI Eina_Bool
|
EAPI Eina_Bool
|
||||||
ecore_con_ssl_client_upgrade(Ecore_Con_Client *cl, Ecore_Con_Type ssl_type)
|
ecore_con_ssl_client_upgrade(Ecore_Con_Client *obj, Ecore_Con_Type ssl_type)
|
||||||
{
|
{
|
||||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(obj, ECORE_CON_CLIENT_CLASS);
|
||||||
|
if (!cl)
|
||||||
{
|
{
|
||||||
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, __func__);
|
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
#if _ECORE_CON_SSL_AVAILABLE == 0
|
#if _ECORE_CON_SSL_AVAILABLE == 0
|
||||||
|
@ -857,7 +859,7 @@ ecore_con_ssl_client_upgrade(Ecore_Con_Client *cl, Ecore_Con_Type ssl_type)
|
||||||
cl->host_server->upgrade = EINA_TRUE;
|
cl->host_server->upgrade = EINA_TRUE;
|
||||||
cl->handshaking = EINA_TRUE;
|
cl->handshaking = EINA_TRUE;
|
||||||
cl->ssl_state = ECORE_CON_SSL_STATE_INIT;
|
cl->ssl_state = ECORE_CON_SSL_STATE_INIT;
|
||||||
return SSL_SUFFIX(_ecore_con_ssl_client_init) (cl);
|
return SSL_SUFFIX(_ecore_con_ssl_client_init) (obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1868,8 +1870,9 @@ _ecore_con_ssl_server_write_openssl(Ecore_Con_Server *svr,
|
||||||
}
|
}
|
||||||
|
|
||||||
static Ecore_Con_Ssl_Error
|
static Ecore_Con_Ssl_Error
|
||||||
_ecore_con_ssl_client_init_openssl(Ecore_Con_Client *cl)
|
_ecore_con_ssl_client_init_openssl(Ecore_Con_Client *obj)
|
||||||
{
|
{
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(obj, ECORE_CON_CLIENT_CLASS);
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
switch (cl->ssl_state)
|
switch (cl->ssl_state)
|
||||||
{
|
{
|
||||||
|
@ -1929,13 +1932,14 @@ _ecore_con_ssl_client_init_openssl(Ecore_Con_Client *cl)
|
||||||
|
|
||||||
error:
|
error:
|
||||||
_openssl_print_errors(cl, ECORE_CON_EVENT_CLIENT_ERROR);
|
_openssl_print_errors(cl, ECORE_CON_EVENT_CLIENT_ERROR);
|
||||||
_ecore_con_ssl_client_shutdown_openssl(cl);
|
_ecore_con_ssl_client_shutdown_openssl(obj);
|
||||||
return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED;
|
return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Ecore_Con_Ssl_Error
|
static Ecore_Con_Ssl_Error
|
||||||
_ecore_con_ssl_client_shutdown_openssl(Ecore_Con_Client *cl)
|
_ecore_con_ssl_client_shutdown_openssl(Ecore_Con_Client *obj)
|
||||||
{
|
{
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(obj, ECORE_CON_CLIENT_CLASS);
|
||||||
if (cl->ssl)
|
if (cl->ssl)
|
||||||
{
|
{
|
||||||
if (!SSL_shutdown(cl->ssl))
|
if (!SSL_shutdown(cl->ssl))
|
||||||
|
@ -1951,10 +1955,11 @@ _ecore_con_ssl_client_shutdown_openssl(Ecore_Con_Client *cl)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_ecore_con_ssl_client_read_openssl(Ecore_Con_Client *cl,
|
_ecore_con_ssl_client_read_openssl(Ecore_Con_Client *obj,
|
||||||
unsigned char *buf,
|
unsigned char *buf,
|
||||||
int size)
|
int size)
|
||||||
{
|
{
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(obj, ECORE_CON_CLIENT_CLASS);
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
if (!cl->ssl) return -1;
|
if (!cl->ssl) return -1;
|
||||||
|
@ -1981,10 +1986,11 @@ _ecore_con_ssl_client_read_openssl(Ecore_Con_Client *cl,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_ecore_con_ssl_client_write_openssl(Ecore_Con_Client *cl,
|
_ecore_con_ssl_client_write_openssl(Ecore_Con_Client *obj,
|
||||||
const unsigned char *buf,
|
const unsigned char *buf,
|
||||||
int size)
|
int size)
|
||||||
{
|
{
|
||||||
|
Ecore_Con_Client_Data *cl = eo_data_scope_get(obj, ECORE_CON_CLIENT_CLASS);
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
num = SSL_write(cl->ssl, buf, size);
|
num = SSL_write(cl->ssl, buf, size);
|
||||||
|
|
Loading…
Reference in New Issue