Enlightenment CVS committal

Author  : lordchaos
Project : e17
Module  : apps/evfs

Dir     : e17/apps/evfs/src/bin


Modified Files:
        evfs_cleanup.c evfs_main.c evfs_operation.c 
        evfs_server_handle.c evfscat.c 


Log Message:
* Indenting
* More work on evfs_operation

===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/evfs/src/bin/evfs_cleanup.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- evfs_cleanup.c      15 Aug 2005 08:52:31 -0000      1.1
+++ evfs_cleanup.c      31 Jan 2006 06:33:57 -0000      1.2
@@ -1,5 +1,7 @@
 #include <evfs.h>
 
-void evfs_cleanup_client(evfs_client* client) {
+void
+evfs_cleanup_client (evfs_client * client)
+{
 
 }
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/evfs/src/bin/evfs_main.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -3 -r1.33 -r1.34
--- evfs_main.c 26 Jan 2006 03:33:47 -0000      1.33
+++ evfs_main.c 31 Jan 2006 06:33:57 -0000      1.34
@@ -46,295 +46,328 @@
 #include <errno.h>
 #include <dirent.h>
 
-static evfs_server* server;
+static evfs_server *server;
 
-evfs_client* evfs_client_get(Ecore_Ipc_Client* client) {
-       return ecore_hash_get(server->client_hash, client);
+evfs_client *
+evfs_client_get (Ecore_Ipc_Client * client)
+{
+  return ecore_hash_get (server->client_hash, client);
 }
 
-unsigned long evfs_server_get_next_id(evfs_server* serve) {
-       serve->clientCounter++;
-       printf("Allocated %ld\n", serve->clientCounter-1);
-       return serve->clientCounter-1;
+unsigned long
+evfs_server_get_next_id (evfs_server * serve)
+{
+  serve->clientCounter++;
+  printf ("Allocated %ld\n", serve->clientCounter - 1);
+  return serve->clientCounter - 1;
 }
 
 int
-ipc_client_add(void *data __UNUSED__, int type __UNUSED__, void *event)
+ipc_client_add (void *data __UNUSED__, int type __UNUSED__, void *event)
 {
-      Ecore_Ipc_Event_Client_Add *e;
-      evfs_client* client;
+  Ecore_Ipc_Event_Client_Add *e;
+  evfs_client *client;
 
 
-      e = (Ecore_Ipc_Event_Client_Add *) event;
-      /*printf("ERR: EVFS Client Connected!!!\n");*/
+  e = (Ecore_Ipc_Event_Client_Add *) event;
+  /*printf("ERR: EVFS Client Connected!!!\n"); */
 
-      client = NEW(evfs_client);
-      client->client = e->client;
-      client->server = server;
-      client->prog_command = NULL;
-      client->id = evfs_server_get_next_id(server);
-      ecore_hash_set(server->client_hash, client->client, client);
+  client = NEW (evfs_client);
+  client->client = e->client;
+  client->server = server;
+  client->prog_command = NULL;
+  client->id = evfs_server_get_next_id (server);
+  ecore_hash_set (server->client_hash, client->client, client);
 
-      server->num_clients++;
+  server->num_clients++;
 
-      evfs_event_client_id_notify(client);
+  evfs_event_client_id_notify (client);
 
-      
-      return (1);
+
+  return (1);
 }
 
 int
-ipc_client_del(void *data __UNUSED__, int type __UNUSED__, void *event)
+ipc_client_del (void *data __UNUSED__, int type __UNUSED__, void *event)
 {
-   Ecore_Ipc_Event_Client_Del *e;
-   Ecore_List* keys;
-   evfs_client* client;
-   evfs_plugin* plugin;
-   char* key;
-
-
-   e = (Ecore_Ipc_Event_Client_Del *) event;
-
-    client = ecore_hash_get(server->client_hash, e->client);
-    printf("Client %ld, Client Disconnected!!!\n", client->id);
-
-    /*Notify the plugins that this client has disconnected*/
-    keys = ecore_hash_keys(server->plugin_uri_hash);
-    ecore_list_goto_first(keys);
-    while ( (key = ecore_list_remove_first(keys)) ){
-           plugin = ecore_hash_get(server->plugin_uri_hash, key);
-           (*plugin->functions->evfs_client_disconnect)(client);
-    }
-    
+  Ecore_Ipc_Event_Client_Del *e;
+  Ecore_List *keys;
+  evfs_client *client;
+  evfs_plugin *plugin;
+  char *key;
+
+
+  e = (Ecore_Ipc_Event_Client_Del *) event;
+
+  client = ecore_hash_get (server->client_hash, e->client);
+  printf ("Client %ld, Client Disconnected!!!\n", client->id);
 
-    ecore_list_destroy(keys);
-    
-    ecore_hash_remove(server->client_hash, client);
-    evfs_cleanup_client(client);
+  /*Notify the plugins that this client has disconnected */
+  keys = ecore_hash_keys (server->plugin_uri_hash);
+  ecore_list_goto_first (keys);
+  while ((key = ecore_list_remove_first (keys))) {
+    plugin = ecore_hash_get (server->plugin_uri_hash, key);
+    (*plugin->functions->evfs_client_disconnect) (client);
+  }
 
-    
-   return (1);
+
+  ecore_list_destroy (keys);
+
+  ecore_hash_remove (server->client_hash, client);
+  evfs_cleanup_client (client);
+
+
+  return (1);
 }
 
 
 int
-ipc_client_data(void *data __UNUSED__, int type __UNUSED__, void *event)
+ipc_client_data (void *data __UNUSED__, int type __UNUSED__, void *event)
 {
-       
-   Ecore_Ipc_Event_Client_Data *e = (Ecore_Ipc_Event_Client_Data*) event;
-   evfs_client* client;
-   
-   ecore_ipc_message* msg = 
ecore_ipc_message_new(e->major,e->minor,e->ref,e->ref_to,e->response,e->data,e->size);
-
-
-   client = evfs_client_get(e->client);
-
-   
-   if (!client->prog_command) {
-          client->prog_command = evfs_command_new();
-   }
-
-   /*True == command finished*/
-   if (evfs_process_incoming_command(server, client->prog_command, msg)) {
-         evfs_command_client* com_cli = NEW(evfs_command_client);
-         com_cli->client = client;
-         com_cli->command = client->prog_command;
-         client->prog_command = NULL;
-         ecore_list_append(server->incoming_command_list, com_cli);
-   }
-
-   free(msg);
-
-
-
-   return 1;
-}
-
-
-void evfs_handle_command(evfs_client* client, evfs_command* command) {
-       switch (command->type) {
-               case EVFS_CMD_STARTMON_FILE:
-                       /*printf("We received a monitor stop request*/
-                       evfs_handle_monitor_start_command(client, command);
-                       
-                       break;
-               case EVFS_CMD_STOPMON_FILE:
-                       /*printf("We received a monitor stop request\n");*/
-                       evfs_handle_monitor_stop_command(client,command);
-                       break;
-
-               case EVFS_CMD_RENAME_FILE:
-                       evfs_handle_file_rename_command(client,command);
-                       break;
-
-               case EVFS_CMD_MOVE_FILE:
-                       printf("Move file stub\n");
-                       break;
-               case EVFS_CMD_REMOVE_FILE: 
-                       evfs_handle_file_remove_command(client,command);
-                       break;
-               case EVFS_CMD_FILE_STAT:
-                       evfs_handle_file_stat_command(client,command);
-                       break;
-               case EVFS_CMD_LIST_DIR:
-                       evfs_handle_dir_list_command(client,command);
-                       break;
-               case EVFS_CMD_FILE_OPEN:
-                       evfs_handle_file_open_command(client,command);
-                       break;
-               case EVFS_CMD_FILE_READ:
-                       evfs_handle_file_read_command(client,command);
-                       break;
-               case EVFS_CMD_FILE_COPY:
-                       printf("File copy handler\n");
-                       evfs_handle_file_copy(client,command,command);
-                       break;
-               case EVFS_CMD_PING:
-                       evfs_handle_ping_command(client,command);
-                       break;
-               default: printf("Warning - unhandled command %d\n", 
command->type);
-                        break;
-       }
+
+  Ecore_Ipc_Event_Client_Data *e = (Ecore_Ipc_Event_Client_Data *) event;
+  evfs_client *client;
+
+  ecore_ipc_message *msg =
+    ecore_ipc_message_new (e->major, e->minor, e->ref, e->ref_to, e->response,
+                          e->data, e->size);
+
+
+  client = evfs_client_get (e->client);
+
+
+  if (!client->prog_command) {
+    client->prog_command = evfs_command_new ();
+  }
+
+  /*True == command finished */
+  if (evfs_process_incoming_command (server, client->prog_command, msg)) {
+    evfs_command_client *com_cli = NEW (evfs_command_client);
+    com_cli->client = client;
+    com_cli->command = client->prog_command;
+    client->prog_command = NULL;
+    ecore_list_append (server->incoming_command_list, com_cli);
+  }
+
+  free (msg);
+
+
+
+  return 1;
+}
+
+
+void
+evfs_handle_command (evfs_client * client, evfs_command * command)
+{
+  switch (command->type) {
+  case EVFS_CMD_STARTMON_FILE:
+    /*printf("We received a monitor stop request */
+    evfs_handle_monitor_start_command (client, command);
+
+    break;
+  case EVFS_CMD_STOPMON_FILE:
+    /*printf("We received a monitor stop request\n"); */
+    evfs_handle_monitor_stop_command (client, command);
+    break;
+
+  case EVFS_CMD_RENAME_FILE:
+    evfs_handle_file_rename_command (client, command);
+    break;
+
+  case EVFS_CMD_MOVE_FILE:
+    printf ("Move file stub\n");
+    break;
+  case EVFS_CMD_REMOVE_FILE:
+    evfs_handle_file_remove_command (client, command);
+    break;
+  case EVFS_CMD_FILE_STAT:
+    evfs_handle_file_stat_command (client, command);
+    break;
+  case EVFS_CMD_LIST_DIR:
+    evfs_handle_dir_list_command (client, command);
+    break;
+  case EVFS_CMD_FILE_OPEN:
+    evfs_handle_file_open_command (client, command);
+    break;
+  case EVFS_CMD_FILE_READ:
+    evfs_handle_file_read_command (client, command);
+    break;
+  case EVFS_CMD_FILE_COPY:
+    printf ("File copy handler\n");
+    evfs_handle_file_copy (client, command, command);
+    break;
+  case EVFS_CMD_PING:
+    evfs_handle_ping_command (client, command);
+    break;
+  default:
+    printf ("Warning - unhandled command %d\n", command->type);
+    break;
+  }
 }
 
 
 
-evfs_plugin* evfs_load_plugin(char* filename) {
-       evfs_plugin* plugin = NEW(evfs_plugin);
+evfs_plugin *
+evfs_load_plugin (char *filename)
+{
+  evfs_plugin *plugin = NEW (evfs_plugin);
 
-       char* (*evfs_plugin_uri_get)();
-       evfs_plugin_functions* (*evfs_plugin_init)();
+  char *(*evfs_plugin_uri_get) ();
+  evfs_plugin_functions *(*evfs_plugin_init) ();
 
-       printf("Loading plugin: %s\n", filename);       
-       plugin->dl_ref = dlopen(filename, RTLD_LAZY);
+  printf ("Loading plugin: %s\n", filename);
+  plugin->dl_ref = dlopen (filename, RTLD_LAZY);
 
-       if (plugin->dl_ref) {
-               evfs_plugin_uri_get = dlsym(plugin->dl_ref, 
"evfs_plugin_uri_get");
-               if (evfs_plugin_uri_get) {
-                       plugin->uri = (*evfs_plugin_uri_get)();                 
-                       printf("The plugin at '%s' handles '%s'\n", filename, 
plugin->uri);
-
-                       /*Execute the init function, if it's there..*/
-                       evfs_plugin_init = dlsym(plugin->dl_ref, 
"evfs_plugin_init");   
-                       if (evfs_plugin_init) {
-                               plugin->functions = (*evfs_plugin_init)();
-                       }
-               } else {
-                       printf("Error - plugin file does not contain uri 
identify function - %s\n", filename);
-                       goto exit_error;
-               }
-                       
-       } else {
-               printf("Error - plugin file invalid - %s\n", filename);
-               goto exit_error;
-       }
+  if (plugin->dl_ref) {
+    evfs_plugin_uri_get = dlsym (plugin->dl_ref, "evfs_plugin_uri_get");
+    if (evfs_plugin_uri_get) {
+      plugin->uri = (*evfs_plugin_uri_get) ();
+      printf ("The plugin at '%s' handles '%s'\n", filename, plugin->uri);
+
+      /*Execute the init function, if it's there.. */
+      evfs_plugin_init = dlsym (plugin->dl_ref, "evfs_plugin_init");
+      if (evfs_plugin_init) {
+       plugin->functions = (*evfs_plugin_init) ();
+      }
+    }
+    else {
+      printf
+       ("Error - plugin file does not contain uri identify function - %s\n",
+        filename);
+      goto exit_error;
+    }
+
+  }
+  else {
+    printf ("Error - plugin file invalid - %s\n", filename);
+    goto exit_error;
+  }
 
 
-       
 
-       return plugin;
+
+  return plugin;
+
+
+exit_error:
+  free (plugin);
+  return NULL;
 
 
-       exit_error:
-               free(plugin);
-               return NULL;
-       
-       
 }
 
 
-void evfs_load_plugins() {
-        struct dirent* de;
-        DIR* dir;
-       evfs_plugin* plugin;
-       char plugin_path[1024];
-
-       printf("Reading plugins from: %s\n", PACKAGE_PLUGIN_DIR 
"/plugins/file");
-        dir = opendir(PACKAGE_PLUGIN_DIR "/plugins/file");
-        if (dir) {
-               while ( (de = readdir(dir)) ) {
-
-                  if (!strncmp(de->d_name + strlen(de->d_name) -3, ".so", 3)) {
-                       snprintf(plugin_path, 1024,"%s/%s", PACKAGE_PLUGIN_DIR 
"/plugins/file", de->d_name);
-                       if ( (plugin = evfs_load_plugin(plugin_path))) {
-                               ecore_hash_set(server->plugin_uri_hash, 
plugin->uri, plugin);
-                       }
-                  }
-               }
-       } else {
-               fprintf(stderr, "EVFS: Could not location plugin directory 
'%s'\n", PACKAGE_PLUGIN_DIR "/plugins/file");
-               exit(1);
+void
+evfs_load_plugins ()
+{
+  struct dirent *de;
+  DIR *dir;
+  evfs_plugin *plugin;
+  char plugin_path[1024];
+
+  printf ("Reading plugins from: %s\n", PACKAGE_PLUGIN_DIR "/plugins/file");
+  dir = opendir (PACKAGE_PLUGIN_DIR "/plugins/file");
+  if (dir) {
+    while ((de = readdir (dir))) {
+
+      if (!strncmp (de->d_name + strlen (de->d_name) - 3, ".so", 3)) {
+       snprintf (plugin_path, 1024, "%s/%s",
+                 PACKAGE_PLUGIN_DIR "/plugins/file", de->d_name);
+       if ((plugin = evfs_load_plugin (plugin_path))) {
+         ecore_hash_set (server->plugin_uri_hash, plugin->uri, plugin);
        }
+      }
+    }
+  }
+  else {
+    fprintf (stderr, "EVFS: Could not location plugin directory '%s'\n",
+            PACKAGE_PLUGIN_DIR "/plugins/file");
+    exit (1);
+  }
 
 }
 
-int ecore_timer_enterer(__UNUSED__ void* data) {
-       return 1;
+int
+ecore_timer_enterer (__UNUSED__ void *data)
+{
+  return 1;
 }
 
 
-int incoming_command_cb(__UNUSED__ void* data) {
-       evfs_command_client* com_cli = 
ecore_list_remove_first(server->incoming_command_list);
-       
-       if (com_cli) {
-               evfs_handle_command(com_cli->client, com_cli->command);
-               evfs_cleanup_command(com_cli->command, 
EVFS_CLEANUP_FREE_COMMAND); 
-               free(com_cli);
+int
+incoming_command_cb (__UNUSED__ void *data)
+{
+  evfs_command_client *com_cli =
+    ecore_list_remove_first (server->incoming_command_list);
+
+  if (com_cli) {
+    evfs_handle_command (com_cli->client, com_cli->command);
+    evfs_cleanup_command (com_cli->command, EVFS_CLEANUP_FREE_COMMAND);
+    free (com_cli);
+
+  }
 
-       }
-       
-       return 1;
+  return 1;
 }
 
 
 
-int main(int argc, char** argv) {
-       /*Init the ipc server*/
-       if (ecore_ipc_init() < 1)
-               return (1);
+int
+main (int argc, char **argv)
+{
+  /*Init the ipc server */
+  if (ecore_ipc_init () < 1)
+    return (1);
 
-       ecore_file_init();
+  ecore_file_init ();
 
-       
-       server = NEW(evfs_server);
-       server->client_hash = ecore_hash_new(ecore_direct_hash, 
ecore_direct_compare);
-       server->plugin_uri_hash = ecore_hash_new(ecore_str_hash, 
ecore_str_compare);
-       server->clientCounter = 0;
-       server->incoming_command_list = ecore_list_new();
-       
-       ecore_idle_enterer_add(incoming_command_cb, NULL);
 
-       /*Add a timer, to make sure our event loop keeps going.  Kinda hacky*/
-       ecore_timer_add(0.5, ecore_timer_enterer, NULL);        
+  server = NEW (evfs_server);
+  server->client_hash =
+    ecore_hash_new (ecore_direct_hash, ecore_direct_compare);
+  server->plugin_uri_hash =
+    ecore_hash_new (ecore_str_hash, ecore_str_compare);
+  server->clientCounter = 0;
+  server->incoming_command_list = ecore_list_new ();
 
-       /*Load the plugins*/
-       evfs_load_plugins();
-       evfs_io_initialise();
-       evfs_vfolder_initialise();
-       evfs_operation_initialise();
+  ecore_idle_enterer_add (incoming_command_cb, NULL);
 
+  /*Add a timer, to make sure our event loop keeps going.  Kinda hacky */
+  ecore_timer_add (0.5, ecore_timer_enterer, NULL);
 
+  /*Load the plugins */
+  evfs_load_plugins ();
+  evfs_io_initialise ();
+  evfs_vfolder_initialise ();
+  evfs_operation_initialise ();
 
-       if ((server->ipc_server = 
ecore_ipc_server_connect(ECORE_IPC_LOCAL_USER, EVFS_IPC_TITLE, 0, NULL))) {
-             ecore_ipc_server_del(server->ipc_server);
-             free(server);
-             printf ("ERR: Server already running...\n");
-             return (1);
-       } else {
-             //printf ("ERR: Server created..\n");
 
-             server->ipc_server = ecore_ipc_server_add(ECORE_IPC_LOCAL_USER, 
EVFS_IPC_TITLE, 0, NULL);
 
-             ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD, 
ipc_client_add,
-                 NULL);
-             ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DEL, 
ipc_client_del,
-                 NULL);
-              ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DATA, 
ipc_client_data,
-                 NULL);
-       }
+  if ((server->ipc_server =
+       ecore_ipc_server_connect (ECORE_IPC_LOCAL_USER, EVFS_IPC_TITLE, 0,
+                                NULL))) {
+    ecore_ipc_server_del (server->ipc_server);
+    free (server);
+    printf ("ERR: Server already running...\n");
+    return (1);
+  }
+  else {
+    //printf ("ERR: Server created..\n");
+
+    server->ipc_server =
+      ecore_ipc_server_add (ECORE_IPC_LOCAL_USER, EVFS_IPC_TITLE, 0, NULL);
+
+    ecore_event_handler_add (ECORE_IPC_EVENT_CLIENT_ADD, ipc_client_add,
+                            NULL);
+    ecore_event_handler_add (ECORE_IPC_EVENT_CLIENT_DEL, ipc_client_del,
+                            NULL);
+    ecore_event_handler_add (ECORE_IPC_EVENT_CLIENT_DATA, ipc_client_data,
+                            NULL);
+  }
+
 
+  ecore_main_loop_begin ();
 
-       ecore_main_loop_begin();
-       
-       return 0;
+  return 0;
 }
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/evfs/src/bin/evfs_operation.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- evfs_operation.c    26 Jan 2006 03:33:47 -0000      1.3
+++ evfs_operation.c    31 Jan 2006 06:33:57 -0000      1.4
@@ -2,50 +2,58 @@
 
 static long evfs_operation_count = 0;
 static int evfs_operation_init = 0;
-static Ecore_Hash* evfs_operation_hash;
+static Ecore_Hash *evfs_operation_hash;
 
-void evfs_operation_initialise() 
+void
+evfs_operation_initialise ()
 {
-       if (evfs_operation_init) 
-               return;
+  if (evfs_operation_init)
+    return;
 
-       evfs_operation_init = 1;
-       evfs_operation_count = 0;
+  evfs_operation_init = 1;
+  evfs_operation_count = 0;
 
-       evfs_operation_hash = ecore_hash_new(ecore_direct_hash, 
ecore_direct_compare);
+  evfs_operation_hash =
+    ecore_hash_new (ecore_direct_hash, ecore_direct_compare);
 }
-       
 
-evfs_operation* evfs_operation_new() 
+
+evfs_operation *
+evfs_operation_new ()
 {
-       evfs_operation_count++;
-       
-       evfs_operation* op = NEW(evfs_operation);
-       op->id = evfs_operation_count;
-       op->status = EVFS_OPERATION_STATUS_NORMAL;
+  evfs_operation_count++;
+
+  evfs_operation *op = NEW (evfs_operation);
+  op->id = evfs_operation_count;
+  op->status = EVFS_OPERATION_STATUS_NORMAL;
 
-       ecore_hash_set(evfs_operation_hash, (long*)op->id, op);
-       
-       return op;
+  ecore_hash_set (evfs_operation_hash, (long *) op->id, op);
+
+  return op;
 }
 
-void evfs_operation_destroy(evfs_operation* op) 
+void
+evfs_operation_destroy (evfs_operation * op)
 {
-       ecore_hash_remove(evfs_operation_hash, (long*)op->id);
-       free(op);
+  ecore_hash_remove (evfs_operation_hash, (long *) op->id);
+  free (op);
 }
 
-evfs_operation* evfs_operation_get_by_id(long id) 
+evfs_operation *
+evfs_operation_get_by_id (long id)
 {
-       return ecore_hash_get(evfs_operation_hash, (long*)id);
+  return ecore_hash_get (evfs_operation_hash, (long *) id);
 }
 
-void evfs_operation_status_set(evfs_operation* op, int status) {
-       op->status = status;
+void
+evfs_operation_status_set (evfs_operation * op, int status)
+{
+  op->status = status;
 }
 
-void evfs_operation_user_dispatch(evfs_client* client, evfs_operation* op) {
-       printf("stub");
+void
+evfs_operation_user_dispatch (evfs_client * client, evfs_command* command, 
evfs_operation * op)
+{
+  /*printf ("stub");*/
+  evfs_operation_event_create(client,command,op);
 }
-
-
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/evfs/src/bin/evfs_server_handle.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -3 -r1.36 -r1.37
--- evfs_server_handle.c        26 Jan 2006 03:33:47 -0000      1.36
+++ evfs_server_handle.c        31 Jan 2006 06:33:57 -0000      1.37
@@ -14,423 +14,537 @@
 /*---------------------------------------------------*/
 /*Move these functions somewhere*/
 
-int evfs_uri_open(evfs_client* client, evfs_filereference* uri) {
-       evfs_plugin* plugin = 
evfs_get_plugin_for_uri(client->server,uri->plugin_uri);
-       if (plugin) {
-               printf("Opening file..\n");
-               return (*plugin->functions->evfs_file_open)(client, uri);       
        
-       } else {
-               printf("Could not get plugin for uri '%s' at evfs_uri_open\n", 
uri->plugin_uri);
-               return -1;
-       }
+int
+evfs_uri_open (evfs_client * client, evfs_filereference * uri)
+{
+  evfs_plugin *plugin =
+    evfs_get_plugin_for_uri (client->server, uri->plugin_uri);
+  if (plugin) {
+    printf ("Opening file..\n");
+    return (*plugin->functions->evfs_file_open) (client, uri);
+  }
+  else {
+    printf ("Could not get plugin for uri '%s' at evfs_uri_open\n",
+           uri->plugin_uri);
+    return -1;
+  }
+}
+
+int
+evfs_uri_close (evfs_client * client, evfs_filereference * uri)
+{
+  evfs_plugin *plugin =
+    evfs_get_plugin_for_uri (client->server, uri->plugin_uri);
+  if (plugin) {
+    printf ("Closing file..\n");
+    return (*plugin->functions->evfs_file_close) (uri);
+  }
+  else {
+    printf ("Could not get plugin for uri '%s' at evfs_uri_close\n",
+           uri->plugin_uri);
+    return -1;
+  }
+
 }
 
-int evfs_uri_close(evfs_client* client, evfs_filereference* uri) {
-       evfs_plugin* plugin = 
evfs_get_plugin_for_uri(client->server,uri->plugin_uri);
-       if (plugin) {
-               printf("Closing file..\n");
-               return (*plugin->functions->evfs_file_close)(uri);              
-       } else {
-               printf("Could not get plugin for uri '%s' at evfs_uri_close\n", 
uri->plugin_uri);
-               return -1;
-       }
 
+int
+evfs_uri_read (evfs_client * client, evfs_filereference * uri, char *bytes,
+              long size)
+{
+  evfs_plugin *plugin =
+    evfs_get_plugin_for_uri (client->server, uri->plugin_uri);
+  if (plugin) {
+    return (*plugin->functions->evfs_file_read) (client, uri, bytes, size);
+  }
+  else {
+    printf ("Could not get plugin for uri '%s' at evfs_uri_open\n",
+           uri->plugin_uri);
+    return -1;
+  }
 }
-               
 
-int evfs_uri_read(evfs_client* client, evfs_filereference* uri, char* bytes, 
long size) {
-       evfs_plugin* plugin = 
evfs_get_plugin_for_uri(client->server,uri->plugin_uri);
-       if (plugin) {
-               return 
(*plugin->functions->evfs_file_read)(client,uri,bytes,size);             
-       } else {
-               printf("Could not get plugin for uri '%s' at evfs_uri_open\n", 
uri->plugin_uri);
-               return -1;
-       }
+/*---------------------------------------------------*/
+
+
+
+
+
+
+
+
+void
+evfs_handle_monitor_start_command (evfs_client * client,
+                                  evfs_command * command)
+{
+  /*First get the plugin responsible for this file */
+
+
+  if (command->file_command.num_files > 0) {
+    evfs_plugin *plugin = evfs_get_plugin_for_uri (client->server,
+                                                  command->file_command.
+                                                  files[0]->plugin_uri);
+
+    if (!plugin) {
+      printf ("No plugin able to monitor this uri type\n");
+    }
+    else {
+      printf
+       ("Requesting a file monitor from this plugin for uri type '%s'\n",
+        command->file_command.files[0]->plugin_uri);
+      (*plugin->functions->evfs_monitor_start) (client, command);
+
+    }
+  }
+  else {
+    printf ("No files to monitor!\n");
+  }
+}
+
+void
+evfs_handle_monitor_stop_command (evfs_client * client,
+                                 evfs_command * command)
+{
+  /*First get the plugin responsible for this file */
+
+  void (*evfs_monitor_start) (evfs_client * client, evfs_command * command);
+
+  if (command->file_command.num_files > 0) {
+    evfs_plugin *plugin = evfs_get_plugin_for_uri (client->server,
+                                                  command->file_command.
+                                                  files[0]->plugin_uri);
+
+    if (!plugin) {
+      printf ("No plugin able to monitor this uri type\n");
+    }
+    else {
+      printf
+       ("Requesting a file monitor end from this plugin for uri type '%s'\n",
+        command->file_command.files[0]->plugin_uri);
+
+      evfs_monitor_start = dlsym (plugin->dl_ref, EVFS_FUNCTION_MONITOR_STOP);
+      if (evfs_monitor_start) {
+       (*evfs_monitor_start) (client, command);
+      }
+
+    }
+  }
+  else {
+    printf ("No files to monitor!\n");
+  }
+}
+
+void
+evfs_handle_file_remove_command (evfs_client * client, evfs_command * command)
+{
+  struct stat file_stat;
+
+  //printf("At remove handle for %s\n", command->file_command.files[0]->path );
+
+  evfs_plugin *plugin = evfs_get_plugin_for_uri (client->server,
+                                                command->file_command.
+                                                files[0]->plugin_uri);
+  if (plugin) {
+    (*plugin->functions->evfs_file_lstat) (command, &file_stat, 0);
+    //printf("ST_MODE: %d\n", file_stat.st_mode);
+
+    //printf("Pointer here: %p\n", plugin->functions->evfs_file_remove);
+
+    /*If we're not a dir, simple remove command */
+    if (!S_ISDIR (file_stat.st_mode)) {
+
+      (*plugin->functions->evfs_file_remove) (command->file_command.
+                                             files[0]->path);
+      //printf("REMOVE FIL: '%s'\n", command->file_command.files[0]->path);
+      //
+      /*Iterate */
+      ecore_main_loop_iterate ();
+
+    }
+    else {
+      //printf("IS LINK RES: %d, for %s\n", S_ISLNK(file_stat.st_mode), 
command->file_command.files[0]->path);
+
+      if (!S_ISLNK (file_stat.st_mode)) {
+
+       /*It's a directory, recurse into it */
+       Ecore_List *directory_list = NULL;
+       evfs_filereference *file = NULL;
+
+       /*First, we need a directory list... */
+       (*plugin->functions->evfs_dir_list) (client, command,
+                                            &directory_list);
+       if (directory_list) {
+         while ((file = ecore_list_remove_first (directory_list))) {
+           evfs_command *recursive_command = NEW (evfs_command);
+
+           recursive_command->file_command.files =
+             malloc (sizeof (evfs_filereference *) * 1);
+           recursive_command->type = EVFS_CMD_REMOVE_FILE;
+           recursive_command->file_command.files[0] = file;
+           recursive_command->file_command.num_files = 1;
+
+           evfs_handle_file_remove_command (client, recursive_command);
+           evfs_cleanup_command (recursive_command,
+                                 EVFS_CLEANUP_FREE_COMMAND);
+
+         }
+       }
+
+       //printf("REMOVE DIR: '%s'\n", command->file_command.files[0]->path);
+       (*plugin->functions->evfs_file_remove) (command->file_command.
+                                               files[0]->path);
+      }
+      else {
+       printf ("Not recursing - LINK directory!\n");
+      }
+
+
+    }
+  }
+  else {
+    printf ("No plugin!\n");
+  }
+}
+
+
+void
+evfs_handle_file_rename_command (evfs_client * client, evfs_command * command)
+{
+  printf ("At rename handle\n");
+
+  evfs_plugin *plugin = evfs_get_plugin_for_uri (client->server,
+                                                command->file_command.
+                                                files[0]->plugin_uri);
+  if (plugin) {
+    printf ("Pointer here: %p\n", plugin->functions->evfs_file_rename);
+
+    if (plugin->functions->evfs_file_rename) {
+      if (command->file_command.num_files == 2)
+       (*plugin->functions->evfs_file_rename) (client, command);
+      else
+       printf ("ERR: Wrong number of files to rename\n");
+    }
+    else
+      printf ("Rename not supported\n");
+  }
+}
+
+void
+evfs_handle_file_stat_command (evfs_client * client, evfs_command * command)
+{
+  struct stat file_stat;
+
+  printf ("At file stat handler\n");
+  printf ("Looking for plugin for '%s'\n",
+         command->file_command.files[0]->plugin_uri);
+  evfs_plugin *plugin = evfs_get_plugin_for_uri (client->server,
+                                                command->file_command.
+                                                files[0]->plugin_uri);
+  if (plugin) {
+    printf ("Pointer here: %p\n", plugin->functions->evfs_file_stat);
+    (*(plugin->functions->evfs_file_stat)) (command, &file_stat, 0);
+
+
+
+    evfs_stat_event_create (client, command, &file_stat);
+  }
+  printf ("Handled event, client is %p\n", client);
+
+}
+
+void
+evfs_handle_file_open_command (evfs_client * client, evfs_command * command)
+{
+
+  printf ("At file open handler\n");
+  printf ("Looking for plugin for '%s'\n",
+         command->file_command.files[0]->plugin_uri);
+  evfs_plugin *plugin = evfs_get_plugin_for_uri (client->server,
+                                                command->file_command.
+                                                files[0]->plugin_uri);
+  if (plugin) {
+    printf ("Pointer here: %p\n", plugin->functions->evfs_file_open);
+    (*(plugin->functions->evfs_file_open)) (client,
+                                           command->file_command.files[0]);
+
+
+    fprintf (stderr, "Opened file, fd is: %d\n",
+            command->file_command.files[0]->fd);
+    evfs_open_event_create (client, command);
+  }
+  printf ("Handled event, client is %p\n", client);
+
+}
+
+
+void
+evfs_handle_file_read_command (evfs_client * client, evfs_command * command)
+{
+  char *bytes;
+  int b_read = 0;
+
+
+  //printf ("At file read handler, fd is: %d\n", 
command->file_command.files[0]->fd);
+  //printf ("Reading %d bytes\n", command->file_command.extra);
+
+  bytes = malloc (sizeof (char) * command->file_command.extra);
+
+  //printf("Looking for plugin for '%s'\n", 
command->file_command.files[0]->plugin_uri);
+  evfs_plugin *plugin = evfs_get_plugin_for_uri (client->server,
+                                                command->file_command.
+                                                files[0]->plugin_uri);
+  if (plugin) {
+    //printf("Pointer here: %p\n", plugin->functions->evfs_file_read);
+    b_read =
+      (*(plugin->functions->evfs_file_read)) (client,
+                                             command->file_command.
+                                             files[0], bytes,
+                                             command->file_command.extra);
+
+    //printf("Bytes read: %d\n", b_read);
+
+
+    evfs_read_event_create (client, command, bytes, b_read);
+  }
+  //printf("Handled event, client is %p\n", client);
+
+}
+
+
+
+void
+evfs_handle_dir_list_command (evfs_client * client, evfs_command * command)
+{
+
+
+  evfs_plugin *plugin = evfs_get_plugin_for_uri (client->server,
+                                                command->file_command.
+                                                files[0]->plugin_uri);
+  if (plugin) {
+    Ecore_List *directory_list = NULL;
+    (*plugin->functions->evfs_dir_list) (client, command, &directory_list);
+
+    if (directory_list) {
+      evfs_list_dir_event_create (client, command, directory_list);
+    }
+    else {
+      printf
+       ("evfs_handle_dir_list_command: Recevied null from plugin for 
directory_list\n");
+    }
+  }
+  else {
+    printf ("No plugin for '%s'\n",
+           command->file_command.files[0]->plugin_uri);
+  }
+
 }
 
-/*---------------------------------------------------*/
 
+/* TODO:
+ * 1. check if file exists before open/write.  if so, wait-and-lock for user
+ *    choice
+ * 2. in main loop, if file read bytes < expected, delete file, and retry a 
+ *    preset number of times, before error.
+ */
+void
+evfs_handle_file_copy (evfs_client * client, evfs_command * command,
+                      evfs_command * root_command)
+{
+  evfs_plugin *plugin;
+  evfs_plugin *dst_plugin;
 
+  char bytes[COPY_BLOCKSIZE];
+  long count;
+  char destination_file[PATH_MAX];
+  long read_write_bytes = 0;
 
+  struct stat file_stat;
+  struct stat dest_stat;
 
+  int progress = 0;
+  int last_notify_progress = 0;
+  int b_read = 0, b_write = 0;
+  int res;
+  evfs_operation *op;
 
+  /*Make a new evfs_operation, for client communication */
+  op = evfs_operation_new ();
 
 
+  plugin =
+    evfs_get_plugin_for_uri (client->server,
+                            command->file_command.files[0]->plugin_uri);
+  dst_plugin =
+    evfs_get_plugin_for_uri (client->server,
+                            command->file_command.files[1]->plugin_uri);
 
-void evfs_handle_monitor_start_command(evfs_client* client, evfs_command* 
command) {
-       /*First get the plugin responsible for this file*/
 
 
-       if (command->file_command.num_files > 0) {
-               evfs_plugin* plugin = 
evfs_get_plugin_for_uri(client->server,command->file_command.files[0]->plugin_uri);
+  if (plugin && dst_plugin) {
 
-               if (!plugin) {
-                       printf("No plugin able to monitor this uri type\n");
-               } else {
-                       printf("Requesting a file monitor from this plugin for 
uri type '%s'\n", command->file_command.files[0]->plugin_uri );
-                       
(*plugin->functions->evfs_monitor_start)(client,command);
-                       
-               }
-       } else {
-               printf("No files to monitor!\n");
-       }
-}
+    /*Check for supported options */
+    if (!(plugin->functions->evfs_file_lstat &&
+         plugin->functions->evfs_file_open &&
+         dst_plugin->functions->evfs_file_create)) {
+      printf ("AHH! Copy Not supported!\n");
+      evfs_operation_destroy (op);
+      return;
+    }
 
-void evfs_handle_monitor_stop_command(evfs_client* client, evfs_command* 
command) {
-       /*First get the plugin responsible for this file*/
 
-       void (*evfs_monitor_start)(evfs_client* client, evfs_command* command);
+    /*Get the source file size */
+    (*plugin->functions->evfs_file_lstat) (command, &file_stat, 0);
+    res = (*dst_plugin->functions->evfs_file_lstat) (command, &dest_stat, 1);
 
-       if (command->file_command.num_files > 0) {
-               evfs_plugin* plugin = evfs_get_plugin_for_uri(client->server, 
command->file_command.files[0]->plugin_uri);
+    /*If this file exists, lock our operation until we get confirmation
+     * from the user that they want to overwrite, or not */
+    if (res != EVFS_ERROR) {
+      printf ("File overwrite\n");
+      evfs_operation_status_set (op, EVFS_OPERATION_STATUS_USER_WAIT);
 
-               if (!plugin) {
-                       printf("No plugin able to monitor this uri type\n");
-               } else {
-                       printf("Requesting a file monitor end from this plugin 
for uri type '%s'\n", command->file_command.files[0]->plugin_uri );
-                       
-                       evfs_monitor_start = dlsym(plugin->dl_ref, 
EVFS_FUNCTION_MONITOR_STOP);
-                       if (evfs_monitor_start) {
-                               (*evfs_monitor_start)(client,command);
-                       }
-                       
-               }
-       } else {
-               printf("No files to monitor!\n");
-       }
-}
+      evfs_operation_user_dispatch (client, command, op);
+      while (op->status == EVFS_OPERATION_STATUS_USER_WAIT) {
+       ecore_main_loop_iterate ();
+       usleep (10);
+      }
+    }
 
-void evfs_handle_file_remove_command(evfs_client* client, evfs_command* 
command) {
-       struct stat file_stat;
-       
-       //printf("At remove handle for %s\n", 
command->file_command.files[0]->path );
-
-       evfs_plugin* plugin = evfs_get_plugin_for_uri(client->server, 
command->file_command.files[0]->plugin_uri);
-       if (plugin) {
-               (*plugin->functions->evfs_file_lstat)(command, &file_stat, 0);
-               //printf("ST_MODE: %d\n", file_stat.st_mode);
-               
-               //printf("Pointer here: %p\n", 
plugin->functions->evfs_file_remove);
-
-               /*If we're not a dir, simple remove command*/
-               if (!S_ISDIR(file_stat.st_mode)) { 
-                       
-                       
(*plugin->functions->evfs_file_remove)(command->file_command.files[0]->path);
-                       //printf("REMOVE FIL: '%s'\n", 
command->file_command.files[0]->path);
-                       //
-                       /*Iterate*/
-                       ecore_main_loop_iterate();
-
-               } else {
-                       //printf("IS LINK RES: %d, for %s\n", 
S_ISLNK(file_stat.st_mode), command->file_command.files[0]->path);
-               
-                       if (!S_ISLNK(file_stat.st_mode)) {
-                       
-                               /*It's a directory, recurse into it*/
-                               Ecore_List* directory_list = NULL;
-                               evfs_filereference* file = NULL;
-                       
-                               /*First, we need a directory list...*/
-                               
(*plugin->functions->evfs_dir_list)(client,command,&directory_list);
-                               if (directory_list) {
-                                       while ((file = 
ecore_list_remove_first(directory_list))) {
-                                               evfs_command* recursive_command 
= NEW(evfs_command);
-       
-                                               
recursive_command->file_command.files = malloc(sizeof(evfs_filereference*)*1);
-                                               recursive_command->type = 
EVFS_CMD_REMOVE_FILE;
-                                               
recursive_command->file_command.files[0] = file;
-                                               
recursive_command->file_command.num_files = 1;
-
-                                               
evfs_handle_file_remove_command(client, recursive_command);
-                                               
evfs_cleanup_command(recursive_command,EVFS_CLEANUP_FREE_COMMAND);
-                                               
-                                       }
-                               }
-
-                               //printf("REMOVE DIR: '%s'\n", 
command->file_command.files[0]->path);
-                               
(*plugin->functions->evfs_file_remove)(command->file_command.files[0]->path);
-                       } else {
-                               printf("Not recursing - LINK directory!\n");
-                       }
-
-
-               }
-       } else { printf ("No plugin!\n"); }
-}
-
-
-void evfs_handle_file_rename_command(evfs_client* client, evfs_command* 
command) {
-       printf("At rename handle\n");
-
-       evfs_plugin* plugin = evfs_get_plugin_for_uri(client->server, 
command->file_command.files[0]->plugin_uri);
-       if (plugin) {
-               printf("Pointer here: %p\n", 
plugin->functions->evfs_file_rename);
-               
-               if (plugin->functions->evfs_file_rename)  {
-                       if (command->file_command.num_files == 2) 
-                               
(*plugin->functions->evfs_file_rename)(client,command);
-                       else
-                               printf("ERR: Wrong number of files to 
rename\n");
-               } else
-                       printf("Rename not supported\n");
-       }
-}
+    if (!S_ISDIR (file_stat.st_mode)) {
+      (*dst_plugin->functions->evfs_file_create) (command->file_command.
+                                                 files[1]);
+      (*plugin->functions->evfs_file_open) (client,
+                                           command->file_command.files[0]);
 
-void evfs_handle_file_stat_command(evfs_client* client, evfs_command* command) 
{
-       struct stat file_stat;
-       
-       printf ("At file stat handler\n");
-       printf("Looking for plugin for '%s'\n", 
command->file_command.files[0]->plugin_uri);
-       evfs_plugin* plugin = evfs_get_plugin_for_uri(client->server, 
command->file_command.files[0]->plugin_uri);
-       if (plugin) {
-               printf("Pointer here: %p\n", plugin->functions->evfs_file_stat);
-               (*(plugin->functions->evfs_file_stat))(command, &file_stat, 0);
+      count = 0;
+      while (count < file_stat.st_size) {
+       //(*plugin->functions->evfs_file_seek)(command->file_command.files[0], 
count, SEEK_SET);
 
-               
+       read_write_bytes =
+         (file_stat.st_size >
+          count +
+          COPY_BLOCKSIZE) ? COPY_BLOCKSIZE : (file_stat.st_size - count);
 
-               evfs_stat_event_create(client, command, &file_stat);
-       }
-       printf("Handled event, client is %p\n", client);
+       //printf("Reading/writing %d bytes\n", read_write_bytes);
 
-}
+       //TODO: Implement error checking here
+       b_read =
+         (*plugin->functions->evfs_file_read) (client,
+                                               command->file_command.
+                                               files[0], bytes,
+                                               read_write_bytes);
+       if (b_read > 0) {
+         b_write =
+           (*dst_plugin->functions->evfs_file_write) (command->
+                                                      file_command.
+                                                      files[1],
+                                                      bytes, b_read);
+         //printf("%d  -> %d\n", b_read, b_write);
+       }
+       count += b_read;
 
-void evfs_handle_file_open_command(evfs_client* client, evfs_command* command) 
{
-       
-       printf ("At file open handler\n");
-       printf("Looking for plugin for '%s'\n", 
command->file_command.files[0]->plugin_uri);
-       evfs_plugin* plugin = evfs_get_plugin_for_uri(client->server, 
command->file_command.files[0]->plugin_uri);
-       if (plugin) {
-               printf("Pointer here: %p\n", plugin->functions->evfs_file_open);
-               (*(plugin->functions->evfs_file_open))(client, 
command->file_command.files[0]);
 
 
-               fprintf(stderr, "Opened file, fd is: %d\n", 
command->file_command.files[0]->fd);
-               evfs_open_event_create(client, command);
+       progress =
+         (double) ((double) count / (double) file_stat.st_size * 100);
+       if (progress % 1 == 0 && last_notify_progress < progress) {
+         /*printf ("Percent complete: %d\n", progress); */
+         evfs_file_progress_event_create (client, command,
+                                          root_command, progress,
+                                          EVFS_PROGRESS_TYPE_CONTINUE);
+         last_notify_progress = progress;
        }
-       printf("Handled event, client is %p\n", client);
 
-}
+       //printf("Bytes to go: %d\n", file_stat.st_size - count);
 
 
-void evfs_handle_file_read_command(evfs_client* client, evfs_command* command) 
{
-       char* bytes;
-       int b_read = 0;
 
-       
-       //printf ("At file read handler, fd is: %d\n", 
command->file_command.files[0]->fd);
-       //printf ("Reading %d bytes\n", command->file_command.extra);
+       /*Iterate */
+       ecore_main_loop_iterate ();
+      }
+      (*dst_plugin->functions->evfs_file_close) (command->file_command.
+                                                files[1]);
+      (*plugin->functions->evfs_file_close) (command->file_command.files[0]);
+    }
+    else {
+      Ecore_List *directory_list = NULL;
 
-       bytes = malloc(sizeof(char)*command->file_command.extra);
+      /*First, we need a directory list... */
+      (*plugin->functions->evfs_dir_list) (client, command, &directory_list);
+      if (directory_list) {
+       int ret = 0;
+       evfs_filereference *file = NULL;
 
-       //printf("Looking for plugin for '%s'\n", 
command->file_command.files[0]->plugin_uri);
-       evfs_plugin* plugin = evfs_get_plugin_for_uri(client->server, 
command->file_command.files[0]->plugin_uri);
-       if (plugin) {
-               //printf("Pointer here: %p\n", 
plugin->functions->evfs_file_read);
-               b_read = (*(plugin->functions->evfs_file_read))(client, 
command->file_command.files[0], bytes, command->file_command.extra );
+       /*OK, so the directory exists at the source, and contains files.
+        * Let's make the destination directory first..*/
+       printf ("Making new directory '%s'",
+               command->file_command.files[1]->path);
+       ret =
+         (*dst_plugin->functions->evfs_file_mkdir) (command->
+                                                    file_command.files[1]);
+       printf ("....ret was %d\n", ret);
 
-               //printf("Bytes read: %d\n", b_read);
 
+       //printf("Recursive directory list for '%s' received..\n", 
command->file_command.files[0]->path);
+       while ((file = ecore_list_remove_first (directory_list))) {
+         evfs_filereference *source = NEW (evfs_filereference);
+         evfs_filereference *dest = NEW (evfs_filereference);
+         evfs_command *recursive_command = NEW (evfs_command);
 
-               evfs_read_event_create(client, command, bytes, b_read);
-       }
-       //printf("Handled event, client is %p\n", client);
 
-}
 
+         snprintf (destination_file, PATH_MAX, "%s%s",
+                   command->file_command.files[1]->path,
+                   strrchr (file->path, '/'));
+
+         source->path = strdup (file->path);
+         source->plugin_uri =
+           strdup (command->file_command.files[0]->plugin_uri);
+         source->parent = NULL;        /*TODO - handle nested uris */
+         dest->path = strdup (destination_file);
+         dest->plugin_uri =
+           strdup (command->file_command.files[1]->plugin_uri);
+         dest->parent = NULL;  /*TODO - handle nested uris */
 
+         recursive_command->file_command.files =
+           malloc (sizeof (evfs_filereference *) * 2);
+         recursive_command->type = EVFS_CMD_FILE_COPY;
+         recursive_command->file_command.files[0] = source;
+         recursive_command->file_command.files[1] = dest;
+         recursive_command->file_command.num_files = 2;
 
-void evfs_handle_dir_list_command(evfs_client* client, evfs_command* command) {
+         //printf("Copy file '%s' to %s\n", file->path, destination_file);
 
-       
-       evfs_plugin* plugin = evfs_get_plugin_for_uri(client->server, 
command->file_command.files[0]->plugin_uri);
-       if (plugin) {
-               Ecore_List* directory_list = NULL;
-               (*plugin->functions->evfs_dir_list)(client,command, 
&directory_list);
+         evfs_handle_file_copy (client, recursive_command, root_command);
 
-               if (directory_list) {
-                       evfs_list_dir_event_create(client, command, 
directory_list);
-               } else {
-                       printf("evfs_handle_dir_list_command: Recevied null 
from plugin for directory_list\n");
-               }
-       } else {
-               printf("No plugin for '%s'\n", 
command->file_command.files[0]->plugin_uri);
+         evfs_cleanup_filereference (file);
+         evfs_cleanup_command (recursive_command, EVFS_CLEANUP_FREE_COMMAND);
        }
+       ecore_list_destroy (directory_list);
 
-}
+      }
 
 
-/* TODO:
- * 1. check if file exists before open/write.  if so, wait-and-lock for user
- *    choice
- * 2. in main loop, if file read bytes < expected, delete file, and retry a 
- *    preset number of times, before error.
- */ 
-void evfs_handle_file_copy(evfs_client* client, evfs_command* command, 
evfs_command* root_command) {
-       evfs_plugin* plugin;
-       evfs_plugin* dst_plugin;
-       
-       char bytes[COPY_BLOCKSIZE];
-       long count;
-       char destination_file[PATH_MAX];
-       long read_write_bytes = 0;
-       
-       struct stat file_stat;
-       struct stat dest_stat;
-       
-       int progress = 0;
-       int last_notify_progress = 0;
-       int b_read = 0, b_write= 0;
-       int res;
-       evfs_operation* op;
-
-       /*Make a new evfs_operation, for client communication*/
-       op = evfs_operation_new();
-       
-
-       plugin = evfs_get_plugin_for_uri(client->server, 
command->file_command.files[0]->plugin_uri);
-       dst_plugin = evfs_get_plugin_for_uri(client->server, 
command->file_command.files[1]->plugin_uri);
-
-
-       
-       if (plugin && dst_plugin) {
-
-       /*Check for supported options*/
-               if (! (
-                       plugin->functions->evfs_file_lstat &&
-                       plugin->functions->evfs_file_open &&
-                       dst_plugin->functions->evfs_file_create 
-                     )) {
-                       printf("AHH! Copy Not supported!\n");
-                       evfs_operation_destroy(op);
-                       return;
-               }
-
-
-               /*Get the source file size*/
-               (*plugin->functions->evfs_file_lstat)(command, &file_stat, 0);
-               res = (*dst_plugin->functions->evfs_file_lstat)(command, 
&dest_stat, 1);
-               //printf("Source file size: %d bytes\n", 
(int)file_stat.st_size);
-               //
-               if (res != EVFS_ERROR) {
-                       printf("File overwrite\n");
-                       evfs_operation_status_set(op, 
EVFS_OPERATION_STATUS_USER_WAIT);
-
-                       evfs_operation_user_dispatch(client,op);
-                       while (op->status == EVFS_OPERATION_STATUS_USER_WAIT) {
-                               ecore_main_loop_iterate();
-                               usleep(10);
-                       }
-               }
-               
-               if (!S_ISDIR(file_stat.st_mode)) {
-                       
(*dst_plugin->functions->evfs_file_create)(command->file_command.files[1]);
-                       (*plugin->functions->evfs_file_open)(client, 
command->file_command.files[0]);
-                       
-                       count = 0;
-                       while (count < file_stat.st_size) {
-                               
//(*plugin->functions->evfs_file_seek)(command->file_command.files[0], count, 
SEEK_SET);
-
-                               read_write_bytes = 
-                               (file_stat.st_size > count + COPY_BLOCKSIZE) ? 
COPY_BLOCKSIZE : (file_stat.st_size - count);
-                               
-                               //printf("Reading/writing %d bytes\n", 
read_write_bytes);
-               
-                               //TODO: Implement error checking here
-                               b_read = 
-                               
(*plugin->functions->evfs_file_read)(client,command->file_command.files[0], 
bytes, read_write_bytes );
-                               if (b_read > 0) {
-                                       b_write = 
(*dst_plugin->functions->evfs_file_write)(command->file_command.files[1], 
bytes, b_read );
-                                       //printf("%d  -> %d\n", b_read, 
b_write);
-                               }
-                               count+= b_read;
-
-
-               
-                               progress = (double)((double)count / 
(double)file_stat.st_size * 100);
-                               if (progress % 1 == 0 && last_notify_progress < 
progress) {
-                                       /*printf ("Percent complete: %d\n", 
progress);*/
-                                       
evfs_file_progress_event_create(client,command, 
-                                               root_command,progress, 
EVFS_PROGRESS_TYPE_CONTINUE);
-                                       last_notify_progress = progress;
-                               }
-
-                               //printf("Bytes to go: %d\n", file_stat.st_size 
- count);
-
-
-       
-                               /*Iterate*/
-                               ecore_main_loop_iterate();
-                       }
-                       
(*dst_plugin->functions->evfs_file_close)(command->file_command.files[1]);
-                       
(*plugin->functions->evfs_file_close)(command->file_command.files[0]);
-               } else {
-                       Ecore_List* directory_list = NULL;
-                       
-                       /*First, we need a directory list...*/
-                       
(*plugin->functions->evfs_dir_list)(client,command,&directory_list);
-                       if (directory_list) {
-                               int ret =0;
-                               evfs_filereference* file = NULL;
-                                               
-                               /*OK, so the directory exists at the source, 
and contains files.
-                                * Let's make the destination directory 
first..*/
-                               printf("Making new directory '%s'", 
command->file_command.files[1]->path);
-                               ret=  
(*dst_plugin->functions->evfs_file_mkdir)(command->file_command.files[1]);
-                               printf("....ret was %d\n", ret);
-                               
-                               
-                               //printf("Recursive directory list for '%s' 
received..\n", command->file_command.files[0]->path);
-                               while ((file = 
ecore_list_remove_first(directory_list))) {
-                                       evfs_filereference* source = 
NEW(evfs_filereference);
-                                       evfs_filereference* dest = 
NEW(evfs_filereference);
-                                       evfs_command* recursive_command = 
NEW(evfs_command);
-
-                                       
-                                       
-                                       snprintf(destination_file, PATH_MAX, 
"%s%s", 
-                                               
command->file_command.files[1]->path, strrchr(file->path, '/'));
-
-                                       source->path = strdup(file->path);
-                                       source->plugin_uri = 
strdup(command->file_command.files[0]->plugin_uri);
-                                       source->parent = NULL; /*TODO - handle 
nested uris*/
-                                       dest->path = strdup(destination_file);
-                                       dest->plugin_uri = 
strdup(command->file_command.files[1]->plugin_uri);
-                                       dest->parent = NULL; /*TODO - handle 
nested uris*/
-
-                                       recursive_command->file_command.files = 
malloc(sizeof(evfs_filereference*)*2);
-                                       recursive_command->type = 
EVFS_CMD_FILE_COPY;
-                                       
recursive_command->file_command.files[0] = source;
-                                       
recursive_command->file_command.files[1] = dest;
-                                       
recursive_command->file_command.num_files = 2;
-                                       
-                                       //printf("Copy file '%s' to %s\n", 
file->path, destination_file);
-
-                                       evfs_handle_file_copy(client, 
recursive_command, root_command);
-                                       
-                                       evfs_cleanup_filereference(file);
-                                       evfs_cleanup_command(recursive_command, 
EVFS_CLEANUP_FREE_COMMAND);
-                               }
-                               ecore_list_destroy(directory_list);
-                               
-                       }
-               
-                       
-               }
-               
-               /*Only send '100%' event when we're back at the top, or we 
aren't recursive*/
-               if (command == root_command) 
-                       evfs_file_progress_event_create(client,command, 
root_command,100, EVFS_PROGRESS_TYPE_DONE);
-
-               
-       } else {
-               printf("Could not get plugins for both source and dest: 
(%s:%s)\n",
-                       command->file_command.files[0]->plugin_uri, 
command->file_command.files[1]->plugin_uri );
-       }
+    }
+
+    /*Only send '100%' event when we're back at the top, or we aren't 
recursive */
+    if (command == root_command)
+      evfs_file_progress_event_create (client, command, root_command, 100,
+                                      EVFS_PROGRESS_TYPE_DONE);
+
+
+  }
+  else {
+    printf ("Could not get plugins for both source and dest: (%s:%s)\n",
+           command->file_command.files[0]->plugin_uri,
+           command->file_command.files[1]->plugin_uri);
+  }
 
-       evfs_operation_destroy(op);
+  evfs_operation_destroy (op);
 
 }
 
-void evfs_handle_ping_command(evfs_client* client, evfs_command* command) {
-       printf("Ping!\n");
+void
+evfs_handle_ping_command (evfs_client * client, evfs_command * command)
+{
+  printf ("Ping!\n");
 }
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/evfs/src/bin/evfscat.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- evfscat.c   23 Jan 2006 10:59:32 -0000      1.2
+++ evfscat.c   31 Jan 2006 06:33:57 -0000      1.3
@@ -1,55 +1,64 @@
 #include <evfs.h>
 #include <string.h>
 
-evfs_connection* con;
+evfs_connection *con;
 
-void callback(evfs_event* data, void* obj) {
+void
+callback (evfs_event * data, void *obj)
+{
 
 
-       switch (data->type) {
-               case EVFS_EV_FILE_OPEN:
-                       //printf("File open event..fd is %d, reading..\n", 
data->resp_command.file_command.files[0]->fd);
-
-                       evfs_client_file_read(con, 
data->resp_command.file_command.files[0], 4096);
-                       
-                       break;
-
-               case EVFS_EV_FILE_READ:
-                       //printf("File read event, size is %ld\n", 
data->data.size);
-                       if (data->data.size > 0) {
-                               fwrite(data->data.bytes, data->data.size, 1, 
stdout);
-                               evfs_client_file_read(con, 
data->resp_command.file_command.files[0], 4096);
-                       } else {
-                               exit(0);
-                       }
-                               
-
-                       
-                       break;
-               default: printf("Unknown event\n");
-                        break;
-       }
+  switch (data->type) {
+  case EVFS_EV_FILE_OPEN:
+    //printf("File open event..fd is %d, reading..\n", 
data->resp_command.file_command.files[0]->fd);
+
+    evfs_client_file_read (con, data->resp_command.file_command.files[0],
+                          4096);
+
+    break;
+
+  case EVFS_EV_FILE_READ:
+    //printf("File read event, size is %ld\n", data->data.size);
+    if (data->data.size > 0) {
+      fwrite (data->data.bytes, data->data.size, 1, stdout);
+      evfs_client_file_read (con,
+                            data->resp_command.file_command.files[0], 4096);
+    }
+    else {
+      exit (0);
+    }
+
+
+
+    break;
+  default:
+    printf ("Unknown event\n");
+    break;
+  }
 }
 
-int main(int argc, char** argv) {
-       
-       evfs_file_uri_path* path;
-       char pathi[1024];
-
-       if (argc < 2) {
-               return 0;
-       }
-
-       if ( (con = evfs_connect(&callback, NULL))) {
-               path = evfs_parse_uri(argv[1]);
-       
-               evfs_client_file_open(con, path->files[0]);
-       } else {
-               printf("evfscat: failure to connect to evfs server\n");
-       }
+int
+main (int argc, char **argv)
+{
+
+  evfs_file_uri_path *path;
+  char pathi[1024];
+
+  if (argc < 2) {
+    return 0;
+  }
+
+  if ((con = evfs_connect (&callback, NULL))) {
+    path = evfs_parse_uri (argv[1]);
+
+    evfs_client_file_open (con, path->files[0]);
+  }
+  else {
+    printf ("evfscat: failure to connect to evfs server\n");
+  }
 
-       ecore_main_loop_begin();
-       evfs_disconnect(con);
+  ecore_main_loop_begin ();
+  evfs_disconnect (con);
 
-       return 0;
+  return 0;
 }




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to