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 +++++++++++++++++++++ 5 files changed, 479 insertions(+), 14 deletions(-) create mode 100644 gnome-settings-daemon/org.gnome.SessionManager.xml (limited to 'gnome-settings-daemon') 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. + + + + + + -- cgit v1.2.1