Enlightenment CVS committal

Author  : lordchaos
Project : e17
Module  : apps/evfs

Dir     : e17/apps/evfs/src/lib


Modified Files:
        evfs_commands.c libevfs.c 


Log Message:
* Stage one of the event engine.  Demo app now receives and displays events 

===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/evfs/src/lib/evfs_commands.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- evfs_commands.c     15 Aug 2005 19:53:57 -0000      1.3
+++ evfs_commands.c     16 Aug 2005 07:31:40 -0000      1.4
@@ -2,16 +2,14 @@
 
 void evfs_monitor_add(evfs_connection* conn, evfs_filereference* ref) {
        evfs_command* command = NEW(evfs_command);
-       printf("Command is %p\n", command);
        
-       printf("Adding a monitor on: '%s' using '%s'\n", ref->path, 
ref->plugin_uri);
+       /*printf("Adding a monitor on: '%s' using '%s'\n", ref->path, 
ref->plugin_uri);*/
 
        command->type = EVFS_CMD_STARTMON_FILE;
        command->file_command.num_files = 1;
        command->file_command.files = malloc(sizeof(evfs_filereference*));
        command->file_command.files[0] = ref;
 
-       printf("Type is %d\n", command->type);
 
        evfs_write_command(conn, command);
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/evfs/src/lib/libevfs.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- libevfs.c   16 Aug 2005 05:44:22 -0000      1.4
+++ libevfs.c   16 Aug 2005 07:31:40 -0000      1.5
@@ -18,8 +18,6 @@
 }
 
 int evfs_server_data (void* data, int type, void* event) {
-       printf("Got message from server %d..\n", 
((Ecore_Ipc_Event_Server_Data*)event)->major);
-
    Ecore_Ipc_Event_Server_Data *e;
    if ((e = (Ecore_Ipc_Event_Server_Data *) event)) {
           /*Special case, if it's an id notify, we can't really id the client 
without it*/
@@ -36,7 +34,6 @@
                           /*We have a client, let's see if it needs an id*/
                           if (client->id == MAX_CLIENT) {
                                   memcpy(&client->id, e->data, sizeof(unsigned 
long));
-                                  printf("This client is assigned id %ld\n", 
client->id);
                           } else {
                                   printf(stderr, "Error, client already has an 
assigned id.  Dropped packet?\n");
                                   return 1;
@@ -52,21 +49,47 @@
                    */
 
                   evfs_connection* conn = evfs_get_connection_for_id(e->ref);
+
+                  if (conn) {
+                          ecore_ipc_message *msg = 
ecore_ipc_message_new(e->major, e->minor, e->ref, e->ref_to, e->response, 
e->data, e->size);
+                          
+                          if (conn->prog_event == NULL) {
+                                  /*We haven't started an event yet - make a 
new one*/
+                                  conn->prog_event = NEW(evfs_event);
+                          }
+
+                          if (evfs_read_event(conn->prog_event, msg)) {
+                                  /*True return == Event fully read*/
+
+                                  /*Execute callback if registered..*/
+                                  if (conn->callback_func) {
+                                          evfs_event* ev = conn->prog_event;
+                                          conn->prog_event = NULL; /*Detach 
this event from the conn.  Client is responsible for it now*/
+                                                                     
+                                          (*conn->callback_func)(ev);
+                                  } else {
+                                          printf("EVFS: Alert - no callback 
registered for event\n");
+                                  }
+                                  
+                          }
+                  } else {
+                          printf(stderr, "EVFS: Could not find connection for 
clientId\n");
+                  }
           }
    }
 }
 
-evfs_connection* evfs_connect() {
+evfs_connection* evfs_connect(void (*callback_func)(void*)) {
        ecore_init();
        ecore_ipc_init();
        
        evfs_connection* connection = NEW(evfs_connection);
        connection->id = MAX_CLIENT;
        connection->prog_event = NULL;
+       connection->callback_func = callback_func;
 
         if (!libevfs_registered_callback) {
                libevfs_registered_callback = 1;
-               fprintf(stderr, "Registering callback at client..\n");
               ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DATA, 
evfs_server_data, NULL); 
               client_list = ecore_list_new();
 




-------------------------------------------------------
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
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to