summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorphintuka <phintuka>2013-08-15 10:12:27 +0000
committerphintuka <phintuka>2013-08-15 10:12:27 +0000
commit791c6a7a963f3d1c72b38b580f8ad0e92d31138c (patch)
treeac5a2033816d93f7c550880a287472cd69242f3b
parent5cfe6e530976a8557c9f316c5519823f78704780 (diff)
downloadxineliboutput-791c6a7a963f3d1c72b38b580f8ad0e92d31138c.tar.gz
xineliboutput-791c6a7a963f3d1c72b38b580f8ad0e92d31138c.tar.bz2
gnome-screensaver: Added support for Nokia N9 MCE (Mode Control Entity)
-rwxr-xr-xconfigure6
-rw-r--r--tools/gnome_screensaver.c62
2 files changed, 66 insertions, 2 deletions
diff --git a/configure b/configure
index 0b51c2b4..df37249f 100755
--- a/configure
+++ b/configure
@@ -7,7 +7,7 @@
# See the main source file 'xineliboutput.c' for copyright information and
# how to reach the author.
#
-# * $Id: configure,v 1.42 2012-08-30 06:44:20 phintuka Exp $
+# * $Id: configure,v 1.43 2013-08-15 10:12:27 phintuka Exp $
#
PKG_CONFIG="pkg-config"
@@ -240,6 +240,7 @@ FEATURES="
i18n
libcap
libbluray
+ mce-dbus-names
"
# set defaults
@@ -382,7 +383,8 @@ if enabled libxine; then
"dbus/dbus-glib.h" \
"-ldbus-glib-1 -lgobject-2.0 -lglib-2.0" \
"dbus_g_bus_get(0,0)" \
- "-I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include"
+ "-I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/lib/glib-2.0/include"
+ enabled dbus-glib-1 && test_library X11 mce-dbus-names "mce/dbus-names.h" "" ""
fi
fi
diff --git a/tools/gnome_screensaver.c b/tools/gnome_screensaver.c
index d9dba279..81685100 100644
--- a/tools/gnome_screensaver.c
+++ b/tools/gnome_screensaver.c
@@ -26,6 +26,11 @@
#include <stdarg.h>
#include <string.h>
+#include "../features.h"
+#ifdef HAVE_MCE_DBUS_NAMES
+# include <mce/dbus-names.h>
+#endif
+
#define LOG_MODULENAME "[scrnsaver] "
#include "../logdefs.h"
@@ -49,6 +54,8 @@
#define MSG_GError "Error: %s"
#define MSG_GNOMEScreensaverEnabled "GNOME screensaver enabled"
#define MSG_GNOMEScreensaverDisabled "GNOME screensaver disabled"
+#define MSG_MCEScreensaverEnabled "MCE screensaver enabled"
+#define MSG_MCEScreensaverDisabled "MCE screensaver disabled"
static guint32 cookie;
@@ -101,6 +108,50 @@ static int gnome_sessionmanager_control(DBusGConnection *connection, int enable)
return 1;
}
+#ifdef HAVE_MCE_DBUS_NAMES
+static int mce_control(DBusGConnection *connection, int enable)
+{
+ GError *error;
+ DBusGProxy *proxy;
+ gboolean ret = 1;
+
+ /* Create a proxy object */
+ proxy = dbus_g_proxy_new_for_name(connection,
+ MCE_SERVICE, MCE_REQUEST_PATH, MCE_REQUEST_IF);
+ if (!proxy) {
+ LOGDBG("Failed to get a proxy for " SM_SERVICE);
+ return 0;
+ }
+
+ error = NULL;
+ if (enable) {
+ ret = dbus_g_proxy_call(proxy, MCE_CANCEL_PREVENT_BLANK_REQ, &error,
+ G_TYPE_INVALID, G_TYPE_INVALID);
+ } else {
+ ret = dbus_g_proxy_call(proxy, MCE_PREVENT_BLANK_REQ, &error,
+ G_TYPE_INVALID, G_TYPE_INVALID);
+ }
+
+ g_object_unref(proxy);
+
+ if (!ret) {
+ /* Check if it's a remote exception or a regular GError */
+ if (error->domain == DBUS_GERROR &&
+ error->code == DBUS_GERROR_REMOTE_EXCEPTION) {
+ LOGMSG(MSG_RemoteMethodException, dbus_g_error_get_name(error), error->message);
+ } else {
+ LOGMSG(MSG_GError, error->message);
+ }
+ g_error_free(error);
+
+ return 0;
+ }
+
+ LOGMSG(enable ? MSG_MCEScreensaverEnabled : MSG_MCEScreensaverDisabled);
+ return 1;
+}
+#endif
+
void gnome_screensaver_control(int enable)
{
DBusGConnection *connection;
@@ -110,6 +161,17 @@ void gnome_screensaver_control(int enable)
g_type_init();
+#ifdef HAVE_MCE_DBUS_NAMES
+ error = NULL;
+ connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
+ if (!connection) {
+ LOGMSG(MSG_OpenBusConnectionError, error ? error->message : "<null>");
+ g_error_free(error);
+ } else if (mce_control(connection, enable)) {
+ return;
+ }
+#endif
+
/* Get a connection to the session bus */
error = NULL;
connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);