gst_plugins_base/gst-libs/gst/pbutils/install-plugins.c
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
   142  * <para>
   142  * <para>
   143  * It is strongly recommended that vendors provide a small helper application
   143  * It is strongly recommended that vendors provide a small helper application
   144  * as interlocutor to the real installer though, even more so if command line
   144  * as interlocutor to the real installer though, even more so if command line
   145  * argument munging is required to transform the command line arguments
   145  * argument munging is required to transform the command line arguments
   146  * passed by GStreamer to the helper application into arguments that are
   146  * passed by GStreamer to the helper application into arguments that are
   147  * understood by the real installer.
   147  * understood by the reeal installer.
   148  * </para>
   148  * </para>
   149  * <para>
   149  * <para>
   150  * The helper application path defined at compile time can be overriden at
   150  * The helper application path defined at compile time can be overriden at
   151  * runtime by setting the <envar>GST_INSTALL_PLUGINS_HELPER</envar>
   151  * runtime by setting the <envar>GST_INSTALL_PLUGINS_HELPER</envar>
   152  * environment variable. This can be useful for testing/debugging purposes.
   152  * environment variable. This can be useful for testing/debugging purposes.
   353 #ifdef HAVE_CONFIG_H
   353 #ifdef HAVE_CONFIG_H
   354 #include "config.h"
   354 #include "config.h"
   355 #endif
   355 #endif
   356 
   356 
   357 #ifdef __SYMBIAN32__
   357 #ifdef __SYMBIAN32__
   358 #include <gst/gst_global.h>
   358 #include <gst_global.h>
   359 #endif
   359 #endif
   360 
   360 
   361 #include "install-plugins.h"
   361 #include "install-plugins.h"
   362 
   362 
   363 #include <gst/gstinfo.h>
   363 #include <gst/gstinfo.h>
   367 #endif
   367 #endif
   368 
   368 
   369 #ifdef HAVE_SYS_WAIT_H
   369 #ifdef HAVE_SYS_WAIT_H
   370 #include <sys/wait.h>
   370 #include <sys/wait.h>
   371 #endif
   371 #endif
   372 
       
   373 #include <string.h>
       
   374 
   372 
   375 /* best effort to make things compile and possibly even work on win32 */
   373 /* best effort to make things compile and possibly even work on win32 */
   376 #ifndef WEXITSTATUS
   374 #ifndef WEXITSTATUS
   377 # define WEXITSTATUS(status) ((((guint)(status)) & 0xff00) >> 8)
   375 # define WEXITSTATUS(status) ((((guint)(status)) & 0xff00) >> 8)
   378 #endif
   376 #endif
   393  * @ctx: a #GstInstallPluginsContext
   391  * @ctx: a #GstInstallPluginsContext
   394  * @xid: the XWindow ID (XID) of the top-level application
   392  * @xid: the XWindow ID (XID) of the top-level application
   395  *
   393  *
   396  * This function is for X11-based applications (such as most Gtk/Qt
   394  * This function is for X11-based applications (such as most Gtk/Qt
   397  * applications on linux/unix) only. You can use it to tell the external
   395  * applications on linux/unix) only. You can use it to tell the external
   398  * installer the XID of your main application window. That way the installer
   396  * the XID of your main application window, so the installer can make its
   399  * can make its own window transient to your application window during the
   397  * own window transient to your application windonw during the installation.
   400  * installation.
       
   401  *
   398  *
   402  * If set, the XID will be passed to the installer via a --transient-for=XID
   399  * If set, the XID will be passed to the installer via a --transient-for=XID
   403  * command line option.
   400  * command line option.
   404  *
   401  *
   405  * Gtk+/Gnome application should be able to obtain the XID of the top-level
   402  * Gtk+/Gnome application should be able to obtain the XID of the top-level
   510   GST_LOG ("Using plugin install helper '%s'", helper);
   507   GST_LOG ("Using plugin install helper '%s'", helper);
   511   return helper;
   508   return helper;
   512 }
   509 }
   513 
   510 
   514 static gboolean
   511 static gboolean
   515 ptr_array_contains_string (GPtrArray * arr, const gchar * s)
       
   516 {
       
   517   gint i;
       
   518 
       
   519   for (i = 0; i < arr->len; ++i) {
       
   520     if (strcmp ((const char *) g_ptr_array_index (arr, i), s) == 0)
       
   521       return TRUE;
       
   522   }
       
   523   return FALSE;
       
   524 }
       
   525 
       
   526 static gboolean
       
   527 gst_install_plugins_spawn_child (gchar ** details,
   512 gst_install_plugins_spawn_child (gchar ** details,
   528     GstInstallPluginsContext * ctx, GPid * child_pid, gint * exit_status)
   513     GstInstallPluginsContext * ctx, GPid * child_pid, gint * exit_status)
   529 {
   514 {
   530   GPtrArray *arr;
   515   GPtrArray *arr;
   531   gboolean ret;
   516   gboolean ret;
   541   if (ctx != NULL && ctx->xid != 0) {
   526   if (ctx != NULL && ctx->xid != 0) {
   542     g_snprintf (xid_str, sizeof (xid_str), "--transient-for=%u", ctx->xid);
   527     g_snprintf (xid_str, sizeof (xid_str), "--transient-for=%u", ctx->xid);
   543     g_ptr_array_add (arr, xid_str);
   528     g_ptr_array_add (arr, xid_str);
   544   }
   529   }
   545 
   530 
   546   /* finally, add the detail strings, but without duplicates */
   531   /* finally, add the detail strings */
   547   while (details != NULL && details[0] != NULL) {
   532   while (details != NULL && details[0] != NULL) {
   548     if (!ptr_array_contains_string (arr, details[0]))
   533     g_ptr_array_add (arr, details[0]);
   549       g_ptr_array_add (arr, details[0]);
       
   550     ++details;
   534     ++details;
   551   }
   535   }
   552 
   536 
   553   /* and NULL-terminate */
   537   /* and NULL-terminate */
   554   g_ptr_array_add (arr, NULL);
   538   g_ptr_array_add (arr, NULL);