Conversion qt3 -> tqt3

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

@ -16,8 +16,8 @@
#include <klocale.h> #include <klocale.h>
#include <kmimetype.h> #include <kmimetype.h>
#include <qbuffer.h> #include <ntqbuffer.h>
#include <qfile.h> #include <ntqfile.h>
using namespace KIO; using namespace KIO;
@ -41,7 +41,7 @@ extern "C"
/* gopher */ /* gopher */
gopher::gopher(const QByteArray &pool_socket, const QByteArray &app_socket) : TCPSlaveBase("gopher", pool_socket, app_socket) gopher::gopher(const TQByteArray &pool_socket, const TQByteArray &app_socket) : TCPSlaveBase("gopher", pool_socket, app_socket)
{ {
} }
@ -56,9 +56,9 @@ void gopher::get(const KUrl& url )
// <gophertype><selector>%09<search> // <gophertype><selector>%09<search>
// <gophertype><selector>%09<search>%09<gopher+_string> // <gophertype><selector>%09<search>%09<gopher+_string>
int port; int port;
QChar type; TQChar type;
QString path(url.path()); TQString path(url.path());
QString query(url.query()); TQString query(url.query());
// determine the type // determine the type
if (path != "/" && path != "") type = path[1]; if (path != "/" && path != "") type = path[1];
@ -82,8 +82,8 @@ void gopher::get(const KUrl& url )
{ {
int i, bytes; int i, bytes;
char aux[10240]; char aux[10240];
QBuffer received; TQBuffer received;
received.open(QIODevice::WriteOnly); received.open(TQIODevice::WriteOnly);
infoMessage(i18n("Connecting to %1...", url.host())); infoMessage(i18n("Connecting to %1...", url.host()));
infoMessage(i18n("%1 contacted. Retrieving data...", url.host())); infoMessage(i18n("%1 contacted. Retrieving data...", url.host()));
@ -104,7 +104,7 @@ void gopher::get(const KUrl& url )
infoMessage(i18n("Retrieved %1 bytes from %2...", bytes, url.host())); infoMessage(i18n("Retrieved %1 bytes from %2...", bytes, url.host()));
} }
if (type == '1' || type =='7') processDirectory(new QByteArray(received.buffer().data(), bytes + 1), url.host(), url.path()); if (type == '1' || type =='7') processDirectory(new TQByteArray(received.buffer().data(), bytes + 1), url.host(), url.path());
else else
{ {
KMimeType::Ptr result = KMimeType::findByContent(received.buffer()); KMimeType::Ptr result = KMimeType::findByContent(received.buffer());
@ -116,12 +116,12 @@ void gopher::get(const KUrl& url )
finished(); finished();
} }
void gopher::processDirectory(QByteArray *received, const QString &host, const QString &path) void gopher::processDirectory(TQByteArray *received, const TQString &host, const TQString &path)
{ {
int i, remove; int i, remove;
QString pathToShow; TQString pathToShow;
QByteArray show; TQByteArray show;
QByteArray info; TQByteArray info;
if (path == "/" || path == "/1") pathToShow = ""; if (path == "/" || path == "/1") pathToShow = "";
else pathToShow = path; else pathToShow = path;
mimeType("text/html"); mimeType("text/html");
@ -155,13 +155,13 @@ void gopher::processDirectory(QByteArray *received, const QString &host, const Q
delete received; delete received;
} }
void gopher::processDirectoryLine(const QByteArray &d, QByteArray &show, QByteArray &info) void gopher::processDirectoryLine(const TQByteArray &d, TQByteArray &show, TQByteArray &info)
{ {
// gopher <type><display><tab><selector><tab><server><tab><port><\r><\n> // gopher <type><display><tab><selector><tab><server><tab><port><\r><\n>
// gopher+ <type><display><tab><selector><tab><server><tab><port><tab><things><\r><\n> // gopher+ <type><display><tab><selector><tab><server><tab><port><tab><things><\r><\n>
int i; int i;
QByteArray type, name, url, server, port; TQByteArray type, name, url, server, port;
QByteArray data = d; TQByteArray data = d;
type = data.left(1); type = data.left(1);
data.remove(0, 1); data.remove(0, 1);
@ -215,8 +215,8 @@ void gopher::processDirectoryLine(const QByteArray &d, QByteArray &show, QByteAr
show.append("\t\t\t<div>"); show.append("\t\t\t<div>");
// support the non-standard extension for URL to external sites // support the non-standard extension for URL to external sites
// in this case, url begins with 'URL:' // in this case, url begins with 'URL:'
QByteArray finalUrl; TQByteArray finalUrl;
QByteArray iconUrl; TQByteArray iconUrl;
if (url.startsWith("URL:")) if (url.startsWith("URL:"))
{ {
finalUrl = url.mid(4); finalUrl = url.mid(4);
@ -243,12 +243,12 @@ void gopher::processDirectoryLine(const QByteArray &d, QByteArray &show, QByteAr
} }
} }
QByteArray gopher::parsePort(QByteArray *received) TQByteArray gopher::parsePort(TQByteArray *received)
{ {
int i = 0; int i = 0;
QByteArray port; TQByteArray port;
bool found = false; bool found = false;
QChar c; TQChar c;
while (!found && i < received -> size()) while (!found && i < received -> size())
{ {
c = received -> at(i); c = received -> at(i);
@ -260,7 +260,7 @@ QByteArray gopher::parsePort(QByteArray *received)
return port; return port;
} }
void gopher::findLine(QByteArray *received, int *i, int *remove) void gopher::findLine(TQByteArray *received, int *i, int *remove)
{ {
// it's not in the rfc but most servers don't follow the spec // it's not in the rfc but most servers don't follow the spec
// find lines ending only in \n and in \r\n // find lines ending only in \n and in \r\n
@ -288,11 +288,11 @@ void gopher::findLine(QByteArray *received, int *i, int *remove)
} }
} }
void gopher::handleSearch(const QString &host, const QString &path, int port) void gopher::handleSearch(const TQString &host, const TQString &path, int port)
{ {
QByteArray show; TQByteArray show;
QString sPort; TQString sPort;
if (port != 70) sPort = ':' + QString::number(port); if (port != 70) sPort = ':' + TQString::number(port);
mimeType("text/html"); mimeType("text/html");
show.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n"); show.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n");
show.append("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"); show.append("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n");
@ -330,9 +330,9 @@ void gopher::handleSearch(const QString &host, const QString &path, int port)
data(show); data(show);
} }
void gopher::addIcon(const QString &type, const QByteArray &url, QByteArray &show) void gopher::addIcon(const TQString &type, const TQByteArray &url, TQByteArray &show)
{ {
QString icon; TQString icon;
if (type == "1") icon = "inode-directory.png"; if (type == "1") icon = "inode-directory.png";
else if (type == "3") icon = "dialog-error.png"; else if (type == "3") icon = "dialog-error.png";
else if (type == "7") icon = "system-search.png"; else if (type == "7") icon = "system-search.png";
@ -343,9 +343,9 @@ void gopher::addIcon(const QString &type, const QByteArray &url, QByteArray &sho
KMimeType::Ptr mime = KMimeType::findByUrl(KUrl(url), 0, false, true); KMimeType::Ptr mime = KMimeType::findByUrl(KUrl(url), 0, false, true);
icon = mime->iconName(); icon = mime->iconName();
} }
QFile file(m_iconLoader.iconPath(icon, -16)); TQFile file(m_iconLoader.iconPath(icon, -16));
file.open(QIODevice::ReadOnly); file.open(TQIODevice::ReadOnly);
QByteArray ba = file.readAll(); TQByteArray ba = file.readAll();
show.append("<img width=\"16\" height=\"16\" src=\"data:image/png;base64,"); show.append("<img width=\"16\" height=\"16\" src=\"data:image/png;base64,");
show.append(KCodecs::base64Encode(ba)); show.append(KCodecs::base64Encode(ba));
show.append("\" /> "); show.append("\" /> ");

@ -17,17 +17,17 @@
class gopher : public KIO::TCPSlaveBase class gopher : public KIO::TCPSlaveBase
{ {
public: public:
gopher(const QByteArray &pool_socket, const QByteArray &app_socket); gopher(const TQByteArray &pool_socket, const TQByteArray &app_socket);
void get(const KUrl& url); void get(const KUrl& url);
private: private:
void processDirectory(QByteArray *received, const QString &host, const QString &path); void processDirectory(TQByteArray *received, const TQString &host, const TQString &path);
void processDirectoryLine(const QByteArray &data, QByteArray &show, QByteArray &info); void processDirectoryLine(const TQByteArray &data, TQByteArray &show, TQByteArray &info);
QByteArray parsePort(QByteArray *received); TQByteArray parsePort(TQByteArray *received);
void findLine(QByteArray *received, int *i, int *remove); void findLine(TQByteArray *received, int *i, int *remove);
void handleSearch(const QString &host, const QString &path, int port); void handleSearch(const TQString &host, const TQString &path, int port);
void addIcon(const QString &type, const QByteArray &url, QByteArray &show); void addIcon(const TQString &type, const TQByteArray &url, TQByteArray &show);
KIconLoader m_iconLoader; KIconLoader m_iconLoader;
}; };

Loading…
Cancel
Save