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

Function can_suspend_logind

gtk/src/callbacks.c:109–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107#endif
108
109static gboolean
110can_suspend_logind (void)
111{
112 gboolean can_suspend = FALSE;
113#if !defined(_WIN32)
114 char *str = NULL;
115 GDBusProxy *proxy;
116 GError *error = NULL;
117 GVariant *res;
118
119 ghb_log_func();
120 proxy = ghb_get_dbus_proxy(G_BUS_TYPE_SYSTEM, DBUS_LOGIND_SERVICE,
121 DBUS_LOGIND_PATH, DBUS_LOGIND_INTERFACE);
122 if (proxy == NULL)
123 return FALSE;
124
125 res = g_dbus_proxy_call_sync(proxy, "CanSuspend", NULL,
126 G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
127 if (!res)
128 {
129 if (error != NULL)
130 {
131 g_warning("CanSuspend failed: %s", error->message);
132 g_error_free(error);
133 }
134 else
135 g_warning("CanSuspend failed");
136 // Try to shutdown anyway
137 can_suspend = TRUE;
138 }
139 else
140 {
141 g_variant_get(res, "(s)", &str);
142 g_variant_unref(res);
143 if (g_strcmp0(str, "yes") == 0)
144 can_suspend = TRUE;
145
146 g_free(str);
147 }
148 g_object_unref(G_OBJECT(proxy));
149#endif
150 return can_suspend;
151}
152
153static void
154suspend_logind (void)

Callers 1

queue_done_actionFunction · 0.85

Calls 1

ghb_get_dbus_proxyFunction · 0.85

Tested by

no test coverage detected