Package: gnome-volume-manager
Version: 1.5.15-1+b1
Severity: wishlist
Tags: patch upstream
I'm attaching a handler for autorun.inf files. It'll grab the pathname from
the "open" variable in "[autorun]" section and pass it to gnome_url_show ().
I think it could be useful if later such files are associated to it.
This has been submitted upstream as:
http://bugzilla.gnome.org/show_bug.cgi?id=397796
Btw, this upstream bug is marked as UNCONFIRMED. I would appreciate if someone
could confirm it.
-- System Information:
Debian Release: 4.0
APT prefers testing
APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-3-amd64
Locale: LANG=ca_AD.UTF-8, LC_CTYPE=ca_AD.UTF-8 (charmap=UTF-8)
Versions of packages gnome-volume-manager depends on:
ii gconf2 2.16.0-3 GNOME configuration database syste
ii hal 0.5.8.1-4 Hardware Abstraction Layer
ii libart-2.0-2 2.3.17-1 Library of functions for 2D graphi
ii libatk1.0-0 1.12.4-1 The ATK accessibility toolkit
ii libbonobo2-0 2.14.0-3 Bonobo CORBA interfaces library
ii libbonoboui2-0 2.14.0-5 The Bonobo UI library
ii libc6 2.3.6.ds1-8 GNU C Library: Shared libraries
ii libcairo2 1.2.4-4 The Cairo 2D vector graphics libra
ii libdbus-1-3 1.0.2-1 simple interprocess messaging syst
ii libdbus-glib-1-2 0.71-3 simple interprocess messaging syst
ii libfontconfig1 2.4.1-2 generic font configuration library
ii libgconf2-4 2.16.0-3 GNOME configuration database syste
ii libgksuui1.0-1 1.0.7-1+b1 a graphical fronted to su library
ii libglade2-0 1:2.6.0-4 library to load .glade files at ru
ii libglib2.0-0 2.12.4-2 The GLib library of C routines
ii libgnome-keyring0 0.6.0-3 GNOME keyring services library
ii libgnome2-0 2.16.0-2 The GNOME 2 library - runtime file
ii libgnomecanvas2-0 2.14.0-2 A powerful object-oriented display
ii libgnomeui-0 2.14.1-2+b1 The GNOME 2 libraries (User Interf
ii libgnomevfs2-0 2.14.2-4 GNOME virtual file-system (runtime
ii libgtk2.0-0 2.8.20-3 The GTK+ graphical user interface
ii libhal1 0.5.8.1-4 Hardware Abstraction Layer - share
ii libice6 1:1.0.1-2 X11 Inter-Client Exchange library
ii liborbit2 1:2.14.3-0.1 libraries for ORBit2 - a CORBA ORB
ii libpango1.0-0 1.14.8-4 Layout and rendering of internatio
ii libpopt0 1.10-3 lib for parsing cmdline parameters
ii libsm6 1:1.0.1-3 X11 Session Management library
ii libx11-6 2:1.0.3-4 X11 client-side library
ii libxcursor1 1.1.7-4 X cursor management library
ii libxext6 1:1.0.1-2 X11 miscellaneous extension librar
ii libxfixes3 1:4.0.1-5 X11 miscellaneous 'fixes' extensio
ii libxi6 1:1.0.1-4 X11 Input extension library
ii libxinerama1 1:1.0.1-4.1 X11 Xinerama extension library
ii libxml2 2.6.27.dfsg-1 GNOME XML library
ii libxrandr2 2:1.1.0.2-5 X11 RandR extension library
ii libxrender1 1:0.9.1-3 X Rendering Extension client libra
ii pmount 0.9.13-1+b1 mount removable devices as normal
Versions of packages gnome-volume-manager recommends:
ii gnome-media 2.14.2-4 GNOME media utilities
pn gthumb <none> (no description available)
ii nautilus-cd-burner 2.14.3-6 CD Burning front-end for Nautilus
ii totem 2.16.4-2 A simple media player for the Gnom
-- no debconf information
diff -Nur gnome-volume-manager.old/src/autorun.c
gnome-volume-manager/src/autorun.c
--- gnome-volume-manager.old/src/autorun.c 1970-01-01 01:00:00.000000000
+0100
+++ gnome-volume-manager/src/autorun.c 2007-01-17 23:11:47.000000000 +0100
@@ -0,0 +1,206 @@
+/* src/autorun.c - Handler for autorun.inf files
+ © Copyright 2007 Robert Millan <[EMAIL PROTECTED]>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ Parts of this program were copied from libgnome's gnome-open.c, which
+ is licensed under LGPL.
+*/
+
+#define _GNU_SOURCE 1 /* asprintf, getline */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <ctype.h> /* tolower, isspace */
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h> /* exit */
+#include <string.h> /* strdup */
+#include <sys/stat.h>
+#include <libgen.h> /* dirname */
+
+#include <glib.h>
+#include <libgnome/gnome-url.h>
+#include <libgnome/gnome-program.h>
+#include <libgnome/gnome-init.h>
+#include <libgnomevfs/gnome-vfs-utils.h>
+
+int
+main (int argc, char **argv)
+{
+ GError *err = NULL;
+ char *uri;
+
+ FILE *fp;
+ char *base = NULL;
+ char *tmp = NULL;
+ char *dir = NULL;
+ char *full_path = NULL;
+ size_t zero = 0;
+ int i;
+ struct stat st;
+
+ if (argc < 2)
+ {
+ fprintf (stderr, "Usage: %s <url>\n", argv[0]);
+ return 1;
+ }
+
+ fp = fopen (argv[1], "r");
+ if (fp == NULL)
+ {
+ perror ("fopen");
+ exit (1);
+ }
+
+ {
+ const char section_autorun_entry[] = "[autorun]";
+ const char section_autorun_exit[] = "\n[";
+ int section_autorun_entry_counter = 0;
+ int section_autorun_exit_counter = 0;
+
+ const char variable_open[] = "\nopen";
+ int variable_open_counter = 0;
+
+ int autorun_section_found = 0;
+
+ while (1)
+ {
+ char c;
+
+ c = getc (fp);
+ if (c == EOF)
+ {
+ if (autorun_section_found)
+ fprintf (stderr, "\"autorun\" section found, but didn't contain
an \"open\" variable.\n");
+ else
+ fprintf (stderr, "No \"autorun\" sections were found.\n");
+ exit (1);
+ }
+
+ if (section_autorun_entry[section_autorun_entry_counter] == '\0')
+ /* we're in [autorun] */
+ {
+ autorun_section_found = 1;
+
+ /* since we're in [autorun], let's check for "open" */
+ if (variable_open[variable_open_counter] == '\0')
+ {
+ /* good. now we just need to eat some whitespace and '=' */
+ if (c == '=')
+ break; /* success */
+ else if (!isspace (c))
+ variable_open_counter = 0;
+ }
+ else
+ if (variable_open[variable_open_counter] == tolower (c))
+ variable_open_counter++;
+ else
+ variable_open_counter = 0;
+
+ /* also check wether [autorun] is finished */
+ if (section_autorun_exit[section_autorun_exit_counter] == '\0')
+ section_autorun_exit_counter = section_autorun_entry_counter = 0;
+ else if (section_autorun_exit[section_autorun_exit_counter] == c)
+ section_autorun_exit_counter++;
+ else
+ section_autorun_exit_counter = 0;
+ }
+ else
+ /* we're not in [autorun]... yet. */
+ if (section_autorun_entry[section_autorun_entry_counter] == tolower
(c))
+ section_autorun_entry_counter++;
+ else
+ section_autorun_entry_counter = 0;
+ }
+ }
+
+ if (getline (&base, &zero, fp) == -1)
+ {
+ perror ("getline");
+ exit (1);
+ }
+
+ fclose (fp);
+
+ /* cleanup messy M$-style syntax :-) */
+ i = 0;
+ while (base[i] != '\0')
+ {
+ if (base[i] == '\\')
+ base[i] = '/';
+ if (base[i] == '\r')
+ {
+ base[i] = '\0';
+ break;
+ }
+ i++;
+ }
+
+ dir = dirname (argv[1]);
+ asprintf (&full_path, "%s/%s", dir, base);
+
+ if (stat (full_path, &st) == 0)
+ goto file_was_found;
+
+ /* keep a pristine copy of "base" in case we have to print it */
+ tmp = strdup (base);
+
+ /* maybe case unawareness? let's try lower */
+ i = 0;
+ while (tmp[i] != '\0')
+ tmp[i] = tolower (tmp[i++]);
+ free (full_path);
+ asprintf (&full_path, "%s/%s", dir, tmp);
+
+ if (stat (full_path, &st) == 0)
+ goto file_was_found;
+
+ /* aaargh. try upper and give up */
+ i = 0;
+ while (tmp[i] != '\0')
+ tmp[i] = toupper (tmp[i++]);
+ free (full_path);
+ asprintf (&full_path, "%s/%s", dir, tmp);
+
+ if (stat (full_path, &st) == 0)
+ goto file_was_found;
+
+ fprintf (stderr, "Can't stat \"%s\"\n", base);
+ exit (1);
+
+ file_was_found:
+
+ gnome_program_init ("gnome-url-show", VERSION,
+ LIBGNOME_MODULE,
+ argc, argv,
+ NULL);
+
+ uri = gnome_vfs_make_uri_from_input_with_dirs (full_path,
+
GNOME_VFS_MAKE_URI_DIR_CURRENT);
+ free (base);
+ free (full_path);
+
+ if (gnome_url_show (uri, &err))
+ return 0;
+
+ fprintf (stderr, "Error showing url: %s\n", err->message);
+ g_error_free (err);
+
+ return 1;
+}
diff -Nur gnome-volume-manager.old/src/Makefile.am
gnome-volume-manager/src/Makefile.am
--- gnome-volume-manager.old/src/Makefile.am 2007-01-17 23:08:48.000000000
+0100
+++ gnome-volume-manager/src/Makefile.am 2007-01-17 23:09:22.000000000
+0100
@@ -12,7 +12,10 @@
-DICONSDIR=\"$(iconsdir)\" \
-DDATADIR=\"$(datadir)\"
-bin_PROGRAMS = gnome-volume-manager gnome-volume-properties
+bin_PROGRAMS = gnome-volume-manager gnome-volume-properties gnome-autorun
+
+gnome_autorun_SOURCES = autorun.c
+gnome_autorun_LDADD = -lgnome-2
gnome_volume_manager_SOURCES = manager.c clipboard.c gvm.h
gnome_volume_manager_LDADD = $(GVM_LIBS) $(NOTIFY_LIBS)