[maemo-commits] [maemo-commits] r13867 - projects/haf/trunk/hildon-fm/hildon-fm

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Mon Sep 17 19:20:52 EEST 2007
Author: marivoll
Date: 2007-09-17 19:20:50 +0300 (Mon, 17 Sep 2007)
New Revision: 13867

Modified:
   projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-model.c
Log:
	* hildon-fm/hildon-file-system-model.c
	(hildon_file_system_model_add_node): Call
	hildon_file_system_special_location_rewrite_path to allow special
	locations to rewrite the paths of its children.


Modified: projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-model.c
===================================================================
--- projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-model.c	2007-09-17 16:19:14 UTC (rev 13866)
+++ projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-model.c	2007-09-17 16:20:50 UTC (rev 13867)
@@ -1724,10 +1724,11 @@
 {
     GNode *node;
     HildonFileSystemModelPrivate *priv;
-    HildonFileSystemModelNode *model_node;
+    HildonFileSystemModelNode *parent_model_node, *model_node;
     GtkFileInfo *file_info = NULL;
     GtkTreePath *tree_path;
     GtkTreeIter iter;
+    GtkFilePath *real_path;
 
     /* Path can be NULL for removable devices that are not present */
     g_return_val_if_fail(HILDON_IS_FILE_SYSTEM_MODEL(model), NULL);
@@ -1736,12 +1737,26 @@
 
     priv = CAST_GET_PRIVATE(model);
 
-    ULOG_INFO("Adding %s", (const char *) path);
+    parent_model_node = parent_node->data;
 
+    if (parent_model_node->location)
+      real_path =
+	hildon_file_system_special_location_rewrite_path (parent_model_node->location,
+							  priv->filesystem,
+							  path);
+    else
+      real_path = gtk_file_path_copy (path);
+
+    DBG ("Adding %s (%s)\n", (const char *)path, (const char *) real_path);
+
     if (parent_folder) {
         GError *error = NULL;
         /* This can cause main loop execution on vfs backend */
 
+	/* We need to use PATH instead of REAL_PATH here since
+	   PARENT_FOLDER only knows about the original paths.
+	*/
+
       /* If we have received the path that we are adding by some other
          means than listing the folder (like via some API function),
          then the backend will send us "files-added" signal immediately
@@ -1761,6 +1776,7 @@
 	  DBG ("ADD ERR %s\n", error->message);
           ULOG_ERR(error->message);
           g_error_free(error);
+	  gtk_file_path_free (real_path);
           return NULL;
         }
 
@@ -1771,7 +1787,7 @@
     {
       node =
         hildon_file_system_model_search_path_internal (parent_node,
-                                                       path, FALSE);
+                                                       real_path, FALSE);
 
         if (node) {
             HildonFileSystemModelNode *model_node = node->data;
@@ -1780,6 +1796,7 @@
 	    if (model_node->info)
 	      gtk_file_info_free (model_node->info);
 	    model_node->info = file_info;
+	    gtk_file_path_free (real_path);
             return node;
         }
     }
@@ -1789,19 +1806,17 @@
     model_node->model = HILDON_FILE_SYSTEM_MODEL(model);
     model_node->present_flag = TRUE;
     model_node->available = TRUE;
-    model_node->path = gtk_file_path_copy(path);
+    model_node->path = real_path;
 
     node = g_node_new(model_node);
     g_node_append(parent_node, node);
 
-    /* FIXME: explicit "obex:///" string there. This is because of the
-     * symlinks in the OBEX module nowadays (the BT device file is not
-     * a folder but a symlink). */
-    if (!parent_folder || (file_info && gtk_file_info_get_is_folder(file_info))
-        || g_str_has_prefix((gchar*)path, "obex:///"))
+    if (!parent_folder
+	|| (file_info && gtk_file_info_get_is_folder(file_info))
+	|| g_str_has_prefix (gtk_file_path_get_string (path), "obex:///"))
     {
         model_node->location = _hildon_file_system_get_special_location(
-                                   priv->filesystem, path);
+                                   priv->filesystem, real_path);
         setup_node_for_location(node);
     }
 
@@ -1813,7 +1828,7 @@
     if (!model_node->location)
     {
       gchar *local_path = gtk_file_system_path_to_filename(priv->filesystem,
-                                                           path);
+                                                           real_path);
 
       if (local_path)
       {


More information about the maemo-commits mailing list