Enlightenment CVS committal Author : chaos Project : e17 Module : proto
Dir : e17/proto/entropy/src Modified Files: entropy_core.c entropy_gui_event_handlers.c plugin_helper.c Log Message: * Begin migration to more rigid plugin structure, and do away with the dlopen/dlsym nastiness everywhere =================================================================== RCS file: /cvs/e/e17/proto/entropy/src/entropy_core.c,v retrieving revision 1.70 retrieving revision 1.71 diff -u -3 -r1.70 -r1.71 --- entropy_core.c 1 Apr 2006 10:05:07 -0000 1.70 +++ entropy_core.c 2 Apr 2006 05:47:38 -0000 1.71 @@ -201,7 +201,8 @@ if (!strncmp(de->d_name + strlen(de->d_name) -3, ".so", 3)) { snprintf(plugin_path, 1024,"%s/%s", PACKAGE_DATA_DIR "/plugins/", de->d_name); - + + printf("Loading '%s'...\n", plugin_path); ecore_list_append(core->plugin_list, create_plugin_object(plugin_path)); } } @@ -267,6 +268,8 @@ entropy_core_gui_event_handler_add(ENTROPY_GUI_EVENT_FOLDER_CHANGE_CONTENTS, entropy_event_handler_folder_change_handler); entropy_core_gui_event_handler_add(ENTROPY_GUI_EVENT_FILE_CHANGE, entropy_event_handler_file_change_handler); entropy_core_gui_event_handler_add(ENTROPY_GUI_EVENT_FILE_METADATA, entropy_event_handler_metadata_request_handler); + entropy_core_gui_event_handler_add(ENTROPY_GUI_EVENT_FILE_METADATA_AVAILABLE, entropy_event_handler_metadata_available_handler); + entropy_core_gui_event_handler_add(ENTROPY_GUI_EVENT_USER_INTERACTION_YES_NO_ABORT, entropy_event_handler_user_interaction_handler); //printf("\n\nDetails of thumbnailers:\n"); @@ -600,7 +603,7 @@ entropy_plugin_identify =dlsym(plugin->dl_ref, "entropy_plugin_identify"); entropy_plugin_type_get = dlsym(plugin->dl_ref, "entropy_plugin_type_get"); entropy_plugin_sub_type_get = dlsym(plugin->dl_ref, "entropy_plugin_sub_type_get"); - //printf("Plugin IDs as: '%s'\n", (*entropy_plugin_identify)()); + printf("Plugin IDs as: '%s'\n", (*entropy_plugin_identify)()); type = (*entropy_plugin_type_get)(); plugin->type = type; @@ -615,7 +618,7 @@ entropy_gui_component_instance* instance; //printf(" ----------------------- Thumbnailer Plugin, registering with engine..\n"); // - entropy_plugin_init = dlsym(plugin->dl_ref, "entropy_plugin_init"); + entropy_plugin_init = dlsym(plugin->dl_ref, "entropy_plugin_gui_instance_new"); instance = (*entropy_plugin_init)(core); instance->plugin = plugin; @@ -626,7 +629,7 @@ } else if (type == ENTROPY_PLUGIN_THUMBNAILER) { entropy_gui_component_instance* instance; - entropy_plugin_init = dlsym(plugin->dl_ref, "entropy_plugin_init"); + entropy_plugin_init = dlsym(plugin->dl_ref, "entropy_plugin_gui_instance_new"); instance = (*entropy_plugin_init)(core); instance->plugin = plugin; @@ -638,21 +641,12 @@ //printf("MIME Identifier Plugin, registering with engine..\n"); entropy_plugin_mime_register(core->mime_plugins, plugin); - /*Initializing..*/ - entropy_plugin_init = dlsym(plugin->dl_ref, "entropy_plugin_init"); - (*entropy_plugin_init)(core); - - } else if (type == ENTROPY_PLUGIN_GUI_LAYOUT) { char* id = entropy_plugin_plugin_identify(plugin); if (!strncmp(core->settings.layout_engine, id, strlen(core->settings.layout_engine))) { core->layout_plugin = entropy_plugin_layout_register(plugin); - /*Initializing..*/ - entropy_plugin_init = dlsym(plugin->dl_ref, "entropy_plugin_init"); - (*entropy_plugin_init)(core); - /*ID the global system toolkit*/ plugin->toolkit = entropy_plugin_helper_toolkit_get(plugin); @@ -667,18 +661,14 @@ plugin->gui_event_callback_p = gui_event_callback; plugin->toolkit = entropy_plugin_helper_toolkit_get(plugin); - //printf("Setting components event callback to %p\n", gui_event_callback); - } else if (type == ENTROPY_PLUGIN_BACKEND_FILE) { - entropy_plugin_init = dlsym(plugin->dl_ref, "entropy_plugin_init"); - (*entropy_plugin_init)(core); } else if (type == ENTROPY_PLUGIN_ACTION_PROVIDER) { entropy_gui_component_instance* instance; //printf ("Processing an action provider...\n"); /*Initializing..*/ - entropy_plugin_init = dlsym(plugin->dl_ref, "entropy_plugin_init"); + entropy_plugin_init = dlsym(plugin->dl_ref, "entropy_plugin_gui_instance_new"); instance = (*entropy_plugin_init)(core); instance->plugin = plugin; @@ -712,7 +702,23 @@ entropy_plugin* create_plugin_object(char* filename) { - entropy_plugin* plugin = entropy_malloc(sizeof(entropy_plugin)); + entropy_plugin* plugin; + void* dl_ref; + entropy_plugin* (*entropy_plugin_init)(entropy_core* core); + + dl_ref = dlopen(filename, RTLD_LAZY); + if (!dl_ref) { + return NULL; /*Could not open plugin*/ + } + + entropy_plugin_init = dlsym(dl_ref, ENTROPY_PLUGIN_INIT_FUNCTION); + + if (!entropy_plugin_init) + return NULL; + + plugin = (*entropy_plugin_init)(entropy_core_get_core()); + plugin->dl_ref = dl_ref; + plugin->functions.entropy_plugin_init = entropy_plugin_init; strncpy(plugin->filename, filename, 254); return plugin; @@ -971,27 +977,7 @@ } - 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)) { + if (!strcmp(event->event_type,ENTROPY_GUI_EVENT_FOLDER_CHANGE_CONTENTS_EXTERNAL)) { Ecore_List* file_list; entropy_file_request* request; @@ -1015,9 +1001,6 @@ /*Now get rid of the request, so we're left with a virginal list of files*/ ecore_list_remove_first(file_list); - - //printf ("External folder list (e.g. from evfs) ready - %p\n", event->data); - /*Call the requestors*/ ecore_list_goto_first(el); while ( (iter = ecore_list_next(el)) ) { @@ -1030,24 +1013,6 @@ iter); } entropy_notify_event_destroy(ev); - - } 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); - 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 evfs progress event*/ - iter); - } - entropy_notify_event_destroy(ev); } else { fprintf(stderr, "entropy_core: Unknown event type called\n"); =================================================================== RCS file: /cvs/e/e17/proto/entropy/src/entropy_gui_event_handlers.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- entropy_gui_event_handlers.c 1 Apr 2006 10:05:07 -0000 1.7 +++ entropy_gui_event_handlers.c 2 Apr 2006 05:47:38 -0000 1.8 @@ -1,6 +1,8 @@ #include "entropy.h" #include "entropy_gui_event_handler.h" +/*N.B. - a lot of these handlers are very similar. We may make a generic wrapper for these*/ + Entropy_Gui_Event_Handler* entropy_gui_event_handler_new( Entropy_Gui_Event_Handler_Instance_Data* (*notify_event_cb)(entropy_gui_event* event, entropy_gui_component_instance* instance), @@ -382,4 +384,64 @@ return data; } +/*----------------------------*/ + +/*Metadata (inbound) */ + +Entropy_Gui_Event_Handler* entropy_event_handler_metadata_available_handler() +{ + return entropy_gui_event_handler_new( + entropy_event_handler_metadata_available_instance_data, + entropy_event_handler_instance_data_generic_cleanup); + +} + +Entropy_Gui_Event_Handler_Instance_Data* entropy_event_handler_metadata_available_instance_data(entropy_gui_event* event, + entropy_gui_component_instance* requestor) +{ + Entropy_Gui_Event_Handler_Instance_Data* data = NULL; + entropy_notify_event* ev = NULL; + + data = entropy_malloc(sizeof(Entropy_Gui_Event_Handler_Instance_Data)); + + ev = entropy_notify_event_new(); + ev->event_type = ENTROPY_NOTIFY_FILE_METADATA_AVAILABLE; + ev->return_struct = event->data; + ev->processed = 1; + + data->notify = ev; + + + return data; +} +/*----------------------------*/ + +/*User interaction */ +Entropy_Gui_Event_Handler* entropy_event_handler_user_interaction_handler() +{ + return entropy_gui_event_handler_new( + entropy_event_handler_user_interaction_instance_data, + entropy_event_handler_instance_data_generic_cleanup); + +} + +Entropy_Gui_Event_Handler_Instance_Data* entropy_event_handler_user_interaction_instance_data(entropy_gui_event* event, + entropy_gui_component_instance* requestor) +{ + Entropy_Gui_Event_Handler_Instance_Data* data = NULL; + entropy_notify_event* ev = NULL; + + data = entropy_malloc(sizeof(Entropy_Gui_Event_Handler_Instance_Data)); + + ev = entropy_notify_event_new(); + ev->event_type = ENTROPY_NOTIFY_USER_INTERACTION_YES_NO_ABORT; + ev->return_struct = event->data; + ev->processed = 1; + + data->notify = ev; + + + return data; +} + =================================================================== RCS file: /cvs/e/e17/proto/entropy/src/plugin_helper.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -3 -r1.12 -r1.13 --- plugin_helper.c 1 Apr 2006 04:35:36 -0000 1.12 +++ plugin_helper.c 2 Apr 2006 05:47:38 -0000 1.13 @@ -177,14 +177,13 @@ void entropy_plugin_filesystem_file_remove(entropy_generic_file* file, entropy_gui_component_instance* instance) { + Entropy_Plugin_File* fileplugin; entropy_plugin *plugin = entropy_plugins_type_get_first ( ENTROPY_PLUGIN_BACKEND_FILE, ENTROPY_PLUGIN_SUB_TYPE_ALL); - - void (*del_func)(entropy_generic_file* source, entropy_gui_component_instance*); - del_func = dlsym(plugin->dl_ref, "entropy_filesystem_file_remove"); - (*del_func)(file, instance); + fileplugin = ENTROPY_PLUGIN_FILE(plugin); + (*fileplugin->file_functions.file_remove)(file, instance); } void entropy_plugin_filesystem_directory_create(entropy_generic_file* file, char* dir) ------------------------------------------------------- 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