[gnome-settings-daemon] daemon: Add chassis type helper



commit 4092695a6d4e02e3f0b07e9f10e918dfa1c13f67
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Jan 27 19:06:46 2015 +0100

    daemon: Add chassis type helper
    
    https://bugzilla.gnome.org/show_bug.cgi?id=743456

 gnome-settings-daemon/gnome-settings-bus.c |   46 ++++++++++++++++++++++++++++
 gnome-settings-daemon/gnome-settings-bus.h |    1 +
 2 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/gnome-settings-daemon/gnome-settings-bus.c b/gnome-settings-daemon/gnome-settings-bus.c
index 9e884a6..cd1a686 100644
--- a/gnome-settings-daemon/gnome-settings-bus.c
+++ b/gnome-settings-daemon/gnome-settings-bus.c
@@ -122,6 +122,52 @@ gnome_settings_bus_get_shell_proxy (void)
         return shell_proxy;
 }
 
+char *
+gnome_settings_get_chassis_type (void)
+{
+        char *ret = NULL;
+        GError *error = NULL;
+        GVariant *inner;
+        GVariant *variant = NULL;
+        GDBusConnection *connection;
+
+        connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM,
+                                     NULL,
+                                     &error);
+        if (connection == NULL) {
+                g_warning ("system bus not available: %s", error->message);
+                g_error_free (error);
+                goto out;
+        }
+
+        variant = g_dbus_connection_call_sync (connection,
+                                               "org.freedesktop.hostname1",
+                                               "/org/freedesktop/hostname1",
+                                               "org.freedesktop.DBus.Properties",
+                                               "Get",
+                                               g_variant_new ("(ss)",
+                                                              "org.freedesktop.hostname1",
+                                                              "Chassis"),
+                                               NULL,
+                                               G_DBUS_CALL_FLAGS_NONE,
+                                               -1,
+                                               NULL,
+                                               &error);
+        if (variant == NULL) {
+                g_debug ("Failed to get property '%s': %s", "Chassis", error->message);
+                g_error_free (error);
+                goto out;
+        }
+
+        g_variant_get (variant, "(v)", &inner);
+        ret = g_variant_dup_string (inner, NULL);
+        g_variant_unref (inner);
+out:
+        g_clear_object (&connection);
+        g_clear_pointer (&variant, g_variant_unref);
+        return ret;
+}
+
 static gpointer
 is_wayland_session (gpointer user_data)
 {
diff --git a/gnome-settings-daemon/gnome-settings-bus.h b/gnome-settings-daemon/gnome-settings-bus.h
index 845a369..1d14980 100644
--- a/gnome-settings-daemon/gnome-settings-bus.h
+++ b/gnome-settings-daemon/gnome-settings-bus.h
@@ -33,6 +33,7 @@ GsdSessionManager        *gnome_settings_bus_get_session_proxy       (void);
 GsdScreenSaver           *gnome_settings_bus_get_screen_saver_proxy  (void);
 GsdShell                 *gnome_settings_bus_get_shell_proxy         (void);
 gboolean                  gnome_settings_is_wayland                  (void);
+char *                    gnome_settings_get_chassis_type            (void);
 
 G_END_DECLS
 


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