Enlightenment CVS committal
Author : lordchaos
Project : e17
Module : apps/efsd
Dir : e17/apps/efsd/efsd
Modified Files:
Makefile.am efsd.h efsd_io.c efsd_io.h efsd_main.c libefsd.c
Log Message:
More unification of the serialization/deserialization architecture using
ecore_ipc
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/Makefile.am,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -3 -r1.31 -r1.32
--- Makefile.am 4 Aug 2005 05:30:22 -0000 1.31
+++ Makefile.am 8 Aug 2005 03:37:26 -0000 1.32
@@ -7,7 +7,7 @@
DEBUGFLAGS = -DDEBUG -DDEBUG_NEST -W -Wall
-INCLUDES = @edb_cflags@ @xml2_cflags@ $(DEBUGFLAGS) @ecore_cflags@
+INCLUDES = @ecore_cflags@ @edb_cflags@ @xml2_cflags@ $(DEBUGFLAGS)
if USE_THREADS_FILES
efsd_threadstuff = efsd_lock.c
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -3 -r1.24 -r1.25
--- efsd.h 6 Aug 2005 08:43:21 -0000 1.24
+++ efsd.h 8 Aug 2005 03:37:26 -0000 1.25
@@ -262,5 +262,20 @@
}
EfsdEvent;
+#if HAVE_ECORE
+typedef struct ecore_ipc_message ecore_ipc_message;
+struct ecore_ipc_message {
+ int major;
+ int minor;
+ int ref;
+ int ref_to;
+ int response;
+ void* data;
+ int len;
+};
+
+ecore_ipc_message* ecore_ipc_message_new(int major, int minor, int ref, int
ref_to, int response, void* data, int len);
+#endif
+
#endif
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd_io.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -3 -r1.45 -r1.46
--- efsd_io.c 7 Aug 2005 23:51:40 -0000 1.45
+++ efsd_io.c 8 Aug 2005 03:37:26 -0000 1.46
@@ -72,17 +72,6 @@
EfsdIOV;
#if HAVE_ECORE
-typedef struct ecore_ipc_message ecore_ipc_message;
-struct ecore_ipc_message {
- int major;
- int minor;
- int ref;
- int ref_to;
- int response;
- void* data;
- int len;
-};
-
ecore_ipc_message* ecore_ipc_message_new(int major, int minor, int ref, int
ref_to, int response, void* data, int len) {
ecore_ipc_message* msg= malloc(sizeof(ecore_ipc_message));
@@ -96,6 +85,49 @@
return msg;
}
+
+void deserialize_command(ecore_ipc_message* msg, EfsdCommand* ec) {
+ printf (" ERR: We have a command on our hands..\n");
+
+ if (msg->minor == 1) {
+ /*An efsdCommandType*/
+ printf(" ERR: Receiving command type, building a
new EfsdCommand struct!\n");
+ memcpy(&ec->type, msg->data,
sizeof(EfsdCommandType));
+ printf (" ERR: Command type is %d\n", ec->type);
+ } else if (msg->minor == 2) {
+ /*An efsdCommandId*/
+ printf(" ERR: Receiving a command id\n");
+ /*Retrieve the inprogress event*/
+ printf (" ERR: Our in-progress command has type
%d\n", ec->type);
+ memcpy(&ec->efsd_file_cmd.id, msg->data,
sizeof(EfsdCmdId));
+ printf (" ERR: Received command id %d\n",
ec->efsd_file_cmd.id);
+ } else if (msg->minor == 3) {
+ /*A file*/
+ printf ( " ERR: Receiving a filename\n");
+ printf ("We have %d files so far..\n",
ec->efsd_file_cmd.num_files);
+ if (!ec->efsd_file_cmd.num_files) {
+ ec->efsd_file_cmd.files =
malloc(sizeof(char*));
+ } else {
+ ec->efsd_file_cmd.files =
realloc(ec->efsd_file_cmd.files, sizeof(char*) *
(ec->efsd_file_cmd.num_files)+1);
+ }
+
ec->efsd_file_cmd.files[ec->efsd_file_cmd.num_files] = strdup(msg->data);
+ printf ("Received a filename\n, it is '%s'\n",
ec->efsd_file_cmd.files[ec->efsd_file_cmd.num_files]);
+ ec->efsd_file_cmd.num_files+=1;
+ } else if (msg->minor == 4) {
+ /*An efsdOption*/
+ /*Basically two ints*/
+ printf ( " ERR: Receiving an option\n");
+ if (!ec->efsd_file_cmd.num_options) {
+ ec->efsd_file_cmd.options =
malloc(sizeof(EfsdOption));
+ } else {
+ ec->efsd_file_cmd.options =
realloc(ec->efsd_file_cmd.options, sizeof(EfsdOption) *
ec->efsd_file_cmd.num_options+1);
+ }
+
memcpy(&ec->efsd_file_cmd.options[ec->efsd_file_cmd.num_options], msg->data,
sizeof(EfsdOption));
+ ec->efsd_file_cmd.num_options++;
+ }
+
+}
+
#endif
@@ -810,6 +842,7 @@
{
#if HAVE_ECORE
Ecore_List* el;
+ Ecore_List* cmd;
ecore_ipc_message* msg;
#endif
@@ -818,8 +851,15 @@
#if HAVE_ECORE
el = ecore_list_new();
- ecore_list_append(el, ecore_ipc_message_new(EFSD_EVENT_REPLY, 1,
0,0,0,&ee->type, sizeof(EfsdEventType)));
- ecore_list_append(el, ecore_ipc_message_new(EFSD_EVENT_REPLY, 2,
0,0,0,ee->efsd_reply_event.data, strlen(ee->efsd_reply_event.data)));
+ cmd = fill_command(&ee->efsd_reply_event.command);
+
+ ecore_list_goto_first(cmd);
+ while ( (msg = ecore_list_next(cmd) )) {
+ ecore_list_append(el, msg);
+ }
+
+ ecore_list_append(el, ecore_ipc_message_new(2, 1, 0,0,0,&ee->type,
sizeof(EfsdEventType)));
+ ecore_list_append(el, ecore_ipc_message_new(2, 2,
0,0,0,ee->efsd_reply_event.data, strlen(ee->efsd_reply_event.data)));
return el;
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd_io.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- efsd_io.h 6 Aug 2005 13:51:54 -0000 1.6
+++ efsd_io.h 8 Aug 2005 03:37:26 -0000 1.7
@@ -38,6 +38,8 @@
#if HAVE_ECORE
int
efsd_io_write_event(Ecore_Ipc_Client* sockfd, EfsdEvent *ee);
+
+void deserialize_command(ecore_ipc_message* msg, EfsdCommand* ec);
#else
int
efsd_io_write_event(int sockfd, EfsdEvent *ee);
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/efsd_main.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -3 -r1.58 -r1.59
--- efsd_main.c 6 Aug 2005 13:51:54 -0000 1.58
+++ efsd_main.c 8 Aug 2005 03:37:26 -0000 1.59
@@ -179,95 +179,38 @@
printf ("ERR: Got message!\n");
if ((e = (Ecore_Ipc_Event_Client_Data *) event))
{
- if (e->major == 1) {
- printf (" ERR: We have a command on our hands..\n");
+ ecore_ipc_message* msg= malloc(sizeof(ecore_ipc_message));
+ msg->major =e->major;
+ msg->minor = e->minor;
+ msg->ref = e->ref;
+ msg->ref_to = e->ref_to;
+ msg->response =e->response;
+ msg->data = e->data;
+ msg->len = e->size;
+
+ if (msg->major == 1) {
+
+
+ ec = ecore_hash_get(partial_command_hash, e->client);
+ if (!ec) {
+ ec = NEW(EfsdCommand);
+ ec->efsd_file_cmd.num_files = 0;
+ ec->efsd_file_cmd.num_options = 0;
+ ecore_hash_set(partial_command_hash, e->client, ec);
+ }
- if (e->minor == 1) {
- /*An efsdCommandType*/
-
- printf(" ERR: Receiving command type, building a
new EfsdCommand struct!\n");
- ec = NEW(EfsdCommand);
-
- memcpy(&ec->type, e->data, sizeof(EfsdCommandType));
-
- printf (" ERR: Command type is %d\n", ec->type);
-
- ecore_hash_set(partial_command_hash, e->client, ec);
-
- } else if (e->minor == 2) {
- /*An efsdCommandId*/
-
- printf(" ERR: Receiving a command id\n");
-
- /*Retrieve the inprogress event*/
- ec = ecore_hash_get(partial_command_hash, e->client);
-
- printf (" ERR: Our in-progress command has type
%d\n", ec->type);
-
- memcpy(&ec->efsd_file_cmd.id, e->data,
sizeof(EfsdCmdId));
-
- printf (" ERR: Received command id %d\n",
ec->efsd_file_cmd.id);
-
- } else if (e->minor == 3) {
- /*A file*/
-
- printf ( " ERR: Receiving a filename\n");
-
- ec = ecore_hash_get(partial_command_hash, e->client);
-
- printf ("We have %d files so far..\n",
ec->efsd_file_cmd.num_files);
-
-
- if (!ec->efsd_file_cmd.num_files) {
- ec->efsd_file_cmd.files =
malloc(sizeof(char*));
- } else {
- ec->efsd_file_cmd.files =
realloc(ec->efsd_file_cmd.files, sizeof(char*) *
(ec->efsd_file_cmd.num_files)+1);
- }
- ec->efsd_file_cmd.files[ec->efsd_file_cmd.num_files]
= strdup(e->data);
-
- printf ("Received a filename\n, it is '%s'\n",
ec->efsd_file_cmd.files[ec->efsd_file_cmd.num_files]);
-
- ec->efsd_file_cmd.num_files+=1;
-
- } else if (e->minor == 4) {
- /*An efsdOption*/
- /*Basically two ints*/
-
- printf ( " ERR: Receiving an option\n");
-
- ec = ecore_hash_get(partial_command_hash, e->client);
-
- if (!ec->efsd_file_cmd.num_options) {
- ec->efsd_file_cmd.options =
malloc(sizeof(EfsdOption));
- } else {
- ec->efsd_file_cmd.options =
realloc(ec->efsd_file_cmd.options, sizeof(EfsdOption) *
ec->efsd_file_cmd.num_options+1);
- }
-
-
-
memcpy(&ec->efsd_file_cmd.options[ec->efsd_file_cmd.num_options], e->data,
sizeof(EfsdOption));
-
- ec->efsd_file_cmd.num_options++;
- } else if (e->minor == 100) {
- /*ecore_ipc_client_send(e->client, 1, 1, 0,0,0, NULL,0);
- cl = e->client;*/
-
- /*Command finished.. process..*/
-
- printf("Command finished..processing..\n");
-
-
- ec = ecore_hash_get(partial_command_hash, e->client);
-
- printf ("Filename is '%s'\n",
ec->efsd_file_cmd.files[0]);
- /*ecore_hash_remove(partial_command_hash,
e->client);*/
-
- main_thread_launch(ec, e->client);
- }
-
+ if (e->minor != 100) {
+ deserialize_command(msg,ec);
+ } else {
+ printf("Command finished..processing..\n");
+ ec = ecore_hash_get(partial_command_hash, e->client);
+ main_thread_launch(ec, e->client);
+ }
+ }
+ free(msg);
- }
}
return 1;
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/efsd/efsd/libefsd.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -3 -r1.59 -r1.60
--- libefsd.c 6 Aug 2005 13:51:54 -0000 1.59
+++ libefsd.c 8 Aug 2005 03:37:26 -0000 1.60
@@ -102,6 +102,8 @@
static void libefsd_callbacks_init(void);
+static Ecore_Hash* partial_command_hash = NULL;
+
/*Ecore Event callbacks*/
#if HAVE_ECORE
@@ -116,12 +118,46 @@
{
switch (e->major) {
- case EFSD_EVENT_REPLY:
+ case 1: printf("It's a command..\n");
+ {
+ EfsdCommand* ec;
+ ecore_ipc_message* msg=
malloc(sizeof(ecore_ipc_message));
+ msg->major =e->major;
+ msg->minor = e->minor;
+ msg->ref = e->ref;
+ msg->ref_to = e->ref_to;
+ msg->response =e->response;
+ msg->data = e->data;
+ msg->len = e->size;
+
+ ec = ecore_hash_get(partial_command_hash, e->server);
+ if (!ec) {
+ ec = NEW(EfsdCommand);
+ ec->efsd_file_cmd.num_files = 0;
+ ec->efsd_file_cmd.num_options = 0;
+ ecore_hash_set(partial_command_hash, e->server,
ec);
+ }
+
+ if (e->minor != 100) {
+ deserialize_command(msg,ec);
+ } else {
+ printf("Command finished..processing..\n");
+ ec = ecore_hash_get(partial_command_hash,
e->server);
+ /*main_thread_launch(ec, e->client);*/
+ }
+
+ free(msg);
+ }
+
+
+ break;
+
+ case 2:
printf ("it's a reply!\n");
switch(e->minor) {
- case 1:
+ case 2:
printf ("It's a data section..\n");
printf ("Data is: %s\n", e->data);
}
@@ -469,6 +505,11 @@
/*Register the event callbacks*/
ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DATA, ipc_server_data, NULL);
+
+ /*Init command hash*/
+ if (!partial_command_hash) {
+ partial_command_hash = ecore_hash_new(ecore_direct_hash,
ecore_direct_compare);
+ }
#else
if ( (ec->fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs