Bug 109957 - Allow URL for remote site to be rewritten in terms of remote:/ for better transparency
Summary: Allow URL for remote site to be rewritten in terms of remote:/ for better tra...
Status: RESOLVED FIXED
Alias: None
Product: kio
Classification: Frameworks and Libraries
Component: remote (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: Kevin Ottens
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-31 22:31 UTC by Mario Tanev
Modified: 2005-10-26 08:22 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mario Tanev 2005-07-31 22:31:10 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
OS:                Linux

I believe the remote:/ protocol should present and be usable in a transparent of actual network address fashion.

For example, if entry exists in remote:/ called Mother, say mapped to fish://mother.url/home/mother, then a user should be able to use the URL remote:/Mother/Documents/cookie_recipe rather than having to type fish://mother.url/home/mother/Documents/cookie_recipe.

Also, clicking on entry Mother, should not change the URL at any point to fish://fullurl, but rather to remote://Mother/relativeurl. So for example, when a user opens Mother, their url will show, remote:/Mother/ which will contain among everything else the folder called Documents, which if opened, the URL will update to remote:/Mother/Documents and so forth.

Additionally, the UP button should go up the url as expected by backtracking a folder denomination (moving back by a /), so remote:/Mother when moved up, would become remote:/

Thank you
Comment 1 Kevin Ottens 2005-10-26 08:17:25 UTC
Well, I basically agree only with the first part of this report. You should be able to use remote:/Mother/Documents/cookie_recipe, and it has to redirect sanely.

As for completely hiding fish:// and the behavior of "Up" I disagree. My point is using those folders you go out from the local box, so we should really keep this redirection IMHO. This way you know that you're not on the local system anymore. Those folders are more links than real folders, the remote system is definitely not a subdir of your system.

I'll soon commit a fix for the first part of this wish, but I consider the remaining parts as WONTFIX because of the above reasons.
Comment 2 Kevin Ottens 2005-10-26 08:22:14 UTC
SVN commit 474358 by ervin:

Improve the redirection. Now we're able to redirect even if we have
trailing directory information.

For example remote:/Server/foo/bar will correctly redirect to
protocol://server.url/foo/bar now.

CCBUG:109957



 M  +29 -7     kio_remote.cpp  


--- branches/KDE/3.5/kdebase/kioslave/remote/kio_remote.cpp #474357:474358
@@ -79,10 +79,14 @@
 		return;
 	}
 
-	KURL target = m_impl.findBaseURL( url.fileName() );
+	int second_slash_idx = url.path().find( '/', 1 );
+	QString root_dirname = url.path().mid( 1, second_slash_idx-1 );
+	
+	KURL target = m_impl.findBaseURL( root_dirname );
 	kdDebug(1220) << "possible redirection target : " << target << endl;
 	if( target.isValid() )
 	{
+		target.addPath( url.path().remove(0, second_slash_idx) );
 		redirection(target);
 		finished();
 		return;
@@ -150,14 +154,32 @@
 		return;
 	}
 
-	KIO::UDSEntry entry;
-	if (m_impl.statNetworkFolder(entry, url.fileName()))
+	int second_slash_idx = url.path().find( '/', 1 );
+	QString root_dirname = url.path().mid( 1, second_slash_idx-1 );
+	
+	if ( second_slash_idx==-1 || ( (int)url.path().length() )==second_slash_idx+1 )
 	{
-		statEntry(entry);
-		finished();
-		return;
+		KIO::UDSEntry entry;
+		if (m_impl.statNetworkFolder(entry, root_dirname))
+		{
+			statEntry(entry);
+			finished();
+			return;
+		}
 	}
-
+	else
+	{
+		KURL target = m_impl.findBaseURL(  root_dirname );
+		kdDebug( 1220 ) << "possible redirection target : " << target << endl;
+		if (  target.isValid() )
+		{
+			target.addPath( url.path().remove( 0, second_slash_idx ) );
+			redirection( target );
+			finished();
+			return;
+		}
+	}
+	
 	error(KIO::ERR_MALFORMED_URL, url.prettyURL());
 }
 
Comment 3 Kevin Ottens 2005-10-26 08:22:58 UTC
SVN commit 474359 by ervin:

Improve the redirection. Now we're able to redirect even if we have
trailing directory information.

For example remote:/Server/foo/bar will correctly redirect to
protocol://server.url/foo/bar now.

(forward port from 3.5)

BUG:109957



 M  +30 -8     kio_remote.cpp  


--- trunk/KDE/kdebase/kioslave/remote/kio_remote.cpp #474358:474359
@@ -45,7 +45,7 @@
 	{
 		// KApplication is necessary to use other ioslaves
 		putenv(strdup("SESSION_MANAGER="));
-		KCmdLineArgs::init(argc, argv, "kio_remote", 0, 0, 0);
+		KCmdLineArgs::init(argc, argv, "kio_remote", 0L, 0L, false);
 		KCmdLineArgs::addCmdLineOptions( options );
 		KApplication app( false, false );
 		// We want to be anonymous even if we use DCOP
@@ -81,10 +81,14 @@
 		return;
 	}
 
-	KURL target = m_impl.findBaseURL( url.fileName() );
+	int second_slash_idx = url.path().find( '/', 1 );
+	QString root_dirname = url.path().mid( 1, second_slash_idx-1 );
+	
+	KURL target = m_impl.findBaseURL( root_dirname );
 	kdDebug(1220) << "possible redirection target : " << target << endl;
 	if( target.isValid() )
 	{
+		target.addPath( url.path().remove(0, second_slash_idx) );
 		redirection(target);
 		finished();
 		return;
@@ -151,14 +155,32 @@
 		return;
 	}
 
-	KIO::UDSEntry entry;
-	if (m_impl.statNetworkFolder(entry, url.fileName()))
+	int second_slash_idx = url.path().find( '/', 1 );
+	QString root_dirname = url.path().mid( 1, second_slash_idx-1 );
+	
+	if ( second_slash_idx==-1 || ( (int)url.path().length() )==second_slash_idx+1 )
 	{
-		statEntry(entry);
-		finished();
-		return;
+		KIO::UDSEntry entry;
+		if (m_impl.statNetworkFolder(entry, root_dirname))
+		{
+			statEntry(entry);
+			finished();
+			return;
+		}
 	}
-
+	else
+	{
+		KURL target = m_impl.findBaseURL(  root_dirname );
+		kdDebug( 1220 ) << "possible redirection target : " << target << endl;
+		if (  target.isValid() )
+		{
+			target.addPath( url.path().remove( 0, second_slash_idx ) );
+			redirection( target );
+			finished();
+			return;
+		}
+	}
+	
 	error(KIO::ERR_MALFORMED_URL, url.prettyURL());
 }