Use dedicated kdDebug area.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit 549de5308f)
r14.0.x
Michele Calgaro 3 years ago
parent 704d7dcf86
commit e6834904ee
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -142,7 +142,7 @@ int kdemain( int argc, char **argv )
TDEInstance instance( "tdeio_ftp" ); TDEInstance instance( "tdeio_ftp" );
( void ) TDEGlobal::locale(); ( void ) TDEGlobal::locale();
kdDebug(7102) << "Starting " << getpid() << endl; kdDebug(7132) << "Starting " << getpid() << endl;
if (argc != 4) if (argc != 4)
{ {
@ -153,7 +153,7 @@ int kdemain( int argc, char **argv )
Ftp slave(argv[1], argv[2], argv[3]); Ftp slave(argv[1], argv[2], argv[3]);
slave.dispatchLoop(); slave.dispatchLoop();
kdDebug(7102) << "Done" << endl; kdDebug(7132) << "Done" << endl;
return 0; return 0;
} }
@ -224,12 +224,12 @@ int FtpTextReader::textRead(FtpSocket *pSock)
//=============================================================================== //===============================================================================
void FtpSocket::debugMessage(const char* pszMsg) const void FtpSocket::debugMessage(const char* pszMsg) const
{ {
kdDebug(7102) << m_pszName << ": " << pszMsg << endl; kdDebug(7132) << m_pszName << ": " << pszMsg << endl;
} }
int FtpSocket::errorMessage(int iErrorCode, const char* pszMsg) const int FtpSocket::errorMessage(int iErrorCode, const char* pszMsg) const
{ {
kdError(7102) << m_pszName << ": " << pszMsg << endl; kdError(7132) << m_pszName << ": " << pszMsg << endl;
return iErrorCode; return iErrorCode;
} }
@ -312,13 +312,13 @@ Ftp::Ftp( const TQCString &prot, const TQCString &pool, const TQCString &app )
// init other members // init other members
m_port = 0; m_port = 0;
kdDebug(7102) << "Ftp::Ftp()" << endl; kdDebug(7132) << "Ftp::Ftp()" << endl;
} }
Ftp::~Ftp() Ftp::~Ftp()
{ {
kdDebug(7102) << "Ftp::~Ftp()" << endl; kdDebug(7132) << "Ftp::~Ftp()" << endl;
closeConnection(); closeConnection();
} }
@ -387,9 +387,9 @@ const char* Ftp::ftpResponse(int iOffset)
iMore = 0; iMore = 0;
if(iMore != 0) if(iMore != 0)
kdDebug(7102) << " > " << pTxt << endl; kdDebug(7132) << " > " << pTxt << endl;
} while(iMore != 0); } while(iMore != 0);
kdDebug(7102) << "resp> " << pTxt << endl; kdDebug(7132) << "resp> " << pTxt << endl;
m_iRespType = (m_iRespCode > 0) ? m_iRespCode / 100 : 0; m_iRespType = (m_iRespCode > 0) ? m_iRespCode / 100 : 0;
} }
@ -404,18 +404,18 @@ const char* Ftp::ftpResponse(int iOffset)
void Ftp::closeConnection() void Ftp::closeConnection()
{ {
if(m_control != NULL || m_data != NULL) if(m_control != NULL || m_data != NULL)
kdDebug(7102) << "Ftp::closeConnection m_bLoggedOn=" << m_bLoggedOn << " m_bBusy=" << m_bBusy << endl; kdDebug(7132) << "Ftp::closeConnection m_bLoggedOn=" << m_bLoggedOn << " m_bBusy=" << m_bBusy << endl;
if(m_bBusy) // ftpCloseCommand not called if(m_bBusy) // ftpCloseCommand not called
{ {
kdWarning(7102) << "Ftp::closeConnection Abandoned data stream" << endl; kdWarning(7132) << "Ftp::closeConnection Abandoned data stream" << endl;
ftpCloseDataConnection(); ftpCloseDataConnection();
} }
if(m_bLoggedOn) // send quit if(m_bLoggedOn) // send quit
{ {
if( !ftpSendCmd( "quit", 0 ) || (m_iRespType != 2) ) if( !ftpSendCmd( "quit", 0 ) || (m_iRespType != 2) )
kdWarning(7102) << "Ftp::closeConnection QUIT returned error: " << m_iRespCode << endl; kdWarning(7132) << "Ftp::closeConnection QUIT returned error: " << m_iRespCode << endl;
} }
// close the data and control connections ... // close the data and control connections ...
@ -426,7 +426,7 @@ void Ftp::closeConnection()
void Ftp::setHost( const TQString& _host, int _port, const TQString& _user, void Ftp::setHost( const TQString& _host, int _port, const TQString& _user,
const TQString& _pass ) const TQString& _pass )
{ {
kdDebug(7102) << "Ftp::setHost (" << getpid() << "): " << _host << endl; kdDebug(7132) << "Ftp::setHost (" << getpid() << "): " << _host << endl;
m_proxyURL = metaData("UseProxy"); m_proxyURL = metaData("UseProxy");
m_bUseProxy = (m_proxyURL.isValid() && m_proxyURL.protocol() == m_prot); m_bUseProxy = (m_proxyURL.isValid() && m_proxyURL.protocol() == m_prot);
@ -455,7 +455,7 @@ bool Ftp::ftpOpenConnection (LoginMode loginMode)
return true; return true;
} }
kdDebug(7102) << "ftpOpenConnection " << m_host << ":" << m_port << " " kdDebug(7132) << "ftpOpenConnection " << m_host << ":" << m_port << " "
<< m_user << " [password hidden]" << endl; << m_user << " [password hidden]" << endl;
infoMessage( i18n("Opening connection to host %1").arg(m_host) ); infoMessage( i18n("Opening connection to host %1").arg(m_host) );
@ -618,7 +618,7 @@ bool Ftp::ftpLogin()
if ( failedAuth > 0 || (!user.isEmpty() && pass.isEmpty()) ) if ( failedAuth > 0 || (!user.isEmpty() && pass.isEmpty()) )
{ {
TQString errorMsg; TQString errorMsg;
kdDebug(7102) << "Prompting user for login info..." << endl; kdDebug(7132) << "Prompting user for login info..." << endl;
// Ask user if we should retry after when login fails! // Ask user if we should retry after when login fails!
if( failedAuth > 0 ) if( failedAuth > 0 )
@ -664,7 +664,7 @@ bool Ftp::ftpLogin()
} }
} }
kdDebug(7102) << "Sending Login name: " << tempbuf << endl; kdDebug(7132) << "Sending Login name: " << tempbuf << endl;
bool loggedIn = ( ftpSendCmd(tempbuf) && (m_iRespCode == 230) ); bool loggedIn = ( ftpSendCmd(tempbuf) && (m_iRespCode == 230) );
bool needPass = (m_iRespCode == 331); bool needPass = (m_iRespCode == 331);
@ -672,7 +672,7 @@ bool Ftp::ftpLogin()
// get back a "230" or "331". // get back a "230" or "331".
if ( !loggedIn && !needPass ) if ( !loggedIn && !needPass )
{ {
kdDebug(7102) << "Login failed: " << ftpResponse(0) << endl; kdDebug(7132) << "Login failed: " << ftpResponse(0) << endl;
++failedAuth; ++failedAuth;
continue; // Well we failed, prompt the user please!! continue; // Well we failed, prompt the user please!!
} }
@ -681,7 +681,7 @@ bool Ftp::ftpLogin()
{ {
tempbuf = "pass "; tempbuf = "pass ";
tempbuf += pass.latin1(); tempbuf += pass.latin1();
kdDebug(7102) << "Sending Login password: " << "[protected]" << endl; kdDebug(7132) << "Sending Login password: " << "[protected]" << endl;
loggedIn = ( ftpSendCmd(tempbuf) && (m_iRespCode == 230) ); loggedIn = ( ftpSendCmd(tempbuf) && (m_iRespCode == 230) );
} }
@ -696,7 +696,7 @@ bool Ftp::ftpLogin()
} while( ++failedAuth ); } while( ++failedAuth );
kdDebug(7102) << "Login OK" << endl; kdDebug(7132) << "Login OK" << endl;
infoMessage( i18n("Login OK") ); infoMessage( i18n("Login OK") );
// Okay, we're logged in. If this is IIS 4, switch dir listing style to Unix: // Okay, we're logged in. If this is IIS 4, switch dir listing style to Unix:
@ -716,16 +716,16 @@ bool Ftp::ftpLogin()
} }
} }
else else
kdWarning(7102) << "syst failed" << endl; kdWarning(7132) << "syst failed" << endl;
if ( config()->readBoolEntry ("EnableAutoLoginMacro") ) if ( config()->readBoolEntry ("EnableAutoLoginMacro") )
ftpAutoLoginMacro (); ftpAutoLoginMacro ();
// Get the current working directory // Get the current working directory
kdDebug(7102) << "Searching for pwd" << endl; kdDebug(7132) << "Searching for pwd" << endl;
if( !ftpSendCmd("pwd") || (m_iRespType != 2) ) if( !ftpSendCmd("pwd") || (m_iRespType != 2) )
{ {
kdDebug(7102) << "Couldn't issue pwd command" << endl; kdDebug(7132) << "Couldn't issue pwd command" << endl;
error( ERR_COULD_NOT_LOGIN, i18n("Could not login to %1.").arg(m_host) ); // or anything better ? error( ERR_COULD_NOT_LOGIN, i18n("Could not login to %1.").arg(m_host) ); // or anything better ?
return false; return false;
} }
@ -737,7 +737,7 @@ bool Ftp::ftpLogin()
{ {
m_initialPath = sTmp.mid(iBeg+1, iEnd-iBeg-1); m_initialPath = sTmp.mid(iBeg+1, iEnd-iBeg-1);
if(m_initialPath[0] != '/') m_initialPath.prepend('/'); if(m_initialPath[0] != '/') m_initialPath.prepend('/');
kdDebug(7102) << "Initial path set to: " << m_initialPath << endl; kdDebug(7132) << "Initial path set to: " << m_initialPath << endl;
m_currentPath = m_initialPath; m_currentPath = m_initialPath;
} }
return true; return true;
@ -789,7 +789,7 @@ bool Ftp::ftpSendCmd( const TQCString& cmd, int maxretries )
if ( cmd.find( '\r' ) != -1 || cmd.find( '\n' ) != -1) if ( cmd.find( '\r' ) != -1 || cmd.find( '\n' ) != -1)
{ {
kdWarning(7102) << "Invalid command received (contains CR or LF):" kdWarning(7132) << "Invalid command received (contains CR or LF):"
<< cmd.data() << endl; << cmd.data() << endl;
error( ERR_UNSUPPORTED_ACTION, m_host ); error( ERR_UNSUPPORTED_ACTION, m_host );
return false; return false;
@ -798,9 +798,9 @@ bool Ftp::ftpSendCmd( const TQCString& cmd, int maxretries )
// Don't print out the password... // Don't print out the password...
bool isPassCmd = (cmd.left(4).lower() == "pass"); bool isPassCmd = (cmd.left(4).lower() == "pass");
if ( !isPassCmd ) if ( !isPassCmd )
kdDebug(7102) << "send> " << cmd.data() << endl; kdDebug(7132) << "send> " << cmd.data() << endl;
else else
kdDebug(7102) << "send> pass [protected]" << endl; kdDebug(7132) << "send> pass [protected]" << endl;
// Send the message... // Send the message...
TQCString buf = cmd; TQCString buf = cmd;
@ -843,7 +843,7 @@ bool Ftp::ftpSendCmd( const TQCString& cmd, int maxretries )
return false; return false;
else else
{ {
kdDebug(7102) << "Was not able to communicate with " << m_host << endl kdDebug(7132) << "Was not able to communicate with " << m_host << endl
<< "Attempting to re-establish connection." << endl; << "Attempting to re-establish connection." << endl;
closeConnection(); // Close the old connection... closeConnection(); // Close the old connection...
@ -853,14 +853,14 @@ bool Ftp::ftpSendCmd( const TQCString& cmd, int maxretries )
{ {
if (m_control != NULL) // if openConnection succeeded ... if (m_control != NULL) // if openConnection succeeded ...
{ {
kdDebug(7102) << "Login failure, aborting" << endl; kdDebug(7132) << "Login failure, aborting" << endl;
error (ERR_COULD_NOT_LOGIN, m_host); error (ERR_COULD_NOT_LOGIN, m_host);
closeConnection (); closeConnection ();
} }
return false; return false;
} }
kdDebug(7102) << "Logged back in, re-issuing command" << endl; kdDebug(7132) << "Logged back in, re-issuing command" << endl;
// If we were able to login, resend the command... // If we were able to login, resend the command...
if (maxretries) if (maxretries)
@ -900,11 +900,11 @@ int Ftp::ftpOpenPASVDataConnection()
/* Let's PASsiVe*/ /* Let's PASsiVe*/
if( !ftpSendCmd("PASV") || (m_iRespType != 2) ) if( !ftpSendCmd("PASV") || (m_iRespType != 2) )
{ {
kdDebug(7102) << "PASV attempt failed" << endl; kdDebug(7132) << "PASV attempt failed" << endl;
// unknown command? // unknown command?
if( m_iRespType == 5 ) if( m_iRespType == 5 )
{ {
kdDebug(7102) << "disabling use of PASV" << endl; kdDebug(7132) << "disabling use of PASV" << endl;
m_extControl |= pasvUnknown; m_extControl |= pasvUnknown;
} }
return ERR_INTERNAL; return ERR_INTERNAL;
@ -922,7 +922,7 @@ int Ftp::ftpOpenPASVDataConnection()
( sscanf(start, "(%d,%d,%d,%d,%d,%d)",&i[0], &i[1], &i[2], &i[3], &i[4], &i[5]) != 6 && ( sscanf(start, "(%d,%d,%d,%d,%d,%d)",&i[0], &i[1], &i[2], &i[3], &i[4], &i[5]) != 6 &&
sscanf(start, "=%d,%d,%d,%d,%d,%d", &i[0], &i[1], &i[2], &i[3], &i[4], &i[5]) != 6 ) ) sscanf(start, "=%d,%d,%d,%d,%d,%d", &i[0], &i[1], &i[2], &i[3], &i[4], &i[5]) != 6 ) )
{ {
kdError(7102) << "parsing IP and port numbers failed. String parsed: " << start << endl; kdError(7132) << "parsing IP and port numbers failed. String parsed: " << start << endl;
return ERR_INTERNAL; return ERR_INTERNAL;
} }
@ -934,7 +934,7 @@ int Ftp::ftpOpenPASVDataConnection()
// now connect the data socket ... // now connect the data socket ...
m_data = new FtpSocket("PASV"); m_data = new FtpSocket("PASV");
m_data->setAddress(host, port); m_data->setAddress(host, port);
kdDebug(7102) << "Connecting to " << host << " on port " << port << endl; kdDebug(7132) << "Connecting to " << host << " on port " << port << endl;
return m_data->connectSocket(connectTimeout(), false); return m_data->connectSocket(connectTimeout(), false);
} }
@ -961,7 +961,7 @@ int Ftp::ftpOpenEPSVDataConnection()
// unknown command? // unknown command?
if( m_iRespType == 5 ) if( m_iRespType == 5 )
{ {
kdDebug(7102) << "disabling use of EPSV" << endl; kdDebug(7132) << "disabling use of EPSV" << endl;
m_extControl |= epsvUnknown; m_extControl |= epsvUnknown;
} }
return ERR_INTERNAL; return ERR_INTERNAL;
@ -1019,7 +1019,7 @@ int Ftp::ftpOpenEPRTDataConnection()
// unknown command? // unknown command?
if( m_iRespType == 5 ) if( m_iRespType == 5 )
{ {
kdDebug(7102) << "disabling use of EPRT" << endl; kdDebug(7132) << "disabling use of EPRT" << endl;
m_extControl |= eprtUnknown; m_extControl |= eprtUnknown;
} }
return ERR_INTERNAL; return ERR_INTERNAL;
@ -1262,12 +1262,12 @@ bool Ftp::ftpCloseCommand()
if(!m_bBusy) if(!m_bBusy)
return true; return true;
kdDebug(7102) << "ftpCloseCommand: reading command result" << endl; kdDebug(7132) << "ftpCloseCommand: reading command result" << endl;
m_bBusy = false; m_bBusy = false;
if(!ftpResponse(-1) || (m_iRespType != 2) ) if(!ftpResponse(-1) || (m_iRespType != 2) )
{ {
kdDebug(7102) << "ftpCloseCommand: no transfer complete message" << endl; kdDebug(7132) << "ftpCloseCommand: no transfer complete message" << endl;
return false; return false;
} }
return true; return true;
@ -1382,7 +1382,7 @@ bool Ftp::ftpChmod( const TQString & path, int permissions )
if(m_iRespCode == 500) if(m_iRespCode == 500)
{ {
m_extControl |= chmodUnknown; m_extControl |= chmodUnknown;
kdDebug(7102) << "ftpChmod: CHMOD not supported - disabling"; kdDebug(7132) << "ftpChmod: CHMOD not supported - disabling";
} }
return false; return false;
} }
@ -1442,7 +1442,7 @@ void Ftp::ftpCreateUDSEntry( const TQString & filename, FtpEntry& ftpEnt, UDSEnt
// --> we do better than Netscape :-) // --> we do better than Netscape :-)
if ( mime->name() == KMimeType::defaultMimeType() ) if ( mime->name() == KMimeType::defaultMimeType() )
{ {
kdDebug(7102) << "Setting guessed mime type to inode/directory for " << filename << endl; kdDebug(7132) << "Setting guessed mime type to inode/directory for " << filename << endl;
atom.m_uds = UDS_GUESSED_MIME_TYPE; atom.m_uds = UDS_GUESSED_MIME_TYPE;
atom.m_str = "inode/directory"; atom.m_str = "inode/directory";
entry.append( atom ); entry.append( atom );
@ -1493,10 +1493,10 @@ void Ftp::ftpStatAnswerNotFound( const TQString & path, const TQString & filenam
// When e.g. uploading a file, we still need stat() to return "not found" // When e.g. uploading a file, we still need stat() to return "not found"
// when the file doesn't exist. // when the file doesn't exist.
TQString statSide = metaData("statSide"); TQString statSide = metaData("statSide");
kdDebug(7102) << "Ftp::stat statSide=" << statSide << endl; kdDebug(7132) << "Ftp::stat statSide=" << statSide << endl;
if ( statSide == "source" ) if ( statSide == "source" )
{ {
kdDebug(7102) << "Not found, but assuming found, because some servers don't allow listing" << endl; kdDebug(7132) << "Not found, but assuming found, because some servers don't allow listing" << endl;
// MS Server is incapable of handling "list <blah>" in a case insensitive way // MS Server is incapable of handling "list <blah>" in a case insensitive way
// But "retr <blah>" works. So lie in stat(), to get going... // But "retr <blah>" works. So lie in stat(), to get going...
// //
@ -1512,12 +1512,12 @@ void Ftp::ftpStatAnswerNotFound( const TQString & path, const TQString & filenam
void Ftp::stat( const KURL &url) void Ftp::stat( const KURL &url)
{ {
kdDebug(7102) << "Ftp::stat : path='" << url.path() << "'" << endl; kdDebug(7132) << "Ftp::stat : path='" << url.path() << "'" << endl;
if( !ftpOpenConnection(loginImplicit) ) if( !ftpOpenConnection(loginImplicit) )
return; return;
TQString path = TQDir::cleanDirPath( url.path() ); TQString path = TQDir::cleanDirPath( url.path() );
kdDebug(7102) << "Ftp::stat : cleaned path='" << path << "'" << endl; kdDebug(7132) << "Ftp::stat : cleaned path='" << path << "'" << endl;
// We can't stat root, but we know it's a dir. // We can't stat root, but we know it's a dir.
if( path.isEmpty() || path == "/" ) if( path.isEmpty() || path == "/" )
@ -1565,7 +1565,7 @@ void Ftp::stat( const KURL &url)
// if we're only interested in "file or directory", we should stop here // if we're only interested in "file or directory", we should stop here
TQString sDetails = metaData("details"); TQString sDetails = metaData("details");
int details = sDetails.isEmpty() ? 2 : sDetails.toInt(); int details = sDetails.isEmpty() ? 2 : sDetails.toInt();
kdDebug(7102) << "Ftp::stat details=" << details << endl; kdDebug(7132) << "Ftp::stat details=" << details << endl;
if ( details == 0 ) if ( details == 0 )
{ {
if ( !isDir && !ftpSize( path, 'I' ) ) // ok, not a dir -> is it a file ? if ( !isDir && !ftpSize( path, 'I' ) ) // ok, not a dir -> is it a file ?
@ -1629,10 +1629,10 @@ void Ftp::stat( const KURL &url)
if( !ftpOpenCommand( "list", listarg, 'I', ERR_DOES_NOT_EXIST ) ) if( !ftpOpenCommand( "list", listarg, 'I', ERR_DOES_NOT_EXIST ) )
{ {
kdError(7102) << "COULD NOT LIST" << endl; kdError(7132) << "COULD NOT LIST" << endl;
return; return;
} }
kdDebug(7102) << "Starting of list was ok" << endl; kdDebug(7132) << "Starting of list was ok" << endl;
Q_ASSERT( !search.isEmpty() && search != "/" ); Q_ASSERT( !search.isEmpty() && search != "/" );
@ -1656,11 +1656,11 @@ void Ftp::stat( const KURL &url)
// Damn, the dir we're trying to list is in fact a symlink // Damn, the dir we're trying to list is in fact a symlink
// Follow it and try again // Follow it and try again
if ( ftpEnt.link.isEmpty() ) if ( ftpEnt.link.isEmpty() )
kdWarning(7102) << "Got " << listarg << " as answer, but empty link!" << endl; kdWarning(7132) << "Got " << listarg << " as answer, but empty link!" << endl;
else else
{ {
linkURL = url; linkURL = url;
kdDebug(7102) << "ftpEnt.link=" << ftpEnt.link << endl; kdDebug(7132) << "ftpEnt.link=" << ftpEnt.link << endl;
if ( ftpEnt.link[0] == '/' ) if ( ftpEnt.link[0] == '/' )
linkURL.setPath( ftpEnt.link ); // Absolute link linkURL.setPath( ftpEnt.link ); // Absolute link
else else
@ -1669,7 +1669,7 @@ void Ftp::stat( const KURL &url)
linkURL.setPath( listarg ); // this is what we were listing (the link) linkURL.setPath( listarg ); // this is what we were listing (the link)
linkURL.setPath( linkURL.directory() ); // go up one dir linkURL.setPath( linkURL.directory() ); // go up one dir
linkURL.addPath( ftpEnt.link ); // replace link by its destination linkURL.addPath( ftpEnt.link ); // replace link by its destination
kdDebug(7102) << "linkURL now " << linkURL.prettyURL() << endl; kdDebug(7132) << "linkURL now " << linkURL.prettyURL() << endl;
} }
// Re-add the filename we're looking for // Re-add the filename we're looking for
linkURL.addPath( filename ); linkURL.addPath( filename );
@ -1678,7 +1678,7 @@ void Ftp::stat( const KURL &url)
} }
} }
// kdDebug(7102) << ftpEnt.name << endl; // kdDebug(7132) << ftpEnt.name << endl;
} }
ftpCloseCommand(); // closes the data connection only ftpCloseCommand(); // closes the data connection only
@ -1700,14 +1700,14 @@ void Ftp::stat( const KURL &url)
return; return;
} }
kdDebug(7102) << "stat : finished successfully" << endl; kdDebug(7132) << "stat : finished successfully" << endl;
finished(); finished();
} }
void Ftp::listDir( const KURL &url ) void Ftp::listDir( const KURL &url )
{ {
kdDebug(7102) << "Ftp::listDir " << url.prettyURL() << endl; kdDebug(7132) << "Ftp::listDir " << url.prettyURL() << endl;
if( !ftpOpenConnection(loginImplicit) ) if( !ftpOpenConnection(loginImplicit) )
return; return;
@ -1727,13 +1727,13 @@ void Ftp::listDir( const KURL &url )
if ( m_initialPath.isEmpty() ) if ( m_initialPath.isEmpty() )
m_initialPath = "/"; m_initialPath = "/";
realURL.setPath( m_initialPath ); realURL.setPath( m_initialPath );
kdDebug(7102) << "REDIRECTION to " << realURL.prettyURL() << endl; kdDebug(7132) << "REDIRECTION to " << realURL.prettyURL() << endl;
redirection( realURL ); redirection( realURL );
finished(); finished();
return; return;
} }
kdDebug(7102) << "hunting for path '" << path << "'" << endl; kdDebug(7132) << "hunting for path '" << path << "'" << endl;
if (!ftpOpenDir( path ) ) if (!ftpOpenDir( path ) )
{ {
@ -1752,14 +1752,14 @@ void Ftp::listDir( const KURL &url )
FtpEntry ftpEnt; FtpEntry ftpEnt;
while( ftpReadDir(ftpEnt) ) while( ftpReadDir(ftpEnt) )
{ {
//kdDebug(7102) << ftpEnt.name << endl; //kdDebug(7132) << ftpEnt.name << endl;
//Q_ASSERT( !ftpEnt.name.isEmpty() ); //Q_ASSERT( !ftpEnt.name.isEmpty() );
if ( !ftpEnt.name.isEmpty() ) if ( !ftpEnt.name.isEmpty() )
{ {
//if ( S_ISDIR( (mode_t)ftpEnt.type ) ) //if ( S_ISDIR( (mode_t)ftpEnt.type ) )
// kdDebug(7102) << "is a dir" << endl; // kdDebug(7132) << "is a dir" << endl;
//if ( !ftpEnt.link.isEmpty() ) //if ( !ftpEnt.link.isEmpty() )
// kdDebug(7102) << "is a link to " << ftpEnt.link << endl; // kdDebug(7132) << "is a link to " << ftpEnt.link << endl;
entry.clear(); entry.clear();
ftpCreateUDSEntry( ftpEnt.name, ftpEnt, entry, false ); ftpCreateUDSEntry( ftpEnt.name, ftpEnt, entry, false );
listEntry( entry, false ); listEntry( entry, false );
@ -1772,7 +1772,7 @@ void Ftp::listDir( const KURL &url )
void Ftp::slave_status() void Ftp::slave_status()
{ {
kdDebug(7102) << "Got slave_status host = " << (m_host.ascii() ? m_host.ascii() : "[None]") << " [" << (m_bLoggedOn ? "Connected" : "Not connected") << "]" << endl; kdDebug(7132) << "Got slave_status host = " << (m_host.ascii() ? m_host.ascii() : "[None]") << " [" << (m_bLoggedOn ? "Connected" : "Not connected") << "]" << endl;
slaveStatus( m_host, m_bLoggedOn ); slaveStatus( m_host, m_bLoggedOn );
} }
@ -1798,11 +1798,11 @@ bool Ftp::ftpOpenDir( const TQString & path )
{ {
if ( !ftpOpenCommand( "list", TQString::null, 'I', ERR_CANNOT_ENTER_DIRECTORY ) ) if ( !ftpOpenCommand( "list", TQString::null, 'I', ERR_CANNOT_ENTER_DIRECTORY ) )
{ {
kdWarning(7102) << "Can't open for listing" << endl; kdWarning(7132) << "Can't open for listing" << endl;
return false; return false;
} }
} }
kdDebug(7102) << "Starting of list was ok" << endl; kdDebug(7132) << "Starting of list was ok" << endl;
return true; return true;
} }
@ -1816,10 +1816,10 @@ bool Ftp::ftpReadDir(FtpEntry& de)
if(m_data->textRead() <= 0) if(m_data->textRead() <= 0)
continue; continue;
if(m_data->textTooLong()) if(m_data->textTooLong())
kdWarning(7102) << "ftpReadDir line too long - truncated" << endl; kdWarning(7132) << "ftpReadDir line too long - truncated" << endl;
const char* buffer = m_data->textLine(); const char* buffer = m_data->textLine();
kdDebug(7102) << "dir > " << buffer << endl; kdDebug(7132) << "dir > " << buffer << endl;
//Normally the listing looks like //Normally the listing looks like
// -rw-r--r-- 1 dfaure dfaure 102 Nov 9 12:30 log // -rw-r--r-- 1 dfaure dfaure 102 Nov 9 12:30 log
@ -1834,7 +1834,7 @@ bool Ftp::ftpReadDir(FtpEntry& de)
if( (p_group = strtok(NULL," ")) == 0) continue; if( (p_group = strtok(NULL," ")) == 0) continue;
if( (p_size = strtok(NULL," ")) == 0) continue; if( (p_size = strtok(NULL," ")) == 0) continue;
//kdDebug(7102) << "p_access=" << p_access << " p_junk=" << p_junk << " p_owner=" << p_owner << " p_group=" << p_group << " p_size=" << p_size << endl; //kdDebug(7132) << "p_access=" << p_access << " p_junk=" << p_junk << " p_owner=" << p_owner << " p_group=" << p_group << " p_size=" << p_size << endl;
de.access = 0; de.access = 0;
if ( strlen( p_access ) == 1 && p_junk[0] == '[' ) { // Netware if ( strlen( p_access ) == 1 && p_junk[0] == '[' ) { // Netware
@ -1848,7 +1848,7 @@ bool Ftp::ftpReadDir(FtpEntry& de)
// So we just ignore the number in front of the ",". Ok, its a hack :-) // So we just ignore the number in front of the ",". Ok, its a hack :-)
if ( strchr( p_size, ',' ) != 0L ) if ( strchr( p_size, ',' ) != 0L )
{ {
//kdDebug(7102) << "Size contains a ',' -> reading size again (/dev hack)" << endl; //kdDebug(7132) << "Size contains a ',' -> reading size again (/dev hack)" << endl;
if ((p_size = strtok(NULL," ")) == 0) if ((p_size = strtok(NULL," ")) == 0)
continue; continue;
} }
@ -1862,12 +1862,12 @@ bool Ftp::ftpReadDir(FtpEntry& de)
p_date_1 = p_size; p_date_1 = p_size;
p_size = p_group; p_size = p_group;
p_group = 0; p_group = 0;
//kdDebug(7102) << "Size didn't have a digit -> size=" << p_size << " date_1=" << p_date_1 << endl; //kdDebug(7132) << "Size didn't have a digit -> size=" << p_size << " date_1=" << p_date_1 << endl;
} }
else else
{ {
p_date_1 = strtok(NULL," "); p_date_1 = strtok(NULL," ");
//kdDebug(7102) << "Size has a digit -> ok. p_date_1=" << p_date_1 << endl; //kdDebug(7132) << "Size has a digit -> ok. p_date_1=" << p_date_1 << endl;
} }
if ( p_date_1 != 0 && if ( p_date_1 != 0 &&
@ -1958,7 +1958,7 @@ bool Ftp::ftpReadDir(FtpEntry& de)
time_t currentTime = time( 0L ); time_t currentTime = time( 0L );
struct tm * tmptr = gmtime( &currentTime ); struct tm * tmptr = gmtime( &currentTime );
int currentMonth = tmptr->tm_mon; int currentMonth = tmptr->tm_mon;
//kdDebug(7102) << "Current time :" << asctime( tmptr ) << endl; //kdDebug(7132) << "Current time :" << asctime( tmptr ) << endl;
// Reset time fields // Reset time fields
tmptr->tm_isdst = -1; // We do not know anything about day saving time (of any random day of the year) tmptr->tm_isdst = -1; // We do not know anything about day saving time (of any random day of the year)
tmptr->tm_sec = 0; tmptr->tm_sec = 0;
@ -1969,13 +1969,13 @@ bool Ftp::ftpReadDir(FtpEntry& de)
// Get month from first field // Get month from first field
// NOTE : no, we don't want to use TDELocale here // NOTE : no, we don't want to use TDELocale here
// It seems all FTP servers use the English way // It seems all FTP servers use the English way
//kdDebug(7102) << "Looking for month " << p_date_1 << endl; //kdDebug(7132) << "Looking for month " << p_date_1 << endl;
static const char * s_months[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", static const char * s_months[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
for ( int c = 0 ; c < 12 ; c ++ ) for ( int c = 0 ; c < 12 ; c ++ )
if ( !strcmp( p_date_1, s_months[c]) ) if ( !strcmp( p_date_1, s_months[c]) )
{ {
//kdDebug(7102) << "Found month " << c << " for " << p_date_1 << endl; //kdDebug(7132) << "Found month " << c << " for " << p_date_1 << endl;
tmptr->tm_mon = c; tmptr->tm_mon = c;
break; break;
} }
@ -2003,10 +2003,10 @@ bool Ftp::ftpReadDir(FtpEntry& de)
tmptr->tm_hour = atoi( p_date_3 ); tmptr->tm_hour = atoi( p_date_3 );
} }
else else
kdWarning(7102) << "Can't parse third field " << p_date_3 << endl; kdWarning(7132) << "Can't parse third field " << p_date_3 << endl;
} }
//kdDebug(7102) << asctime( tmptr ) << endl; //kdDebug(7132) << asctime( tmptr ) << endl;
de.date = mktime( tmptr ); de.date = mktime( tmptr );
return true; return true;
} }
@ -2020,7 +2020,7 @@ bool Ftp::ftpReadDir(FtpEntry& de)
//=============================================================================== //===============================================================================
void Ftp::get( const KURL & url ) void Ftp::get( const KURL & url )
{ {
kdDebug(7102) << "Ftp::get " << url.url() << endl; kdDebug(7132) << "Ftp::get " << url.url() << endl;
int iError = 0; int iError = 0;
ftpGet(iError, -1, url, 0); // iError gets status ftpGet(iError, -1, url, 0); // iError gets status
if(iError) // can have only server side errs if(iError) // can have only server side errs
@ -2043,7 +2043,7 @@ Ftp::StatusCode Ftp::ftpGet(int& iError, int iCopyFile, const KURL& url, TDEIO::
ftpFolder(url.path(), false) ) ftpFolder(url.path(), false) )
{ {
// Ok it's a dir in fact // Ok it's a dir in fact
kdDebug(7102) << "ftpGet: it is a directory in fact" << endl; kdDebug(7132) << "ftpGet: it is a directory in fact" << endl;
iError = ERR_IS_DIRECTORY; iError = ERR_IS_DIRECTORY;
return statusServerError; return statusServerError;
} }
@ -2052,12 +2052,12 @@ Ftp::StatusCode Ftp::ftpGet(int& iError, int iCopyFile, const KURL& url, TDEIO::
if ( !resumeOffset.isEmpty() ) if ( !resumeOffset.isEmpty() )
{ {
llOffset = resumeOffset.toLongLong(); llOffset = resumeOffset.toLongLong();
kdDebug(7102) << "ftpGet: got offset from metadata : " << llOffset << endl; kdDebug(7132) << "ftpGet: got offset from metadata : " << llOffset << endl;
} }
if( !ftpOpenCommand("retr", url.path(), '?', ERR_CANNOT_OPEN_FOR_READING, llOffset) ) if( !ftpOpenCommand("retr", url.path(), '?', ERR_CANNOT_OPEN_FOR_READING, llOffset) )
{ {
kdWarning(7102) << "ftpGet: Can't open for reading" << endl; kdWarning(7132) << "ftpGet: Can't open for reading" << endl;
return statusServerError; return statusServerError;
} }
@ -2072,7 +2072,7 @@ Ftp::StatusCode Ftp::ftpGet(int& iError, int iCopyFile, const KURL& url, TDEIO::
if ( m_size != UnknownSize ) if ( m_size != UnknownSize )
bytesLeft = m_size - llOffset; bytesLeft = m_size - llOffset;
kdDebug(7102) << "ftpGet: starting with offset=" << llOffset << endl; kdDebug(7132) << "ftpGet: starting with offset=" << llOffset << endl;
TDEIO::fileoffset_t processed_size = llOffset; TDEIO::fileoffset_t processed_size = llOffset;
TQByteArray array; TQByteArray array;
@ -2124,7 +2124,7 @@ Ftp::StatusCode Ftp::ftpGet(int& iError, int iCopyFile, const KURL& url, TDEIO::
array.setRawData(buffer, n); array.setRawData(buffer, n);
KMimeMagicResult * result = KMimeMagic::self()->findBufferFileType(array, url.fileName()); KMimeMagicResult * result = KMimeMagic::self()->findBufferFileType(array, url.fileName());
array.resetRawData(buffer, n); array.resetRawData(buffer, n);
kdDebug(7102) << "ftpGet: Emitting mimetype " << result->mimeType() << endl; kdDebug(7132) << "ftpGet: Emitting mimetype " << result->mimeType() << endl;
mimeType( result->mimeType() ); mimeType( result->mimeType() );
if( m_size != UnknownSize ) // Emit total size AFTER mimetype if( m_size != UnknownSize ) // Emit total size AFTER mimetype
totalSize( m_size ); totalSize( m_size );
@ -2142,12 +2142,12 @@ Ftp::StatusCode Ftp::ftpGet(int& iError, int iCopyFile, const KURL& url, TDEIO::
processedSize( processed_size ); processedSize( processed_size );
} }
kdDebug(7102) << "ftpGet: done" << endl; kdDebug(7132) << "ftpGet: done" << endl;
if(iCopyFile == -1) // must signal EOF to data pump ... if(iCopyFile == -1) // must signal EOF to data pump ...
data(array); // array is empty and must be empty! data(array); // array is empty and must be empty!
processedSize( m_size == UnknownSize ? processed_size : m_size ); processedSize( m_size == UnknownSize ? processed_size : m_size );
kdDebug(7102) << "ftpGet: emitting finished()" << endl; kdDebug(7132) << "ftpGet: emitting finished()" << endl;
finished(); finished();
return statusSuccess; return statusSuccess;
} }
@ -2159,7 +2159,7 @@ void Ftp::mimetype( const KURL& url )
return; return;
if ( !ftpOpenCommand( "retr", url.path(), 'I', ERR_CANNOT_OPEN_FOR_READING, 0 ) ) { if ( !ftpOpenCommand( "retr", url.path(), 'I', ERR_CANNOT_OPEN_FOR_READING, 0 ) ) {
kdWarning(7102) << "Can't open for reading" << endl; kdWarning(7132) << "Can't open for reading" << endl;
return; return;
} }
char buffer[ 2048 ]; char buffer[ 2048 ];
@ -2171,12 +2171,12 @@ void Ftp::mimetype( const KURL& url )
data( array ); data( array );
array.resetRawData(buffer, n); array.resetRawData(buffer, n);
kdDebug(7102) << "aborting" << endl; kdDebug(7132) << "aborting" << endl;
ftpAbortTransfer(); ftpAbortTransfer();
kdDebug(7102) << "finished" << endl; kdDebug(7132) << "finished" << endl;
finished(); finished();
kdDebug(7102) << "after finished" << endl; kdDebug(7132) << "after finished" << endl;
} }
void Ftp::ftpAbortTransfer() void Ftp::ftpAbortTransfer()
@ -2197,7 +2197,7 @@ void Ftp::ftpAbortTransfer()
; // error... ; // error...
// Send ABOR // Send ABOR
kdDebug(7102) << "send ABOR" << endl; kdDebug(7132) << "send ABOR" << endl;
TQCString buf = "ABOR\r\n"; TQCString buf = "ABOR\r\n";
if ( KSocks::self()->write( sControl, buf.data(), buf.length() ) <= 0 ) { if ( KSocks::self()->write( sControl, buf.data(), buf.length() ) <= 0 ) {
error( ERR_COULD_NOT_WRITE, TQString::null ); error( ERR_COULD_NOT_WRITE, TQString::null );
@ -2205,14 +2205,14 @@ void Ftp::ftpAbortTransfer()
} }
// //
kdDebug(7102) << "read resp" << endl; kdDebug(7132) << "read resp" << endl;
if ( readresp() != '2' ) if ( readresp() != '2' )
{ {
error( ERR_COULD_NOT_READ, TQString::null ); error( ERR_COULD_NOT_READ, TQString::null );
return; return;
} }
kdDebug(7102) << "close sockets" << endl; kdDebug(7132) << "close sockets" << endl;
closeSockets(); closeSockets();
} }
*/ */
@ -2223,7 +2223,7 @@ void Ftp::ftpAbortTransfer()
//=============================================================================== //===============================================================================
void Ftp::put(const KURL& url, int permissions, bool overwrite, bool resume) void Ftp::put(const KURL& url, int permissions, bool overwrite, bool resume)
{ {
kdDebug(7102) << "Ftp::put " << url.url() << endl; kdDebug(7132) << "Ftp::put " << url.url() << endl;
int iError = 0; // iError gets status int iError = 0; // iError gets status
ftpPut(iError, -1, url, permissions, overwrite, resume); ftpPut(iError, -1, url, permissions, overwrite, resume);
if(iError) // can have only server side errs if(iError) // can have only server side errs
@ -2306,7 +2306,7 @@ Ftp::StatusCode Ftp::ftpPut(int& iError, int iCopyFile, const KURL& dest_url,
// if we are using marking of partial downloads -> add .part extension // if we are using marking of partial downloads -> add .part extension
if ( bMarkPartial ) { if ( bMarkPartial ) {
kdDebug(7102) << "Adding .part extension to " << dest_orig << endl; kdDebug(7132) << "Adding .part extension to " << dest_orig << endl;
dest = dest_part; dest = dest_part;
} else } else
dest = dest_orig; dest = dest_orig;
@ -2330,7 +2330,7 @@ Ftp::StatusCode Ftp::ftpPut(int& iError, int iCopyFile, const KURL& dest_url,
if (! ftpOpenCommand( "stor", dest, '?', ERR_COULD_NOT_WRITE, offset ) ) if (! ftpOpenCommand( "stor", dest, '?', ERR_COULD_NOT_WRITE, offset ) )
return statusServerError; return statusServerError;
kdDebug(7102) << "ftpPut: starting with offset=" << offset << endl; kdDebug(7132) << "ftpPut: starting with offset=" << offset << endl;
TDEIO::fileoffset_t processed_size = offset; TDEIO::fileoffset_t processed_size = offset;
TQByteArray buffer; TQByteArray buffer;
@ -2368,7 +2368,7 @@ Ftp::StatusCode Ftp::ftpPut(int& iError, int iCopyFile, const KURL& dest_url,
if (result != 0) // error if (result != 0) // error
{ {
ftpCloseCommand(); // don't care about errors ftpCloseCommand(); // don't care about errors
kdDebug(7102) << "Error during 'put'. Aborting." << endl; kdDebug(7132) << "Error during 'put'. Aborting." << endl;
if (bMarkPartial) if (bMarkPartial)
{ {
// Remove if smaller than minimum size // Remove if smaller than minimum size
@ -2392,7 +2392,7 @@ Ftp::StatusCode Ftp::ftpPut(int& iError, int iCopyFile, const KURL& dest_url,
// after full download rename the file back to original name // after full download rename the file back to original name
if ( bMarkPartial ) if ( bMarkPartial )
{ {
kdDebug(7102) << "renaming dest (" << dest << ") back to dest_orig (" << dest_orig << ")" << endl; kdDebug(7132) << "renaming dest (" << dest << ") back to dest_orig (" << dest_orig << ")" << endl;
if ( !ftpRename( dest, dest_orig, true ) ) if ( !ftpRename( dest, dest_orig, true ) )
{ {
iError = ERR_CANNOT_RENAME_PARTIAL; iError = ERR_CANNOT_RENAME_PARTIAL;
@ -2404,7 +2404,7 @@ Ftp::StatusCode Ftp::ftpPut(int& iError, int iCopyFile, const KURL& dest_url,
if ( permissions != -1 ) if ( permissions != -1 )
{ {
if ( m_user == FTP_LOGIN ) if ( m_user == FTP_LOGIN )
kdDebug(7102) << "Trying to chmod over anonymous FTP ???" << endl; kdDebug(7132) << "Trying to chmod over anonymous FTP ???" << endl;
// chmod the file we just put // chmod the file we just put
if ( ! ftpChmod( dest_orig, permissions ) ) if ( ! ftpChmod( dest_orig, permissions ) )
{ {
@ -2455,7 +2455,7 @@ bool Ftp::ftpDataMode(char cMode)
else if(cMode == 'a') cMode = 'A'; else if(cMode == 'a') cMode = 'A';
else if(cMode != 'A') cMode = 'I'; else if(cMode != 'A') cMode = 'I';
kdDebug(7102) << "ftpDataMode: want '" << cMode << "' has '" << m_cDataMode << "'" << endl; kdDebug(7132) << "ftpDataMode: want '" << cMode << "' has '" << m_cDataMode << "'" << endl;
if(m_cDataMode == cMode) if(m_cDataMode == cMode)
return true; return true;
@ -2474,7 +2474,7 @@ bool Ftp::ftpFolder(const TQString& path, bool bReportError)
int iLen = newPath.length(); int iLen = newPath.length();
if(iLen > 1 && newPath[iLen-1] == '/') newPath.truncate(iLen-1); if(iLen > 1 && newPath[iLen-1] == '/') newPath.truncate(iLen-1);
//kdDebug(7102) << "ftpFolder: want '" << newPath << "' has '" << m_currentPath << "'" << endl; //kdDebug(7132) << "ftpFolder: want '" << newPath << "' has '" << m_currentPath << "'" << endl;
if(m_currentPath == newPath) if(m_currentPath == newPath)
return true; return true;
@ -2510,14 +2510,14 @@ void Ftp::copy( const KURL &src, const KURL &dest, int permissions, bool overwri
if(bSrcLocal && !bDestLocal) // File -> Ftp if(bSrcLocal && !bDestLocal) // File -> Ftp
{ {
sCopyFile = src.path(); sCopyFile = src.path();
kdDebug(7102) << "Ftp::copy local file '" << sCopyFile << "' -> ftp '" << dest.path() << "'" << endl; kdDebug(7132) << "Ftp::copy local file '" << sCopyFile << "' -> ftp '" << dest.path() << "'" << endl;
cs = ftpCopyPut(iError, iCopyFile, sCopyFile, dest, permissions, overwrite); cs = ftpCopyPut(iError, iCopyFile, sCopyFile, dest, permissions, overwrite);
if( cs == statusServerError) sCopyFile = dest.url(); if( cs == statusServerError) sCopyFile = dest.url();
} }
else if(!bSrcLocal && bDestLocal) // Ftp -> File else if(!bSrcLocal && bDestLocal) // Ftp -> File
{ {
sCopyFile = dest.path(); sCopyFile = dest.path();
kdDebug(7102) << "Ftp::copy ftp '" << src.path() << "' -> local file '" << sCopyFile << "'" << endl; kdDebug(7132) << "Ftp::copy ftp '" << src.path() << "' -> local file '" << sCopyFile << "'" << endl;
cs = ftpCopyGet(iError, iCopyFile, sCopyFile, src, permissions, overwrite); cs = ftpCopyGet(iError, iCopyFile, sCopyFile, src, permissions, overwrite);
if( cs == statusServerError ) sCopyFile = src.url(); if( cs == statusServerError ) sCopyFile = src.url();
} }
@ -2644,14 +2644,14 @@ Ftp::StatusCode Ftp::ftpCopyGet(int& iError, int& iCopyFile, const TQString sCop
iError = ERR_CANNOT_RESUME; iError = ERR_CANNOT_RESUME;
return statusClientError; // client side error return statusClientError; // client side error
} }
kdDebug(7102) << "copy: resuming at " << hCopyOffset << endl; kdDebug(7132) << "copy: resuming at " << hCopyOffset << endl;
} }
else else
iCopyFile = KDE_open(sPart.data(), O_CREAT | O_TRUNC | O_WRONLY, initialMode); iCopyFile = KDE_open(sPart.data(), O_CREAT | O_TRUNC | O_WRONLY, initialMode);
if(iCopyFile == -1) if(iCopyFile == -1)
{ {
kdDebug(7102) << "copy: ### COULD NOT WRITE " << sCopyFile << endl; kdDebug(7132) << "copy: ### COULD NOT WRITE " << sCopyFile << endl;
iError = (errno == EACCES) ? ERR_WRITE_ACCESS_DENIED iError = (errno == EACCES) ? ERR_WRITE_ACCESS_DENIED
: ERR_CANNOT_OPEN_FOR_WRITING; : ERR_CANNOT_OPEN_FOR_WRITING;
return statusClientError; return statusClientError;
@ -2672,7 +2672,7 @@ Ftp::StatusCode Ftp::ftpCopyGet(int& iError, int& iCopyFile, const TQString sCop
{ // rename ".part" on success { // rename ".part" on success
if ( ::rename( sPart.data(), sDest.data() ) ) if ( ::rename( sPart.data(), sDest.data() ) )
{ {
kdDebug(7102) << "copy: cannot rename " << sPart << " to " << sDest << endl; kdDebug(7132) << "copy: cannot rename " << sPart << " to " << sDest << endl;
iError = ERR_CANNOT_RENAME_PARTIAL; iError = ERR_CANNOT_RENAME_PARTIAL;
iRes = statusClientError; iRes = statusClientError;
} }

Loading…
Cancel
Save