~khurshid-alam/unity-settings-daemon/fix-low-battery-notifications

« back to all changes in this revision

Viewing changes to gnome-settings-daemon/gnome-settings-bus.c

  • Committer: Sebastien Bacher
  • Author(s): Khurshid Alam
  • Date: 2019-06-21 08:32:43 UTC
  • mfrom: (4192.1.1 upstream)
  • Revision ID: seb128@ubuntu.com-20190621083243-8k7ifmdkb5tpgaqe
Fix airplane mode switch not appearing

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
 
88
88
        return screen_saver_proxy;
89
89
}
 
90
 
 
91
char *
 
92
gnome_settings_get_chassis_type (void)
 
93
{
 
94
        char *ret = NULL;
 
95
        GError *error = NULL;
 
96
        GVariant *inner;
 
97
        GVariant *variant = NULL;
 
98
        GDBusConnection *connection;
 
99
 
 
100
        connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM,
 
101
                                     NULL,
 
102
                                     &error);
 
103
        if (connection == NULL) {
 
104
                g_warning ("system bus not available: %s", error->message);
 
105
                g_error_free (error);
 
106
                goto out;
 
107
        }
 
108
 
 
109
        variant = g_dbus_connection_call_sync (connection,
 
110
                                               "org.freedesktop.hostname1",
 
111
                                               "/org/freedesktop/hostname1",
 
112
                                               "org.freedesktop.DBus.Properties",
 
113
                                               "Get",
 
114
                                               g_variant_new ("(ss)",
 
115
                                                              "org.freedesktop.hostname1",
 
116
                                                              "Chassis"),
 
117
                                               NULL,
 
118
                                               G_DBUS_CALL_FLAGS_NONE,
 
119
                                               -1,
 
120
                                               NULL,
 
121
                                               &error);
 
122
        if (variant == NULL) {
 
123
                g_debug ("Failed to get property '%s': %s", "Chassis", error->message);
 
124
                g_error_free (error);
 
125
                goto out;
 
126
        }
 
127
 
 
128
        g_variant_get (variant, "(v)", &inner);
 
129
        ret = g_variant_dup_string (inner, NULL);
 
130
        g_variant_unref (inner);
 
131
out:
 
132
        g_clear_object (&connection);
 
133
        g_clear_pointer (&variant, g_variant_unref);
 
134
        return ret;
 
135
}