summaryrefslogtreecommitdiff
path: root/src/bin/e_ipc.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2004-11-25 03:37:45 +0000
committerCarsten Haitzler <raster@rasterman.com>2004-11-25 03:37:45 +0000
commit5e2388c886b15923f2b1350191524f40b0e9050a (patch)
treeeeb93c0db03cb87075ed74cc31367f669e5f2e72 /src/bin/e_ipc.c
parentf2b45ed47126d12986591cb02a6fcfc5908255fe (diff)
_ _ _ _ _____ ___
| | | | ___| | | | ___| __ ___ ___ _______ ___ / _ \__ _____ _ __ | |_| |/ _ \ | | | |_ | '__/ _ \/ _ \_ / _ \/ __| | | | \ \ / / _ \ '__| | _ | __/ | | | _|| | | __/ __// / __/\__ \ | |_| |\ V / __/ | |_| |_|\___|_|_| |_| |_| \___|\___/___\___||___/ \___/ \_/ \___|_| I put E17's wm code into cvs. Hell is freezing over. Duke Nukem Forever will be out next week. Snowballls take up residence in Hell. The Fat Lady sings. The End is nigh... :) SVN revision: 12247
Diffstat (limited to 'src/bin/e_ipc.c')
-rw-r--r--src/bin/e_ipc.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/bin/e_ipc.c b/src/bin/e_ipc.c
new file mode 100644
index 0000000..df1c3a2
--- /dev/null
+++ b/src/bin/e_ipc.c
@@ -0,0 +1,78 @@
1#include "e.h"
2
3/* local subsystem functions */
4static int _e_ipc_cb_client_add(void *data, int type, void *event);
5static int _e_ipc_cb_client_del(void *data, int type, void *event);
6static int _e_ipc_cb_client_data(void *data, int type, void *event);
7
8/* local subsystem globals */
9static Ecore_Ipc_Server *_e_ipc_server = NULL;
10
11/* externally accessible functions */
12int
13e_ipc_init(void)
14{
15 char buf[1024];
16 char *disp;
17
18 disp = getenv("DISPLAY");
19 if (!disp) disp = ":0";
20 snprintf(buf, sizeof(buf), "enlightenment-(%s)", disp);
21 _e_ipc_server = ecore_ipc_server_add(ECORE_IPC_LOCAL_USER, buf, 0, NULL);
22 if (!_e_ipc_server) return 0;
23 ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD, _e_ipc_cb_client_add, NULL);
24 ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DEL, _e_ipc_cb_client_del, NULL);
25 ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DATA, _e_ipc_cb_client_data, NULL);
26 return 1;
27}
28
29void
30e_ipc_shutdown(void)
31{
32 if (_e_ipc_server)
33 {
34 ecore_ipc_server_del(_e_ipc_server);
35 _e_ipc_server = NULL;
36 }
37}
38
39/* local subsystem globals */
40static int
41_e_ipc_cb_client_add(void *data, int type, void *event)
42{
43 Ecore_Ipc_Event_Client_Add *e;
44
45 e = event;
46 if (ecore_ipc_client_server_get(e->client) != _e_ipc_server) return 1;
47 printf("E-IPC: client %p connected to server!\n", e->client);
48 return 1;
49}
50
51static int
52_e_ipc_cb_client_del(void *data, int type, void *event)
53{
54 Ecore_Ipc_Event_Client_Del *e;
55
56 e = event;
57 if (ecore_ipc_client_server_get(e->client) != _e_ipc_server) return 1;
58 printf("E-IPC: client %p disconnected from server!\n", e->client);
59 /* delete client sruct */
60 ecore_ipc_client_del(e->client);
61 return 1;
62}
63
64static int
65_e_ipc_cb_client_data(void *data, int type, void *event)
66{
67 Ecore_Ipc_Event_Client_Data *e;
68
69 e = event;
70 if (ecore_ipc_client_server_get(e->client) != _e_ipc_server) return 1;
71 printf("E-IPC: client sent: [%i] [%i] (%i) \"%s\"\n", e->major, e->minor, e->size, e->data);
72 /* ecore_ipc_client_send(e->client, 1, 2, 7, 77, 0, "ABC", 4); */
73 /* we can disconnect a client like this: */
74 /* ecore_ipc_client_del(e->client); */
75 /* or we can end a server by: */
76 /* ecore_ipc_server_del(ecore_ipc_client_server_get(e->client)); */
77 return 1;
78}