File lockdown-protocols.patch of Package telepathy-mission-control

Index: libmissioncontrol/mc-profile.c
===================================================================
--- libmissioncontrol/mc-profile.c	(revision 541)
+++ libmissioncontrol/mc-profile.c	(working copy)
@@ -28,6 +28,7 @@
 
 #include <glib.h>
 #include <glib/gstdio.h>
+#include <gconf/gconf-client.h>
 #include <string.h>
 #include <sys/types.h>
 #include <libintl.h>
@@ -486,10 +487,20 @@
     GError *error = NULL;
     GList *ret = NULL;
     const gchar *filename, *dirname, **profile_dirs;
+    const gchar *profile_name;
+    gboolean protocols_locked_down;
+    GSList* allowed_profile_names;
+    GSList* allowed_profile_name;
+    gboolean profile_allowed;
+    gint i;
+    GConfClient *client = gconf_client_get_default ();
 
     profile_dirs = _mc_profile_get_dirs ();
     if (!profile_dirs) return NULL;
 
+    protocols_locked_down = gconf_client_get_bool (client, "/apps/telepathy/mc/protocols_locked_down", &error);
+    allowed_profile_names = gconf_client_get_list (client, "/apps/telepathy/mc/allowed_protocols", GCONF_VALUE_STRING, &error);
+
     for (dirname = *profile_dirs; dirname; profile_dirs++, dirname = *profile_dirs)
     {
 	dir = g_dir_open(dirname, 0, &error);
@@ -515,12 +526,38 @@
 	    g_free (unique_name);
 
 	    if (profile)
-		ret = g_list_prepend (ret, profile);
+        {
+            profile_allowed = FALSE;
+            profile_name = mc_profile_get_unique_name (profile);
+            allowed_profile_name = allowed_profile_names;
+            while (protocols_locked_down && allowed_profile_name != NULL) {
+                i++;
+                if (strcmp (profile_name, allowed_profile_name->data) == 0) {
+                    profile_allowed = TRUE;
+                    break;
+                }
+                allowed_profile_name = g_slist_next (allowed_profile_name);
+            }
+
+            if (profile_allowed || i == 0 || !protocols_locked_down) {
+                ret = g_list_prepend (ret, profile);
+            } else {
+                g_debug ("ignoring profile because not allowed: %s", profile_name);
+                g_object_unref (profile);
+            }
+        }
 	}
 
-	g_dir_close (dir);
     }
 
+    if (allowed_profile_names) {
+        while (allowed_profile_names) {
+            g_free (allowed_profile_names->data);
+            allowed_profile_names = g_slist_next (allowed_profile_names);
+        }
+        g_slist_free (allowed_profile_names);
+    }
+
     return ret;
 }
openSUSE Build Service is sponsored by