summaryrefslogtreecommitdiffstats
path: root/kftpgrabber/src/engine/ftpsocket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kftpgrabber/src/engine/ftpsocket.cpp')
-rw-r--r--kftpgrabber/src/engine/ftpsocket.cpp140
1 files changed, 70 insertions, 70 deletions
diff --git a/kftpgrabber/src/engine/ftpsocket.cpp b/kftpgrabber/src/engine/ftpsocket.cpp
index b0cb9ae..dce9f99 100644
--- a/kftpgrabber/src/engine/ftpsocket.cpp
+++ b/kftpgrabber/src/engine/ftpsocket.cpp
@@ -44,11 +44,11 @@
#include "misc/kftpotpgenerator.h"
#include "misc/config.h"
-#include <qdir.h>
+#include <ntqdir.h>
-#include <klocale.h>
+#include <tdelocale.h>
#include <kstandarddirs.h>
-#include <ksocketdevice.h>
+#include <tdesocketdevice.h>
#include <utime.h>
#include <stdlib.h>
@@ -133,15 +133,15 @@ void FtpSocket::poll()
}
// Check for timeouts
- // NOTE This should be moved to a QTimer's slot when ported to Qt 4
+ // NOTE This should be moved to a TQTimer's slot when ported to TQt 4
timeoutCheck();
keepaliveCheck();
}
void FtpSocket::slotControlTryRead()
{
- QString tmpStr;
- Q_LONG size = 0;
+ TQString tmpStr;
+ TQ_LONG size = 0;
// Read what we can
if (getConfigInt("ssl") && m_controlSsl) {
@@ -178,8 +178,8 @@ void FtpSocket::processBuffer()
// Parse any lines we might have
int pos;
while ((pos = m_buffer.find('\n')) > -1) {
- QString line = m_buffer.mid(0, pos);
- line = m_remoteEncoding->decode(QCString(line.ascii()));
+ TQString line = m_buffer.mid(0, pos);
+ line = m_remoteEncoding->decode(TQCString(line.ascii()));
parseLine(line);
// Remove what we just parsed
@@ -187,7 +187,7 @@ void FtpSocket::processBuffer()
}
}
-void FtpSocket::parseLine(const QString &line)
+void FtpSocket::parseLine(const TQString &line)
{
// Is this the end of multiline response ?
if (!m_multiLineCode.isEmpty() && line.left(4) == m_multiLineCode) {
@@ -210,9 +210,9 @@ void FtpSocket::parseLine(const QString &line)
nextCommand();
}
-bool FtpSocket::isResponse(const QString &code)
+bool FtpSocket::isResponse(const TQString &code)
{
- QString ref;
+ TQString ref;
if (isMultiline())
ref = m_multiLineCode;
@@ -222,10 +222,10 @@ bool FtpSocket::isResponse(const QString &code)
return ref.left(code.length()) == code;
}
-void FtpSocket::sendCommand(const QString &command)
+void FtpSocket::sendCommand(const TQString &command)
{
emitEvent(Event::EventCommand, command);
- QCString buffer(m_remoteEncoding->encode(command) + "\r\n");
+ TQCString buffer(m_remoteEncoding->encode(command) + "\r\n");
if (getConfigInt("ssl") && m_controlSsl)
m_controlSsl->write(buffer.data(), buffer.length());
@@ -340,7 +340,7 @@ public:
if (socket()->isResponse("331 Response to otp-") ||
socket()->isResponse("331 Response to s/key")) {
// OTP: 331 Response to otp-md5 41 or4828 ext required for foo.
- QString tmp = socket()->getResponse();
+ TQString tmp = socket()->getResponse();
tmp = tmp.section(' ', 3, 5);
KFTPOTPGenerator otp(tmp, socket()->getCurrentUrl().pass());
@@ -392,7 +392,7 @@ public:
}
case SentPbsz: {
currentState = SentProt;
- QString prot = "PROT ";
+ TQString prot = "PROT ";
if (socket()->getConfigInt("ssl.prot_mode") == 0)
prot.append('P');
@@ -430,7 +430,7 @@ public:
// Parse the current working directory
if (socket()->isResponse("2")) {
// 257 "/home/default/path"
- QString tmp = socket()->getResponse();
+ TQString tmp = socket()->getResponse();
int first = tmp.find('"') + 1;
tmp = tmp.mid(first, tmp.findRev('"') - first);
@@ -453,7 +453,7 @@ public:
void parseFeat()
{
- QString feat = socket()->getResponse().stripWhiteSpace().upper();
+ TQString feat = socket()->getResponse().stripWhiteSpace().upper();
if (feat.left(3).toInt() > 0 && feat[3] == '-')
feat.remove(0, 4);
@@ -492,7 +492,7 @@ void FtpSocket::protoConnect(const KURL &url)
// Start the connect procedure
m_controlConnecting = true;
setCurrentUrl(url);
- KNetwork::KStreamSocket::connect(url.host(), QString::number(url.port()));
+ KNetwork::KStreamSocket::connect(url.host(), TQString::number(url.port()));
}
void FtpSocket::slotConnected()
@@ -618,7 +618,7 @@ public:
currentState = SentType;
socket()->resetTransferStart();
- QString type = "TYPE ";
+ TQString type = "TYPE ";
type.append(socket()->getConfigInt("params.data_type"));
socket()->sendCommand(type);
break;
@@ -673,7 +673,7 @@ public:
// We have the connection
if (socket()->getConfigInt("params.data_rest_do")) {
currentState = SentRest;
- socket()->sendCommand("REST " + QString::number(socket()->getConfigFs("params.data_rest")));
+ socket()->sendCommand("REST " + TQString::number(socket()->getConfigFs("params.data_rest")));
} else {
currentState = SentDataCmd;
socket()->sendCommand(socket()->getConfig("params.data_command"));
@@ -771,7 +771,7 @@ public:
// We have the address, let's setup the transfer socket and then
// we are done.
currentState = HaveConnection;
- socket()->setupPassiveTransferSocket(QString::null, port);
+ socket()->setupPassiveTransferSocket(TQString::null, port);
} else {
// Just send the EPSV command
currentState = NegotiateEpsv;
@@ -810,7 +810,7 @@ public:
}
// Convert to string
- QString host;
+ TQString host;
int port;
host.sprintf("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
@@ -856,19 +856,19 @@ public:
// Setup the socket and set the apropriate port command
currentState = NegotiateActive;
- KNetwork::KSocketAddress address = socket()->setupActiveTransferSocket();
+ KNetwork::TDESocketAddress address = socket()->setupActiveTransferSocket();
if (address.address()) {
if (socket()->getConfigInt("feat.eprt")) {
- QString ianaFamily = QString::number(address.ianaFamily());
+ TQString ianaFamily = TQString::number(address.ianaFamily());
socket()->sendCommand("EPRT |" + ianaFamily + "|" + address.nodeName() + "|" + address.serviceName() + "|");
} else if (address.ianaFamily() == 1) {
- QString format = address.nodeName().replace(".", ",");
+ TQString format = address.nodeName().replace(".", ",");
format.append(",");
- format.append(QString::number((unsigned char) address.address()->sa_data[0]));
+ format.append(TQString::number((unsigned char) address.address()->sa_data[0]));
format.append(",");
- format.append(QString::number((unsigned char) address.address()->sa_data[1]));
+ format.append(TQString::number((unsigned char) address.address()->sa_data[1]));
socket()->sendCommand("PORT " + format);
} else {
@@ -902,10 +902,10 @@ void FtpSocket::initializeTransferSocket()
m_transferSocket->setAddressReuseable(true);
}
-void FtpSocket::setupPassiveTransferSocket(const QString &host, int port)
+void FtpSocket::setupPassiveTransferSocket(const TQString &host, int port)
{
// Use the host from control connection if empty
- QString realHost = host;
+ TQString realHost = host;
if (host.isEmpty() || getConfigInt("pasv.use_site_ip"))
realHost = peerAddress().nodeName();
@@ -916,13 +916,13 @@ void FtpSocket::setupPassiveTransferSocket(const QString &host, int port)
m_transferSocket = new KNetwork::KStreamSocket();
initializeTransferSocket();
- m_transferSocket->connect(realHost, QString::number(port));
+ m_transferSocket->connect(realHost, TQString::number(port));
}
-KNetwork::KSocketAddress FtpSocket::setupActiveTransferSocket()
+KNetwork::TDESocketAddress FtpSocket::setupActiveTransferSocket()
{
if (!m_serverSocket)
- m_serverSocket = new KNetwork::KServerSocket();
+ m_serverSocket = new KNetwork::TDEServerSocket();
m_serverSocket->setAcceptBuffered(false);
m_serverSocket->setFamily(KNetwork::KResolver::InetFamily);
@@ -934,10 +934,10 @@ KNetwork::KSocketAddress FtpSocket::setupActiveTransferSocket()
unsigned int min = KFTPCore::Config::activeMinPort();
for (unsigned int port = min + rand() % (max - min + 1); port <= max; port++) {
- m_serverSocket->setAddress(QString::number(port));
+ m_serverSocket->setAddress(TQString::number(port));
bool success = m_serverSocket->listen();
- if (found = (success && m_serverSocket->error() == KSocketBase::NoError))
+ if (found = (success && m_serverSocket->error() == TDESocketBase::NoError))
break;
m_serverSocket->close();
@@ -946,7 +946,7 @@ KNetwork::KSocketAddress FtpSocket::setupActiveTransferSocket()
if (!found) {
emitEvent(Event::EventMessage, i18n("Unable to establish a listening socket."));
resetCommandClass(Failed);
- return KNetwork::KSocketAddress();
+ return KNetwork::TDESocketAddress();
}
} else {
m_serverSocket->setAddress("0");
@@ -954,16 +954,16 @@ KNetwork::KSocketAddress FtpSocket::setupActiveTransferSocket()
if (!m_serverSocket->listen()) {
emitEvent(Event::EventMessage, i18n("Unable to establish a listening socket."));
resetCommandClass(Failed);
- return KNetwork::KSocketAddress();
+ return KNetwork::TDESocketAddress();
}
}
- KNetwork::KSocketAddress serverAddr = m_serverSocket->localAddress();
- KNetwork::KSocketAddress controlAddr = localAddress();
- KNetwork::KSocketAddress request;
+ KNetwork::TDESocketAddress serverAddr = m_serverSocket->localAddress();
+ KNetwork::TDESocketAddress controlAddr = localAddress();
+ KNetwork::TDESocketAddress request;
if (KFTPCore::Config::portForceIp() && !getConfigInt("active.no_force_ip")) {
- QString remoteIp = peerAddress().nodeName();
+ TQString remoteIp = peerAddress().nodeName();
if (KFTPCore::Config::ignoreExternalIpForLan() &&
(remoteIp.startsWith("192.168.") || remoteIp.startsWith("10.") || remoteIp.startsWith("172.16."))) {
@@ -1069,7 +1069,7 @@ void FtpSocket::slotDataConnected()
nextCommand();
}
-void FtpSocket::variableBufferUpdate(Q_LONG size)
+void FtpSocket::variableBufferUpdate(TQ_LONG size)
{
if (size > m_transferBufferSize - 64) {
if (m_transferBufferSize + 512 <= 32768) {
@@ -1113,10 +1113,10 @@ void FtpSocket::slotDataTryWrite()
return;
}
- QFile::Offset tmpOffset = getTransferFile()->at();
- Q_LONG readSize = getTransferFile()->readBlock(m_transferBuffer, m_transferBufferSize);
+ TQFile::Offset tmpOffset = getTransferFile()->at();
+ TQ_LONG readSize = getTransferFile()->readBlock(m_transferBuffer, m_transferBufferSize);
- Q_LONG size = 0;
+ TQ_LONG size = 0;
if (m_dataSsl)
size = m_dataSsl->write(m_transferBuffer, readSize);
@@ -1163,7 +1163,7 @@ void FtpSocket::slotDataTryRead()
m_transferBuffer = (char*) realloc(m_transferBuffer, m_transferBufferSize);
}
- Q_LONG size = 0;
+ TQ_LONG size = 0;
if (m_dataSsl) {
size = m_dataSsl->read(m_transferBuffer, m_transferBufferSize);
@@ -1208,7 +1208,7 @@ void FtpSocket::slotDataTryRead()
break;
}
default: {
- qDebug("WARNING: slotDataReadActivity called for an invalid command!");
+ tqDebug("WARNING: slotDataReadActivity called for an invalid command!");
return;
}
}
@@ -1232,7 +1232,7 @@ public:
ENGINE_STANDARD_COMMAND_CONSTRUCTOR(FtpCommandList, FtpSocket, CmdList)
- QString path;
+ TQString path;
void process()
{
@@ -1312,7 +1312,7 @@ public:
return;
} else if (socket()->isMultiline()) {
// Some servers put the response code into the multiline reply
- QString response = socket()->getResponse();
+ TQString response = socket()->getResponse();
if (response.left(3) == "211")
response = response.mid(4);
@@ -1408,7 +1408,7 @@ public:
} else {
// Parse MDTM response
struct tm dt = {0,0,0,0,0,0,0,0,0,0,0};
- QString tmp(socket()->getResponse());
+ TQString tmp(socket()->getResponse());
tmp.remove(0, 4);
dt.tm_year = tmp.left(4).toInt() - 1900;
@@ -1422,12 +1422,12 @@ public:
}
// Check if the local file exists and stat the remote file if so
- if (QDir::root().exists(destinationFile.path())) {
+ if (TQDir::root().exists(destinationFile.path())) {
socket()->protoStat(sourceFile);
currentState = StatDone;
return;
} else {
- KStandardDirs::makeDir(destinationFile.directory());
+ TDEStandardDirs::makeDir(destinationFile.directory());
// Don't break so we will get on to initiating the data connection
}
@@ -1556,9 +1556,9 @@ public:
ENGINE_STANDARD_COMMAND_CONSTRUCTOR(FtpCommandCwd, FtpSocket, CmdNone)
- QString targetDirectory;
- QString currentPathPart;
- QString cached;
+ TQString targetDirectory;
+ TQString currentPathPart;
+ TQString cached;
int currentPart;
int numParts;
bool shouldCreate;
@@ -1626,7 +1626,7 @@ public:
case SentPwd: {
// Parse the current working directory
if (socket()->isResponse("2")) {
- QString tmp = socket()->getResponse();
+ TQString tmp = socket()->getResponse();
int first = tmp.find('"') + 1;
tmp = tmp.mid(first, tmp.findRev('"') - first);
@@ -1674,7 +1674,7 @@ public:
}
};
-void FtpSocket::changeWorkingDirectory(const QString &path, bool shouldCreate)
+void FtpSocket::changeWorkingDirectory(const TQString &path, bool shouldCreate)
{
// Set the path to cwd to
setConfig("params.cwd.path", path);
@@ -1721,7 +1721,7 @@ public:
fetchedSize = false;
// Check if the local file exists
- if (!QDir::root().exists(sourceFile.path())) {
+ if (!TQDir::root().exists(sourceFile.path())) {
socket()->emitError(FileNotFound);
socket()->resetCommandClass(Failed);
return;
@@ -1898,8 +1898,8 @@ public:
ENGINE_STANDARD_COMMAND_CONSTRUCTOR(FtpCommandRemove, FtpSocket, CmdNone)
- QString destinationPath;
- QString parentDirectory;
+ TQString destinationPath;
+ TQString parentDirectory;
void process()
{
@@ -1982,8 +1982,8 @@ public:
ENGINE_STANDARD_COMMAND_CONSTRUCTOR(FtpCommandRename, FtpSocket, CmdRename)
- QString sourcePath;
- QString destinationPath;
+ TQString sourcePath;
+ TQString destinationPath;
void process()
{
@@ -2053,7 +2053,7 @@ public:
case None: {
currentState = SentChmod;
- QString chmod;
+ TQString chmod;
chmod.sprintf("SITE CHMOD %.3d %s", socket()->getConfigInt("params.chmod.mode"),
socket()->getConfig("params.chmod.path").ascii());
socket()->sendCommand(chmod);
@@ -2140,7 +2140,7 @@ public:
ENGINE_STANDARD_COMMAND_CONSTRUCTOR(FtpCommandRaw, FtpSocket, CmdRaw)
- QString response;
+ TQString response;
void process()
{
@@ -2163,7 +2163,7 @@ public:
}
};
-void FtpSocket::protoRaw(const QString &raw)
+void FtpSocket::protoRaw(const TQString &raw)
{
setConfig("params.raw.command", raw);
activateCommandClass(FtpCommandRaw);
@@ -2346,7 +2346,7 @@ public:
// Change type
currentState = SourceSentType;
- QString type = "TYPE ";
+ TQString type = "TYPE ";
type.append(KFTPCore::Config::self()->ftpMode(sourceFile.path()));
socket()->sendCommand(type);
break;
@@ -2452,7 +2452,7 @@ public:
if (!socket()->isResponse("2")) {
socket()->resetCommandClass(Failed);
} else {
- QString tmp = socket()->getResponse();
+ TQString tmp = socket()->getResponse();
int pos = tmp.find('(') + 1;
tmp = tmp.mid(pos, tmp.find(')') - pos);
@@ -2464,7 +2464,7 @@ public:
}
case SourceDoRest: {
currentState = SourceSentRest;
- socket()->sendCommand("REST " + QString::number(resumeOffset));
+ socket()->sendCommand("REST " + TQString::number(resumeOffset));
break;
}
case SourceSentRest: {
@@ -2499,7 +2499,7 @@ public:
if (socket()->getConfigInt("params.fxp.changed_prot")) {
currentState = SourceResetProt;
- QString prot = "PROT ";
+ TQString prot = "PROT ";
if (socket()->getConfigInt("ssl.prot_mode") == 0)
prot.append('P');
@@ -2554,7 +2554,7 @@ public:
case DestDoType: {
currentState = DestSentType;
- QString type = "TYPE ";
+ TQString type = "TYPE ";
type.append(KFTPCore::Config::self()->ftpMode(sourceFile.path()));
socket()->sendCommand(type);
break;
@@ -2666,7 +2666,7 @@ public:
if (socket()->getConfigInt("params.fxp.changed_prot")) {
currentState = DestResetProt;
- QString prot = "PROT ";
+ TQString prot = "PROT ";
if (socket()->getConfigInt("ssl.prot_mode") == 0)
prot.append('P');