[gnome-commander] Do not use GnomeVFSURI in GnomeCmdDir class, part 1



commit 3c6589334db6eca9e5907eec22060147b2ce5233
Author: Uwe Scholz <u scholz83 gmx de>
Date:   Sun Jun 27 22:30:33 2021 +0200

    Do not use GnomeVFSURI in GnomeCmdDir class, part 1

 src/gnome-cmd-dir.cc | 56 ++++++++++++++++++++--------------------------------
 src/gnome-cmd-dir.h  |  7 +++----
 2 files changed, 24 insertions(+), 39 deletions(-)
---
diff --git a/src/gnome-cmd-dir.cc b/src/gnome-cmd-dir.cc
index 7fd63a14..a38f67e4 100644
--- a/src/gnome-cmd-dir.cc
+++ b/src/gnome-cmd-dir.cc
@@ -693,11 +693,11 @@ gchar *gnome_cmd_dir_get_display_path (GnomeCmdDir *dir)
 }
 
 
-GnomeVFSURI *gnome_cmd_dir_get_uri (GnomeCmdDir *dir)
+GFile *gnome_cmd_dir_get_gfile (GnomeCmdDir *dir)
 {
     g_return_val_if_fail (GNOME_CMD_IS_DIR (dir), nullptr);
 
-    return gnome_cmd_dir_get_child_uri(dir, ".");
+    return gnome_cmd_dir_get_child_gfile(dir, ".");
 }
 
 
@@ -705,24 +705,11 @@ gchar *gnome_cmd_dir_get_uri_str (GnomeCmdDir *dir)
 {
     g_return_val_if_fail (GNOME_CMD_IS_DIR (dir), nullptr);
 
-    GnomeVFSURI *uri = gnome_cmd_dir_get_uri (dir);
-    gchar *uri_str = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_PASSWORD);
-    gnome_vfs_uri_unref (uri);
-
-    return uri_str;
-}
-
-
-GnomeVFSURI *gnome_cmd_dir_get_child_uri (GnomeCmdDir *dir, const gchar *filename)
-{
-    g_return_val_if_fail (GNOME_CMD_IS_DIR (dir), nullptr);
+    GFile *gFile = gnome_cmd_dir_get_gfile (dir);
 
-    GnomeCmdPath *path = dir->priv->path->get_child(filename);
-
-    GnomeVFSURI *uri = gnome_cmd_con_create_uri (dir->priv->con, path);
-    delete path;
+    gchar *dir_str = g_file_get_uri (gFile);
 
-    return uri;
+    return dir_str;
 }
 
 
@@ -742,43 +729,42 @@ GFile *gnome_cmd_dir_get_child_gfile (GnomeCmdDir *dir, const gchar *filename)
 }
 
 
-GnomeVFSURI *gnome_cmd_dir_get_absolute_path_uri (GnomeCmdDir *dir, string absolute_filename)
+GFile *gnome_cmd_dir_get_absolute_path_gfile (GnomeCmdDir *dir, string absolute_filename)
 {
     g_return_val_if_fail (GNOME_CMD_IS_DIR (dir), nullptr);
 
 #ifdef HAVE_SAMBA
     // include workgroups and shares for smb uris
-    GnomeVFSURI *dir_uri = gnome_cmd_dir_get_uri (dir);
+    GFile *dir_gFile = gnome_cmd_dir_get_gfile (dir);
+
+    auto uriScheme = g_file_get_uri_scheme (dir_gFile);
 
-    if (strcmp (gnome_vfs_uri_get_scheme (dir_uri), "smb") == 0)
+    if (uriScheme && strcmp (uriScheme, "smb") == 0)
     {
-        gchar *mime_type = gnome_vfs_get_mime_type (gnome_vfs_uri_to_string (dir_uri, 
GNOME_VFS_URI_HIDE_PASSWORD));
-        while (strcmp (mime_type, "x-directory/normal") == 0)
+        while (GetGfileAttributeUInt32(dir_gFile, G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
         {
-            g_free (mime_type);
-
-            GnomeVFSURI *tmp_dir_uri = gnome_vfs_uri_get_parent (dir_uri);
-            gnome_vfs_uri_unref (dir_uri);
-            dir_uri = gnome_vfs_uri_dup (tmp_dir_uri);
-            mime_type = gnome_vfs_get_mime_type (gnome_vfs_uri_to_string (dir_uri, 
GNOME_VFS_URI_HIDE_PASSWORD));
+            auto gFileParent = g_file_get_parent(dir_gFile);
+            g_object_unref (dir_gFile);
+            dir_gFile = gFileParent;
         }
 
-        g_free (mime_type);
-
-        gchar *server_and_share = gnome_vfs_uri_to_string (dir_uri, GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD);
+        //ToDo: This has to be tested after the migration to GIO/gvfs is done
+        auto server_and_share = g_file_get_uri(dir_gFile);
         stringify (absolute_filename, g_build_filename (server_and_share, absolute_filename.c_str(), 
nullptr));
         g_free (server_and_share);
     }
 
-    gnome_vfs_uri_unref (dir_uri);
+    g_free(uriScheme);
+
+    g_object_unref (dir_gFile);
 #endif
 
     GnomeCmdPath *path = gnome_cmd_con_create_path (dir->priv->con, absolute_filename.c_str());
-    GnomeVFSURI *uri = gnome_cmd_con_create_uri (dir->priv->con, path);
+    auto gFile = gnome_cmd_con_create_gfile (dir->priv->con, path);
 
     delete path;
 
-    return uri;
+    return gFile;
 }
 
 
diff --git a/src/gnome-cmd-dir.h b/src/gnome-cmd-dir.h
index 8ca6e932..58029ad0 100644
--- a/src/gnome-cmd-dir.h
+++ b/src/gnome-cmd-dir.h
@@ -1,4 +1,4 @@
-/** 
+/**
  * @file gnome-cmd-dir.h
  * @copyright (C) 2001-2006 Marcus Bjurman\n
  * @copyright (C) 2007-2012 Piotr Eljasiak\n
@@ -126,13 +126,12 @@ void gnome_cmd_dir_set_path (GnomeCmdDir *dir, GnomeCmdPath *path);
 void gnome_cmd_dir_update_path (GnomeCmdDir *dir);
 gchar *gnome_cmd_dir_get_display_path (GnomeCmdDir *dir);
 
-GnomeVFSURI *gnome_cmd_dir_get_uri (GnomeCmdDir *dir);
+GFile       *gnome_cmd_dir_get_gfile (GnomeCmdDir *dir);
 gchar       *gnome_cmd_dir_get_uri_str (GnomeCmdDir *dir);
 
-GnomeVFSURI *gnome_cmd_dir_get_child_uri (GnomeCmdDir *dir, const gchar *filename);
 GFile *gnome_cmd_dir_get_child_gfile (GnomeCmdDir *dir, const gchar *filename);
 
-GnomeVFSURI *gnome_cmd_dir_get_absolute_path_uri (GnomeCmdDir *dir, std::string absolute_filename);
+GFile *gnome_cmd_dir_get_absolute_path_gfile (GnomeCmdDir *dir, std::string absolute_filename);
 
 void gnome_cmd_dir_file_created (GnomeCmdDir *dir, const gchar *uri_str);
 void gnome_cmd_dir_file_deleted (GnomeCmdDir *dir, const gchar *uri_str);


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