glib r6364 - trunk/gio



Author: alexl
Date: Thu Jan 24 16:06:33 2008
New Revision: 6364
URL: http://svn.gnome.org/viewvc/glib?rev=6364&view=rev

Log:
2008-01-24  Alexander Larsson  <alexl redhat com>

        * gdrive.[ch]:
	Add g_drive_get_identifier and
        g_drive_enumerate_identifiers

        * gvolume.[ch]:
        Add g_volume_get_identifier and
        g_volume_enumerate_identifiers
	
        * gio.symbols:
	Add symbols
	
        * gunixvolume.c:
	Implement identifiers for unix backend



Modified:
   trunk/gio/ChangeLog
   trunk/gio/gdrive.c
   trunk/gio/gdrive.h
   trunk/gio/gio.symbols
   trunk/gio/gunixvolume.c
   trunk/gio/gvolume.c
   trunk/gio/gvolume.h

Modified: trunk/gio/gdrive.c
==============================================================================
--- trunk/gio/gdrive.c	(original)
+++ trunk/gio/gdrive.c	Thu Jan 24 16:06:33 2008
@@ -474,5 +474,37 @@
   return (* iface->poll_for_media_finish) (drive, result, error);
 }
 
+char *
+g_drive_get_identifier (GDrive              *drive,
+			const char          *kind)
+{
+  GDriveIface *iface;
+
+  g_return_val_if_fail (G_IS_DRIVE (drive), NULL);
+  g_return_val_if_fail (kind != NULL, NULL);
+
+  iface = G_DRIVE_GET_IFACE (drive);
+
+  if (iface->get_identifier == NULL)
+    return NULL;
+  
+  return (* iface->get_identifier) (drive, kind);
+}
+
+char **
+g_drive_enumerate_identifiers (GDrive *drive)
+{
+  GDriveIface *iface;
+
+  g_return_val_if_fail (G_IS_DRIVE (drive), NULL);
+  iface = G_DRIVE_GET_IFACE (drive);
+
+  if (iface->enumerate_identifiers == NULL)
+    return NULL;
+  
+  return (* iface->enumerate_identifiers) (drive);
+}
+
+
 #define __G_DRIVE_C__
 #include "gioaliasdef.c"

Modified: trunk/gio/gdrive.h
==============================================================================
--- trunk/gio/gdrive.h	(original)
+++ trunk/gio/gdrive.h	Thu Jan 24 16:06:33 2008
@@ -98,6 +98,10 @@
   gboolean (*poll_for_media_finish)    (GDrive              *drive,
                                         GAsyncResult        *result,
                                         GError             **error);
+
+  char *   (*get_identifier)           (GDrive              *drive,
+					const char          *kind);
+  char **  (*enumerate_identifiers)    (GDrive              *drive);
 };
 
 GType g_drive_get_type                    (void) G_GNUC_CONST;
@@ -126,6 +130,9 @@
 gboolean g_drive_poll_for_media_finish    (GDrive               *drive,
                                            GAsyncResult         *result,
                                            GError              **error);
+char *   g_drive_get_identifier           (GDrive              *drive,
+					   const char          *kind);
+char **  g_drive_enumerate_identifiers    (GDrive              *drive);
 
 G_END_DECLS
 

Modified: trunk/gio/gio.symbols
==============================================================================
--- trunk/gio/gio.symbols	(original)
+++ trunk/gio/gio.symbols	Thu Jan 24 16:06:33 2008
@@ -194,6 +194,8 @@
 g_drive_eject_finish
 g_drive_poll_for_media
 g_drive_poll_for_media_finish
+g_drive_get_identifier
+g_drive_enumerate_identifiers
 #endif
 #endif
 
@@ -701,7 +703,9 @@
 g_volume_mount 
 g_volume_mount_finish 
 g_volume_eject 
-g_volume_eject_finish 
+g_volume_eject_finish
+g_volume_get_identifier
+g_volume_enumerate_identifiers
 #endif
 #endif
 

Modified: trunk/gio/gunixvolume.c
==============================================================================
--- trunk/gio/gunixvolume.c	(original)
+++ trunk/gio/gunixvolume.c	Thu Jan 24 16:06:33 2008
@@ -49,6 +49,9 @@
   char *mount_path;
   gboolean can_eject;
 
