From 90f66bb16befd7ac31a910d15a99fab7d1956a8f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 2 Sep 2013 15:24:22 +0100 Subject: [PATCH] Listen to systemd sleep/shutdown signals, and inhibit until disconnected Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68758 --- configure.ac | 10 +- src/connectivity-monitor.c | 316 ++++++++++++++++++++++++++++++++++++++++++--- src/connectivity-monitor.h | 4 + src/mcd-account.c | 8 +- src/mcd-connection.c | 38 +++--- src/mcd-connection.h | 4 +- tests/tease-the-minotaur.c | 4 +- 7 files changed, 345 insertions(+), 39 deletions(-) diff --git a/configure.ac b/configure.ac index 44f9898..501a627 100644 --- a/configure.ac +++ b/configure.ac @@ -266,8 +266,14 @@ AC_DEFINE([TP_DISABLE_SINGLE_INCLUDE], [], [Avoid individual headers]) PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.32, gobject-2.0, gmodule-no-export-2.0, gio-2.0]) -AC_SUBST(GLIB_LIBS) -AC_SUBST(GLIB_CFLAGS) + +PKG_CHECK_MODULES([GIO_UNIX], [gio-unix-2.0], + [ + AC_DEFINE(HAVE_GIO_UNIX, [], [Define if GIO-Unix is available]) + GLIB_CFLAGS="$GLIB_CFLAGS $GIO_UNIX_CFLAGS" + GLIB_LIBS="$GLIB_LIBS $GIO_UNIX_LIBS" + ], + []) AC_DEFINE([GLIB_VERSION_MIN_REQUIRED], [GLIB_VERSION_2_30], [Ignore post 2.30 deprecations]) AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [GLIB_VERSION_2_32], [Prevent post 2.32 APIs]) diff --git a/src/connectivity-monitor.c b/src/connectivity-monitor.c index 7015ef2..d0211e0 100644 --- a/src/connectivity-monitor.c +++ b/src/connectivity-monitor.c @@ -25,6 +25,11 @@ #include "config.h" #include "connectivity-monitor.h" +#include + +#ifdef HAVE_GIO_UNIX +#include +#endif #ifdef HAVE_NM #include @@ -38,19 +43,39 @@ #include "mcd-debug.h" +#define LOGIN1_BUS_NAME "org.freedesktop.login1" +#define LOGIN1_MANAGER_OBJECT_PATH "/org/freedesktop/login1" +#define LOGIN1_MANAGER_IFACE "org.freedesktop.login1.Manager" +#define LOGIN1_MANAGER_PREPARE_FOR_SLEEP "PrepareForSleep" +#define LOGIN1_MANAGER_PREPARE_FOR_SHUTDOWN "PrepareForShutdown" +#define LOGIN1_MANAGER_INHIBIT "Inhibit" + +struct _McdInhibit { + gsize holds; + int fd; +}; + typedef enum { - /* Set if the device is not suspended; clear if it is. */ + /* Set if the device is not suspended; clear if it is suspending + * (or suspended, but we don't get scheduled then). */ CONNECTIVITY_AWAKE = (1 << 0), /* Set if GNetworkMonitor says we're up. */ CONNECTIVITY_UP = (1 << 1), /* Clear if NetworkManager says we're in a shaky state like * disconnecting (the GNetworkMonitor can't tell this). Set otherwise. */ - CONNECTIVITY_STABLE = (1 << 2) + CONNECTIVITY_STABLE = (1 << 2), + /* Set if the device is not shutting down, clear if it is. */ + CONNECTIVITY_RUNNING = (1 << 3) } Connectivity; struct _McdConnectivityMonitorPrivate { GNetworkMonitor *network_monitor; + GDBusConnection *system_bus; + guint login1_prepare_for_sleep_id; + guint login1_prepare_for_shutdown_id; + McdInhibit *login1_inhibit; + #ifdef HAVE_NM NMClient *nm_client; gulong state_change_signal_id; @@ -89,14 +114,16 @@ is_connected (Connectivity connectivity) { return ((connectivity & CONNECTIVITY_AWAKE) && (connectivity & CONNECTIVITY_UP) && - (connectivity & CONNECTIVITY_STABLE)); + (connectivity & CONNECTIVITY_STABLE) && + (connectivity & CONNECTIVITY_RUNNING)); } static void connectivity_monitor_change_states ( McdConnectivityMonitor *self, Connectivity set, - Connectivity clear) + Connectivity clear, + McdInhibit *inhibit) { McdConnectivityMonitorPrivate *priv = self->priv; Connectivity connectivity = ((priv->connectivity | set) & (~clear)); @@ -106,12 +133,23 @@ connectivity_monitor_change_states ( if (priv->connectivity == connectivity) return; + DEBUG ("awake: %d -> %d; up: %d -> %d; stable: %d -> %d; running: %d -> %d", + (priv->connectivity & CONNECTIVITY_AWAKE), + (connectivity & CONNECTIVITY_AWAKE), + (priv->connectivity & CONNECTIVITY_UP), + (connectivity & CONNECTIVITY_UP), + (priv->connectivity & CONNECTIVITY_STABLE), + (connectivity & CONNECTIVITY_STABLE), + (priv->connectivity & CONNECTIVITY_RUNNING), + (connectivity & CONNECTIVITY_RUNNING)); + priv->connectivity = connectivity; if (old_total != new_total) { DEBUG ("%s", new_total ? "connected" : "disconnected"); - g_signal_emit (self, signals[STATE_CHANGE], 0, new_total); + g_signal_emit (self, signals[STATE_CHANGE], 0, new_total, + inhibit); } } @@ -148,13 +186,13 @@ connectivity_monitor_nm_state_change_cb (NMClient *client, DEBUG ("New NetworkManager network state %d (unstable state)", state); connectivity_monitor_change_states (connectivity_monitor, - 0, CONNECTIVITY_STABLE); + 0, CONNECTIVITY_STABLE, NULL); } else { DEBUG ("New NetworkManager network state %d (stable state)", state); connectivity_monitor_change_states (connectivity_monitor, - CONNECTIVITY_STABLE, 0); + CONNECTIVITY_STABLE, 0, NULL); } } #endif @@ -176,14 +214,14 @@ connectivity_monitor_network_changed (GNetworkMonitor *monitor, DEBUG ("GNetworkMonitor (%s) says we are at least partially online", G_OBJECT_TYPE_NAME (monitor)); connectivity_monitor_change_states (connectivity_monitor, - CONNECTIVITY_UP, 0); + CONNECTIVITY_UP, 0, NULL); } else { DEBUG ("GNetworkMonitor (%s) says we are offline", G_OBJECT_TYPE_NAME (monitor)); connectivity_monitor_change_states (connectivity_monitor, - 0, CONNECTIVITY_UP); + 0, CONNECTIVITY_UP, NULL); } } @@ -194,9 +232,9 @@ connectivity_monitor_set_awake ( gboolean awake) { if (awake) - connectivity_monitor_change_states (self, CONNECTIVITY_AWAKE, 0); + connectivity_monitor_change_states (self, CONNECTIVITY_AWAKE, 0, NULL); else - connectivity_monitor_change_states (self, 0, CONNECTIVITY_AWAKE); + connectivity_monitor_change_states (self, 0, CONNECTIVITY_AWAKE, NULL); } static void @@ -224,6 +262,201 @@ notify_resume_cb ( } #endif +#ifdef HAVE_GIO_UNIX +static void +login1_inhibit_cb (GObject *source G_GNUC_UNUSED, + GAsyncResult *result, + gpointer user_data) +{ + McdConnectivityMonitor *self = MCD_CONNECTIVITY_MONITOR (user_data); + GUnixFDList *fds = NULL; + GError *error = NULL; + GVariant *tuple = g_dbus_connection_call_with_unix_fd_list_finish ( + self->priv->system_bus, &fds, result, &error); + + if (tuple != NULL) + { + gint32 i; + + g_variant_get (tuple, "(h)", &i); + + if (g_unix_fd_list_get_length (fds) > i) + { + g_warn_if_fail (self->priv->login1_inhibit->fd == -1); + self->priv->login1_inhibit->fd = g_unix_fd_list_get (fds, i, &error); + + if (self->priv->login1_inhibit->fd >= 0) + { + DEBUG ("fd %d inhibits login1 sleep/shutdown", + self->priv->login1_inhibit->fd); + } + else + { + DEBUG ("unable to duplicate fd: %s #%d: %s", + g_quark_to_string (error->domain), error->code, + error->message); + g_error_free (error); + mcd_inhibit_release (self->priv->login1_inhibit); + self->priv->login1_inhibit = NULL; + } + } + else + { + DEBUG ("Inhibit() didn't return enough fds?"); + } + } + else + { + DEBUG ("unable to delay sleep and shutdown: %s #%d: %s", + g_quark_to_string (error->domain), error->code, error->message); + g_error_free (error); + } + + g_clear_object (&fds); + g_object_unref (self); +} +#endif + +static void +connectivity_monitor_renew_inhibit (McdConnectivityMonitor *self) +{ +#ifdef HAVE_GIO_UNIX + if (self->priv->login1_inhibit != NULL) + return; + + self->priv->login1_inhibit = g_slice_new (McdInhibit); + self->priv->login1_inhibit->holds = 1; + self->priv->login1_inhibit->fd = -1; + + g_dbus_connection_call_with_unix_fd_list (self->priv->system_bus, + LOGIN1_BUS_NAME, LOGIN1_MANAGER_OBJECT_PATH, + LOGIN1_MANAGER_IFACE, LOGIN1_MANAGER_INHIBIT, + g_variant_new ("(ssss)", "sleep:shutdown", + "Telepathy", "Disconnecting IM accounts before suspend/shutdown...", + "delay"), + G_VARIANT_TYPE ("(h)"), G_DBUS_CALL_FLAGS_NONE, + -1, NULL, NULL, login1_inhibit_cb, g_object_ref (self)); +#endif +} + +static void +login1_prepare_for_sleep_cb (GDBusConnection *system_bus G_GNUC_UNUSED, + const gchar *sender_name G_GNUC_UNUSED, + const gchar *object_path G_GNUC_UNUSED, + const gchar *interface_name G_GNUC_UNUSED, + const gchar *signal_name G_GNUC_UNUSED, + GVariant *parameters, + gpointer user_data) +{ + McdConnectivityMonitor *self = MCD_CONNECTIVITY_MONITOR (user_data); + + if (g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(b)"))) + { + gboolean sleeping; + + g_variant_get (parameters, "(b)", &sleeping); + + if (sleeping) + { + DEBUG ("about to suspend"); + connectivity_monitor_change_states (self, 0, CONNECTIVITY_AWAKE, + self->priv->login1_inhibit); + } + else + { + DEBUG ("woke up, or suspend was cancelled"); + connectivity_monitor_renew_inhibit (self); + connectivity_monitor_change_states (self, CONNECTIVITY_AWAKE, 0, + self->priv->login1_inhibit); + } + } + else if (DEBUGGING) + { + gchar *pretty = g_variant_print (parameters, TRUE); + + DEBUG ("ignoring PrepareForSleep signal not of type (b): %s", pretty); + g_free (pretty); + } +} + +static void +login1_prepare_for_shutdown_cb (GDBusConnection *system_bus G_GNUC_UNUSED, + const gchar *sender_name G_GNUC_UNUSED, + const gchar *object_path G_GNUC_UNUSED, + const gchar *interface_name G_GNUC_UNUSED, + const gchar *signal_name G_GNUC_UNUSED, + GVariant *parameters, + gpointer user_data) +{ + McdConnectivityMonitor *self = MCD_CONNECTIVITY_MONITOR (user_data); + + if (g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(b)"))) + { + gboolean shutting_down; + + g_variant_get (parameters, "(b)", &shutting_down); + + if (shutting_down) + { + DEBUG ("about to shut down"); + connectivity_monitor_change_states (self, 0, CONNECTIVITY_RUNNING, + self->priv->login1_inhibit); + } + else + { + DEBUG ("shutdown was cancelled"); + connectivity_monitor_renew_inhibit (self); + connectivity_monitor_change_states (self, CONNECTIVITY_RUNNING, 0, + self->priv->login1_inhibit); + } + } + else if (DEBUGGING) + { + gchar *pretty = g_variant_print (parameters, TRUE); + + DEBUG ("ignoring PrepareForShutdown signal not of type (b): %s", pretty); + g_free (pretty); + } +} + +static void +got_system_bus_cb (GObject *source G_GNUC_UNUSED, + GAsyncResult *result, + gpointer user_data) +{ + McdConnectivityMonitor *self = MCD_CONNECTIVITY_MONITOR (user_data); + GError *error = NULL; + + self->priv->system_bus = g_bus_get_finish (result, &error); + + if (self->priv->system_bus != NULL) + { + self->priv->login1_prepare_for_sleep_id = + g_dbus_connection_signal_subscribe (self->priv->system_bus, + LOGIN1_BUS_NAME, LOGIN1_MANAGER_IFACE, + LOGIN1_MANAGER_PREPARE_FOR_SLEEP, LOGIN1_MANAGER_OBJECT_PATH, + NULL, G_DBUS_SIGNAL_FLAGS_NONE, login1_prepare_for_sleep_cb, + self, NULL); + + self->priv->login1_prepare_for_shutdown_id = + g_dbus_connection_signal_subscribe (self->priv->system_bus, + LOGIN1_BUS_NAME, LOGIN1_MANAGER_IFACE, + LOGIN1_MANAGER_PREPARE_FOR_SHUTDOWN, LOGIN1_MANAGER_OBJECT_PATH, + NULL, G_DBUS_SIGNAL_FLAGS_NONE, login1_prepare_for_shutdown_cb, + self, NULL); + + connectivity_monitor_renew_inhibit (self); + } + else + { + DEBUG ("unable to connect to system bus: %s #%d: %s", + g_quark_to_string (error->domain), error->code, error->message); + g_error_free (error); + } + + g_object_unref (self); +} + static void mcd_connectivity_monitor_init (McdConnectivityMonitor *connectivity_monitor) { @@ -237,7 +470,7 @@ mcd_connectivity_monitor_init (McdConnectivityMonitor *connectivity_monitor) priv->use_conn = TRUE; /* Initially, assume everything is good. */ priv->connectivity = CONNECTIVITY_AWAKE | CONNECTIVITY_STABLE | - CONNECTIVITY_UP; + CONNECTIVITY_UP | CONNECTIVITY_RUNNING; priv->network_monitor = g_network_monitor_get_default (); @@ -280,6 +513,9 @@ mcd_connectivity_monitor_init (McdConnectivityMonitor *connectivity_monitor) "notify-resume", G_CALLBACK (notify_resume_cb), connectivity_monitor, G_CONNECT_AFTER); #endif + + g_bus_get (G_BUS_TYPE_SYSTEM, NULL, got_system_bus_cb, + g_object_ref (connectivity_monitor)); } static void @@ -308,6 +544,17 @@ connectivity_monitor_finalize (GObject *object) G_OBJECT_CLASS (mcd_connectivity_monitor_parent_class)->finalize (object); } +static inline void +clear_subscription (GDBusConnection *conn, + guint *subscription) +{ + if (*subscription == 0) + return; + + g_dbus_connection_signal_unsubscribe (conn, *subscription); + *subscription = 0; +} + static void connectivity_monitor_dispose (GObject *object) { @@ -319,6 +566,14 @@ connectivity_monitor_dispose (GObject *object) g_clear_object (&self->priv->settings); #endif + clear_subscription (self->priv->system_bus, + &self->priv->login1_prepare_for_sleep_id); + clear_subscription (self->priv->system_bus, + &self->priv->login1_prepare_for_shutdown_id); + tp_clear_pointer (&self->priv->login1_inhibit, mcd_inhibit_release); + + g_clear_object (&self->priv->system_bus); + G_OBJECT_CLASS (mcd_connectivity_monitor_parent_class)->dispose (object); } @@ -401,10 +656,9 @@ mcd_connectivity_monitor_class_init (McdConnectivityMonitorClass *klass) G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, - NULL, NULL, - g_cclosure_marshal_VOID__BOOLEAN, + NULL, NULL, NULL, G_TYPE_NONE, - 1, G_TYPE_BOOLEAN, NULL); + 2, G_TYPE_BOOLEAN, G_TYPE_POINTER); g_object_class_install_property (oclass, PROP_USE_CONN, @@ -469,8 +723,38 @@ mcd_connectivity_monitor_set_use_conn (McdConnectivityMonitor *connectivity_moni { /* !use_conn basically means "always assume it's stable and up". */ connectivity_monitor_change_states (connectivity_monitor, - CONNECTIVITY_STABLE|CONNECTIVITY_UP, 0); + CONNECTIVITY_STABLE|CONNECTIVITY_UP, 0, NULL); } g_object_notify (G_OBJECT (connectivity_monitor), "use-conn"); } + +McdInhibit * +mcd_inhibit_hold (McdInhibit *inhibit) +{ + DEBUG ("%p (fd %d): %" G_GSIZE_FORMAT " -> %" G_GSIZE_FORMAT, + inhibit, inhibit->fd, inhibit->holds, inhibit->holds + 1); + + inhibit->holds++; + return inhibit; +} + +void +mcd_inhibit_release (McdInhibit *inhibit) +{ + DEBUG ("%p (fd %d): %" G_GSIZE_FORMAT " -> %" G_GSIZE_FORMAT, + inhibit, inhibit->fd, inhibit->holds, inhibit->holds - 1); + + if (--inhibit->holds == 0) + { + /* Not using the retry-on-EINTR idiom: see g_close() in GLib 2.36. + * After we depend on GLib 2.36, we could use g_close(). */ + if (inhibit->fd != -1 && + close (inhibit->fd) != 0) + { + WARNING ("unable to close fd, ignoring: %s", g_strerror (errno)); + } + + g_slice_free (McdInhibit, inhibit); + } +} diff --git a/src/connectivity-monitor.h b/src/connectivity-monitor.h index ce4b59e..de10e10 100644 --- a/src/connectivity-monitor.h +++ b/src/connectivity-monitor.h @@ -68,6 +68,10 @@ gboolean mcd_connectivity_monitor_get_use_conn (McdConnectivityMonitor *connecti void mcd_connectivity_monitor_set_use_conn (McdConnectivityMonitor *connectivity, gboolean use_conn); +typedef struct _McdInhibit McdInhibit; +McdInhibit *mcd_inhibit_hold (McdInhibit *inhibit); +void mcd_inhibit_release (McdInhibit *inhibit); + G_END_DECLS #endif /* MCD_CONNECTIVITY_MONITOR_H */ diff --git a/src/mcd-account.c b/src/mcd-account.c index ecc3075..e1b8fed 100644 --- a/src/mcd-account.c +++ b/src/mcd-account.c @@ -2981,7 +2981,7 @@ _mcd_account_reconnect (McdAccount *self, * back from the CM yet, the old parameters will still be used, I think * (I can't quite make out what actually happens). */ if (self->priv->connection) - mcd_connection_close (self->priv->connection); + mcd_connection_close (self->priv->connection, NULL); _mcd_account_connection_begin (self, user_initiated); } @@ -3611,6 +3611,7 @@ static void monitor_state_changed_cb ( McdConnectivityMonitor *monitor, gboolean connected, + McdInhibit *inhibit, gpointer user_data) { McdAccount *self = MCD_ACCOUNT (user_data); @@ -3638,8 +3639,9 @@ monitor_state_changed_cb ( DEBUG ("account %s must disconnect", self->priv->unique_name); connection = mcd_account_get_connection (self); - if (connection) - mcd_connection_close (connection); + + if (connection != NULL) + mcd_connection_close (connection, inhibit); } } diff --git a/src/mcd-connection.c b/src/mcd-connection.c index 93b81d5..c82f2d5 100644 --- a/src/mcd-connection.c +++ b/src/mcd-connection.c @@ -175,7 +175,8 @@ static const gchar * const *presence_fallbacks[] = { _available_fb, _away_fb, _ext_away_fb, _hidden_fb, _busy_fb }; -static void _mcd_connection_release_tp_connection (McdConnection *connection); +static void _mcd_connection_release_tp_connection (McdConnection *connection, + McdInhibit *inhibit); static gboolean request_channel_new_iface (McdConnection *connection, McdChannel *channel); @@ -480,12 +481,15 @@ static void disconnect_cb (TpConnection *proxy, const GError *error, gpointer user_data, GObject *weak_object) { - if (error) - g_warning ("Disconnect failed: %s", error->message); + if (error != NULL) + WARNING ("Disconnect failed: %s", error->message); + else + DEBUG ("Disconnected %s", tp_proxy_get_object_path (TP_PROXY (proxy))); } static void -_mcd_connection_call_disconnect (McdConnection *connection) +_mcd_connection_call_disconnect (McdConnection *connection, + McdInhibit *inhibit) { TpConnection *tp_conn = connection->priv->tp_conn; @@ -494,10 +498,10 @@ _mcd_connection_call_disconnect (McdConnection *connection) if (tp_connection_get_status (tp_conn, NULL) == TP_CONNECTION_STATUS_DISCONNECTED) return; - tp_cli_connection_call_disconnect (tp_conn, -1, - disconnect_cb, - NULL, NULL, - (GObject *)connection); + tp_cli_connection_call_disconnect (tp_conn, -1, disconnect_cb, + inhibit ? mcd_inhibit_hold (inhibit) : NULL, + inhibit ? (GDestroyNotify) mcd_inhibit_release : NULL, + NULL); } @@ -525,7 +529,7 @@ _mcd_connection_request_presence (McdConnection *self, /* Connection Proxy */ self->priv->abort_reason = TP_CONNECTION_STATUS_REASON_REQUESTED; mcd_mission_disconnect (MCD_MISSION (self)); - _mcd_connection_call_disconnect (self); + _mcd_connection_call_disconnect (self, NULL); /* if a reconnection attempt is scheduled, cancel it */ if (self->priv->reconnect_timer) @@ -792,7 +796,7 @@ mcd_connection_invalidated_cb (TpConnection *tp_conn, DEBUG ("Proxy destroyed (%s)!", message); - _mcd_connection_release_tp_connection (connection); + _mcd_connection_release_tp_connection (connection, NULL); if (priv->connected && priv->abort_reason != TP_CONNECTION_STATUS_REASON_REQUESTED && @@ -1606,7 +1610,8 @@ _mcd_connection_finalize (GObject * object) } static void -_mcd_connection_release_tp_connection (McdConnection *connection) +_mcd_connection_release_tp_connection (McdConnection *connection, + McdInhibit *inhibit) { McdConnectionPrivate *priv = MCD_CONNECTION_PRIV (connection); @@ -1645,7 +1650,7 @@ _mcd_connection_release_tp_connection (McdConnection *connection) g_signal_handlers_disconnect_by_func (G_OBJECT (priv->tp_conn), G_CALLBACK (mcd_connection_invalidated_cb), connection); - _mcd_connection_call_disconnect (connection); + _mcd_connection_call_disconnect (connection, inhibit); /* the tp_connection has gone away, so we no longer need (or want) * the probation timer to go off: there's nothing for it to check */ @@ -1727,7 +1732,7 @@ _mcd_connection_dispose (GObject * object) mcd_operation_foreach (MCD_OPERATION (connection), (GFunc) _foreach_channel_remove, connection); - _mcd_connection_release_tp_connection (connection); + _mcd_connection_release_tp_connection (connection, NULL); g_assert (priv->tp_conn == NULL); if (priv->account) @@ -2186,13 +2191,14 @@ mcd_connection_request_channel (McdConnection *connection, } void -mcd_connection_close (McdConnection *connection) +mcd_connection_close (McdConnection *connection, + McdInhibit *inhibit) { g_return_if_fail (MCD_IS_CONNECTION (connection)); connection->priv->closed = TRUE; connection->priv->abort_reason = TP_CONNECTION_STATUS_REASON_REQUESTED; - _mcd_connection_release_tp_connection (connection); + _mcd_connection_release_tp_connection (connection, inhibit); mcd_mission_abort (MCD_MISSION (connection)); } @@ -2326,7 +2332,7 @@ _mcd_connection_set_tp_connection (McdConnection *connection, } DEBUG ("releasing old connection first"); - _mcd_connection_release_tp_connection (connection); + _mcd_connection_release_tp_connection (connection, NULL); } g_assert (priv->tp_conn == NULL); diff --git a/src/mcd-connection.h b/src/mcd-connection.h index 8f450b9..90bfce7 100644 --- a/src/mcd-connection.h +++ b/src/mcd-connection.h @@ -30,6 +30,7 @@ #include #include +#include "connectivity-monitor.h" /* for McdInhibit */ #include "mcd-operation.h" G_BEGIN_DECLS @@ -72,7 +73,8 @@ TpConnection *mcd_connection_get_tp_connection (McdConnection *connection); gboolean mcd_connection_request_channel (McdConnection *connection, McdChannel *channel); -void mcd_connection_close (McdConnection *connection); +void mcd_connection_close (McdConnection *connection, + McdInhibit *inhibit); McdChannel * mcd_connection_find_channel_by_path (McdConnection *connection, const gchar *object_path); diff --git a/tests/tease-the-minotaur.c b/tests/tease-the-minotaur.c index 50f5a6c..ed7a61f 100644 --- a/tests/tease-the-minotaur.c +++ b/tests/tease-the-minotaur.c @@ -30,6 +30,7 @@ static void state_change_cb ( McdConnectivityMonitor *minotaur, gboolean connected, + McdInhibit *inhibit, gpointer user_data) { g_print (connected ? "connected\n" : "disconnected\n"); @@ -47,7 +48,8 @@ main ( minotaur = mcd_connectivity_monitor_new (); g_signal_connect (minotaur, "state-change", (GCallback) state_change_cb, NULL); - state_change_cb (minotaur, mcd_connectivity_monitor_is_online (minotaur), NULL); + state_change_cb (minotaur, mcd_connectivity_monitor_is_online (minotaur), + NULL, NULL); im_feeling_loopy = g_main_loop_new (NULL, FALSE); g_main_loop_run (im_feeling_loopy); -- 1.8.4.rc3