forked from enlightenment/efl
Ecore con: Add Connector class (the connecting variant of server).
This change also consists of cleaning up the server class and adding a constructor and a finalizer to it.
This commit is contained in:
parent
bdb60f017f
commit
bba7ac87f1
|
@ -8,6 +8,8 @@ ecorecon_eobuiltheaders = \
|
|||
lib/ecore_con/ecore_con_client.eo.legacy.h \
|
||||
lib/ecore_con/ecore_con_server.eo.h \
|
||||
lib/ecore_con/ecore_con_server.eo.legacy.h \
|
||||
lib/ecore_con/ecore_con_connector.eo.h \
|
||||
lib/ecore_con/ecore_con_connector.eo.legacy.h \
|
||||
lib/ecore_con/ecore_con_url.eo.h \
|
||||
lib/ecore_con/ecore_con_url.eo.legacy.h
|
||||
|
||||
|
@ -16,6 +18,7 @@ BUILT_SOURCES += \
|
|||
lib/ecore_con/ecore_con_base.eo.c \
|
||||
lib/ecore_con/ecore_con_client.eo.c \
|
||||
lib/ecore_con/ecore_con_server.eo.c \
|
||||
lib/ecore_con/ecore_con_connector.eo.c \
|
||||
lib/ecore_con/ecore_con_url.eo.c
|
||||
|
||||
ecoreconeolianfilesdir = $(datadir)/eolian/include/ecore-@VMAJ@
|
||||
|
@ -23,6 +26,7 @@ ecoreconeolianfiles_DATA = \
|
|||
lib/ecore_con/ecore_con_base.eo \
|
||||
lib/ecore_con/ecore_con_client.eo \
|
||||
lib/ecore_con/ecore_con_server.eo \
|
||||
lib/ecore_con/ecore_con_connector.eo \
|
||||
lib/ecore_con/ecore_con_url.eo
|
||||
|
||||
EXTRA_DIST += \
|
||||
|
|
|
@ -232,6 +232,8 @@ typedef Eo Ecore_Con;
|
|||
*/
|
||||
typedef struct Ecore_Con_Socks Ecore_Con_Socks;
|
||||
|
||||
typedef enum _Ecore_Con_Type Ecore_Con_Type;
|
||||
|
||||
#ifndef EFL_NOLEGACY_API_SUPPORT
|
||||
#include "Ecore_Con_Legacy.h"
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "ecore_con_base.eo.h"
|
||||
#include "ecore_con_server.eo.h"
|
||||
#include "ecore_con_connector.eo.h"
|
||||
#include "ecore_con_client.eo.h"
|
||||
#include "ecore_con_url.eo.h"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "ecore_con_base.eo.legacy.h"
|
||||
#include "ecore_con_server.eo.legacy.h"
|
||||
#include "ecore_con_connector.eo.legacy.h"
|
||||
#include "ecore_con_client.eo.legacy.h"
|
||||
#include "ecore_con_url.eo.legacy.h"
|
||||
|
|
|
@ -282,7 +282,10 @@ _ecore_con_base_lookup(Eo *kls_obj EINA_UNUSED, void *pd EINA_UNUSED, const char
|
|||
if (!name || !done_cb)
|
||||
return EINA_FALSE;
|
||||
|
||||
obj = eo_add(ECORE_CON_SERVER_CLASS, NULL);
|
||||
obj = eo_add(ECORE_CON_SERVER_CLASS, NULL,
|
||||
ecore_con_server_obj_connection_type_set(ECORE_CON_REMOTE_TCP),
|
||||
ecore_con_server_obj_name_set(name),
|
||||
ecore_con_obj_port_set(1025));
|
||||
Ecore_Con_Server_Data *svr = eo_data_scope_get(obj, ECORE_CON_SERVER_CLASS);
|
||||
if (!svr)
|
||||
return EINA_FALSE;
|
||||
|
@ -301,14 +304,7 @@ _ecore_con_base_lookup(Eo *kls_obj EINA_UNUSED, void *pd EINA_UNUSED, const char
|
|||
if (!svr->name)
|
||||
goto on_error;
|
||||
|
||||
svr->type = ECORE_CON_REMOTE_TCP;
|
||||
svr->port = 1025;
|
||||
svr->data = lk;
|
||||
svr->created = EINA_TRUE;
|
||||
svr->reject_excess_clients = EINA_FALSE;
|
||||
svr->client_limit = -1;
|
||||
svr->clients = NULL;
|
||||
svr->ppid = getpid();
|
||||
|
||||
memset(&hints, 0, sizeof(struct addrinfo));
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
|
@ -350,39 +346,53 @@ ecore_con_server_add(Ecore_Con_Type compl_type,
|
|||
const void *data)
|
||||
{
|
||||
Ecore_Con_Server *obj;
|
||||
Ecore_Con_Type type;
|
||||
|
||||
if (port < 0 || !name)
|
||||
return NULL; /* local user socket: FILE: ~/.ecore/[name]/[port] */
|
||||
|
||||
/* local system socket: FILE: /tmp/.ecore_service|[name]|[port] */
|
||||
/* remote system socket: TCP/IP: [name]:[port] */
|
||||
obj = eo_add(ECORE_CON_SERVER_CLASS, NULL);
|
||||
Ecore_Con_Server_Data *svr = eo_data_scope_get(obj, ECORE_CON_SERVER_CLASS);
|
||||
obj = eo_add(ECORE_CON_SERVER_CLASS, NULL,
|
||||
ecore_con_server_obj_connection_type_set(compl_type),
|
||||
ecore_con_server_obj_name_set(name),
|
||||
ecore_con_obj_port_set(port));
|
||||
|
||||
ecore_con_server_data_set(obj, (void *) data);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_ecore_con_server_eo_base_constructor(Ecore_Con_Server *obj, Ecore_Con_Server_Data *svr)
|
||||
{
|
||||
eo_do_super(obj, ECORE_CON_SERVER_CLASS, eo_constructor());
|
||||
|
||||
svr->fd = -1;
|
||||
svr->start_time = ecore_time_get();
|
||||
svr->type = compl_type;
|
||||
svr->port = port;
|
||||
svr->data = (void *)data;
|
||||
svr->created = EINA_TRUE;
|
||||
svr->use_cert = (compl_type & ECORE_CON_SSL & ECORE_CON_LOAD_CERT) == ECORE_CON_LOAD_CERT;
|
||||
svr->reject_excess_clients = EINA_FALSE;
|
||||
svr->client_limit = -1;
|
||||
svr->clients = NULL;
|
||||
svr->ppid = getpid();
|
||||
}
|
||||
|
||||
EOLIAN static Eo *
|
||||
_ecore_con_server_eo_base_finalize(Ecore_Con_Server *obj, Ecore_Con_Server_Data *svr)
|
||||
{
|
||||
Ecore_Con_Type compl_type = svr->type;
|
||||
Ecore_Con_Type type;
|
||||
|
||||
eo_do_super(obj, ECORE_CON_SERVER_CLASS, eo_finalize());
|
||||
|
||||
svr->use_cert = (svr->type & ECORE_CON_SSL & ECORE_CON_LOAD_CERT) == ECORE_CON_LOAD_CERT;
|
||||
|
||||
servers = eina_list_append(servers, obj);
|
||||
|
||||
svr->name = strdup(name);
|
||||
type = compl_type & ECORE_CON_TYPE;
|
||||
|
||||
if (!svr->name)
|
||||
goto error;
|
||||
|
||||
if (ecore_con_ssl_server_prepare(obj, compl_type & ECORE_CON_SSL))
|
||||
goto error;
|
||||
|
||||
type = compl_type & ECORE_CON_TYPE;
|
||||
|
||||
if ((type == ECORE_CON_LOCAL_USER) ||
|
||||
(type == ECORE_CON_LOCAL_SYSTEM) ||
|
||||
(type == ECORE_CON_LOCAL_ABSTRACT))
|
||||
|
@ -426,31 +436,36 @@ ecore_con_server_connect(Ecore_Con_Type compl_type,
|
|||
const void *data)
|
||||
{
|
||||
Ecore_Con_Server *obj;
|
||||
Ecore_Con_Type type;
|
||||
|
||||
if ((!name) || (!name[0]))
|
||||
return NULL;
|
||||
/* local user socket: FILE: ~/.ecore/[name]/[port] */
|
||||
/* local system socket: FILE: /tmp/.ecore_service|[name]|[port] */
|
||||
/* remote system socket: TCP/IP: [name]:[port] */
|
||||
obj = eo_add(ECORE_CON_SERVER_CLASS, NULL);
|
||||
Ecore_Con_Server_Data *svr = eo_data_scope_get(obj, ECORE_CON_SERVER_CLASS);
|
||||
obj = eo_add(ECORE_CON_CONNECTOR_CLASS, NULL,
|
||||
ecore_con_server_obj_connection_type_set(compl_type),
|
||||
ecore_con_server_obj_name_set(name),
|
||||
ecore_con_obj_port_set(port));
|
||||
|
||||
ecore_con_server_data_set(obj, (void *) data);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
EOLIAN static Eo *
|
||||
_ecore_con_connector_eo_base_finalize(Ecore_Con_Server *obj, void *pd EINA_UNUSED)
|
||||
{
|
||||
Ecore_Con_Server_Data *svr = eo_data_scope_get(obj, ECORE_CON_SERVER_CLASS);
|
||||
Ecore_Con_Type compl_type = svr->type;
|
||||
Ecore_Con_Type type;
|
||||
|
||||
/* XXX: We intentionally put SERVER class here and not connector, as we'd
|
||||
* like to skip that one. */
|
||||
eo_do_super(obj, ECORE_CON_SERVER_CLASS, eo_finalize());
|
||||
|
||||
|
||||
svr->fd = -1;
|
||||
svr->type = compl_type;
|
||||
svr->port = port;
|
||||
svr->data = (void *)data;
|
||||
svr->created = EINA_FALSE;
|
||||
svr->use_cert = (compl_type & ECORE_CON_SSL & ECORE_CON_LOAD_CERT) == ECORE_CON_LOAD_CERT;
|
||||
svr->disable_proxy = (compl_type & ECORE_CON_SUPER_SSL & ECORE_CON_NO_PROXY) == ECORE_CON_NO_PROXY;
|
||||
svr->reject_excess_clients = EINA_FALSE;
|
||||
svr->clients = NULL;
|
||||
svr->client_limit = -1;
|
||||
|
||||
servers = eina_list_append(servers, obj);
|
||||
|
||||
svr->name = strdup(name);
|
||||
if (!svr->name)
|
||||
if (!svr->name || (svr->port < 0))
|
||||
goto error;
|
||||
|
||||
type = compl_type & ECORE_CON_TYPE;
|
||||
|
@ -479,7 +494,7 @@ ecore_con_server_connect(Ecore_Con_Type compl_type,
|
|||
(type == ECORE_CON_REMOTE_CORK) ||
|
||||
(type == ECORE_CON_REMOTE_UDP) ||
|
||||
(type == ECORE_CON_REMOTE_BROADCAST)) &&
|
||||
(port < 0), error);
|
||||
(svr->port < 0), error);
|
||||
|
||||
if ((type == ECORE_CON_LOCAL_USER) ||
|
||||
(type == ECORE_CON_LOCAL_SYSTEM) ||
|
||||
|
@ -594,6 +609,29 @@ _ecore_con_server_clients_get(Eo *obj EINA_UNUSED, Ecore_Con_Server_Data *svr)
|
|||
return svr->clients;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_ecore_con_server_connection_type_set(Eo *obj EINA_UNUSED, Ecore_Con_Server_Data *svr, Ecore_Con_Type type)
|
||||
{
|
||||
/* FIXME: Add a check that only allows this during construction. */
|
||||
svr->type = type;
|
||||
}
|
||||
|
||||
EOLIAN static Ecore_Con_Type
|
||||
_ecore_con_server_connection_type_get(Eo *obj EINA_UNUSED, Ecore_Con_Server_Data *svr)
|
||||
{
|
||||
return svr->type;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_ecore_con_server_name_set(Eo *obj EINA_UNUSED, Ecore_Con_Server_Data *svr, const char *name)
|
||||
{
|
||||
/* FIXME: Add a check that only allows this during construction. */
|
||||
if (svr->name)
|
||||
free(svr->name);
|
||||
|
||||
svr->name = strdup(name);
|
||||
}
|
||||
|
||||
EOLIAN static const char *
|
||||
_ecore_con_server_name_get(Eo *obj EINA_UNUSED, Ecore_Con_Server_Data *svr)
|
||||
{
|
||||
|
@ -606,6 +644,13 @@ ecore_con_server_port_get(const Ecore_Con *obj)
|
|||
return eo_do((Ecore_Con *)obj, ecore_con_obj_port_get());
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_ecore_con_server_ecore_con_base_port_set(Eo *obj EINA_UNUSED, Ecore_Con_Server_Data *svr, int port)
|
||||
{
|
||||
/* FIXME: Add a check that only allows this during construction. */
|
||||
svr->port = port;
|
||||
}
|
||||
|
||||
EOLIAN static int
|
||||
_ecore_con_server_ecore_con_base_port_get(Eo *obj EINA_UNUSED, Ecore_Con_Server_Data *svr)
|
||||
{
|
||||
|
@ -2780,3 +2825,4 @@ _ecore_con_lookup_done(void *data,
|
|||
#include "ecore_con_base.eo.c"
|
||||
#include "ecore_con_client.eo.c"
|
||||
#include "ecore_con_server.eo.c"
|
||||
#include "ecore_con_connector.eo.c"
|
||||
|
|
|
@ -38,6 +38,9 @@ abstract Ecore.Con.Base (Eo.Base) {
|
|||
* @brief Return the port that the obj is connected to
|
||||
*
|
||||
*/
|
||||
set {
|
||||
legacy: null;
|
||||
}
|
||||
get {
|
||||
legacy: null;
|
||||
}
|
||||
|
@ -156,6 +159,7 @@ abstract Ecore.Con.Base (Eo.Base) {
|
|||
implements {
|
||||
virtual.ip.get;
|
||||
virtual.uptime.get;
|
||||
virtual.port.set;
|
||||
virtual.port.get;
|
||||
virtual.fd.get;
|
||||
virtual.connected.get;
|
||||
|
@ -194,7 +198,9 @@ type Ecore_Con_Dns_Cb: func void (const(char) *canonname,
|
|||
* Add events (to all of the ecore con stuff, e.g url).
|
||||
* Make server the father of the client - make sure I don't leak references.
|
||||
*
|
||||
* Still need to add constructors to server/client, and most likely migrate ecore_con_eet.
|
||||
* Still need to add constructor client, and most likely migrate ecore_con_eet.
|
||||
*
|
||||
* Split server to two classes, listener and connector (or w/e).
|
||||
*
|
||||
* Mark the constructing properties all around.
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
class Ecore.Con.Connector (Ecore.Con.Server) {
|
||||
legacy_prefix: null;
|
||||
eo_prefix: ecore_con_connector_obj;
|
||||
data: null;
|
||||
implements {
|
||||
Eo.Base.finalize;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
/* FIXME: make abstract. */
|
||||
class Ecore.Con.Server (Ecore.Con.Base) {
|
||||
eo_prefix: ecore_con_server_obj;
|
||||
properties {
|
||||
|
@ -8,6 +7,9 @@ class Ecore.Con.Server (Ecore.Con.Base) {
|
|||
*
|
||||
* The name returned is the name used to connect on this server.
|
||||
*/
|
||||
set {
|
||||
legacy: null;
|
||||
}
|
||||
get {
|
||||
}
|
||||
values {
|
||||
|
@ -52,11 +54,25 @@ class Ecore.Con.Server (Ecore.Con.Base) {
|
|||
const(Eina_List <const(Ecore.Con.Client) *>) *clients; /*@ The list of clients on this server. */
|
||||
}
|
||||
}
|
||||
connection_type {
|
||||
get {
|
||||
legacy: null;
|
||||
}
|
||||
set {
|
||||
legacy: null;
|
||||
}
|
||||
values {
|
||||
Ecore_Con_Type conn_type;
|
||||
}
|
||||
}
|
||||
}
|
||||
implements {
|
||||
Eo.Base.constructor;
|
||||
Eo.Base.destructor;
|
||||
Eo.Base.finalize;
|
||||
Ecore.Con.Base.ip.get;
|
||||
Ecore.Con.Base.uptime.get;
|
||||
Ecore.Con.Base.port.set;
|
||||
Ecore.Con.Base.port.get;
|
||||
Ecore.Con.Base.fd.get;
|
||||
Ecore.Con.Base.connected.get;
|
||||
|
|
Loading…
Reference in New Issue