Enlightenment CVS committal
Author : chaos
Project : e17
Module : apps/evfs
Dir : e17/apps/evfs/src/bin
Modified Files:
evfs_main.c evfs_operation_tasks.c evfs_server_handle.c
Log Message:
Ok, lotsa changes:
* Abstracted out the plugin architecture. Two plugins types now: Filesystem,
and metadata provider
* Added audio tagger metadata provider (based on e_taggerd by CodeWarrior). Be
warned - metadata provider file type is hardcoded to go to this plugin for now
- more later, including libextract)
* A few bug fixes, whatever ended up in this commit cycle
===================================================================
RCS file: /cvs/e/e17/apps/evfs/src/bin/evfs_main.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -3 -r1.42 -r1.43
--- evfs_main.c 15 Apr 2006 03:15:54 -0000 1.42
+++ evfs_main.c 21 Apr 2006 15:10:16 -0000 1.43
@@ -111,7 +111,7 @@
while ((key = ecore_list_remove_first(keys)))
{
plugin = ecore_hash_get(server->plugin_uri_hash, key);
- (*plugin->functions->evfs_client_disconnect) (client);
+ (*EVFS_PLUGIN_FILE(plugin)->functions->evfs_client_disconnect)
(client);
}
ecore_list_destroy(keys);
@@ -212,6 +212,10 @@
case EVFS_CMD_OPERATION_RESPONSE:
evfs_handle_operation_command(client, command);
break;
+
+ case EVFS_CMD_METADATA_RETRIEVE:
+ evfs_handle_metadata_command(client,command);
+ break;
default:
printf("Warning - unhandled command %d\n", command->type);
break;
@@ -221,26 +225,26 @@
}
evfs_plugin *
-evfs_load_plugin(char *filename)
+evfs_load_plugin_file(char *filename)
{
- evfs_plugin *plugin = NEW(evfs_plugin);
+ evfs_plugin_file *plugin = NEW(evfs_plugin_file);
char *(*evfs_plugin_uri_get) ();
evfs_plugin_functions *(*evfs_plugin_init) ();
printf("Loading plugin: %s\n", filename);
- plugin->dl_ref = dlopen(filename, RTLD_LAZY);
+ EVFS_PLUGIN(plugin)->dl_ref = dlopen(filename, RTLD_LAZY);
- if (plugin->dl_ref)
+ if (EVFS_PLUGIN(plugin)->dl_ref)
{
- evfs_plugin_uri_get = dlsym(plugin->dl_ref, "evfs_plugin_uri_get");
+ evfs_plugin_uri_get = dlsym(EVFS_PLUGIN(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");
+ evfs_plugin_init = dlsym(EVFS_PLUGIN(plugin)->dl_ref,
"evfs_plugin_init");
if (evfs_plugin_init)
{
plugin->functions = (*evfs_plugin_init) ();
@@ -261,7 +265,63 @@
goto exit_error;
}
- return plugin;
+ return EVFS_PLUGIN(plugin);
+
+ exit_error:
+ free(plugin);
+ return NULL;
+
+}
+
+evfs_plugin *
+evfs_load_plugin_meta(char *filename)
+{
+ evfs_plugin_meta *plugin = NEW(evfs_plugin_file);
+ evfs_plugin_functions_meta *(*evfs_plugin_init) ();
+ Ecore_List* (*evfs_plugin_meta_types_get)();
+ char* type;
+ Ecore_List* types;
+
+
+ printf("Loading plugin: %s\n", filename);
+ EVFS_PLUGIN(plugin)->dl_ref = dlopen(filename, RTLD_LAZY);
+
+ if (EVFS_PLUGIN(plugin)->dl_ref)
+ {
+ /*Execute the init function, if it's there.. */
+ evfs_plugin_init = dlsym(EVFS_PLUGIN(plugin)->dl_ref,
"evfs_plugin_init");
+ if (evfs_plugin_init)
+ {
+ plugin->functions = (*evfs_plugin_init) ();
+
+ /*Load meta types*/
+ evfs_plugin_meta_types_get =
dlsym(EVFS_PLUGIN(plugin)->dl_ref, "evfs_plugin_meta_types_get");
+ if (evfs_plugin_meta_types_get) {
+
+ types = (*evfs_plugin_meta_types_get)();
+ /*Register..*/
+ while ( (type = ecore_list_remove_first(types))) {
+
ecore_hash_set(evfs_server_get()->plugin_meta_hash, type, plugin);
+ printf(" Registered meta plugin for
'%s'...\n", type);
+ }
+ } else {
+ printf("Error - could not get type register function
for meta plugin");
+ }
+ } else {
+ printf
+ ("Error - plugin file does not contain init function - %s\n",
+ filename);
+ goto exit_error;
+ }
+
+ }
+ else
+ {
+ printf("Error - plugin file invalid - %s\n", filename);
+ goto exit_error;
+ }
+
+ return EVFS_PLUGIN(plugin);
exit_error:
free(plugin);
@@ -269,6 +329,7 @@
}
+
void
evfs_load_plugins()
{
@@ -283,14 +344,13 @@
{
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)))
+ if ((plugin = evfs_load_plugin_file(plugin_path)))
{
- ecore_hash_set(server->plugin_uri_hash, plugin->uri,
+ ecore_hash_set(server->plugin_uri_hash,
EVFS_PLUGIN_FILE(plugin)->uri,
plugin);
}
}
@@ -304,6 +364,31 @@
}
closedir(dir);
+ /*Load meta plugins*/
+ printf("Reading plugins from: %s\n", PACKAGE_PLUGIN_DIR "/plugins/meta");
+ dir = opendir(PACKAGE_PLUGIN_DIR "/plugins/meta");
+ 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/meta", de->d_name);
+ if ((plugin = evfs_load_plugin_meta(plugin_path)))
+ {
+ }
+ }
+ }
+ }
+ else
+ {
+ fprintf(stderr, "EVFS: Could not location plugin directory '%s'\n",
+ PACKAGE_PLUGIN_DIR "/plugins/file");
+ exit(1);
+ }
+ closedir(dir);
+
}
int
@@ -345,6 +430,7 @@
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->plugin_meta_hash = ecore_hash_new(ecore_str_hash,
ecore_str_compare);
server->clientCounter = 0;
server->incoming_command_list = ecore_list_new();
===================================================================
RCS file: /cvs/e/e17/apps/evfs/src/bin/evfs_operation_tasks.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- evfs_operation_tasks.c 9 Apr 2006 09:02:44 -0000 1.5
+++ evfs_operation_tasks.c 21 Apr 2006 15:10:16 -0000 1.6
@@ -44,13 +44,13 @@
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);
+ int fd
=(*EVFS_PLUGIN_FILE(copy->file_from->plugin)->functions->evfs_file_open)
(op->client, copy->file_from);
/*TODO: Error checking on file open fail*/
}
if (copy->file_to->fd == 0 && copy->file_to->fd_p == NULL) {
/*printf("Creating destination file..\n");*/
- (*copy->file_to->plugin->functions->evfs_file_create)
(copy->file_to);
+
(*EVFS_PLUGIN_FILE(copy->file_to->plugin)->functions->evfs_file_create)
(copy->file_to);
}
/*printf ("next_byte:size -> %lld:%lld\n", copy->next_byte,
copy->source_stat.st_size); */
@@ -63,13 +63,13 @@
(copy->source_stat.st_size - copy->next_byte);
- b_read = (*copy->file_from->plugin->functions->evfs_file_read)
(op->client,
+ b_read =
(*EVFS_PLUGIN_FILE(copy->file_from->plugin)->functions->evfs_file_read)
(op->client,
copy->file_from,
bytes,
read_write_bytes);
if (b_read > 0) {
- b_write =
(*copy->file_to->plugin->functions->evfs_file_write) (copy->file_to,
+ b_write =
(*EVFS_PLUGIN_FILE(copy->file_to->plugin)->functions->evfs_file_write)
(copy->file_to,
bytes,
b_read);
@@ -93,8 +93,8 @@
/*Check if it's time to end..*/
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_PLUGIN_FILE(copy->file_from->plugin)->functions->evfs_file_close)
(copy->file_from);
+
(*EVFS_PLUGIN_FILE(copy->file_to->plugin)->functions->evfs_file_close)
(copy->file_to);
EVFS_OPERATION_TASK(copy)->status =
EVFS_OPERATION_TASK_STATUS_COMMITTED;
}
@@ -112,7 +112,7 @@
task->file->plugin_uri);
- ret = (*task->file->plugin->functions->evfs_file_mkdir) (task->file);
+ ret =
(*EVFS_PLUGIN_FILE(task->file->plugin)->functions->evfs_file_mkdir)
(task->file);
/*TODO - handle 'fail' state*/
EVFS_OPERATION_TASK(task)->status =
EVFS_OPERATION_TASK_STATUS_COMMITTED;
@@ -126,7 +126,7 @@
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);
+ ret =
(*EVFS_PLUGIN_FILE(task->file->plugin)->functions->evfs_file_remove)
(task->file->path);
/*TODO - handle 'fail' state*/
EVFS_OPERATION_TASK(task)->status =
EVFS_OPERATION_TASK_STATUS_COMMITTED;
===================================================================
RCS file: /cvs/e/e17/apps/evfs/src/bin/evfs_server_handle.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -3 -r1.51 -r1.52
--- evfs_server_handle.c 14 Mar 2006 13:06:22 -0000 1.51
+++ evfs_server_handle.c 21 Apr 2006 15:10:16 -0000 1.52
@@ -21,7 +21,7 @@
if (plugin)
{
printf("Opening file..\n");
- return (*plugin->functions->evfs_file_open) (client, uri);
+ return (*EVFS_PLUGIN_FILE(plugin)->functions->evfs_file_open) (client,
uri);
}
else
{
@@ -39,7 +39,7 @@
if (plugin)
{
printf("Closing file..\n");
- return (*plugin->functions->evfs_file_close) (uri);
+ return (*EVFS_PLUGIN_FILE(plugin)->functions->evfs_file_close) (uri);
}
else
{
@@ -58,7 +58,7 @@
evfs_get_plugin_for_uri(client->server, uri->plugin_uri);
if (plugin)
{
- return (*plugin->functions->evfs_file_read) (client, uri, bytes, size);
+ return (*EVFS_PLUGIN_FILE(plugin)->functions->evfs_file_read) (client,
uri, bytes, size);
}
else
{
@@ -90,7 +90,7 @@
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);
+ (*EVFS_PLUGIN_FILE(plugin)->functions->evfs_monitor_start)
(client, command);
}
}
@@ -148,7 +148,7 @@
op = evfs_operation_files_new(client, root_command);
command->op = EVFS_OPERATION(op);
} else {
- op = root_command->op;
+ op = EVFS_OPERATION_FILES(root_command->op);
}
@@ -157,7 +157,7 @@
files[0]->plugin_uri);
if (plugin)
{
- (*plugin->functions->evfs_file_lstat) (command, &file_stat, 0);
+ (*EVFS_PLUGIN_FILE(plugin)->functions->evfs_file_lstat) (command,
&file_stat, 0);
/*If we're not a dir, simple remove command */
if (!S_ISDIR(file_stat.st_mode))
@@ -181,7 +181,7 @@
evfs_filereference *file = NULL;
/*First, we need a directory list... */
- (*plugin->functions->evfs_dir_list) (client, command,
+ (*EVFS_PLUGIN_FILE(plugin)->functions->evfs_dir_list)
(client, command,
&directory_list);
if (directory_list)
{
@@ -242,12 +242,12 @@
files[0]->plugin_uri);
if (plugin)
{
- printf("Pointer here: %p\n", plugin->functions->evfs_file_rename);
+ printf("Pointer here: %p\n",
EVFS_PLUGIN_FILE(plugin)->functions->evfs_file_rename);
- if (plugin->functions->evfs_file_rename)
+ if (EVFS_PLUGIN_FILE(plugin)->functions->evfs_file_rename)
{
if (command->file_command.num_files == 2)
- (*plugin->functions->evfs_file_rename) (client, command);
+ (*EVFS_PLUGIN_FILE(plugin)->functions->evfs_file_rename)
(client, command);
else
printf("ERR: Wrong number of files to rename\n");
}
@@ -266,7 +266,7 @@
files[0]->plugin_uri);
if (plugin)
{
- (*(plugin->functions->evfs_file_stat)) (command, &file_stat, 0);
+ (*(EVFS_PLUGIN_FILE(plugin)->functions->evfs_file_stat)) (command,
&file_stat, 0);
evfs_stat_event_create(client, command, &file_stat);
}
@@ -284,8 +284,8 @@
files[0]->plugin_uri);
if (plugin)
{
- printf("Pointer here: %p\n", plugin->functions->evfs_file_open);
- (*(plugin->functions->evfs_file_open)) (client,
+ printf("Pointer here: %p\n",
EVFS_PLUGIN_FILE(plugin)->functions->evfs_file_open);
+ (*(EVFS_PLUGIN_FILE(plugin)->functions->evfs_file_open)) (client,
command->file_command.files[0]);
fprintf(stderr, "Opened file, fd is: %d\n",
@@ -312,9 +312,9 @@
files[0]->plugin_uri);
if (plugin)
{
- //printf("Pointer here: %p\n", plugin->functions->evfs_file_read);
+ //printf("Pointer here: %p\n",
EVFS_PLUGIN_FILE(plugin)->functions->evfs_file_read);
b_read =
- (*(plugin->functions->evfs_file_read)) (client,
+ (*(EVFS_PLUGIN_FILE(plugin)->functions->evfs_file_read)) (client,
command->file_command.
files[0], bytes,
command->file_command.extra);
@@ -338,7 +338,7 @@
{
Ecore_List *directory_list = NULL;
- (*plugin->functions->evfs_dir_list) (client, command, &directory_list);
+ (*EVFS_PLUGIN_FILE(plugin)->functions->evfs_dir_list) (client,
command, &directory_list);
if (directory_list)
{
@@ -373,7 +373,7 @@
command->file_command.files[0]->path);
ret =
- (*plugin->functions->evfs_file_mkdir)
(command->file_command.files[0]);
+ (*EVFS_PLUGIN_FILE(plugin)->functions->evfs_file_mkdir)
(command->file_command.files[0]);
printf("....ret was %d\n", ret);
}
}
@@ -421,11 +421,11 @@
{
/*Check for supported options */
- if (!(plugin->functions->evfs_file_lstat &&
- plugin->functions->evfs_file_open &&
- dst_plugin->functions->evfs_file_create &&
- plugin->functions->evfs_file_read &&
- dst_plugin->functions->evfs_file_write))
+ if (!(EVFS_PLUGIN_FILE(plugin)->functions->evfs_file_lstat &&
+ EVFS_PLUGIN_FILE(plugin)->functions->evfs_file_open &&
+ EVFS_PLUGIN_FILE(dst_plugin)->functions->evfs_file_create &&
+ EVFS_PLUGIN_FILE(plugin)->functions->evfs_file_read &&
+ EVFS_PLUGIN_FILE(dst_plugin)->functions->evfs_file_write))
{
printf("ARGH! Copy Not supported!\n");
evfs_operation_destroy(EVFS_OPERATION(op));
@@ -433,9 +433,9 @@
}
/*Get the source file size */
- (*plugin->functions->evfs_file_lstat) (command, &file_stat, 0);
+ (*EVFS_PLUGIN_FILE(plugin)->functions->evfs_file_lstat) (command,
&file_stat, 0);
res =
- (*dst_plugin->functions->evfs_file_lstat) (command, &dest_stat, 1);
+ (*EVFS_PLUGIN_FILE(dst_plugin)->functions->evfs_file_lstat)
(command, &dest_stat, 1);
if (!S_ISDIR(file_stat.st_mode))
{
@@ -451,7 +451,7 @@
evfs_filereference_clone(command->file_command.files[1]));
/*First, we need a directory list... */
- (*plugin->functions->evfs_dir_list) (client, command,
+ (*EVFS_PLUGIN_FILE(plugin)->functions->evfs_dir_list) (client,
command,
&directory_list);
if (directory_list)
{
@@ -538,4 +538,21 @@
printf("*** Received operation response for op %ld -> %d\n",
command->op->id, command->op->response);
}
+}
+
+void evfs_handle_metadata_command(evfs_client* client, evfs_command* command)
+{
+ char* type = "audio/x-mp3";
+ evfs_plugin_meta* plugin;
+ Ecore_List* ret_list;
+
+ plugin =
EVFS_PLUGIN_META(evfs_meta_plugin_get_for_type(evfs_server_get(),type));
+ if (plugin) {
+ ret_list =
(*plugin->functions->evfs_file_meta_retrieve)(client,command);
+
+ evfs_meta_data_event_create(client,command, ret_list);
+ } else {
+ printf("Could not find plugin to tag this type\n");
+ }
+
}
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs