forked from enlightenment/enlightenment
- extend E's ipc a bit more
- this change the way the module-list call returns from libe, it will return a list now, instead of a event per entry in the list - adds a module directory list and background directory list call - adds a shutdown call to shutdown E - extends enlightenment_remote to handle the above and implments a -bg-get call SVN revision: 14125
This commit is contained in:
parent
6ca778ea55
commit
df5b523477
|
@ -1,9 +1,11 @@
|
|||
#include "e.h"
|
||||
#include "config.h"
|
||||
|
||||
/* local subsystem functions */
|
||||
static int _e_ipc_cb_client_add(void *data, int type, void *event);
|
||||
static int _e_ipc_cb_client_del(void *data, int type, void *event);
|
||||
static int _e_ipc_cb_client_data(void *data, int type, void *event);
|
||||
static char *_e_ipc_path_str_get(char **paths, int *bytes);
|
||||
|
||||
/* local subsystem globals */
|
||||
static Ecore_Ipc_Server *_e_ipc_server = NULL;
|
||||
|
@ -169,6 +171,26 @@ _e_ipc_cb_client_data(void *data, int type, void *event)
|
|||
free(data);
|
||||
}
|
||||
break;
|
||||
case E_IPC_OP_MODULE_DIRS_LIST:
|
||||
{
|
||||
char *dirs[] = {
|
||||
PACKAGE_LIB_DIR"/enlightenment/modules",
|
||||
PACKAGE_LIB_DIR"/enlightenment/modules_extra",
|
||||
"~/.e/e/modules",
|
||||
NULL
|
||||
};
|
||||
char *data;
|
||||
int bytes = 0;
|
||||
|
||||
data = _e_ipc_path_str_get(dirs, &bytes);
|
||||
ecore_ipc_client_send(e->client,
|
||||
E_IPC_DOMAIN_REPLY,
|
||||
E_IPC_OP_MODULE_DIRS_LIST_REPLY,
|
||||
0/*ref*/, 0/*ref_to*/, 0/*response*/,
|
||||
data, bytes);
|
||||
free(data);
|
||||
}
|
||||
break;
|
||||
case E_IPC_OP_BG_SET:
|
||||
{
|
||||
char *file;
|
||||
|
@ -460,12 +482,37 @@ _e_ipc_cb_client_data(void *data, int type, void *event)
|
|||
|
||||
}
|
||||
break;
|
||||
case E_IPC_OP_BG_DIRS_LIST:
|
||||
{
|
||||
char *dirs[] = {
|
||||
PACKAGE_DATA_DIR"/data/themes",
|
||||
"~/.e/e/backgrounds",
|
||||
"~/.e/e/themes",
|
||||
NULL
|
||||
};
|
||||
char *data;
|
||||
int bytes = 0;
|
||||
|
||||
data = _e_ipc_path_str_get(dirs, &bytes);
|
||||
ecore_ipc_client_send(e->client,
|
||||
E_IPC_DOMAIN_REPLY,
|
||||
E_IPC_OP_BG_DIRS_LIST_REPLY,
|
||||
0/*ref*/, 0/*ref_to*/, 0/*response*/,
|
||||
data, bytes);
|
||||
free(data);
|
||||
}
|
||||
break;
|
||||
case E_IPC_OP_RESTART:
|
||||
{
|
||||
restart = 1;
|
||||
ecore_main_loop_quit();
|
||||
}
|
||||
break;
|
||||
case E_IPC_OP_SHUTDOWN:
|
||||
{
|
||||
ecore_main_loop_quit();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -477,3 +524,39 @@ _e_ipc_cb_client_data(void *data, int type, void *event)
|
|||
/* ecore_ipc_server_del(ecore_ipc_client_server_get(e->client)); */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: This dosen't handle the case where one of the paths is of the
|
||||
* form: ~moo/bar/baz need to figure out the correct path to the
|
||||
* specified users homedir
|
||||
*/
|
||||
static char *
|
||||
_e_ipc_path_str_get(char **paths, int *bytes)
|
||||
{
|
||||
char *data = NULL, **cur, *home;
|
||||
int pos = 0;
|
||||
char tmp[PATH_MAX];
|
||||
|
||||
*bytes = 0;
|
||||
home = e_user_homedir_get();
|
||||
for (cur = paths; *cur != NULL; cur++)
|
||||
{
|
||||
int len;
|
||||
char *p;
|
||||
|
||||
p = *cur;
|
||||
if (*p == '~') snprintf(tmp, PATH_MAX, "%s%s", home, ++p);
|
||||
else snprintf(tmp, PATH_MAX, "%s", p);
|
||||
|
||||
*bytes += strlen(tmp) + 1;
|
||||
data = realloc(data, *bytes);
|
||||
|
||||
memcpy(data + pos, tmp, strlen(tmp));
|
||||
pos = *bytes;
|
||||
data[pos - 1] = 0;
|
||||
}
|
||||
free(home);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,9 +20,13 @@ typedef enum _E_Ipc_Op {
|
|||
E_IPC_OP_MODULE_DISABLE,
|
||||
E_IPC_OP_MODULE_LIST,
|
||||
E_IPC_OP_MODULE_LIST_REPLY,
|
||||
E_IPC_OP_MODULE_DIRS_LIST,
|
||||
E_IPC_OP_MODULE_DIRS_LIST_REPLY,
|
||||
E_IPC_OP_BG_SET,
|
||||
E_IPC_OP_BG_GET,
|
||||
E_IPC_OP_BG_GET_REPLY,
|
||||
E_IPC_OP_BG_DIRS_LIST,
|
||||
E_IPC_OP_BG_DIRS_LIST_REPLY,
|
||||
E_IPC_OP_FONT_AVAILABLE_LIST,
|
||||
E_IPC_OP_FONT_AVAILABLE_LIST_REPLY,
|
||||
E_IPC_OP_FONT_APPLY,
|
||||
|
@ -39,6 +43,7 @@ typedef enum _E_Ipc_Op {
|
|||
E_IPC_OP_FONT_DEFAULT_LIST,
|
||||
E_IPC_OP_FONT_DEFAULT_LIST_REPLY,
|
||||
E_IPC_OP_RESTART,
|
||||
E_IPC_OP_SHUTDOWN,
|
||||
E_IPC_OP_LAST
|
||||
} E_Ipc_Op;
|
||||
|
||||
|
|
|
@ -50,7 +50,10 @@ E_IPC_Opt_Handler handlers[] =
|
|||
OSTR("-module-enable", "Enable module OPT1 if not enabled", E_IPC_OP_MODULE_ENABLE, 0),
|
||||
OSTR("-module-disable", "Disable module OPT1 if not disabled", E_IPC_OP_MODULE_DISABLE, 0),
|
||||
OREQ("-module-list", "List all loaded modules and their states", E_IPC_OP_MODULE_LIST, 1),
|
||||
OREQ("-module-dirs-list", "List all modules directories", E_IPC_OP_MODULE_DIRS_LIST, 1),
|
||||
OSTR("-bg-set", "Set the background edje file to be OPT1", E_IPC_OP_BG_SET, 0),
|
||||
OREQ("-bg-get", "Get the background edje file", E_IPC_OP_BG_GET, 1),
|
||||
OREQ("-bg-dirs-list", "Get the background directories", E_IPC_OP_BG_DIRS_LIST, 1),
|
||||
OSTR("-font-fallback-remove", "Remove OPT1 from the fontset", E_IPC_OP_FONT_FALLBACK_REMOVE, 0),
|
||||
OSTR("-font-fallback-prepend", "Prepend OPT1 to the fontset", E_IPC_OP_FONT_FALLBACK_PREPEND, 0),
|
||||
OSTR("-font-fallback-append", "Append OPT1 to the fontset", E_IPC_OP_FONT_FALLBACK_APPEND, 0),
|
||||
|
@ -62,7 +65,8 @@ E_IPC_Opt_Handler handlers[] =
|
|||
OSTR("-font-default-remove", "Remove the default text class OPT1", E_IPC_OP_FONT_DEFAULT_REMOVE, 0),
|
||||
OREQ("-font-default-list", "List all configured text classes", E_IPC_OP_FONT_DEFAULT_LIST, 1),
|
||||
OMUL("-font-default-set", "Set textclass (OPT1) font (OPT2) and size (OPT3)", E_IPC_OP_FONT_DEFAULT_SET, 0, 3),
|
||||
OREQ("-restart", "Restart E17", E_IPC_OP_RESTART, 0)
|
||||
OREQ("-restart", "Restart E17", E_IPC_OP_RESTART, 0),
|
||||
OREQ("-shutdown", "Shutdown E17", E_IPC_OP_SHUTDOWN, 0)
|
||||
};
|
||||
|
||||
/* externally accessible functions */
|
||||
|
@ -338,6 +342,44 @@ _e_ipc_cb_server_data(void *data, int type, void *event)
|
|||
else
|
||||
printf("REPLY: MODULE NONE\n");
|
||||
break;
|
||||
case E_IPC_OP_MODULE_DIRS_LIST_REPLY:
|
||||
if (e->data)
|
||||
{
|
||||
char *p;
|
||||
|
||||
p = e->data;
|
||||
while (p < (char *)(e->data + e->size))
|
||||
{
|
||||
char *dir;
|
||||
|
||||
dir = p;
|
||||
printf("REPLY: MODULE DIR=%s\n", dir);
|
||||
p += strlen(dir) + 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case E_IPC_OP_BG_GET_REPLY:
|
||||
if (e->data)
|
||||
{
|
||||
printf("REPLY: %s\n", e->data);
|
||||
}
|
||||
break;
|
||||
case E_IPC_OP_BG_DIRS_LIST_REPLY:
|
||||
if (e->data)
|
||||
{
|
||||
char *p;
|
||||
|
||||
p = e->data;
|
||||
while (p < (char *)(e->data + e->size))
|
||||
{
|
||||
char *dir;
|
||||
|
||||
dir = p;
|
||||
printf("REPLY: BG DIR=%s\n", dir);
|
||||
p += strlen(dir) + 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case E_IPC_OP_FONT_FALLBACK_LIST_REPLY:
|
||||
if (e->data)
|
||||
{
|
||||
|
|
30
src/lib/E.h
30
src/lib/E.h
|
@ -19,21 +19,44 @@
|
|||
#endif
|
||||
|
||||
typedef struct _E_Response_Module_List E_Response_Module_List;
|
||||
typedef struct _E_Response_Module_Data E_Response_Module_Data;
|
||||
typedef struct _E_Response_Module_Dirs_List E_Response_Module_Dirs_List;
|
||||
typedef struct _E_Response_Background_Get E_Response_Background_Get;
|
||||
typedef struct _E_Response_Background_Dirs_List E_Response_Background_Dirs_List;
|
||||
|
||||
struct _E_Response_Module_List
|
||||
{
|
||||
E_Response_Module_Data **modules;
|
||||
int count;
|
||||
};
|
||||
|
||||
struct _E_Response_Module_Data
|
||||
{
|
||||
char *name;
|
||||
char enabled;
|
||||
};
|
||||
|
||||
struct _E_Response_Module_Dirs_List
|
||||
{
|
||||
char **dirs;
|
||||
int count;
|
||||
};
|
||||
|
||||
struct _E_Response_Background_Get
|
||||
{
|
||||
char *data;
|
||||
char *file;
|
||||
};
|
||||
|
||||
struct _E_Response_Background_Dirs_List
|
||||
{
|
||||
char **dirs;
|
||||
int count;
|
||||
};
|
||||
|
||||
extern EAPI int E_RESPONSE_MODULE_LIST;
|
||||
extern EAPI int E_RESPONSE_BACKGROUND_GET;
|
||||
extern EAPI int E_RESPONSE_MODULE_DIRS_LIST;
|
||||
extern EAPI int E_RESPONSE_BACKGROUND_DIRS_LIST;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -45,6 +68,7 @@ extern "C" {
|
|||
|
||||
/* E startup and shutdown */
|
||||
EAPI void e_restart (void);
|
||||
EAPI void e_quit (void);
|
||||
|
||||
/* E module manipulation */
|
||||
EAPI void e_module_enabled_set (const char *module, int enable);
|
||||
|
@ -55,6 +79,10 @@ extern "C" {
|
|||
EAPI void e_background_set (const char *bgfile);
|
||||
EAPI void e_background_get (void);
|
||||
|
||||
/* E path information */
|
||||
EAPI void e_module_dirs_list (void);
|
||||
EAPI void e_background_dirs_list (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
173
src/lib/e_main.c
173
src/lib/e_main.c
|
@ -7,11 +7,10 @@
|
|||
* TODO:
|
||||
* add ecore events for callbacks to all/some ipc calls, e.g. module_list
|
||||
*
|
||||
* add module_list, module_enabled_get and module_enabled_set
|
||||
* add module_enabled_get
|
||||
*
|
||||
* augment IPC calls and add wrappers for them - i.e.:
|
||||
* e restart/shutdown
|
||||
* desktops add/remove/list/currentset/bgset etc
|
||||
* desktops add/remove/list/currentset etc
|
||||
* windows shade[get/set]/maximise[get/set]/iconify[get/set]/list
|
||||
*
|
||||
* add ability to e to set theme, so we can have a theme_set call :)
|
||||
|
@ -26,10 +25,16 @@ static int _e_ipc_init(const char *display);
|
|||
static void _e_ipc_shutdown(void);
|
||||
static int _e_cb_server_data(void *data, int type, void *event);
|
||||
|
||||
static void _e_cb_module_list_free(void *data, void *ev);
|
||||
static void _e_cb_module_dir_list_free(void *data, void *ev);
|
||||
static void _e_cb_bg_dir_list_free(void *data, void *ev);
|
||||
|
||||
static Ecore_Ipc_Server *_e_ipc_server = NULL;
|
||||
|
||||
int E_RESPONSE_MODULE_LIST = 0;
|
||||
int E_RESPONSE_MODULE_DIRS_LIST = 0;
|
||||
int E_RESPONSE_BACKGROUND_GET = 0;
|
||||
int E_RESPONSE_BACKGROUND_DIRS_LIST = 0;
|
||||
|
||||
/*
|
||||
* initialise connection to the current E running on "display".
|
||||
|
@ -102,7 +107,9 @@ e_init(const char* display)
|
|||
if (!E_RESPONSE_MODULE_LIST)
|
||||
{
|
||||
E_RESPONSE_MODULE_LIST = ecore_event_type_new();
|
||||
E_RESPONSE_MODULE_DIRS_LIST = ecore_event_type_new();
|
||||
E_RESPONSE_BACKGROUND_GET = ecore_event_type_new();
|
||||
E_RESPONSE_BACKGROUND_DIRS_LIST = ecore_event_type_new();
|
||||
}
|
||||
|
||||
if (free_disp)
|
||||
|
@ -127,12 +134,17 @@ e_shutdown(void)
|
|||
void
|
||||
e_restart(void)
|
||||
{
|
||||
E_Ipc_Op type;
|
||||
|
||||
type = E_IPC_OP_RESTART;
|
||||
ecore_ipc_server_send(_e_ipc_server, E_IPC_DOMAIN_REQUEST, type, 0/*ref*/,
|
||||
0/*ref_to*/, 0/*response*/, NULL, 0);
|
||||
ecore_ipc_server_send(_e_ipc_server, E_IPC_DOMAIN_REQUEST,
|
||||
E_IPC_OP_RESTART, 0/*ref*/, 0/*ref_to*/,
|
||||
0/*response*/, NULL, 0);
|
||||
}
|
||||
|
||||
void
|
||||
e_quit(void)
|
||||
{
|
||||
ecore_ipc_server_send(_e_ipc_server, E_IPC_DOMAIN_REQUEST,
|
||||
E_IPC_OP_SHUTDOWN, 0/*ref*/, 0/*ref_to*/,
|
||||
0/*response*/, NULL, 0);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -179,6 +191,14 @@ e_module_list(void)
|
|||
0/*response*/, NULL, 0);
|
||||
}
|
||||
|
||||
void
|
||||
e_module_dirs_list(void)
|
||||
{
|
||||
ecore_ipc_server_send(_e_ipc_server, E_IPC_DOMAIN_REQUEST,
|
||||
E_IPC_OP_MODULE_DIRS_LIST, 0/*ref*/, 0/*ref_to*/,
|
||||
0/*response*/, NULL, 0);
|
||||
}
|
||||
|
||||
void
|
||||
e_background_set(const char *bgfile)
|
||||
{
|
||||
|
@ -198,6 +218,14 @@ e_background_get(void)
|
|||
0/*response*/, NULL, 0);
|
||||
}
|
||||
|
||||
void
|
||||
e_background_dirs_list(void)
|
||||
{
|
||||
ecore_ipc_server_send(_e_ipc_server, E_IPC_DOMAIN_REQUEST,
|
||||
E_IPC_OP_BG_DIRS_LIST, 0/*ref*/,
|
||||
0/*ref_to*/, 0/*response*/, NULL, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
_e_ipc_init(const char *display)
|
||||
{
|
||||
|
@ -242,28 +270,74 @@ _e_cb_server_data(void *data, int type, void *event)
|
|||
case E_IPC_OP_MODULE_LIST_REPLY:
|
||||
if (e->data)
|
||||
{
|
||||
E_Response_Module_List *res;
|
||||
int count = 0;
|
||||
char *p;
|
||||
|
||||
res = calloc(1, sizeof(E_Response_Module_List));
|
||||
|
||||
p = e->data;
|
||||
while (p < (char *)(e->data + e->size))
|
||||
{
|
||||
E_Response_Module_List *res;
|
||||
p += strlen(p) + 1 + 1;
|
||||
count ++;
|
||||
}
|
||||
res->modules = malloc(sizeof(E_Response_Module_Data *) * count);
|
||||
res->count = count;
|
||||
|
||||
res = calloc(1, sizeof(E_Response_Module_List));
|
||||
res->name = p;
|
||||
p += strlen(res->name);
|
||||
count = 0;
|
||||
p = e->data;
|
||||
while (p < (char *)(e->data + e->size))
|
||||
{
|
||||
E_Response_Module_Data *md;
|
||||
md = malloc(sizeof(E_Response_Module_Data));
|
||||
md->name = p;
|
||||
p += strlen(md->name);
|
||||
if (p < (char *)(e->data + e->size))
|
||||
{
|
||||
p++;
|
||||
if (p < (char *)(e->data + e->size))
|
||||
{
|
||||
res->enabled = *p;
|
||||
md->enabled = *p;
|
||||
p++;
|
||||
ecore_event_add(E_RESPONSE_MODULE_LIST, res,
|
||||
NULL, NULL);
|
||||
}
|
||||
}
|
||||
res->modules[count] = md;
|
||||
count ++;
|
||||
}
|
||||
ecore_event_add(E_RESPONSE_MODULE_LIST, res,
|
||||
_e_cb_module_list_free, NULL);
|
||||
}
|
||||
break;
|
||||
case E_IPC_OP_MODULE_DIRS_LIST_REPLY:
|
||||
if (e->data)
|
||||
{
|
||||
E_Response_Module_Dirs_List *res;
|
||||
int count = 0;
|
||||
char *p;
|
||||
|
||||
res = calloc(1, sizeof(E_Response_Module_Dirs_List));
|
||||
|
||||
p = e->data;
|
||||
while (p < (char *)(e->data + e->size))
|
||||
{
|
||||
p += strlen(p) + 1;
|
||||
count ++;
|
||||
}
|
||||
|
||||
res->dirs = malloc(sizeof(char *) * count);
|
||||
res->count = count;
|
||||
|
||||
count = 0;
|
||||
p = e->data;
|
||||
while (p < (char *)(e->data + e->size))
|
||||
{
|
||||
res->dirs[count] = p;
|
||||
p += strlen(res->dirs[count]) + 1;
|
||||
count++;
|
||||
}
|
||||
ecore_event_add(E_RESPONSE_MODULE_DIRS_LIST, res,
|
||||
_e_cb_module_dir_list_free, NULL);
|
||||
}
|
||||
break;
|
||||
case E_IPC_OP_BG_GET_REPLY:
|
||||
|
@ -271,12 +345,79 @@ _e_cb_server_data(void *data, int type, void *event)
|
|||
E_Response_Background_Get *res;
|
||||
|
||||
res = calloc(1, sizeof(E_Response_Background_Get));
|
||||
res->data = e->data;
|
||||
res->file = e->data;
|
||||
ecore_event_add(E_RESPONSE_BACKGROUND_GET, res, NULL, NULL);
|
||||
break;
|
||||
}
|
||||
case E_IPC_OP_BG_DIRS_LIST_REPLY:
|
||||
if (e->data)
|
||||
{
|
||||
E_Response_Background_Dirs_List *res;
|
||||
char *p;
|
||||
int count = 0;
|
||||
|
||||
res = calloc(1, sizeof(E_Response_Background_Dirs_List));
|
||||
|
||||
p = e->data;
|
||||
while (p < (char *)(e->data + e->size))
|
||||
{
|
||||
p += strlen(p) + 1;
|
||||
count ++;
|
||||
}
|
||||
|
||||
res->dirs = malloc(sizeof(char *) * count);
|
||||
res->count = count;
|
||||
|
||||
count = 0;
|
||||
p = e->data;
|
||||
while (p < (char *)(e->data + e->size))
|
||||
{
|
||||
res->dirs[count] = p;
|
||||
p += strlen(res->dirs[count]) + 1;
|
||||
count++;
|
||||
}
|
||||
ecore_event_add(E_RESPONSE_BACKGROUND_DIRS_LIST, res,
|
||||
_e_cb_bg_dir_list_free, NULL);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void _e_cb_module_list_free(void *data, void *ev)
|
||||
{
|
||||
E_Response_Module_List *e;
|
||||
int i;
|
||||
|
||||
e = ev;
|
||||
for (i = 0; i < e->count; i++)
|
||||
{
|
||||
free(e->modules[i]);
|
||||
}
|
||||
free(e->modules);
|
||||
free(e);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_cb_module_dir_list_free(void *data, void *ev)
|
||||
{
|
||||
E_Response_Module_Dirs_List *e;
|
||||
|
||||
e = ev;
|
||||
free(e->dirs);
|
||||
free(e);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_cb_bg_dir_list_free(void *data, void *ev)
|
||||
{
|
||||
E_Response_Background_Dirs_List *e;
|
||||
|
||||
e = ev;
|
||||
free(e->dirs);
|
||||
free(e);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue