Use dedicated kdDebug area.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/6/head
Michele Calgaro 3 years ago
parent d2794cd731
commit 549de5308f
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -142,7 +142,7 @@ int kdemain( int argc, char **argv )
TDEInstance instance( "tdeio_ftp" );
( void ) TDEGlobal::locale();
kdDebug(7102) << "Starting " << getpid() << endl;
kdDebug(7132) << "Starting " << getpid() << endl;
if (argc != 4)
{
@ -153,7 +153,7 @@ int kdemain( int argc, char **argv )
Ftp slave(argv[1], argv[2], argv[3]);
slave.dispatchLoop();
kdDebug(7102) << "Done" << endl;
kdDebug(7132) << "Done" << endl;
return 0;
}
@ -224,12 +224,12 @@ int FtpTextReader::textRead(FtpSocket *pSock)
//===============================================================================
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
{
kdError(7102) << m_pszName << ": " << pszMsg << endl;
kdError(7132) << m_pszName << ": " << pszMsg << endl;
return iErrorCode;
}
@ -312,13 +312,13 @@ Ftp::Ftp( const TQCString &prot, const TQCString &pool, const TQCString &app )
// init other members
m_port = 0;
kdDebug(7102) << "Ftp::Ftp()" << endl;
kdDebug(7132) << "Ftp::Ftp()" << endl;
}
Ftp::~Ftp()
{
kdDebug(7102) << "Ftp::~Ftp()" << endl;
kdDebug(7132) << "Ftp::~Ftp()" << endl;
closeConnection();
}
@ -387,9 +387,9 @@ const char* Ftp::ftpResponse(int iOffset)
iMore = 0;
if(iMore != 0)
kdDebug(7102) << " > " << pTxt << endl;
kdDebug(7132) << " > " << pTxt << endl;
} while(iMore != 0);
kdDebug(7102) << "resp> " << pTxt << endl;
kdDebug(7132) << "resp> " << pTxt << endl;
m_iRespType = (m_iRespCode > 0) ? m_iRespCode / 100 : 0;
}
@ -404,18 +404,18 @@ const char* Ftp::ftpResponse(int iOffset)
void Ftp::closeConnection()
{
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
{
kdWarning(7102) << "Ftp::closeConnection Abandoned data stream" << endl;
kdWarning(7132) << "Ftp::closeConnection Abandoned data stream" << endl;
ftpCloseDataConnection();
}
if(m_bLoggedOn) // send quit
{
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 ...
@ -426,7 +426,7 @@ void Ftp::closeConnection()
void Ftp::setHost( const TQString& _host, int _port, const TQString& _user,
const TQString& _pass )
{
kdDebug(7102) << "Ftp::setHost (" << getpid() << "): " << _host << endl;
kdDebug(7132) << "Ftp::setHost (" << getpid() << "): " << _host << endl;
m_proxyURL = metaData("UseProxy");
m_bUseProxy = (m_proxyURL.isValid() && m_proxyURL.protocol() == m_prot);
@ -455,7 +455,7 @@ bool Ftp::ftpOpenConnection (LoginMode loginMode)
return true;
}
kdDebug(7102) << "ftpOpenConnection " << m_host << ":" << m_port << " "
kdDebug(7132) << "ftpOpenConnection " << m_host << ":" << m_port << " "
<< m_user << " [password hidden]" << endl;
infoMessage( i18n("Opening connection to host %1").arg(m_host) );
@ -618,7 +618,7 @@ bool Ftp::ftpLogin()
if ( failedAuth > 0 || (!user.isEmpty() && pass.isEmpty()) )
{
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!
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 needPass = (m_iRespCode == 331);
@ -672,7 +672,7 @@ bool Ftp::ftpLogin()
// get back a "230" or "331".
if ( !loggedIn && !needPass )
{
kdDebug(7102) << "Login failed: " << ftpResponse(0) << endl;
kdDebug(7132) << "Login failed: " << ftpResponse(0) << endl;
++failedAuth;
continue; // Well we failed, prompt the user please!!
}
@ -681,7 +681,7 @@ bool Ftp::ftpLogin()
{
tempbuf = "pass ";
tempbuf += pass.latin1();
kdDebug(7102) << "Sending Login password: " << "[protected]" << endl;
kdDebug(7132) << "Sending Login password: " << "[protected]" << endl;
loggedIn = ( ftpSendCmd(tempbuf) && (m_iRespCode == 230) );
}
@ -696,7 +696,7 @@ bool Ftp::ftpLogin()
} while( ++failedAuth );
kdDebug(7102) << "Login OK" << endl;
kdDebug(7132) << "Login OK" << endl;
infoMessage( i18n("Login OK") );
// Okay, we're logged in. If this is IIS 4, switch dir listing style to Unix:
@ -716,16 +716,16 @@ bool Ftp::ftpLogin()
}
}
else
kdWarning(7102) << "syst failed" << endl;
kdWarning(7132) << "syst failed" << endl;
if ( config()->readBoolEntry ("EnableAutoLoginMacro") )
ftpAutoLoginMacro ();
// Get the current working directory
kdDebug(7102) << "Searching for pwd" << endl;
kdDebug(7132) << "Searching for pwd" << endl;
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 ?
return false;
}
@ -737,7 +737,7 @@ bool Ftp::ftpLogin()
{
m_initialPath = sTmp.mid(iBeg+1, iEnd-iBeg-1);
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;
}
return true;
@ -789,7 +789,7 @@ bool Ftp::ftpSendCmd( const TQCString& cmd, int maxretries )
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;
error( ERR_UNSUPPORTED_ACTION, m_host );
return false;
@ -798,9 +798,9 @@ bool Ftp::ftpSendCmd( const TQCString& cmd, int maxretries )
// Don't print out the password...
bool isPassCmd = (cmd.left(4).lower() == "pass");
if ( !isPassCmd )
kdDebug(7102) << "send> " << cmd.data() << endl;
kdDebug(7132) << "send> " << cmd.data() << endl;
else
kdDebug(7102) << "send> pass [protected]" << endl;
kdDebug(7132) << "send> pass [protected]" << endl;
// Send the message...
TQCString buf = cmd;
@ -843,7 +843,7 @@ bool Ftp::ftpSendCmd( const TQCString& cmd, int maxretries )
return false;
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;
closeConnection(); // Close the old connection...
@ -853,14 +853,14 @@ bool Ftp::ftpSendCmd( const TQCString& cmd, int maxretries )
{
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);
closeConnection ();
}
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 (maxretries)
@ -900,11 +900,11 @@ int Ftp::ftpOpenPASVDataConnection()
/* Let's PASsiVe*/
if( !ftpSendCmd("PASV") || (m_iRespType != 2) )
{
kdDebug(7102) << "PASV attempt failed" << endl;
kdDebug(7132) << "PASV attempt failed" << endl;
// unknown command?
if( m_iRespType == 5 )
{
kdDebug(7102) << "disabling use of PASV" << endl;
kdDebug(7132) << "disabling use of PASV" << endl;
m_extControl |= pasvUnknown;
}
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 ) )
{
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;
}
@ -934,7 +934,7 @@ int Ftp::ftpOpenPASVDataConnection()
// now connect the data socket ...
m_data = new FtpSocket("PASV");
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);
}
@ -961,7 +961,7 @@ int Ftp::ftpOpenEPSVDataConnection()
// unknown command?
if( m_iRespType == 5 )
{
kdDebug(7102) << "disabling use of EPSV" << endl;
kdDebug(7132) << "disabling use of EPSV" << endl;
m_extControl |= epsvUnknown;
}
return ERR_INTERNAL;
@ -1019,7 +1019,7 @@ int Ftp::ftpOpenEPRTDataConnection()
// unknown command?
if( m_iRespType == 5 )
{
kdDebug(7102) << "disabling use of EPRT" << endl;
kdDebug(7132) << "disabling use of EPRT" << endl;
m_extControl |= eprtUnknown;
}
return ERR_INTERNAL;
@ -1262,12 +1262,12 @@ bool Ftp::ftpCloseCommand()
if(!m_bBusy)
return true;
kdDebug(7102) << "ftpCloseCommand: reading command result" << endl;
kdDebug(7132) << "ftpCloseCommand: reading command result" << endl;
m_bBusy = false;
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 true;
@ -1382,7 +1382,7 @@ bool Ftp::ftpChmod( const TQString & path, int permissions )
if(m_iRespCode == 500)
{
m_extControl |= chmodUnknown;
kdDebug(7102) << "ftpChmod: CHMOD not supported - disabling";
kdDebug(7132) << "ftpChmod: CHMOD not supported - disabling";
}
return false;
}
@ -1442,7 +1442,7 @@ void Ftp::ftpCreateUDSEntry( const TQString & filename, FtpEntry& ftpEnt, UDSEnt
// --> we do better than Netscape :-)
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_str = "inode/directory";
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 the file doesn't exist.
TQString statSide = metaData("statSide");
kdDebug(7102) << "Ftp::stat statSide=" << statSide << endl;
kdDebug(7132) << "Ftp::stat statSide=" << statSide << endl;
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
// 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)
{
kdDebug(7102) << "Ftp::stat : path='" << url.path() << "'" << endl;
kdDebug(7132) << "Ftp::stat : path='" << url.path() << "'" << endl;
if( !ftpOpenConnection(loginImplicit) )
return;
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.
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
TQString sDetails = metaData("details");
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 ( !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 ) )
{
kdError(7102) << "COULD NOT LIST" << endl;
kdError(7132) << "COULD NOT LIST" << endl;
return;
}
kdDebug(7102) << "Starting of list was ok" << endl;
kdDebug(7132) << "Starting of list was ok" << endl;
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
// Follow it and try again
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
{
linkURL = url;
kdDebug(7102) << "ftpEnt.link=" << ftpEnt.link << endl;
kdDebug(7132) << "ftpEnt.link=" << ftpEnt.link << endl;
if ( ftpEnt.link[0] == '/' )
linkURL.setPath( ftpEnt.link ); // Absolute link
else
@ -1669,7 +1669,7 @@ void Ftp::stat( const KURL &url)
linkURL.setPath( listarg ); // this is what we were listing (the link)
linkURL.setPath( linkURL.directory() ); // go up one dir
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
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
@ -1700,14 +1700,14 @@ void Ftp::stat( const KURL &url)
return;
}
kdDebug(7102) << "stat : finished successfully" << endl;
kdDebug(7132) << "stat : finished successfully" << endl;
finished();
}
void Ftp::listDir( const KURL &url )
{
kdDebug(7102) << "Ftp::listDir " << url.prettyURL() << endl;
kdDebug(7132) << "Ftp::listDir " << url.prettyURL() << endl;
if( !ftpOpenConnection(loginImplicit) )
return;
@ -1727,13 +1727,13 @@ void Ftp::listDir( const KURL &url )
if ( m_initialPath.isEmpty() )
m_initialPath = "/";
realURL.setPath( m_initialPath );
kdDebug(7102) << "REDIRECTION to " << realURL.prettyURL() << endl;
kdDebug(7132) << "REDIRECTION to " << realURL.prettyURL() << endl;
redirection( realURL );
finished();
return;
}
kdDebug(7102) << "hunting for path '" << path << "'" << endl;
kdDebug(7132) << "hunting for path '" << path << "'" << endl;
if (!ftpOpenDir( path ) )
{
@ -1752,14 +1752,14 @@ void Ftp::listDir( const KURL &url )
FtpEntry ftpEnt;
while( ftpReadDir(ftpEnt) )
{
//kdDebug(7102) << ftpEnt.name << endl;
//kdDebug(7132) << ftpEnt.name << endl;
//Q_ASSERT( !ftpEnt.name.isEmpty() );
if ( !ftpEnt.name.isEmpty() )
{
//if ( S_ISDIR( (mode_t)ftpEnt.type ) )
// kdDebug(7102) << "is a dir" << endl;
// kdDebug(7132) << "is a dir" << endl;
//if ( !ftpEnt.link.isEmpty() )
// kdDebug(7102) << "is a link to " << ftpEnt.link << endl;
// kdDebug(7132) << "is a link to " << ftpEnt.link << endl;
entry.clear();
ftpCreateUDSEntry( ftpEnt.name, ftpEnt, entry, false );
listEntry( entry, false );
@ -1772,7 +1772,7 @@ void Ftp::listDir( const KURL &url )
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 );
}
@ -1798,11 +1798,11 @@ bool Ftp::ftpOpenDir( const TQString & path )
{
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;
}
}
kdDebug(7102) << "Starting of list was ok" << endl;
kdDebug(7132) << "Starting of list was ok" << endl;
return true;
}
@ -1816,10 +1816,10 @@ bool Ftp::ftpReadDir(FtpEntry& de)
if(m_data->textRead() <= 0)
continue;
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();
kdDebug(7102) << "dir > " << buffer << endl;
kdDebug(7132) << "dir > " << buffer << endl;
//Normally the listing looks like
// -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_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;
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 :-)
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)
continue;
}
@ -1862,12 +1862,12 @@ bool Ftp::ftpReadDir(FtpEntry& de)
p_date_1 = p_size;
p_size = p_group;
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
{
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 &&
@ -1958,7 +1958,7 @@ bool Ftp::ftpReadDir(FtpEntry& de)
time_t currentTime = time( 0L );
struct tm * tmptr = gmtime( &currentTime );
int currentMonth = tmptr->tm_mon;
//kdDebug(7102) << "Current time :" << asctime( tmptr ) << endl;
//kdDebug(7132) << "Current time :" << asctime( tmptr ) << endl;
// 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_sec = 0;
@ -1969,13 +1969,13 @@ bool Ftp::ftpReadDir(FtpEntry& de)
// Get month from first field
// NOTE : no, we don't want to use TDELocale here
// 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",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
for ( int c = 0 ; c < 12 ; 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;
break;
}
@ -2003,10 +2003,10 @@ bool Ftp::ftpReadDir(FtpEntry& de)
tmptr->tm_hour = atoi( p_date_3 );
}
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 );
return true;
}
@ -2020,7 +2020,7 @@ bool Ftp::ftpReadDir(FtpEntry& de)
//===============================================================================
void Ftp::get( const KURL & url )
{
kdDebug(7102) << "Ftp::get " << url.url() << endl;
kdDebug(7132) << "Ftp::get " << url.url() << endl;
int iError = 0;
ftpGet(iError, -1, url, 0); // iError gets status
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) )
{
// 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;
return statusServerError;
}
@ -2052,12 +2052,12 @@ Ftp::StatusCode Ftp::ftpGet(int& iError, int iCopyFile, const KURL& url, TDEIO::
if ( !resumeOffset.isEmpty() )
{
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) )
{
kdWarning(7102) << "ftpGet: Can't open for reading" << endl;
kdWarning(7132) << "ftpGet: Can't open for reading" << endl;
return statusServerError;
}
@ -2072,7 +2072,7 @@ Ftp::StatusCode Ftp::ftpGet(int& iError, int iCopyFile, const KURL& url, TDEIO::
if ( m_size != UnknownSize )
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;
TQByteArray array;
@ -2124,7 +2124,7 @@ Ftp::StatusCode Ftp::ftpGet(int& iError, int iCopyFile, const KURL& url, TDEIO::
array.setRawData(buffer, n);
KMimeMagicResult * result = KMimeMagic::self()->findBufferFileType(array, url.fileName());
array.resetRawData(buffer, n);
kdDebug(7102) << "ftpGet: Emitting mimetype " << result->mimeType() << endl;
kdDebug(7132) << "ftpGet: Emitting mimetype " << result->mimeType() << endl;
mimeType( result->mimeType() );
if( m_size != UnknownSize ) // Emit total size AFTER mimetype
totalSize( m_size );
@ -2142,12 +2142,12 @@ Ftp::StatusCode Ftp::ftpGet(int& iError, int iCopyFile, const KURL& url, TDEIO::
processedSize( processed_size );
}
kdDebug(7102) << "ftpGet: done" << endl;
kdDebug(7132) << "ftpGet: done" << endl;
if(iCopyFile == -1) // must signal EOF to data pump ...
data(array); // array is empty and must be empty!
processedSize( m_size == UnknownSize ? processed_size : m_size );
kdDebug(7102) << "ftpGet: emitting finished()" << endl;
kdDebug(7132) << "ftpGet: emitting finished()" << endl;
finished();
return statusSuccess;
}
@ -2159,7 +2159,7 @@ void Ftp::mimetype( const KURL& url )
return;
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;
}
char buffer[ 2048 ];
@ -2171,12 +2171,12 @@ void Ftp::mimetype( const KURL& url )
data( array );
array.resetRawData(buffer, n);
kdDebug(7102) << "aborting" << endl;
kdDebug(7132) << "aborting" << endl;
ftpAbortTransfer();
kdDebug(7102) << "finished" << endl;
kdDebug(7132) << "finished" << endl;
finished();
kdDebug(7102) << "after finished" << endl;
kdDebug(7132) << "after finished" << endl;
}
void Ftp::ftpAbortTransfer()
@ -2197,7 +2197,7 @@ void Ftp::ftpAbortTransfer()
; // error...
// Send ABOR
kdDebug(7102) << "send ABOR" << endl;
kdDebug(7132) << "send ABOR" << endl;
TQCString buf = "ABOR\r\n";
if ( KSocks::self()->write( sControl, buf.data(), buf.length() ) <= 0 ) {
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' )
{
error( ERR_COULD_NOT_READ, TQString::null );
return;
}
kdDebug(7102) << "close sockets" << endl;
kdDebug(7132) << "close sockets" << endl;
closeSockets();
}
*/
@ -2223,7 +2223,7 @@ void Ftp::ftpAbortTransfer()
//===============================================================================
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
ftpPut(iError, -1, url, permissions, overwrite, resume);
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 ( bMarkPartial ) {
kdDebug(7102) << "Adding .part extension to " << dest_orig << endl;
kdDebug(7132) << "Adding .part extension to " << dest_orig << endl;
dest = dest_part;
} else
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 ) )
return statusServerError;
kdDebug(7102) << "ftpPut: starting with offset=" << offset << endl;
kdDebug(7132) << "ftpPut: starting with offset=" << offset << endl;
TDEIO::fileoffset_t processed_size = offset;
TQByteArray buffer;
@ -2368,7 +2368,7 @@ Ftp::StatusCode Ftp::ftpPut(int& iError, int iCopyFile, const KURL& dest_url,
if (result != 0) // error
{
ftpCloseCommand(); // don't care about errors
kdDebug(7102) << "Error during 'put'. Aborting." << endl;
kdDebug(7132) << "Error during 'put'. Aborting." << endl;
if (bMarkPartial)
{
// 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
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 ) )
{
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 ( 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
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 = 'I';
kdDebug(7102) << "ftpDataMode: want '" << cMode << "' has '" << m_cDataMode << "'" << endl;
kdDebug(7132) << "ftpDataMode: want '" << cMode << "' has '" << m_cDataMode << "'" << endl;
if(m_cDataMode == cMode)
return true;
@ -2474,7 +2474,7 @@ bool Ftp::ftpFolder(const TQString& path, bool bReportError)
int iLen = newPath.length();
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)
return true;
@ -2510,14 +2510,14 @@ void Ftp::copy( const KURL &src, const KURL &dest, int permissions, bool overwri
if(bSrcLocal && !bDestLocal) // File -> Ftp
{
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);
if( cs == statusServerError) sCopyFile = dest.url();
}
else if(!bSrcLocal && bDestLocal) // Ftp -> File
{
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);
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;
return statusClientError; // client side error
}
kdDebug(7102) << "copy: resuming at " << hCopyOffset << endl;
kdDebug(7132) << "copy: resuming at " << hCopyOffset << endl;
}
else
iCopyFile = KDE_open(sPart.data(), O_CREAT | O_TRUNC | O_WRONLY, initialMode);
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
: ERR_CANNOT_OPEN_FOR_WRITING;
return statusClientError;
@ -2672,7 +2672,7 @@ Ftp::StatusCode Ftp::ftpCopyGet(int& iError, int& iCopyFile, const TQString sCop
{ // rename ".part" on success
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;
iRes = statusClientError;
}

Loading…
Cancel
Save