42
41
gdm_action_reboot()
44
DBusGConnection *connection;
49
connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
50
if (connection == NULL) {
55
proxy = dbus_g_proxy_new_for_name (connection,
56
"org.gnome.SessionManager",
57
"/org/gnome/SessionManager",
58
"org.gnome.SessionManager");
46
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
47
G_DBUS_PROXY_FLAGS_NONE,
48
NULL, /* GDBusInterfaceInfo */
49
"org.gnome.SessionManager",
50
"/org/gnome/SessionManager",
51
"org.gnome.SessionManager",
52
NULL, /* GCancellable */
63
if (!dbus_g_proxy_call (proxy, "RequestReboot", &error,
64
G_TYPE_INVALID, G_TYPE_INVALID)) {
57
answer = g_dbus_proxy_call_sync (proxy, "RequestReboot", NULL,
58
G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL);
59
g_object_unref (proxy);
64
g_variant_unref (answer);
74
DBusGConnection *connection;
79
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
80
if (connection == NULL) {
85
proxy = dbus_g_proxy_new_for_name (connection,
86
"org.freedesktop.ConsoleKit",
87
"/org/freedesktop/ConsoleKit/Manager",
88
"org.freedesktop.ConsoleKit.Manager");
74
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
75
G_DBUS_PROXY_FLAGS_NONE,
76
NULL, /* GDBusInterfaceInfo */
77
"org.freedesktop.ConsoleKit",
78
"/org/freedesktop/ConsoleKit/Manager",
79
"org.freedesktop.ConsoleKit.Manager",
80
NULL, /* GCancellable */
93
if (!dbus_g_proxy_call (proxy, "Restart", &error,
94
G_TYPE_INVALID, G_TYPE_INVALID)) {
85
answer = g_dbus_proxy_call_sync (proxy, "Restart", NULL,
86
G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL);
87
g_object_unref (proxy);
92
g_variant_unref (answer);
133
is_aptdaemon_on_the_system_bus ()
135
DBusConnection *connection;
136
DBusError *dbus_error = NULL;
137
DBusMessage *message, *reply;
138
const char *aptdaemon_bus_name = "org.debian.apt";
141
connection = dbus_bus_get(DBUS_BUS_SYSTEM, dbus_error);
142
if (dbus_error != NULL) {
143
g_warning("failed to connect to the system bus");
146
message = dbus_message_new_method_call(DBUS_SERVICE_DBUS,
150
if (message == NULL) {
151
g_warning ("failed to create dbus message");
155
dbus_message_append_args(message,
156
DBUS_TYPE_STRING, &aptdaemon_bus_name,
159
reply = dbus_connection_send_with_reply_and_block(connection,
163
dbus_message_unref(message);
166
dbus_message_unref(reply);
172
g_debug("aptdaemon on bus: %i", res);
177
128
aptdaemon_pending_transactions ()
179
DBusGConnection *connection;
182
char *current = NULL;
183
char **pending = NULL;
185
if (!is_aptdaemon_on_the_system_bus())
189
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
190
if (connection == NULL) {
191
g_debug ("Failed to open connection to bus: %s\n", error->message);
192
g_error_free (error);
196
proxy = dbus_g_proxy_new_for_name (connection,
201
if (!dbus_g_proxy_call (proxy, "GetActiveTransactions", &error,
203
G_TYPE_STRING, ¤t,
204
G_TYPE_STRV, &pending,
206
g_debug ("error during dbus call: %s\n", error->message);
207
g_error_free (error);
208
g_object_unref (proxy);
134
const char *current = NULL;
135
char **pending = NULL;
138
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
139
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
140
NULL, /* GDBusInterfaceInfo */
144
NULL, /* GCancellable */
147
g_debug ("Failed to open connection to bus: %s\n", error->message);
148
g_error_free (error);
152
owner = g_dbus_proxy_get_name_owner (proxy);
153
g_debug("aptdaemon on bus: %i", (owner != NULL));
155
g_object_unref (proxy);
162
answer = g_dbus_proxy_call_sync (proxy, "GetActiveTransactions", NULL,
163
G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
164
g_object_unref (proxy);
166
if (answer == NULL) {
167
g_debug ("error during dbus call: %s\n", error->message);
168
g_error_free (error);
172
if (g_strcmp0 (g_variant_get_type_string (answer), "(sas)") != 0) {
173
g_debug ("aptd answer in unexpected format: %s\n",
174
g_variant_get_type_string (answer));
175
g_variant_unref (answer);
179
g_variant_get (answer, "(&s^a&s)", ¤t, &pending);
212
181
gboolean has_pending = FALSE;
213
182
if ((current && strcmp(current,"") != 0) || g_strv_length(pending) > 0)
214
183
has_pending = TRUE;
216
g_object_unref (proxy);
218
g_strfreev (pending);
186
g_variant_unref (answer);
220
188
return has_pending;