Вот исходник
| Код | DBusGConnection *connection; GError *error = NULL; char strTmp[MAX_PATH] = {0}; DBusGProxy *proxy; gboolean boolret; g_type_init (); connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); if (connection == NULL) { sprintf(strTmp, "Error: %s", dbus_g_error_get_name(error)); g_error_free (error); LogInfo(strTmp); return; } proxy = dbus_g_proxy_new_for_name (connection, "org.gnome.ScreenSaver", "/org/gnome/ScreenSaver", "org.gnome.ScreenSaver");
if (!dbus_g_proxy_call (proxy, "GetActive", &error, G_TYPE_INVALID, G_TYPE_BOOLEAN, &boolret, G_TYPE_INVALID)) { sprintf(strTmp, "Error: %s", dbus_g_error_get_name(error)); g_error_free (error); LogInfo(strTmp); goto End; } if (boolret) { if (!dbus_g_proxy_call (proxy, "SimulateUserActivity", &error, G_TYPE_INVALID)) { sprintf(strTmp, "Error: %s", dbus_g_error_get_name(error)); g_error_free (error); LogInfo(strTmp); } }
End: g_object_unref (proxy);
|
|