Re: [Utopia] gnome-vfs HAL patch, take 3



On Fri, 2004-07-09 at 11:26 +0200, Alexander Larsson wrote:
> What about the attached (untested) gnome-vfs-export-hal-udi.patch? It
> exports the hal udi as a string, whenever its availible. This lets
> nautilus recover UDI information from computer:// since the Drive/Volume
> id is availible in the desktop files there. This would make it easy to
> do things like adding emblems in nautilus.
> 

Ok, I just tried your patch, a slightly modified version is attached
with a ChangeLog entry for the changes. 

I tested this in Nautilus by the patch in [1] that uses the HAL UDI as
the display name; see here http://freedesktop.org/~david/hal_udi.png

Btw, one potential problem I've noticed is that by linking with
libgnomevfs then libhal is dragged in as well, e.g.

 [davidz ixus davidz]$ which nautilus
 /opt/gnome2/bin/nautilus
 [davidz ixus davidz]$ strace nautilus 2> /tmp/nout 
 [davidz ixus davidz]$ cat /tmp/nout |grep libhal
 open("/opt/gnome2/lib/libhal.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
 open("/opt/gnome2/lib/libhal.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
 open("/usr/lib/libhal.so.0", O_RDONLY)  = 3

and /opt/gnome2/bin/nautilus doesn't explicitly link with libhal. This
doesn't look right, does it?

Cheers,
David


[1] :
Index: nautilus-desktop-link.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-desktop-link.c,v
retrieving revision 1.8
diff -u -p -r1.8 nautilus-desktop-link.c
--- nautilus-desktop-link.c     10 Feb 2004 15:33:12 -0000      1.8
+++ nautilus-desktop-link.c     13 Jul 2004 18:06:16 -0000
@@ -197,6 +197,7 @@ nautilus_desktop_link_new_from_volume (G
        NautilusDesktopLink *link;
        GnomeVFSDrive *drive;
        char *name;
+       char *hal_udi;
                                                                                                     
        link = NAUTILUS_DESKTOP_LINK (g_object_new (NAUTILUS_TYPE_DESKTOP_LINK, NULL));
                                                                                                     
@@ -217,7 +218,12 @@ nautilus_desktop_link_new_from_volume (G
        link->details->filename = g_strconcat (name, ".volume", NULL);
        g_free (name);
                                                                                                     
-       link->details->display_name = gnome_vfs_volume_get_display_name (volume);
+       hal_udi = gnome_vfs_volume_get_hal_udi (volume);
+       if (hal_udi != NULL) {
+               link->details->display_name = g_strdup (hal_udi);
+       } else {
+               link->details->display_name = gnome_vfs_volume_get_display_name (volume);
+       }
                                                                                                     
        link->details->activation_uri = gnome_vfs_volume_get_activation_uri (volume);
        link->details->icon = gnome_vfs_volume_get_icon (volume);

? gnome-vfs-export-hal-udi2.patch
? imported/Makefile
? imported/Makefile.in
? imported/neon/Makefile.in
? libgnomevfs/s-enum-types-c
? libgnomevfs/s-enum-types-h
? test/test-dns-sd
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-vfs/ChangeLog,v
retrieving revision 1.1842
diff -u -p -r1.1842 ChangeLog
--- ChangeLog	12 Jul 2004 08:37:26 -0000	1.1842
+++ ChangeLog	13 Jul 2004 18:00:10 -0000
@@ -1,3 +1,35 @@
+2004-07-13  David Zeuthen  <david fubar dk>
+
+	Export HAL UDI to applications using GNOME VFS. Largely based on
+	patch from Alexander Larsson.
+
+	* libgnomevfs/gnome-vfs-volume-monitor-private.h: hal_udi is now
+	always added to _GnomeVFSVolumePrivate and _GnomeVFSDrivePrivate
+	even if HAL is not used
+
+	* libgnomevfs/gnome-vfs-hal-mounts.c: Remove TODO about exporting UDI
+	(_hal_add_volume): Remember to set vol->priv->hal_udi
+
+	* libgnomevfs/gnome-vfs-volume.h: add gnome_vfs_volume_get_hal_udi()
+	prototype
+
+	* libgnomevfs/gnome-vfs-volume.c (gnome_vfs_volume_finalize): Always
+	free hal_udi as it is now available even when not using HAL
+	(gnome_vfs_volume_get_hal_udi): New function
+	(gnome_vfs_volume_to_corba, gnome_vfs_volume_from_corba): Handle 
+	hal_udi
+
+	* libgnomevfs/gnome-vfs-drive.h: add gnome_vfs_drive_get_hal_udi()
+	prototype
+
+	* libgnomevfs/gnome-vfs-drive.c (gnome_vfs_drive_finalize): Always
+	free hal_udi as it is now available even when not using HAL
+	(gnome_vfs_drive_get_hal_udi): New function
+	(gnome_vfs_drive_to_corba, gnome_vfs_drive_from_corba): Handle hal_udi
+
+	* libgnomevfs/GNOME_VFS_Daemon.idl:
+	(GNOME::VFS::Volume, GNOME::VFS::Drive): Add hal_udi as a string
+
 2004-07-12  Alexander Larsson  <alexl redhat com>
 
 	* modules/ftp-method.c (ftp_connection_destroy):
Index: libgnomevfs/GNOME_VFS_Daemon.idl
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/GNOME_VFS_Daemon.idl,v
retrieving revision 1.7
diff -u -p -r1.7 GNOME_VFS_Daemon.idl
--- libgnomevfs/GNOME_VFS_Daemon.idl	20 Apr 2004 13:27:46 -0000	1.7
+++ libgnomevfs/GNOME_VFS_Daemon.idl	13 Jul 2004 18:00:11 -0000
@@ -48,6 +48,7 @@ module GNOME {
 			string device_path;
 			long unix_device;
 			string gconf_id;
+		        string hal_udi;
 		};
 		typedef sequence<Volume> VolumeList;
 
@@ -61,6 +62,7 @@ module GNOME {
 			string icon;
 			boolean is_user_visible;
 			boolean is_connected;
+		        string hal_udi;
 		};
 		
 		typedef sequence<Drive> DriveList;
Index: libgnomevfs/gnome-vfs-drive.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-drive.c,v
retrieving revision 1.5
diff -u -p -r1.5 gnome-vfs-drive.c
--- libgnomevfs/gnome-vfs-drive.c	9 Jul 2004 08:39:16 -0000	1.5
+++ libgnomevfs/gnome-vfs-drive.c	13 Jul 2004 18:00:11 -0000
@@ -171,9 +171,7 @@ gnome_vfs_drive_finalize (GObject *objec
 	g_free (priv->activation_uri);
 	g_free (priv->display_name);
 	g_free (priv->icon);
-#ifdef USE_HAL
 	g_free (priv->hal_udi);
-#endif
 	g_free (priv);
 	drive->priv = NULL;
 	
@@ -254,6 +252,12 @@ gnome_vfs_drive_get_activation_uri (Gnom
 }
 
 char *
+gnome_vfs_drive_get_hal_udi (GnomeVFSDrive *drive)
+{
+	return g_strdup (drive->priv->hal_udi);
+}
+
+char *
 gnome_vfs_drive_get_display_name (GnomeVFSDrive *drive)
 {
 	return g_strdup (drive->priv->display_name);
@@ -340,6 +344,7 @@ gnome_vfs_drive_to_corba (GnomeVFSDrive 
 	corba_drive->activation_uri = corba_string_or_null_dup (drive->priv->activation_uri);
 	corba_drive->display_name = corba_string_or_null_dup (drive->priv->display_name);
 	corba_drive->icon = corba_string_or_null_dup (drive->priv->icon);
+	corba_drive->hal_udi = corba_string_or_null_dup (drive->priv->hal_udi);
 	
 	corba_drive->is_user_visible = drive->priv->is_user_visible;
 	corba_drive->is_connected = drive->priv->is_connected;
@@ -368,6 +373,7 @@ _gnome_vfs_drive_from_corba (const GNOME
 	drive->priv->activation_uri = decode_corba_string_or_null (corba_drive->activation_uri, TRUE);
 	drive->priv->display_name = decode_corba_string_or_null (corba_drive->display_name, TRUE);
 	drive->priv->icon = decode_corba_string_or_null (corba_drive->icon, TRUE);
+	drive->priv->hal_udi = decode_corba_string_or_null (corba_drive->hal_udi, TRUE);
 	
 	drive->priv->is_user_visible = corba_drive->is_user_visible;
 	drive->priv->is_connected = corba_drive->is_connected;
Index: libgnomevfs/gnome-vfs-drive.h
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-drive.h,v
retrieving revision 1.6
diff -u -p -r1.6 gnome-vfs-drive.h
--- libgnomevfs/gnome-vfs-drive.h	1 Mar 2004 09:43:31 -0000	1.6
+++ libgnomevfs/gnome-vfs-drive.h	13 Jul 2004 18:00:11 -0000
@@ -68,6 +68,7 @@ char *             gnome_vfs_drive_get_d
 char *             gnome_vfs_drive_get_activation_uri  (GnomeVFSDrive *drive);
 char *             gnome_vfs_drive_get_display_name    (GnomeVFSDrive *drive);
 char *             gnome_vfs_drive_get_icon            (GnomeVFSDrive *drive);
+char *             gnome_vfs_drive_get_hal_udi         (GnomeVFSDrive *drive);
 gboolean           gnome_vfs_drive_is_user_visible     (GnomeVFSDrive *drive);
 gboolean           gnome_vfs_drive_is_connected        (GnomeVFSDrive *drive);
 gboolean           gnome_vfs_drive_is_mounted          (GnomeVFSDrive *drive);
Index: libgnomevfs/gnome-vfs-hal-mounts.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-hal-mounts.c,v
retrieving revision 1.1
diff -u -p -r1.1 gnome-vfs-hal-mounts.c
--- libgnomevfs/gnome-vfs-hal-mounts.c	9 Jul 2004 08:39:16 -0000	1.1
+++ libgnomevfs/gnome-vfs-hal-mounts.c	13 Jul 2004 18:00:12 -0000
@@ -41,15 +41,10 @@
  *
  *  TODO/QUESTIONS/ISSUES
  *
- *  - Find a way to expose the HAL UDI of a drive and a volume such that
- *    e.g. Nautilus can extract more properties on the device
- *
  *  - Fix HAL so hal_initialize() fails when we cannot connect to the HAL
  *    daemon; When this works GNOME VFS falls back to mtab/fstab monitoring.
  *    Which is nice.
  *
- *  - Use MP3, Camera icons by looking at info.capabilities
- *
  *  - When a recordable disc (CD-R, CD-RW, DVD-R, DVD+RW etc.) is closed
  *    should we map down to the non-cdrecordable type? E.g. 
  *
@@ -73,10 +68,6 @@
  *
  *  - Do the same for MP3 players when GNOME VFS backends for these emerge.
  *
- *  - Someone please look at GNOME Bug 143888. Fixing this will allow
- *    a reasonable good desktop experience without automounting or
- *    autodetection
- *
  *  NOTE
  *
  *  - For this patch you need a recent version of GNOME VFS that doesn't
@@ -1064,11 +1055,11 @@ _hal_add_volume (GnomeVFSVolumeMonitorDa
 
 		drive->priv->hal_udi = g_strdup (
 #ifdef HAL_ONLY_SHOW_MOUNTED_VOLUMES
-			udi);
+			udi
 #else
-			hal_drive->no_partitions ? hal_drive->udi : udi);
+			hal_drive->no_partitions ? hal_drive->udi : udi
 #endif
-		
+		);
 		_gnome_vfs_volume_monitor_connected (volume_monitor, drive);
 		gnome_vfs_drive_unref (drive);
 	} 
@@ -1091,6 +1082,7 @@ _hal_add_volume (GnomeVFSVolumeMonitorDa
 			device_type = _hal_get_vol_type (hal_vol, hal_drive, hal_ctx);
 
 			vol = g_object_new (GNOME_VFS_TYPE_VOLUME, NULL);
+			vol->priv->hal_udi = g_strdup (udi);
 			vol->priv->volume_type = GNOME_VFS_VOLUME_TYPE_MOUNTPOINT;
 			
 			if (is_blank_disc) {
Index: libgnomevfs/gnome-vfs-volume-monitor-private.h
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-volume-monitor-private.h,v
retrieving revision 1.5
diff -u -p -r1.5 gnome-vfs-volume-monitor-private.h
--- libgnomevfs/gnome-vfs-volume-monitor-private.h	9 Jul 2004 08:39:16 -0000	1.5
+++ libgnomevfs/gnome-vfs-volume-monitor-private.h	13 Jul 2004 18:00:12 -0000
@@ -60,12 +60,11 @@ struct _GnomeVFSVolumePrivate {
 	char *device_path;
 	dev_t unix_device;
 
+	/* Only for HAL devices: */
+	char *hal_udi;
+
 	/* Only for connected servers */
 	char *gconf_id;
-
-#ifdef USE_HAL
-	char *hal_udi;
-#endif /* USE_HAL */
 };
 
 
@@ -84,9 +83,8 @@ struct _GnomeVFSDrivePrivate {
 	gboolean is_user_visible;
 	gboolean is_connected;
 
-#ifdef USE_HAL
+	/* Only for HAL devices: */
 	char *hal_udi;
-#endif /* USE_HAL */
 };
 
 void _gnome_vfs_volume_set_drive                (GnomeVFSVolume        *volume,
Index: libgnomevfs/gnome-vfs-volume.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-volume.c,v
retrieving revision 1.5
diff -u -p -r1.5 gnome-vfs-volume.c
--- libgnomevfs/gnome-vfs-volume.c	9 Jul 2004 08:39:16 -0000	1.5
+++ libgnomevfs/gnome-vfs-volume.c	13 Jul 2004 18:00:13 -0000
@@ -136,9 +136,7 @@ gnome_vfs_volume_finalize (GObject *obje
 	g_free (priv->display_name);
 	g_free (priv->icon);
 	g_free (priv->gconf_id);
-#ifdef USE_HAL
 	g_free (priv->hal_udi);
-#endif
 	g_free (priv);
 	volume->priv = NULL;
 	
@@ -209,6 +207,12 @@ gnome_vfs_volume_get_activation_uri (Gno
 }
 
 char *
+gnome_vfs_volume_get_hal_udi (GnomeVFSVolume *volume)
+{
+	return g_strdup (volume->priv->hal_udi);
+}
+
+char *
 gnome_vfs_volume_get_filesystem_type (GnomeVFSVolume *volume)
 {
 	return g_strdup (volume->priv->filesystem_type);
@@ -360,6 +364,7 @@ gnome_vfs_volume_to_corba (GnomeVFSVolum
 	corba_volume->display_name = corba_string_or_null_dup (volume->priv->display_name);
 	corba_volume->icon = corba_string_or_null_dup (volume->priv->icon);
 	corba_volume->gconf_id = corba_string_or_null_dup (volume->priv->gconf_id);
+	corba_volume->hal_udi = corba_string_or_null_dup (volume->priv->hal_udi);
 	
 	corba_volume->is_user_visible = volume->priv->is_user_visible;
 	corba_volume->is_read_only = volume->priv->is_read_only;
@@ -395,6 +400,7 @@ _gnome_vfs_volume_from_corba (const GNOM
 	volume->priv->display_name = decode_corba_string_or_null (corba_volume->display_name, TRUE);
 	volume->priv->icon = decode_corba_string_or_null (corba_volume->icon, TRUE);
 	volume->priv->gconf_id = decode_corba_string_or_null (corba_volume->gconf_id, TRUE);
+	volume->priv->hal_udi = decode_corba_string_or_null (corba_volume->hal_udi, TRUE);
 	
 	volume->priv->is_user_visible = corba_volume->is_user_visible;
 	volume->priv->is_read_only = corba_volume->is_read_only;
Index: libgnomevfs/gnome-vfs-volume.h
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-volume.h,v
retrieving revision 1.6
diff -u -p -r1.6 gnome-vfs-volume.h
--- libgnomevfs/gnome-vfs-volume.h	1 Mar 2004 09:43:31 -0000	1.6
+++ libgnomevfs/gnome-vfs-volume.h	13 Jul 2004 18:00:13 -0000
@@ -105,6 +105,7 @@ char *             gnome_vfs_volume_get_
 char *             gnome_vfs_volume_get_filesystem_type (GnomeVFSVolume *volume);
 char *             gnome_vfs_volume_get_display_name    (GnomeVFSVolume *volume);
 char *             gnome_vfs_volume_get_icon            (GnomeVFSVolume *volume);
+char *             gnome_vfs_volume_get_hal_udi         (GnomeVFSVolume *volume);
 gboolean           gnome_vfs_volume_is_user_visible     (GnomeVFSVolume *volume);
 gboolean           gnome_vfs_volume_is_read_only        (GnomeVFSVolume *volume);
 gboolean           gnome_vfs_volume_is_mounted          (GnomeVFSVolume *volume);


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