gnome-session r4908 - in trunk: . gnome-session
- From: mccann svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-session r4908 - in trunk: . gnome-session
- Date: Mon, 4 Aug 2008 22:33:59 +0000 (UTC)
Author: mccann
Date: Mon Aug 4 22:33:58 2008
New Revision: 4908
URL: http://svn.gnome.org/viewvc/gnome-session?rev=4908&view=rev
Log:
2008-08-04 William Jon McCann <jmccann redhat com>
* gnome-session/gsm-app.c (gsm_app_has_autostart_condition):
* gnome-session/gsm-app.h:
* gnome-session/gsm-autostart-app.c (gsm_autostart_app_dispose),
(is_disabled), (gsm_autostart_app_has_autostart_condition),
(gsm_autostart_app_class_init):
* gnome-session/gsm-manager.c (_start_app), (do_phase_startup),
(find_app_for_app_id), (find_app_for_startup_id), (append_app),
(append_required_apps), (gsm_manager_init), (gsm_manager_finalize),
(_app_has_autostart_condition),
(gsm_manager_is_autostart_condition_handled):
* gnome-session/gsm-manager.h:
* gnome-session/org.gnome.SessionManager.xml:
Add a method to ask if a certain AutostartCondition is
being handled. One use of this is for the settings daemon
to know if there are any a11y tools that will be started
for a certain gconf key.
Modified:
trunk/ChangeLog
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-manager.h
trunk/gnome-session/org.gnome.SessionManager.xml
Modified: trunk/gnome-session/gsm-app.c
==============================================================================
--- trunk/gnome-session/gsm-app.c (original)
+++ trunk/gnome-session/gsm-app.c Mon Aug 4 22:33:58 2008
@@ -313,6 +313,18 @@
}
gboolean
+gsm_app_has_autostart_condition (GsmApp *app,
+ const char *condition)
+{
+
+ if (GSM_APP_GET_CLASS (app)->impl_has_autostart_condition) {
+ return GSM_APP_GET_CLASS (app)->impl_has_autostart_condition (app, condition);
+ } else {
+ return FALSE;
+ }
+}
+
+gboolean
gsm_app_start (GsmApp *app,
GError **error)
{
Modified: trunk/gnome-session/gsm-app.h
==============================================================================
--- trunk/gnome-session/gsm-app.h (original)
+++ trunk/gnome-session/gsm-app.h Mon Aug 4 22:33:58 2008
@@ -59,21 +59,23 @@
void (*registered) (GsmApp *app);
/* virtual methods */
- gboolean (*impl_start) (GsmApp *app,
- GError **error);
- gboolean (*impl_restart) (GsmApp *app,
- GError **error);
- gboolean (*impl_stop) (GsmApp *app,
- GError **error);
- gboolean (*impl_provides) (GsmApp *app,
- const char *service);
- gboolean (*impl_is_running) (GsmApp *app);
-
- gboolean (*impl_get_autorestart) (GsmApp *app);
- const char *(*impl_get_id) (GsmApp *app);
- gboolean (*impl_is_disabled) (GsmApp *app);
- void (*impl_set_client) (GsmApp *app,
- GsmClient *client);
+ gboolean (*impl_start) (GsmApp *app,
+ GError **error);
+ gboolean (*impl_restart) (GsmApp *app,
+ GError **error);
+ gboolean (*impl_stop) (GsmApp *app,
+ GError **error);
+ gboolean (*impl_provides) (GsmApp *app,
+ const char *service);
+ gboolean (*impl_has_autostart_condition) (GsmApp *app,
+ const char *service);
+ gboolean (*impl_is_running) (GsmApp *app);
+
+ gboolean (*impl_get_autorestart) (GsmApp *app);
+ const char *(*impl_get_id) (GsmApp *app);
+ gboolean (*impl_is_disabled) (GsmApp *app);
+ void (*impl_set_client) (GsmApp *app,
+ GsmClient *client);
};
typedef enum
@@ -85,29 +87,31 @@
#define GSM_APP_ERROR gsm_app_error_quark ()
-GQuark gsm_app_error_quark (void);
-GType gsm_app_get_type (void) G_GNUC_CONST;
+GQuark gsm_app_error_quark (void);
+GType gsm_app_get_type (void) G_GNUC_CONST;
-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);
-void gsm_app_died (GsmApp *app);
-
-gboolean gsm_app_provides (GsmApp *app,
- const char *service);
-gboolean gsm_app_is_disabled (GsmApp *app);
-void gsm_app_registered (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);
+void gsm_app_died (GsmApp *app);
+
+gboolean gsm_app_provides (GsmApp *app,
+ 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);
G_END_DECLS
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 22:33:58 2008
@@ -45,6 +45,7 @@
char *desktop_filename;
char *desktop_id;
char *startup_id;
+ char *condition_string;
GFileMonitor *monitor;
gboolean condition;
@@ -235,6 +236,11 @@
priv->startup_id = NULL;
}
+ if (priv->condition_string) {
+ g_free (priv->condition_string);
+ priv->condition_string = NULL;
+ }
+
if (priv->desktop_file) {
egg_desktop_file_free (priv->desktop_file);
priv->desktop_file = NULL;
@@ -372,7 +378,6 @@
is_disabled (GsmApp *app)
{
GsmAutostartAppPrivate *priv;
- char *condition;
gboolean autorestart = FALSE;
priv = GSM_AUTOSTART_APP (app)->priv;
@@ -410,23 +415,25 @@
}
/* Check AutostartCondition */
- condition = egg_desktop_file_get_string (priv->desktop_file,
- "AutostartCondition",
- NULL);
+ g_free (priv->condition_string);
+ priv->condition_string = egg_desktop_file_get_string (priv->desktop_file,
+ "AutostartCondition",
+ NULL);
- if (condition) {
+ if (priv->condition_string != NULL) {
gboolean disabled;
- char *space, *key;
- int len;
+ char *space;
+ char *key;
+ int len;
- space = condition + strcspn (condition, " ");
- len = space - condition;
+ space = priv->condition_string + strcspn (priv->condition_string, " ");
+ len = space - priv->condition_string;
key = space;
while (isspace ((unsigned char)*key)) {
key++;
}
- if (!g_ascii_strncasecmp (condition, "if-exists", len) && key) {
+ if (!g_ascii_strncasecmp (priv->condition_string, "if-exists", len) && key) {
char *file_path = g_build_filename (g_get_user_config_dir (), key, NULL);
disabled = !g_file_test (file_path, G_FILE_TEST_EXISTS);
@@ -444,7 +451,7 @@
}
g_free (file_path);
- } else if (!g_ascii_strncasecmp (condition, "unless-exists", len) && key) {
+ } else if (!g_ascii_strncasecmp (priv->condition_string, "unless-exists", len) && key) {
char *file_path = g_build_filename (g_get_user_config_dir (), key, NULL);
disabled = g_file_test (file_path, G_FILE_TEST_EXISTS);
@@ -462,7 +469,7 @@
}
g_free (file_path);
- } else if (!g_ascii_strncasecmp (condition, "GNOME", len)) {
+ } else if (!g_ascii_strncasecmp (priv->condition_string, "GNOME", len)) {
if (key) {
GConfClient *client;
@@ -497,8 +504,6 @@
disabled = TRUE;
}
- g_free (condition);
-
/* Set initial condition */
priv->condition = !disabled;
@@ -796,6 +801,28 @@
}
static gboolean
+gsm_autostart_app_has_autostart_condition (GsmApp *app,
+ const char *condition)
+{
+ GsmAutostartApp *aapp;
+
+ g_return_val_if_fail (GSM_IS_APP (app), FALSE);
+ g_return_val_if_fail (condition != NULL, FALSE);
+
+ aapp = GSM_AUTOSTART_APP (app);
+
+ if (aapp->priv->condition_string == NULL) {
+ return FALSE;
+ }
+
+ if (strcmp (aapp->priv->condition_string, condition) == 0) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gboolean
gsm_autostart_app_get_autorestart (GsmApp *app)
{
gboolean res;
@@ -880,6 +907,7 @@
app_class->impl_restart = gsm_autostart_app_restart;
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_autorestart = gsm_autostart_app_get_autorestart;
Modified: trunk/gnome-session/gsm-manager.c
==============================================================================
--- trunk/gnome-session/gsm-manager.c (original)
+++ trunk/gnome-session/gsm-manager.c Mon Aug 4 22:33:58 2008
@@ -80,9 +80,7 @@
gboolean failsafe;
GsmStore *clients;
GsmStore *inhibitors;
-
- /* Startup/resumed apps */
- GHashTable *apps_by_id;
+ GsmStore *apps;
/* Current status */
GsmManagerPhase phase;
@@ -407,7 +405,7 @@
}
}
-static void
+static gboolean
_start_app (const char *id,
GsmApp *app,
GsmManager *manager)
@@ -416,7 +414,7 @@
gboolean res;
if (gsm_app_get_phase (app) != manager->priv->phase) {
- return;
+ goto out;
}
/* Keep track of app autostart condition in order to react
@@ -428,7 +426,7 @@
if (gsm_app_is_disabled (app)) {
g_debug ("GsmManager: Skipping disabled app: %s", id);
- return;
+ goto out;
}
error = NULL;
@@ -441,7 +439,7 @@
g_error_free (error);
error = NULL;
}
- return;
+ goto out;
}
g_signal_connect (app,
@@ -456,14 +454,16 @@
manager);
manager->priv->pending_apps = g_slist_prepend (manager->priv->pending_apps, app);
}
+ out:
+ return FALSE;
}
static void
do_phase_startup (GsmManager *manager)
{
- g_hash_table_foreach (manager->priv->apps_by_id,
- (GHFunc)_start_app,
- manager);
+ gsm_store_foreach (manager->priv->apps,
+ (GsmStoreFunc)_start_app,
+ manager);
if (manager->priv->pending_apps != NULL) {
if (manager->priv->phase < GSM_MANAGER_PHASE_APPLICATION) {
@@ -977,7 +977,7 @@
const char *app_id)
{
GsmApp *app;
- app = g_hash_table_lookup (manager->priv->apps_by_id, app_id);
+ app = (GsmApp *)gsm_store_lookup (manager->priv->apps, app_id);
return app;
}
@@ -1184,9 +1184,9 @@
} else {
GsmApp *app;
- app = g_hash_table_find (manager->priv->apps_by_id,
- (GHRFunc)_app_has_startup_id,
- (char *)startup_id);
+ app = (GsmApp *)gsm_store_find (manager->priv->apps,
+ (GsmStoreFunc)_app_has_startup_id,
+ (char *)startup_id);
if (app != NULL) {
found_app = app;
goto out;
@@ -1575,13 +1575,13 @@
return;
}
- dup = g_hash_table_lookup (manager->priv->apps_by_id, id);
+ dup = (GsmApp *)gsm_store_lookup (manager->priv->apps, id);
if (dup != NULL) {
g_debug ("GsmManager: not adding app: already added");
return;
}
- g_hash_table_insert (manager->priv->apps_by_id, g_strdup (id), g_object_ref (app));
+ gsm_store_add (manager->priv->apps, id, G_OBJECT (app));
}
static void
@@ -1811,9 +1811,9 @@
continue;
}
- app = g_hash_table_find (manager->priv->apps_by_id,
- (GHRFunc)_find_app_provides,
- (char *)service);
+ app = (GsmApp *)gsm_store_find (manager->priv->apps,
+ (GsmStoreFunc)_find_app_provides,
+ (char *)service);
if (app == NULL) {
app = gsm_autostart_app_new (default_provider);
if (app != NULL) {
@@ -1999,11 +1999,6 @@
manager->priv = GSM_MANAGER_GET_PRIVATE (manager);
- manager->priv->apps_by_id = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- g_object_unref);
-
manager->priv->inhibitors = gsm_store_new ();
g_signal_connect (manager->priv->inhibitors,
"added",
@@ -2013,6 +2008,8 @@
"removed",
G_CALLBACK (on_store_inhibitor_removed),
manager);
+
+ manager->priv->apps = gsm_store_new ();
}
static void
@@ -2031,8 +2028,8 @@
g_object_unref (manager->priv->clients);
}
- if (manager->priv->apps_by_id != NULL) {
- g_hash_table_destroy (manager->priv->apps_by_id);
+ if (manager->priv->apps != NULL) {
+ g_object_unref (manager->priv->apps);
}
if (manager->priv->inhibitors != NULL) {
@@ -2787,3 +2784,38 @@
return TRUE;
}
+
+
+static gboolean
+_app_has_autostart_condition (const char *id,
+ GsmApp *app,
+ const char *condition)
+{
+ gboolean has;
+ gboolean disabled;
+
+ has = gsm_app_has_autostart_condition (app, condition);
+ disabled = gsm_app_is_disabled (app);
+
+ return has && !disabled;
+}
+
+gboolean
+gsm_manager_is_autostart_condition_handled (GsmManager *manager,
+ const char *condition,
+ gboolean *handled,
+ GError **error)
+{
+ GsmApp *app;
+
+ g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
+
+ app = (GsmApp *)gsm_store_find (manager->priv->apps, (GsmStoreFunc)_app_has_autostart_condition, (char *)condition);
+ if (app != NULL) {
+ *handled = TRUE;
+ } else {
+ *handled = FALSE;
+ }
+
+ return TRUE;
+}
Modified: trunk/gnome-session/gsm-manager.h
==============================================================================
--- trunk/gnome-session/gsm-manager.h (original)
+++ trunk/gnome-session/gsm-manager.h Mon Aug 4 22:33:58 2008
@@ -104,63 +104,67 @@
GSM_MANAGER_LOGOUT_MODE_FORCE
} GsmManagerLogoutMode;
-GType gsm_manager_error_get_type (void);
+GType gsm_manager_error_get_type (void);
#define GSM_MANAGER_TYPE_ERROR (gsm_manager_error_get_type ())
-GQuark gsm_manager_error_quark (void);
-GType gsm_manager_get_type (void);
+GQuark gsm_manager_error_quark (void);
+GType gsm_manager_get_type (void);
-GsmManager * gsm_manager_new (GsmStore *client_store,
- gboolean failsafe);
+GsmManager * gsm_manager_new (GsmStore *client_store,
+ gboolean failsafe);
-void gsm_manager_start (GsmManager *manager);
+void gsm_manager_start (GsmManager *manager);
/* exported methods */
-gboolean gsm_manager_register_client (GsmManager *manager,
- const char *app_id,
- const char *client_startup_id,
- DBusGMethodInvocation *context);
-gboolean gsm_manager_unregister_client (GsmManager *manager,
- const char *session_client_id,
- DBusGMethodInvocation *context);
-
-gboolean gsm_manager_inhibit (GsmManager *manager,
- const char *app_id,
- guint toplevel_xid,
- const char *reason,
- guint flags,
- DBusGMethodInvocation *context);
-gboolean gsm_manager_uninhibit (GsmManager *manager,
- guint inhibit_cookie,
- DBusGMethodInvocation *context);
-gboolean gsm_manager_is_inhibited (GsmManager *manager,
- guint flags,
- gboolean *is_inhibited,
- GError *error);
-
-gboolean gsm_manager_shutdown (GsmManager *manager,
- GError **error);
-gboolean gsm_manager_logout (GsmManager *manager,
- int logout_mode,
- GError **error);
-
-gboolean gsm_manager_setenv (GsmManager *manager,
- const char *variable,
- const char *value,
- GError **error);
-gboolean gsm_manager_initialization_error (GsmManager *manager,
- const char *message,
- gboolean fatal,
- GError **error);
-
-gboolean gsm_manager_get_clients (GsmManager *manager,
- GPtrArray **clients,
- GError **error);
-gboolean gsm_manager_get_inhibitors (GsmManager *manager,
- GPtrArray **inhibitors,
- GError **error);
+gboolean gsm_manager_register_client (GsmManager *manager,
+ const char *app_id,
+ const char *client_startup_id,
+ DBusGMethodInvocation *context);
+gboolean gsm_manager_unregister_client (GsmManager *manager,
+ const char *session_client_id,
+ DBusGMethodInvocation *context);
+
+gboolean gsm_manager_inhibit (GsmManager *manager,
+ const char *app_id,
+ guint toplevel_xid,
+ const char *reason,
+ guint flags,
+ DBusGMethodInvocation *context);
+gboolean gsm_manager_uninhibit (GsmManager *manager,
+ guint inhibit_cookie,
+ DBusGMethodInvocation *context);
+gboolean gsm_manager_is_inhibited (GsmManager *manager,
+ guint flags,
+ gboolean *is_inhibited,
+ GError *error);
+
+gboolean gsm_manager_shutdown (GsmManager *manager,
+ GError **error);
+gboolean gsm_manager_logout (GsmManager *manager,
+ int logout_mode,
+ GError **error);
+
+gboolean gsm_manager_setenv (GsmManager *manager,
+ const char *variable,
+ const char *value,
+ GError **error);
+gboolean gsm_manager_initialization_error (GsmManager *manager,
+ const char *message,
+ gboolean fatal,
+ GError **error);
+
+gboolean gsm_manager_get_clients (GsmManager *manager,
+ GPtrArray **clients,
+ GError **error);
+gboolean gsm_manager_get_inhibitors (GsmManager *manager,
+ GPtrArray **inhibitors,
+ GError **error);
+gboolean gsm_manager_is_autostart_condition_handled (GsmManager *manager,
+ const char *condition,
+ gboolean *handled,
+ GError **error);
G_END_DECLS
Modified: trunk/gnome-session/org.gnome.SessionManager.xml
==============================================================================
--- trunk/gnome-session/org.gnome.SessionManager.xml (original)
+++ trunk/gnome-session/org.gnome.SessionManager.xml Mon Aug 4 22:33:58 2008
@@ -224,6 +224,26 @@
</doc:doc>
</method>
+
+ <method name="IsAutostartConditionHandled">
+ <arg name="condition" direction="in" type="s">
+ <doc:doc>
+ <doc:summary>The autostart condition string</doc:summary>
+ </doc:doc>
+ </arg>
+ <arg name="handled" direction="out" type="b">
+ <doc:doc>
+ <doc:summary>True if condition is handled, false otherwise</doc:summary>
+ </doc:doc>
+ </arg>
+ <doc:doc>
+ <doc:description>
+ <doc:para>Allows the caller to determine whether the session manager is
+ handling changes to the specified autostart condition.</doc:para>
+ </doc:description>
+ </doc:doc>
+ </method>
+
<method name="Shutdown">
<doc:doc>
<doc:description>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]