Enlightenment CVS committal Author : lordchaos Project : e17 Module : apps/evfs
Dir : e17/apps/evfs/src/bin Modified Files: evfs_operation.c evfs_operation_tasks.c evfs_server_handle.c Log Message: * Re-add support for operational (e.g. file copy/remove/etc) responses - this time in the new workflow system. Currently supported responses for overwrite: Yes, Yes to All, No, Abort. Some cleanup and helper functions are still required here, but the base logic works =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/evfs/src/bin/evfs_operation.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- evfs_operation.c 12 Mar 2006 05:41:24 -0000 1.8 +++ evfs_operation.c 14 Mar 2006 10:54:19 -0000 1.9 @@ -96,6 +96,11 @@ op->status = status; } +void evfs_operation_wait_type_set(evfs_operation* op, int type) +{ + op->wait_type = type; +} + void evfs_operation_user_dispatch(evfs_client * client, evfs_command * command, evfs_operation * op, char* misc) @@ -108,7 +113,7 @@ /*Sub task functions*/ void evfs_operation_copy_task_add(evfs_operation* op, evfs_filereference* file_from, evfs_filereference* file_to, struct stat from_stat, - struct stat to_stat) + struct stat to_stat, int to_stat_response) { evfs_operation_files* fop = EVFS_OPERATION_FILES(op); evfs_operation_task_file_copy* copy = calloc(1, sizeof(evfs_operation_task_file_copy)); @@ -118,6 +123,7 @@ copy->next_byte = 0; memcpy(©->source_stat, &from_stat, sizeof(struct stat)); memcpy(©->dest_stat, &to_stat, sizeof(struct stat)); + copy->dest_stat_response = to_stat_response; EVFS_OPERATION_TASK(copy)->status = EVFS_OPERATION_TASK_STATUS_PENDING; EVFS_OPERATION_TASK(copy)->type = EVFS_OPERATION_TASK_TYPE_FILE_COPY; @@ -216,12 +222,52 @@ } } +//TODO - move this to some kind of state table, so we can deal with it properly +void evfs_operation_response_handle(evfs_operation* op, evfs_operation_task* task) +{ + + switch (op->wait_type) { + case EVFS_OPERATION_WAIT_TYPE_FILE_OVERWRITE: + printf("This is a file overwrite wait type\n"); + + /*In this case, we want to look at the response - if it's an + * affirm, continue as normal. If it's deny, jump over it*/ + + if (op->response == EVFS_OPERATION_RESPONSE_AFFIRM) { + task->status = EVFS_OPERATION_TASK_STATUS_EXEC_CONT; + op->status = EVFS_OPERATION_STATUS_NORMAL; + } else if (op->response == EVFS_OPERATION_RESPONSE_AFFIRM_ALL) { + op->status = EVFS_OPERATION_STATUS_OVERRIDE; + } else if (op->response == EVFS_OPERATION_RESPONSE_NEGATE) { + printf("NEGATE reponse received\n"); + task->status = EVFS_OPERATION_TASK_STATUS_CANCEL; + op->status = EVFS_OPERATION_STATUS_NORMAL; + } else if (op->response == EVFS_OPERATION_RESPONSE_ABORT) { + op->status = EVFS_OPERATION_STATUS_COMPLETED; + task->status = EVFS_OPERATION_TASK_STATUS_CANCEL; + } + break; + default: + printf("Unknown wait type\n"); + break; + } +} + void evfs_operation_run_tasks(evfs_operation* op) { evfs_operation_task* task = NULL; task = ecore_list_current(op->sub_task); if (task) { + + + if (op->status == EVFS_OPERATION_STATUS_REPLY_RECEIVED) { + evfs_operation_response_handle(op,task); + } + + + if (op->status == EVFS_OPERATION_STATUS_NORMAL || op->status == EVFS_OPERATION_STATUS_OVERRIDE) { + if (task->status == EVFS_OPERATION_TASK_STATUS_PENDING) task->status = EVFS_OPERATION_TASK_STATUS_EXEC; @@ -231,7 +277,8 @@ int prog = 0; double progress; double calc; - + + /*printf("...Processing file copy task type!\n");*/ prog = evfs_operation_tasks_file_copy_run(op, EVFS_OPERATION_TASK_FILE_COPY(task)); EVFS_OPERATION_FILES(op)->progress_bytes += prog; @@ -276,9 +323,13 @@ } + OPERATION_TASK_EXIT: if (task->status == EVFS_OPERATION_TASK_STATUS_COMMITTED) { ecore_list_next(op->sub_task); } + } else { + /*printf("Operation is in user wait state!\n");*/ + } } else { /*If task is null, operation is completed!*/ op->status = EVFS_OPERATION_STATUS_COMPLETED; =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/evfs/src/bin/evfs_operation_tasks.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- evfs_operation_tasks.c 12 Mar 2006 06:32:25 -0000 1.2 +++ evfs_operation_tasks.c 14 Mar 2006 10:54:19 -0000 1.3 @@ -18,7 +18,30 @@ copy->file_to->plugin_uri); - + /*Check if we're trying to overwrite*/ + if (!(op->status == EVFS_OPERATION_STATUS_OVERRIDE) && + !(EVFS_OPERATION_TASK(copy)->status == EVFS_OPERATION_TASK_STATUS_EXEC_CONT) && + !(EVFS_OPERATION_TASK(copy)->status == EVFS_OPERATION_TASK_STATUS_CANCEL)) { + + if (copy->dest_stat_response != EVFS_ERROR) { + /*Looks like we're overwriting*/ + + evfs_operation_status_set(op, EVFS_OPERATION_STATUS_USER_WAIT); + evfs_operation_wait_type_set(op, EVFS_OPERATION_WAIT_TYPE_FILE_OVERWRITE); + evfs_operation_user_dispatch(op->client, op->command, op, copy->file_to->path); + + return 0; + } + } + + /*Check for cancel...*/ + if (EVFS_OPERATION_TASK(copy)->status == EVFS_OPERATION_TASK_STATUS_CANCEL) { + printf("**** Cancelling copy via user request\n"); + + EVFS_OPERATION_TASK(copy)->status = EVFS_OPERATION_TASK_STATUS_COMMITTED; + return copy->source_stat.st_size; + } + if (copy->file_from->fd == 0 && copy->file_from->fd_p == NULL) { /*printf("Opening source file...\n");*/ int fd =(*copy->file_from->plugin->functions->evfs_file_open) (op->client, copy->file_from); @@ -63,8 +86,12 @@ /*printf("Ending task, continuing operation...\n");*/ /*Check if it's time to end..*/ - if (copy->next_byte == copy->source_stat.st_size) + if (copy->next_byte == copy->source_stat.st_size) { + (*copy->file_from->plugin->functions->evfs_file_close) (copy->file_from); + (*copy->file_to->plugin->functions->evfs_file_close) (copy->file_to); + EVFS_OPERATION_TASK(copy)->status = EVFS_OPERATION_TASK_STATUS_COMMITTED; + } return total; =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/evfs/src/bin/evfs_server_handle.c,v retrieving revision 1.49 retrieving revision 1.50 diff -u -3 -r1.49 -r1.50 --- evfs_server_handle.c 12 Mar 2006 05:27:33 -0000 1.49 +++ evfs_server_handle.c 14 Mar 2006 10:54:19 -0000 1.50 @@ -428,7 +428,7 @@ evfs_operation_copy_task_add(EVFS_OPERATION(op), evfs_filereference_clone(command->file_command.files[0]), evfs_filereference_clone(command->file_command.files[1]), - file_stat, dest_stat); + file_stat, dest_stat, res); } else { Ecore_List *directory_list = NULL; @@ -519,7 +519,7 @@ op_get = evfs_operation_get_by_id(command->op->id); if (op_get) { - op_get->status = EVFS_OPERATION_STATUS_NORMAL; + op_get->status = EVFS_OPERATION_STATUS_REPLY_RECEIVED; op_get->response = command->op->response; printf("*** Received operation response for op %ld -> %d\n", command->op->id, command->op->response); ------------------------------------------------------- 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