Enlightenment CVS committal

Author  : lordchaos
Project : e17
Module  : apps/evfs

Dir     : e17/apps/evfs/src/bin


Modified Files:
        evfs_main.c evfs_operation.c evfs_operation_tasks.c 
        evfs_server_handle.c 


Log Message:
* Port 'remove' (standard and recursive), to new workflow engine
* Support progress events for remove

===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/evfs/src/bin/evfs_main.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -3 -r1.38 -r1.39
--- evfs_main.c 12 Mar 2006 05:27:33 -0000      1.38
+++ evfs_main.c 14 Mar 2006 13:06:22 -0000      1.39
@@ -181,7 +181,8 @@
         printf("Move file stub\n");
         break;
      case EVFS_CMD_REMOVE_FILE:
-        evfs_handle_file_remove_command(client, command);
+        evfs_handle_file_remove_command(client, command, command);
+       cleanup_command=0;
         break;
      case EVFS_CMD_FILE_STAT:
         evfs_handle_file_stat_command(client, command);
@@ -349,7 +350,7 @@
    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.1, ecore_timer_enterer, NULL);
+   ecore_timer_add(0.02, ecore_timer_enterer, NULL);
 
    /*Load the plugins */
    evfs_load_plugins();
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/evfs/src/bin/evfs_operation.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- evfs_operation.c    14 Mar 2006 10:54:19 -0000      1.9
+++ evfs_operation.c    14 Mar 2006 13:06:22 -0000      1.10
@@ -67,6 +67,9 @@
                           case EVFS_OPERATION_TASK_TYPE_MKDIR:
                                   
evfs_cleanup_filereference(EVFS_OPERATION_TASK_MKDIR(task)->file);
                                   break;
+                          case EVFS_OPERATION_TASK_TYPE_FILE_REMOVE:
+                                  
evfs_cleanup_filereference(EVFS_OPERATION_TASK_FILE_REMOVE(task)->file);
+                                  break;
                           default:
                                   printf("Destroying unknown task type\n");
                                   break;
@@ -134,6 +137,23 @@
        ecore_list_append(op->sub_task, copy);
 }
 
+void evfs_operation_remove_task_add(evfs_operation* op, evfs_filereference* 
file, struct stat file_stat)
+{
+       evfs_operation_files* fop = EVFS_OPERATION_FILES(op);
+       evfs_operation_task_file_remove* remove = calloc(1, 
sizeof(evfs_operation_task_file_remove));
+
+       remove->file = file;
+       memcpy(&remove->file_stat, &file_stat, sizeof(struct stat));
+
+       EVFS_OPERATION_TASK(remove)->status = 
EVFS_OPERATION_TASK_STATUS_PENDING;
+       EVFS_OPERATION_TASK(remove)->type = 
EVFS_OPERATION_TASK_TYPE_FILE_REMOVE;
+
+       fop->total_bytes += file_stat.st_size;
+       fop->total_files += 1;
+
+       ecore_list_append(op->sub_task, remove);
+}
+
 
 /*Sub task functions*/
 void evfs_operation_mkdir_task_add(evfs_operation* op, evfs_filereference* dir)
@@ -173,6 +193,8 @@
                                                                        
                                break;
                        case EVFS_OPERATION_TASK_TYPE_FILE_REMOVE:
+                               printf("REMOVE: %s://%s \n", 
EVFS_OPERATION_TASK_FILE_REMOVE(task)->file->plugin_uri,
+                                                                    
EVFS_OPERATION_TASK_FILE_REMOVE(task)->file->path);                             
   
                                break;
 
                        case EVFS_OPERATION_TASK_TYPE_MKDIR:
@@ -307,6 +329,40 @@
                                }
                        }
                        break;
