2004-11-24 19:37:45 -08:00
|
|
|
#include "e.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);
|
2005-05-12 07:46:28 -07:00
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
/* local subsystem globals */
|
|
|
|
static Ecore_Ipc_Server *_e_ipc_server = NULL;
|
|
|
|
|
|
|
|
/* externally accessible functions */
|
|
|
|
int
|
|
|
|
e_ipc_init(void)
|
|
|
|
{
|
|
|
|
char buf[1024];
|
|
|
|
char *disp;
|
|
|
|
|
|
|
|
disp = getenv("DISPLAY");
|
|
|
|
if (!disp) disp = ":0";
|
|
|
|
snprintf(buf, sizeof(buf), "enlightenment-(%s)", disp);
|
|
|
|
_e_ipc_server = ecore_ipc_server_add(ECORE_IPC_LOCAL_USER, buf, 0, NULL);
|
|
|
|
if (!_e_ipc_server) return 0;
|
|
|
|
ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD, _e_ipc_cb_client_add, NULL);
|
|
|
|
ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DEL, _e_ipc_cb_client_del, NULL);
|
|
|
|
ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DATA, _e_ipc_cb_client_data, NULL);
|
2005-05-12 07:46:28 -07:00
|
|
|
|
|
|
|
e_ipc_codec_init();
|
2004-11-24 19:37:45 -08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
e_ipc_shutdown(void)
|
|
|
|
{
|
2005-05-12 07:46:28 -07:00
|
|
|
e_ipc_codec_shutdown();
|
2004-11-24 19:37:45 -08:00
|
|
|
if (_e_ipc_server)
|
|
|
|
{
|
|
|
|
ecore_ipc_server_del(_e_ipc_server);
|
|
|
|
_e_ipc_server = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* local subsystem globals */
|
|
|
|
static int
|
2005-04-12 23:03:50 -07:00
|
|
|
_e_ipc_cb_client_add(void *data __UNUSED__, int type __UNUSED__, void *event)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
|
|
|
Ecore_Ipc_Event_Client_Add *e;
|
|
|
|
|
|
|
|
e = event;
|
|
|
|
if (ecore_ipc_client_server_get(e->client) != _e_ipc_server) return 1;
|
|
|
|
printf("E-IPC: client %p connected to server!\n", e->client);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2005-04-12 23:03:50 -07:00
|
|
|
_e_ipc_cb_client_del(void *data __UNUSED__, int type __UNUSED__, void *event)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
|
|
|
Ecore_Ipc_Event_Client_Del *e;
|
|
|
|
|
|
|
|
e = event;
|
|
|
|
if (ecore_ipc_client_server_get(e->client) != _e_ipc_server) return 1;
|
|
|
|
printf("E-IPC: client %p disconnected from server!\n", e->client);
|
|
|
|
/* delete client sruct */
|
|
|
|
ecore_ipc_client_del(e->client);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2005-04-12 23:03:50 -07:00
|
|
|
_e_ipc_cb_client_data(void *data __UNUSED__, int type __UNUSED__, void *event)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
|
|
|
Ecore_Ipc_Event_Client_Data *e;
|
|
|
|
|
|
|
|
e = event;
|
|
|
|
if (ecore_ipc_client_server_get(e->client) != _e_ipc_server) return 1;
|
2004-11-26 04:20:38 -08:00
|
|
|
switch (e->minor)
|
|
|
|
{
|
2005-05-30 20:01:53 -07:00
|
|
|
#define TYPE E_WM_IN
|
|
|
|
#include "e_ipc_handlers.h"
|
|
|
|
#undef TYPE
|
|
|
|
/* here to steal from to port over to the new e_ipc_handlers.h */
|
|
|
|
#if 0
|
2005-04-02 08:40:37 -08:00
|
|
|
case E_IPC_OP_FONT_FALLBACK_APPEND:
|
|
|
|
{
|
2005-05-30 20:01:53 -07:00
|
|
|
char *font_name = NULL;
|
2005-04-21 21:25:51 -07:00
|
|
|
|
2005-05-30 20:01:53 -07:00
|
|
|
if (e_ipc_codec_str_dec(e->data, e->size, &font_name))
|
|
|
|
{
|
|
|
|
e_font_fallback_append(font_name);
|
|
|
|
free(font_name);
|
|
|
|
e_config_save_queue();
|
|
|
|
}
|
2005-04-02 08:40:37 -08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case E_IPC_OP_FONT_FALLBACK_PREPEND:
|
|
|
|
{
|
2005-05-30 20:01:53 -07:00
|
|
|
char *font_name = NULL;
|
|
|
|
|
|
|
|
if (e_ipc_codec_str_dec(e->data, e->size, &font_name))
|
|
|
|
{
|
|
|
|
e_font_fallback_prepend(font_name);
|
|
|
|
free(font_name);
|
|
|
|
e_config_save_queue();
|
|
|
|
}
|
2005-04-02 08:40:37 -08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case E_IPC_OP_FONT_FALLBACK_LIST:
|
|
|
|
{
|
2005-05-30 20:01:53 -07:00
|
|
|
E_Font_Fallback *ff;
|
|
|
|
Evas_List *dat = NULL, *l;
|
|
|
|
void *data;
|
2005-04-02 08:40:37 -08:00
|
|
|
int bytes;
|
2005-05-30 20:01:53 -07:00
|
|
|
|
|
|
|
for (l = e_font_available_list(); l; l = l->next)
|
|
|
|
{
|
|
|
|
ff = l->data;
|
|
|
|
dat = evas_list_append(dat, ff->name);
|
|
|
|
}
|
|
|
|
data = e_ipc_codec_str_list_enc(dat, &bytes);
|
2005-04-02 08:40:37 -08:00
|
|
|
ecore_ipc_client_send(e->client,
|
|
|
|
E_IPC_DOMAIN_REPLY,
|
|
|
|
E_IPC_OP_FONT_FALLBACK_LIST_REPLY,
|
|
|
|
0/*ref*/, 0/*ref_to*/, 0/*response*/,
|
|
|
|
data, bytes);
|
|
|
|
free(data);
|
2005-05-30 20:01:53 -07:00
|
|
|
evas_list_free(dat);
|
2005-04-02 08:40:37 -08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case E_IPC_OP_FONT_FALLBACK_REMOVE:
|
|
|
|
{
|
2005-05-30 20:01:53 -07:00
|
|
|
char *font_name = NULL;
|
|
|
|
|
|
|
|
if (e_ipc_codec_str_dec(e->data, e->size, &font_name))
|
|
|
|
{
|
|
|
|
e_font_fallback_remove(font_name);
|
|
|
|
free(font_name);
|
|
|
|
e_config_save_queue();
|
|
|
|
}
|
2005-04-02 08:40:37 -08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case E_IPC_OP_FONT_DEFAULT_SET:
|
|
|
|
{
|
2005-05-30 20:01:53 -07:00
|
|
|
E_Ipc_2Str_Int *v = NULL;
|
2005-04-02 08:40:37 -08:00
|
|
|
|
2005-05-30 20:01:53 -07:00
|
|
|
if (e_ipc_codec_2str_int_dec(e->data, e->size, &v))
|
|
|
|
{
|
|
|
|
e_font_default_set(v->str1, v->str2, v->val);
|
|
|
|
free(v->str1);
|
|
|
|
free(v->str2);
|
|
|
|
free(v);
|
|
|
|
e_config_save_queue();
|
|
|
|
}
|
2005-04-02 08:40:37 -08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case E_IPC_OP_FONT_DEFAULT_GET:
|
|
|
|
{
|
|
|
|
E_Font_Default *efd;
|
2005-05-30 20:01:53 -07:00
|
|
|
char *tclass = NULL;
|
|
|
|
void *data;
|
2005-04-21 21:25:51 -07:00
|
|
|
int bytes;
|
2005-04-02 08:40:37 -08:00
|
|
|
|
2005-05-30 20:01:53 -07:00
|
|
|
if (e_ipc_codec_str_dec(e->data, e->size, &tclass))
|
|
|
|
{
|
|
|
|
efd = e_font_default_get(tclass);
|
|
|
|
data = e_ipc_codec_2str_int_enc(efd->text_class, efd->font, efd->size, &bytes);
|
|
|
|
ecore_ipc_client_send(e->client,
|
|
|
|
E_IPC_DOMAIN_REPLY,
|
|
|
|
E_IPC_OP_FONT_DEFAULT_GET_REPLY,
|
|
|
|
0/*ref*/, 0/*ref_to*/, 0/*response*/,
|
|
|
|
data, bytes);
|
|
|
|
free(data);
|
|
|
|
free(tclass);
|
|
|
|
}
|
2005-04-02 08:40:37 -08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case E_IPC_OP_FONT_DEFAULT_REMOVE:
|
|
|
|
{
|
2005-05-30 20:01:53 -07:00
|
|
|
char *tclass = NULL;
|
2005-04-21 21:25:51 -07:00
|
|
|
|
2005-05-30 20:01:53 -07:00
|
|
|
if (e_ipc_codec_str_dec(e->data, e->size, &tclass))
|
|
|
|
{
|
|
|
|
e_font_default_remove(tclass);
|
|
|
|
free(tclass);
|
|
|
|
e_config_save_queue();
|
|
|
|
}
|
2005-04-02 08:40:37 -08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case E_IPC_OP_FONT_DEFAULT_LIST:
|
|
|
|
{
|
2005-05-30 20:01:53 -07:00
|
|
|
E_Ipc_2Str_Int *v;
|
|
|
|
E_Font_Default *efd;
|
|
|
|
Evas_List *dat = NULL, *l;
|
|
|
|
void *data;
|
2005-04-02 08:40:37 -08:00
|
|
|
int bytes;
|
2005-05-30 20:01:53 -07:00
|
|
|
|
|
|
|
for (l = e_font_default_list(); l; l = l->next)
|
|
|
|
{
|
|
|
|
efd = l->data;
|
|
|
|
v = calloc(1, sizeof(E_Ipc_2Str_Int));
|
|
|
|
v->str1 = efd->text_class;
|
|
|
|
v->str2 = efd->font;
|
|
|
|
v->val = efd->size;
|
|
|
|
dat = evas_list_append(dat, v);
|
|
|
|
}
|
|
|
|
data = e_ipc_codec_2str_int_list_enc(dat, &bytes);
|
2005-04-02 08:40:37 -08:00
|
|
|
ecore_ipc_client_send(e->client,
|
|
|
|
E_IPC_DOMAIN_REPLY,
|
|
|
|
E_IPC_OP_FONT_DEFAULT_LIST_REPLY,
|
|
|
|
0/*ref*/, 0/*ref_to*/, 0/*response*/,
|
|
|
|
data, bytes);
|
2005-05-30 20:01:53 -07:00
|
|
|
while (dat)
|
|
|
|
{
|
|
|
|
v = dat->data;
|
|
|
|
free(v);
|
|
|
|
dat = evas_list_remove_list(dat, dat);
|
|
|
|
}
|
2005-04-02 08:40:37 -08:00
|
|
|
free(data);
|
|
|
|
}
|
|
|
|
break;
|
2005-05-03 09:27:46 -07:00
|
|
|
case E_IPC_OP_BINDING_MOUSE_LIST:
|
|
|
|
{
|
|
|
|
Evas_List *bindings;
|
|
|
|
int bytes;
|
|
|
|
char *data;
|
|
|
|
|
|
|
|
bindings = e_config->mouse_bindings;
|
2005-05-03 21:50:33 -07:00
|
|
|
data = _e_ipc_mouse_binding_list_enc(bindings, &bytes);
|
2005-05-03 09:27:46 -07:00
|
|
|
ecore_ipc_client_send(e->client,
|
|
|
|
E_IPC_DOMAIN_REPLY,
|
|
|
|
E_IPC_OP_BINDING_MOUSE_LIST_REPLY,
|
|
|
|
0/*ref*/, 0/*ref_to*/, 0/*response*/,
|
|
|
|
data, bytes);
|
|
|
|
free(data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case E_IPC_OP_BINDING_MOUSE_ADD:
|
|
|
|
{
|
2005-05-04 23:45:47 -07:00
|
|
|
E_Config_Binding_Mouse bind, *eb;
|
|
|
|
|
|
|
|
_e_ipc_mouse_binding_dec(e->data, e->size, &bind);
|
|
|
|
{
|
|
|
|
eb = e_config_binding_mouse_match(&bind);
|
|
|
|
if (!eb)
|
|
|
|
{
|
|
|
|
eb = E_NEW(E_Config_Binding_Key, 1);
|
|
|
|
e_config->mouse_bindings = evas_list_append(e_config->mouse_bindings, eb);
|
|
|
|
eb->context = bind.context;
|
|
|
|
eb->button = bind.button;
|
|
|
|
eb->modifiers = bind.modifiers;
|
|
|
|
eb->any_mod = bind.any_mod;
|
|
|
|
eb->action = strdup(bind.action);
|
|
|
|
eb->params = strdup(bind.params);
|
|
|
|
e_border_button_bindings_ungrab_all();
|
|
|
|
e_bindings_mouse_add(bind.context, bind.button, bind.modifiers,
|
|
|
|
bind.any_mod, bind.action, bind.params);
|
|
|
|
e_border_button_bindings_grab_all();
|
|
|
|
e_config_save_queue();
|
|
|
|
}
|
|
|
|
}
|
2005-05-03 09:27:46 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case E_IPC_OP_BINDING_MOUSE_DEL:
|
|
|
|
{
|
2005-05-04 23:45:47 -07:00
|
|
|
E_Config_Binding_Mouse bind, *eb;
|
|
|
|
|
|
|
|
_e_ipc_mouse_binding_dec(e->data, e->size, &bind);
|
|
|
|
{
|
|
|
|
eb = e_config_binding_mouse_match(&bind);
|
|
|
|
if (eb)
|
|
|
|
{
|
|
|
|
e_config->mouse_bindings = evas_list_remove(e_config->mouse_bindings, eb);
|
|
|
|
IF_FREE(eb->action);
|
|
|
|
IF_FREE(eb->params);
|
|
|
|
IF_FREE(eb);
|
|
|
|
e_border_button_bindings_ungrab_all();
|
|
|
|
e_bindings_mouse_del(bind.context, bind.button, bind.modifiers,
|
|
|
|
bind.any_mod, bind.action, bind.params);
|
|
|
|
e_border_button_bindings_grab_all();
|
|
|
|
e_config_save_queue();
|
|
|
|
}
|
|
|
|
}
|
2005-05-03 09:27:46 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case E_IPC_OP_BINDING_KEY_LIST:
|
|
|
|
{
|
|
|
|
Evas_List *bindings;
|
|
|
|
int bytes;
|
|
|
|
char *data;
|
|
|
|
|
|
|
|
bindings = e_config->key_bindings;
|
2005-05-03 21:50:33 -07:00
|
|
|
data = _e_ipc_key_binding_list_enc(bindings, &bytes);
|
2005-05-03 09:27:46 -07:00
|
|
|
ecore_ipc_client_send(e->client,
|
|
|
|
E_IPC_DOMAIN_REPLY,
|
|
|
|
E_IPC_OP_BINDING_KEY_LIST_REPLY,
|
|
|
|
0/*ref*/, 0/*ref_to*/, 0/*response*/,
|
|
|
|
data, bytes);
|
|
|
|
free(data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case E_IPC_OP_BINDING_KEY_ADD:
|
|
|
|
{
|
2005-05-04 23:45:47 -07:00
|
|
|
E_Config_Binding_Key bind, *eb;
|
|
|
|
|
|
|
|
_e_ipc_key_binding_dec(e->data, e->size, &bind);
|
|
|
|
{
|
|
|
|
eb = e_config_binding_key_match(&bind);
|
|
|
|
if (!eb)
|
|
|
|
{
|
|
|
|
eb = E_NEW(E_Config_Binding_Key, 1);
|
|
|
|
e_config->key_bindings = evas_list_append(e_config->key_bindings, eb);
|
|
|
|
eb->context = bind.context;
|
|
|
|
eb->modifiers = bind.modifiers;
|
|
|
|
eb->any_mod = bind.any_mod;
|
|
|
|
eb->key = strdup(bind.key);
|
|
|
|
eb->action = strdup(bind.action);
|
|
|
|
eb->params = strdup(bind.params);
|
|
|
|
e_managers_keys_ungrab();
|
|
|
|
e_bindings_key_add(bind.context, bind.key, bind.modifiers,
|
|
|
|
bind.any_mod, bind.action, bind.params);
|
|
|
|
e_managers_keys_grab();
|
|
|
|
e_config_save_queue();
|
|
|
|
}
|
|
|
|
}
|
2005-05-03 09:27:46 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case E_IPC_OP_BINDING_KEY_DEL:
|
|
|
|
{
|
2005-05-04 23:45:47 -07:00
|
|
|
E_Config_Binding_Key bind, *eb;
|
|
|
|
|
|
|
|
_e_ipc_key_binding_dec(e->data, e->size, &bind);
|
|
|
|
{
|
|
|
|
eb = e_config_binding_key_match(&bind);
|
|
|
|
if (eb)
|
|
|
|
{
|
|
|
|
e_config->key_bindings = evas_list_remove(e_config->key_bindings, eb);
|
|
|
|
IF_FREE(eb->key);
|
|
|
|
IF_FREE(eb->action);
|
|
|
|
IF_FREE(eb->params);
|
|
|
|
IF_FREE(eb);
|
|
|
|
e_managers_keys_ungrab();
|
|
|
|
e_bindings_key_del(bind.context, bind.key, bind.modifiers,
|
|
|
|
bind.any_mod, bind.action, bind.params);
|
|
|
|
e_managers_keys_grab();
|
|
|
|
e_config_save_queue();
|
|
|
|
}
|
|
|
|
}
|
2005-05-03 09:27:46 -07:00
|
|
|
}
|
|
|
|
break;
|
2005-05-30 20:01:53 -07:00
|
|
|
#endif
|
2004-11-26 04:20:38 -08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
printf("E-IPC: client sent: [%i] [%i] (%i) \"%p\"\n", e->major, e->minor, e->size, e->data);
|
2004-11-24 19:37:45 -08:00
|
|
|
/* ecore_ipc_client_send(e->client, 1, 2, 7, 77, 0, "ABC", 4); */
|
|
|
|
/* we can disconnect a client like this: */
|
|
|
|
/* ecore_ipc_client_del(e->client); */
|
|
|
|
/* or we can end a server by: */
|
|
|
|
/* ecore_ipc_server_del(ecore_ipc_client_server_get(e->client)); */
|
|
|
|
return 1;
|
|
|
|
}
|
2005-04-08 23:06:39 -07:00
|
|
|
|
2005-05-30 20:04:02 -07:00
|
|
|
#if 0
|
2005-05-13 08:15:52 -07:00
|
|
|
static void
|
|
|
|
_e_ipc_reply_double_send(Ecore_Ipc_Client *client, double val, int opcode)
|
|
|
|
{
|
|
|
|
void *data;
|
|
|
|
int bytes;
|
|
|
|
|
|
|
|
if ((data = e_ipc_codec_double_enc(val, &bytes)))
|
|
|
|
{
|
|
|
|
ecore_ipc_client_send(client,
|
|
|
|
E_IPC_DOMAIN_REPLY,
|
|
|
|
opcode,
|
|
|
|
0/*ref*/, 0/*ref_to*/, 0/*response*/,
|
|
|
|
data, bytes);
|
|
|
|
free(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_ipc_reply_int_send(Ecore_Ipc_Client *client, int val, int opcode)
|
|
|
|
{
|
|
|
|
void *data;
|
|
|
|
int bytes;
|
|
|
|
|
|
|
|
if ((data = e_ipc_codec_int_enc(val, &bytes)))
|
|
|
|
{
|
|
|
|
ecore_ipc_client_send(client,
|
|
|
|
E_IPC_DOMAIN_REPLY,
|
|
|
|
opcode,
|
|
|
|
0/*ref*/, 0/*ref_to*/, 0/*response*/,
|
|
|
|
data, bytes);
|
|
|
|
free(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_ipc_reply_2int_send(Ecore_Ipc_Client *client, int val1, int val2, int opcode)
|
|
|
|
{
|
|
|
|
void *data;
|
|
|
|
int bytes;
|
|
|
|
|
|
|
|
if ((data = e_ipc_codec_2int_enc(val1, val2, &bytes)))
|
|
|
|
{
|
|
|
|
ecore_ipc_client_send(client,
|
|
|
|
E_IPC_DOMAIN_REPLY,
|
|
|
|
opcode,
|
|
|
|
0/*ref*/, 0/*ref_to*/, 0/*response*/,
|
|
|
|
data, bytes);
|
|
|
|
free(data);
|
|
|
|
}
|
|
|
|
}
|
2005-05-30 20:04:02 -07:00
|
|
|
#endif
|