+  char *identifier;
+  char *identifier_type;
+  
   char *name;
   GIcon *icon;
 };
@@ -77,6 +80,8 @@
   g_free (volume->name);
   g_free (volume->mount_path);
   g_free (volume->device_path);
+  g_free (volume->identifier);
+  g_free (volume->identifier_type);
 
   if (G_OBJECT_CLASS (g_unix_volume_parent_class)->finalize)
     (*G_OBJECT_CLASS (g_unix_volume_parent_class)->finalize) (object);
@@ -121,6 +126,29 @@
 
   volume->name = g_unix_mount_point_guess_name (mountpoint);
   volume->icon = g_unix_mount_point_guess_icon (mountpoint);
+
+
+  if (strcmp (g_unix_mount_point_get_fs_type (mountpoint), "nfs") == 0)
+    {
+      volume->identifier_type = g_strdup (G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT);
+      volume->identifier = g_strdup (volume->device_path);
+    }
+  else if (g_str_has_prefix (volume->device_path, "LABEL="))
+    {
+      volume->identifier_type = g_strdup (G_VOLUME_IDENTIFIER_KIND_LABEL);
+      volume->identifier = g_strdup (volume->device_path + 6);
+    }
+  else if (g_str_has_prefix (volume->device_path, "UUID="))
+    {
+      volume->identifier_type = g_strdup (G_VOLUME_IDENTIFIER_KIND_UUID);
+      volume->identifier = g_strdup (volume->device_path + 5);
+    }
+  else if (g_path_is_absolute (volume->device_path))
+    {
+      volume->identifier_type = g_strdup (G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
+      volume->identifier = g_strdup (volume->device_path);
+    }
+  
   return volume;
 }
 
@@ -402,6 +430,39 @@
   return TRUE;
 }
 
+static char *
+g_unix_volume_get_identifier (GVolume              *volume,
+                              const char          *kind)
+{
+  GUnixVolume *unix_volume = G_UNIX_VOLUME (volume);
+
+  if (strcmp (kind, unix_volume->identifier_type) == 0)
+    return g_strdup (unix_volume->identifier);
+  return NULL;
+}
+
+static char **
+g_unix_volume_enumerate_identifiers (GVolume *volume)
+{
+  GUnixVolume *unix_volume = G_UNIX_VOLUME (volume);
+  char **res;
+
+  if (unix_volume->identifier_type)
+    {
+      res = g_new (char *, 2);
+      res[0] = g_strdup (unix_volume->identifier_type);
+      res[1] = NULL;
+    }
+  else
+    {
+      res = g_new (char *, 1);
+      res[0] = NULL;
+    }
+
+  return res;
+}
+
+
 static void
 g_unix_volume_volume_iface_init (GVolumeIface *iface)
 {
@@ -416,4 +477,6 @@
   iface->mount_finish = g_unix_volume_mount_finish;
   iface->eject = g_unix_volume_eject;
   iface->eject_finish = g_unix_volume_eject_finish;
+  iface->get_identifier = g_unix_volume_get_identifier;
+  iface->enumerate_identifiers = g_unix_volume_enumerate_identifiers;
 }

Modified: trunk/gio/gvolume.c
==============================================================================
--- trunk/gio/gvolume.c	(original)
+++ trunk/gio/gvolume.c	Thu Jan 24 16:06:33 2008
@@ -420,5 +420,37 @@
   return (* iface->eject_finish) (volume, result, error);
 }
 
+char *
+g_volume_get_identifier (GVolume              *volume,
+			 const char          *kind)
+{
+  GVolumeIface *iface;
+
+  g_return_val_if_fail (G_IS_VOLUME (volume), NULL);
+  g_return_val_if_fail (kind != NULL, NULL);
+
+  iface = G_VOLUME_GET_IFACE (volume);
+
+  if (iface->get_identifier == NULL)
+    return NULL;
+  
+  return (* iface->get_identifier) (volume, kind);
+}
+
+char **
+g_volume_enumerate_identifiers (GVolume *volume)
+{
+  GVolumeIface *iface;
+
+  g_return_val_if_fail (G_IS_VOLUME (volume), NULL);
+  iface = G_VOLUME_GET_IFACE (volume);
+
+  if (iface->enumerate_identifiers == NULL)
+    return NULL;
+  
+  return (* iface->enumerate_identifiers) (volume);
+}
+
+
 #define __G_VOLUME_C__
 #include "gioaliasdef.c"

