gnome-session r4909 - in trunk: . gnome-session
- From: mccann svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-session r4909 - in trunk: . gnome-session
- Date: Mon, 4 Aug 2008 23:27:08 +0000 (UTC)
Author: mccann
Date: Mon Aug 4 23:27:08 2008
New Revision: 4909
URL: http://svn.gnome.org/viewvc/gnome-session?rev=4909&view=rev
Log:
2008-08-04 William Jon McCann <jmccann redhat com>
* gnome-session/Makefile.am:
* gnome-session/gsm-app.c (gsm_app_error_quark),
(get_next_app_serial), (register_app), (gsm_app_constructor),
(gsm_app_class_init), (gsm_app_peek_id), (gsm_app_peek_app_id),
(gsm_app_peek_startup_id), (gsm_app_peek_phase),
(gsm_app_peek_is_disabled), (gsm_app_peek_autorestart),
(gsm_app_get_app_id), (gsm_app_get_startup_id),
(gsm_app_get_phase):
* gnome-session/gsm-app.h:
* gnome-session/gsm-autostart-app.c (is_disabled),
(autostart_app_start_spawn), (autostart_app_start_activate),
(gsm_autostart_app_get_app_id), (gsm_autostart_app_constructor),
(gsm_autostart_app_class_init):
* gnome-session/gsm-manager.c (app_condition_changed),
(on_phase_timeout), (_start_app), (_disconnect_client),
(_app_has_startup_id), (find_app_for_startup_id),
(on_xsmp_client_register_request), (append_app),
(gsm_manager_register_client), (_app_has_autostart_condition):
* gnome-session/gsm-resumed-app.c (gsm_resumed_app_get_app_id),
(gsm_resumed_app_class_init):
* gnome-session/org.gnome.SessionManager.App.xml:
Put the apps on the bus.
Added:
trunk/gnome-session/org.gnome.SessionManager.App.xml
Modified:
trunk/ChangeLog
trunk/gnome-session/Makefile.am
trunk/gnome-session/gsm-app.c
trunk/gnome-session/gsm-app.h
trunk/gnome-session/gsm-autostart-app.c
trunk/gnome-session/gsm-manager.c
trunk/gnome-session/gsm-resumed-app.c
Modified: trunk/gnome-session/Makefile.am
==============================================================================
--- trunk/gnome-session/Makefile.am (original)
+++ trunk/gnome-session/Makefile.am Mon Aug 4 23:27:08 2008
@@ -108,6 +108,9 @@
gsm-client-glue.h: org.gnome.SessionManager.Client.xml Makefile.am
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
+ 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
dbus-binding-tool --prefix=gsm_inhibitor --mode=glib-server --output=gsm-inhibitor-glue.h $(srcdir)/org.gnome.SessionManager.Inhibitor.xml
@@ -117,6 +120,7 @@
gsm-manager-glue.h \
gsm-inhibitor-glue.h \
gsm-client-glue.h \
+ gsm-app-glue.h \
$(NULL)
CLEANFILES = \
@@ -127,6 +131,7 @@
README \
gsm-marshal.list \
org.gnome.SessionManager.xml \
+ org.gnome.SessionManager.App.xml \
org.gnome.SessionManager.Client.xml \
org.gnome.SessionManager.ClientPrivate.xml \
org.gnome.SessionManager.Inhibitor.xml \
Modified: trunk/gnome-session/gsm-app.c
==============================================================================
--- trunk/gnome-session/gsm-app.c (original)
+++ trunk/gnome-session/gsm-app.c Mon Aug 4 23:27:08 2008
@@ -27,14 +27,17 @@
#include <string.h>
#include "gsm-app.h"
+#include "gsm-app-glue.h"
#define GSM_APP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_APP, GsmAppPrivate))
struct _GsmAppPrivate
{
- char *id;
- int phase;
- char *startup_id;
+ char *id;
+ char *app_id;
+ int phase;
+ char *startup_id;
+ DBusGConnection *connection;
};
@@ -45,6 +48,8 @@
LAST_SIGNAL
};
+static guint32 app_serial = 1;
+
static guint signals[LAST_SIGNAL] = { 0 };
enum {
@@ -66,6 +71,64 @@
}
return ret;
+
+}
+
+static guint32
+get_next_app_serial (void)
+{
+ guint32 serial;
+
+ serial = app_serial++;
+
+ if ((gint32)app_serial < 0) {
+ app_serial = 1;
+ }
+
+ return serial;
+}
+
+static gboolean
+register_app (GsmApp *app)
+{
+ GError *error;
+
+ error = NULL;
+ app->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ if (app->priv->connection == NULL) {
+ if (error != NULL) {
+ g_critical ("error getting session bus: %s", error->message);
+ g_error_free (error);
+ }
+ return FALSE;
+ }
+
+ dbus_g_connection_register_g_object (app->priv->connection, app->priv->id, G_OBJECT (app));
+
+ return TRUE;
+}
+
+static GObject *
+gsm_app_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
+{
+ GsmApp *app;
+ gboolean res;
+
+ app = GSM_APP (G_OBJECT_CLASS (gsm_app_parent_class)->constructor (type,
+ n_construct_properties,
+ construct_properties));
+
+ g_free (app->priv->id);
+ app->priv->id = g_strdup_printf ("/org/gnome/SessionManager/App%u", get_next_app_serial ());
+
+ res = register_app (app);
+ if (! res) {
+ g_warning ("Unable to register app with session bus");
+ }
+
+ return G_OBJECT (app);
}
static void
@@ -174,9 +237,10 @@
object_class->set_property = gsm_app_set_property;
object_class->get_property = gsm_app_get_property;
object_class->dispose = gsm_app_dispose;
+ object_class->constructor = gsm_app_constructor;
- klass->impl_get_id = NULL;
klass->impl_start = NULL;
+ klass->impl_get_app_id = NULL;
klass->impl_get_autorestart = NULL;
klass->impl_provides = NULL;
klass->impl_is_running = NULL;
@@ -235,22 +299,29 @@
0);
g_type_class_add_private (klass, sizeof (GsmAppPrivate));
+ dbus_g_object_type_install_info (GSM_TYPE_APP, &dbus_glib_gsm_app_object_info);
}
const char *
-gsm_app_get_id (GsmApp *app)
+gsm_app_peek_id (GsmApp *app)
{
- return GSM_APP_GET_CLASS (app)->impl_get_id (app);
+ return app->priv->id;
}
const char *
-gsm_app_get_startup_id (GsmApp *app)
+gsm_app_peek_app_id (GsmApp *app)
+{
+ return GSM_APP_GET_CLASS (app)->impl_get_app_id (app);
+}
+
+const char *
+gsm_app_peek_startup_id (GsmApp *app)
{
return app->priv->startup_id;
}
/**
- * gsm_app_get_phase:
+ * gsm_app_peek_phase:
* @app: a %GsmApp
*
* Returns @app's startup phase.
@@ -258,7 +329,7 @@
* Return value: @app's startup phase
**/
GsmManagerPhase
-gsm_app_get_phase (GsmApp *app)
+gsm_app_peek_phase (GsmApp *app)
{
g_return_val_if_fail (GSM_IS_APP (app), GSM_MANAGER_PHASE_APPLICATION);
@@ -266,7 +337,7 @@
}
gboolean
-gsm_app_is_disabled (GsmApp *app)
+gsm_app_peek_is_disabled (GsmApp *app)
{
g_return_val_if_fail (GSM_IS_APP (app), FALSE);
@@ -290,7 +361,7 @@
}
gboolean
-gsm_app_get_autorestart (GsmApp *app)
+gsm_app_peek_autorestart (GsmApp *app)
{
g_return_val_if_fail (GSM_IS_APP (app), FALSE);
@@ -372,3 +443,33 @@
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)
+{
+ g_return_val_if_fail (GSM_IS_APP (app), FALSE);
+ *id = g_strdup (app->priv->startup_id);
+ return TRUE;
+}
+
+gboolean
+gsm_app_get_phase (GsmApp *app,
+ guint *phase,
+ GError **error)
+{
+ g_return_val_if_fail (GSM_IS_APP (app), FALSE);
+ *phase = app->priv->phase;
+ return TRUE;
+}
Modified: trunk/gnome-session/gsm-app.h
==============================================================================
--- trunk/gnome-session/gsm-app.h (original)
+++ trunk/gnome-session/gsm-app.h Mon Aug 4 23:27:08 2008
@@ -72,7 +72,7 @@
gboolean (*impl_is_running) (GsmApp *app);
gboolean (*impl_get_autorestart) (GsmApp *app);
- const char *(*impl_get_id) (GsmApp *app);
+ const char *(*impl_get_app_id) (GsmApp *app);
gboolean (*impl_is_disabled) (GsmApp *app);
void (*impl_set_client) (GsmApp *app,
GsmClient *client);
@@ -90,17 +90,20 @@
GQuark gsm_app_error_quark (void);
GType gsm_app_get_type (void) G_GNUC_CONST;
+gboolean gsm_app_peek_autorestart (GsmApp *app);
+
+const char *gsm_app_peek_id (GsmApp *app);
+const char *gsm_app_peek_app_id (GsmApp *app);
+const char *gsm_app_peek_startup_id (GsmApp *app);
+GsmManagerPhase gsm_app_peek_phase (GsmApp *app);
+gboolean gsm_app_peek_is_disabled (GsmApp *app);
+
gboolean gsm_app_start (GsmApp *app,
GError **error);
gboolean gsm_app_restart (GsmApp *app,
GError **error);
gboolean gsm_app_stop (GsmApp *app,
GError **error);
-gboolean gsm_app_get_autorestart (GsmApp *app);
-
-const char *gsm_app_get_id (GsmApp *app);
-const char *gsm_app_get_startup_id (GsmApp *app);
-GsmManagerPhase gsm_app_get_phase (GsmApp *app);
gboolean gsm_app_is_running (GsmApp *app);
void gsm_app_exited (GsmApp *app);
@@ -110,9 +113,19 @@
const char *service);
gboolean gsm_app_has_autostart_condition (GsmApp *app,
const char *condition);
-gboolean gsm_app_is_disabled (GsmApp *app);
void gsm_app_registered (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__ */
Modified: trunk/gnome-session/gsm-autostart-app.c
==============================================================================
--- trunk/gnome-session/gsm-autostart-app.c (original)
+++ trunk/gnome-session/gsm-autostart-app.c Mon Aug 4 23:27:08 2008
@@ -395,7 +395,7 @@
!egg_desktop_file_get_boolean (priv->desktop_file,
"X-GNOME-Autostart-enabled", NULL)) {
g_debug ("app %s is disabled by X-GNOME-Autostart-enabled",
- gsm_app_get_id (app));
+ gsm_app_peek_id (app));
return TRUE;
}
@@ -403,14 +403,14 @@
if (egg_desktop_file_get_boolean (priv->desktop_file,
EGG_DESKTOP_FILE_KEY_HIDDEN, NULL)) {
g_debug ("app %s is disabled by Hidden",
- gsm_app_get_id (app));
+ gsm_app_peek_id (app));
return TRUE;
}
/* Check OnlyShowIn/NotShowIn/TryExec */
if (!egg_desktop_file_can_launch (priv->desktop_file, "GNOME")) {
g_debug ("app %s not installed or not for GNOME",
- gsm_app_get_id (app));
+ gsm_app_peek_id (app));
return TRUE;
}
@@ -509,7 +509,7 @@
if (disabled) {
g_debug ("app %s is disabled by AutostartCondition",
- gsm_app_get_id (app));
+ gsm_app_peek_id (app));
return TRUE;
}
}
@@ -593,7 +593,7 @@
GError *local_error;
const char *startup_id;
- startup_id = gsm_app_get_startup_id (GSM_APP (app));
+ startup_id = gsm_app_peek_startup_id (GSM_APP (app));
g_assert (startup_id != NULL);
env[0] = g_strdup_printf ("DESKTOP_AUTOSTART_ID=%s", startup_id);
@@ -669,7 +669,7 @@
return FALSE;
}
- name = gsm_app_get_startup_id (GSM_APP (app));
+ name = gsm_app_peek_startup_id (GSM_APP (app));
g_assert (name != NULL);
path = egg_desktop_file_get_string (app->priv->desktop_file,
@@ -847,7 +847,7 @@
}
static const char *
-gsm_autostart_app_get_id (GsmApp *app)
+gsm_autostart_app_get_app_id (GsmApp *app)
{
const char *location;
const char *slash;
@@ -872,16 +872,11 @@
GObjectConstructParam *construct_properties)
{
GsmAutostartApp *app;
- const char *id;
app = GSM_AUTOSTART_APP (G_OBJECT_CLASS (gsm_autostart_app_parent_class)->constructor (type,
n_construct_properties,
construct_properties));
- id = gsm_autostart_app_get_id (GSM_APP (app));
-
- g_object_set (app, "id", id, NULL);
-
if (! load_desktop_file (app)) {
g_object_unref (app);
app = NULL;
@@ -908,7 +903,7 @@
app_class->impl_stop = gsm_autostart_app_stop;
app_class->impl_provides = gsm_autostart_app_provides;
app_class->impl_has_autostart_condition = gsm_autostart_app_has_autostart_condition;
- app_class->impl_get_id = gsm_autostart_app_get_id;
+ app_class->impl_get_app_id = gsm_autostart_app_get_app_id;
app_class->impl_get_autorestart = gsm_autostart_app_get_autorestart;
g_object_class_install_property (object_class,
Modified: trunk/gnome-session/gsm-manager.c
==============================================================================
--- trunk/gnome-session/gsm-manager.c (original)
+++ trunk/gnome-session/gsm-manager.c Mon Aug 4 23:27:08 2008
@@ -237,7 +237,7 @@
client = (GsmClient *)gsm_store_find (manager->priv->clients,
(GsmStoreFunc)_find_by_startup_id,
- (char *)gsm_app_get_startup_id (app));
+ (char *)gsm_app_peek_startup_id (app));
if (condition) {
if (!gsm_app_is_running (app) && client == NULL) {
@@ -371,7 +371,7 @@
case GSM_MANAGER_PHASE_APPLICATION:
for (a = manager->priv->pending_apps; a; a = a->next) {
g_warning ("Application '%s' failed to register before timeout",
- gsm_app_get_id (a->data));
+ gsm_app_peek_app_id (a->data));
g_signal_handlers_disconnect_by_func (a->data, app_registered, manager);
/* FIXME: what if the app was filling in a required slot? */
}
@@ -413,7 +413,7 @@
GError *error;
gboolean res;
- if (gsm_app_get_phase (app) != manager->priv->phase) {
+ if (gsm_app_peek_phase (app) != manager->priv->phase) {
goto out;
}
@@ -424,7 +424,7 @@
G_CALLBACK (app_condition_changed),
manager);
- if (gsm_app_is_disabled (app)) {
+ if (gsm_app_peek_is_disabled (app)) {
g_debug ("GsmManager: Skipping disabled app: %s", id);
goto out;
}
@@ -434,7 +434,7 @@
if (!res) {
if (error != NULL) {
g_warning ("Could not launch application '%s': %s",
- gsm_app_get_id (app),
+ gsm_app_peek_app_id (app),
error->message);
g_error_free (error);
error = NULL;
@@ -1025,7 +1025,7 @@
goto out;
}
- app_restart = gsm_app_get_autorestart (app);
+ app_restart = gsm_app_peek_autorestart (app);
client_restart_hint = gsm_client_peek_restart_style_hint (client);
/* allow legacy clients to override the app info */
@@ -1151,7 +1151,7 @@
{
const char *startup_id_b;
- startup_id_b = gsm_app_get_startup_id (app);
+ startup_id_b = gsm_app_peek_startup_id (app);
if (IS_STRING_EMPTY (startup_id_b)) {
return FALSE;
@@ -1176,7 +1176,7 @@
for (a = manager->priv->pending_apps; a != NULL; a = a->next) {
GsmApp *app = GSM_APP (a->data);
- if (strcmp (startup_id, gsm_app_get_startup_id (app)) == 0) {
+ if (strcmp (startup_id, gsm_app_peek_startup_id (app)) == 0) {
found_app = app;
goto out;
}
@@ -1338,7 +1338,7 @@
app = find_app_for_startup_id (manager, new_id);
if (app != NULL) {
- gsm_client_set_app_id (GSM_CLIENT (client), gsm_app_get_id (app));
+ gsm_client_set_app_id (GSM_CLIENT (client), gsm_app_peek_app_id (app));
gsm_app_registered (app);
goto out;
}
@@ -1569,7 +1569,7 @@
const char *id;
GsmApp *dup;
- id = gsm_app_get_id (app);
+ id = gsm_app_peek_id (app);
if (IS_STRING_EMPTY (id)) {
g_debug ("GsmManager: not adding app: no ID");
return;
@@ -2551,7 +2551,7 @@
g_object_unref (client);
if (app != NULL) {
- gsm_client_set_app_id (client, gsm_app_get_id (app));
+ gsm_client_set_app_id (client, gsm_app_peek_app_id (app));
gsm_app_registered (app);
} else {
/* if an app id is specified store it in the client
@@ -2795,7 +2795,7 @@
gboolean disabled;
has = gsm_app_has_autostart_condition (app, condition);
- disabled = gsm_app_is_disabled (app);
+ disabled = gsm_app_peek_is_disabled (app);
return has && !disabled;
}
Modified: trunk/gnome-session/gsm-resumed-app.c
==============================================================================
--- trunk/gnome-session/gsm-resumed-app.c (original)
+++ trunk/gnome-session/gsm-resumed-app.c Mon Aug 4 23:27:08 2008
@@ -153,7 +153,7 @@
}
static const char *
-gsm_resumed_app_get_id (GsmApp *app)
+gsm_resumed_app_get_app_id (GsmApp *app)
{
return GSM_RESUMED_APP (app)->priv->program;
}
@@ -186,7 +186,7 @@
object_class->dispose = gsm_resumed_app_dispose;
- app_class->impl_get_id = gsm_resumed_app_get_id;
+ app_class->impl_get_app_id = gsm_resumed_app_get_app_id;
app_class->impl_start = gsm_resumed_app_start;
app_class->impl_restart = gsm_resumed_app_restart;
Added: trunk/gnome-session/org.gnome.SessionManager.App.xml
==============================================================================
--- (empty file)
+++ trunk/gnome-session/org.gnome.SessionManager.App.xml Mon Aug 4 23:27:08 2008
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
+ <interface name="org.gnome.SessionManager.App">
+ <method name="GetAppId">
+ <arg type="s" name="app_id" direction="out">
+ <doc:doc>
+ <doc:summary>The identifier for the application</doc:summary>
+ </doc:doc>
+ </arg>
+ <doc:doc>
+ <doc:description>
+ <doc:para>Return the application ID.</doc:para>
+ </doc:description>
+ </doc:doc>
+ </method>
+ <method name="GetStartupId">
+ <arg type="s" name="startup_id" direction="out">
+ <doc:doc>
+ <doc:summary>The startup identifier</doc:summary>
+ </doc:doc>
+ </arg>
+ <doc:doc>
+ <doc:description>
+ <doc:para>Return the startup ID associated with this application.</doc:para>
+ </doc:description>
+ </doc:doc>
+ </method>
+ <method name="GetPhase">
+ <arg type="u" name="phase" direction="out">
+ <doc:doc>
+ <doc:summary>The application startup phase</doc:summary>
+ </doc:doc>
+ </arg>
+ <doc:doc>
+ <doc:description>
+ <doc:para>Return the startup phase of this application.</doc:para>
+ </doc:description>
+ </doc:doc>
+ </method>
+
+ </interface>
+</node>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]