diff options
author | Wu Xiaotian <[email protected]> | 2020-04-28 17:06:07 +0800 |
---|---|---|
committer | Xiaotian Wu <[email protected]> | 2023-10-03 18:44:26 +0800 |
commit | 7cba004dfcd621cfa193c389a01de11526c701d9 (patch) | |
tree | e9ee8a14e11f4dafde74c6cfc267da9d89b19870 | |
parent | aa8baa90d497a54410676190e784986e185a8745 (diff) | |
download | mate-session-manager-7cba004dfcd621cfa193c389a01de11526c701d9.tar.bz2 mate-session-manager-7cba004dfcd621cfa193c389a01de11526c701d9.tar.xz |
update
-rw-r--r-- | mate-session/Makefile.am | 84 | ||||
-rw-r--r-- | mate-session/gs-idle-monitor.c | 4 | ||||
-rw-r--r-- | mate-session/gsm-app.c | 127 | ||||
-rw-r--r-- | mate-session/gsm-app.h | 11 | ||||
-rw-r--r-- | mate-session/gsm-autostart-app.c | 18 | ||||
-rw-r--r-- | mate-session/gsm-client.c | 242 | ||||
-rw-r--r-- | mate-session/gsm-client.h | 20 | ||||
-rw-r--r-- | mate-session/gsm-consolekit.c | 8 | ||||
-rw-r--r-- | mate-session/gsm-dbus-client.c | 495 | ||||
-rw-r--r-- | mate-session/gsm-dbus-client.h | 26 | ||||
-rw-r--r-- | mate-session/gsm-inhibitor.c | 228 | ||||
-rw-r--r-- | mate-session/gsm-inhibitor.h | 20 | ||||
-rw-r--r-- | mate-session/gsm-manager.c | 206 | ||||
-rw-r--r-- | mate-session/gsm-presence.c | 368 | ||||
-rw-r--r-- | mate-session/gsm-presence.h | 14 | ||||
-rw-r--r-- | mate-session/gsm-systemd.c | 10 | ||||
-rw-r--r-- | mate-session/gsm-xsmp-client.c | 26 | ||||
-rw-r--r-- | mate-session/org.gnome.SessionManager.xml | 4 |
18 files changed, 773 insertions, 1138 deletions
diff --git a/mate-session/Makefile.am b/mate-session/Makefile.am index 448ee76..7e1efa4 100644 --- a/mate-session/Makefile.am +++ b/mate-session/Makefile.am @@ -104,29 +104,75 @@ gsm-marshal.c: gsm-marshal.list gsm-marshal.h: gsm-marshal.list $(AM_V_GEN)$(GLIB_GENMARSHAL) $< --prefix=gsm_marshal --header > $@ -gsm-manager-glue.h: org.gnome.SessionManager.xml Makefile.am - $(AM_V_GEN)dbus-binding-tool --prefix=gsm_manager --mode=glib-server --output=gsm-manager-glue.h $(srcdir)/org.gnome.SessionManager.xml - -gsm-client-glue.h: org.gnome.SessionManager.Client.xml Makefile.am - $(AM_V_GEN)dbus-binding-tool --prefix=gsm_client --mode=glib-server --output=gsm-client-glue.h $(srcdir)/org.gnome.SessionManager.Client.xml - -gsm-app-glue.h: org.gnome.SessionManager.App.xml Makefile.am - $(AM_V_GEN)dbus-binding-tool --prefix=gsm_app --mode=glib-server --output=gsm-app-glue.h $(srcdir)/org.gnome.SessionManager.App.xml - -gsm-inhibitor-glue.h: org.gnome.SessionManager.Inhibitor.xml Makefile.am - $(AM_V_GEN)dbus-binding-tool --prefix=gsm_inhibitor --mode=glib-server --output=gsm-inhibitor-glue.h $(srcdir)/org.gnome.SessionManager.Inhibitor.xml - -gsm-presence-glue.h: org.gnome.SessionManager.Presence.xml Makefile.am - $(AM_V_GEN)dbus-binding-tool --prefix=gsm_presence --mode=glib-server --output=gsm-presence-glue.h $(srcdir)/org.gnome.SessionManager.Presence.xml +org.gnome.SessionManager.h: org.gnome.SessionManager.xml Makefile.am + $(AM_V_GEN) gdbus-codegen --interface-prefix org.gnome.SessionManager. \ + --generate-c-code org.gnome.SessionManager \ + --c-namespace Gsm \ + --annotate "org.gnome.SessionManager" "org.gtk.GDBus.C.Name" ExportedManager \ + $(srcdir)/org.gnome.SessionManager.xml +org.gnome.SessionManager.c: org.gnome.SessionManager.h + @: # generated as a side-effect + +org.gnome.SessionManager.Client.h: org.gnome.SessionManager.Client.xml Makefile.am + $(AM_V_GEN) gdbus-codegen --interface-prefix org.gnome.SessionManager.Client. \ + --generate-c-code org.gnome.SessionManager.Client \ + --c-namespace Gsm \ + --annotate "org.gnome.SessionManager.Client" "org.gtk.GDBus.C.Name" ExportedClient \ + $(srcdir)/org.gnome.SessionManager.Client.xml +org.gnome.SessionManager.Client.c: org.gnome.SessionManager.Client.h + @: # generated as a side-effect + +org.gnome.SessionManager.ClientPrivate.h: org.gnome.SessionManager.ClientPrivate.xml Makefile.am + $(AM_V_GEN) gdbus-codegen --interface-prefix org.gnome.SessionManager.ClientPrivate. \ + --generate-c-code org.gnome.SessionManager.ClientPrivate \ + --c-namespace Gsm \ + --annotate "org.gnome.SessionManager.ClientPrivate" "org.gtk.GDBus.C.Name" ExportedClientPrivate \ + $(srcdir)/org.gnome.SessionManager.ClientPrivate.xml +org.gnome.SessionManager.ClientPrivate.c: org.gnome.SessionManager.ClientPrivate.h + @: # generated as a side-effect + +org.gnome.SessionManager.App.h: org.gnome.SessionManager.App.xml Makefile.am + $(AM_V_GEN) gdbus-codegen --interface-prefix org.gnome.SessionManager.App. \ + --generate-c-code org.gnome.SessionManager.App \ + --c-namespace Gsm \ + --annotate "org.gnome.SessionManager.App" "org.gtk.GDBus.C.Name" ExportedApp \ + $(srcdir)/org.gnome.SessionManager.App.xml +org.gnome.SessionManager.App.c: org.gnome.SessionManager.App.h + @: # generated as a side-effect + +org.gnome.SessionManager.Inhibitor.h: org.gnome.SessionManager.Inhibitor.xml Makefile.am + $(AM_V_GEN) gdbus-codegen --interface-prefix org.gnome.SessionManager.Inhibitor. \ + --generate-c-code org.gnome.SessionManager.Inhibitor \ + --c-namespace Gsm \ + --annotate "org.gnome.SessionManager.Inhibitor" "org.gtk.GDBus.C.Name" ExportedInhibitor \ + $(srcdir)/org.gnome.SessionManager.Inhibitor.xml +org.gnome.SessionManager.Inhibitor.c: org.gnome.SessionManager.Inhibitor.h + @: # generated as a side-effect + +org.gnome.SessionManager.Presence.h: org.gnome.SessionManager.Presence.xml Makefile.am + $(AM_V_GEN) gdbus-codegen --interface-prefix org.gnome.SessionManager.Presence. \ + --generate-c-code org.gnome.SessionManager.Presence \ + --c-namespace Gsm \ + --annotate "org.gnome.SessionManager.Presence" "org.gtk.GDBus.C.Name" ExportedPresence \ + $(srcdir)/org.gnome.SessionManager.Presence.xml +org.gnome.SessionManager.Presence.c: org.gnome.SessionManager.Presence.h + @: # generated as a side-effect BUILT_SOURCES = \ gsm-marshal.c \ gsm-marshal.h \ - gsm-manager-glue.h \ - gsm-presence-glue.h \ - gsm-inhibitor-glue.h \ - gsm-client-glue.h \ - gsm-app-glue.h + org.gnome.SessionManager.App.h \ + org.gnome.SessionManager.App.c \ + org.gnome.SessionManager.Client.h \ + org.gnome.SessionManager.Client.c \ + org.gnome.SessionManager.ClientPrivate.h \ + org.gnome.SessionManager.ClientPrivate.c \ + org.gnome.SessionManager.Inhibitor.h \ + org.gnome.SessionManager.Inhibitor.c \ + org.gnome.SessionManager.h \ + org.gnome.SessionManager.c \ + org.gnome.SessionManager.Presence.h \ + org.gnome.SessionManager.Presence.c EXTRA_DIST = \ README \ diff --git a/mate-session/gs-idle-monitor.c b/mate-session/gs-idle-monitor.c index 375cf5d..e613e5c 100644 --- a/mate-session/gs-idle-monitor.c +++ b/mate-session/gs-idle-monitor.c @@ -104,7 +104,7 @@ gs_idle_monitor_dispose (GObject *object) } static gboolean -_find_alarm (gpointer key, +_find_alarm (gpointer key G_GNUC_UNUSED, GSIdleMonitorWatch *watch, XSyncAlarm *alarm) { @@ -217,7 +217,7 @@ handle_alarm_notify_event (GSIdleMonitor *monitor, static GdkFilterReturn xevent_filter (GdkXEvent *xevent, - GdkEvent *event, + GdkEvent *event G_GNUC_UNUSED, GSIdleMonitor *monitor) { XEvent *ev; diff --git a/mate-session/gsm-app.c b/mate-session/gsm-app.c index 6d7a058..2edde33 100644 --- a/mate-session/gsm-app.c +++ b/mate-session/gsm-app.c @@ -28,14 +28,15 @@ #include <string.h> #include "gsm-app.h" -#include "gsm-app-glue.h" +#include "org.gnome.SessionManager.App.h" typedef struct { char *id; char *app_id; int phase; char *startup_id; - DBusGConnection *connection; + GDBusConnection *connection; + GsmExportedApp *skeleton; } GsmAppPrivate; enum { @@ -71,6 +72,46 @@ gsm_app_error_quark (void) } +static gboolean +gsm_app_get_app_id (GsmExportedApp *skeleton, + GDBusMethodInvocation *invocation, + GsmApp *app) +{ + const gchar *id; + + id = GSM_APP_GET_CLASS (app)->impl_get_app_id (app); + gsm_exported_app_complete_get_app_id (skeleton, invocation, id); + + return TRUE; +} + +static gboolean +gsm_app_get_startup_id (GsmExportedApp *skeleton, + GDBusMethodInvocation *invocation, + GsmApp *app) +{ + const gchar *id; + GsmAppPrivate *priv; + + priv = gsm_app_get_instance_private (app); + id = g_strdup (priv->startup_id); + gsm_exported_app_complete_get_startup_id (skeleton, invocation, id); + + return TRUE; +} + +static gboolean +gsm_app_get_phase (GsmExportedApp *skeleton, + GDBusMethodInvocation *invocation, + GsmApp *app) +{ + GsmAppPrivate *priv; + + priv = gsm_app_get_instance_private (app); + gsm_exported_app_complete_get_phase (skeleton, invocation, priv->phase); + return TRUE; +} + static guint32 get_next_app_serial (void) { @@ -90,20 +131,36 @@ register_app (GsmApp *app) { GError *error; GsmAppPrivate *priv; + GsmExportedApp *skeleton; error = NULL; priv = gsm_app_get_instance_private (app); - priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - if (priv->connection == NULL) { - if (error != NULL) { - g_critical ("error getting session bus: %s", error->message); - g_error_free (error); - } + priv->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); + if (error != NULL) { + g_critical ("error getting session bus: %s", error->message); + g_error_free (error); + return FALSE; + } + + skeleton = gsm_exported_app_skeleton_new (); + priv->skeleton = skeleton; + g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (skeleton), + priv->connection, priv->id, + &error); + + if (error != NULL) { + g_critical ("error registering app on session bus: %s", error->message); + g_error_free (error); return FALSE; } - dbus_g_connection_register_g_object (priv->connection, priv->id, G_OBJECT (app)); + g_signal_connect (skeleton, "handle-get-app-id", + G_CALLBACK (gsm_app_get_app_id), app); + g_signal_connect (skeleton, "handle-get-phase", + G_CALLBACK (gsm_app_get_phase), app); + g_signal_connect (skeleton, "handle-get-startup-id", + G_CALLBACK (gsm_app_get_startup_id), app); return TRUE; } @@ -134,7 +191,7 @@ gsm_app_constructor (GType type, } static void -gsm_app_init (GsmApp *app) +gsm_app_init (GsmApp G_GNUC_UNUSED *app) { } @@ -185,7 +242,7 @@ static void gsm_app_set_property (GObject *object, guint prop_id, const GValue *value, - GParamSpec *pspec) + GParamSpec *pspec G_GNUC_UNUSED) { GsmApp *app = GSM_APP (object); @@ -208,7 +265,7 @@ static void gsm_app_get_property (GObject *object, guint prop_id, GValue *value, - GParamSpec *pspec) + GParamSpec *pspec G_GNUC_UNUSED) { GsmAppPrivate *priv; GsmApp *app = GSM_APP (object); @@ -244,6 +301,14 @@ gsm_app_dispose (GObject *object) g_free (priv->id); priv->id = NULL; + if (priv->skeleton != NULL) { + g_dbus_interface_skeleton_unexport_from_connection (G_DBUS_INTERFACE_SKELETON (priv->skeleton), + priv->connection); + g_clear_object (&priv->skeleton); + } + + g_clear_object (&priv->connection); + G_OBJECT_CLASS (gsm_app_parent_class)->dispose (object); } @@ -316,8 +381,6 @@ gsm_app_class_init (GsmAppClass *klass) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - - dbus_g_object_type_install_info (GSM_TYPE_APP, &dbus_glib_gsm_app_object_info); } const char * @@ -501,39 +564,3 @@ gsm_app_died (GsmApp *app) g_signal_emit (app, signals[DIED], 0); } - -gboolean -gsm_app_get_app_id (GsmApp *app, - char **id, - GError **error) -{ - g_return_val_if_fail (GSM_IS_APP (app), FALSE); - *id = g_strdup (GSM_APP_GET_CLASS (app)->impl_get_app_id (app)); - return TRUE; -} - -gboolean -gsm_app_get_startup_id (GsmApp *app, - char **id, - GError **error) -{ - GsmAppPrivate *priv; - g_return_val_if_fail (GSM_IS_APP (app), FALSE); - - priv = gsm_app_get_instance_private (app); - *id = g_strdup (priv->startup_id); - return TRUE; -} - -gboolean -gsm_app_get_phase (GsmApp *app, - guint *phase, - GError **error) -{ - GsmAppPrivate *priv; - g_return_val_if_fail (GSM_IS_APP (app), FALSE); - - priv = gsm_app_get_instance_private (app); - *phase = priv->phase; - return TRUE; -} diff --git a/mate-session/gsm-app.h b/mate-session/gsm-app.h index 96a06d1..8c2424a 100644 --- a/mate-session/gsm-app.h +++ b/mate-session/gsm-app.h @@ -104,17 +104,6 @@ gboolean gsm_app_has_autostart_condition (GsmApp *app, void gsm_app_registered (GsmApp *app); int gsm_app_peek_autostart_delay (GsmApp *app); -/* exported to bus */ -gboolean gsm_app_get_app_id (GsmApp *app, - char **id, - GError **error); -gboolean gsm_app_get_startup_id (GsmApp *app, - char **id, - GError **error); -gboolean gsm_app_get_phase (GsmApp *app, - guint *phase, - GError **error); - G_END_DECLS #endif /* __GSM_APP_H__ */ diff --git a/mate-session/gsm-autostart-app.c b/mate-session/gsm-autostart-app.c index 079bfa1..a73e9bb 100644 --- a/mate-session/gsm-autostart-app.c +++ b/mate-session/gsm-autostart-app.c @@ -178,9 +178,9 @@ parse_condition_string (const char *condition_string, } static void -if_exists_condition_cb (GFileMonitor *monitor, - GFile *file, - GFile *other_file, +if_exists_condition_cb (GFileMonitor *monitor G_GNUC_UNUSED, + GFile *file G_GNUC_UNUSED, + GFile *other_file G_GNUC_UNUSED, GFileMonitorEvent event, GsmApp *app) { @@ -209,9 +209,9 @@ if_exists_condition_cb (GFileMonitor *monitor, } static void -unless_exists_condition_cb (GFileMonitor *monitor, - GFile *file, - GFile *other_file, +unless_exists_condition_cb (GFileMonitor *monitor G_GNUC_UNUSED, + GFile *file G_GNUC_UNUSED, + GFile *other_file G_GNUC_UNUSED, GFileMonitorEvent event, GsmApp *app) { @@ -802,8 +802,8 @@ autostart_app_stop_spawn (GsmAutostartApp *app, } static gboolean -autostart_app_stop_activate (GsmAutostartApp *app, - GError **error) +autostart_app_stop_activate (GsmAutostartApp *app G_GNUC_UNUSED, + GError **error G_GNUC_UNUSED) { return TRUE; } @@ -896,7 +896,7 @@ autostart_app_start_spawn (GsmAutostartApp *app, } static void -start_notify (GObject *source_object, +start_notify (GObject *source_object G_GNUC_UNUSED, GAsyncResult *res, gpointer data) { diff --git a/mate-session/gsm-client.c b/mate-session/gsm-client.c index 8dc4005..ffe7db6 100644 --- a/mate-session/gsm-client.c +++ b/mate-session/gsm-client.c @@ -22,13 +22,11 @@ #include "config.h" -#include <dbus/dbus-glib.h> - #include "eggdesktopfile.h" #include "gsm-marshal.h" #include "gsm-client.h" -#include "gsm-client-glue.h" +#include "org.gnome.SessionManager.Client.h" static guint32 client_serial = 1; @@ -38,7 +36,8 @@ typedef struct { char *startup_id; char *app_id; guint status; - DBusGConnection *connection; + GsmExportedClient *skeleton; + GDBusConnection *connection; } GsmClientPrivate; enum { @@ -59,71 +58,155 @@ static guint signals[LAST_SIGNAL] = { 0 }; G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GsmClient, gsm_client, G_TYPE_OBJECT) +#define GSM_CLIENT_DBUS_IFACE "org.gnome.SessionManager.Client" + +static const GDBusErrorEntry gsm_client_error_entries[] = { + { GSM_CLIENT_ERROR_GENERAL, GSM_CLIENT_DBUS_IFACE ".GeneralError" }, + { GSM_CLIENT_ERROR_NOT_REGISTERED, GSM_CLIENT_DBUS_IFACE ".NotRegistered" } +}; + GQuark gsm_client_error_quark (void) { - static GQuark ret = 0; - if (ret == 0) { - ret = g_quark_from_static_string ("gsm_client_error"); + static volatile gsize quark_volatile = 0; + + g_dbus_error_register_error_domain ("gsm_client_error", + &quark_volatile, + gsm_client_error_entries, + G_N_ELEMENTS (gsm_client_error_entries)); + return quark_volatile; +} + +static guint32 +get_next_client_serial (void) +{ + guint32 serial; + + serial = client_serial++; + + if ((gint32)client_serial < 0) { + client_serial = 1; } - return ret; + return serial; } -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } +static gboolean +gsm_client_get_startup_id (GsmExportedClient *skeleton, + GDBusMethodInvocation *invocation, + GsmClient *client) +{ + GsmClientPrivate *priv; + + priv = gsm_client_get_instance_private (client); + gsm_exported_client_complete_get_startup_id (skeleton, invocation, priv->startup_id); + return TRUE; +} -GType -gsm_client_error_get_type (void) +static gboolean +gsm_client_get_app_id (GsmExportedClient *skeleton, + GDBusMethodInvocation *invocation, + GsmClient *client) { - static GType etype = 0; + GsmClientPrivate *priv; - if (etype == 0) { - static const GEnumValue values[] = { - ENUM_ENTRY (GSM_CLIENT_ERROR_GENERAL, "GeneralError"), - ENUM_ENTRY (GSM_CLIENT_ERROR_NOT_REGISTERED, "NotRegistered"), - { 0, 0, 0 } - }; + priv = gsm_client_get_instance_private (client); + gsm_exported_client_complete_get_app_id (skeleton, invocation, priv->app_id); + return TRUE; +} - g_assert (GSM_CLIENT_NUM_ERRORS == G_N_ELEMENTS (values) - 1); +static gboolean +gsm_client_get_restart_style_hint (GsmExportedClient *skeleton, + GDBusMethodInvocation *invocation, + GsmClient *client) +{ + guint hint; - etype = g_enum_register_static ("GsmClientError", values); - } + hint = GSM_CLIENT_GET_CLASS (client)->impl_get_restart_style_hint (client); + gsm_exported_client_complete_get_restart_style_hint (skeleton, invocation, hint); + return TRUE; +} + +static gboolean +gsm_client_get_status (GsmExportedClient *skeleton, + GDBusMethodInvocation *invocation, + GsmClient *client) +{ + GsmClientPrivate *priv; - return etype; + priv = gsm_client_get_instance_private (client); + gsm_exported_client_complete_get_status (skeleton, invocation, priv->status); + return TRUE; } -static guint32 -get_next_client_serial (void) +static gboolean +gsm_client_get_unix_process_id (GsmExportedClient *skeleton, + GDBusMethodInvocation *invocation, + GsmClient *client) { - guint32 serial; + guint pid; - serial = client_serial++; + pid = GSM_CLIENT_GET_CLASS (client)->impl_get_unix_process_id (client); + gsm_exported_client_complete_get_unix_process_id (skeleton, invocation, pid); + return TRUE; +} - if ((gint32)client_serial < 0) { - client_serial = 1; - } +static gboolean +gsm_client_stop_dbus (GsmExportedClient *skeleton, + GDBusMethodInvocation *invocation, + GsmClient *client) +{ + GError *error = NULL; + gsm_client_stop (client, &error); - return serial; + if (error != NULL) { + g_dbus_method_invocation_take_error (invocation, error); + } else { + gsm_exported_client_complete_stop (skeleton, invocation); + } + return TRUE; } static gboolean register_client (GsmClient *client) { - GError *error; + GError *error = NULL; + GsmExportedClient *skeleton; GsmClientPrivate *priv; - error = NULL; priv = gsm_client_get_instance_private (client); - priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + priv->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); if (priv->connection == NULL) { - if (error != NULL) { - g_critical ("error getting session bus: %s", error->message); - g_error_free (error); - } + g_critical ("error getting session bus: %s", error->message); + g_error_free (error); + return FALSE; + } + + skeleton = gsm_exported_client_skeleton_new (); + priv->skeleton = skeleton; + g_debug ("exporting client to object path: %s", priv->id); + g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (skeleton), + priv->connection, + priv->id, &error); + + if (error != NULL) { + g_critical ("error exporting client on session bus: %s", error->message); + g_error_free (error); return FALSE; } - dbus_g_connection_register_g_object (priv->connection, priv->id, G_OBJECT (client)); + g_signal_connect (skeleton, "handle-get-app-id", + G_CALLBACK (gsm_client_get_app_id), client); + g_signal_connect (skeleton, "handle-get-restart-style-hint", + G_CALLBACK (gsm_client_get_restart_style_hint), client); + g_signal_connect (skeleton, "handle-get-startup-id", + G_CALLBACK (gsm_client_get_startup_id), client); + g_signal_connect (skeleton, "handle-get-status", + G_CALLBACK (gsm_client_get_status), client); + g_signal_connect (skeleton, "handle-get-unix-process-id", + G_CALLBACK (gsm_client_get_unix_process_id), client); + g_signal_connect (skeleton, "handle-stop", + G_CALLBACK (gsm_client_stop_dbus), client); return TRUE; } @@ -153,7 +236,7 @@ gsm_client_constructor (GType type, } static void -gsm_client_init (GsmClient *client) +gsm_client_init (GsmClient *client G_GNUC_UNUSED) { } @@ -175,6 +258,14 @@ gsm_client_finalize (GObject *object) g_free (priv->startup_id); g_free (priv->app_id); + if (priv->skeleton != NULL) { + g_dbus_interface_skeleton_unexport_from_connection (G_DBUS_INTERFACE_SKELETON (priv->skeleton), + priv->connection); + g_clear_object (&priv->skeleton); + } + + g_clear_object (&priv->connection); + G_OBJECT_CLASS (gsm_client_parent_class)->finalize (object); } @@ -286,7 +377,7 @@ gsm_client_get_property (GObject *object, static gboolean default_stop (GsmClient *client, - GError **error) + GError **error G_GNUC_UNUSED) { g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE); @@ -367,8 +458,6 @@ gsm_client_class_init (GsmClientClass *klass) G_MAXINT, GSM_CLIENT_UNREGISTERED, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - dbus_g_object_type_install_info (GSM_TYPE_CLIENT, &dbus_glib_gsm_client_object_info); } const char * @@ -433,75 +522,6 @@ gsm_client_peek_restart_style_hint (GsmClient *client) return GSM_CLIENT_GET_CLASS (client)->impl_get_restart_style_hint (client); } -gboolean -gsm_client_get_startup_id (GsmClient *client, - char **id, - GError **error) -{ - GsmClientPrivate *priv; - g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE); - - priv = gsm_client_get_instance_private (client); - - *id = g_strdup (priv->startup_id); - - return TRUE; -} - -gboolean -gsm_client_get_app_id (GsmClient *client, - char **id, - GError **error) -{ - GsmClientPrivate *priv; - g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE); - - priv = gsm_client_get_instance_private (client); - - *id = g_strdup (priv->app_id); - - return TRUE; -} - -gboolean -gsm_client_get_restart_style_hint (GsmClient *client, - guint *hint, - GError **error) -{ - g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE); - - *hint = GSM_CLIENT_GET_CLASS (client)->impl_get_restart_style_hint (client); - - return TRUE; -} - -gboolean -gsm_client_get_status (GsmClient *client, - guint *status, - GError **error) -{ - GsmClientPrivate *priv; - g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE); - - priv = gsm_client_get_instance_private (client); - - *status = priv->status; - - return TRUE; -} - -gboolean -gsm_client_get_unix_process_id (GsmClient *client, - guint *pid, - GError **error) -{ - g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE); - - *pid = GSM_CLIENT_GET_CLASS (client)->impl_get_unix_process_id (client); - - return TRUE; -} - /** * gsm_client_get_app_name: * @client: a #GsmClient. diff --git a/mate-session/gsm-client.h b/mate-session/gsm-client.h index ff3012f..c40c169 100644 --- a/mate-session/gsm-client.h +++ b/mate-session/gsm-client.h @@ -90,9 +90,6 @@ typedef enum } GsmClientError; #define GSM_CLIENT_ERROR gsm_client_error_quark () -#define GSM_CLIENT_TYPE_ERROR (gsm_client_error_get_type ()) - -GType gsm_client_error_get_type (void); GQuark gsm_client_error_quark (void); const char *gsm_client_peek_id (GsmClient *client); @@ -121,24 +118,9 @@ void gsm_client_disconnected (GsmClient *client) GKeyFile *gsm_client_save (GsmClient *client, GError **error); -/* exported to bus */ + gboolean gsm_client_stop (GsmClient *client, GError **error); -gboolean gsm_client_get_startup_id (GsmClient *client, - char **startup_id, - GError **error); -gboolean gsm_client_get_app_id (GsmClient *client, - char **app_id, - GError **error); -gboolean gsm_client_get_restart_style_hint (GsmClient *client, - guint *hint, - GError **error); -gboolean gsm_client_get_status (GsmClient *client, - guint *status, - GError **error); -gboolean gsm_client_get_unix_process_id (GsmClient *client, - guint *pid, - GError **error); /* private */ diff --git a/mate-session/gsm-consolekit.c b/mate-session/gsm-consolekit.c index 45101c8..b7c24bd 100644 --- a/mate-session/gsm-consolekit.c +++ b/mate-session/gsm-consolekit.c @@ -150,7 +150,7 @@ gsm_consolekit_class_init (GsmConsolekitClass *manager_class) } static DBusHandlerResult -gsm_consolekit_dbus_filter (DBusConnection *connection, +gsm_consolekit_dbus_filter (DBusConnection *connection G_GNUC_UNUSED, DBusMessage *message, void *user_data) { @@ -272,10 +272,10 @@ out: } static void -gsm_consolekit_on_name_owner_changed (DBusGProxy *bus_proxy, +gsm_consolekit_on_name_owner_changed (DBusGProxy *bus_proxy G_GNUC_UNUSED, const char *name, - const char *prev_owner, - const char *new_owner, + const char *prev_owner G_GNUC_UNUSED, + const char *new_owner G_GNUC_UNUSED, GsmConsolekit *manager) { GsmConsolekitPrivate *priv; diff --git a/mate-session/gsm-dbus-client.c b/mate-session/gsm-dbus-client.c index 69d723a..5a45416 100644 --- a/mate-session/gsm-dbus-client.c +++ b/mate-session/gsm-dbus-client.c @@ -28,11 +28,9 @@ #include <string.h> #include <time.h> #include <unistd.h> +#include <gio/gio.h> -#include <dbus/dbus.h> -#include <dbus/dbus-glib.h> -#include <dbus/dbus-glib-lowlevel.h> - +#include "org.gnome.SessionManager.ClientPrivate.h" #include "gsm-dbus-client.h" #include "gsm-marshal.h" @@ -48,7 +46,9 @@ struct _GsmDBusClient char *bus_name; GPid caller_pid; GsmClientRestartStyle restart_style_hint; - DBusConnection *connection; + + GDBusConnection *connection; + GsmExportedClientPrivate *skeleton; }; enum { @@ -58,175 +58,37 @@ enum { G_DEFINE_TYPE (GsmDBusClient, gsm_dbus_client, GSM_TYPE_CLIENT) -GQuark -gsm_dbus_client_error_quark (void) -{ - static GQuark ret = 0; - if (ret == 0) { - ret = g_quark_from_static_string ("gsm_dbus_client_error"); - } - - return ret; -} - -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -gsm_dbus_client_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - ENUM_ENTRY (GSM_DBUS_CLIENT_ERROR_GENERAL, "GeneralError"), - ENUM_ENTRY (GSM_DBUS_CLIENT_ERROR_NOT_CLIENT, "NotClient"), - { 0, 0, 0 } - }; - - g_assert (GSM_DBUS_CLIENT_NUM_ERRORS == G_N_ELEMENTS (values) - 1); - - etype = g_enum_register_static ("GsmDbusClientError", values); - } - - return etype; -} - static gboolean setup_connection (GsmDBusClient *client) { - DBusError error; - - dbus_error_init (&error); + GError *error = NULL; if (client->connection == NULL) { - client->connection = dbus_bus_get (DBUS_BUS_SESSION, &error); - if (client->connection == NULL) { - if (dbus_error_is_set (&error)) { - g_debug ("GsmDbusClient: Couldn't connect to session bus: %s", - error.message); - dbus_error_free (&error); - } + client->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); + if (error != NULL) { + g_debug ("GsmDbusClient: Couldn't connect to session bus: %s", + error->message); + g_error_free (error); return FALSE; } - - dbus_connection_setup_with_g_main (client->connection, NULL); - dbus_connection_set_exit_on_disconnect (client->connection, FALSE); } return TRUE; } static void -raise_error (DBusConnection *connection, - DBusMessage *in_reply_to, - const char *error_name, - char *format, ...) +handle_end_session_response (GsmExportedClientPrivate *skeleton, + GDBusMethodInvocation *invocation, + gboolean is_ok, + const char *reason, + GsmDBusClient *client) { - char buf[512]; - DBusMessage *reply; - - va_list args; - va_start (args, format); - vsnprintf (buf, sizeof (buf), format, args); - va_end (args); - - reply = dbus_message_new_error (in_reply_to, error_name, buf); - if (reply == NULL) { - g_error ("No memory"); - } - if (! dbus_connection_send (connection, reply, NULL)) { - g_error ("No memory"); - } - - dbus_message_unref (reply); -} - -static void -handle_end_session_response (GsmDBusClient *client, - DBusMessage *message) -{ - const char *sender; - DBusMessage *reply; - DBusError error; - dbus_bool_t is_ok; - const char *reason; - - dbus_error_init (&error); - if (! dbus_message_get_args (message, &error, - DBUS_TYPE_BOOLEAN, &is_ok, - DBUS_TYPE_STRING, &reason, - DBUS_TYPE_INVALID)) { - if (dbus_error_is_set (&error)) { - g_warning ("Invalid method call: %s", error.message); - dbus_error_free (&error); - } - raise_error (client->connection, - message, - DBUS_ERROR_FAILED, - "There is a syntax error in the invocation of the method EndSessionResponse"); - return; - } - g_debug ("GsmDBusClient: got EndSessionResponse is-ok:%d reason=%s", is_ok, reason); - /* make sure it is from our client */ - sender = dbus_message_get_sender (message); - if (sender == NULL - || IS_STRING_EMPTY (client->bus_name) - || strcmp (sender, client->bus_name) != 0) { - - raise_error (client->connection, - message, - DBUS_ERROR_FAILED, - "Caller not recognized as the client"); - return; - } - - reply = dbus_message_new_method_return (message); - if (reply == NULL) { - g_error ("No memory"); - } - gsm_client_end_session_response (GSM_CLIENT (client), is_ok, FALSE, FALSE, reason); - if (! dbus_connection_send (client->connection, reply, NULL)) { - g_error ("No memory"); - } - - dbus_message_unref (reply); -} - -static DBusHandlerResult -client_dbus_filter_function (DBusConnection *connection, - DBusMessage *message, - void *user_data) -{ - GsmDBusClient *client = GSM_DBUS_CLIENT (user_data); - const char *path; - - g_return_val_if_fail (connection != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED); - g_return_val_if_fail (message != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED); - - path = dbus_message_get_path (message); - - g_debug ("GsmDBusClient: obj_path=%s interface=%s method=%s", - dbus_message_get_path (message), - dbus_message_get_interface (message), - dbus_message_get_member (message)); - - if (dbus_message_is_method_call (message, SM_DBUS_CLIENT_PRIVATE_INTERFACE, "EndSessionResponse")) { - g_assert (gsm_client_peek_id (GSM_CLIENT (client)) != NULL); - - if (path != NULL && strcmp (path, gsm_client_peek_id (GSM_CLIENT (client))) != 0) { - /* Different object path */ - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - } - handle_end_session_response (client, message); - return DBUS_HANDLER_RESULT_HANDLED; - } - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + gsm_exported_client_private_complete_end_session_response (skeleton, invocation); } static GObject * @@ -235,6 +97,8 @@ gsm_dbus_client_constructor (GType type, GObjectConstructParam *construct_properties) { GsmDBusClient *client; + GError *error = NULL; + GsmExportedClientPrivate *skeleton; client = GSM_DBUS_CLIENT (G_OBJECT_CLASS (gsm_dbus_client_parent_class)->constructor (type, n_construct_properties, @@ -245,92 +109,121 @@ gsm_dbus_client_constructor (GType type, return NULL; } - /* Object path is already registered by base class */ - dbus_connection_add_filter (client->connection, client_dbus_filter_function, client, NULL); + skeleton = gsm_exported_client_private_skeleton_new (); + client->skeleton = skeleton; + g_debug ("exporting dbus client to object path: %s", gsm_client_peek_id (GSM_CLIENT (client))); + g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (skeleton), + client->connection, + gsm_client_peek_id (GSM_CLIENT (client)), + &error); + + if (error != NULL) { + g_critical ("error exporting client private on session bus: %s", error->message); + g_error_free (error); + g_object_unref (client); + return NULL; + } + + g_signal_connect (skeleton, "handle-end-session-response", + G_CALLBACK (handle_end_session_response), client); return G_OBJECT (client); } static void -gsm_dbus_client_init (GsmDBusClient *client) +gsm_dbus_client_init (GsmDBusClient *client G_GNUC_UNUSED) { } /* adapted from PolicyKit */ static gboolean -get_caller_info (GsmDBusClient *client, +get_caller_info (GsmDBusClient *client G_GNUC_UNUSED, const char *sender, - uid_t *calling_uid, - pid_t *calling_pid) + uid_t *calling_uid_out, + pid_t *calling_pid_out) { - gboolean res; + GDBusConnection *connection; + gboolean retval; GError *error; - DBusGConnection *connection; - DBusGProxy *bus_proxy; + GVariant *uid_variant, *pid_variant; + uid_t uid; + pid_t pid; - res = FALSE; - bus_proxy = NULL; + retval = FALSE; if (sender == NULL) { goto out; } error = NULL; - connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - if (connection == NULL) { - if (error != NULL) { - g_warning ("error getting session bus: %s", error->message); - g_error_free (error); - } + uid_variant = pid_variant = NULL; + connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); + + if (error != NULL) { + g_warning ("error getting session bus: %s", error->message); + g_error_free (error); goto out; } - bus_proxy = dbus_g_proxy_new_for_name (connection, - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS); + uid_variant = g_dbus_connection_call_sync (connection, + "org.freedesktop.DBus", + "/org/freedesktop/DBus", + "org.freedesktop.DBus", + "GetConnectionUnixUser", + g_variant_new ("(s)", sender), + G_VARIANT_TYPE ("(u)"), + G_DBUS_CALL_FLAGS_NONE, + -1, NULL, &error); - error = NULL; - if (! dbus_g_proxy_call (bus_proxy, "GetConnectionUnixUser", &error, - G_TYPE_STRING, sender, - G_TYPE_INVALID, - G_TYPE_UINT, calling_uid, - G_TYPE_INVALID)) { + if (error != NULL) { g_debug ("GetConnectionUnixUser() failed: %s", error->message); g_error_free (error); goto out; } - error = NULL; - if (! dbus_g_proxy_call (bus_proxy, "GetConnectionUnixProcessID", &error, - G_TYPE_STRING, sender, - G_TYPE_INVALID, - G_TYPE_UINT, calling_pid, - G_TYPE_INVALID)) { + pid_variant = g_dbus_connection_call_sync (connection, + "org.freedesktop.DBus", + "/org/freedesktop/DBus", + "org.freedesktop.DBus", + "GetConnectionUnixProcessID", + g_variant_new ("(s)", sender), + G_VARIANT_TYPE ("(u)"), + G_DBUS_CALL_FLAGS_NONE, + -1, NULL, &error); + + if (error != NULL) { g_debug ("GetConnectionUnixProcessID() failed: %s", error->message); g_error_free (error); goto out; } - res = TRUE; + g_variant_get (uid_variant, "(u)", &uid); + g_variant_get (pid_variant, "(u)", &pid); + + if (calling_uid_out != NULL) { + *calling_uid_out = uid; + } + if (calling_pid_out != NULL) { + *calling_pid_out = pid; + } + + retval = TRUE; - g_debug ("uid = %d", *calling_uid); - g_debug ("pid = %d", *calling_pid); + g_debug ("uid = %d", uid); + g_debug ("pid = %d", pid); out: - if (bus_proxy != NULL) { - g_object_unref (bus_proxy); - } - return res; + g_clear_pointer (&uid_variant, g_variant_unref); + g_clear_pointer (&pid_variant, g_variant_unref); + g_clear_object (&connection); + + return retval; } static void gsm_dbus_client_set_bus_name (GsmDBusClient *client, const char *bus_name) { - uid_t uid; - pid_t pid; - g_return_if_fail (GSM_IS_DBUS_CLIENT (client)); g_free (client->bus_name); @@ -338,17 +231,9 @@ gsm_dbus_client_set_bus_name (GsmDBusClient *client, client->bus_name = g_strdup (bus_name); g_object_notify (G_OBJECT (client), "bus-name"); - if (client->bus_name != NULL) { - gboolean res; - - res = get_caller_info (client, bus_name, &uid, &pid); - if (! res) { - pid = 0; - } - } else { - pid = 0; + if (!get_caller_info (client, bus_name, NULL, &client->caller_pid)) { + client->caller_pid = 0; } - client->caller_pid = pid; } const char * @@ -406,12 +291,20 @@ gsm_dbus_client_finalize (GObject *object) g_free (client->bus_name); + if (client->skeleton != NULL) { + g_dbus_interface_skeleton_unexport_from_connection (G_DBUS_INTERFACE_SKELETON (client->skeleton), + client->connection); + g_clear_object (&client->skeleton); + } + + g_clear_object (&client->connection); + G_OBJECT_CLASS (gsm_dbus_client_parent_class)->finalize (object); } static GKeyFile * dbus_client_save (GsmClient *client, - GError **error) + GError **error G_GNUC_UNUSED) { g_debug ("GsmDBusClient: saving client with id %s", gsm_client_peek_id (client)); @@ -424,41 +317,15 @@ dbus_client_save (GsmClient *client, static gboolean dbus_client_stop (GsmClient *client, - GError **error) + GError **error G_GNUC_UNUSED) { GsmDBusClient *dbus_client = (GsmDBusClient *) client; - DBusMessage *message; - gboolean ret; - - ret = FALSE; - - /* unicast the signal to only the registered bus name */ - message = dbus_message_new_signal (gsm_client_peek_id (client), - SM_DBUS_CLIENT_PRIVATE_INTERFACE, - "Stop"); - if (message == NULL) { - goto out; - } - if (!dbus_message_set_destination (message, dbus_client->bus_name)) { - goto out; - } - - if (!dbus_connection_send (dbus_client->connection, message, NULL)) { - goto out; - } - - ret = TRUE; - - out: - if (message != NULL) { - dbus_message_unref (message); - } - - return ret; + gsm_exported_client_private_emit_stop (dbus_client->skeleton); + return TRUE; } static char * -dbus_client_get_app_name (GsmClient *client) +dbus_client_get_app_name (GsmClient *client G_GNUC_UNUSED) { /* Always use app-id instead */ return NULL; @@ -482,11 +349,6 @@ dbus_client_query_end_session (GsmClient *client, GError **error) { GsmDBusClient *dbus_client = (GsmDBusClient *) client; - DBusMessage *message; - DBusMessageIter iter; - gboolean ret; - - ret = FALSE; if (dbus_client->bus_name == NULL) { g_set_error (error, @@ -498,155 +360,29 @@ dbus_client_query_end_session (GsmClient *client, g_debug ("GsmDBusClient: sending QueryEndSession signal to %s", dbus_client->bus_name); - /* unicast the signal to only the registered bus name */ - message = dbus_message_new_signal (gsm_client_peek_id (client), - SM_DBUS_CLIENT_PRIVATE_INTERFACE, - "QueryEndSession"); - if (message == NULL) { - g_set_error (error, - GSM_CLIENT_ERROR, - GSM_CLIENT_ERROR_NOT_REGISTERED, - "Unable to send QueryEndSession message"); - goto out; - } - if (!dbus_message_set_destination (message, dbus_client->bus_name)) { - g_set_error (error, - GSM_CLIENT_ERROR, - GSM_CLIENT_ERROR_NOT_REGISTERED, - "Unable to send QueryEndSession message"); - goto out; - } - - dbus_message_iter_init_append (message, &iter); - dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &flags); - - if (!dbus_connection_send (dbus_client->connection, message, NULL)) { - g_set_error (error, - GSM_CLIENT_ERROR, - GSM_CLIENT_ERROR_NOT_REGISTERED, - "Unable to send QueryEndSession message"); - goto out; - } - - ret = TRUE; - - out: - if (message != NULL) { - dbus_message_unref (message); - } - - return ret; + gsm_exported_client_private_emit_query_end_session (dbus_client->skeleton, flags); + return TRUE; } static gboolean dbus_client_end_session (GsmClient *client, guint flags, - GError **error) + GError **error G_GNUC_UNUSED) { GsmDBusClient *dbus_client = (GsmDBusClient *) client; - DBusMessage *message; - DBusMessageIter iter; - gboolean ret; - - ret = FALSE; - /* unicast the signal to only the registered bus name */ - message = dbus_message_new_signal (gsm_client_peek_id (client), - SM_DBUS_CLIENT_PRIVATE_INTERFACE, - "EndSession"); - if (message == NULL) { - g_set_error (error, - GSM_CLIENT_ERROR, - GSM_CLIENT_ERROR_NOT_REGISTERED, - "Unable to send EndSession message"); - goto out; - } - if (!dbus_message_set_destination (message, dbus_client->bus_name)) { - g_set_error (error, - GSM_CLIENT_ERROR, - GSM_CLIENT_ERROR_NOT_REGISTERED, - "Unable to send EndSession message"); - goto out; - } - - dbus_message_iter_init_append (message, &iter); - dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &flags); - - if (!dbus_connection_send (dbus_client->connection, message, NULL)) { - g_set_error (error, - GSM_CLIENT_ERROR, - GSM_CLIENT_ERROR_NOT_REGISTERED, - "Unable to send EndSession message"); - goto out; - } - - ret = TRUE; - - out: - if (message != NULL) { - dbus_message_unref (message); - } - return ret; + gsm_exported_client_private_emit_end_session (dbus_client->skeleton, flags); + return TRUE; } static gboolean dbus_client_cancel_end_session (GsmClient *client, - GError **error) -{ - GsmDBusClient *dbus_client = (GsmDBusClient *) client; - DBusMessage *message; - gboolean ret = FALSE; - - /* unicast the signal to only the registered bus name */ - message = dbus_message_new_signal (gsm_client_peek_id (client), - SM_DBUS_CLIENT_PRIVATE_INTERFACE, - "CancelEndSession"); - if (message == NULL) { - g_set_error (error, - GSM_CLIENT_ERROR, - GSM_CLIENT_ERROR_NOT_REGISTERED, - "Unable to send CancelEndSession message"); - goto out; - } - if (!dbus_message_set_destination (message, dbus_client->bus_name)) { - g_set_error (error, - GSM_CLIENT_ERROR, - GSM_CLIENT_ERROR_NOT_REGISTERED, - "Unable to send CancelEndSession message"); - goto out; - } - - if (!dbus_connection_send (dbus_client->connection, message, NULL)) { - g_set_error (error, - GSM_CLIENT_ERROR, - GSM_CLIENT_ERROR_NOT_REGISTERED, - "Unable to send CancelEndSession message"); - goto out; - } - - ret = TRUE; - - out: - if (message != NULL) { - dbus_message_unref (message); - } - - return ret; -} - -static void -gsm_dbus_client_dispose (GObject *object) + GError **error G_GNUC_UNUSED) { - GsmDBusClient *client; - - g_return_if_fail (object != NULL); - g_return_if_fail (GSM_IS_DBUS_CLIENT (object)); - - client = GSM_DBUS_CLIENT (object); - - dbus_connection_remove_filter (client->connection, client_dbus_filter_function, client); + GsmDBusClient *dbus_client = (GsmDBusClient *) client; - G_OBJECT_CLASS (gsm_dbus_client_parent_class)->dispose (object); + gsm_exported_client_private_emit_cancel_end_session (dbus_client->skeleton); + return TRUE; } static void @@ -659,7 +395,6 @@ gsm_dbus_client_class_init (GsmDBusClientClass *klass) object_class->constructor = gsm_dbus_client_constructor; object_class->get_property = gsm_dbus_client_get_property; object_class->set_property = gsm_dbus_client_set_property; - object_class->dispose = gsm_dbus_client_dispose; client_class->impl_save = dbus_client_save; client_class->impl_stop = dbus_client_stop; diff --git a/mate-session/gsm-dbus-client.h b/mate-session/gsm-dbus-client.h index c264c92..d22ab5d 100644 --- a/mate-session/gsm-dbus-client.h +++ b/mate-session/gsm-dbus-client.h @@ -29,19 +29,19 @@ G_BEGIN_DECLS #define GSM_TYPE_DBUS_CLIENT (gsm_dbus_client_get_type ()) G_DECLARE_FINAL_TYPE (GsmDBusClient, gsm_dbus_client, GSM, DBUS_CLIENT, GsmClient) -typedef enum -{ - GSM_DBUS_CLIENT_ERROR_GENERAL = 0, - GSM_DBUS_CLIENT_ERROR_NOT_CLIENT, - GSM_DBUS_CLIENT_NUM_ERRORS -} GsmDBusClientError; - -#define GSM_DBUS_CLIENT_ERROR gsm_dbus_client_error_quark () - -GType gsm_dbus_client_error_get_type (void); -#define GSM_DBUS_CLIENT_TYPE_ERROR (gsm_dbus_client_error_get_type ()) - -GQuark gsm_dbus_client_error_quark (void); +//typedef enum +//{ +// GSM_DBUS_CLIENT_ERROR_GENERAL = 0, +// GSM_DBUS_CLIENT_ERROR_NOT_CLIENT, +// GSM_DBUS_CLIENT_NUM_ERRORS +//} GsmDBusClientError; + +//#define GSM_DBUS_CLIENT_ERROR gsm_dbus_client_error_quark () +// +//GType gsm_dbus_client_error_get_type (void); +//#define GSM_DBUS_CLIENT_TYPE_ERROR (gsm_dbus_client_error_get_type ()) + +//GQuark gsm_dbus_client_error_quark (void); GsmClient * gsm_dbus_client_new (const char *startup_id, const char *bus_name); diff --git a/mate-session/gsm-inhibitor.c b/mate-session/gsm-inhibitor.c index 8632c15..0c8ed7c 100644 --- a/mate-session/gsm-inhibitor.c +++ b/mate-session/gsm-inhibitor.c @@ -27,11 +27,9 @@ #include <time.h> #include <unistd.h> -#include <dbus/dbus-glib.h> - #include "gsm-inhibitor.h" -#include "gsm-inhibitor-glue.h" #include "gsm-util.h" +#include "org.gnome.SessionManager.Inhibitor.h" static guint32 inhibitor_serial = 1; @@ -46,7 +44,8 @@ struct _GsmInhibitor guint flags; guint toplevel_xid; guint cookie; - DBusGConnection *connection; + GDBusConnection *connection; + GsmExportedInhibitor *skeleton; }; enum { @@ -62,37 +61,96 @@ enum { G_DEFINE_TYPE (GsmInhibitor, gsm_inhibitor, G_TYPE_OBJECT) +#define GSM_INHIBITOR_DBUS_IFACE "org.gnome.SessionManager.Inhibitor" + +static const GDBusErrorEntry gsm_inhibitor_error_entries[] = { + { GSM_INHIBITOR_ERROR_GENERAL, GSM_INHIBITOR_DBUS_IFACE ".GeneralError" }, + { GSM_INHIBITOR_ERROR_NOT_SET, GSM_INHIBITOR_DBUS_IFACE ".NotSet" } +}; + GQuark gsm_inhibitor_error_quark (void) { - static GQuark ret = 0; - if (ret == 0) { - ret = g_quark_from_static_string ("gsm_inhibitor_error"); - } + static volatile gsize quark_volatile = 0; - return ret; + g_dbus_error_register_error_domain ("gsm_inhibitor_error", + &quark_volatile, + gsm_inhibitor_error_entries, + G_N_ELEMENTS (gsm_inhibitor_error_entries)); + return quark_volatile; } -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } +static gboolean +gsm_inhibitor_get_app_id (GsmExportedInhibitor *skeleton, + GDBusMethodInvocation *invocation, + GsmInhibitor *inhibitor) +{ + const gchar *id; + + if (inhibitor->app_id != NULL) { + id = inhibitor->app_id; + } else { + id = ""; + } + + gsm_exported_inhibitor_complete_get_app_id (skeleton, invocation, id); + + return TRUE; +} -GType -gsm_inhibitor_error_get_type (void) +static gboolean +gsm_inhibitor_get_client_id (GsmExportedInhibitor *skeleton, + GDBusMethodInvocation *invocation, + GsmInhibitor *inhibitor) { - static GType etype = 0; + /* object paths are not allowed to be NULL or blank */ + if (IS_STRING_EMPTY (inhibitor->client_id)) { + g_dbus_method_invocation_return_error (invocation, + GSM_INHIBITOR_ERROR, + GSM_INHIBITOR_ERROR_NOT_SET, + "Value is not set"); + return TRUE; + } + + gsm_exported_inhibitor_complete_get_client_id (skeleton, invocation, inhibitor->client_id); + g_debug ("GsmInhibitor: getting client-id = '%s'", inhibitor->client_id); - if (etype == 0) { - static const GEnumValue values[] = { - ENUM_ENTRY (GSM_INHIBITOR_ERROR_GENERAL, "GeneralError"), - ENUM_ENTRY (GSM_INHIBITOR_ERROR_NOT_SET, "NotSet"), - { 0, 0, 0 } - }; + return TRUE; +} - g_assert (GSM_INHIBITOR_NUM_ERRORS == G_N_ELEMENTS (values) - 1); +static gboolean +gsm_inhibitor_get_reason (GsmExportedInhibitor *skeleton, + GDBusMethodInvocation *invocation, + GsmInhibitor *inhibitor) +{ + const gchar *reason; - etype = g_enum_register_static ("GsmInhibitorError", values); + if (inhibitor->reason != NULL) { + reason = inhibitor->reason; + } else { + reason = ""; } - return etype; + gsm_exported_inhibitor_complete_get_reason (skeleton, invocation, reason); + return TRUE; +} + +static gboolean +gsm_inhibitor_get_flags (GsmExportedInhibitor *skeleton, + GDBusMethodInvocation *invocation, + GsmInhibitor *inhibitor) +{ + gsm_exported_inhibitor_complete_get_flags (skeleton, invocation, inhibitor->flags); + return TRUE; +} + +static gboolean +gsm_inhibitor_get_toplevel_xid (GsmExportedInhibitor *skeleton, + GDBusMethodInvocation *invocation, + GsmInhibitor *inhibitor) +{ + gsm_exported_inhibitor_complete_get_toplevel_xid (skeleton, invocation, inhibitor->toplevel_xid); + return TRUE; } static guint32 @@ -113,18 +171,39 @@ static gboolean register_inhibitor (GsmInhibitor *inhibitor) { GError *error; + GsmExportedInhibitor *skeleton; error = NULL; - inhibitor->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - if (inhibitor->connection == NULL) { - if (error != NULL) { - g_critical ("error getting session bus: %s", error->message); - g_error_free (error); - } + inhibitor->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); + + if (error != NULL) { + g_critical ("error getting session bus: %s", error->message); + g_error_free (error); return FALSE; } - dbus_g_connection_register_g_object (inhibitor->connection, inhibitor->id, G_OBJECT (inhibitor)); + skeleton = gsm_exported_inhibitor_skeleton_new (); + inhibitor->skeleton = skeleton; + g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (skeleton), + inhibitor->connection, + inhibitor->id, &error); + + if (error != NULL) { + g_critical ("error exporting inhibitor on session bus: %s", error->message); + g_error_free (error); + return FALSE; + } + + g_signal_connect (skeleton, "handle-get-app-id", + G_CALLBACK (gsm_inhibitor_get_app_id), inhibitor); + g_signal_connect (skeleton, "handle-get-client-id", + G_CALLBACK (gsm_inhibitor_get_client_id), inhibitor); + g_signal_connect (skeleton, "handle-get-flags", + G_CALLBACK (gsm_inhibitor_get_flags), inhibitor); + g_signal_connect (skeleton, "handle-get-reason", + G_CALLBACK (gsm_inhibitor_get_reason), inhibitor); + g_signal_connect (skeleton, "handle-get-toplevel-xid", + G_CALLBACK (gsm_inhibitor_get_toplevel_xid), inhibitor); return TRUE; } @@ -152,7 +231,7 @@ gsm_inhibitor_constructor (GType type, } static void -gsm_inhibitor_init (GsmInhibitor *inhibitor) +gsm_inhibitor_init (GsmInhibitor *inhibitor G_GNUC_UNUSED) { } @@ -262,85 +341,6 @@ gsm_inhibitor_peek_bus_name (GsmInhibitor *inhibitor) return inhibitor->bus_name; } -gboolean -gsm_inhibitor_get_app_id (GsmInhibitor *inhibitor, - char **id, - GError **error) -{ - g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), FALSE); - - if (inhibitor->app_id != NULL) { - *id = g_strdup (inhibitor->app_id); - } else { - *id = g_strdup (""); - } - - return TRUE; -} - -gboolean -gsm_inhibitor_get_client_id (GsmInhibitor *inhibitor, - char **id, - GError **error) -{ - g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), FALSE); - - /* object paths are not allowed to be NULL or blank */ - if (IS_STRING_EMPTY (inhibitor->client_id)) { - g_set_error (error, - GSM_INHIBITOR_ERROR, - GSM_INHIBITOR_ERROR_NOT_SET, - "Value is not set"); - return FALSE; - } - - *id = g_strdup (inhibitor->client_id); - - g_debug ("GsmInhibitor: getting client-id = '%s'", *id); - - return TRUE; -} - -gboolean -gsm_inhibitor_get_reason (GsmInhibitor *inhibitor, - char **reason, - GError **error) -{ - g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), FALSE); - - if (inhibitor->reason != NULL) { - *reason = g_strdup (inhibitor->reason); - } else { - *reason = g_strdup (""); - } - - return TRUE; -} - -gboolean -gsm_inhibitor_get_flags (GsmInhibitor *inhibitor, - guint *flags, - GError **error) -{ - g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), FALSE); - - *flags = inhibitor->flags; - - return TRUE; -} - -gboolean -gsm_inhibitor_get_toplevel_xid (GsmInhibitor *inhibitor, - guint *xid, - GError **error) -{ - g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), FALSE); - - *xid = inhibitor->toplevel_xid; - - return TRUE; -} - const char * gsm_inhibitor_peek_id (GsmInhibitor *inhibitor) { @@ -484,6 +484,14 @@ gsm_inhibitor_finalize (GObject *object) g_free (inhibitor->client_id); g_free (inhibitor->reason); + if (inhibitor->skeleton != NULL) { + g_dbus_interface_skeleton_unexport_from_connection (G_DBUS_INTERFACE_SKELETON (inhibitor->skeleton), + inhibitor->connection); + g_clear_object (&inhibitor->skeleton); + } + + g_clear_object (&inhibitor->connection); + G_OBJECT_CLASS (gsm_inhibitor_parent_class)->finalize (object); } @@ -553,8 +561,6 @@ gsm_inhibitor_class_init (GsmInhibitorClass *klass) 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - dbus_g_object_type_install_info (GSM_TYPE_INHIBITOR, &dbus_glib_gsm_inhibitor_object_info); - dbus_g_error_domain_register (GSM_INHIBITOR_ERROR, NULL, GSM_INHIBITOR_TYPE_ERROR); } GsmInhibitor * diff --git a/mate-session/gsm-inhibitor.h b/mate-session/gsm-inhibitor.h index a4d20e9..ff8ec5f 100644 --- a/mate-session/gsm-inhibitor.h +++ b/mate-session/gsm-inhibitor.h @@ -29,7 +29,6 @@ G_BEGIN_DECLS #define GSM_TYPE_INHIBITOR (gsm_inhibitor_get_type ()) #define GSM_INHIBITOR_ERROR (gsm_inhibitor_error_quark ()) -#define GSM_INHIBITOR_TYPE_ERROR (gsm_inhibitor_error_get_type ()) G_DECLARE_FINAL_TYPE (GsmInhibitor, gsm_inhibitor, GSM, INHIBITOR, GObject) typedef enum { @@ -46,8 +45,6 @@ typedef enum GSM_INHIBITOR_NUM_ERRORS } GsmInhibitorError; -GType gsm_inhibitor_error_get_type (void); - GQuark gsm_inhibitor_error_quark (void); GsmInhibitor * gsm_inhibitor_new (const char *app_id, @@ -72,23 +69,6 @@ guint gsm_inhibitor_peek_cookie (GsmInhibitor *inhibitor); guint gsm_inhibitor_peek_flags (GsmInhibitor *inhibitor); guint gsm_inhibitor_peek_toplevel_xid (GsmInhibitor *inhibitor); -/* exported to bus */ -gboolean gsm_inhibitor_get_app_id (GsmInhibitor *inhibitor, - char **id, - GError **error); -gboolean gsm_inhibitor_get_client_id (GsmInhibitor *inhibitor, - char **id, - GError **error); -gboolean gsm_inhibitor_get_reason (GsmInhibitor *inhibitor, - char **reason, - GError **error); -gboolean gsm_inhibitor_get_flags (GsmInhibitor *inhibitor, - guint *flags, - GError **error); -gboolean gsm_inhibitor_get_toplevel_xid (GsmInhibitor *inhibitor, - guint *xid, - GError **error); - G_END_DECLS #endif /* __GSM_INHIBITOR_H__ */ diff --git a/mate-session/gsm-manager.c b/mate-session/gsm-manager.c index 37ca39d..ae948eb 100644 --- a/mate-session/gsm-manager.c +++ b/mate-session/gsm-manager.c @@ -36,15 +36,13 @@ #include <glib/gi18n.h> #include <glib/gstdio.h> #include <glib-object.h> -#include <dbus/dbus-glib.h> -#include <dbus/dbus-glib-lowlevel.h> #include <gtk/gtk.h> /* for logout dialog */ #include <gio/gio.h> /* for gsettings */ #include <gdk/gdkx.h> #include "gsm-manager.h" -#include "gsm-manager-glue.h" +#include "org.gnome.SessionManager.h" #include "gsm-store.h" #include "gsm-inhibitor.h" @@ -69,6 +67,7 @@ #define GSM_MANAGER_DBUS_PATH "/org/gnome/SessionManager" #define GSM_MANAGER_DBUS_NAME "org.gnome.SessionManager" +#define GSM_MANAGER_DBUS_IFACE "org.gnome.SessionManager" #define GSM_MANAGER_PHASE_TIMEOUT 30 /* seconds */ @@ -147,8 +146,10 @@ typedef struct { char *renderer; DBusGProxy *bus_proxy; - DBusGConnection *connection; + GDBusConnection *connection; + GsmExportedManager *skeleton; gboolean dbus_disconnected : 1; + guint name_owner_id; } GsmManagerPrivate; enum { @@ -190,48 +191,32 @@ static gpointer manager_object = NULL; G_DEFINE_TYPE_WITH_PRIVATE (GsmManager, gsm_manager, G_TYPE_OBJECT) +static const GDBusErrorEntry gsm_manager_error_entries[] = { + { GSM_MANAGER_ERROR_GENERAL, GSM_MANAGER_DBUS_IFACE ".GeneralError" }, + { GSM_MANAGER_ERROR_NOT_IN_INITIALIZATION, GSM_MANAGER_DBUS_IFACE ".NotInInitialization" }, + { GSM_MANAGER_ERROR_NOT_IN_RUNNING, GSM_MANAGER_DBUS_IFACE ".NotInRunning" }, + { GSM_MANAGER_ERROR_ALREADY_REGISTERED, GSM_MANAGER_DBUS_IFACE ".AlreadyRegistered" }, + { GSM_MANAGER_ERROR_NOT_REGISTERED, GSM_MANAGER_DBUS_IFACE ".NotRegistered" }, + { GSM_MANAGER_ERROR_INVALID_OPTION, GSM_MANAGER_DBUS_IFACE ".InvalidOption" }, + { GSM_MANAGER_ERROR_LOCKED_DOWN, GSM_MANAGER_DBUS_IFACE ".LockedDown" } +}; + GQuark gsm_manager_error_quark (void) { - static GQuark ret = 0; - if (ret == 0) { - ret = g_quark_from_static_string ("gsm_manager_error"); - } - - return ret; -} - -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -gsm_manager_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - ENUM_ENTRY (GSM_MANAGER_ERROR_GENERAL, "GeneralError"), - ENUM_ENTRY (GSM_MANAGER_ERROR_NOT_IN_INITIALIZATION, "NotInInitialization"), - ENUM_ENTRY (GSM_MANAGER_ERROR_NOT_IN_RUNNING, "NotInRunning"), - ENUM_ENTRY (GSM_MANAGER_ERROR_ALREADY_REGISTERED, "AlreadyRegistered"), - ENUM_ENTRY (GSM_MANAGER_ERROR_NOT_REGISTERED, "NotRegistered"), - ENUM_ENTRY (GSM_MANAGER_ERROR_INVALID_OPTION, "InvalidOption"), - ENUM_ENTRY (GSM_MANAGER_ERROR_LOCKED_DOWN, "LockedDown"), - { 0, 0, 0 } - }; - - g_assert (GSM_MANAGER_NUM_ERRORS == G_N_ELEMENTS (values) - 1); - - etype = g_enum_register_static ("GsmManagerError", values); - } + static volatile gsize quark_volatile = 0; - return etype; + g_dbus_error_register_error_domain ("gsm_manager_error", + &quark_volatile, + gsm_manager_error_entries, + G_N_ELEMENTS (gsm_manager_error_entries)); + return quark_volatile; } static gboolean -_debug_client (const char *id, +_debug_client (const char *id G_GNUC_UNUSED, GsmClient *client, - GsmManager *manager) + GsmManager *manager G_GNUC_UNUSED) { g_debug ("GsmManager: Client %s", gsm_client_peek_id (client)); return FALSE; @@ -248,9 +233,9 @@ debug_clients (GsmManager *manager) } static gboolean -_debug_inhibitor (const char *id, +_debug_inhibitor (const char *id G_GNUC_UNUSED, GsmInhibitor *inhibitor, - GsmManager *manager) + GsmManager *manager G_GNUC_UNUSED) { g_debug ("GsmManager: Inhibitor app:%s client:%s bus-name:%s reason:%s", gsm_inhibitor_peek_app_id (inhibitor), @@ -272,7 +257,7 @@ debug_inhibitors (GsmManager *manager) } static gboolean -_find_by_cookie (const char *id, +_find_by_cookie (const char *id G_GNUC_UNUSED, GsmInhibitor *inhibitor, guint *cookie_ap) { @@ -284,7 +269,7 @@ _find_by_cookie (const char *id, } static gboolean -_find_by_startup_id (const char *id, +_find_by_startup_id (const char *id G_GNUC_UNUSED, GsmClient *client, const char *startup_id_a) { @@ -793,7 +778,7 @@ _client_end_session (GsmClient *client, } static gboolean -_client_end_session_helper (const char *id, +_client_end_session_helper (const char *id G_GNUC_UNUSED, GsmClient *client, ClientEndSessionData *data) { @@ -869,9 +854,9 @@ do_phase_end_session_part_2 (GsmManager *manager) } static gboolean -_client_stop (const char *id, +_client_stop (const char *id G_GNUC_UNUSED, GsmClient *client, - gpointer user_data) + gpointer user_data G_GNUC_UNUSED) { gboolean ret; GError *error; @@ -954,7 +939,7 @@ do_phase_exit (GsmManager *manager) } static gboolean -_client_query_end_session (const char *id, +_client_query_end_session (const char *id G_GNUC_UNUSED, GsmClient *client, ClientEndSessionData *data) { @@ -979,7 +964,7 @@ _client_query_end_session (const char *id, } static gboolean -inhibitor_has_flag (gpointer key, +inhibitor_has_flag (gpointer key G_GNUC_UNUSED, GsmInhibitor *inhibitor, gpointer data) { @@ -1036,9 +1021,9 @@ gsm_manager_is_idle_inhibited (GsmManager *manager) } static gboolean -_client_cancel_end_session (const char *id, +_client_cancel_end_session (const char *id G_GNUC_UNUSED, GsmClient *client, - GsmManager *manager) + GsmManager *manager G_GNUC_UNUSED) { gboolean res; GError *error; @@ -1054,9 +1039,9 @@ _client_cancel_end_session (const char *id, } static gboolean -inhibitor_is_jit (gpointer key, +inhibitor_is_jit (gpointer key G_GNUC_UNUSED, GsmInhibitor *inhibitor, - GsmManager *manager) + GsmManager *manager G_GNUC_UNUSED) { gboolean matches; const char *id; @@ -1619,7 +1604,7 @@ start_phase (GsmManager *manager) do_phase_startup (manager); break; case GSM_MANAGER_PHASE_RUNNING: - g_signal_emit (manager, signals[SESSION_RUNNING], 0); + gsm_exported_manager_emit_session_running (manager->priv->skeleton); update_idle (manager); break; case GSM_MANAGER_PHASE_QUERY_END_SESSION: @@ -1638,7 +1623,7 @@ start_phase (GsmManager *manager) } static gboolean -_debug_app_for_phase (const char *id, +_debug_app_for_phase (const char *id G_GNUC_UNUSED, GsmApp *app, gpointer data) { @@ -1700,7 +1685,7 @@ _gsm_manager_set_renderer (GsmManager *manager, } static gboolean -_app_has_app_id (const char *id, +_app_has_app_id (const char *id G_GNUC_UNUSED, GsmApp *app, const char *app_id_a) { @@ -1725,7 +1710,7 @@ find_app_for_app_id (GsmManager *manager, } static gboolean -inhibitor_has_client_id (gpointer key, +inhibitor_has_client_id (gpointer key G_GNUC_UNUSED, GsmInhibitor *inhibitor, const char *client_id_a) { @@ -1748,7 +1733,7 @@ inhibitor_has_client_id (gpointer key, } static gboolean -_app_has_startup_id (const char *id, +_app_has_startup_id (const char *id G_GNUC_UNUSED, GsmApp *app, const char *startup_id_a) { @@ -1920,7 +1905,7 @@ typedef struct { } RemoveClientData; static gboolean -_disconnect_dbus_client (const char *id, +_disconnect_dbus_client (const char *id G_GNUC_UNUSED, GsmClient *client, RemoveClientData *data) { @@ -1982,7 +1967,7 @@ remove_clients_for_connection (GsmManager *manager, } static gboolean -inhibitor_has_bus_name (gpointer key, +inhibitor_has_bus_name (gpointer key G_GNUC_UNUSED, GsmInhibitor *inhibitor, RemoveClientData *data) { @@ -2025,8 +2010,8 @@ remove_inhibitors_for_connection (GsmManager *manager, } static void -bus_name_owner_changed (DBusGProxy *bus_proxy, - const char *service_name, +bus_name_owner_changed (DBusGProxy *bus_proxy G_GNUC_UNUSED, + const char *service_name G_GNUC_UNUSED, const char *old_service_name, const char *new_service_name, GsmManager *manager) @@ -2046,7 +2031,7 @@ bus_name_owner_changed (DBusGProxy *bus_proxy, } static DBusHandlerResult -gsm_manager_bus_filter (DBusConnection *connection, +gsm_manager_bus_filter (DBusConnection *connection G_GNUC_UNUSED, DBusMessage *message, void *user_data) { @@ -2129,7 +2114,7 @@ gsm_manager_set_failsafe (GsmManager *manager, } static gboolean -_client_has_startup_id (const char *id, +_client_has_startup_id (const char *id G_GNUC_UNUSED, GsmClient *client, const char *startup_id_a) { @@ -2184,13 +2169,13 @@ on_xsmp_client_register_request (GsmXSMPClient *client, if (IS_STRING_EMPTY (*id)) { new_id = gsm_util_generate_startup_id (); } else { - GsmClient *sm_client; + GsmClient *c; - sm_client = (GsmClient *)gsm_store_find (priv->clients, - (GsmStoreFunc)_client_has_startup_id, - *id); + c = (GsmClient *)gsm_store_find (priv->clients, + (GsmStoreFunc)_client_has_startup_id, + *id); /* We can't have two clients with the same id. */ - if (sm_client != NULL) { + if (c != NULL) { goto out; } @@ -2405,7 +2390,7 @@ on_client_end_session_response (GsmClient *client, } static void -on_xsmp_client_logout_request (GsmXSMPClient *client, +on_xsmp_client_logout_request (GsmXSMPClient *client G_GNUC_UNUSED, gboolean show_dialog, GsmManager *manager) { @@ -2454,7 +2439,7 @@ on_store_client_added (GsmStore *store, G_CALLBACK (on_client_end_session_response), manager); - g_signal_emit (manager, signals [CLIENT_ADDED], 0, id); + gsm_exported_manager_emit_client_added (manager->priv->skeleton, id); /* FIXME: disconnect signal handler */ } @@ -2465,7 +2450,7 @@ on_store_client_removed (GsmStore *store, { g_debug ("GsmManager: Client removed: %s", id); - g_signal_emit (manager, signals [CLIENT_REMOVED], 0, id); + gsm_exported_manager_emit_client_removed (manager->priv->skeleton, id); } static void @@ -2586,7 +2571,7 @@ on_store_inhibitor_added (GsmStore *store, GsmManager *manager) { g_debug ("GsmManager: Inhibitor added: %s", id); - g_signal_emit (manager, signals [INHIBITOR_ADDED], 0, id); + gsm_exported_manager_emit_inhibitor_added (manager->priv->skeleton, id); update_idle (manager); } @@ -2596,7 +2581,7 @@ on_store_inhibitor_removed (GsmStore *store, GsmManager *manager) { g_debug ("GsmManager: Inhibitor removed: %s", id); - g_signal_emit (manager, signals [INHIBITOR_REMOVED], 0, id); + gsm_exported_manager_emit_inhibitor_removed (manager->priv->skeleton, id); update_idle (manager); } @@ -2658,7 +2643,18 @@ gsm_manager_dispose (GObject *object) priv->settings_screensaver = NULL; } - g_clear_pointer (&priv->renderer, g_free); + if (manager->priv->name_owner_id != 0) { + g_dbus_connection_signal_unsubscribe (manager->priv->connection, manager->priv->name_owner_id);; + manager->priv->name_owner_id = 0; + } + + if (manager->priv->skeleton != NULL) { + g_dbus_interface_skeleton_unexport_from_connection (G_DBUS_INTERFACE_SKELETON (manager->priv->skeleton), + manager->priv->connection); + g_clear_object (&manager->priv->skeleton); + } + + g_clear_object (&manager->priv->connection); G_OBJECT_CLASS (gsm_manager_parent_class)->dispose (object); } @@ -2685,67 +2681,6 @@ gsm_manager_class_init (GsmManagerClass *klass) G_TYPE_NONE, 1, G_TYPE_STRING); - signals [SESSION_RUNNING] = - g_signal_new ("session-running", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GsmManagerClass, session_running), - NULL, - NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); - - signals [SESSION_OVER] = - g_signal_new ("session-over", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GsmManagerClass, session_over), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); - signals [CLIENT_ADDED] = - g_signal_new ("client-added", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GsmManagerClass, client_added), - NULL, - NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, - 1, DBUS_TYPE_G_OBJECT_PATH); - signals [CLIENT_REMOVED] = - g_signal_new ("client-removed", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GsmManagerClass, client_removed), - NULL, - NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, - 1, DBUS_TYPE_G_OBJECT_PATH); - signals [INHIBITOR_ADDED] = - g_signal_new ("inhibitor-added", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GsmManagerClass, inhibitor_added), - NULL, - NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, - 1, DBUS_TYPE_G_OBJECT_PATH); - signals [INHIBITOR_REMOVED] = - g_signal_new ("inhibitor-removed", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GsmManagerClass, inhibitor_removed), - NULL, - NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, - 1, DBUS_TYPE_G_OBJECT_PATH); - g_object_class_install_property (object_class, PROP_FAILSAFE, g_param_spec_boolean ("failsafe", @@ -2768,9 +2703,6 @@ gsm_manager_class_init (GsmManagerClass *klass) NULL, NULL, G_PARAM_READABLE)); - - dbus_g_object_type_install_info (GSM_TYPE_MANAGER, &dbus_glib_gsm_manager_object_info); - dbus_g_error_domain_register (GSM_MANAGER_ERROR, NULL, GSM_MANAGER_TYPE_ERROR); } static void diff --git a/mate-session/gsm-presence.c b/mate-session/gsm-presence.c index 7fc2304..d948ec9 100644 --- a/mate-session/gsm-presence.c +++ b/mate-session/gsm-presence.c @@ -27,13 +27,12 @@ #include <time.h> #include <unistd.h> -#include <dbus/dbus-glib.h> - #include "gs-idle-monitor.h" #include "gsm-presence.h" -#include "gsm-presence-glue.h" +#include "org.gnome.SessionManager.Presence.h" +#define GSM_PRESENCE_DBUS_IFACE "org.gnome.SessionManager.Presence" #define GSM_PRESENCE_DBUS_PATH "/org/gnome/SessionManager/Presence" #define GS_NAME "org.mate.ScreenSaver" @@ -51,59 +50,92 @@ typedef struct { guint idle_watch_id; guint idle_timeout; gboolean screensaver_active; - DBusGConnection *bus_connection; - DBusGProxy *bus_proxy; - DBusGProxy *screensaver_proxy; + GDBusConnection *connection; + GDBusProxy *screensaver_proxy; + + GsmExportedPresence *skeleton; } GsmPresencePrivate; enum { PROP_0, - PROP_STATUS, - PROP_STATUS_TEXT, PROP_IDLE_ENABLED, PROP_IDLE_TIMEOUT, }; enum { STATUS_CHANGED, - STATUS_TEXT_CHANGED, LAST_SIGNAL }; -static guint signals [LAST_SIGNAL] = { 0 }; +static guint signals[LAST_SIGNAL] = { 0, }; G_DEFINE_TYPE_WITH_PRIVATE (GsmPresence, gsm_presence, G_TYPE_OBJECT); +static const GDBusErrorEntry gsm_presence_error_entries[] = { + { GSM_PRESENCE_ERROR_GENERAL, GSM_PRESENCE_DBUS_IFACE ".GeneralError" } +}; + GQuark gsm_presence_error_quark (void) { - static GQuark ret = 0; - if (ret == 0) { - ret = g_quark_from_static_string ("gsm_presence_error"); - } + static volatile gsize quark_volatile = 0; - return ret; + g_dbus_error_register_error_domain ("gsm_presence_error", + &quark_volatile, + gsm_presence_error_entries, + G_N_ELEMENTS (gsm_presence_error_entries)); + return quark_volatile; } -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } - -GType -gsm_presence_error_get_type (void) +static void idle_became_active_cb (GSIdleMonitor *idle_monitor, + guint id, + gpointer user_data); +static void +gsm_presence_set_status (GsmPresence *presence, + guint status) { - static GType etype = 0; - - if (etype == 0) { - static const GEnumValue values[] = { - ENUM_ENTRY (GSM_PRESENCE_ERROR_GENERAL, "GeneralError"), - { 0, 0, 0 } - }; - - g_assert (GSM_PRESENCE_NUM_ERRORS == G_N_ELEMENTS (values) - 1); - - etype = g_enum_register_static ("GsmPresenceError", values); - } + GsmPresencePrivate *priv; + + priv = gsm_presence_get_instance_private (presence); + if (status != priv->status) { + priv->status = status; + gsm_exported_presence_set_status (priv->skeleton, status); + gsm_exported_presence_emit_status_changed (priv->skeleton, priv->status); + g_signal_emit (presence, signals[STATUS_CHANGED], 0, priv->status); + } +} - return etype; +static gboolean +gsm_presence_set_status_text (GsmPresence *presence, + const char *status_text, + GError **error) +{ + g_return_val_if_fail (GSM_IS_PRESENCE (presence), FALSE); + GsmPresencePrivate *priv; + + priv = gsm_presence_get_instance_private (presence); + + g_free (priv->status_text); + priv->status_text = NULL; + + /* check length */ + if (status_text != NULL && strlen (status_text) > MAX_STATUS_TEXT) { + g_set_error (error, + GSM_PRESENCE_ERROR, + GSM_PRESENCE_ERROR_GENERAL, + "Status text too long"); + return FALSE; + } + + if (status_text != NULL) { + priv->status_text = g_strdup (status_text); + } else { + priv->status_text = g_strdup (""); + } + + gsm_exported_presence_set_status_text (priv->skeleton, priv->status_text); + gsm_exported_presence_emit_status_text_changed (priv->skeleton, priv->status_text); + return TRUE; } static void @@ -123,7 +155,7 @@ set_session_idle (GsmPresence *presence, /* save current status */ priv->saved_status = priv->status; - gsm_presence_set_status (presence, GSM_PRESENCE_STATUS_IDLE, NULL); + gsm_presence_set_status (presence, GSM_PRESENCE_STATUS_IDLE); } else { if (priv->status != GSM_PRESENCE_STATUS_IDLE) { g_debug ("GsmPresence: already not idle, ignoring"); @@ -131,14 +163,14 @@ set_session_idle (GsmPresence *presence, } /* restore saved status */ - gsm_presence_set_status (presence, priv->saved_status, NULL); + gsm_presence_set_status (presence, priv->saved_status); priv->saved_status = GSM_PRESENCE_STATUS_AVAILABLE; } } static gboolean -on_idle_timeout (GSIdleMonitor *monitor, - guint id, +on_idle_timeout (GSIdleMonitor *monitor G_GNUC_UNUSED, + guint id G_GNUC_UNUSED, gboolean condition, GsmPresence *presence) { @@ -180,14 +212,22 @@ reset_idle_watch (GsmPresence *presence) } static void -on_screensaver_active_changed (DBusGProxy *proxy, - gboolean is_active, - GsmPresence *presence) +on_screensaver_dbus_signal (GDBusProxy *proxy G_GNUC_UNUSED, + gchar *sender_name G_GNUC_UNUSED, + gchar *signal_name G_GNUC_UNUSED, + GVariant *parameters, + GsmPresence *presence) { GsmPresencePrivate *priv; - - g_debug ("screensaver status changed: %d", is_active); priv = gsm_presence_get_instance_private (presence); + gboolean is_active; + + if (g_strcmp0 (signal_name, "ActiveChanged") != 0) { + return; + } + + g_variant_get (parameters, "(b)", &is_active); + if (priv->screensaver_active != is_active) { priv->screensaver_active = is_active; reset_idle_watch (presence); @@ -196,70 +236,54 @@ on_screensaver_active_changed (DBusGProxy *proxy, } static void -on_screensaver_proxy_destroy (GObject *proxy, - GsmPresence *presence) +on_screensaver_name_owner_changed (GDBusProxy *screensaver_proxy, + GParamSpec *pspec G_GNUC_UNUSED, + GsmPresence *presence) { GsmPresencePrivate *priv; + gchar *name_owner; g_warning ("Detected that screensaver has left the bus"); priv = gsm_presence_get_instance_private (presence); - priv->screensaver_proxy = NULL; - priv->screensaver_active = FALSE; - set_session_idle (presence, FALSE); + name_owner = g_dbus_proxy_get_name_owner (screensaver_proxy); + if (name_owner == NULL) { + g_debug ("Detected that screensaver has left the bus"); + + priv->screensaver_proxy = NULL; + priv->screensaver_active = FALSE; + set_session_idle (presence, FALSE); + } + + g_free (name_owner); reset_idle_watch (presence); } -static void -on_bus_name_owner_changed (DBusGProxy *bus_proxy, - const char *service_name, - const char *old_service_name, - const char *new_service_name, - GsmPresence *presence) +static gboolean +gsm_presence_set_status_text_dbus (GsmExportedPresence *skeleton, + GDBusMethodInvocation *invocation, + gchar *status_text, + GsmPresence *presence) { - GError *error; - GsmPresencePrivate *priv; - - priv = gsm_presence_get_instance_private (presence); + GError *error = NULL; - if (service_name == NULL - || strcmp (service_name, GS_NAME) != 0) { - /* ignore */ - return; + if (gsm_presence_set_status_text (presence, status_text, &error)) { + gsm_exported_presence_complete_set_status_text (skeleton, invocation); + } else { + g_dbus_method_invocation_take_error (invocation, error); } + return TRUE; +} - if (strlen (new_service_name) == 0 - && strlen (old_service_name) > 0) { - /* service removed */ - /* let destroy signal handle this? */ - } else if (strlen (old_service_name) == 0 - && strlen (new_service_name) > 0) { - /* service added */ - error = NULL; - priv->screensaver_proxy = dbus_g_proxy_new_for_name_owner (priv->bus_connection, - GS_NAME, - GS_PATH, - GS_INTERFACE, - &error); - if (priv->screensaver_proxy != NULL) { - g_signal_connect (priv->screensaver_proxy, - "destroy", - G_CALLBACK (on_screensaver_proxy_destroy), - presence); - dbus_g_proxy_add_signal (priv->screensaver_proxy, - "ActiveChanged", - G_TYPE_BOOLEAN, - G_TYPE_INVALID); - dbus_g_proxy_connect_signal (priv->screensaver_proxy, - "ActiveChanged", - G_CALLBACK (on_screensaver_active_changed), - presence, - NULL); - } else { - g_warning ("Unable to get screensaver proxy: %s", error->message); - g_error_free (error); - } - } +static gboolean +gsm_presence_set_status_dbus (GsmExportedPresence *skeleton, + GDBusMethodInvocation *invocation, + guint status, + GsmPresence *presence) +{ + gsm_presence_set_status (presence, status); + gsm_exported_presence_complete_set_status (skeleton, invocation); + return TRUE; } static gboolean @@ -267,21 +291,33 @@ register_presence (GsmPresence *presence) { GError *error; GsmPresencePrivate *priv; + GsmExportedPresence *skeleton; error = NULL; priv = gsm_presence_get_instance_private (presence); - priv->bus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - if (priv->bus_connection == NULL) { - if (error != NULL) { - g_critical ("error getting session bus: %s", error->message); - g_error_free (error); - } + priv->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); + if (error != NULL) { + g_critical ("error getting session bus: %s", error->message); + g_error_free (error); return FALSE; } - dbus_g_connection_register_g_object (priv->bus_connection, GSM_PRESENCE_DBUS_PATH, G_OBJECT (presence)); + skeleton = gsm_exported_presence_skeleton_new (); + priv->skeleton = skeleton; + g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (skeleton), + priv->connection, + GSM_PRESENCE_DBUS_PATH, &error); + if (error != NULL) { + g_critical ("error registering presence object on session bus: %s", error->message); + g_error_free (error); + return FALSE; + } + g_signal_connect (skeleton, "handle-set-status", + G_CALLBACK (gsm_presence_set_status_dbus), presence); + g_signal_connect (skeleton, "handle-set-status-text", + G_CALLBACK (gsm_presence_set_status_text_dbus), presence); return TRUE; } @@ -293,6 +329,7 @@ gsm_presence_constructor (GType type, GsmPresence *presence; gboolean res; GsmPresencePrivate *priv; + GError *error = NULL; presence = GSM_PRESENCE (G_OBJECT_CLASS (gsm_presence_parent_class)->constructor (type, n_construct_properties, @@ -304,22 +341,22 @@ gsm_presence_constructor (GType type, g_warning ("Unable to register presence with session bus"); } - priv->bus_proxy = dbus_g_proxy_new_for_name (priv->bus_connection, - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS); - if (priv->bus_proxy != NULL) { - dbus_g_proxy_add_signal (priv->bus_proxy, - "NameOwnerChanged", - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_INVALID); - dbus_g_proxy_connect_signal (priv->bus_proxy, - "NameOwnerChanged", - G_CALLBACK (on_bus_name_owner_changed), - presence, - NULL); + priv->screensaver_proxy = g_dbus_proxy_new_sync (priv->connection, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + GS_NAME, + GS_PATH, + GS_INTERFACE, + NULL, &error); + if (error != NULL) { + g_critical ("Unable to create a DBus proxy for GnomeScreensaver: %s", + error->message); + g_error_free (error); + } else { + g_signal_connect (priv->screensaver_proxy, "notify::g-name-owner", + G_CALLBACK (on_screensaver_name_owner_changed), presence); + g_signal_connect (priv->screensaver_proxy, "g-signal", + G_CALLBACK (on_screensaver_dbus_signal), presence); } return G_OBJECT (presence); @@ -352,55 +389,6 @@ gsm_presence_set_idle_enabled (GsmPresence *presence, } } -gboolean -gsm_presence_set_status_text (GsmPresence *presence, - const char *status_text, - GError **error) -{ - GsmPresencePrivate *priv; - g_return_val_if_fail (GSM_IS_PRESENCE (presence), FALSE); - - priv = gsm_presence_get_instance_private (presence); - - g_free (priv->status_text); - - /* check length */ - if (status_text != NULL && strlen (status_text) > MAX_STATUS_TEXT) { - g_set_error (error, - GSM_PRESENCE_ERROR, - GSM_PRESENCE_ERROR_GENERAL, - "Status text too long"); - return FALSE; - } - - if (status_text != NULL) { - priv->status_text = g_strdup (status_text); - } else { - priv->status_text = g_strdup (""); - } - g_object_notify (G_OBJECT (presence), "status-text"); - g_signal_emit (presence, signals[STATUS_TEXT_CHANGED], 0, priv->status_text); - return TRUE; -} - -gboolean -gsm_presence_set_status (GsmPresence *presence, - guint status, - GError **error) -{ - GsmPresencePrivate *priv; - - g_return_val_if_fail (GSM_IS_PRESENCE (presence), FALSE); - priv = gsm_presence_get_instance_private (presence); - - if (status != priv->status) { - priv->status = status; - g_object_notify (G_OBJECT (presence), "status"); - g_signal_emit (presence, signals[STATUS_CHANGED], 0, priv->status); - } - return TRUE; -} - void gsm_presence_set_idle_timeout (GsmPresence *presence, guint timeout) @@ -428,12 +416,6 @@ gsm_presence_set_property (GObject *object, self = GSM_PRESENCE (object); switch (prop_id) { - case PROP_STATUS: - gsm_presence_set_status (self, g_value_get_uint (value), NULL); - break; - case PROP_STATUS_TEXT: - gsm_presence_set_status_text (self, g_value_get_string (value), NULL); - break; case PROP_IDLE_ENABLED: gsm_presence_set_idle_enabled (self, g_value_get_boolean (value)); break; @@ -460,12 +442,6 @@ gsm_presence_get_property (GObject *object, priv = gsm_presence_get_instance_private (self); switch (prop_id) { - case PROP_STATUS: - g_value_set_uint (value, priv->status); - break; - case PROP_STATUS_TEXT: - g_value_set_string (value, priv->status_text); - break; case PROP_IDLE_ENABLED: g_value_set_boolean (value, priv->idle_enabled); break; @@ -515,43 +491,6 @@ gsm_presence_class_init (GsmPresenceClass *klass) object_class->get_property = gsm_presence_get_property; object_class->set_property = gsm_presence_set_property; - signals [STATUS_CHANGED] = - g_signal_new ("status-changed", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GsmPresenceClass, status_changed), - NULL, - NULL, - g_cclosure_marshal_VOID__UINT, - G_TYPE_NONE, - 1, G_TYPE_UINT); - signals [STATUS_TEXT_CHANGED] = - g_signal_new ("status-text-changed", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GsmPresenceClass, status_text_changed), - NULL, - NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, - 1, G_TYPE_STRING); - - g_object_class_install_property (object_class, - PROP_STATUS, - g_param_spec_uint ("status", - "status", - "status", - 0, - G_MAXINT, - 0, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - g_object_class_install_property (object_class, - PROP_STATUS_TEXT, - g_param_spec_string ("status-text", - "status text", - "status text", - "", - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); g_object_class_install_property (object_class, PROP_IDLE_ENABLED, g_param_spec_boolean ("idle-enabled", @@ -568,9 +507,6 @@ gsm_presence_class_init (GsmPresenceClass *klass) G_MAXINT, 300000, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - dbus_g_object_type_install_info (GSM_TYPE_PRESENCE, &dbus_glib_gsm_presence_object_info); - dbus_g_error_domain_register (GSM_PRESENCE_ERROR, NULL, GSM_PRESENCE_TYPE_ERROR); } GsmPresence * diff --git a/mate-session/gsm-presence.h b/mate-session/gsm-presence.h index 27d611b..7728f21 100644 --- a/mate-session/gsm-presence.h +++ b/mate-session/gsm-presence.h @@ -36,9 +36,6 @@ struct _GsmPresenceClass void (* status_changed) (GsmPresence *presence, guint status); - void (* status_text_changed) (GsmPresence *presence, - const char *status_text); - }; typedef enum { @@ -55,9 +52,6 @@ typedef enum } GsmPresenceError; #define GSM_PRESENCE_ERROR gsm_presence_error_quark () -GType gsm_presence_error_get_type (void); -#define GSM_PRESENCE_TYPE_ERROR (gsm_presence_error_get_type ()) - GQuark gsm_presence_error_quark (void); GsmPresence * gsm_presence_new (void); @@ -67,14 +61,6 @@ void gsm_presence_set_idle_enabled (GsmPresence *presence, void gsm_presence_set_idle_timeout (GsmPresence *presence, guint n_seconds); -/* exported to bus */ -gboolean gsm_presence_set_status (GsmPresence *presence, - guint status, - GError **error); -gboolean gsm_presence_set_status_text (GsmPresence *presence, - const char *status_text, - GError **error); - G_END_DECLS #endif /* __GSM_PRESENCE_H__ */ diff --git a/mate-session/gsm-systemd.c b/mate-session/gsm-systemd.c index 74def27..7f7dde1 100644 --- a/mate-session/gsm-systemd.c +++ b/mate-session/gsm-systemd.c @@ -150,7 +150,7 @@ gsm_systemd_class_init (GsmSystemdClass *manager_class) } static DBusHandlerResult -gsm_systemd_dbus_filter (DBusConnection *connection, +gsm_systemd_dbus_filter (DBusConnection *connection G_GNUC_UNUSED, DBusMessage *message, void *user_data) { @@ -272,10 +272,10 @@ out: } static void -gsm_systemd_on_name_owner_changed (DBusGProxy *bus_proxy, +gsm_systemd_on_name_owner_changed (DBusGProxy *bus_proxy G_GNUC_UNUSED, const char *name, - const char *prev_owner, - const char *new_owner, + const char *prev_owner G_GNUC_UNUSED, + const char *new_owner G_GNUC_UNUSED, GsmSystemd *manager) { GsmSystemdPrivate *priv; @@ -421,7 +421,7 @@ emit_stop_complete (GsmSystemd *manager, } gboolean -gsm_systemd_is_last_session_for_user (GsmSystemd *manager) +gsm_systemd_is_last_session_for_user (GsmSystemd *manager G_GNUC_UNUSED) { char **sessions = NULL; char *session = NULL; diff --git a/mate-session/gsm-xsmp-client.c b/mate-session/gsm-xsmp-client.c index bffecac..cae732a 100644 --- a/mate-session/gsm-xsmp-client.c +++ b/mate-session/gsm-xsmp-client.c @@ -73,8 +73,8 @@ static guint signals[LAST_SIGNAL] = { 0 }; G_DEFINE_TYPE_WITH_PRIVATE (GsmXSMPClient, gsm_xsmp_client, GSM_TYPE_CLIENT) static gboolean -client_iochannel_watch (GIOChannel *channel, - GIOCondition condition, +client_iochannel_watch (GIOChannel *channel G_GNUC_UNUSED, + GIOCondition condition G_GNUC_UNUSED, GsmXSMPClient *client) { gboolean keep_going; @@ -279,7 +279,7 @@ debug_print_property (SmProp *prop) } static void -set_properties_callback (SmsConn conn, +set_properties_callback (SmsConn conn G_GNUC_UNUSED, SmPointer manager_data, int num_props, SmProp **props) @@ -307,7 +307,7 @@ set_properties_callback (SmsConn conn, } static void -delete_properties_callback (SmsConn conn, +delete_properties_callback (SmsConn conn G_GNUC_UNUSED, SmPointer manager_data, int num_props, char **prop_names) @@ -920,17 +920,17 @@ gsm_xsmp_client_finalize (GObject *object) gsm_xsmp_client_disconnect (client); g_free (priv->description); - g_ptr_array_foreach (priv->props, (GFunc)SmFreeProperty, NULL); + g_ptr_array_foreach (priv->props, (GFunc) SmFreeProperty, NULL); g_ptr_array_free (priv->props, TRUE); G_OBJECT_CLASS (gsm_xsmp_client_parent_class)->finalize (object); } static gboolean -_boolean_handled_accumulator (GSignalInvocationHint *ihint, +_boolean_handled_accumulator (GSignalInvocationHint *ihint G_GNUC_UNUSED, GValue *return_accu, const GValue *handler_return, - gpointer dummy) + gpointer dummy G_GNUC_UNUSED) { gboolean continue_emission; gboolean signal_handled; @@ -1150,7 +1150,7 @@ register_client_callback (SmsConn conn, } static void -save_yourself_request_callback (SmsConn conn, +save_yourself_request_callback (SmsConn conn G_GNUC_UNUSED, SmPointer manager_data, int save_type, Bool shutdown, @@ -1215,7 +1215,7 @@ save_yourself_request_callback (SmsConn conn, } static void -save_yourself_phase2_request_callback (SmsConn conn, +save_yourself_phase2_request_callback (SmsConn conn G_GNUC_UNUSED, SmPointer manager_data) { GsmXSMPClientPrivate *priv; @@ -1236,7 +1236,7 @@ save_yourself_phase2_request_callback (SmsConn conn, } static void -interact_request_callback (SmsConn conn, +interact_request_callback (SmsConn conn G_GNUC_UNUSED, SmPointer manager_data, int dialog_type) { @@ -1274,7 +1274,7 @@ interact_request_callback (SmsConn conn, } static void -interact_done_callback (SmsConn conn, +interact_done_callback (SmsConn conn G_GNUC_UNUSED, SmPointer manager_data, Bool cancel_shutdown) { @@ -1293,7 +1293,7 @@ interact_done_callback (SmsConn conn, } static void -save_yourself_done_callback (SmsConn conn, +save_yourself_done_callback (SmsConn conn G_GNUC_UNUSED, SmPointer manager_data, Bool success) { @@ -1329,7 +1329,7 @@ save_yourself_done_callback (SmsConn conn, } static void -close_connection_callback (SmsConn conn, +close_connection_callback (SmsConn conn G_GNUC_UNUSED, SmPointer manager_data, int count, char **reason_msgs) diff --git a/mate-session/org.gnome.SessionManager.xml b/mate-session/org.gnome.SessionManager.xml index 47deb6b..09826ff 100644 --- a/mate-session/org.gnome.SessionManager.xml +++ b/mate-session/org.gnome.SessionManager.xml @@ -44,7 +44,6 @@ <!-- Running phase interfaces --> <method name="RegisterClient"> - <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg type="s" name="app_id" direction="in"> <doc:doc> <doc:summary>The application identifier</doc:summary> @@ -68,7 +67,6 @@ </method> <method name="UnregisterClient"> - <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg type="o" name="client_id" direction="in"> <doc:doc> <doc:summary>The object path of the client</doc:summary> @@ -82,7 +80,6 @@ </method> <method name="Inhibit"> - <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg type="s" name="app_id" direction="in"> <doc:doc> <doc:summary>The application identifier</doc:summary> @@ -159,7 +156,6 @@ </method> <method name="Uninhibit"> - <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg type="u" name="inhibit_cookie" direction="in"> <doc:doc> <doc:summary>The cookie</doc:summary> |