[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Patch to add direct FTP proxy support in kio_ftp
From:       Dawit Alemayehu <adawit () kde ! org>
Date:       2001-06-29 14:52:01
[Download RAW message or body]

Hi Michael,

Can update kdelibs/kio and try the following patch please.
The patch assumes that the proxy FTP server does not require 
you to login, but the remote server can as needed. 

Anyways, you have to download your script file and change
it to return the appropriate URL as discussed for now.

Regards,
Dawit A.

["ftp.diff" (text/plain)]

Index: ftp.cc
===================================================================
RCS file: /home/kde/kdelibs/kio/ftp/ftp.cc,v
retrieving revision 1.142
diff -u -p -b -B -w -r1.142 ftp.cc
--- ftp.cc	2001/06/26 22:20:19	1.142
+++ ftp.cc	2001/06/29 14:24:46
@@ -260,7 +260,13 @@ void Ftp::setHost( const QString& _host,
       pass = FTP_PASSWD;
   }
 
-  if ( m_host != _host || m_port != _port || m_user != user || m_pass != pass )
+  m_proxyURL = metaData("UseProxy");
+  kdDebug(7102) << "Proxy URL: " << m_proxyURL.url() << endl;
+  m_bUseProxy = ( m_proxyURL.isValid() &&
+                  m_proxyURL.protocol() == QString::fromLatin1("ftp") );
+
+  if ( m_host != _host || m_port != _port ||
+       m_user != user || m_pass != pass )
       closeConnection( );
 
   m_host = _host;
@@ -284,8 +290,11 @@ void Ftp::openConnection()
   assert( !m_bLoggedOn );
 
   m_initialPath = QString::null;
+
+  QString host = m_bUseProxy ? m_proxyURL.host() : m_host;
+  unsigned short int port = m_bUseProxy ? m_proxyURL.port() : m_port;
 
-  if (!connect( m_host, m_port ))
+  if (!connect( host, port ))
     return; // error emitted by connect
 
   m_bFtpStarted = true;
@@ -427,7 +436,7 @@ bool Ftp::ftpLogin()
       {
         if ( user != FTP_LOGIN && pass != FTP_PASSWD )
             info.username = m_user;
-        if ( checkCachedAuthentication( info ) )
+        if ( failedAuth < 3 && checkCachedAuthentication( info ) )
         {
           user = info.username;
           pass = info.password;
@@ -454,8 +463,11 @@ bool Ftp::ftpLogin()
 
       tempbuf = "user ";
       tempbuf += user.latin1();
+      if ( m_bUseProxy )
+        tempbuf += '@' + m_host.latin1();
       kdDebug(7102) << "Sending Login name: " << user << endl;
-      bool loggedIn = (ftpSendCmd( tempbuf, '2' ) && !strncmp( rspbuf, "230", 3));
+      bool loggedIn = (ftpSendCmd( tempbuf, '2' ) &&
+                       !strncmp( rspbuf, "230", 3));
       bool needPass = !strncmp( rspbuf, "331", 3);
       // Prompt user for login info if we do not
       // get back a "230" or "331".
Index: ftp.h
===================================================================
RCS file: /home/kde/kdelibs/kio/ftp/ftp.h,v
retrieving revision 1.41
diff -u -p -b -B -w -r1.41 ftp.h
--- ftp.h	2001/05/07 21:44:28	1.41
+++ ftp.h	2001/06/29 14:24:47
@@ -32,6 +32,8 @@
 
 #include <qcstring.h>
 #include <qstring.h>
+
+#include <kurl.h>
 #include <kio/slavebase.h>
 
 class KExtendedSocket;
@@ -247,6 +249,7 @@ private: // data members
    * Where we end up after connecting
    */
   QString m_initialPath;
+  KURL m_proxyURL;
 
   netbuf *nControl;
   char rspbuf[256];
@@ -254,7 +257,7 @@ private: // data members
   bool m_bLoggedOn;
   bool m_bFtpStarted;
   bool m_bPasv;
-
+  bool m_bUseProxy;
   bool m_bPersistent;
 
   size_t m_size;

>> Visit http://master.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic