summaryrefslogtreecommitdiffstats
path: root/src/modules/http/httpfiletransfer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/http/httpfiletransfer.cpp')
-rw-r--r--src/modules/http/httpfiletransfer.cpp162
1 files changed, 81 insertions, 81 deletions
diff --git a/src/modules/http/httpfiletransfer.cpp b/src/modules/http/httpfiletransfer.cpp
index 09c3b1f9..789b7a1b 100644
--- a/src/modules/http/httpfiletransfer.cpp
+++ b/src/modules/http/httpfiletransfer.cpp
@@ -35,10 +35,10 @@
#include "kvi_kvs_script.h"
#include "kvi_tal_popupmenu.h"
-#include <qpainter.h>
+#include <tqpainter.h>
static KviPointerList<KviHttpFileTransfer> * g_pHttpFileTransfers = 0;
-static QPixmap * g_pHttpIcon = 0;
+static TQPixmap * g_pHttpIcon = 0;
KviHttpFileTransfer::KviHttpFileTransfer()
@@ -58,16 +58,16 @@ KviHttpFileTransfer::KviHttpFileTransfer()
m_pHttpRequest = new KviHttpRequest();
- connect(m_pHttpRequest,SIGNAL(status(const QString &)),this,SLOT(statusMessage(const QString &)));
- connect(m_pHttpRequest,SIGNAL(terminated(bool)),this,SLOT(transferTerminated(bool)));
- connect(m_pHttpRequest,SIGNAL(header(KviPointerHashTable<const char *,KviStr> *)),this,SLOT(headersReceived(KviPointerHashTable<const char *,KviStr> *)));
- connect(m_pHttpRequest,SIGNAL(resolvingHost(const QString &)),this,SLOT(resolvingHost(const QString &)));
- connect(m_pHttpRequest,SIGNAL(requestSent(const QStringList &)),this,SLOT(requestSent(const QStringList &)));
- connect(m_pHttpRequest,SIGNAL(contactingHost(const QString &)),this,SLOT(contactingHost(const QString &)));
- connect(m_pHttpRequest,SIGNAL(receivedResponse(const QString &)),this,SLOT(receivedResponse(const QString &)));
- connect(m_pHttpRequest,SIGNAL(connectionEstabilished()),this,SLOT(connectionEstabilished()));
+ connect(m_pHttpRequest,TQT_SIGNAL(status(const TQString &)),this,TQT_SLOT(statusMessage(const TQString &)));
+ connect(m_pHttpRequest,TQT_SIGNAL(terminated(bool)),this,TQT_SLOT(transferTerminated(bool)));
+ connect(m_pHttpRequest,TQT_SIGNAL(header(KviPointerHashTable<const char *,KviStr> *)),this,TQT_SLOT(headersReceived(KviPointerHashTable<const char *,KviStr> *)));
+ connect(m_pHttpRequest,TQT_SIGNAL(resolvingHost(const TQString &)),this,TQT_SLOT(resolvingHost(const TQString &)));
+ connect(m_pHttpRequest,TQT_SIGNAL(requestSent(const TQStringList &)),this,TQT_SLOT(requestSent(const TQStringList &)));
+ connect(m_pHttpRequest,TQT_SIGNAL(contactingHost(const TQString &)),this,TQT_SLOT(contactingHost(const TQString &)));
+ connect(m_pHttpRequest,TQT_SIGNAL(receivedResponse(const TQString &)),this,TQT_SLOT(receivedResponse(const TQString &)));
+ connect(m_pHttpRequest,TQT_SIGNAL(connectionEstabilished()),this,TQT_SLOT(connectionEstabilished()));
- m_eGeneralStatus = Initializing;
+ m_eGeneraltqStatus = Initializing;
m_szStatusString = __tr2qs_ctx("Initializing","http");
}
@@ -92,7 +92,7 @@ void KviHttpFileTransfer::die()
delete this;
}
-QString KviHttpFileTransfer::localFileName()
+TQString KviHttpFileTransfer::localFileName()
{
return m_pHttpRequest->fileName();
}
@@ -104,26 +104,26 @@ void KviHttpFileTransfer::abort()
void KviHttpFileTransfer::fillContextPopup(KviTalPopupMenu * m,int column)
{
- int id = m->insertItem(__tr2qs_ctx("Abort","http"),this,SLOT(abort()));
+ int id = m->insertItem(__tr2qs_ctx("Abort","http"),this,TQT_SLOT(abort()));
if(!active())m->setItemEnabled(id,false);
}
bool KviHttpFileTransfer::active()
{
- return ((m_eGeneralStatus == Connecting) || (m_eGeneralStatus == Downloading));
+ return ((m_eGeneraltqStatus == Connecting) || (m_eGeneraltqStatus == Downloading));
}
-void KviHttpFileTransfer::displayPaint(QPainter * p,int column,int width,int height)
+void KviHttpFileTransfer::displayPaint(TQPainter * p,int column,int width,int height)
{
- QString txt;
- bool bIsTerminated = ((m_eGeneralStatus == Success) || (m_eGeneralStatus == Failure));
+ TQString txt;
+ bool bIsTerminated = ((m_eGeneraltqStatus == Success) || (m_eGeneraltqStatus == Failure));
switch(column)
{
case COLUMN_TRANSFERTYPE:
{
int offset = 0;
- switch(m_eGeneralStatus)
+ switch(m_eGeneraltqStatus)
{
case Initializing: offset = 0; break;
case Connecting: offset = 0; break;
@@ -136,53 +136,53 @@ void KviHttpFileTransfer::displayPaint(QPainter * p,int column,int width,int hei
break;
case COLUMN_FILEINFO:
{
- QFontMetrics fm(p->font());
+ TQFontMetrics fm(p->font());
- QString szFrom = __tr2qs_ctx("From: ","http");
- QString szTo = __tr2qs_ctx("To: ","http");
+ TQString szFrom = __tr2qs_ctx("From: ","http");
+ TQString szTo = __tr2qs_ctx("To: ","http");
int daW1 = fm.width(szFrom);
int daW2 = fm.width(szTo);
if(daW1 < daW2)daW1 = daW2;
int iLineSpacing = fm.lineSpacing();
- p->setPen(Qt::black);
+ p->setPen(TQt::black);
int iY = 4;
- p->drawText(4 + daW1,iY,width - (8 + daW1),height - 8,Qt::AlignTop | Qt::AlignLeft,m_pHttpRequest->url().url().ptr());
+ p->drawText(4 + daW1,iY,width - (8 + daW1),height - 8,TQt::AlignTop | TQt::AlignLeft,m_pHttpRequest->url().url().ptr());
iY += iLineSpacing;
if(!(m_pHttpRequest->fileName().isEmpty()))
{
- p->drawText(4 + daW1,iY,width - (8 + daW1),height - 8,Qt::AlignTop | Qt::AlignLeft,m_pHttpRequest->fileName());
+ p->drawText(4 + daW1,iY,width - (8 + daW1),height - 8,TQt::AlignTop | TQt::AlignLeft,m_pHttpRequest->fileName());
}
iY += iLineSpacing;
- p->setPen(Qt::darkGray);
+ p->setPen(TQt::darkGray);
- p->drawText(4,4,width - 8,height - 8,Qt::AlignTop | Qt::AlignLeft,szFrom);
- p->drawText(4,4 + iLineSpacing,width - 8,height - 8,Qt::AlignTop | Qt::AlignLeft,szTo);
+ p->drawText(4,4,width - 8,height - 8,TQt::AlignTop | TQt::AlignLeft,szFrom);
+ p->drawText(4,4 + iLineSpacing,width - 8,height - 8,TQt::AlignTop | TQt::AlignLeft,szTo);
- p->setPen(QColor(180,180,200));
+ p->setPen(TQColor(180,180,200));
iLineSpacing += 2;
p->drawRect(4,height - (iLineSpacing + 4),width - 8,iLineSpacing);
- p->fillRect(5,height - (iLineSpacing + 3),width - 10,iLineSpacing - 2,bIsTerminated ? QColor(210,210,210) : QColor(190,190,240));
- p->setPen(Qt::black);
- p->drawText(7,height - (iLineSpacing + 4),width - 14,iLineSpacing,Qt::AlignVCenter | Qt::AlignLeft,m_szStatusString);
+ p->fillRect(5,height - (iLineSpacing + 3),width - 10,iLineSpacing - 2,bIsTerminated ? TQColor(210,210,210) : TQColor(190,190,240));
+ p->setPen(TQt::black);
+ p->drawText(7,height - (iLineSpacing + 4),width - 14,iLineSpacing,TQt::AlignVCenter | TQt::AlignLeft,m_szStatusString);
}
break;
case COLUMN_PROGRESS:
{
- QFontMetrics fm(p->font());
+ TQFontMetrics fm(p->font());
unsigned int uTotal = m_pHttpRequest->totalSize();
unsigned int uRecvd = m_pHttpRequest->receivedSize();
int iW = width - 8;
- p->setPen(bIsTerminated ? Qt::lightGray : QColor(210,210,240));
+ p->setPen(bIsTerminated ? TQt::lightGray : TQColor(210,210,240));
p->drawRect(4,4,iW,12);
int iAvgSpeed = -1;
@@ -209,17 +209,17 @@ void KviHttpFileTransfer::displayPaint(QPainter * p,int column,int width,int hei
iW -= 2;
int iL = (int) ((((double)iW) * dPerc) / 100.0);
//iR = iW - iL;
- p->fillRect(5,5,iL,10,bIsTerminated ? QColor(140,110,110) : QColor(200,100,100));
+ p->fillRect(5,5,iL,10,bIsTerminated ? TQColor(140,110,110) : TQColor(200,100,100));
- txt = QString(__tr2qs_ctx("%1 of %2 (%3 %)","http")).arg(KviQString::makeSizeReadable(uRecvd))
- .arg(KviQString::makeSizeReadable(uTotal)).arg(dPerc,0,'f',2);
+ txt = TQString(__tr2qs_ctx("%1 of %2 (%3 %)","http")).tqarg(KviTQString::makeSizeReadable(uRecvd))
+ .tqarg(KviTQString::makeSizeReadable(uTotal)).tqarg(dPerc,0,'f',2);
} else {
- txt = KviQString::makeSizeReadable(m_pHttpRequest->receivedSize());
+ txt = KviTQString::makeSizeReadable(m_pHttpRequest->receivedSize());
}
- p->setPen(Qt::black);
+ p->setPen(TQt::black);
- p->drawText(4,19,width - 8,height - 8,Qt::AlignTop | Qt::AlignLeft,txt);
+ p->drawText(4,19,width - 8,height - 8,TQt::AlignTop | TQt::AlignLeft,txt);
int iLeftHalf = (iW - 2) / 2;
int iRightHalf = iW - (iLeftHalf + 1);
@@ -230,7 +230,7 @@ void KviHttpFileTransfer::displayPaint(QPainter * p,int column,int width,int hei
txt += " ";
if(iInstantSpeed >= 0)
{
- QString tmpisp;
+ TQString tmpisp;
KviNetUtils::formatNetworkBandwidthString(tmpisp,iAvgSpeed);
txt += tmpisp;
} else {
@@ -242,7 +242,7 @@ void KviHttpFileTransfer::displayPaint(QPainter * p,int column,int width,int hei
txt += " ";
if(iAvgSpeed >= 0)
{
- QString tmpspd;
+ TQString tmpspd;
KviNetUtils::formatNetworkBandwidthString(tmpspd,iAvgSpeed);
txt += tmpspd;
} else {
@@ -253,11 +253,11 @@ void KviHttpFileTransfer::displayPaint(QPainter * p,int column,int width,int hei
int iDaH = height - (iLineSpacing + 4);
- p->setPen(QColor(180,180,200));
+ p->setPen(TQColor(180,180,200));
p->drawRect(4,iDaH,iLeftHalf,iLineSpacing);
- p->fillRect(5,iDaH + 1,iLeftHalf - 2,iLineSpacing - 2,bIsTerminated ? QColor(210,210,210) : QColor(190,190,240));
- p->setPen(bIsTerminated ? Qt::darkGray : Qt::black);
- p->drawText(6,iDaH,iLeftHalf - 4,iLineSpacing,Qt::AlignLeft | Qt::AlignVCenter,txt);
+ p->fillRect(5,iDaH + 1,iLeftHalf - 2,iLineSpacing - 2,bIsTerminated ? TQColor(210,210,210) : TQColor(190,190,240));
+ p->setPen(bIsTerminated ? TQt::darkGray : TQt::black);
+ p->drawText(6,iDaH,iLeftHalf - 4,iLineSpacing,TQt::AlignLeft | TQt::AlignVCenter,txt);
unsigned int uD,uH,uM,uS;
@@ -265,27 +265,27 @@ void KviHttpFileTransfer::displayPaint(QPainter * p,int column,int width,int hei
{
KviTimeUtils::secondsToDaysHoursMinsSecs(kvi_timeSpan(m_tTransferEndTime,m_tTransferStartTime),&uD,&uH,&uM,&uS);
txt = "TOT: ";
- if(uD > 0)txt += QString(__tr2qs_ctx("%1d %2h %3m %4s","http")).arg(uD).arg(uH).arg(uM).arg(uS);
- else if(uH > 0)txt += QString(__tr2qs_ctx("%2h %3m %4s","http")).arg(uH).arg(uM).arg(uS);
- else txt += QString(__tr2qs_ctx("%3m %4s","http")).arg(uM).arg(uS);
+ if(uD > 0)txt += TQString(__tr2qs_ctx("%1d %2h %3m %4s","http")).tqarg(uD).tqarg(uH).tqarg(uM).tqarg(uS);
+ else if(uH > 0)txt += TQString(__tr2qs_ctx("%2h %3m %4s","http")).tqarg(uH).tqarg(uM).tqarg(uS);
+ else txt += TQString(__tr2qs_ctx("%3m %4s","http")).tqarg(uM).tqarg(uS);
} else {
if(iEta >= 0)
{
KviTimeUtils::secondsToDaysHoursMinsSecs(iEta,&uD,&uH,&uM,&uS);
txt = "ETA: ";
- if(uD > 0)txt += QString(__tr2qs_ctx("%1d %2h %3m %4s","http")).arg(uD).arg(uH).arg(uM).arg(uS);
- else if(uH > 0)txt += QString(__tr2qs_ctx("%2h %3m %4s","http")).arg(uH).arg(uM).arg(uS);
- else txt += QString(__tr2qs_ctx("%3m %4s","http")).arg(uM).arg(uS);
+ if(uD > 0)txt += TQString(__tr2qs_ctx("%1d %2h %3m %4s","http")).tqarg(uD).tqarg(uH).tqarg(uM).tqarg(uS);
+ else if(uH > 0)txt += TQString(__tr2qs_ctx("%2h %3m %4s","http")).tqarg(uH).tqarg(uM).tqarg(uS);
+ else txt += TQString(__tr2qs_ctx("%3m %4s","http")).tqarg(uM).tqarg(uS);
} else {
txt = "ETA: Unknown";
}
}
- p->setPen(QColor(180,180,200));
+ p->setPen(TQColor(180,180,200));
p->drawRect(width - (4 + iRightHalf),iDaH,iRightHalf,iLineSpacing);
- p->fillRect(width - (3 + iRightHalf),iDaH + 1,iRightHalf - 2,iLineSpacing - 2,bIsTerminated ? QColor(210,210,210) : QColor(190,190,240));
- p->setPen(bIsTerminated ? Qt::darkGray : Qt::black);
- p->drawText(width - (2 + iRightHalf),iDaH,iRightHalf - 4,iLineSpacing,Qt::AlignLeft | Qt::AlignVCenter,txt);
+ p->fillRect(width - (3 + iRightHalf),iDaH + 1,iRightHalf - 2,iLineSpacing - 2,bIsTerminated ? TQColor(210,210,210) : TQColor(190,190,240));
+ p->setPen(bIsTerminated ? TQt::darkGray : TQt::black);
+ p->drawText(width - (2 + iRightHalf),iDaH,iRightHalf - 4,iLineSpacing,TQt::AlignLeft | TQt::AlignVCenter,txt);
}
break;
@@ -298,16 +298,16 @@ int KviHttpFileTransfer::displayHeight(int iLineSpacing)
return iH >= 70 ? iH : 70;
}
-QString KviHttpFileTransfer::tipText()
+TQString KviHttpFileTransfer::tipText()
{
- QString s;
- s = QString("<table><tr><td bgcolor=\"#000000\"><font color=\"#FFFFFF\"><b>HTTP Transfer (ID %1)</b></font></td></tr>").arg(id());
+ TQString s;
+ s = TQString("<table><tr><td bgcolor=\"#000000\"><font color=\"#FFFFFF\"><b>HTTP Transfer (ID %1)</b></font></td></tr>").tqarg(id());
if(m_lRequest.count() > 0)
{
s += "<tr><td bgcolor=\"#404040\"><font color=\"#FFFFFF\">Request Headers</font></td></tr>";
s += "<tr><td bgcolor=\"#C0C0C0\">";
- for(QStringList::ConstIterator it = m_lRequest.begin();it != m_lRequest.end();++it)
+ for(TQStringList::ConstIterator it = m_lRequest.begin();it != m_lRequest.end();++it)
{
s += "&nbsp; &nbsp;";
s += *it;
@@ -320,7 +320,7 @@ QString KviHttpFileTransfer::tipText()
{
s += "<tr><td bgcolor=\"#404040\"><font color=\"#FFFFFF\">Response Headers</font></td></tr>";
s += "<tr><td bgcolor=\"#C0C0C0\">";
- for(QStringList::ConstIterator it = m_lHeaders.begin();it != m_lHeaders.end();++it)
+ for(TQStringList::ConstIterator it = m_lHeaders.begin();it != m_lHeaders.end();++it)
{
s += "&nbsp; &nbsp;";
s += *it;
@@ -340,9 +340,9 @@ void KviHttpFileTransfer::init()
g_pHttpFileTransfers = new KviPointerList<KviHttpFileTransfer>;
g_pHttpFileTransfers->setAutoDelete(false);
- QPixmap * pix = g_pIconManager->getImage("kvi_httpicons.png");
- if(pix)g_pHttpIcon = new QPixmap(*pix);
- else g_pHttpIcon = new QPixmap(192,48);
+ TQPixmap * pix = g_pIconManager->getImage("kvi_httpicons.png");
+ if(pix)g_pHttpIcon = new TQPixmap(*pix);
+ else g_pHttpIcon = new TQPixmap(192,48);
}
void KviHttpFileTransfer::done()
@@ -362,7 +362,7 @@ unsigned int KviHttpFileTransfer::runningTransfers()
return g_pHttpFileTransfers->count();
}
-void KviHttpFileTransfer::requestSent(const QStringList &requestHeaders)
+void KviHttpFileTransfer::requestSent(const TQStringList &requestHeaders)
{
m_szStatusString = __tr2qs_ctx("Request sent, waiting for reply...","http");
displayUpdate();
@@ -373,7 +373,7 @@ void KviHttpFileTransfer::requestSent(const QStringList &requestHeaders)
if(!m_bNoOutput)
out->output(KVI_OUT_GENERICSTATUS,__tr2qs_ctx("[HTTP %d]: Request data sent:","http"),id());
- for(QStringList::ConstIterator it = requestHeaders.begin();it != requestHeaders.end();++it)
+ for(TQStringList::ConstIterator it = requestHeaders.begin();it != requestHeaders.end();++it)
{
if(!m_bNoOutput)
out->output(KVI_OUT_GENERICSTATUS,"[HTTP %d]: %s",id(),(*it).utf8().data());
@@ -388,29 +388,29 @@ void KviHttpFileTransfer::connectionEstabilished()
displayUpdate();
}
-void KviHttpFileTransfer::resolvingHost(const QString &hostname)
+void KviHttpFileTransfer::resolvingHost(const TQString &hostname)
{
- m_szStatusString = __tr2qs_ctx("Resolving host %1","http").arg(hostname);
+ m_szStatusString = __tr2qs_ctx("Resolving host %1","http").tqarg(hostname);
displayUpdate();
}
-void KviHttpFileTransfer::contactingHost(const QString &ipandport)
+void KviHttpFileTransfer::contactingHost(const TQString &ipandport)
{
- m_szStatusString = __tr2qs_ctx("Contacting host %1","http").arg(ipandport);
+ m_szStatusString = __tr2qs_ctx("Contacting host %1","http").tqarg(ipandport);
displayUpdate();
}
-void KviHttpFileTransfer::receivedResponse(const QString &response)
+void KviHttpFileTransfer::receivedResponse(const TQString &response)
{
m_lHeaders.clear();
m_lHeaders.append(response);
- m_szStatusString = __tr2qs_ctx("Transferring data (%1)","http").arg(response);
+ m_szStatusString = __tr2qs_ctx("Transferring data (%1)","http").tqarg(response);
m_tTransferStartTime = kvi_unixTime();
- m_eGeneralStatus = Downloading;
+ m_eGeneraltqStatus = Downloading;
displayUpdate();
}
-void KviHttpFileTransfer::statusMessage(const QString &txt)
+void KviHttpFileTransfer::statusMessage(const TQString &txt)
{
KviWindow * out = transferWindow();
if(out && (!m_bNoOutput))
@@ -439,25 +439,25 @@ void KviHttpFileTransfer::transferTerminated(bool bSuccess)
if(bSuccess)
{
m_szStatusString = __tr2qs_ctx("Transfer completed","http");
- m_eGeneralStatus = Success;
+ m_eGeneraltqStatus = Success;
displayUpdate();
if(out && (!m_bNoOutput))out->output(KVI_OUT_GENERICSUCCESS,__tr2qs_ctx("[HTTP %d]: Transfer completed","http"),id());
- g_pApp->fileDownloadTerminated(true,m_pHttpRequest->url().url().ptr(),m_pHttpRequest->fileName(),QString::null,QString::null,!m_bNotifyCompletion);
+ g_pApp->fileDownloadTerminated(true,m_pHttpRequest->url().url().ptr(),m_pHttpRequest->fileName(),TQString(),TQString(),!m_bNotifyCompletion);
} else {
m_szStatusString = __tr2qs_ctx("Transfer failed","http");
m_szStatusString += ": ";
m_szStatusString += m_pHttpRequest->lastError();
- m_eGeneralStatus = Failure;
+ m_eGeneraltqStatus = Failure;
displayUpdate();
if(out && (!m_bNoOutput))out->output(KVI_OUT_GENERICERROR,__tr2qs_ctx("[HTTP %d]: Transfer failed: %Q","http"),id(),&(m_pHttpRequest->lastError()));
- g_pApp->fileDownloadTerminated(false,m_pHttpRequest->url().url().ptr(),m_pHttpRequest->fileName(),QString::null,m_pHttpRequest->lastError(),!m_bNotifyCompletion);
+ g_pApp->fileDownloadTerminated(false,m_pHttpRequest->url().url().ptr(),m_pHttpRequest->fileName(),TQString(),m_pHttpRequest->lastError(),!m_bNotifyCompletion);
}
if(m_bAutoClean)
{
if(m_pAutoCleanTimer)delete m_pAutoCleanTimer;
- m_pAutoCleanTimer = new QTimer();
- connect(m_pAutoCleanTimer,SIGNAL(timeout()),this,SLOT(autoClean()));
+ m_pAutoCleanTimer = new TQTimer();
+ connect(m_pAutoCleanTimer,TQT_SIGNAL(timeout()),this,TQT_SLOT(autoClean()));
m_pAutoCleanTimer->start(100,true);
}
}
@@ -471,7 +471,7 @@ void KviHttpFileTransfer::headersReceived(KviPointerHashTable<const char *,KviSt
KviPointerHashTableIterator<const char *,KviStr> it(*h);
while(KviStr * s = it.current())
{
- QString szHeader = it.currentKey();
+ TQString szHeader = it.currentKey();
szHeader += ": ";
szHeader += s->ptr();
m_lHeaders.append(szHeader);
@@ -482,7 +482,7 @@ void KviHttpFileTransfer::headersReceived(KviPointerHashTable<const char *,KviSt
bool KviHttpFileTransfer::startDownload()
{
- m_eGeneralStatus = Connecting;
+ m_eGeneraltqStatus = Connecting;
return m_pHttpRequest->start();
}