summaryrefslogtreecommitdiff
path: root/src/linux/up-backend.c
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2013-02-12 11:00:21 +0000
committerRichard Hughes <richard@hughsie.com>2013-02-12 11:08:35 +0000
commit372c2f8d2922add987683a24b5d69902e05e2f97 (patch)
treee96cfcf7144e9226daa6eb259fb9a072d56ad1b3 /src/linux/up-backend.c
parent9843589d2d80e6dc2b3f51338e64bd1da1c53860 (diff)
Add a --enable-deprecated configure argument
This is turned off by default. If this is not set, then any calls to Suspend(), SuspendAllowed(), Hibernate() or HibernateAllowed() will fail with an error. The error mesage tells the user what new method to port to in logind. I'm expecting to set --enable-deprecated for Fedora 17 and 18, but turn it off for Fedora 19, so other distributions probably want to follow suit to find out what other stuff needs to be ported to the new APIs early. GNOME should already be fine, but KDE will need some solid porting as I understand it. See http://lists.freedesktop.org/archives/devkit-devel/2013-January/001339.html for more information on future plans and for rationale.
Diffstat (limited to 'src/linux/up-backend.c')
-rw-r--r--src/linux/up-backend.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/linux/up-backend.c b/src/linux/up-backend.c
index 3656b69..e77dd1b 100644
--- a/src/linux/up-backend.c
+++ b/src/linux/up-backend.c
@@ -49,6 +49,7 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
+#ifdef ENABLE_DEPRECATED
#ifdef HAVE_SYSTEMD
#include <systemd/sd-daemon.h>
@@ -56,6 +57,7 @@
#define SD_SUSPEND_COMMAND "gdbus call --system --dest org.freedesktop.login1 --object-path /org/freedesktop/login1 --method org.freedesktop.login1.Manager.Suspend 'true'"
#endif
+#endif
static void up_backend_class_init (UpBackendClass *klass);
static void up_backend_init (UpBackend *backend);
@@ -77,7 +79,9 @@ struct UpBackendPrivate
enum {
SIGNAL_DEVICE_ADDED,
SIGNAL_DEVICE_REMOVED,
+#ifdef ENABLE_DEPRECATED
SIGNAL_RESUMING,
+#endif
SIGNAL_LAST
};
@@ -88,8 +92,10 @@ G_DEFINE_TYPE (UpBackend, up_backend, G_TYPE_OBJECT)
static gboolean up_backend_device_add (UpBackend *backend, GUdevDevice *native);
static void up_backend_device_remove (UpBackend *backend, GUdevDevice *native);
+#ifdef ENABLE_DEPRECATED
#define UP_BACKEND_SUSPEND_COMMAND "/usr/sbin/pm-suspend"
#define UP_BACKEND_HIBERNATE_COMMAND "/usr/sbin/pm-hibernate"
+#endif
#define UP_BACKEND_POWERSAVE_TRUE_COMMAND "/usr/sbin/pm-powersave true"
#define UP_BACKEND_POWERSAVE_FALSE_COMMAND "/usr/sbin/pm-powersave false"
@@ -362,6 +368,7 @@ up_backend_coldplug (UpBackend *backend, UpDaemon *daemon)
return TRUE;
}
+#ifdef ENABLE_DEPRECATED
/**
* up_backend_supports_sleep_state:
*
@@ -619,6 +626,7 @@ up_backend_emits_resuming (UpBackend *backend)
#endif
return FALSE;
}
+#endif
/**
* up_backend_get_powersave_command:
@@ -653,16 +661,19 @@ up_backend_class_init (UpBackendClass *klass)
G_STRUCT_OFFSET (UpBackendClass, device_removed),
NULL, NULL, up_marshal_VOID__POINTER_POINTER,
G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
+#ifdef ENABLE_DEPRECATED
signals [SIGNAL_RESUMING] =
g_signal_new ("resuming",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (UpBackendClass, resuming),
NULL, NULL, g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+#endif
g_type_class_add_private (klass, sizeof (UpBackendPrivate));
}
+#ifdef ENABLE_DEPRECATED
static DBusHandlerResult
message_filter (DBusConnection *connection,
DBusMessage *message,
@@ -675,9 +686,9 @@ message_filter (DBusConnection *connection,
g_signal_emit (backend, signals[SIGNAL_RESUMING], 0);
return DBUS_HANDLER_RESULT_HANDLED;
}
-
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
+#endif
/**
* up_backend_init:
@@ -691,6 +702,7 @@ up_backend_init (UpBackend *backend)
backend->priv->device_list = NULL;
backend->priv->managed_devices = up_device_list_new ();
+#ifdef ENABLE_DEPRECATED
#ifdef HAVE_SYSTEMD
if (sd_booted ()) {
DBusGConnection *bus;
@@ -699,6 +711,7 @@ up_backend_init (UpBackend *backend)
dbus_connection_add_filter (backend->priv->connection, message_filter, backend, NULL);
}
#endif
+#endif
}
/**
@@ -723,8 +736,10 @@ up_backend_finalize (GObject *object)
g_object_unref (backend->priv->managed_devices);
+#ifdef ENABLE_DEPRECATED
if (backend->priv->connection)
dbus_connection_remove_filter (backend->priv->connection, message_filter, backend);
+#endif
G_OBJECT_CLASS (up_backend_parent_class)->finalize (object);
}