forked from enlightenment/enlightenment
Add some more IPC stuff, think I am getting the hang of this now
Make libe use the ipc_handlers backend (womeone might need to correct my autofoo) what should we do for the (pretty custom) libe RESPONSEs? should they go into the handlers too? SVN revision: 15055
This commit is contained in:
parent
28d41b1d28
commit
ff669b3289
|
@ -116,6 +116,8 @@ AC_ARG_WITH(evas-config,
|
||||||
])
|
])
|
||||||
evas_cflags=`$EVAS_CONFIG --cflags`
|
evas_cflags=`$EVAS_CONFIG --cflags`
|
||||||
evas_libs=`$EVAS_CONFIG --libs`
|
evas_libs=`$EVAS_CONFIG --libs`
|
||||||
|
AC_SUBST(evas_cflags)
|
||||||
|
AC_SUBST(evas_libs)
|
||||||
|
|
||||||
AC_ARG_WITH(ecore-config,
|
AC_ARG_WITH(ecore-config,
|
||||||
[ --with-ecore-config=ECORE_CONFIG use ecore-config specified ],
|
[ --with-ecore-config=ECORE_CONFIG use ecore-config specified ],
|
||||||
|
|
|
@ -382,6 +382,37 @@ break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
#define HDL E_IPC_OP_RESTART
|
||||||
|
#if (TYPE == E_REMOTE_OPTIONS)
|
||||||
|
OP("-restart", 0, "Restart Enlightenment", 0, HDL)
|
||||||
|
#elif (TYPE == E_REMOTE_OUT)
|
||||||
|
REQ_NULL(HDL);
|
||||||
|
#elif (TYPE == E_WM_IN)
|
||||||
|
GENERIC(HDL);
|
||||||
|
restart = 1;
|
||||||
|
ecore_main_loop_quit();
|
||||||
|
END_GENERIC();
|
||||||
|
#elif (TYPE == E_REMOTE_IN)
|
||||||
|
#endif
|
||||||
|
#undef HDL
|
||||||
|
/****************************************************************************/
|
||||||
|
#define HDL E_IPC_OP_SHUTDOWN
|
||||||
|
#if (TYPE == E_REMOTE_OPTIONS)
|
||||||
|
OP("-shutdown", 0, "Shutdown (exit) Enlightenment", 1, HDL)
|
||||||
|
#elif (TYPE == E_REMOTE_OUT)
|
||||||
|
REQ_NULL(HDL);
|
||||||
|
#elif (TYPE == E_WM_IN)
|
||||||
|
GENERIC(HDL);
|
||||||
|
ecore_main_loop_quit();
|
||||||
|
END_GENERIC();
|
||||||
|
#elif (TYPE == E_REMOTE_IN)
|
||||||
|
#endif
|
||||||
|
#undef HDL
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
MAINTAINERCLEANFILES = Makefile.in
|
MAINTAINERCLEANFILES = Makefile.in
|
||||||
INCLUDES = -I$(includedir) \
|
INCLUDES = -I$(includedir) \
|
||||||
-I$(top_srcdir)/src/bin
|
-I$(top_srcdir)/src/bin
|
||||||
@ecore_cflags@
|
@ecore_cflags@ \
|
||||||
|
@evas_cflags@
|
||||||
|
|
||||||
lib_LTLIBRARIES = libe.la
|
lib_LTLIBRARIES = libe.la
|
||||||
|
|
||||||
|
@ -11,7 +12,8 @@ libe_la_SOURCES= \
|
||||||
e_main.c \
|
e_main.c \
|
||||||
e.h \
|
e.h \
|
||||||
../bin/e_ipc_codec.c \
|
../bin/e_ipc_codec.c \
|
||||||
|
../bin/e_ipc_codec.h \
|
||||||
e_private.h
|
e_private.h
|
||||||
|
|
||||||
libe_la_LIBADD = @ecore_libs@
|
libe_la_LIBADD = @ecore_libs@ @evas_libs@
|
||||||
libe_la_DEPENDENCIES = $(top_builddir)/config.h
|
libe_la_DEPENDENCIES = $(top_builddir)/config.h
|
||||||
|
|
154
src/lib/e_main.c
154
src/lib/e_main.c
|
@ -16,13 +16,33 @@
|
||||||
* add ability to e to set theme, so we can have a theme_set call :)
|
* add ability to e to set theme, so we can have a theme_set call :)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <Evas.h>
|
||||||
#include "E.h"
|
#include "E.h"
|
||||||
#include "e_private.h"
|
#include "e_private.h"
|
||||||
#include <Ecore.h>
|
#include <Ecore.h>
|
||||||
#include <Ecore_Ipc.h>
|
#include <Ecore_Ipc.h>
|
||||||
|
|
||||||
|
typedef struct _Opt Opt;
|
||||||
|
|
||||||
|
struct _Opt
|
||||||
|
{
|
||||||
|
char *opt;
|
||||||
|
int num_param;
|
||||||
|
char *desc;
|
||||||
|
int num_reply;
|
||||||
|
E_Ipc_Op opcode;
|
||||||
|
};
|
||||||
|
|
||||||
|
Opt opts[] = {
|
||||||
|
#define TYPE E_REMOTE_OPTIONS
|
||||||
|
#include "e_ipc_handlers.h"
|
||||||
|
#undef TYPE
|
||||||
|
};
|
||||||
|
|
||||||
static int _e_ipc_init(const char *display);
|
static int _e_ipc_init(const char *display);
|
||||||
static void _e_ipc_shutdown(void);
|
static void _e_ipc_shutdown(void);
|
||||||
|
static Opt *_e_ipc_call_find(char *name);
|
||||||
|
static void _e_ipc_call(Opt *opt, char **params);
|
||||||
static int _e_cb_server_data(void *data, int type, void *event);
|
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_list_free(void *data, void *ev);
|
||||||
|
@ -98,13 +118,6 @@ e_init(const char* display)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* setup e ipc codecs */
|
|
||||||
if (!e_ipc_codec_init())
|
|
||||||
{
|
|
||||||
fprintf(stderr, "ERROR: Could not start enlightenment IPC codecs.\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* setup e ipc service */
|
/* setup e ipc service */
|
||||||
if (!_e_ipc_init(disp))
|
if (!_e_ipc_init(disp))
|
||||||
{
|
{
|
||||||
|
@ -112,6 +125,7 @@ e_init(const char* display)
|
||||||
"Did you specify the right display?\n");
|
"Did you specify the right display?\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
e_ipc_codec_init();
|
||||||
|
|
||||||
if (!E_RESPONSE_MODULE_LIST)
|
if (!E_RESPONSE_MODULE_LIST)
|
||||||
{
|
{
|
||||||
|
@ -145,17 +159,13 @@ e_shutdown(void)
|
||||||
void
|
void
|
||||||
e_restart(void)
|
e_restart(void)
|
||||||
{
|
{
|
||||||
ecore_ipc_server_send(_e_ipc_server, E_IPC_DOMAIN_REQUEST,
|
_e_ipc_call(_e_ipc_call_find("-restart"), NULL);
|
||||||
E_IPC_OP_RESTART, 0/*ref*/, 0/*ref_to*/,
|
|
||||||
0/*response*/, NULL, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
e_quit(void)
|
e_quit(void)
|
||||||
{
|
{
|
||||||
ecore_ipc_server_send(_e_ipc_server, E_IPC_DOMAIN_REQUEST,
|
_e_ipc_call(_e_ipc_call_find("-shutdown"), NULL);
|
||||||
E_IPC_OP_SHUTDOWN, 0/*ref*/, 0/*ref_to*/,
|
|
||||||
0/*response*/, NULL, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -167,13 +177,9 @@ e_module_enabled_set(const char *module, int enable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (enable)
|
if (enable)
|
||||||
type = E_IPC_OP_MODULE_ENABLE;
|
_e_ipc_call(_e_ipc_call_find("-module-enable"), &module);
|
||||||
else
|
else
|
||||||
type = E_IPC_OP_MODULE_DISABLE;
|
_e_ipc_call(_e_ipc_call_find("-module-disable"), &module);
|
||||||
|
|
||||||
ecore_ipc_server_send(_e_ipc_server, E_IPC_DOMAIN_REQUEST, type, 0/*ref*/,
|
|
||||||
0/*ref_to*/, 0/*response*/, (void *)module,
|
|
||||||
strlen(module));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -185,21 +191,15 @@ e_module_load_set(const char *module, int load)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (load)
|
if (load)
|
||||||
type = E_IPC_OP_MODULE_LOAD;
|
_e_ipc_call(_e_ipc_call_find("-module-load"), &module);
|
||||||
else
|
else
|
||||||
type = E_IPC_OP_MODULE_UNLOAD;
|
_e_ipc_call(_e_ipc_call_find("-module-unload"), &module);
|
||||||
|
|
||||||
ecore_ipc_server_send(_e_ipc_server, E_IPC_DOMAIN_REQUEST, type, 0/*ref*/,
|
|
||||||
0/*ref_to*/, 0/*response*/, (void *)module,
|
|
||||||
strlen(module));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
e_module_list(void)
|
e_module_list(void)
|
||||||
{
|
{
|
||||||
ecore_ipc_server_send(_e_ipc_server, E_IPC_DOMAIN_REQUEST,
|
_e_ipc_call(_e_ipc_call_find("-module-list"), NULL);
|
||||||
E_IPC_OP_MODULE_LIST, 0/*ref*/, 0/*ref_to*/,
|
|
||||||
0/*response*/, NULL, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -216,17 +216,13 @@ e_background_set(const char *bgfile)
|
||||||
if (!bgfile)
|
if (!bgfile)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ecore_ipc_server_send(_e_ipc_server, E_IPC_DOMAIN_REQUEST, E_IPC_OP_BG_SET,
|
_e_ipc_call(_e_ipc_call_find("-default-bg-set"), &bgfile);
|
||||||
0/*ref*/, 0/*ref_to*/, 0/*response*/, (void *)bgfile,
|
|
||||||
strlen(bgfile));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
e_background_get(void)
|
e_background_get(void)
|
||||||
{
|
{
|
||||||
ecore_ipc_server_send(_e_ipc_server, E_IPC_DOMAIN_REQUEST,
|
_e_ipc_call(_e_ipc_call_find("-default-bg-get"), NULL);
|
||||||
E_IPC_OP_BG_GET, 0/*ref*/, 0/*ref_to*/,
|
|
||||||
0/*response*/, NULL, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -245,6 +241,8 @@ e_theme_dirs_list(void)
|
||||||
// 0/*ref_to*/, 0/*response*/, NULL, 0);
|
// 0/*ref_to*/, 0/*response*/, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//static int reply_count = 0;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_e_ipc_init(const char *display)
|
_e_ipc_init(const char *display)
|
||||||
{
|
{
|
||||||
|
@ -259,8 +257,6 @@ _e_ipc_init(const char *display)
|
||||||
/* similar... */
|
/* similar... */
|
||||||
if (!_e_ipc_server) return 0;
|
if (!_e_ipc_server) return 0;
|
||||||
|
|
||||||
/* ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_ADD, _e_cb_server_add, NULL);*/
|
|
||||||
/* ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DEL, _e_cb_server_del, NULL);*/
|
|
||||||
ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DATA, _e_cb_server_data, NULL);
|
ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DATA, _e_cb_server_data, NULL);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -276,6 +272,41 @@ _e_ipc_shutdown(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Opt *
|
||||||
|
_e_ipc_call_find(char *name)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
for (j = 0; j < (int)(sizeof(opts) / sizeof(Opt)); j++)
|
||||||
|
{
|
||||||
|
Opt *opt;
|
||||||
|
|
||||||
|
opt = &(opts[j]);
|
||||||
|
if (!strcmp(opt->opt, name))
|
||||||
|
return opt;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_e_ipc_call(Opt *opt, char **params)
|
||||||
|
{
|
||||||
|
Ecore_Ipc_Event_Server_Data *e = malloc(sizeof(Ecore_Ipc_Event_Server_Data));
|
||||||
|
e->server = _e_ipc_server;
|
||||||
|
|
||||||
|
switch(opt->opcode)
|
||||||
|
{
|
||||||
|
|
||||||
|
#define TYPE E_REMOTE_OUT
|
||||||
|
#include "e_ipc_handlers.h"
|
||||||
|
#undef TYPE
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
free(e);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_e_cb_server_data(void *data __UNUSED__, int type, void *event)
|
_e_cb_server_data(void *data __UNUSED__, int type, void *event)
|
||||||
{
|
{
|
||||||
|
@ -283,6 +314,41 @@ _e_cb_server_data(void *data __UNUSED__, int type, void *event)
|
||||||
|
|
||||||
e = event;
|
e = event;
|
||||||
|
|
||||||
|
switch (e->minor)
|
||||||
|
{
|
||||||
|
|
||||||
|
case E_IPC_OP_BG_GET_REPLY:
|
||||||
|
{
|
||||||
|
E_Response_Background_Get *res;
|
||||||
|
char *str = NULL;
|
||||||
|
|
||||||
|
res = calloc(1, sizeof(E_Response_Background_Get));
|
||||||
|
if (e->data)
|
||||||
|
{
|
||||||
|
e_ipc_codec_str_dec(e->data, e->size, &str);
|
||||||
|
res->file = str;
|
||||||
|
}
|
||||||
|
ecore_event_add(E_RESPONSE_BACKGROUND_GET, res, NULL, NULL);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
// FIXME: if we were to use the e_handlers.h then it will need library
|
||||||
|
// stuff, i.e. E_LIB_IN which creates the replies and sends the event...
|
||||||
|
//
|
||||||
|
//#define TYPE E_REMOTE_IN
|
||||||
|
//#include "e_ipc_handlers.h"
|
||||||
|
//#undef TYPE
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Ecore_Ipc_Event_Server_Data *e;
|
||||||
|
|
||||||
|
e = event;
|
||||||
|
|
||||||
type = E_IPC_OP_MODULE_LIST;
|
type = E_IPC_OP_MODULE_LIST;
|
||||||
switch (e->minor)
|
switch (e->minor)
|
||||||
{
|
{
|
||||||
|
@ -328,7 +394,7 @@ _e_cb_server_data(void *data __UNUSED__, int type, void *event)
|
||||||
_e_cb_module_list_free, NULL);
|
_e_cb_module_list_free, NULL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
/*
|
*
|
||||||
case E_IPC_OP_MODULE_DIRS_LIST_REPLY:
|
case E_IPC_OP_MODULE_DIRS_LIST_REPLY:
|
||||||
if (e->data)
|
if (e->data)
|
||||||
{
|
{
|
||||||
|
@ -360,7 +426,7 @@ _e_cb_server_data(void *data __UNUSED__, int type, void *event)
|
||||||
_e_cb_module_dir_list_free, NULL);
|
_e_cb_module_dir_list_free, NULL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
*/
|
*
|
||||||
case E_IPC_OP_BG_GET_REPLY:
|
case E_IPC_OP_BG_GET_REPLY:
|
||||||
{
|
{
|
||||||
E_Response_Background_Get *res;
|
E_Response_Background_Get *res;
|
||||||
|
@ -369,13 +435,13 @@ _e_cb_server_data(void *data __UNUSED__, int type, void *event)
|
||||||
res = calloc(1, sizeof(E_Response_Background_Get));
|
res = calloc(1, sizeof(E_Response_Background_Get));
|
||||||
if (e->data)
|
if (e->data)
|
||||||
{
|
{
|
||||||
e_ipc_codec_str_dec(e->data, e->size, &str);
|
e_codec_str_dec(e->data, e->size, &str);
|
||||||
res->file = str;
|
res->file = str;
|
||||||
}
|
}
|
||||||
ecore_event_add(E_RESPONSE_BACKGROUND_GET, res, NULL, NULL);
|
ecore_event_add(E_RESPONSE_BACKGROUND_GET, res, NULL, NULL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
/* case E_IPC_OP_BG_DIRS_LIST_REPLY:
|
* case E_IPC_OP_BG_DIRS_LIST_REPLY:
|
||||||
if (e->data)
|
if (e->data)
|
||||||
{
|
{
|
||||||
E_Response_Background_Dirs_List *res;
|
E_Response_Background_Dirs_List *res;
|
||||||
|
@ -406,8 +472,8 @@ _e_cb_server_data(void *data __UNUSED__, int type, void *event)
|
||||||
_e_cb_bg_dir_list_free, NULL);
|
_e_cb_bg_dir_list_free, NULL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
*/
|
*
|
||||||
/* case E_IPC_OP_THEME_DIRS_LIST_REPLY:
|
* case E_IPC_OP_THEME_DIRS_LIST_REPLY:
|
||||||
if (e->data)
|
if (e->data)
|
||||||
{
|
{
|
||||||
E_Response_Theme_Dirs_List *res;
|
E_Response_Theme_Dirs_List *res;
|
||||||
|
@ -438,11 +504,11 @@ _e_cb_server_data(void *data __UNUSED__, int type, void *event)
|
||||||
_e_cb_theme_dir_list_free, NULL);
|
_e_cb_theme_dir_list_free, NULL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
*/
|
*
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _e_cb_module_list_free(void *data __UNUSED__, void *ev)
|
static void _e_cb_module_list_free(void *data __UNUSED__, void *ev)
|
||||||
|
|
|
@ -23,3 +23,9 @@
|
||||||
#include "e_ipc.h"
|
#include "e_ipc.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define E_TYPEDEFS 1
|
||||||
|
#include "e_ipc_codec.h"
|
||||||
|
#undef E_TYPEDEFS
|
||||||
|
#include "e_ipc_codec.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue