Enlightenment CVS committal Author : chaos Project : e17 Module : proto
Dir : e17/proto/entropy/src Modified Files: Makefile.am entropy_config.c entropy_core.c entropy_file.c entropy_thumbnailer_engine.c main.c notification_engine.c plugin_helper.c Log Message: Whoa! Lots of while-you-were sleeping CVS downtime changes: * Extractor based plugin - middle click a file to try! * Remove pthread nastiness, and begin making *everything* async * Lots of bug fixes * Much improved file cache reference tracking - more stable entropy * Loads more =================================================================== RCS file: /cvs/e/e17/proto/entropy/src/Makefile.am,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- Makefile.am 3 Jan 2006 10:48:23 -0000 1.5 +++ Makefile.am 28 Mar 2006 10:31:14 -0000 1.6 @@ -22,13 +22,11 @@ entropy_alert.c -entropy_CC = @PTHREAD_CC@ -entropy_CFLAGS = @PTHREAD_CFLAGS@ \ - @EWL_CFLAGS@ @EVFS_CFLAGS@ \ +entropy_CC = cc +entropy_CFLAGS = @EWL_CFLAGS@ @EVFS_CFLAGS@ \ @IMLIB2_CFLAGS@ @EPSILON_CFLAGS@ -entropy_LDFLAGS = -rdynamic @PTHREAD_CFLAGS@ @IMLIB2_CFLAGS@ +entropy_LDFLAGS = -rdynamic @IMLIB2_CFLAGS@ entropy_LDADD = $(INTLLIBS) \ - @PTHREAD_LIBS@ \ @EWL_LIBS@ \ @IMLIB2_LIBS@ \ @EVFS_LIBS@ @EPSILON_LIBS@ =================================================================== RCS file: /cvs/e/e17/proto/entropy/src/entropy_config.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -3 -r1.14 -r1.15 --- entropy_config.c 22 Mar 2006 11:04:49 -0000 1.14 +++ entropy_config.c 28 Mar 2006 10:31:14 -0000 1.15 @@ -242,7 +242,7 @@ Entropy_Config_Structure* entropy_config_structure_new(char* name, char* uri) { - Entropy_Config_Structure* structure = calloc(1,sizeof(Entropy_Config_Structure)); + Entropy_Config_Structure* structure = entropy_malloc(sizeof(Entropy_Config_Structure)); structure->name = strdup(name); structure->uri = strdup(uri); @@ -255,7 +255,7 @@ { va_list args; Entropy_Config_Mime_Binding_Action* action; - Entropy_Config_Mime_Binding* binding = calloc(1,sizeof(Entropy_Config_Mime_Binding)); + Entropy_Config_Mime_Binding* binding = entropy_malloc(sizeof(Entropy_Config_Mime_Binding)); va_start(args, action1); for (action = action1; action; action = va_arg(args, Entropy_Config_Mime_Binding_Action*)) { @@ -273,7 +273,7 @@ Entropy_Config_Mime_Binding_Action* entropy_config_binding_action_new(char* description, char* executable, char* args) { - Entropy_Config_Mime_Binding_Action* action = calloc(1,sizeof(Entropy_Config_Mime_Binding_Action)); + Entropy_Config_Mime_Binding_Action* action = entropy_malloc(sizeof(Entropy_Config_Mime_Binding_Action)); action->app_description = strdup(description); action->executable = strdup(executable); @@ -296,7 +296,7 @@ if (_Entropy_Config) return _Entropy_Config; _Entropy_Config = entropy_malloc(sizeof(Entropy_Config)); - mimes = calloc(1,sizeof(Entropy_Config_Loaded)); + mimes = entropy_malloc(sizeof(Entropy_Config_Loaded)); i = strlen(entropy_core_home_dir_get()) + strlen("/.e/apps/entropy") + 2; @@ -375,7 +375,7 @@ if (data) { _Entropy_Config->Loaded_Config = eet_data_descriptor_decode(_entropy_config_loaded_edd, data, size_ret); /*Print them out..*/ - entropy_config_mimes_print(_Entropy_Config->Loaded_Config); + /*entropy_config_mimes_print(_Entropy_Config->Loaded_Config);*/ } } /*------*/ @@ -605,7 +605,7 @@ { entropy_core* core = entropy_core_get_core(); - char *eg = calloc (HEADER_CONFIG_MAX, sizeof (char)); + char *eg = entropy_malloc(HEADER_CONFIG_MAX * sizeof (char)); snprintf (eg, HEADER_CONFIG_MAX, "Computer;file:///|Home;file://%s|Samba Example (Don't use!);smb://username:password@/test/machine/folder", =================================================================== RCS file: /cvs/e/e17/proto/entropy/src/entropy_core.c,v retrieving revision 1.63 retrieving revision 1.64 diff -u -3 -r1.63 -r1.64 --- entropy_core.c 19 Mar 2006 10:38:47 -0000 1.63 +++ entropy_core.c 28 Mar 2006 10:31:14 -0000 1.64 @@ -14,12 +14,13 @@ #include "entropy.h" #include <ctype.h> -#include <pthread.h> #include "md5.h" #include "entropy_gui.h" #include <Epsilon.h> #include <Evas.h> +#include <X11/Xlib.h> + #define ENTROPY_CORE 1 static int requests = 0; @@ -52,48 +53,36 @@ /*printf ("Received message\n");*/ if (e->major == ENTROPY_IPC_EVENT_CORE) { - pthread_mutex_lock(&core->notify->exe_queue_mutex); entropy_notify_event* eevent; ecore_list_goto_first(core->notify->exe_queue); if ( (eevent = ecore_list_next(core->notify->exe_queue)) ) { + if (!eevent->processed) { + printf("Pulled an unprocessed event off the queue!\n"); + } + ecore_list_remove_first(core->notify->exe_queue); + /*If the return struct is null, don't call the callbacks. The requester has taken responsibility * for calling the requesters of this type when the data is available, which is obviously not now*/ if (eevent->return_struct) { + + /*printf("******* PROCESSING %p\n", eevent);*/ ecore_list_goto_first(eevent->cb_list); while ( (cb_data = ecore_list_next(eevent->cb_list)) ) { (*cb_data->cb)(eevent, eevent->requestor_data, eevent->return_struct, cb_data->data); } destroy_struct = 1; + /*printf("******** DONE\n");*/ } else { entropy_log ("ipc_client_data: RETURN was NULL. Caller will notify when data ready\n", ENTROPY_LOG_WARN); destroy_struct = 0; } - /*TODO move this to a dedicated cleanup function*/ - if (destroy_struct) { - switch (eevent->event_type) { - case ENTROPY_NOTIFY_FILELIST_REQUEST: - /*It's a filelist request - return is an ecore list - destroy*/ - ecore_list_destroy(eevent->return_struct); - break; - - case ENTROPY_NOTIFY_THUMBNAIL_REQUEST: - /*A thumbnail - we want to keep this, don't destroy anything*/ - break; - - case ENTROPY_NOTIFY_FILE_STAT_AVAILABLE: - //entropy_file_stat* stat = eevent->return_struct; - break; - } - } - entropy_notify_event_destroy(eevent); } - pthread_mutex_unlock(&core->notify->exe_queue_mutex); } else if (e->major == ENTROPY_IPC_EVENT_LAYOUT_NEW) { entropy_gui_component_instance* (*entropy_plugin_layout_create)(entropy_core*); @@ -148,9 +137,6 @@ /*Read inbound arguments*/ entropy_core_args_parse(core, argc,argv); - /*Init the file cache mutex*/ - pthread_mutex_init(&core->file_cache_mutex, NULL); - /*Initialise the ecore ipc system*/ if (ecore_ipc_init() < 1) { printf("Couldn't connect to the ecore_ipc subsystem\n"); @@ -308,16 +294,7 @@ entropy_plugin_layout_main = dlsym(core->layout_plugin->dl_ref, "entropy_plugin_layout_main"); - - /*FIXME why doesn't the UI update unless we have an empty ecore_timer here? - * Try removing this, and thumbnail a large dir without - * moving the mouse */ - ecore_timer_add(0.2, ecore_timer_enterer, NULL); - - - - - + ecore_idle_enterer_add(entropy_notify_loop, core->notify); //printf("--------------- Running main\n"); @@ -365,7 +342,7 @@ /*IF not found, make a new one*/ if (!found) { - binding = calloc(1,sizeof(Entropy_Config_Mime_Binding)); + binding = entropy_malloc(sizeof(Entropy_Config_Mime_Binding)); binding->mime_type = strdup(mime_type); binding->desc = strdup(desc); core_core->config->Loaded_Config->mime_bindings = @@ -388,7 +365,7 @@ if (!strcmp(binding->mime_type, mime_type)) { /*Create a new action, based on this mime_type*/ - action = calloc(1,sizeof(Entropy_Config_Mime_Binding_Action)); + action = entropy_malloc(sizeof(Entropy_Config_Mime_Binding_Action)); action->app_description = strdup(name); action->executable = strdup(executable); @@ -405,117 +382,11 @@ void entropy_core_config_load() { - int count, new_count; - Ecore_List* mime_type_actions; - char* key; - int i=0; - char type[100]; - char* pos; - entropy_mime_action* action; - - printf("Loading core config...\n"); - - /*Set some defaults*/ - mime_type_actions = ecore_list_new(); - ecore_list_append(mime_type_actions, "image/jpeg:exhibit"); - ecore_list_append(mime_type_actions, "image/png:exhibit"); - ecore_list_append(mime_type_actions, "image/gif:exhibit"); - ecore_list_append(mime_type_actions, "text/html:firefox"); - ecore_list_append(mime_type_actions, "text/csrc:gvim"); - ecore_list_append(mime_type_actions, "audio/x-mp3:xmms"); - ecore_list_append(mime_type_actions, "video/x-ms-wmv:mplayer"); - ecore_list_append(mime_type_actions, "video/mpeg:mplayer"); - ecore_list_append(mime_type_actions, "application/msword:abiword"); - ecore_list_append(mime_type_actions, "application/vnd.ms-excel:gnumeric"); - ecore_list_append(mime_type_actions, "video/x-msvideo:mplayer"); - - new_count = ecore_list_nodes(mime_type_actions); - - if ( (!(count = entropy_config_int_get("core","mime_type_count"))) || count < new_count ) { - - - entropy_config_int_set("core", "mime_type_count", new_count); - printf("Setting up initial mime types, writing %d (old was %d)..\n", new_count,count); - - while ( (key = ecore_list_remove_first(mime_type_actions))) { - snprintf(type,50,"mimetype_action.%d", i); - - entropy_config_str_set("core", type, key); - printf("Wrote '%s' \n", key); - - i++; - } - - ecore_list_destroy(mime_type_actions); - } - - - count = entropy_config_int_get("core","mime_type_count"); - printf("Have to load %d mime entries..\n", count); - - new_count=0; - while (new_count < count) { - snprintf(type,50,"mimetype_action.%d", new_count); - key = entropy_config_str_get("core", type); - pos = strrchr(key, ':'); - - printf("Key is: '%s'\n", key); - - if (pos >= 0) { - *pos = '\0'; - printf("Loading '%s', is '%s' -> '%s'\n", type, key, pos+1); - - action = entropy_malloc(sizeof(entropy_mime_action)); - action->executable = strdup(pos+1); - - ecore_hash_set(core_core->mime_action_hint, strdup(key), action); - - } - free(key); - - new_count++; - } - - - - - + /*DEPRECATED*/ } void entropy_core_config_save() { - Ecore_List* keys; - int count; - char key[100]; - char executable[256]; - char* gkey; - int i=0; - - - - /*Save the mime_action config*/ - keys = ecore_hash_keys(core_core->mime_action_hint); - count = ecore_list_nodes(keys); - - /*Set the count of mime_types*/ - entropy_config_int_set("core","mime_type_count", count); - - /*Write the types*/ - while ( (gkey = ecore_list_remove_first(keys)) ) { - snprintf(key, 100, "mimetype_action.%d", i); - - snprintf(executable,256,"%s:%s", gkey, - ((entropy_mime_action*)ecore_hash_get(core_core->mime_action_hint, gkey))->executable); - - printf("Saving '%s' for '%s' using '%s'\n", - ((entropy_mime_action*)ecore_hash_get(core_core->mime_action_hint, gkey))->executable, gkey, key); - - entropy_config_str_set("core", key, executable); - - i++; - } - - - + /*DEPRECATED*/ } Entropy_Config_Mime_Binding_Action* entropy_core_mime_hint_get(char* mime_type, int key) { @@ -659,6 +530,10 @@ return "entropy_gui_event_thumbnail_available"; } else if (!strcmp(event, ENTROPY_GUI_EVENT_USER_INTERACTION_YES_NO_ABORT)) { return "entropy_gui_event_user_interaction_yes_no_abort"; + } else if (!strcmp(event, ENTROPY_GUI_EVENT_FILE_METADATA)) { + return "entropy_gui_event_file_metadata"; + } else if (!strcmp(event, ENTROPY_GUI_EVENT_FILE_METADATA_AVAILABLE)) { + return "entropy_gui_event_file_metadata_available"; } else { return ""; } @@ -776,11 +651,22 @@ plugin->gui_event_callback_p = gui_event_callback; //printf ("SETTING ACTION callback at : %p\n", gui_event_callback); + } else if (type == ENTROPY_PLUGIN_METADATA_READ) { + entropy_gui_component_instance* instance; + + /*Initializing..*/ + entropy_plugin_init = dlsym(plugin->dl_ref, "entropy_plugin_init"); + instance = (*entropy_plugin_init)(core); + instance->plugin = plugin; + + gui_event_callback = dlsym(plugin->dl_ref, "gui_event_callback"); + plugin->gui_event_callback_p = gui_event_callback; } + return 0; } @@ -1008,7 +894,7 @@ if (!el) { /*No-one cares about this event - perhaps we shouldn't exit here. The caller may still want it to run*/ - //printf("entropy_core: Nobody registered to receive this event\n"); + printf("entropy_core: Nobody registered to receive this event\n"); entropy_free(event); return; } @@ -1016,17 +902,16 @@ if (!strcmp(event->event_type,ENTROPY_GUI_EVENT_FOLDER_CHANGE_CONTENTS)) { - entropy_plugin* plugin; - entropy_notify_event *ev; - - entropy_file_request* request = entropy_malloc(sizeof(entropy_file_request)); - /*A folder request's data is an entropy_generic_file*/ + entropy_notify_event *ev = entropy_notify_event_new(); + Ecore_List* res; + entropy_file_request* request = entropy_malloc(sizeof(entropy_file_request)); - //printf("File says: %s %s\n", ((entropy_generic_file*)event->data)->path, ((entropy_generic_file*)event->data)->filename); - /*Check if we need to put a slash between the path/file*/ + ev->event_type = ENTROPY_NOTIFY_FILELIST_REQUEST; + ev->processed = 1; + /*Check if we need to put a slash between the path/file*/ if (((entropy_file_request*)event->data)->drill_down) { printf("Request for drill down\n"); } @@ -1037,34 +922,39 @@ request->file_type = FILE_ALL; request->drill_down = ((entropy_file_request*)event->data)->drill_down; - - /*FIXME We should get the caller's current file plugin from the caller - i.e. the gui instance*/ - plugin = entropy_plugins_type_get_first(ENTROPY_PLUGIN_BACKEND_FILE ,ENTROPY_PLUGIN_SUB_TYPE_ALL); - - - /*Make our new event for notification*/ - ev = entropy_notify_request_register(instance->core->notify, instance, ENTROPY_NOTIFY_FILELIST_REQUEST, - plugin, "filelist_get", request, - NULL); + ev->data = request; - ecore_list_goto_first(el); - while ( (iter = ecore_list_next(el)) ) { - if (iter->active) entropy_notify_event_callback_add(ev, (void*)iter->plugin->gui_event_callback_p, iter); - } - /*Add the obj to be nuked once we've executed*/ - entropy_notify_event_cleanup_add(ev, request); - - /*Tell the notify engine we're ready to run*/ - entropy_notify_event_commit(instance->core->notify, ev); + /*HACK/FIXME - see what happens if we expire events - this should be on request*/ + printf("************* Calling interceptor..\n"); + entropy_notify_event_expire_requestor_layout(instance); + + + res = entropy_plugin_filesystem_filelist_get(request); + ev->return_struct = res; + + if (res) { + ecore_list_goto_first(el); + while ( (iter = ecore_list_next(el)) ) { + if (iter->active) (*iter->plugin->gui_event_callback_p) + (ev, + iter, + res, /*An ecore_list of files*/ + iter); + + } + } /*Nuke the file_request object that was passed to us*/ free(event->data); + entropy_notify_event_destroy(ev); + free(request); } else if (!strcmp(event->event_type,ENTROPY_GUI_EVENT_FILE_CHANGE)) { entropy_notify_event* ev = entropy_notify_event_new(); ev->event_type = ENTROPY_NOTIFY_FILE_CHANGE; + ev->processed = 1; //printf("Sending a file change event...\n"); @@ -1082,12 +972,10 @@ } else if (!strcmp(event->event_type,ENTROPY_GUI_EVENT_FILE_CREATE)) { entropy_notify_event* ev = entropy_notify_event_new(); ev->event_type = ENTROPY_NOTIFY_FILE_CREATE; + ev->processed = 1; - printf("Create event at notify_event\n"); - ecore_list_goto_first(el); while ( (iter = ecore_list_next(el)) ) { - printf ("Notifying %p of create event\n", iter); if (iter->active) (*iter->plugin->gui_event_callback_p) (ev, iter, @@ -1099,6 +987,7 @@ } else if (!strcmp(event->event_type,ENTROPY_GUI_EVENT_FILE_REMOVE)) { entropy_notify_event* ev = entropy_notify_event_new(); ev->event_type = ENTROPY_NOTIFY_FILE_REMOVE; + ev->processed = 1; //printf("Sending a file create event...\n"); @@ -1115,6 +1004,7 @@ } else if (!strcmp(event->event_type,ENTROPY_GUI_EVENT_FILE_REMOVE_DIRECTORY)) { entropy_notify_event* ev = entropy_notify_event_new(); ev->event_type = ENTROPY_NOTIFY_FILE_REMOVE_DIRECTORY; + ev->processed = 1; //printf("Sending a file create event...\n"); @@ -1133,6 +1023,7 @@ entropy_notify_event* ev = entropy_notify_event_new(); ev->event_type = ENTROPY_NOTIFY_FILE_ACTION; ev->key = event->key; + ev->processed = 1; //printf ("Requested an action execute\n"); @@ -1149,10 +1040,29 @@ instance); } entropy_notify_event_destroy(ev); + + } else if (!strcmp(event->event_type,ENTROPY_GUI_EVENT_FILE_METADATA)) { + entropy_notify_event* ev = entropy_notify_event_new(); + ev->event_type = ENTROPY_NOTIFY_FILE_METADATA_REQUEST; + ev->key = event->key; + ev->processed = 1; + + + /*Call the requestors*/ + ecore_list_goto_first(el); + while ( (iter = ecore_list_next(el)) ) { + //printf( "Calling callback at : %p\n", iter->plugin->gui_event_callback_p); + + if (iter->active) (*iter->plugin->gui_event_callback_p) + (ev, + instance, /*We use instance here, because the action runner needs to know the caller*/ + event->data, /*An entropy_generic_file*/ + instance); + } + entropy_notify_event_destroy(ev); } else if (!strcmp(event->event_type,ENTROPY_GUI_EVENT_FILE_STAT)) { - entropy_plugin* plugin; - entropy_notify_event *ev; + entropy_notify_event *ev = entropy_notify_event_new(); entropy_file_request* request = entropy_malloc(sizeof(entropy_file_request)); /*Set up the request..*/ @@ -1160,28 +1070,31 @@ request->core = instance->core; request->requester = instance->layout_parent; /*--------------------------------------------*/ - - //printf ("Requested a stat on a file...md5 %s, pointer %p, path '%s', filename '%s'\n", ((entropy_generic_file*)event->data)->md5, ((entropy_generic_file*)event->data), ((entropy_generic_file*)event->data)->path, ((entropy_generic_file*)event->data)->filename ); - /*FIXME We should get the caller's current file plugin from the caller - i.e. the gui instance*/ - plugin = entropy_plugins_type_get_first(ENTROPY_PLUGIN_BACKEND_FILE ,ENTROPY_PLUGIN_SUB_TYPE_ALL); - - /*Make our new event for notification*/ - ev = entropy_notify_request_register(instance->core->notify, instance, ENTROPY_NOTIFY_FILE_STAT_EXECUTED, - plugin, "filestat_get", request , - NULL); + ev->event_type = ENTROPY_NOTIFY_FILE_STAT_EXECUTED; + ev->processed = 1; + entropy_plugin_filesystem_filestat_get(request); + ecore_list_goto_first(el); while ( (iter = ecore_list_next(el)) ) { - if (iter->active) entropy_notify_event_callback_add(ev, (void*)iter->plugin->gui_event_callback_p, iter); + if (iter->active) (*iter->plugin->gui_event_callback_p) + (ev, + iter, + NULL, /*An entropy_file_stat*/ + iter); + } - /*Tell the notify engine we're ready to run*/ - entropy_notify_event_commit(instance->core->notify, ev); + entropy_free(request); + entropy_notify_event_destroy(ev); } else if (!strcmp(event->event_type,ENTROPY_GUI_EVENT_FILE_STAT_AVAILABLE)) { entropy_notify_event* ev = entropy_notify_event_new(); ev->event_type = ENTROPY_NOTIFY_FILE_STAT_AVAILABLE; + ev->return_struct = event->data; + if (event->data) ev->data = ((entropy_file_stat*)event->data)->file; + ev->processed = 1; //printf ("Stat available for consumption - %p\n", event->data); @@ -1204,6 +1117,8 @@ } else if (!strcmp(event->event_type,ENTROPY_GUI_EVENT_THUMBNAIL_AVAILABLE)) { entropy_notify_event* ev = entropy_notify_event_new(); ev->event_type = ENTROPY_NOTIFY_THUMBNAIL_REQUEST; + ev->return_struct = event->data; + ev->processed = 1; /*Call the requestors*/ @@ -1219,6 +1134,26 @@ } entropy_notify_event_destroy(ev); + /*A metadata object has been made available*/ + } else if (!strcmp(event->event_type,ENTROPY_GUI_EVENT_FILE_METADATA_AVAILABLE)) { + entropy_notify_event* ev = entropy_notify_event_new(); + ev->event_type = ENTROPY_NOTIFY_FILE_METADATA_AVAILABLE; + ev->return_struct = event->data; + ev->processed = 1; + + /*Call the requestors*/ + ecore_list_goto_first(el); + while ( (iter = ecore_list_next(el)) ) { + //printf( "Calling callback at : %p\n", iter->plugin->gui_event_callback_p); + + if (iter->active) (*iter->plugin->gui_event_callback_p) + (ev, + iter, + event->data, /*An ecore_list of Entropy_Metadata_Object*/ + iter); + } + entropy_notify_event_destroy(ev); + } else if (!strcmp(event->event_type,ENTROPY_GUI_EVENT_FOLDER_CHANGE_CONTENTS_EXTERNAL)) { Ecore_List* file_list; @@ -1226,6 +1161,7 @@ entropy_notify_event* ev = entropy_notify_event_new(); ev->event_type = ENTROPY_NOTIFY_FILELIST_REQUEST_EXTERNAL; + ev->processed = 1; /*The first thing in the calling event data (an ecore_list) is the original request*/ @@ -1237,6 +1173,8 @@ /*Assign the file request to the outgoing event data*/ ev->data = request; + ev->return_struct = file_list; + /*Now get rid of the request, so we're left with a virginal list of files*/ ecore_list_remove_first(file_list); @@ -1260,6 +1198,7 @@ } else if (!strcmp(event->event_type,ENTROPY_GUI_EVENT_FILE_PROGRESS)) { entropy_notify_event* ev = entropy_notify_event_new(); ev->event_type = ENTROPY_NOTIFY_FILE_PROGRESS; + ev->processed = 1; @@ -1278,6 +1217,7 @@ } else if (!strcmp(event->event_type, ENTROPY_GUI_EVENT_USER_INTERACTION_YES_NO_ABORT)) { entropy_notify_event* ev = entropy_notify_event_new(); ev->event_type = ENTROPY_NOTIFY_USER_INTERACTION_YES_NO_ABORT; + ev->processed = 1; /*Call the requestors*/ ecore_list_goto_first(el); @@ -1308,6 +1248,10 @@ *lc = (unsigned char)tolower((unsigned char)*lc); } +char* md5_entropy_local_file(char* filename) +{ + return md5_entropy_path_file("file",filename,""); +} char* md5_entropy_path_file(char* plugin, char* folder, char* filename) { char* md5; @@ -1321,7 +1265,10 @@ /*printf("MD5'ing %s %s\n", path, filename);*/ - snprintf(full_name, 1024, "%s%s%s", plugin, folder, filename); + if (strlen(filename)) + snprintf(full_name, 1024, "%s%s/%s", plugin, folder, filename); + else + snprintf(full_name, 1024, "%s%s", plugin, folder); md5_init(&state); md5_append(&state, (const md5_byte_t*)full_name, strlen(full_name)); @@ -1340,9 +1287,7 @@ { Ecore_List* ret = NULL; - LOCK(&core_core->file_cache_mutex); ret = ecore_hash_keys(core_core->file_interest_list); - UNLOCK(&core_core->file_cache_mutex); return ret; } @@ -1350,23 +1295,19 @@ void entropy_core_file_cache_add(char* md5, entropy_file_listener* listener) { - LOCK(&core_core->file_cache_mutex); if (!ecore_hash_get(core_core->file_interest_list, md5)) { ecore_hash_set(core_core->file_interest_list, md5, listener); } else { printf("*** BAD: Called set-reference with file already cached!\n"); - UNLOCK(&core_core->file_cache_mutex); entropy_core_file_cache_add_reference(md5); - LOCK(&core_core->file_cache_mutex); } entropy_generic_file_uri_set(listener->file); file_cache_size++; /*printf("File cache goes to %ld\n", file_cache_size);*/ - UNLOCK(&core_core->file_cache_mutex); } @@ -1379,7 +1320,6 @@ void entropy_core_file_cache_add_reference(char* md5) { - LOCK(&core_core->file_cache_mutex); entropy_file_listener* listener = ecore_hash_get(core_core->file_interest_list, md5); if (listener) { @@ -1388,17 +1328,18 @@ /*At this point, check if the file needs a uri generating.. * And generate if necesary */ entropy_generic_file_uri_set(listener->file); + + //printf("+ Ref count for '%s/%s' -> %d..\n", listener->file->path, listener->file->filename, listener->count); } - UNLOCK(&core_core->file_cache_mutex); } void entropy_core_file_cache_remove_reference(char* md5) { - LOCK(&core_core->file_cache_mutex); - entropy_file_listener* listener = ecore_hash_get(core_core->file_interest_list, md5); if (listener) { listener->count--; + + //printf("- Ref count for '%s/%s' -> %d..\n", listener->file->path, listener->file->filename, listener->count); if (listener->count <= 0) { ecore_hash_remove(core_core->uri_reference_list, listener->file->uri); @@ -1414,17 +1355,14 @@ } } - UNLOCK(&core_core->file_cache_mutex); } entropy_file_listener* entropy_core_file_cache_retrieve(char* md5) { entropy_file_listener* listen; - LOCK(&core_core->file_cache_mutex); listen = ecore_hash_get(core_core->file_interest_list, md5); - UNLOCK(&core_core->file_cache_mutex); return listen; } @@ -1634,15 +1572,11 @@ void* entropy_malloc(size_t size) { - requests++; - - //printf(" ********************** %d requests for mem (UP)\n", requests); return calloc(1,size); } void entropy_free(void* ref) { if (ref) { - requests--; //printf(" ********************** %d requests for mem (DOWN)\n", requests); free(ref); } else { =================================================================== RCS file: /cvs/e/e17/proto/entropy/src/entropy_file.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -3 -r1.9 -r1.10 --- entropy_file.c 21 Feb 2006 11:28:54 -0000 1.9 +++ entropy_file.c 28 Mar 2006 10:31:14 -0000 1.10 @@ -10,12 +10,12 @@ bzero(file->mime_type, MIME_LENGTH); allocated_files++; - print_allocation(); return file; } void entropy_generic_file_destroy(entropy_generic_file* file) { + /*printf("Cleaning '%s/%s' => %p (%p)\n", file->path, file->filename, file, file->mime_type);*/ if (file->thumbnail) { entropy_thumbnail_destroy(file->thumbnail); } @@ -36,7 +36,6 @@ entropy_free(file); allocated_files -= 1; - print_allocation(); } void entropy_generic_file_uri_set(entropy_generic_file* file) { =================================================================== RCS file: /cvs/e/e17/proto/entropy/src/entropy_thumbnailer_engine.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- entropy_thumbnailer_engine.c 2 Jan 2006 09:05:41 -0000 1.2 +++ entropy_thumbnailer_engine.c 28 Mar 2006 10:31:14 -0000 1.3 @@ -9,7 +9,7 @@ } entropy_thumbnail_request* entropy_thumbnail_request_new() { - return calloc(1, sizeof(entropy_thumbnail_request)); + return entropy_malloc(sizeof(entropy_thumbnail_request)); } void entropy_thumbnail_request_destroy(entropy_thumbnail_request* request) { =================================================================== RCS file: /cvs/e/e17/proto/entropy/src/main.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- main.c 20 Feb 2006 06:48:35 -0000 1.4 +++ main.c 28 Mar 2006 10:31:14 -0000 1.5 @@ -8,11 +8,19 @@ #include "entropy_alert.h" #include <Ecore_X.h> +#include <execinfo.h> + void entropy_sigseg_act(int x, siginfo_t *info, void *data) { + void* array[255]; + size_t size; + write(2, "**** SEGMENTATION FAULT ****\n", 29); write(2, "**** Printing Backtrace... *****\n\n", 34); + + size = backtrace(array, 255); + backtrace_symbols_fd(array, size, 2); ecore_x_pointer_ungrab(); ecore_x_keyboard_ungrab(); =================================================================== RCS file: /cvs/e/e17/proto/entropy/src/notification_engine.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- notification_engine.c 12 Jan 2006 09:16:08 -0000 1.8 +++ notification_engine.c 28 Mar 2006 10:31:14 -0000 1.9 @@ -1,10 +1,8 @@ #include "entropy.h" #include "notification_engine.h" -#include <pthread.h> #include <stdlib.h> #include <dlfcn.h> - entropy_notification_engine* entropy_notification_engine_init() { entropy_notification_engine* notify = entropy_malloc(sizeof(entropy_notification_engine)); @@ -12,16 +10,10 @@ notify->op_queue = ecore_list_new(); notify->exe_queue = ecore_list_new(); - notify->terminate = 0; - pthread_mutex_init(¬ify->op_queue_mutex, NULL); - pthread_mutex_init(¬ify->loop_mutex, NULL); - pthread_mutex_init(¬ify->exe_queue_mutex, NULL); - //printf("Initializing the notify engine..\n"); notify->server = ecore_ipc_server_connect(ECORE_IPC_LOCAL_USER, IPC_TITLE, 0, NULL); - - notify->notify_thread_id = pthread_create(¬ify->notify_thread, NULL, entropy_notify_loop, (void*)notify); + /*notify->notify_thread_id = pthread_create(¬ify->notify_thread, NULL, entropy_notify_loop, (void*)notify);*/ return notify; } @@ -35,7 +27,6 @@ /*Wait for thread to finish*/ printf("Waiting for notify thread to finish..\n"); - pthread_mutex_lock(&engine->loop_mutex); printf("..Terminated\n"); ecore_list_goto_first(engine->op_queue); @@ -91,73 +82,70 @@ } -void* entropy_notify_loop(void* data) { +int entropy_notify_loop(void* data) { entropy_notification_engine* notify = (entropy_notification_engine*)data; entropy_notify_event* next; int rc; - void* (*call_func)(void* arg); - pthread_mutex_lock(¬ify->loop_mutex); - - while (!notify->terminate) { + ecore_list_goto_first (notify->op_queue); + if ( (next = ecore_list_next(notify->op_queue)) ) { + next->processed = 1; - /*Lock the mutex*/ - rc = pthread_mutex_lock(¬ify->op_queue_mutex); - if (rc) { - perror("pthread_mutex_lock: entropy_notify_loop"); - pthread_exit(NULL); - } - ecore_list_goto_first (notify->op_queue); - if ( (next = ecore_list_next(notify->op_queue)) ) { - pthread_mutex_unlock(¬ify->op_queue_mutex); - - /*printf ("*************************************** Notify loop - Processing event..\n"); - printf("Calling function '%s'\n", next->function);*/ - call_func = dlsym(next->plugin->dl_ref, next->function); + /*printf ("*************************************** Notify loop - Processing event..\n"); */ + /*printf("Calling function '%s'\n", next->function);*/ + call_func = dlsym(next->plugin->dl_ref, next->function); + next->return_struct = (*call_func)(next->data); + /*Relock to remove next*/ + ecore_list_remove_first(notify->op_queue); - next->return_struct = (*call_func)(next->data); + ecore_list_append(notify->exe_queue, next); - /*printf ("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Called\n");*/ + ecore_ipc_server_send(notify->server, ENTROPY_IPC_EVENT_CORE, 6, 0, 0, 0, NULL, 0); + } else { + } + - /*Relock to remove next*/ - rc = pthread_mutex_lock(¬ify->op_queue_mutex); - if (rc) { - perror("pthread_mutex_lock: entropy_notify_loop"); - pthread_exit(NULL); - } - ecore_list_remove_first(notify->op_queue); - pthread_mutex_unlock(¬ify->op_queue_mutex); - + return 1; +} - - +void entropy_notify_event_expire_requestor_layout(void* requestor) +{ + /*HACK - assume the requestor is an entropy_gui_component_instance* - + * safe for now - but we commit ourselves here*/ - /*Lock the mutex for the exe queue*/ - pthread_mutex_lock(¬ify->exe_queue_mutex); - ecore_list_append(notify->exe_queue, next); - - ecore_ipc_server_send(notify->server, ENTROPY_IPC_EVENT_CORE, 6, 0, 0, 0, NULL, 0); - pthread_mutex_unlock(¬ify->exe_queue_mutex); + entropy_notification_engine* engine = entropy_core_get_core()->notify; + entropy_gui_component_instance* instance = requestor; + entropy_gui_component_instance* layout = instance->layout_parent; + entropy_notify_event* ev; - - + ecore_list_goto_first(engine->op_queue); + ev = ecore_list_current(engine->op_queue); + while ( ev) { + if ( ((entropy_gui_component_instance*)ev->requestor_data)->layout_parent == layout) { + if (!ev->processed) { + ecore_list_remove(engine->op_queue); + entropy_notify_event_destroy(ev); + + printf("Removed event, unprocessed: %p\n", ev); + + ev = ecore_list_current(engine->op_queue); + } else { + printf("Left event, processed: %p\n", ev); + + ev = ecore_list_next(engine->op_queue); + } } else { - pthread_mutex_unlock(¬ify->op_queue_mutex); - /*printf("Notify loop - nothing to do.,.\n");*/ + printf("Left event, different layout: %p\n", ev); + + ev = ecore_list_next(engine->op_queue); } - - - usleep(5000); /*Allow the CPU to have a rest*/ } - - pthread_mutex_unlock(¬ify->loop_mutex); - pthread_exit(NULL); } entropy_notify_event* entropy_notify_request_register(entropy_notification_engine* notify, void* requestor, int event_type, entropy_plugin* request_plugin, char* request_function, void* request_data, Ecore_List* cleanup) { @@ -199,8 +187,75 @@ entropy_notify_event_cb_data* cb_data; void *clean; + /*Remove any file references*/ + if (eevent->data) { + switch (eevent->event_type) { + case ENTROPY_NOTIFY_FILELIST_REQUEST_EXTERNAL: + case ENTROPY_NOTIFY_FILELIST_REQUEST: { + } + break; + + case ENTROPY_NOTIFY_THUMBNAIL_REQUEST: { + /*Remove ref to thumbnail's file*/ + entropy_file_request* req = eevent->data; + + + //printf("De-refing for thumbnail:\n"); + entropy_core_file_cache_remove_reference ( + req->file->md5); + + } + break; + + case ENTROPY_NOTIFY_FILE_STAT_AVAILABLE: { + /*Remove a reference to the calling file*/ + entropy_generic_file* file = eevent->data; + + + //printf("Derefing for stat..\n"); + entropy_core_file_cache_remove_reference ( + file->md5); + } + break; + + } + } + /*Cleanup the return struct*/ + if (eevent->return_struct) { + switch (eevent->event_type) { + case ENTROPY_NOTIFY_FILELIST_REQUEST_EXTERNAL: + case ENTROPY_NOTIFY_FILELIST_REQUEST: { + Ecore_List* list = eevent->return_struct; + entropy_generic_file* file; + + //printf("Freeing files at return struct for filelist..\n"); + + /*It's a filelist request - return is an ecore list - destroy*/ + while ((file = ecore_list_remove_first(list))) { + entropy_core_file_cache_remove_reference (file->md5); + } + ecore_list_destroy(eevent->return_struct); + } + break; + + case ENTROPY_NOTIFY_THUMBNAIL_REQUEST: { + } + break; + + case ENTROPY_NOTIFY_FILE_STAT_AVAILABLE: { + + } + break; + + default: + printf("Event type: %d\n", eevent->event_type); + break; + } + } + + /*This is potentially bad - we need some way to identify what we are freeing*/ ecore_list_goto_first(eevent->cb_list); while ( (cb_data = ecore_list_next(eevent->cb_list)) ) { entropy_free(cb_data); @@ -208,7 +263,6 @@ /*Nuke our cleanup objs*/ - ecore_list_goto_first(eevent->cleanup_list); while ( (clean = ecore_list_next(eevent->cleanup_list))) { entropy_free(clean); @@ -219,9 +273,6 @@ entropy_free(eevent); - allocated_events--; - print_allocation(); - } @@ -240,22 +291,19 @@ -void entropy_notify_event_commit(entropy_notification_engine* engine, entropy_notify_event* ev) { +void entropy_notify_event_commit(entropy_notify_event* ev) { + entropy_notification_engine* engine = entropy_core_get_core()->notify; - pthread_mutex_lock(&engine->op_queue_mutex); ecore_list_append(engine->op_queue, ev); - pthread_mutex_unlock(&engine->op_queue_mutex); } void entropy_notify_event_bulk_commit(entropy_notification_engine* engine, Ecore_List* list) { entropy_notify_event* ev; - pthread_mutex_lock(&engine->op_queue_mutex); while ( (ev = ecore_list_remove_first(list))) { ecore_list_append(engine->op_queue, ev); } - pthread_mutex_unlock(&engine->op_queue_mutex); ecore_list_destroy(list); @@ -266,11 +314,18 @@ void entropy_notify_lock_loop(entropy_notification_engine* notify) { - pthread_mutex_lock(¬ify->op_queue_mutex); } void entropy_notify_unlock_loop(entropy_notification_engine* notify) { - pthread_mutex_unlock(¬ify->op_queue_mutex); } + +void entropy_notify_lock_malloc() +{ +} + +void entropy_notify_unlock_malloc() +{ +} + =================================================================== RCS file: /cvs/e/e17/proto/entropy/src/plugin_helper.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- plugin_helper.c 14 Mar 2006 13:05:40 -0000 1.10 +++ plugin_helper.c 28 Mar 2006 10:31:14 -0000 1.11 @@ -115,6 +115,34 @@ return plugin_list; } +Ecore_List* entropy_plugin_filesystem_filelist_get(entropy_file_request* request) +{ + entropy_plugin* plugin; + Ecore_List* (*list_func)(entropy_file_request* request); + Ecore_List* ret; + + /*FIXME We should get the caller's current file plugin from the caller - i.e. the gui instance*/ + plugin = entropy_plugins_type_get_first(ENTROPY_PLUGIN_BACKEND_FILE ,ENTROPY_PLUGIN_SUB_TYPE_ALL); + list_func = dlsym(plugin->dl_ref, "filelist_get"); + + ret = (*list_func)(request); + + return ret; + +} + +void entropy_plugin_filesystem_filestat_get(entropy_file_request* request) +{ + entropy_plugin* plugin; + Ecore_List* (*stat_func)(entropy_file_request* request); + + /*FIXME We should get the caller's current file plugin from the caller - i.e. the gui instance*/ + plugin = entropy_plugins_type_get_first(ENTROPY_PLUGIN_BACKEND_FILE ,ENTROPY_PLUGIN_SUB_TYPE_ALL); + stat_func = dlsym(plugin->dl_ref, "filestat_get"); + + (*stat_func)(request); +} + void entropy_plugin_filesystem_file_remove(entropy_generic_file* file, entropy_gui_component_instance* instance) { entropy_plugin *plugin = entropy_plugins_type_get_first ( ------------------------------------------------------- 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