summaryrefslogtreecommitdiffstats
path: root/src/kvilib/net/kvi_http.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/kvilib/net/kvi_http.cpp')
-rw-r--r--src/kvilib/net/kvi_http.cpp154
1 files changed, 77 insertions, 77 deletions
diff --git a/src/kvilib/net/kvi_http.cpp b/src/kvilib/net/kvi_http.cpp
index 2e94abbe..07a69658 100644
--- a/src/kvilib/net/kvi_http.cpp
+++ b/src/kvilib/net/kvi_http.cpp
@@ -25,8 +25,8 @@
#define __KVILIB__
-#include <qdir.h>
-#include <qtimer.h>
+#include <tqdir.h>
+#include <tqtimer.h>
//#include <zlib.h>
#include "kvi_http.h"
@@ -46,7 +46,7 @@
#define KVI_HTTP_REQUEST_THREAD_EVENT_REQUESTSENT (KVI_THREAD_USER_EVENT_BASE + 0xCAFF)
KviHttpRequest::KviHttpRequest()
-: QObject()
+: TQObject()
{
m_pDns = 0;
m_pThread = 0;
@@ -55,24 +55,24 @@ KviHttpRequest::KviHttpRequest()
m_bHeaderProcessed = false;
m_pBuffer = new KviDataBuffer();
- resetStatus();
+ resettqStatus();
resetData();
}
KviHttpRequest::~KviHttpRequest()
{
- resetInternalStatus();
+ resetInternaltqStatus();
delete m_pBuffer;
}
void KviHttpRequest::abort()
{
- resetInternalStatus();
+ resetInternaltqStatus();
m_szLastError = __tr2qs("Aborted");
emit terminated(false);
}
-void KviHttpRequest::resetInternalStatus()
+void KviHttpRequest::resetInternaltqStatus()
{
if(m_pThread)delete m_pThread;
if(m_pDns)delete m_pDns;
@@ -91,7 +91,7 @@ void KviHttpRequest::resetInternalStatus()
KviThreadManager::killPendingEvents(this);
}
-void KviHttpRequest::resetStatus()
+void KviHttpRequest::resettqStatus()
{
m_szLastError = __tr2qs("No request");
m_uTotalSize = 0;
@@ -114,12 +114,12 @@ void KviHttpRequest::resetData()
void KviHttpRequest::reset()
{
- resetStatus();
+ resettqStatus();
resetData();
- resetInternalStatus();
+ resetInternaltqStatus();
}
-bool KviHttpRequest::get(const KviUrl &u,ProcessingType p,const QString &szFileName)
+bool KviHttpRequest::get(const KviUrl &u,ProcessingType p,const TQString &szFileName)
{
reset();
setUrl(u);
@@ -131,8 +131,8 @@ bool KviHttpRequest::get(const KviUrl &u,ProcessingType p,const QString &szFileN
bool KviHttpRequest::start()
{
// ensure that the file is closed
- resetInternalStatus();
- resetStatus();
+ resetInternaltqStatus();
+ resettqStatus();
if(m_eProcessingType == StoreToFile)
{
@@ -148,7 +148,7 @@ bool KviHttpRequest::start()
if(KviFile::exists(m_szFileName))
{
// we check it
- QFileInfo fi(m_szFileName);
+ TQFileInfo fi(m_szFileName);
m_uContentOffset = fi.size();
}
}
@@ -156,22 +156,22 @@ bool KviHttpRequest::start()
if(m_url.host().isEmpty())
{
- resetInternalStatus();
+ resetInternaltqStatus();
m_szLastError = __tr2qs("Invalid URL: Missing hostname");
return false;
}
if((!kvi_strEqualCI(m_url.protocol().ptr(),"http")) && (!kvi_strEqualCI(m_url.protocol().ptr(),"https")))
{
- resetInternalStatus();
- m_szLastError=__tr2qs("Unsupported protocol %1").arg(m_url.protocol().ptr());
+ resetInternaltqStatus();
+ m_szLastError=__tr2qs("Unsupported protocol %1").tqarg(m_url.protocol().ptr());
return false;
}
if(kvi_isValidStringIp(m_url.host().ptr()))
{
m_szIp = m_url.host();
- QTimer::singleShot(10,this,SLOT(haveServerIp()));
+ TQTimer::singleShot(10,this,TQT_SLOT(haveServerIp()));
return true;
}
@@ -181,20 +181,20 @@ bool KviHttpRequest::start()
bool KviHttpRequest::startDnsLookup()
{
m_pDns = new KviDns();
- connect(m_pDns,SIGNAL(lookupDone(KviDns *)),this,SLOT(dnsLookupDone(KviDns *)));
+ connect(m_pDns,TQT_SIGNAL(lookupDone(KviDns *)),this,TQT_SLOT(dnsLookupDone(KviDns *)));
if(!m_pDns->lookup(m_url.host().ptr(),KviDns::IpV4))
{
- resetInternalStatus();
+ resetInternaltqStatus();
m_szLastError = __tr2qs("Unable to start the DNS lookup");
return false;
}
- QString tmp;
- KviQString::sprintf(tmp,__tr2qs("Looking up host %s"),m_url.host().ptr());
+ TQString tmp;
+ KviTQString::sprintf(tmp,__tr2qs("Looking up host %s"),m_url.host().ptr());
emit status(tmp); // FIXME
- emit resolvingHost(QString(m_url.host().ptr()));
+ emit resolvingHost(TQString(m_url.host().ptr()));
return true;
}
@@ -206,13 +206,13 @@ void KviHttpRequest::dnsLookupDone(KviDns *d)
m_szIp = d->firstIpAddress();
delete m_pDns;
m_pDns = 0;
- QString tmp;
- KviQString::sprintf(tmp,__tr2qs("Host %s resolved to %Q"),m_url.host().ptr(),&m_szIp);
+ TQString tmp;
+ KviTQString::sprintf(tmp,__tr2qs("Host %s resolved to %Q"),m_url.host().ptr(),&m_szIp);
emit status(tmp);
haveServerIp();
} else {
int iErr = d->error();
- resetInternalStatus();
+ resetInternaltqStatus();
m_szLastError = KviError::getDescription(iErr);
emit terminated(false);
}
@@ -223,8 +223,8 @@ void KviHttpRequest::haveServerIp()
unsigned short uPort = m_url.port();
if(uPort == 0)uPort = 80;
- QString tmp;
- KviQString::sprintf(tmp,"%Q:%u",&m_szIp,uPort);
+ TQString tmp;
+ KviTQString::sprintf(tmp,"%Q:%u",&m_szIp,uPort);
emit contactingHost(tmp);
if(m_pThread)delete m_pThread;
@@ -242,17 +242,17 @@ void KviHttpRequest::haveServerIp()
if(!m_pThread->start())
{
- resetInternalStatus();
+ resetInternaltqStatus();
m_szLastError = __tr2qs("Unable to start the request slave thread");
emit terminated(false);
return;
}
- KviQString::sprintf(tmp,__tr2qs("Contacting host %Q on port %u"),&m_szIp,uPort);
+ KviTQString::sprintf(tmp,__tr2qs("Contacting host %Q on port %u"),&m_szIp,uPort);
emit status(tmp);
}
-bool KviHttpRequest::event(QEvent *e)
+bool KviHttpRequest::event(TQEvent *e)
{
if(e->type() == KVI_THREAD_EVENT)
{
@@ -273,11 +273,11 @@ bool KviHttpRequest::event(QEvent *e)
break;
case KVI_HTTP_REQUEST_THREAD_EVENT_REQUESTSENT:
{
- QString * req = ((KviThreadDataEvent<QString> *)e)->getData();
+ TQString * req = ((KviThreadDataEvent<TQString> *)e)->getData();
#ifdef COMPILE_USE_QT4
- QStringList sl = req->split("\r\n");
+ TQStringList sl = req->split("\r\n");
#else
- QStringList sl = QStringList::split("\r\n",*req);
+ TQStringList sl = TQStringList::split("\r\n",*req);
#endif
emit requestSent(sl);
delete req;
@@ -318,7 +318,7 @@ bool KviHttpRequest::event(QEvent *e)
// nothing... just make gcc happy
break;
}
- resetInternalStatus();
+ resetInternaltqStatus();
m_szLastError = __tr2qs("Success");
emit terminated(true);
return true;
@@ -328,7 +328,7 @@ bool KviHttpRequest::event(QEvent *e)
KviStr * err = ((KviThreadDataEvent<KviStr> *)e)->getData();
m_szLastError = __tr2qs_no_xgettext(err->ptr());
delete err;
- resetInternalStatus();
+ resetInternaltqStatus();
emit terminated(false);
return true;
}
@@ -343,24 +343,24 @@ bool KviHttpRequest::event(QEvent *e)
break;
}
}
- return QObject::event(e);
+ return TQObject::event(e);
}
void KviHttpRequest::emitLines(KviDataBuffer * pDataBuffer)
{
- int idx = pDataBuffer->find((const unsigned char *)"\n",1);
+ int idx = pDataBuffer->tqfind((const unsigned char *)"\n",1);
while(idx != -1)
{
KviStr tmp((const char *)(m_pBuffer->data()),idx);
tmp.stripRight('\r');
pDataBuffer->remove(idx + 1);
- idx = pDataBuffer->find((const unsigned char *)"\n",1);
+ idx = pDataBuffer->tqfind((const unsigned char *)"\n",1);
emit data(tmp);
}
}
// header += "Accept: ";
-// QString acceptHeader = metaData("accept");
+// TQString acceptHeader = metaData("accept");
// if (!acceptHeader.isEmpty())
// header += acceptHeader;
// else
@@ -406,26 +406,26 @@ bool KviHttpRequest::openFile()
case RenameIncoming:
{
int i=0;
- QString tmp = m_szFileName;
+ TQString tmp = m_szFileName;
do {
i++;
- m_szFileName = tmp + QString(".kvirnm-%1").arg(i);
+ m_szFileName = tmp + TQString(".kvirnm-%1").tqarg(i);
} while(KviFile::exists(m_szFileName));
}
break;
case RenameExisting:
{
int i=0;
- QString tmp;
+ TQString tmp;
do {
i++;
- tmp = m_szFileName + QString(".kvirnm-%1").arg(i);
+ tmp = m_szFileName + TQString(".kvirnm-%1").tqarg(i);
} while(KviFile::exists(tmp));
- QDir d;
+ TQDir d;
if(!d.rename(m_szFileName,tmp))
{
// fail :(
- resetInternalStatus();
+ resetInternaltqStatus();
m_szLastError = __tr2qs("Failed to rename the existing file, please rename manually and retry");
emit terminated(false);
return false;
@@ -443,8 +443,8 @@ bool KviHttpRequest::openFile()
if(!m_pFile->openForWriting(bAppend))
{
- resetInternalStatus();
- KviQString::sprintf(m_szLastError,__tr2qs("Can't open file \"%Q\" for writing"),&m_szFileName);
+ resetInternaltqStatus();
+ KviTQString::sprintf(m_szLastError,__tr2qs("Can't open file \"%Q\" for writing"),&m_szFileName);
emit terminated(false);
return false;
}
@@ -473,7 +473,7 @@ bool KviHttpRequest::processHeader(KviStr &szHeader)
bool bValid = false;
- unsigned int uStatus = 0;
+ unsigned int utqStatus = 0;
// check the response value
if(kvi_strEqualCSN(szResponse.ptr(),"HTTP",4))
@@ -486,24 +486,24 @@ bool KviHttpRequest::processHeader(KviStr &szHeader)
if(idx != -1)szNumber = szR.left(idx);
else szNumber = szR;
bool bOk;
- uStatus = szNumber.toUInt(&bOk);
+ utqStatus = szNumber.toUInt(&bOk);
if(bOk)bValid = true;
}
if(!bValid)
{
// the response is invalid ?
- resetInternalStatus();
- m_szLastError=__tr2qs("Invalid HTTP response: %s").arg(szResponse.ptr());
+ resetInternaltqStatus();
+ m_szLastError=__tr2qs("Invalid HTTP response: %s").tqarg(szResponse.ptr());
emit terminated(false);
return false;
}
- QString tmp;
- KviQString::sprintf(tmp,__tr2qs("Received HTTP response: %s"),szResponse.ptr());
+ TQString tmp;
+ KviTQString::sprintf(tmp,__tr2qs("Received HTTP response: %s"),szResponse.ptr());
emit status(tmp);
- emit receivedResponse(QString(szResponse.ptr()));
+ emit receivedResponse(TQString(szResponse.ptr()));
KviPointerList<KviStr> hlist;
hlist.setAutoDelete(true);
@@ -531,12 +531,12 @@ bool KviHttpRequest::processHeader(KviStr &szHeader)
KviStr szName = s->left(idx);
s->cutLeft(idx + 1);
s->stripWhiteSpace();
- hdr.replace(szName.ptr(),new KviStr(*s));
+ hdr.tqreplace(szName.ptr(),new KviStr(*s));
//debug("FOUND HEADER (%s)=(%s)",szName.ptr(),s->ptr());
}
}
- KviStr * size = hdr.find("Content-length");
+ KviStr * size = hdr.tqfind("Content-length");
if(size)
{
bool bOk;
@@ -544,13 +544,13 @@ bool KviHttpRequest::processHeader(KviStr &szHeader)
if(!bOk)m_uTotalSize = 0;
}
- KviStr * contentEncoding = hdr.find("Content-encoding");
+ KviStr * contentEncoding = hdr.tqfind("Content-encoding");
if(contentEncoding)
{
m_bGzip = contentEncoding->equalsCI("gzip");
}
- KviStr * transferEncoding = hdr.find("Transfer-Encoding");
+ KviStr * transferEncoding = hdr.tqfind("Transfer-Encoding");
if(transferEncoding)
{
if(kvi_strEqualCI(transferEncoding->ptr(),"chunked"))
@@ -608,14 +608,14 @@ bool KviHttpRequest::processHeader(KviStr &szHeader)
// case 504: // Gateway timeout
// case 505: // HTTP Version not supported
- if((uStatus != 200) && (uStatus != 206))
+ if((utqStatus != 200) && (utqStatus != 206))
{
// this is not "OK" and not "Partial content"
// Error , redirect or something confusing
if(m_eProcessingType != HeadersOnly)
{
// this is an error then
- resetInternalStatus();
+ resetInternaltqStatus();
m_szLastError = szResponse.ptr();
emit terminated(false);
return false;
@@ -624,7 +624,7 @@ bool KviHttpRequest::processHeader(KviStr &szHeader)
if((m_uMaxContentLength > 0) && (m_uTotalSize > ((unsigned int)m_uMaxContentLength)))
{
- resetInternalStatus();
+ resetInternaltqStatus();
m_szLastError=__tr2qs("Stream exceeding maximum length");
emit terminated(false);
return false;
@@ -651,13 +651,13 @@ void KviHttpRequest::processData(KviDataBuffer * data)
// time to process the header
m_pBuffer->append(*data);
- int idx = m_pBuffer->find((const unsigned char *)"\r\n\r\n",4);
+ int idx = m_pBuffer->tqfind((const unsigned char *)"\r\n\r\n",4);
if(idx == -1)
{
// header not complete
if(m_pBuffer->size() > 4096)
{
- resetInternalStatus();
+ resetInternaltqStatus();
m_szLastError = __tr2qs("Header too long: exceeded 4096 bytes");
emit terminated(false);
}
@@ -706,7 +706,7 @@ void KviHttpRequest::processData(KviDataBuffer * data)
if(((m_uTotalSize > 0) && (m_uReceivedSize > m_uTotalSize)) || ((m_uMaxContentLength > 0) && (m_uReceivedSize > m_uMaxContentLength)))
{
- resetInternalStatus();
+ resetInternaltqStatus();
m_szLastError=__tr2qs("Stream exceeded expected length");
emit terminated(false);
}
@@ -721,7 +721,7 @@ void KviHttpRequest::processData(KviDataBuffer * data)
// we're processing data in m_pBuffer here
if(m_bChunkedTransferEncoding)
{
- // The transfer encoding is chunked: the buffer contains
+ // The transfer encoding is chunked: the buffer tqcontains
// chunks of data with an initial header composed
// of a hexadecimal length, an optional bullshit and a single CRLF
// The transfer terminates when we read a last chunk of size 0
@@ -776,7 +776,7 @@ void KviHttpRequest::processData(KviDataBuffer * data)
// We're looking for the beginning of a chunk now.
// Note that we might be at the end of a previous chunk that has a CRLF terminator
// we need to skip it.
- int crlf = m_pBuffer->find((const unsigned char *)"\r\n",2);
+ int crlf = m_pBuffer->tqfind((const unsigned char *)"\r\n",2);
if(crlf != -1)
{
if(crlf == 0)
@@ -789,12 +789,12 @@ void KviHttpRequest::processData(KviDataBuffer * data)
KviStr szHeader((const char *)(m_pBuffer->data()),crlf);
szHeader.cutFromFirst(' ');
// now szHeader should contain a hexadecimal chunk length... (why the hell it is hex and not decimal ????)
- QString szHexHeader = szHeader.ptr();
+ TQString szHexHeader = szHeader.ptr();
bool bOk;
m_uRemainingChunkSize = szHexHeader.toLong(&bOk,16);
if(!bOk)
{
- resetInternalStatus();
+ resetInternaltqStatus();
m_szLastError = __tr2qs("Protocol error: invalid chunk size");
emit terminated(false);
return;
@@ -814,7 +814,7 @@ void KviHttpRequest::processData(KviDataBuffer * data)
// chunk header not complete
if(m_pBuffer->size() > 4096)
{
- resetInternalStatus();
+ resetInternaltqStatus();
m_szLastError = __tr2qs("Chunk header too long: exceeded 4096 bytes");
emit terminated(false);
return;
@@ -848,7 +848,7 @@ check_stream_length:
if(((m_uTotalSize > 0) && (m_uReceivedSize > m_uTotalSize)) || ((m_uMaxContentLength > 0) && (m_uReceivedSize > m_uMaxContentLength)))
{
- resetInternalStatus();
+ resetInternaltqStatus();
m_szLastError=__tr2qs("Stream exceeded expected length");
emit terminated(false);
}
@@ -872,13 +872,13 @@ check_stream_length:
KviHttpRequestThread::KviHttpRequestThread(
KviHttpRequest * r,
- const QString &szHost,
- const QString &szIp,
+ const TQString &szHost,
+ const TQString &szIp,
unsigned short uPort,
- const QString & szPath,
+ const TQString & szPath,
unsigned int uContentOffset,
RequestMethod m,
- const QString &szPostData,
+ const TQString &szPostData,
bool bUseSSL
) : KviSensitiveThread()
{
@@ -1403,7 +1403,7 @@ void KviHttpRequestThread::runInternal()
"Connection: Close\r\n" \
"User-Agent: KVIrc-http-slave/1.0.0\r\n" \
"Accept: */*\r\n",
- szMethod.ptr(),KviQString::toUtf8(m_szPath).data(),KviQString::toUtf8(m_szHost).data());
+ szMethod.ptr(),KviTQString::toUtf8(m_szPath).data(),KviTQString::toUtf8(m_szHost).data());
if(m_uContentOffset > 0)
szRequest.append(KviStr::Format,"Range: bytes=%u-\r\n",m_uContentOffset);
@@ -1430,7 +1430,7 @@ void KviHttpRequestThread::runInternal()
if(!sendBuffer(szRequest.ptr(),szRequest.len(),60))return;
// now loop reading data
- postEvent(m_pRequest,new KviThreadDataEvent<QString>(KVI_HTTP_REQUEST_THREAD_EVENT_REQUESTSENT,new QString(szRequest)));
+ postEvent(m_pRequest,new KviThreadDataEvent<TQString>(KVI_HTTP_REQUEST_THREAD_EVENT_REQUESTSENT,new TQString(szRequest)));
for(;;)
{