Enlightenment CVS committal

Author  : chaos
Project : e17
Module  : libs/epsilon

Dir     : e17/libs/epsilon/src/lib


Modified Files:
        Epsilon.c Makefile.am 


Log Message:
* First commit of the plugin architecture (needs some work on mime identify), 
and the xine video thumbnailer

===================================================================
RCS file: /cvs/e/e17/libs/epsilon/src/lib/Epsilon.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -3 -r1.25 -r1.26
--- Epsilon.c   17 Jan 2006 08:50:19 -0000      1.25
+++ Epsilon.c   30 Apr 2006 13:44:38 -0000      1.26
@@ -1,4 +1,5 @@
 #include "Epsilon.h"
+#include "epsilon_plugin.h"
 #include "../config.h"
 #define X_DISPLAY_MISSING 1
 #include <Imlib2.h>
@@ -10,6 +11,8 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include <errno.h>
+#include <dirent.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include "md5.h"
@@ -23,9 +26,18 @@
 #define THUMB_SIZE_LARGE 256
 #include "exiftags/exif.h"
 
+#include <Emotion.h>
+#include <Ecore.h>
+
 #include <Evas.h>
 #include <Ecore_Evas.h>
 #include <Edje.h>
+#include <dlfcn.h>
+
+#include <xine.h>
+#include <xine/xineutils.h>
+
+static Ecore_Hash* plugins_mime;
 
 extern int epsilon_info_exif_props_as_int_get (Epsilon_Info * ei, unsigned
                                               short lvl, long prop);
@@ -86,6 +98,27 @@
       free (e);
     }
 }
+
+
+Epsilon_Plugin*
+epsilon_plugin_load(char* path)
+{
+       Epsilon_Plugin* plugin = NULL;
+       void* dl_ref;
+       Epsilon_Plugin* (*epsilon_plugin_init)();
+
+       printf ("Loading plugin '%s'...\n", path);
+
+       dl_ref = dlopen(path, RTLD_LAZY);
+       if (dl_ref) {
+               epsilon_plugin_init = dlsym(dl_ref, "epsilon_plugin_init");
+               plugin = (*epsilon_plugin_init)();
+       }
+
+       return plugin;
+}
+
+
 void
 epsilon_init (void)
 {
@@ -96,6 +129,12 @@
     ".thumbnails/large", ".thumbnails/fail"
   };
 
+   struct dirent *de;
+   char* type;
+   DIR *dir;
+   Epsilon_Plugin *plugin;
+   char plugin_path[1024];
+
   for (i = 0; i < 4; i++)
     {
       snprintf (buf, sizeof(buf), "%s/%s", getenv ("HOME"), dirs[i]);
@@ -104,6 +143,30 @@
       else
        mkdir (buf, S_IRUSR | S_IWUSR | S_IXUSR);
     }
+
+  plugins_mime = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+
+  /*Initialise plugins*/
+  dir = opendir(PACKAGE_LIB_DIR "/epsilon/plugins/");
+  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_LIB_DIR "/epsilon/plugins", de->d_name);
+
+                          if ((plugin = epsilon_plugin_load(plugin_path))) {
+                                  /*Append the mime types for this plugin*/
+                                  ecore_list_goto_first(plugin->mime_types);
+                                  while ( (type = 
ecore_list_next(plugin->mime_types))) {
+                                       ecore_hash_set(plugins_mime, type, 
plugin);
+                                  }
+                          }
+
+               }
+       }
+
+  }
+  closedir(dir);
 }
 
 void
@@ -339,6 +402,19 @@
   return (0);
 }
 
+
+/*This needs to be worked into some kind of 'mime-magic' ID 
+ * section, to work out what file type we're dealing with*/
+char* epsilon_mime_for_extension_get(char* extension)
+{
+       if ((!strcasecmp(extension, "mpg")) ||
+                       (!strcasecmp(extension, "mpeg"))) return "video/mpeg";
+       else if (!strcasecmp(extension, "wmv")) return "video/x-ms-wmv";
+       else if (!strcasecmp(extension, "avi")) return "video/x-msvideo";
+       else if (!strcasecmp(extension, "mov")) return "video/quicktime";
+       else return NULL;
+}
+
 int
 epsilon_exists (Epsilon * e)
 {
@@ -441,6 +517,9 @@
   int iw, ih;
   int tw, th;
   char outfile[PATH_MAX];
+  char* mime;
+  Epsilon_Plugin* plugin;
+
 #ifdef HAVE_EPEG_H
   Epeg_Image *im;
   Epeg_Thumbnail_Info info;
@@ -560,9 +639,10 @@
          }
       }
 
-
-    if (!tmp)
-      {
+   mime = epsilon_mime_for_extension_get( strrchr(e->src, '.')+1);  
+   if (  (plugin = ecore_hash_get(plugins_mime, mime)) ) {
+       tmp = (*plugin->epsilon_generate_thumb)(e);
+   } else {
        tmp = imlib_load_image_immediately_without_cache (e->src);
        imlib_context_set_image (tmp);
        snprintf (format, sizeof(format), "image/%s", imlib_image_format ());
===================================================================
RCS file: /cvs/e/e17/libs/epsilon/src/lib/Makefile.am,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- Makefile.am 28 Mar 2006 09:10:14 -0000      1.9
+++ Makefile.am 30 Apr 2006 13:44:38 -0000      1.10
@@ -8,7 +8,8 @@
 
 INCLUDES            = @IMLIB2_CFLAGS@ @EPEG_CFLAGS@ @PNG_CFLAGS@ 
@ECORE_CFLAGS@ @EVAS_CFLAGS@ @EDJE_CFLAGS@ \
                        -I$(top_srcdir)/src/include \
-                       -DPACKAGE_BIN_DIR=\""$(bindir)"\"
+                       -DPACKAGE_BIN_DIR=\""$(bindir)"\" \
+                       -DPACKAGE_LIB_DIR=\""$(libdir)"\"
 
 lib_LTLIBRARIES      = libepsilon.la
 include_HEADERS      = Epsilon.h 
@@ -19,6 +20,6 @@
 epsilon_thumb.c \
 $(top_srcdir)/src/common/epsilon_thumb_common.c
 
-libepsilon_la_LIBADD   = exiftags/libepsilon_exiftags.la @IMLIB2_LIBS@ 
@EPEG_LIBS@ @PNG_LIBS@ @ECORE_LIBS@ @EVAS_LIBS@ @EDJE_LIBS@
+libepsilon_la_LIBADD   = exiftags/libepsilon_exiftags.la @IMLIB2_LIBS@ 
@EPEG_LIBS@ @PNG_LIBS@ @ECORE_LIBS@ @EVAS_LIBS@ @EDJE_LIBS@ -lemotion -lxine
 libepsilon_la_DEPENDENCIES = ../config.h 
 libepsilon_la_LDFLAGS      = $(LDFLAGS) -version-info 0:1:0




-------------------------------------------------------
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
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to