2009-01-31 10:33:39 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2009-01-31 10:56:17 -08:00
|
|
|
# include <config.h>
|
2009-01-31 10:33:39 -08:00
|
|
|
#endif
|
|
|
|
|
2003-12-05 08:57:32 -08:00
|
|
|
/* ############## bad */
|
|
|
|
#define HAVE_EVAS2
|
|
|
|
|
|
|
|
#include <signal.h>
|
|
|
|
#include <dlfcn.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <glob.h>
|
2004-07-15 06:43:15 -07:00
|
|
|
#include <sys/param.h>
|
2003-12-05 08:57:32 -08:00
|
|
|
#include <limits.h>
|
|
|
|
#include <string.h>
|
2004-05-07 20:10:45 -07:00
|
|
|
#include <stdlib.h> /* malloc(), free() */
|
2003-12-05 08:57:32 -08:00
|
|
|
|
2006-01-06 10:26:37 -08:00
|
|
|
#include "Ecore.h"
|
|
|
|
#include "Ecore_Config.h"
|
|
|
|
#include "ecore_config_util.h"
|
|
|
|
#include "ecore_config_ipc.h"
|
|
|
|
|
|
|
|
#include "ecore_config_private.h"
|
|
|
|
|
2005-06-07 14:54:07 -07:00
|
|
|
static Ecore_Config_Server *__ecore_config_servers;
|
2005-12-30 12:10:01 -08:00
|
|
|
Ecore_Timer *ipc_timer = NULL;
|
2004-05-07 20:10:45 -07:00
|
|
|
|
|
|
|
Ecore_Config_Server *
|
|
|
|
_ecore_config_server_convert(void *srv)
|
|
|
|
{
|
|
|
|
Ecore_Config_Server *srv_tmp;
|
|
|
|
|
2005-06-07 14:54:07 -07:00
|
|
|
srv_tmp = __ecore_config_servers;
|
|
|
|
while (srv_tmp)
|
2004-05-07 20:10:45 -07:00
|
|
|
{
|
2005-06-07 14:54:07 -07:00
|
|
|
if (srv_tmp->server == srv)
|
|
|
|
return srv_tmp;
|
|
|
|
srv_tmp = srv_tmp->next;
|
2004-05-07 20:10:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return __ecore_config_server_global;
|
2003-12-05 08:57:32 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* INTERFACE FOR IPC MODULES */
|
|
|
|
/*****************************/
|
|
|
|
|
2004-05-07 20:10:45 -07:00
|
|
|
char *
|
|
|
|
_ecore_config_ipc_prop_list(Ecore_Config_Server * srv, const long serial)
|
|
|
|
{
|
|
|
|
Ecore_Config_Bundle *theme;
|
|
|
|
Ecore_Config_Prop *e;
|
|
|
|
estring *s;
|
|
|
|
int f;
|
|
|
|
|
2004-05-08 07:51:05 -07:00
|
|
|
theme = ecore_config_bundle_by_serial_get(srv, serial);
|
2004-05-07 20:10:45 -07:00
|
|
|
e = theme ? theme->data : NULL;
|
|
|
|
s = estring_new(8192);
|
|
|
|
f = 0;
|
|
|
|
while (e)
|
|
|
|
{
|
|
|
|
/* ignore system properties in listings, unless they have been overridden */
|
2005-09-18 05:25:57 -07:00
|
|
|
if (e->flags & ECORE_CONFIG_FLAG_SYSTEM && !(e->flags & ECORE_CONFIG_FLAG_MODIFIED))
|
2004-05-07 20:10:45 -07:00
|
|
|
{
|
|
|
|
e = e->next;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
estring_appendf(s, "%s%s: %s", f ? "\n" : "", e->key,
|
2004-05-08 07:51:05 -07:00
|
|
|
ecore_config_type_get(e));
|
2005-09-18 05:25:57 -07:00
|
|
|
if (e->flags & ECORE_CONFIG_FLAG_BOUNDS)
|
2004-05-07 20:10:45 -07:00
|
|
|
{
|
2005-09-18 05:25:57 -07:00
|
|
|
if (e->type == ECORE_CONFIG_FLT)
|
2004-05-07 20:10:45 -07:00
|
|
|
estring_appendf(s, ", range %le..%le",
|
|
|
|
(float)e->lo / ECORE_CONFIG_FLOAT_PRECISION,
|
|
|
|
(float)e->hi / ECORE_CONFIG_FLOAT_PRECISION);
|
|
|
|
else
|
|
|
|
estring_appendf(s, ", range %d..%d", e->lo, e->hi);
|
|
|
|
}
|
2005-09-18 05:25:57 -07:00
|
|
|
if (e->type == ECORE_CONFIG_THM)
|
2004-05-07 20:10:45 -07:00
|
|
|
estring_appendf(s, ", group %s", e->data ? e->data : "Main");
|
|
|
|
f = 1;
|
|
|
|
e = e->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return estring_disown(s);
|
|
|
|
}
|
2003-12-05 08:57:32 -08:00
|
|
|
|
2004-05-07 20:10:45 -07:00
|
|
|
char *
|
|
|
|
_ecore_config_ipc_prop_desc(Ecore_Config_Server * srv, const long serial,
|
|
|
|
const char *key)
|
|
|
|
{
|
2003-12-05 08:57:32 -08:00
|
|
|
#ifdef HAVE_EVAS2
|
2004-05-07 20:10:45 -07:00
|
|
|
Ecore_Config_Prop *e;
|
2003-12-05 08:57:32 -08:00
|
|
|
|
2004-05-07 20:10:45 -07:00
|
|
|
e = ecore_config_get(key);
|
|
|
|
if (e)
|
|
|
|
{
|
|
|
|
estring *s = estring_new(512);
|
2003-12-05 08:57:32 -08:00
|
|
|
|
2004-05-08 07:51:05 -07:00
|
|
|
estring_appendf(s, "%s: %s", e->key, ecore_config_type_get(e));
|
2005-09-18 05:25:57 -07:00
|
|
|
if (e->flags & ECORE_CONFIG_FLAG_BOUNDS)
|
2004-05-07 20:10:45 -07:00
|
|
|
estring_appendf(s, ", range %d..%d", e->lo, e->hi);
|
|
|
|
return estring_disown(s);
|
|
|
|
}
|
2003-12-05 08:57:32 -08:00
|
|
|
#endif
|
2004-05-07 20:10:45 -07:00
|
|
|
return strdup("<undefined>");
|
|
|
|
}
|
2003-12-05 08:57:32 -08:00
|
|
|
|
2004-05-07 20:10:45 -07:00
|
|
|
char *
|
|
|
|
_ecore_config_ipc_prop_get(Ecore_Config_Server * srv, const long serial,
|
|
|
|
const char *key)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_EVAS2
|
|
|
|
char *ret;
|
2003-12-05 08:57:32 -08:00
|
|
|
|
2009-12-07 13:01:26 -08:00
|
|
|
if ((ret = ecore_config_as_string_get(key)))
|
2004-05-07 20:10:45 -07:00
|
|
|
return ret;
|
|
|
|
#endif
|
|
|
|
return strdup("<undefined>");
|
|
|
|
}
|
2003-12-05 08:57:32 -08:00
|
|
|
|
2004-05-07 20:10:45 -07:00
|
|
|
int
|
|
|
|
_ecore_config_ipc_prop_set(Ecore_Config_Server * srv, const long serial,
|
|
|
|
const char *key, const char *val)
|
|
|
|
{
|
2003-12-05 08:57:32 -08:00
|
|
|
#ifdef HAVE_EVAS2
|
2004-05-07 20:10:45 -07:00
|
|
|
int ret;
|
|
|
|
Ecore_Config_Bundle *theme;
|
|
|
|
|
2004-05-08 07:51:05 -07:00
|
|
|
theme = ecore_config_bundle_by_serial_get(srv, serial);
|
2004-05-07 20:10:45 -07:00
|
|
|
ret = ecore_config_set(key, (char *)val);
|
2009-12-21 09:32:19 -08:00
|
|
|
ERR("ipc.prop.set(%s->%s,\"%s\") => %d\n", theme ? theme->identifier : "",
|
|
|
|
key, val, ret);
|
2004-05-07 20:10:45 -07:00
|
|
|
return ret;
|
2003-12-05 08:57:32 -08:00
|
|
|
#else
|
2004-05-07 20:10:45 -07:00
|
|
|
return ECORE_CONFIG_ERR_NOTSUPP;
|
2003-12-05 08:57:32 -08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
2004-05-07 20:10:45 -07:00
|
|
|
char *
|
|
|
|
_ecore_config_ipc_bundle_list(Ecore_Config_Server * srv)
|
|
|
|
{
|
|
|
|
Ecore_Config_Bundle *ns;
|
|
|
|
estring *s;
|
|
|
|
int f;
|
|
|
|
|
2004-05-08 07:51:05 -07:00
|
|
|
ns = ecore_config_bundle_1st_get(srv);
|
2004-05-07 20:10:45 -07:00
|
|
|
s = estring_new(8192);
|
|
|
|
f = 0;
|
|
|
|
if (!ns)
|
|
|
|
return strdup("<no_bundles_created>");
|
|
|
|
|
|
|
|
while (ns)
|
|
|
|
{
|
|
|
|
estring_appendf(s, "%s%d: %s", f ? "\n" : "",
|
2004-05-08 07:51:05 -07:00
|
|
|
ecore_config_bundle_serial_get(ns),
|
|
|
|
ecore_config_bundle_label_get(ns));
|
2004-05-07 20:10:45 -07:00
|
|
|
f = 1;
|
2004-05-08 07:51:05 -07:00
|
|
|
ns = ecore_config_bundle_next_get(ns);
|
2004-05-07 20:10:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return estring_disown(s);
|
|
|
|
}
|
2003-12-05 08:57:32 -08:00
|
|
|
|
2004-05-07 20:10:45 -07:00
|
|
|
int
|
|
|
|
_ecore_config_ipc_bundle_new(Ecore_Config_Server * srv, const char *label)
|
|
|
|
{
|
|
|
|
if (ecore_config_bundle_new(srv, label))
|
|
|
|
return ECORE_CONFIG_ERR_SUCC;
|
|
|
|
return ECORE_CONFIG_ERR_FAIL;
|
|
|
|
}
|
2003-12-05 08:57:32 -08:00
|
|
|
|
2004-05-07 20:10:45 -07:00
|
|
|
char *
|
|
|
|
_ecore_config_ipc_bundle_label_get(Ecore_Config_Server * srv, const long serial)
|
|
|
|
{
|
|
|
|
Ecore_Config_Bundle *ns;
|
|
|
|
char *label;
|
2003-12-05 08:57:32 -08:00
|
|
|
|
2004-05-08 07:51:05 -07:00
|
|
|
ns = ecore_config_bundle_by_serial_get(srv, serial);
|
|
|
|
label = ecore_config_bundle_label_get(ns);
|
2004-05-07 20:10:45 -07:00
|
|
|
return strdup(label ? label : "<no such bundle>");
|
|
|
|
}
|
2003-12-05 08:57:32 -08:00
|
|
|
|
2004-05-07 20:10:45 -07:00
|
|
|
int
|
|
|
|
_ecore_config_ipc_bundle_label_set(Ecore_Config_Server * srv, const long serial,
|
|
|
|
const char *label)
|
|
|
|
{
|
|
|
|
Ecore_Config_Bundle *ns;
|
|
|
|
|
2004-05-08 07:51:05 -07:00
|
|
|
ns = ecore_config_bundle_by_serial_get(srv, serial);
|
2004-05-07 20:10:45 -07:00
|
|
|
if (!(ns->identifier = malloc(sizeof(label))))
|
|
|
|
return ECORE_CONFIG_ERR_OOM;
|
|
|
|
memcpy(ns->identifier, label, sizeof(label));
|
|
|
|
return ECORE_CONFIG_ERR_SUCC;
|
|
|
|
}
|
2003-12-05 08:57:32 -08:00
|
|
|
|
2004-05-07 20:10:45 -07:00
|
|
|
long
|
|
|
|
_ecore_config_ipc_bundle_label_find(Ecore_Config_Server * srv,
|
|
|
|
const char *label)
|
|
|
|
{
|
|
|
|
Ecore_Config_Bundle *ns;
|
2003-12-05 08:57:32 -08:00
|
|
|
|
2004-05-08 07:51:05 -07:00
|
|
|
ns = ecore_config_bundle_by_label_get(srv, label);
|
|
|
|
return ns ? ecore_config_bundle_serial_get(ns) : -1;
|
2004-05-07 20:10:45 -07:00
|
|
|
}
|
2003-12-05 08:57:32 -08:00
|
|
|
|
2010-07-05 17:08:52 -07:00
|
|
|
static Eina_Bool
|
2006-11-05 06:19:56 -08:00
|
|
|
_ecore_config_ipc_poll(void *data __UNUSED__)
|
2004-05-07 20:10:45 -07:00
|
|
|
{
|
|
|
|
Ecore_Config_Server *s;
|
|
|
|
|
2005-06-07 14:54:07 -07:00
|
|
|
s = __ecore_config_servers;
|
|
|
|
while (s)
|
2004-05-07 20:10:45 -07:00
|
|
|
{
|
2005-06-07 14:54:07 -07:00
|
|
|
_ecore_config_ipc_ecore_poll(&s->server);
|
|
|
|
s = s->next;
|
2004-05-07 20:10:45 -07:00
|
|
|
}
|
|
|
|
|
2010-07-05 17:08:52 -07:00
|
|
|
return EINA_TRUE;
|
2004-05-07 20:10:45 -07:00
|
|
|
}
|
2003-12-05 08:57:32 -08:00
|
|
|
|
2004-05-07 20:10:45 -07:00
|
|
|
int
|
|
|
|
_ecore_config_ipc_exit(void)
|
|
|
|
{
|
|
|
|
Ecore_Config_Server *l;
|
|
|
|
|
|
|
|
if (ipc_timer)
|
2005-12-30 12:10:01 -08:00
|
|
|
ecore_timer_del(ipc_timer);
|
|
|
|
|
2005-06-07 14:54:07 -07:00
|
|
|
l = __ecore_config_servers;
|
|
|
|
while (l)
|
2004-05-07 20:10:45 -07:00
|
|
|
{
|
2005-06-07 14:54:07 -07:00
|
|
|
_ecore_config_ipc_ecore_exit(&l->server);
|
2005-12-24 02:28:08 -08:00
|
|
|
if (l->name)
|
|
|
|
free(l->name);
|
2005-06-07 14:54:07 -07:00
|
|
|
l = l->next;
|
2004-05-07 20:10:45 -07:00
|
|
|
}
|
2005-06-07 14:54:07 -07:00
|
|
|
|
|
|
|
return ECORE_CONFIG_ERR_SUCC;
|
2004-05-07 20:10:45 -07:00
|
|
|
}
|
2003-12-05 08:57:32 -08:00
|
|
|
|
2004-05-07 20:10:45 -07:00
|
|
|
Ecore_Config_Server *
|
2005-03-01 23:06:44 -08:00
|
|
|
_ecore_config_ipc_init(const char *pipe_name)
|
2004-05-07 20:10:45 -07:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
Ecore_Config_Server *list;
|
|
|
|
Ecore_Config_Server *ret_srv;
|
|
|
|
|
|
|
|
list = NULL;
|
|
|
|
ret_srv = NULL;
|
|
|
|
list = NULL;
|
|
|
|
|
2005-06-07 14:54:07 -07:00
|
|
|
list = malloc(sizeof(Ecore_Config_Server));
|
|
|
|
memset(list, 0, sizeof(Ecore_Config_Server));
|
|
|
|
if ((ret = _ecore_config_ipc_ecore_init(pipe_name, &list->server)) != ECORE_CONFIG_ERR_SUCC)
|
2004-05-07 20:10:45 -07:00
|
|
|
{
|
2009-12-21 09:32:19 -08:00
|
|
|
ERR("_ecore_config_ipc_init: failed to register %s, code %d",
|
2005-06-07 14:54:07 -07:00
|
|
|
pipe_name, ret);
|
2004-05-07 20:10:45 -07:00
|
|
|
}
|
|
|
|
|
2009-12-21 09:32:19 -08:00
|
|
|
ERR("_ecore_config_ipc_init: registered \"%s\"...", pipe_name);
|
2004-05-07 20:10:45 -07:00
|
|
|
|
2005-06-07 14:54:07 -07:00
|
|
|
list->name = strdup(pipe_name);
|
|
|
|
list->next = __ecore_config_servers;
|
2004-05-07 20:10:45 -07:00
|
|
|
|
2005-06-07 14:54:07 -07:00
|
|
|
__ecore_config_servers = list;
|
|
|
|
if (!ret_srv)
|
|
|
|
ret_srv = list;
|
2003-12-05 08:57:32 -08:00
|
|
|
|
2005-06-07 14:54:07 -07:00
|
|
|
if (!ipc_timer)
|
2005-12-30 12:10:01 -08:00
|
|
|
ipc_timer = ecore_timer_add(100, _ecore_config_ipc_poll, NULL);
|
2005-06-07 14:54:07 -07:00
|
|
|
|
2004-05-07 20:10:45 -07:00
|
|
|
return ret_srv;
|
|
|
|
}
|
2003-12-05 08:57:32 -08:00
|
|
|
/*****************************************************************************/
|