summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2012-02-09 12:15:49 -0500
committerRyan Lortie <desrt@desrt.ca>2012-02-09 12:15:49 -0500
commit40e9192d7261ff9eec9e6ec4bd7029c08df80004 (patch)
treef7cf53b3fb8c8eec681a6b06aa1f1851eb7af5a3
parentdb38923c94bb764f14ac4b7bff6e71cf6aba343f (diff)
downloadglib-40e9192d7261ff9eec9e6ec4bd7029c08df80004.tar.gz
GApplication: put non-unique apps on D-Bus
For a number of reasons it might be useful to register the object paths associated with a non-unique application so that the application can at least field requests to its unique D-Bus name. https://bugzilla.gnome.org/show_bug.cgi?id=647986
-rw-r--r--gio/gapplication.c21
-rw-r--r--gio/gapplicationimpl-dbus.c22
2 files changed, 30 insertions, 13 deletions
diff --git a/gio/gapplication.c b/gio/gapplication.c
index 1aab950a3..0d523d33a 100644
--- a/gio/gapplication.c
+++ b/gio/gapplication.c
@@ -1179,18 +1179,15 @@ g_application_register (GApplication *application,
if (!application->priv->is_registered)
{
- if (~application->priv->flags & G_APPLICATION_NON_UNIQUE)
- {
- application->priv->impl =
- g_application_impl_register (application, application->priv->id,
- application->priv->flags,
- application->priv->actions,
- &application->priv->remote_actions,
- cancellable, error);
-
- if (application->priv->impl == NULL)
- return FALSE;
- }
+ application->priv->impl =
+ g_application_impl_register (application, application->priv->id,
+ application->priv->flags,
+ application->priv->actions,
+ &application->priv->remote_actions,
+ cancellable, error);
+
+ if (application->priv->impl == NULL)
+ return FALSE;
application->priv->is_remote = application->priv->remote_actions != NULL;
application->priv->is_registered = TRUE;
diff --git a/gio/gapplicationimpl-dbus.c b/gio/gapplicationimpl-dbus.c
index 2dfc153c4..5a512f844 100644
--- a/gio/gapplicationimpl-dbus.c
+++ b/gio/gapplicationimpl-dbus.c
@@ -218,6 +218,7 @@ application_path_from_appid (const gchar *appid)
*/
static gboolean
g_application_impl_attempt_primary (GApplicationImpl *impl,
+ gboolean non_unique,
GCancellable *cancellable,
GError **error)
{
@@ -267,6 +268,21 @@ g_application_impl_attempt_primary (GApplicationImpl *impl,
if (impl->actions_id == 0)
return FALSE;
+ if (non_unique)
+ {
+ /* If this is a non-unique application then it is sufficient to
+ * have our object paths registered. We can return now.
+ *
+ * Note: non-unique applications always act as primary-instance.
+ */
+ impl->primary = TRUE;
+ return TRUE;
+ }
+
+ /* If this is a unique application then we need to attempt to own
+ * the well-known name and fall back to remote mode (!is_primary)
+ * in the case that we can't do that.
+ */
/* DBUS_NAME_FLAG_DO_NOT_QUEUE: 0x4 */
reply = g_dbus_connection_call_sync (impl->session_bus, "org.freedesktop.DBus", "/org/freedesktop/DBus",
"org.freedesktop.DBus", "RequestName",
@@ -367,7 +383,11 @@ g_application_impl_register (GApplication *application,
*/
if (~flags & G_APPLICATION_IS_LAUNCHER)
{
- if (!g_application_impl_attempt_primary (impl, cancellable, error))
+ gboolean non_unique;
+
+ non_unique = (flags & G_APPLICATION_NON_UNIQUE) != 0;
+
+ if (!g_application_impl_attempt_primary (impl, non_unique, cancellable, error))
{
g_application_impl_destroy (impl);
return NULL;