From 541cf9615dce339e8f2efb32c16c3a94680917c5 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Fri, 2 Aug 2013 15:54:26 -0400 Subject: common: generate session manager proxy Generating D-Bus proxies is more convienent and more typesafe than using naked GDBusProxy objects. As a first step this commit changes the common session manager proxy to be generated from XML. Since the generated proxy can be compatibly used in any existing GDBusProxy calls, this commit doesn't attempt to rewrite all the plugins to use the generated apis. That can happen in future clean ups. https://bugzilla.gnome.org/show_bug.cgi?id=705127 --- gnome-settings-daemon/Makefile.am | 18 +- gnome-settings-daemon/gnome-settings-session.c | 19 +- gnome-settings-daemon/gnome-settings-session.h | 3 +- gnome-settings-daemon/main.c | 2 +- gnome-settings-daemon/org.gnome.SessionManager.xml | 451 +++++++++++++++++++++ plugins/color/gsd-color-x11.c | 2 +- plugins/media-keys/gsd-media-keys-manager.c | 2 +- plugins/power/gsd-power-manager.c | 10 +- .../gsd-screensaver-proxy-manager.c | 8 +- plugins/updates/gsd-updates-manager.c | 6 +- plugins/updates/gsd-updates-refresh.c | 6 +- 11 files changed, 496 insertions(+), 31 deletions(-) create mode 100644 gnome-settings-daemon/org.gnome.SessionManager.xml diff --git a/gnome-settings-daemon/Makefile.am b/gnome-settings-daemon/Makefile.am index 7cb28051..c0d749e3 100644 --- a/gnome-settings-daemon/Makefile.am +++ b/gnome-settings-daemon/Makefile.am @@ -1,4 +1,5 @@ NULL = +BUILT_SOURCES = $(NULL) AM_CPPFLAGS = \ -DDATADIR=\""$(datadir)"\" \ @@ -18,7 +19,20 @@ privlib_LTLIBRARIES = \ libgsd.la \ $(NULL) +session_manager_dbus_built_sources = gsd-session-manager-glue.c gsd-session-manager-glue.h +BUILT_SOURCES += $(session_manager_dbus_built_sources) + +$(session_manager_dbus_built_sources) : Makefile.am org.gnome.SessionManager.xml + gdbus-codegen \ + --interface-prefix org.gnome.SessionManager. \ + --generate-c-code gsd-session-manager-glue \ + --c-namespace Gsd \ + --annotate "org.gnome.SessionManager" \ + "org.gtk.GDBus.C.Name" SessionManager \ + $(srcdir)/org.gnome.SessionManager.xml + libgsd_la_SOURCES = \ + $(session_manager_dbus_built_sources) \ gnome-settings-profile.c \ gnome-settings-profile.h \ gnome-settings-session.c \ @@ -53,7 +67,9 @@ gsd_SCRIPTS = \ gnome-settings-daemon-localeexec EXTRA_DIST = \ - gnome-settings-daemon-localeexec.in + gnome-settings-daemon-localeexec.in \ + org.gnome.SessionManager.xml \ + $(NULL) gnome-settings-daemon-localeexec: gnome-settings-daemon-localeexec.in $(AM_V_GEN) sed -e "s|\@libexecdir\@|$(libexecdir)|" -e "s|\@prefix\@|$(prefix)|" $< > $@.tmp && mv $@.tmp $@ diff --git a/gnome-settings-daemon/gnome-settings-session.c b/gnome-settings-daemon/gnome-settings-session.c index a9efeded..0d883a5d 100644 --- a/gnome-settings-daemon/gnome-settings-session.c +++ b/gnome-settings-daemon/gnome-settings-session.c @@ -31,25 +31,22 @@ #define GNOME_SESSION_DBUS_NAME "org.gnome.SessionManager" #define GNOME_SESSION_DBUS_OBJECT "/org/gnome/SessionManager" -#define GNOME_SESSION_DBUS_INTERFACE "org.gnome.SessionManager" -GDBusProxy * +GsdSessionManager * gnome_settings_session_get_session_proxy (void) { - static GDBusProxy *session_proxy; + static GsdSessionManager *session_proxy; GError *error = NULL; if (session_proxy != NULL) { g_object_ref (session_proxy); } else { - session_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, - G_DBUS_PROXY_FLAGS_NONE, - NULL, - GNOME_SESSION_DBUS_NAME, - GNOME_SESSION_DBUS_OBJECT, - GNOME_SESSION_DBUS_INTERFACE, - NULL, - &error); + session_proxy = gsd_session_manager_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, + G_DBUS_PROXY_FLAGS_NONE, + GNOME_SESSION_DBUS_NAME, + GNOME_SESSION_DBUS_OBJECT, + NULL, + &error); if (error) { g_warning ("Failed to connect to the session manager: %s", error->message); g_error_free (error); diff --git a/gnome-settings-daemon/gnome-settings-session.h b/gnome-settings-daemon/gnome-settings-session.h index 0c9a1b79..857479fd 100644 --- a/gnome-settings-daemon/gnome-settings-session.h +++ b/gnome-settings-daemon/gnome-settings-session.h @@ -23,10 +23,11 @@ #define __GNOME_SETTINGS_SESSION_H #include +#include "gsd-session-manager-glue.h" G_BEGIN_DECLS -GDBusProxy *gnome_settings_session_get_session_proxy (void); +GsdSessionManager *gnome_settings_session_get_session_proxy (void); G_END_DECLS diff --git a/gnome-settings-daemon/main.c b/gnome-settings-daemon/main.c index 353b5587..56cd5e88 100644 --- a/gnome-settings-daemon/main.c +++ b/gnome-settings-daemon/main.c @@ -341,7 +341,7 @@ name_acquired_handler (GDBusConnection *connection, { GDBusProxy *proxy; - proxy = gnome_settings_session_get_session_proxy (); + proxy = G_DBUS_PROXY (gnome_settings_session_get_session_proxy ()); /* Always call this first, as Setenv can only be called before any client registers */ set_locale (proxy); diff --git a/gnome-settings-daemon/org.gnome.SessionManager.xml b/gnome-settings-daemon/org.gnome.SessionManager.xml new file mode 100644 index 00000000..eb69180b --- /dev/null +++ b/gnome-settings-daemon/org.gnome.SessionManager.xml @@ -0,0 +1,451 @@ + + + + + + + + + + + The variable name + + + + + The value + + + + + Adds the variable name to the application launch environment with the specified value. May only be used during the Session Manager initialization phase. + + + + + + + + The locale category + + + + + The value + + + + + Reads the current state of the specific locale category. + + + + + + + + The error message + + + + + Whether the error should be treated as fatal + + + + + May be used by applications launched during the Session Manager initialization phase to indicate there was a problem. + + + + + + + + + + + The application identifier + + + + + Client startup identifier + + + + + The object path of the newly registered client + + + + + Register the caller as a Session Management client. + + + + + + + + + The object path of the client + + + + + Unregister the specified client from Session Management. + + + + + + + + + The application identifier + + + + + The toplevel X window identifier + + + + + The reason for the inhibit + + + + + Flags that specify what should be inhibited + + + + + The cookie + + + + + Proactively indicates that the calling application is performing an action that should not be interrupted and sets a reason to be displayed to the user when an interruption is about to take placea. + + + Applications should invoke this method when they begin an operation that + should not be interrupted, such as creating a CD or DVD. The types of actions + that may be blocked are specified by the flags parameter. When the application + completes the operation it should call Uninhibit() + or disconnect from the session bus. + + + Applications should not expect that they will always be able to block the + action. In most cases, users will be given the option to force the action + to take place. + + + Reasons should be short and to the point. + + + The flags parameter must include at least one of the following: + + + 1 + Inhibit logging out + + + 2 + Inhibit user switching + + + 4 + Inhibit suspending the session or computer + + + 8 + Inhibit the session being marked as idle + + + 16 + Inhibit auto-mounting removable media for the session + + + Values for flags may be bitwise or'ed together. + + + The returned cookie is used to uniquely identify this request. It should be used + as an argument to Uninhibit() in + order to remove the request. + + + + + + + + + + The cookie + + + + + Cancel a previous call to Inhibit() identified by the cookie. + + + + + + + + Flags that spefify what should be inhibited + + + + + Returns TRUE if any of the operations in the bitfield flags are inhibited + + + + + Determine if operation(s) specified by the flags + are currently inhibited. Flags are same as those accepted + by the + Inhibit() + method. + + + + + + + + an array of client IDs + + + + + This gets a list of all the Clients + that are currently known to the session manager. + Each Client ID is an D-Bus object path for the object that implements the + Client interface. + + org.gnome.SessionManager.Client + + + + + + + an array of inhibitor IDs + + + + + This gets a list of all the Inhibitors + that are currently known to the session manager. + Each Inhibitor ID is an D-Bus object path for the object that implements the + Inhibitor interface. + + org.gnome.SessionManager.Inhibitor + + + + + + + + The autostart condition string + + + + + True if condition is handled, false otherwise + + + + + Allows the caller to determine whether the session manager is + handling changes to the specified autostart condition. + + + + + + + + Request a shutdown dialog. + + + + + + + + Request a reboot dialog. + + + + + + + + True if shutdown is available to the user, false otherwise + + + + + Allows the caller to determine whether or not it's okay to show + a shutdown option in the UI + + + + + + + + The type of logout that is being requested + + + + + Request a logout dialog + + Allowed values for the mode parameter are: + + + 0 + Normal. + + + 1 + No confirmation inferface should be shown. + + + 2 + Forcefully logout. No confirmation will be shown and any inhibitors will be ignored. + + + Values for flags may be bitwise or'ed together. + + + + + + + + + True if the session has entered the Running phase, false otherwise + + + + + Allows the caller to determine whether the session manager + has entered the Running phase, in case the client missed the + SessionRunning signal. + + + + + + + + + + The object path for the added client + + + + + Emitted when a client has been added to the session manager. + + + + + + + + The object path for the removed client + + + + + Emitted when a client has been removed from the session manager. + + + + + + + + + The object path for the added inhibitor + + + + + Emitted when an inhibitor has been added to the session manager. + + + + + + + + The object path for the removed inhibitor + + + + + Emitted when an inhibitor has been removed from the session manager. + + + + + + + + + Indicates the session has entered the Running phase. + + + + + + + + Indicates the session is about to end. + + + + + + + + + + The name of the session that has been loaded. + + + + + + + + If true, the session is currently in the + foreground and available for user input. + + + + + + + + A bitmask of flags to indicate which actions + are inhibited. See the Inhibit() function's description + for a list of possible values. + + + + + + diff --git a/plugins/color/gsd-color-x11.c b/plugins/color/gsd-color-x11.c index 6e5fd79b..08b3e291 100644 --- a/plugins/color/gsd-color-x11.c +++ b/plugins/color/gsd-color-x11.c @@ -42,7 +42,7 @@ struct GsdColorX11Private { - GDBusProxy *session; + GsdSessionManager *session; CdClient *client; GnomeRRScreen *x11_screen; GHashTable *edid_cache; diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c index 78f6c5f0..d288f33b 100644 --- a/plugins/media-keys/gsd-media-keys-manager.c +++ b/plugins/media-keys/gsd-media-keys-manager.c @@ -845,7 +845,7 @@ gnome_session_shutdown (GsdMediaKeysManager *manager) GVariant *variant; GDBusProxy *proxy; - proxy = gnome_settings_session_get_session_proxy (); + proxy = G_DBUS_PROXY (gnome_settings_session_get_session_proxy ()); variant = g_dbus_proxy_call_sync (proxy, "Shutdown", NULL, diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c index 3e934512..5d1fe38d 100644 --- a/plugins/power/gsd-power-manager.c +++ b/plugins/power/gsd-power-manager.c @@ -136,7 +136,7 @@ typedef enum { struct GsdPowerManagerPrivate { /* D-Bus */ - GDBusProxy *session; + GsdSessionManager *session; guint name_id; GDBusNodeInfo *introspection_data; GDBusConnection *connection; @@ -1794,7 +1794,7 @@ gnome_session_shutdown_cb (GObject *source_object, static void gnome_session_shutdown (GsdPowerManager *manager) { - g_dbus_proxy_call (manager->priv->session, + g_dbus_proxy_call (G_DBUS_PROXY (manager->priv->session), "Shutdown", NULL, G_DBUS_CALL_FLAGS_NONE, @@ -1826,7 +1826,7 @@ static void gnome_session_logout (GsdPowerManager *manager, guint logout_mode) { - g_dbus_proxy_call (manager->priv->session, + g_dbus_proxy_call (G_DBUS_PROXY (manager->priv->session), "Logout", g_variant_new ("(u)", logout_mode), G_DBUS_CALL_FLAGS_NONE, @@ -2349,7 +2349,7 @@ is_session_active (GsdPowerManager *manager) GVariant *variant; gboolean is_session_active = FALSE; - variant = g_dbus_proxy_get_cached_property (manager->priv->session, + variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (manager->priv->session), "SessionIsActive"); if (variant) { is_session_active = g_variant_get_boolean (variant); @@ -2512,7 +2512,7 @@ idle_is_session_inhibited (GsdPowerManager *manager, if (manager->priv->session == NULL) return FALSE; - variant = g_dbus_proxy_get_cached_property (manager->priv->session, + variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (manager->priv->session), "InhibitedActions"); if (!variant) return FALSE; diff --git a/plugins/screensaver-proxy/gsd-screensaver-proxy-manager.c b/plugins/screensaver-proxy/gsd-screensaver-proxy-manager.c index d1e1ffc6..3532cb49 100644 --- a/plugins/screensaver-proxy/gsd-screensaver-proxy-manager.c +++ b/plugins/screensaver-proxy/gsd-screensaver-proxy-manager.c @@ -92,7 +92,7 @@ static const gchar introspection_xml[] = struct GsdScreensaverProxyManagerPrivate { - GDBusProxy *session; + GsdSessionManager *session; GDBusConnection *connection; GCancellable *bus_cancellable; GDBusNodeInfo *introspection_data; @@ -126,7 +126,7 @@ name_vanished_cb (GDBusConnection *connection, if (g_strcmp0 (sender, name) == 0) { guint cookie = GPOINTER_TO_UINT (cookie_ptr); - g_dbus_proxy_call_sync (manager->priv->session, + g_dbus_proxy_call_sync (G_DBUS_PROXY (manager->priv->session), "Uninhibit", g_variant_new ("(u)", cookie), G_DBUS_CALL_FLAGS_NONE, @@ -170,7 +170,7 @@ handle_method_call (GDBusConnection *connection, g_variant_get (parameters, "(ss)", &app_id, &reason); - ret = g_dbus_proxy_call_sync (manager->priv->session, + ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (G_DBUS_PROXY (manager->priv->session)), "Inhibit", g_variant_new ("(susu)", app_id, 0, reason, GSM_INHIBITOR_FLAG_IDLE), @@ -199,7 +199,7 @@ handle_method_call (GDBusConnection *connection, guint cookie; g_variant_get (parameters, "(u)", &cookie); - g_dbus_proxy_call_sync (manager->priv->session, + g_dbus_proxy_call_sync (G_DBUS_PROXY (manager->priv->session), "Uninhibit", parameters, G_DBUS_CALL_FLAGS_NONE, diff --git a/plugins/updates/gsd-updates-manager.c b/plugins/updates/gsd-updates-manager.c index dc60e120..32332239 100644 --- a/plugins/updates/gsd-updates-manager.c +++ b/plugins/updates/gsd-updates-manager.c @@ -61,7 +61,7 @@ struct GsdUpdatesManagerPrivate PkControl *control; PkTask *task; guint inhibit_cookie; - GDBusProxy *proxy_session; + GsdSessionManager *proxy_session; guint update_viewer_watcher_id; GVolumeMonitor *volume_monitor; guint failed_get_updates_count; @@ -972,7 +972,7 @@ session_inhibit (GsdUpdatesManager *manager) /* TRANSLATORS: the reason why we've inhibited it */ reason = _("A transaction that cannot be interrupted is running"); - retval = g_dbus_proxy_call_sync (manager->priv->proxy_session, + retval = g_dbus_proxy_call_sync (G_DBUS_PROXY (manager->priv->proxy_session), "Inhibit", g_variant_new ("(susu)", "gnome-settings-daemon", /* app-id */ @@ -1009,7 +1009,7 @@ session_uninhibit (GsdUpdatesManager *manager) g_warning ("not locked"); goto out; } - retval = g_dbus_proxy_call_sync (manager->priv->proxy_session, + retval = g_dbus_proxy_call_sync (G_DBUS_PROXY (manager->priv->proxy_session), "Uninhibit", g_variant_new ("(u)", manager->priv->inhibit_cookie), diff --git a/plugins/updates/gsd-updates-refresh.c b/plugins/updates/gsd-updates-refresh.c index ebd566f9..665543b7 100644 --- a/plugins/updates/gsd-updates-refresh.c +++ b/plugins/updates/gsd-updates-refresh.c @@ -64,7 +64,7 @@ struct GsdUpdatesRefreshPrivate guint periodic_id; UpClient *client; GSettings *settings; - GDBusProxy *proxy_session; + GsdSessionManager *proxy_session; PkControl *control; }; @@ -508,11 +508,11 @@ gsd_updates_refresh_init (GsdUpdatesRefresh *refresh) refresh->priv->proxy_session = gnome_settings_session_get_session_proxy (); if (refresh->priv->proxy_session != NULL) { - g_signal_connect (refresh->priv->proxy_session, + g_signal_connect (G_DBUS_PROXY (refresh->priv->proxy_session), "g-signal", G_CALLBACK (session_presence_signal_cb), refresh); - status = g_dbus_proxy_get_cached_property (refresh->priv->proxy_session, + status = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (refresh->priv->proxy_session), "status"); if (status) { g_variant_get (status, "u", &status_code); -- cgit v1.2.1