[gnome-session] gsm: Add gsm_app_provides() to get list of Provides defined in .desktop



commit 6eafe805d2b5880cc020586c7d155ad30fe958d2
Author: Vincent Untz <vuntz gnome org>
Date:   Tue Mar 22 13:14:26 2011 +0100

    gsm: Add gsm_app_provides() to get list of Provides defined in .desktop
    
    We need this to compare Provides defined in autostart files, so we don't
    start two applications providing the same service.

 gnome-session/gsm-app.c           |   12 +++++++++++-
 gnome-session/gsm-app.h           |    2 ++
 gnome-session/gsm-autostart-app.c |   19 +++++++++++++++++++
 3 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/gnome-session/gsm-app.c b/gnome-session/gsm-app.c
index 79917a8..ce2d5b2 100644
--- a/gnome-session/gsm-app.c
+++ b/gnome-session/gsm-app.c
@@ -249,6 +249,7 @@ gsm_app_class_init (GsmAppClass *klass)
         klass->impl_get_app_id = NULL;
         klass->impl_get_autorestart = NULL;
         klass->impl_provides = NULL;
+        klass->impl_get_provides = NULL;
         klass->impl_is_running = NULL;
 
         g_object_class_install_property (object_class,
@@ -393,7 +394,6 @@ gsm_app_peek_autorestart (GsmApp *app)
 gboolean
 gsm_app_provides (GsmApp *app, const char *service)
 {
-
         if (GSM_APP_GET_CLASS (app)->impl_provides) {
                 return GSM_APP_GET_CLASS (app)->impl_provides (app, service);
         } else {
@@ -401,6 +401,16 @@ gsm_app_provides (GsmApp *app, const char *service)
         }
 }
 
+char **
+gsm_app_get_provides (GsmApp *app)
+{
+        if (GSM_APP_GET_CLASS (app)->impl_get_provides) {
+                return GSM_APP_GET_CLASS (app)->impl_get_provides (app);
+        } else {
+                return NULL;
+        }
+}
+
 gboolean
 gsm_app_has_autostart_condition (GsmApp     *app,
                                  const char *condition)
diff --git a/gnome-session/gsm-app.h b/gnome-session/gsm-app.h
index 162908b..fa11b67 100644
--- a/gnome-session/gsm-app.h
+++ b/gnome-session/gsm-app.h
@@ -67,6 +67,7 @@ struct _GsmAppClass
                                                        GError    **error);
         gboolean    (*impl_provides)                  (GsmApp     *app,
                                                        const char *service);
+        char **     (*impl_get_provides)              (GsmApp     *app);
         gboolean    (*impl_has_autostart_condition)   (GsmApp     *app,
                                                        const char *service);
         gboolean    (*impl_is_running)                (GsmApp     *app);
@@ -113,6 +114,7 @@ void             gsm_app_died                           (GsmApp     *app);
 
 gboolean         gsm_app_provides                       (GsmApp     *app,
                                                          const char *service);
+char           **gsm_app_get_provides                   (GsmApp     *app);
 gboolean         gsm_app_has_autostart_condition        (GsmApp     *app,
                                                          const char *condition);
 void             gsm_app_registered                     (GsmApp     *app);
diff --git a/gnome-session/gsm-autostart-app.c b/gnome-session/gsm-autostart-app.c
index 05285d7..eaf441b 100644
--- a/gnome-session/gsm-autostart-app.c
+++ b/gnome-session/gsm-autostart-app.c
@@ -1231,6 +1231,24 @@ gsm_autostart_app_provides (GsmApp     *app,
         return FALSE;
 }
 
+static char **
+gsm_autostart_app_get_provides (GsmApp *app)
+{
+        GsmAutostartApp *aapp;
+
+        g_return_val_if_fail (GSM_IS_APP (app), NULL);
+
+        aapp = GSM_AUTOSTART_APP (app);
+
+        if (aapp->priv->desktop_file == NULL) {
+                return NULL;
+        }
+
+        return egg_desktop_file_get_string_list (aapp->priv->desktop_file,
+                                                 GSM_AUTOSTART_APP_PROVIDES_KEY,
+                                                 NULL, NULL);
+}
+
 static gboolean
 gsm_autostart_app_has_autostart_condition (GsmApp     *app,
                                            const char *condition)
@@ -1334,6 +1352,7 @@ gsm_autostart_app_class_init (GsmAutostartAppClass *klass)
         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_get_provides = gsm_autostart_app_get_provides;
         app_class->impl_has_autostart_condition = gsm_autostart_app_has_autostart_condition;
         app_class->impl_get_app_id = gsm_autostart_app_get_app_id;
         app_class->impl_get_autorestart = gsm_autostart_app_get_autorestart;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]