Modified: trunk/gio/gvolume.h
==============================================================================
--- trunk/gio/gvolume.h	(original)
+++ trunk/gio/gvolume.h	Thu Jan 24 16:06:33 2008
@@ -34,6 +34,13 @@
 
 G_BEGIN_DECLS
 
+#define G_VOLUME_IDENTIFIER_KIND_HAL_UDI "hal-udi"
+#define G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE "unix-device"
+#define G_VOLUME_IDENTIFIER_KIND_LABEL "label"
+#define G_VOLUME_IDENTIFIER_KIND_UUID "uuid"
+#define G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT "nfs-mount"
+
+
 #define G_TYPE_VOLUME            (g_volume_get_type ())
 #define G_VOLUME(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_VOLUME, GVolume))
 #define G_IS_VOLUME(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_VOLUME))
@@ -94,33 +101,41 @@
   gboolean  (*eject_finish)   (GVolume             *volume,
                                GAsyncResult        *result,
                                GError             **error);
+  
+  char *   (*get_identifier)           (GVolume             *volume,
+					const char          *kind);
+  char **  (*enumerate_identifiers)    (GVolume             *volume);
 };
 
 GType     g_volume_get_type       (void) G_GNUC_CONST;
 
-char *    g_volume_get_name       (GVolume              *volume);
-GIcon *   g_volume_get_icon       (GVolume              *volume);
-char *    g_volume_get_uuid       (GVolume              *volume);
-GDrive *  g_volume_get_drive      (GVolume              *volume);
-GMount *  g_volume_get_mount      (GVolume              *volume);
-gboolean  g_volume_can_mount      (GVolume              *volume);
-gboolean  g_volume_can_eject      (GVolume              *volume);
-void      g_volume_mount          (GVolume              *volume,
-                                   GMountOperation      *mount_operation,
-                                   GCancellable         *cancellable,
-                                   GAsyncReadyCallback   callback,
-                                   gpointer              user_data);
-gboolean g_volume_mount_finish    (GVolume              *volume,
-                                   GAsyncResult         *result,
-                                   GError              **error);
-void      g_volume_eject          (GVolume              *volume,
-				   GMountUnmountFlags    flags,
-                                   GCancellable         *cancellable,
-                                   GAsyncReadyCallback   callback,
-                                   gpointer              user_data);
-gboolean g_volume_eject_finish    (GVolume              *volume,
-                                   GAsyncResult         *result,
-                                   GError              **error);
+char *   g_volume_get_name              (GVolume              *volume);
+GIcon *  g_volume_get_icon              (GVolume              *volume);
+char *   g_volume_get_uuid              (GVolume              *volume);
+GDrive * g_volume_get_drive             (GVolume              *volume);
+GMount * g_volume_get_mount             (GVolume              *volume);
+gboolean g_volume_can_mount             (GVolume              *volume);
+gboolean g_volume_can_eject             (GVolume              *volume);
+void     g_volume_mount                 (GVolume              *volume,
+					 GMountOperation      *mount_operation,
+					 GCancellable         *cancellable,
+					 GAsyncReadyCallback   callback,
+					 gpointer              user_data);
+gboolean g_volume_mount_finish          (GVolume              *volume,
+					 GAsyncResult         *result,
+					 GError              **error);
+void     g_volume_eject                 (GVolume              *volume,
+					 GMountUnmountFlags    flags,
+					 GCancellable         *cancellable,
+					 GAsyncReadyCallback   callback,
+					 gpointer              user_data);
+gboolean g_volume_eject_finish          (GVolume              *volume,
+					 GAsyncResult         *result,
+					 GError              **error);
+char *   g_volume_get_identifier        (GVolume              *volume,
+					 const char           *kind);
+char **  g_volume_enumerate_identifiers (GVolume              *volume);
+
 
 G_END_DECLS
 



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