[gnome-disk-utility] Include the pool ssh address in the presentable identifier for GduMachine



commit 09bf56875e07b9a484d2d0108e7963b7af49bc9a
Author: David Zeuthen <davidz redhat com>
Date:   Mon Dec 14 11:04:10 2009 -0500

    Include the pool ssh address in the presentable identifier for GduMachine
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 src/gdu/gdu-machine.c |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/src/gdu/gdu-machine.c b/src/gdu/gdu-machine.c
index 6b707d1..536661d 100644
--- a/src/gdu/gdu-machine.c
+++ b/src/gdu/gdu-machine.c
@@ -49,6 +49,7 @@
 struct _GduMachinePrivate
 {
         GduPool *pool;
+        gchar *id;
 };
 
 static GObjectClass *parent_class = NULL;
@@ -64,6 +65,8 @@ gdu_machine_finalize (GObject *object)
 {
         GduMachine *machine = GDU_MACHINE (object);
 
+        g_free (machine->priv->id);
+
         if (machine->priv->pool != NULL)
                 g_object_unref (machine->priv->pool);
 
@@ -93,15 +96,34 @@ GduMachine *
 _gdu_machine_new (GduPool *pool)
 {
         GduMachine *machine;
+        const gchar *ssh_user_name;
+        const gchar *ssh_address;
+        static guint count = 0;
+
         machine = GDU_MACHINE (g_object_new (GDU_TYPE_MACHINE, NULL));
         machine->priv->pool = g_object_ref (pool);
+
+        ssh_user_name = gdu_pool_get_ssh_user_name (machine->priv->pool);
+        if (ssh_user_name == NULL)
+                ssh_user_name = g_get_user_name ();
+        ssh_address = gdu_pool_get_ssh_address (machine->priv->pool);
+
+        if (ssh_address != NULL) {
+                machine->priv->id = g_strdup_printf ("__machine_root_%d_for_%s %s__",
+                                                     count++,
+                                                     ssh_user_name,
+                                                     ssh_address);
+        } else {
+                machine->priv->id = g_strdup_printf ("__machine_root_%d__", count++);
+        }
         return machine;
 }
 
 static const gchar *
 gdu_machine_get_id (GduPresentable *presentable)
 {
-        return "__root__"; /* TODO: include address? */
+        GduMachine *machine = GDU_MACHINE (presentable);
+        return machine->priv->id;
 }
 
 static GduDevice *
@@ -153,7 +175,6 @@ gdu_machine_get_vpd_name (GduPresentable *presentable)
         } else {
                 /* TODO: include IP address */
                 ret = g_strdup_printf ("%s %s", ssh_user_name, ssh_address);
-
         }
 
         /* TODO: include udisks and OS version numbers? */



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