MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / can_shutdown_logind

Function can_shutdown_logind

gtk/src/callbacks.c:187–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187static gboolean
188can_shutdown_logind (void)
189{
190 gboolean can_shutdown = FALSE;
191#if !defined(_WIN32)
192 char *str = NULL;
193 GDBusProxy *proxy;
194 GError *error = NULL;
195 GVariant *res;
196
197
198 ghb_log_func();
199 proxy = ghb_get_dbus_proxy(G_BUS_TYPE_SYSTEM, DBUS_LOGIND_SERVICE,
200 DBUS_LOGIND_PATH, DBUS_LOGIND_INTERFACE);
201 if (proxy == NULL)
202 return FALSE;
203
204 res = g_dbus_proxy_call_sync(proxy, "CanPowerOff", NULL,
205 G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
206 if (!res)
207 {
208 if (error != NULL)
209 {
210 g_warning("CanPowerOff failed: %s", error->message);
211 g_error_free(error);
212 }
213 else
214 g_warning("CanPowerOff failed");
215 // Try to shutdown anyway
216 can_shutdown = TRUE;
217 }
218 else
219 {
220 g_variant_get(res, "(s)", &str);
221 g_variant_unref(res);
222 if (g_strcmp0(str, "yes") == 0)
223 can_shutdown = TRUE;
224
225 g_free(str);
226 }
227 g_object_unref(G_OBJECT(proxy));
228#endif
229 return can_shutdown;
230}
231
232static void
233shutdown_logind (void)

Callers 1

queue_done_actionFunction · 0.85

Calls 1

ghb_get_dbus_proxyFunction · 0.85

Tested by

no test coverage detected