diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:48:06 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:48:06 +0000 |
commit | 47c8a359c5276062c4bc17f0e82410f29081b502 (patch) | |
tree | 2d54a5f60a5b74067632f9ef6df58c2bc38155e6 /kopete/protocols/jabber/libiris/cutestuff/network/httpconnect.cpp | |
parent | 6f82532777a35e0e60bbd2b290b2e93e646f349b (diff) | |
download | tdenetwork-47c8a359c5276062c4bc17f0e82410f29081b502.tar.gz tdenetwork-47c8a359c5276062c4bc17f0e82410f29081b502.zip |
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1157648 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kopete/protocols/jabber/libiris/cutestuff/network/httpconnect.cpp')
-rw-r--r-- | kopete/protocols/jabber/libiris/cutestuff/network/httpconnect.cpp | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/kopete/protocols/jabber/libiris/cutestuff/network/httpconnect.cpp b/kopete/protocols/jabber/libiris/cutestuff/network/httpconnect.cpp index 76550db0..6abeb556 100644 --- a/kopete/protocols/jabber/libiris/cutestuff/network/httpconnect.cpp +++ b/kopete/protocols/jabber/libiris/cutestuff/network/httpconnect.cpp @@ -20,7 +20,7 @@ #include"httpconnect.h" -#include<qstringlist.h> +#include<tqstringlist.h> #include"bsocket.h" #include"base64.h" @@ -30,20 +30,20 @@ // CS_NAMESPACE_BEGIN -static QString extractLine(QByteArray *buf, bool *found) +static TQString extractLine(TQByteArray *buf, bool *found) { // scan for newline int n; for(n = 0; n < (int)buf->size()-1; ++n) { if(buf->at(n) == '\r' && buf->at(n+1) == '\n') { - QCString cstr; + TQCString cstr; cstr.resize(n+1); memcpy(cstr.data(), buf->data(), n); n += 2; // hack off CR/LF memmove(buf->data(), buf->data() + n, buf->size() - n); buf->resize(buf->size() - n); - QString s = QString::fromUtf8(cstr); + TQString s = TQString::fromUtf8(cstr); if(found) *found = true; @@ -56,7 +56,7 @@ static QString extractLine(QByteArray *buf, bool *found) return ""; } -static bool extractMainHeader(const QString &line, QString *proto, int *code, QString *msg) +static bool extractMainHeader(const TQString &line, TQString *proto, int *code, TQString *msg) { int n = line.find(' '); if(n == -1) @@ -81,31 +81,31 @@ public: Private() {} BSocket sock; - QString host; + TQString host; int port; - QString user, pass; - QString real_host; + TQString user, pass; + TQString real_host; int real_port; - QByteArray recvBuf; + TQByteArray recvBuf; bool inHeader; - QStringList headerLines; + TQStringList headerLines; int toWrite; bool active; }; -HttpConnect::HttpConnect(QObject *parent) +HttpConnect::HttpConnect(TQObject *parent) :ByteStream(parent) { d = new Private; - connect(&d->sock, SIGNAL(connected()), SLOT(sock_connected())); - connect(&d->sock, SIGNAL(connectionClosed()), SLOT(sock_connectionClosed())); - connect(&d->sock, SIGNAL(delayedCloseFinished()), SLOT(sock_delayedCloseFinished())); - connect(&d->sock, SIGNAL(readyRead()), SLOT(sock_readyRead())); - connect(&d->sock, SIGNAL(bytesWritten(int)), SLOT(sock_bytesWritten(int))); - connect(&d->sock, SIGNAL(error(int)), SLOT(sock_error(int))); + connect(&d->sock, TQT_SIGNAL(connected()), TQT_SLOT(sock_connected())); + connect(&d->sock, TQT_SIGNAL(connectionClosed()), TQT_SLOT(sock_connectionClosed())); + connect(&d->sock, TQT_SIGNAL(delayedCloseFinished()), TQT_SLOT(sock_delayedCloseFinished())); + connect(&d->sock, TQT_SIGNAL(readyRead()), TQT_SLOT(sock_readyRead())); + connect(&d->sock, TQT_SIGNAL(bytesWritten(int)), TQT_SLOT(sock_bytesWritten(int))); + connect(&d->sock, TQT_SIGNAL(error(int)), TQT_SLOT(sock_error(int))); reset(true); } @@ -127,13 +127,13 @@ void HttpConnect::reset(bool clear) d->active = false; } -void HttpConnect::setAuth(const QString &user, const QString &pass) +void HttpConnect::setAuth(const TQString &user, const TQString &pass) { d->user = user; d->pass = pass; } -void HttpConnect::connectToHost(const QString &proxyHost, int proxyPort, const QString &host, int port) +void HttpConnect::connectToHost(const TQString &proxyHost, int proxyPort, const TQString &host, int port) { reset(true); @@ -164,13 +164,13 @@ void HttpConnect::close() reset(); } -void HttpConnect::write(const QByteArray &buf) +void HttpConnect::write(const TQByteArray &buf) { if(d->active) d->sock.write(buf); } -QByteArray HttpConnect::read(int bytes) +TQByteArray HttpConnect::read(int bytes) { return ByteStream::read(bytes); } @@ -197,18 +197,18 @@ void HttpConnect::sock_connected() d->headerLines.clear(); // connected, now send the request - QString s; - s += QString("CONNECT ") + d->real_host + ':' + QString::number(d->real_port) + " HTTP/1.0\r\n"; + TQString s; + s += TQString("CONNECT ") + d->real_host + ':' + TQString::number(d->real_port) + " HTTP/1.0\r\n"; if(!d->user.isEmpty()) { - QString str = d->user + ':' + d->pass; - s += QString("Proxy-Authorization: Basic ") + Base64::encodeString(str) + "\r\n"; + TQString str = d->user + ':' + d->pass; + s += TQString("Proxy-Authorization: Basic ") + Base64::encodeString(str) + "\r\n"; } s += "Proxy-Connection: Keep-Alive\r\n"; s += "Pragma: no-cache\r\n"; s += "\r\n"; - QCString cs = s.utf8(); - QByteArray block(cs.length()); + TQCString cs = s.utf8(); + TQByteArray block(cs.length()); memcpy(block.data(), cs.data(), block.size()); d->toWrite = block.size(); d->sock.write(block); @@ -235,7 +235,7 @@ void HttpConnect::sock_delayedCloseFinished() void HttpConnect::sock_readyRead() { - QByteArray block = d->sock.read(); + TQByteArray block = d->sock.read(); if(!d->active) { ByteStream::appendArray(&d->recvBuf, block); @@ -244,7 +244,7 @@ void HttpConnect::sock_readyRead() // grab available lines while(1) { bool found; - QString line = extractLine(&d->recvBuf, &found); + TQString line = extractLine(&d->recvBuf, &found); if(!found) break; if(line.isEmpty()) { @@ -256,12 +256,12 @@ void HttpConnect::sock_readyRead() // done with grabbing the header? if(!d->inHeader) { - QString str = d->headerLines.first(); + TQString str = d->headerLines.first(); d->headerLines.remove(d->headerLines.begin()); - QString proto; + TQString proto; int code; - QString msg; + TQString msg; if(!extractMainHeader(str, &proto, &code, &msg)) { #ifdef PROX_DEBUG fprintf(stderr, "HttpConnect: invalid header!\n"); @@ -273,7 +273,7 @@ void HttpConnect::sock_readyRead() else { #ifdef PROX_DEBUG fprintf(stderr, "HttpConnect: header proto=[%s] code=[%d] msg=[%s]\n", proto.latin1(), code, msg.latin1()); - for(QStringList::ConstIterator it = d->headerLines.begin(); it != d->headerLines.end(); ++it) + for(TQStringList::ConstIterator it = d->headerLines.begin(); it != d->headerLines.end(); ++it) fprintf(stderr, "HttpConnect: * [%s]\n", (*it).latin1()); #endif } @@ -294,7 +294,7 @@ void HttpConnect::sock_readyRead() } else { int err; - QString errStr; + TQString errStr; if(code == 407) { // Authentication failed err = ErrProxyAuth; errStr = tr("Authentication failed"); |