[gnome-commander/gcmd-1-3] Added gnome_cmd_con_get_scheme() function



commit 840a695987ca80eb42d171e0f10b54a93b2ec3a5
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Sun Jan 31 16:14:13 2010 +0100

    Added gnome_cmd_con_get_scheme() function

 src/gnome-cmd-con-ftp.cc |   12 +-----------
 src/gnome-cmd-con.h      |   14 ++++++++++++++
 2 files changed, 15 insertions(+), 11 deletions(-)
---
diff --git a/src/gnome-cmd-con-ftp.cc b/src/gnome-cmd-con-ftp.cc
index aabdc15..8d98dd1 100644
--- a/src/gnome-cmd-con-ftp.cc
+++ b/src/gnome-cmd-con-ftp.cc
@@ -248,10 +248,7 @@ GnomeCmdConFtp *gnome_cmd_con_ftp_new (const gchar *alias, const string &text_ur
 
     g_return_val_if_fail (uri != NULL, NULL);
 
-    const gchar *scheme = gnome_vfs_uri_get_scheme (uri);       // do not g_free
     const gchar *host = gnome_vfs_uri_get_host_name (uri);      // do not g_free
-    const gchar *remote_dir = gnome_vfs_uri_get_path (uri);     // do not g_free
-    const gchar *user = gnome_vfs_uri_get_user_name (uri);      // do not g_free
     const gchar *password = gnome_vfs_uri_get_password (uri);   // do not g_free
 
     GnomeCmdConFtp *server = (GnomeCmdConFtp *) gtk_type_new (gnome_cmd_con_ftp_get_type ());
@@ -266,14 +263,7 @@ GnomeCmdConFtp *gnome_cmd_con_ftp_new (const gchar *alias, const string &text_ur
 
     gnome_cmd_con_ftp_set_host_name (server, host);
 
-    con->method = gnome_vfs_uri_is_local (uri) ? CON_LOCAL :
-                  g_str_equal (scheme, "ftp")  ? (user && g_str_equal (user, "anonymous") ? CON_ANON_FTP : CON_FTP) :
-                  g_str_equal (scheme, "sftp") ? CON_SSH :
-                  g_str_equal (scheme, "dav")  ? CON_DAV :
-                  g_str_equal (scheme, "davs") ? CON_DAVS :
-                  g_str_equal (scheme, "smb")  ? CON_SMB :
-                                                 CON_URI;
-
+    con->method = gnome_cmd_con_get_scheme (uri);
     con->gnome_auth = !password && con->method!=CON_ANON_FTP;          // ?????????
 
     gnome_vfs_uri_unref (uri);
diff --git a/src/gnome-cmd-con.h b/src/gnome-cmd-con.h
index dee6b4e..2f2dac4 100644
--- a/src/gnome-cmd-con.h
+++ b/src/gnome-cmd-con.h
@@ -361,6 +361,20 @@ inline gchar *gnome_cmd_con_get_free_space (GnomeCmdCon *con, GnomeCmdDir *dir,
     return retval;
 }
 
+inline ConnectionMethodID gnome_cmd_con_get_scheme (GnomeVFSURI *uri)
+{
+    const gchar *scheme = gnome_vfs_uri_get_scheme (uri);       // do not g_free
+    const gchar *user = gnome_vfs_uri_get_user_name (uri);      // do not g_free
+
+    return gnome_vfs_uri_is_local (uri) ? CON_LOCAL :
+           g_str_equal (scheme, "ftp")  ? (user && g_str_equal (user, "anonymous") ? CON_ANON_FTP : CON_FTP) :
+           g_str_equal (scheme, "sftp") ? CON_SSH :
+           g_str_equal (scheme, "dav")  ? CON_DAV :
+           g_str_equal (scheme, "davs") ? CON_DAVS :
+           g_str_equal (scheme, "smb")  ? CON_SMB :
+                                          CON_URI;
+}
+
 std::string &__gnome_cmd_con_make_uri (std::string &s, const gchar *method, gboolean use_auth, std::string &server, std::string &port, std::string &folder, std::string &user, std::string &password);
 
 inline std::string &gnome_cmd_con_make_custom_uri (std::string &s, const std::string &uri)



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