* src/maemo/modest-msg-edit-window.c:
[modest] / src / modest-conf.c
index 7536ec5..e8fc818 100644 (file)
@@ -114,8 +114,8 @@ static void
 modest_conf_init (ModestConf *obj)
 {
        GConfClient *conf = NULL;
+       GError *error = NULL;
        ModestConfPrivate *priv = MODEST_CONF_GET_PRIVATE(obj);
-       GError *err      = NULL;
 
        priv->gconf_client = NULL;
        
@@ -125,7 +125,22 @@ modest_conf_init (ModestConf *obj)
                return;
        }
 
-       priv->gconf_client = conf;      /* all went well! */
+       priv->gconf_client = conf;
+
+       /* All the tree will be listened */
+       gconf_client_add_dir (priv->gconf_client,
+                             "/apps/modest",
+                             GCONF_CLIENT_PRELOAD_NONE,
+                             &error);
+
+       /* Notify every change under namespace */
+       if (!error)
+               gconf_client_notify_add (priv->gconf_client,
+                                        "/apps/modest",
+                                        modest_conf_on_change,
+                                        obj,
+                                        NULL,
+                                        &error);
 }
 
 static void
@@ -294,7 +309,6 @@ modest_conf_set_list (ModestConf* self, const gchar* key,
 {
        ModestConfPrivate *priv;
        GConfValueType gconf_type;
-       gboolean result;
        
        g_return_val_if_fail (self, FALSE);
        g_return_val_if_fail (key, FALSE);
@@ -302,31 +316,8 @@ modest_conf_set_list (ModestConf* self, const gchar* key,
        priv = MODEST_CONF_GET_PRIVATE(self);
 
        gconf_type = modest_conf_type_to_gconf_type (list_type, err);
-       if (*err)
-               return FALSE;
 
-       result = gconf_client_set_list (priv->gconf_client, key, gconf_type, val, err);
-       if(*err) {
-               g_warning("gconf_client_set_list() failed with key=%s. error=%s", key,
-                         (*err)->message);
-               result = FALSE;
-       }
-       
-       /* TODO: Remove this, when we fix the problem: */
-       /* This shows that sometimes set_list fails, while saying that it succeeded: */
-       if (result) {
-               const gint debug_list_length_start = g_slist_length(val);
-               GSList* debug_list = gconf_client_get_list(priv->gconf_client, key, gconf_type, err);
-               const gint debug_list_length_after = g_slist_length(debug_list);
-              
-               if(debug_list_length_start != debug_list_length_after)
-                       g_warning("modest_conf_set_list(): The list length after setting is "
-                                 "not the same as the specified list. key=%s. "
-                                 "We think that we fixed this, so tell us if you see this.", key);
-               g_slist_free(debug_list);
-       }
-       
-       return result;
+       return gconf_client_set_list (priv->gconf_client, key, gconf_type, val, err);
 }
 
 
@@ -428,7 +419,6 @@ modest_conf_on_change (GConfClient *client,
                       key, event, conn_id);
 }
 
-
 static GConfValueType
 modest_conf_type_to_gconf_type (ModestConfValueType value_type, GError **err)
 {
@@ -456,45 +446,29 @@ modest_conf_type_to_gconf_type (ModestConfValueType value_type, GError **err)
        return gconf_type;
 }
 
-ModestConfNotificationId
+void
 modest_conf_listen_to_namespace (ModestConf *self,
                                 const gchar *namespace)
 {
        ModestConfPrivate *priv;
        GError *error = NULL;
-       ModestConfNotificationId notification_id;
 
-       g_return_val_if_fail (MODEST_IS_CONF (self), 0);
-       g_return_val_if_fail (namespace, 0);
+       g_return_if_fail (MODEST_IS_CONF (self));
+       g_return_if_fail (namespace);
        
        priv = MODEST_CONF_GET_PRIVATE(self);
 
        /* Add the namespace to the list of the namespaces that will
           be observed */
-       gconf_client_add_dir (priv->gconf_client, namespace,
+       gconf_client_add_dir (priv->gconf_client,
+                             namespace,
                              GCONF_CLIENT_PRELOAD_NONE,
                              &error);
-
-       if (error)
-               return 0;
-
-       /* Notify every change under namespace */
-       notification_id = gconf_client_notify_add (priv->gconf_client,
-                                                  namespace,
-                                                  modest_conf_on_change,
-                                                  self,
-                                                  NULL,
-                                                  &error);
-       if (error)
-               return 0;
-       else
-               return notification_id;
 }
 
 void 
 modest_conf_forget_namespace (ModestConf *self,
-                             const gchar *namespace,
-                             ModestConfNotificationId id)
+                             const gchar *namespace)
 {
        ModestConfPrivate *priv;
 
@@ -506,7 +480,4 @@ modest_conf_forget_namespace (ModestConf *self,
        /* Remove the namespace to the list of the namespaces that will
           be observed */
        gconf_client_remove_dir (priv->gconf_client, namespace, NULL);
-
-       /* Notify every change under namespace */
-       gconf_client_notify_remove (priv->gconf_client, id);
 }