+
+                       case EVFS_OPERATION_TASK_TYPE_FILE_REMOVE: {
+                               int prog = 0;
+                               double progress;
+                               double calc;
+
+                               prog = evfs_operation_tasks_file_remove_run(op, 
EVFS_OPERATION_TASK_FILE_REMOVE(task));
+                               EVFS_OPERATION_FILES(op)->progress_bytes += 
prog;
+
+                               calc = 
(double)EVFS_OPERATION_FILES(op)->total_bytes / 
(double)EVFS_OPERATION_FILES(op)->progress_bytes;
+                               progress = 1.0 / calc;
+                               progress *= 100.0;
+
+                               evfs_file_progress_event_create(op->client,  
EVFS_OPERATION_TASK_FILE_REMOVE(task)->file,
+                                               evfs_empty_file_get(),
+                                               op->command, progress, 
+                                               EVFS_PROGRESS_TYPE_CONTINUE);
+
+
+                               if (task->status == 
EVFS_OPERATION_TASK_STATUS_COMMITTED) {
+                                       
EVFS_OPERATION_FILES(op)->progress_files += 1;
+                                       op->processed_tasks++;
+                               }
+
+                               //FIXME - ther's probably a better place to put 
this*/
+                               if (op->processed_tasks == 
ecore_list_nodes(op->sub_task) && task->status == 
EVFS_OPERATION_TASK_STATUS_COMMITTED) {
+                                       
evfs_file_progress_event_create(op->client,  
EVFS_OPERATION_TASK_FILE_REMOVE(task)->file,
+                                               evfs_empty_file_get(),
+                                               op->command, 100, 
+                                               EVFS_PROGRESS_TYPE_DONE);       
                                
+                               }
+                                                                     
+                       }
+                       break;
                        
                        case EVFS_OPERATION_TASK_TYPE_MKDIR:
                                /*printf("...Processing mkdir task type!\n");*/
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/evfs/src/bin/evfs_operation_tasks.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- evfs_operation_tasks.c      14 Mar 2006 10:54:19 -0000      1.3
+++ evfs_operation_tasks.c      14 Mar 2006 13:06:22 -0000      1.4
@@ -111,3 +111,22 @@
        /*TODO - handle 'fail' state*/
        EVFS_OPERATION_TASK(task)->status = 
EVFS_OPERATION_TASK_STATUS_COMMITTED;
 }
+
+uint64 evfs_operation_tasks_file_remove_run(evfs_operation* op, 
evfs_operation_task_file_remove* task)
+{
+       int ret=0;
+
+       if (!task->file->plugin)
+               task->file->plugin = evfs_get_plugin_for_uri(evfs_server_get(),
+                              task->file->plugin_uri);
+
+       ret = (*task->file->plugin->functions->evfs_file_remove) 
(task->file->path);
+
+       /*TODO - handle 'fail' state*/
+       EVFS_OPERATION_TASK(task)->status = 
EVFS_OPERATION_TASK_STATUS_COMMITTED;
+
+       return task->file_stat.st_size;
+}
+
+
+
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/evfs/src/bin/evfs_server_handle.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -3 -r1.50 -r1.51
--- evfs_server_handle.c        14 Mar 2006 10:54:19 -0000      1.50
+++ evfs_server_handle.c        14 Mar 2006 13:06:22 -0000      1.51
@@ -139,11 +139,18 @@
 }
 
 void
-evfs_handle_file_remove_command(evfs_client * client, evfs_command * command)
+evfs_handle_file_remove_command(evfs_client * client, evfs_command * command, 
evfs_command* root_command)
 {
    struct stat file_stat;
+   evfs_operation_files* op;
+
+   if (root_command == command) {
+          op = evfs_operation_files_new(client, root_command);
+          command->op = EVFS_OPERATION(op);
+   } else {
+          op = root_command->op;
+   }
 
-   //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.
@@ -151,26 +158,21 @@
    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);
-             //
+                 evfs_operation_remove_task_add(EVFS_OPERATION(op), 
+                      evfs_filereference_clone(command->file_command.files[0]),
+                      file_stat);              
+                 
              /*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))
                {
 
@@ -194,16 +196,17 @@
                             recursive_command->file_command.num_files = 1;
 
                             evfs_handle_file_remove_command(client,
-                                                            recursive_command);
+                                                            recursive_command, 
root_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);
+                 evfs_operation_remove_task_add(EVFS_OPERATION(op), 
+                      evfs_filereference_clone(command->file_command.files[0]),
+                      file_stat);      
+
                }
              else
                {
@@ -211,6 +214,17 @@
                }
 
           }
+
+
+        if (command == root_command) {
+           /*evfs_file_progress_event_create(client, command, root_command, 
100,
+                                           EVFS_PROGRESS_TYPE_DONE);*/
+
+          evfs_operation_tasks_print(EVFS_OPERATION(op));
+
+          evfs_operation_queue_pending_add(EVFS_OPERATION(op));
+
+       }
      }
    else
      {




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to