| 185 | } |
| 186 | |
| 187 | static gboolean |
| 188 | can_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 | |
| 232 | static void |
| 233 | shutdown_logind (void) |
no test coverage detected