[totem-pl-parser] videosite: Allow looking for alternative resolution scripts



commit 1147853ac9012c085ebb1d6306451c6d197542cf
Author: Bastien Nocera <hadess hadess net>
Date:   Wed May 27 17:39:56 2015 +0200

    videosite: Allow looking for alternative resolution scripts
    
    Third-parties are allowed to install scripts or binaries in
    $(libexecdir)/totem-pl-parser/. The first script (as sorted through
    strcmp()) will be chosen to resolve all possible websites.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=749977

 plparse/Makefile.am                 |    9 +++++----
 plparse/totem-pl-parser-videosite.c |   30 ++++++++++++++++++++++++++++--
 2 files changed, 33 insertions(+), 6 deletions(-)
---
diff --git a/plparse/Makefile.am b/plparse/Makefile.am
index 949975b..688040e 100644
--- a/plparse/Makefile.am
+++ b/plparse/Makefile.am
@@ -183,10 +183,11 @@ EXTRA_DIST =                              \
        plparser-mini.symbols
 
 if HAVE_QUVI
-libexec_PROGRAMS = totem-pl-parser-videosite
-totem_pl_parser_videosite_SOURCES = videosite-parser.c
-totem_pl_parser_videosite_CFLAGS = $(QUVI_CFLAGS) -DLIBEXECDIR=\""$(libexecdir)"\"
-totem_pl_parser_videosite_LDADD = $(QUVI_LIBS)
+libexecsubdir = $(libexecdir)/totem-pl-parser/
+libexecsub_PROGRAMS = 99-totem-pl-parser-videosite
+99_totem_pl_parser_videosite_SOURCES = videosite-parser.c
+99_totem_pl_parser_videosite_CFLAGS = $(QUVI_CFLAGS) -DLIBEXECDIR=\""$(libexecdir)"\"
+99_totem_pl_parser_videosite_LDADD = $(QUVI_LIBS)
 endif
 
 # Introspection
diff --git a/plparse/totem-pl-parser-videosite.c b/plparse/totem-pl-parser-videosite.c
index 4a135fc..6cb0837 100644
--- a/plparse/totem-pl-parser-videosite.c
+++ b/plparse/totem-pl-parser-videosite.c
@@ -28,13 +28,39 @@
 #include "totem-pl-parser-videosite.h"
 #include "totem-pl-parser-private.h"
 
+/* The helper script will be either the one shipped in totem-pl-parser,
+ * when running tests, or the first non-hidden file in the totem-pl-parser
+ * libexec directory, when sorted by lexicographic ordering (through strcmp) */
 static char *
 find_helper_script (void)
 {
 #ifdef UNINSTALLED_TESTS
-       return g_strdup ("../totem-pl-parser-videosite");
+       return g_strdup ("../99-totem-pl-parser-videosite");
 #else
-       return g_strdup (LIBEXECDIR "/totem-pl-parser-videosite");
+       GDir *dir;
+       const char *name;
+       char *ret = NULL;
+
+       dir = g_dir_open (LIBEXECDIR "/totem-pl-parser", 0, NULL);
+       if (!dir)
+               goto bail;
+
+       while ((name = g_dir_read_name (dir)) != NULL) {
+               /* Skip hidden files */
+               if (name[0] == '.')
+                       continue;
+               if (ret == NULL || g_strcmp0 (name, ret) < 0) {
+                       g_free (ret);
+                       ret = g_strdup (name);
+               }
+       }
+       g_clear_pointer (&dir, g_dir_close);
+
+       if (ret != NULL)
+               return ret;
+
+bail:
+       return g_strdup (LIBEXECDIR "/totem-pl-parser/99-totem-pl-parser-videosite");
 #endif
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]