diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-28 20:34:15 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-28 20:34:15 +0000 |
commit | 1c1403293485f35fd53db45aaa77a01cdd9627e7 (patch) | |
tree | 38559cd68cd4f63023fb5f6375def9db3b8b491e /plugins/upnp | |
parent | 894f94545727610df22c4f73911d62d58266f695 (diff) | |
download | ktorrent-1c1403293485f35fd53db45aaa77a01cdd9627e7.tar.gz ktorrent-1c1403293485f35fd53db45aaa77a01cdd9627e7.zip |
TQt4 port ktorrent
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/ktorrent@1238733 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'plugins/upnp')
-rw-r--r-- | plugins/upnp/soap.cpp | 16 | ||||
-rw-r--r-- | plugins/upnp/soap.h | 12 | ||||
-rw-r--r-- | plugins/upnp/upnpdescriptionparser.cpp | 44 | ||||
-rw-r--r-- | plugins/upnp/upnpdescriptionparser.h | 2 | ||||
-rw-r--r-- | plugins/upnp/upnpmcastsocket.cpp | 83 | ||||
-rw-r--r-- | plugins/upnp/upnpmcastsocket.h | 11 | ||||
-rw-r--r-- | plugins/upnp/upnpplugin.cpp | 10 | ||||
-rw-r--r-- | plugins/upnp/upnpplugin.h | 5 | ||||
-rw-r--r-- | plugins/upnp/upnpprefpage.cpp | 8 | ||||
-rw-r--r-- | plugins/upnp/upnpprefpage.h | 2 | ||||
-rw-r--r-- | plugins/upnp/upnpprefwidget.cpp | 32 | ||||
-rw-r--r-- | plugins/upnp/upnpprefwidget.h | 7 | ||||
-rw-r--r-- | plugins/upnp/upnprouter.cpp | 92 | ||||
-rw-r--r-- | plugins/upnp/upnprouter.h | 55 | ||||
-rw-r--r-- | plugins/upnp/upnpwidget.ui | 18 |
15 files changed, 201 insertions, 196 deletions
diff --git a/plugins/upnp/soap.cpp b/plugins/upnp/soap.cpp index b155b55..f80d5af 100644 --- a/plugins/upnp/soap.cpp +++ b/plugins/upnp/soap.cpp @@ -22,32 +22,32 @@ namespace kt { - QString SOAP::createCommand(const QString & action,const QString & service) + TQString SOAP::createCommand(const TQString & action,const TQString & service) { - QString comm = QString("<?xml version=\"1.0\"?>\r\n" + TQString comm = TQString("<?xml version=\"1.0\"?>\r\n" "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">" "<SOAP-ENV:Body>" "<m:%1 xmlns:m=\"%2\"/>" "</SOAP-ENV:Body></SOAP-ENV:Envelope>" - "\r\n").arg(action).arg(service); + "\r\n").tqarg(action).tqarg(service); return comm; } - QString SOAP::createCommand(const QString & action,const QString & service,const QValueList<Arg> & args) + TQString SOAP::createCommand(const TQString & action,const TQString & service,const TQValueList<Arg> & args) { - QString comm = QString("<?xml version=\"1.0\"?>\r\n" + TQString comm = TQString("<?xml version=\"1.0\"?>\r\n" "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">" "<SOAP-ENV:Body>" - "<m:%1 xmlns:m=\"%2\">").arg(action).arg(service); + "<m:%1 xmlns:m=\"%2\">").tqarg(action).tqarg(service); - for (QValueList<Arg>::const_iterator i = args.begin();i != args.end();i++) + for (TQValueList<Arg>::const_iterator i = args.begin();i != args.end();i++) { const Arg & a = *i; comm += "<" + a.element + ">" + a.value + "</" + a.element + ">"; } - comm += QString("</m:%1></SOAP-ENV:Body></SOAP-ENV:Envelope>\r\n").arg(action); + comm += TQString("</m:%1></SOAP-ENV:Body></SOAP-ENV:Envelope>\r\n").tqarg(action); return comm; } } diff --git a/plugins/upnp/soap.h b/plugins/upnp/soap.h index c11e2ed..6632342 100644 --- a/plugins/upnp/soap.h +++ b/plugins/upnp/soap.h @@ -20,8 +20,8 @@ #ifndef KTSOAP_H #define KTSOAP_H -#include <qvaluelist.h> -#include <qstring.h> +#include <tqvaluelist.h> +#include <tqstring.h> namespace kt { @@ -39,12 +39,12 @@ namespace kt * @param service The name of the service * @return The command */ - static QString createCommand(const QString & action,const QString & service); + static TQString createCommand(const TQString & action,const TQString & service); struct Arg { - QString element; - QString value; + TQString element; + TQString value; }; /** @@ -54,7 +54,7 @@ namespace kt * @param args Arguments for command * @return The command */ - static QString createCommand(const QString & action,const QString & service,const QValueList<Arg> & args); + static TQString createCommand(const TQString & action,const TQString & service,const TQValueList<Arg> & args); }; } diff --git a/plugins/upnp/upnpdescriptionparser.cpp b/plugins/upnp/upnpdescriptionparser.cpp index 43afbc3..bd933a4 100644 --- a/plugins/upnp/upnpdescriptionparser.cpp +++ b/plugins/upnp/upnpdescriptionparser.cpp @@ -17,8 +17,8 @@ * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#include <qxml.h> -#include <qvaluestack.h> +#include <tqxml.h> +#include <tqvaluestack.h> #include <util/fileops.h> #include <util/log.h> #include <torrent/globals.h> @@ -30,17 +30,17 @@ using namespace bt; namespace kt { - class XMLContentHandler : public QXmlDefaultHandler + class XMLContentHandler : public TQXmlDefaultHandler { - enum Status + enum tqStatus { TOPLEVEL,ROOT,DEVICE,SERVICE,FIELD,OTHER }; - QString tmp; + TQString tmp; UPnPRouter* router; UPnPService curr_service; - QValueStack<Status> status_stack; + TQValueStack<tqStatus> status_stack; public: XMLContentHandler(UPnPRouter* router); virtual ~XMLContentHandler(); @@ -48,13 +48,13 @@ namespace kt bool startDocument(); bool endDocument(); - bool startElement(const QString &, const QString & localName, const QString &, - const QXmlAttributes & atts); - bool endElement(const QString & , const QString & localName, const QString & ); - bool characters(const QString & ch); + bool startElement(const TQString &, const TQString & localName, const TQString &, + const TQXmlAttributes & atts); + bool endElement(const TQString & , const TQString & localName, const TQString & ); + bool characters(const TQString & ch); - bool interestingDeviceField(const QString & name); - bool interestingServiceField(const QString & name); + bool interestingDeviceField(const TQString & name); + bool interestingServiceField(const TQString & name); }; @@ -65,17 +65,17 @@ namespace kt UPnPDescriptionParser::~UPnPDescriptionParser() {} - bool UPnPDescriptionParser::parse(const QString & file,UPnPRouter* router) + bool UPnPDescriptionParser::parse(const TQString & file,UPnPRouter* router) { bool ret = true; { - QFile fptr(file); + TQFile fptr(file); if (!fptr.open(IO_ReadOnly)) return false; - QXmlInputSource input(&fptr); + TQXmlInputSource input(TQT_TQIODEVICE(&fptr)); XMLContentHandler chandler(router); - QXmlSimpleReader reader; + TQXmlSimpleReader reader; reader.setContentHandler(&chandler); ret = reader.parse(&input,false); @@ -111,21 +111,21 @@ namespace kt return true; } - bool XMLContentHandler::interestingDeviceField(const QString & name) + bool XMLContentHandler::interestingDeviceField(const TQString & name) { return name == "friendlyName" || name == "manufacturer" || name == "modelDescription" || name == "modelName" || name == "modelNumber"; } - bool XMLContentHandler::interestingServiceField(const QString & name) + bool XMLContentHandler::interestingServiceField(const TQString & name) { return name == "serviceType" || name == "serviceId" || name == "SCPDURL" || name == "controlURL" || name == "eventSubURL"; } - bool XMLContentHandler::startElement(const QString &, const QString & localName, const QString &, - const QXmlAttributes & ) + bool XMLContentHandler::startElement(const TQString &, const TQString & localName, const TQString &, + const TQXmlAttributes & ) { tmp = ""; switch (status_stack.top()) @@ -172,7 +172,7 @@ namespace kt return true; } - bool XMLContentHandler::endElement(const QString & , const QString & localName, const QString & ) + bool XMLContentHandler::endElement(const TQString & , const TQString & localName, const TQString & ) { switch (status_stack.top()) { @@ -208,7 +208,7 @@ namespace kt } - bool XMLContentHandler::characters(const QString & ch) + bool XMLContentHandler::characters(const TQString & ch) { if (ch.length() > 0) { diff --git a/plugins/upnp/upnpdescriptionparser.h b/plugins/upnp/upnpdescriptionparser.h index 5d4bf1e..2aaacfe 100644 --- a/plugins/upnp/upnpdescriptionparser.h +++ b/plugins/upnp/upnpdescriptionparser.h @@ -41,7 +41,7 @@ namespace kt * @param router The router off the xml description * @return true upon success */ - bool parse(const QString & file,UPnPRouter* router); + bool parse(const TQString & file,UPnPRouter* router); }; } diff --git a/plugins/upnp/upnpmcastsocket.cpp b/plugins/upnp/upnpmcastsocket.cpp index 47712ea..6395752 100644 --- a/plugins/upnp/upnpmcastsocket.cpp +++ b/plugins/upnp/upnpmcastsocket.cpp @@ -19,24 +19,25 @@ ***************************************************************************/ #include <kurl.h> -#include <unistd.h> +extern "C" { + #include <unistd.h> + inline ssize_t mycread (int __fd, void *__buf, size_t __nbytes) { read(__fd, __buf, __nbytes); } +}; #include <sys/socket.h> #include <netinet/in.h> -#include <netinet/in_systm.h> +#include <netinet/in_systm.h> #include <netinet/ip.h> #include <arpa/inet.h> #include <netinet/ip.h> -#include <qstringlist.h> +#include <tqstringlist.h> #include <ksocketdevice.h> #include <ksocketaddress.h> #include <util/log.h> #include <torrent/globals.h> -#include <qfile.h> -#include <qtextstream.h> +#include <tqfile.h> +#include <tqtextstream.h> #include "upnpmcastsocket.h" - - using namespace KNetwork; using namespace bt; @@ -46,14 +47,14 @@ namespace kt UPnPMCastSocket::UPnPMCastSocket(bool verbose) : verbose(verbose) { routers.setAutoDelete(true); - QObject::connect(this,SIGNAL(readyRead()),this,SLOT(onReadyRead())); - QObject::connect(this,SIGNAL(gotError(int)),this,SLOT(onError(int))); + TQObject::connect(this,TQT_SIGNAL(readyRead()),this,TQT_SLOT(onReadyRead())); + TQObject::connect(this,TQT_SIGNAL(gotError(int)),this,TQT_SLOT(onError(int))); setAddressReuseable(true); setFamily(KNetwork::KResolver::IPv4Family); setBlocking(true); for (Uint32 i = 0;i < 10;i++) { - if (!bind(QString::null,QString::number(1900 + i))) + if (!bind(TQString(),TQString::number(1900 + i))) Out(SYS_PNP|LOG_IMPORTANT) << "Cannot bind to UDP port 1900" << endl; else break; @@ -66,8 +67,8 @@ namespace kt UPnPMCastSocket::~UPnPMCastSocket() { leaveUPnPMCastGroup(); - QObject::disconnect(this,SIGNAL(readyRead()),this,SLOT(onReadyRead())); - QObject::disconnect(this,SIGNAL(gotError(int)),this,SLOT(onError(int))); + TQObject::disconnect(this,TQT_SIGNAL(readyRead()),this,TQT_SLOT(onReadyRead())); + TQObject::disconnect(this,TQT_SIGNAL(gotError(int)),this,TQT_SLOT(onError(int))); } void UPnPMCastSocket::discover() @@ -102,7 +103,7 @@ namespace kt else { // add it to the list and emit the signal - if (!routers.contains(r->getServer())) + if (!routers.tqcontains(r->getServer())) { routers.insert(r->getServer(),r); discovered(r); @@ -123,7 +124,7 @@ namespace kt // so we need to deal with it oursleves int fd = socketDevice()->socket(); char tmp; - read(fd,&tmp,1); + mycread(fd,&tmp,1); return; } @@ -134,25 +135,25 @@ namespace kt if (verbose) { Out(SYS_PNP|LOG_NOTICE) << "Received : " << endl; - Out(SYS_PNP|LOG_NOTICE) << QString(p.data()) << endl; + Out(SYS_PNP|LOG_NOTICE) << TQString(p.data()) << endl; } // try to make a router of it UPnPRouter* r = parseResponse(p.data()); if (r) { - QObject::connect(r,SIGNAL(xmlFileDownloaded( UPnPRouter*, bool )), - this,SLOT(onXmlFileDownloaded( UPnPRouter*, bool ))); + TQObject::connect(r,TQT_SIGNAL(xmlFileDownloaded( UPnPRouter*, bool )), + this,TQT_SLOT(onXmlFileDownloaded( UPnPRouter*, bool ))); // download it's xml file r->downloadXMLFile(); } } - UPnPRouter* UPnPMCastSocket::parseResponse(const QByteArray & arr) + UPnPRouter* UPnPMCastSocket::parseResponse(const TQByteArray & arr) { - QStringList lines = QStringList::split("\r\n",QString(arr),false); - QString server; + TQStringList lines = TQStringList::split("\r\n",TQString(arr),false); + TQString server; KURL location; /* @@ -162,14 +163,14 @@ namespace kt */ // first read first line and see if contains a HTTP 200 OK message - QString line = lines.first(); - if (!line.contains("HTTP")) + TQString line = lines.first(); + if (!line.tqcontains("HTTP")) { // it is either a 200 OK or a NOTIFY - if (!line.contains("NOTIFY") && !line.contains("200")) + if (!line.tqcontains("NOTIFY") && !line.tqcontains("200")) return 0; } - else if (line.contains("M-SEARCH")) // ignore M-SEARCH + else if (line.tqcontains("M-SEARCH")) // ignore M-SEARCH return 0; // quick check that the response being parsed is valid @@ -177,7 +178,7 @@ namespace kt for (Uint32 idx = 0;idx < lines.count() && !validDevice; idx++) { line = lines[idx]; - if ((line.contains("ST:") || line.contains("NT:")) && line.contains("InternetGatewayDevice")) + if ((line.tqcontains("ST:") || line.tqcontains("NT:")) && line.tqcontains("InternetGatewayDevice")) { validDevice = true; } @@ -194,20 +195,20 @@ namespace kt line = lines[i]; if (line.startsWith("Location") || line.startsWith("LOCATION") || line.startsWith("location")) { - location = line.mid(line.find(':') + 1).stripWhiteSpace(); + location = line.mid(line.tqfind(':') + 1).stripWhiteSpace(); if (!location.isValid()) return 0; } else if (line.startsWith("Server") || line.startsWith("server") || line.startsWith("SERVER")) { - server = line.mid(line.find(':') + 1).stripWhiteSpace(); + server = line.mid(line.tqfind(':') + 1).stripWhiteSpace(); if (server.length() == 0) return 0; } } - if (routers.contains(server)) + if (routers.tqcontains(server)) { return 0; } @@ -221,22 +222,22 @@ namespace kt void UPnPMCastSocket::onError(int) { - Out(SYS_PNP|LOG_IMPORTANT) << "UPnPMCastSocket Error : " << errorString() << endl; + Out(SYS_PNP|LOG_IMPORTANT) << "UPnPMCastSocket Error : " << KSocketBase::errorString() << endl; } - void UPnPMCastSocket::saveRouters(const QString & file) + void UPnPMCastSocket::saveRouters(const TQString & file) { - QFile fptr(file); + TQFile fptr(file); if (!fptr.open(IO_WriteOnly)) { - Out(SYS_PNP|LOG_IMPORTANT) << "Cannot open file " << file << " : " << fptr.errorString() << endl; + Out(SYS_PNP|LOG_IMPORTANT) << "Cannot open file " << file << " : " << TQString(fptr.errorString()) << endl; return; } // file format is simple : 2 lines per router, // one containing the server, the other the location - QTextStream fout(&fptr); - bt::PtrMap<QString,UPnPRouter>::iterator i = routers.begin(); + TQTextStream fout(&fptr); + bt::PtrMap<TQString,UPnPRouter>::iterator i = routers.begin(); while (i != routers.end()) { UPnPRouter* r = i->second; @@ -246,29 +247,29 @@ namespace kt } } - void UPnPMCastSocket::loadRouters(const QString & file) + void UPnPMCastSocket::loadRouters(const TQString & file) { - QFile fptr(file); + TQFile fptr(file); if (!fptr.open(IO_ReadOnly)) { - Out(SYS_PNP|LOG_IMPORTANT) << "Cannot open file " << file << " : " << fptr.errorString() << endl; + Out(SYS_PNP|LOG_IMPORTANT) << "Cannot open file " << file << " : " << TQString(fptr.errorString()) << endl; return; } // file format is simple : 2 lines per router, // one containing the server, the other the location - QTextStream fin(&fptr); + TQTextStream fin(&fptr); while (!fin.atEnd()) { - QString server, location; + TQString server, location; server = fin.readLine(); location = fin.readLine(); - if (!routers.contains(server)) + if (!routers.tqcontains(server)) { UPnPRouter* r = new UPnPRouter(server,location); // download it's xml file - QObject::connect(r,SIGNAL(xmlFileDownloaded( UPnPRouter*, bool )),this,SLOT(onXmlFileDownloaded( UPnPRouter*, bool ))); + TQObject::connect(r,TQT_SIGNAL(xmlFileDownloaded( UPnPRouter*, bool )),this,TQT_SLOT(onXmlFileDownloaded( UPnPRouter*, bool ))); r->downloadXMLFile(); } } diff --git a/plugins/upnp/upnpmcastsocket.h b/plugins/upnp/upnpmcastsocket.h index 493c5b9..86688a2 100644 --- a/plugins/upnp/upnpmcastsocket.h +++ b/plugins/upnp/upnpmcastsocket.h @@ -40,6 +40,7 @@ namespace kt class UPnPMCastSocket : public KNetwork::KDatagramSocket { Q_OBJECT + TQ_OBJECT public: UPnPMCastSocket(bool verbose = false); virtual ~UPnPMCastSocket(); @@ -48,13 +49,13 @@ namespace kt Uint32 getNumDevicesDiscovered() const {return routers.count();} /// Find a router using it's server name - UPnPRouter* findDevice(const QString & name) {return routers.find(name);} + UPnPRouter* findDevice(const TQString & name) {return routers.tqfind(name);} /// Save all routers to a file (for convenience at startup) - void saveRouters(const QString & file); + void saveRouters(const TQString & file); /// Load all routers from a file - void loadRouters(const QString & file); + void loadRouters(const TQString & file); public slots: /** @@ -76,14 +77,14 @@ namespace kt void discovered(UPnPRouter* router); public: - UPnPRouter* parseResponse(const QByteArray & arr); + UPnPRouter* parseResponse(const TQByteArray & arr); private: void joinUPnPMCastGroup(); void leaveUPnPMCastGroup(); private: - bt::PtrMap<QString,UPnPRouter> routers; + bt::PtrMap<TQString,UPnPRouter> routers; bool verbose; }; } diff --git a/plugins/upnp/upnpplugin.cpp b/plugins/upnp/upnpplugin.cpp index dbe58b4..95df507 100644 --- a/plugins/upnp/upnpplugin.cpp +++ b/plugins/upnp/upnpplugin.cpp @@ -42,8 +42,8 @@ K_EXPORT_COMPONENT_FACTORY(ktupnpplugin,KGenericFactory<kt::UPnPPlugin>("ktupnpp namespace kt { - UPnPPlugin::UPnPPlugin(QObject* parent, const char* name, const QStringList& args) - : Plugin(parent, name, args,NAME,i18n("UPnP"),AUTHOR,EMAIL,i18n("Uses UPnP to automatically forward ports on your router"),"ktupnp") + UPnPPlugin::UPnPPlugin(TQObject* tqparent, const char* name, const TQStringList& args) + : Plugin(tqparent, name, args,NAME,i18n("UPnP"),AUTHOR,EMAIL,i18n("Uses UPnP to automatically forward ports on your router"),"ktupnp") { sock = 0; pref = 0; @@ -64,7 +64,7 @@ namespace kt pref = new UPnPPrefPage(sock); this->getGUI()->addPrefPage(pref); // load the routers list - QString routers_file = KGlobal::dirs()->saveLocation("data","ktorrent") + "routers"; + TQString routers_file = KGlobal::dirs()->saveLocation("data","ktorrent") + "routers"; if (bt::Exists(routers_file)) sock->loadRouters(routers_file); sock->discover(); @@ -72,7 +72,7 @@ namespace kt void UPnPPlugin::unload() { - QString routers_file = KGlobal::dirs()->saveLocation("data","ktorrent") + "routers"; + TQString routers_file = KGlobal::dirs()->saveLocation("data","ktorrent") + "routers"; sock->saveRouters(routers_file); this->getGUI()->removePrefPage(pref); sock->close(); @@ -87,7 +87,7 @@ namespace kt pref->shutdown(job); } - bool UPnPPlugin::versionCheck(const QString & version) const + bool UPnPPlugin::versionCheck(const TQString & version) const { return version == KT_VERSION_MACRO; } diff --git a/plugins/upnp/upnpplugin.h b/plugins/upnp/upnpplugin.h index a6ca78a..f6e10f0 100644 --- a/plugins/upnp/upnpplugin.h +++ b/plugins/upnp/upnpplugin.h @@ -33,14 +33,15 @@ namespace kt class UPnPPlugin : public Plugin { Q_OBJECT + TQ_OBJECT public: - UPnPPlugin(QObject* parent, const char* name, const QStringList& args); + UPnPPlugin(TQObject* tqparent, const char* name, const TQStringList& args); virtual ~UPnPPlugin(); virtual void load(); virtual void unload(); virtual void shutdown(bt::WaitJob* job); - virtual bool versionCheck(const QString& version) const; + virtual bool versionCheck(const TQString& version) const; private: UPnPMCastSocket* sock; UPnPPrefPage* pref; diff --git a/plugins/upnp/upnpprefpage.cpp b/plugins/upnp/upnpprefpage.cpp index dc50c2f..aa7a241 100644 --- a/plugins/upnp/upnpprefpage.cpp +++ b/plugins/upnp/upnpprefpage.cpp @@ -43,11 +43,11 @@ namespace kt return true; } - void UPnPPrefPage::createWidget(QWidget* parent) + void UPnPPrefPage::createWidget(TQWidget* tqparent) { - widget = new UPnPPrefWidget(parent); - QObject::connect(sock,SIGNAL(discovered(UPnPRouter* )),widget,SLOT(addDevice(UPnPRouter* ))); - QObject::connect(widget,SIGNAL(rescan()),sock,SLOT(discover())); + widget = new UPnPPrefWidget(tqparent); + TQObject::connect(sock,TQT_SIGNAL(discovered(UPnPRouter* )),widget,TQT_SLOT(addDevice(UPnPRouter* ))); + TQObject::connect(widget,TQT_SIGNAL(rescan()),sock,TQT_SLOT(discover())); } void UPnPPrefPage::deleteWidget() diff --git a/plugins/upnp/upnpprefpage.h b/plugins/upnp/upnpprefpage.h index 7d5b4f5..abba967 100644 --- a/plugins/upnp/upnpprefpage.h +++ b/plugins/upnp/upnpprefpage.h @@ -46,7 +46,7 @@ namespace kt virtual ~UPnPPrefPage(); virtual bool apply(); - virtual void createWidget(QWidget* parent); + virtual void createWidget(TQWidget* tqparent); virtual void deleteWidget(); virtual void updateData(); diff --git a/plugins/upnp/upnpprefwidget.cpp b/plugins/upnp/upnpprefwidget.cpp index 43e2aec..bd4e593 100644 --- a/plugins/upnp/upnpprefwidget.cpp +++ b/plugins/upnp/upnpprefwidget.cpp @@ -37,13 +37,13 @@ using namespace bt; namespace kt { - UPnPPrefWidget::UPnPPrefWidget(QWidget* parent, const char* name, WFlags fl) - : UPnPWidget(parent,name,fl) + UPnPPrefWidget::UPnPPrefWidget(TQWidget* tqparent, const char* name, WFlags fl) + : UPnPWidget(tqparent,name,fl) { def_router = 0; - connect(m_forward_btn,SIGNAL(clicked()),this,SLOT(onForwardBtnClicked())); - connect(m_undo_forward_btn,SIGNAL(clicked()),this,SLOT(onUndoForwardBtnClicked())); - connect(m_rescan,SIGNAL(clicked()),this,SLOT(onRescanClicked())); + connect(m_forward_btn,TQT_SIGNAL(clicked()),this,TQT_SLOT(onForwardBtnClicked())); + connect(m_undo_forward_btn,TQT_SIGNAL(clicked()),this,TQT_SLOT(onUndoForwardBtnClicked())); + connect(m_rescan,TQT_SIGNAL(clicked()),this,TQT_SLOT(onRescanClicked())); bt::Globals::instance().getPortList().setListener(this); } @@ -72,13 +72,13 @@ namespace kt void UPnPPrefWidget::addDevice(UPnPRouter* r) { - connect(r,SIGNAL(updateGUI()),this,SLOT(updatePortMappings())); + connect(r,TQT_SIGNAL(updateGUI()),this,TQT_SLOT(updatePortMappings())); KListViewItem* item = new KListViewItem(m_device_list,r->getDescription().friendlyName); item->setMultiLinesEnabled(true); itemmap[item] = r; // if we have discovered the default device or there is none // forward it's ports - QString def_dev = UPnPPluginSettings::defaultDevice(); + TQString def_dev = UPnPPluginSettings::defaultDevice(); if (def_dev == r->getServer() || def_dev.length() == 0) { Out(SYS_PNP|LOG_DEBUG) << "Doing default port mappings ..." << endl; @@ -126,7 +126,7 @@ namespace kt r->forward(p); } - QString def_dev = UPnPPluginSettings::defaultDevice(); + TQString def_dev = UPnPPluginSettings::defaultDevice(); if (def_dev != r->getServer()) { UPnPPluginSettings::setDefaultDevice(r->getServer()); @@ -168,10 +168,10 @@ namespace kt r->undoForward(p,false); } - QString def_dev = UPnPPluginSettings::defaultDevice(); + TQString def_dev = UPnPPluginSettings::defaultDevice(); if (def_dev == r->getServer()) { - UPnPPluginSettings::setDefaultDevice(QString::null); + UPnPPluginSettings::setDefaultDevice(TQString()); UPnPPluginSettings::writeConfig(); def_router = 0; } @@ -186,22 +186,22 @@ namespace kt void UPnPPrefWidget::updatePortMappings() { // update all port mappings - QMap<KListViewItem*,UPnPRouter*>::iterator i = itemmap.begin(); + TQMap<KListViewItem*,UPnPRouter*>::iterator i = itemmap.begin(); while (i != itemmap.end()) { UPnPRouter* r = i.data(); KListViewItem* item = i.key(); - QString msg,services; - QValueList<UPnPRouter::Forwarding>::iterator j = r->beginPortMappings(); + TQString msg,services; + TQValueList<UPnPRouter::Forwarding>::iterator j = r->beginPortMappings(); while (j != r->endPortMappings()) { UPnPRouter::Forwarding & f = *j; if (!f.pending_req) { - msg += QString::number(f.port.number) + " ("; - QString prot = (f.port.proto == net::UDP ? "UDP" : "TCP"); + msg += TQString::number(f.port.number) + " ("; + TQString prot = (f.port.proto == net::UDP ? "UDP" : "TCP"); msg += prot + ")"; - if (f.service->servicetype.contains("WANPPPConnection")) + if (f.service->servicetype.tqcontains("WANPPPConnection")) services += "PPP"; else services += "IP"; diff --git a/plugins/upnp/upnpprefwidget.h b/plugins/upnp/upnpprefwidget.h index 16fa31b..4c2c954 100644 --- a/plugins/upnp/upnpprefwidget.h +++ b/plugins/upnp/upnpprefwidget.h @@ -21,7 +21,7 @@ #ifndef UPNPPREFWIDGET_H #define UPNPPREFWIDGET_H -#include <qmap.h> +#include <tqmap.h> #include "upnprouter.h" #include "upnpwidget.h" @@ -41,9 +41,10 @@ namespace kt class UPnPPrefWidget : public UPnPWidget,public net::PortListener { Q_OBJECT + TQ_OBJECT public: - UPnPPrefWidget(QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + UPnPPrefWidget(TQWidget* tqparent = 0, const char* name = 0, WFlags fl = 0 ); virtual ~UPnPPrefWidget(); void shutdown(bt::WaitJob* job); @@ -74,7 +75,7 @@ namespace kt virtual void portRemoved(const net::Port & port); private: - QMap<KListViewItem*,UPnPRouter*> itemmap; + TQMap<KListViewItem*,UPnPRouter*> itemmap; UPnPRouter* def_router; }; } diff --git a/plugins/upnp/upnprouter.cpp b/plugins/upnp/upnprouter.cpp index 617abf5..e5593ea 100644 --- a/plugins/upnp/upnprouter.cpp +++ b/plugins/upnp/upnprouter.cpp @@ -21,7 +21,7 @@ #include <klocale.h> #include <kglobal.h> #include <kstandarddirs.h> -#include <qstringlist.h> +#include <tqstringlist.h> #include <kio/netaccess.h> #include <kio/job.h> #include <torrent/globals.h> @@ -54,7 +54,7 @@ namespace kt this->scpdurl = s.scpdurl; } - void UPnPService::setProperty(const QString & name,const QString & value) + void UPnPService::setProperty(const TQString & name,const TQString & value) { if (name == "serviceType") servicetype = value; @@ -94,7 +94,7 @@ namespace kt /////////////////////////////////////// - void UPnPDeviceDescription::setProperty(const QString & name,const QString & value) + void UPnPDeviceDescription::setProperty(const TQString & name,const TQString & value) { if (name == "friendlyName") friendlyName = value; @@ -110,16 +110,16 @@ namespace kt /////////////////////////////////////// - UPnPRouter::UPnPRouter(const QString & server,const KURL & location,bool verbose) : server(server),location(location),verbose(verbose) + UPnPRouter::UPnPRouter(const TQString & server,const KURL & location,bool verbose) : server(server),location(location),verbose(verbose) { // make the tmp_file unique, current time * a random number should be enough - tmp_file = QString("/tmp/ktorrent_upnp_description-%1.xml").arg(bt::GetCurrentTime() * rand()); + tmp_file = TQString("/tmp/ktorrent_upnp_description-%1.xml").tqarg(bt::GetCurrentTime() * rand()); } UPnPRouter::~UPnPRouter() { - QValueList<HTTPRequest*>::iterator i = active_reqs.begin(); + TQValueList<HTTPRequest*>::iterator i = active_reqs.begin(); while (i != active_reqs.end()) { (*i)->deleteLater(); @@ -129,7 +129,7 @@ namespace kt void UPnPRouter::addService(const UPnPService & s) { - QValueList<UPnPService>::iterator i = services.begin(); + TQValueList<UPnPService>::iterator i = services.begin(); while (i != services.end()) { UPnPService & os = *i; @@ -148,14 +148,14 @@ namespace kt return; } - QString target = tmp_file; + TQString target = tmp_file; // load in the file (target is always local) UPnPDescriptionParser desc_parse; bool ret = desc_parse.parse(target,this); if (!ret) { Out(SYS_PNP|LOG_IMPORTANT) << "Error parsing router description !" << endl; - QString dest = KGlobal::dirs()->saveLocation("data","ktorrent") + "upnp_failure"; + TQString dest = KGlobal::dirs()->saveLocation("data","ktorrent") + "upnp_failure"; KIO::file_copy(target,dest,-1,true,false,false); } else @@ -171,7 +171,7 @@ namespace kt { // downlaod XML description into a temporary file in /tmp KIO::Job* job = KIO::file_copy(location,tmp_file,-1,true,false,false); - connect(job,SIGNAL(result(KIO::Job *)),this,SLOT(downloadFinished( KIO::Job* ))); + connect(job,TQT_SIGNAL(result(KIO::Job *)),this,TQT_SLOT(downloadFinished( KIO::Job* ))); } void UPnPRouter::debugPrintData() @@ -182,7 +182,7 @@ namespace kt Out(SYS_PNP|LOG_DEBUG) << "Model description = " << desc.modelDescription << endl; Out(SYS_PNP|LOG_DEBUG) << "Model name = " << desc.modelName << endl; Out(SYS_PNP|LOG_DEBUG) << "Model number = " << desc.modelNumber << endl; - for (QValueList<UPnPService>::iterator i = services.begin();i != services.end();i++) + for (TQValueList<UPnPService>::iterator i = services.begin();i != services.end();i++) { UPnPService & s = *i; Out() << "Service : " << endl; @@ -196,14 +196,14 @@ namespace kt void UPnPRouter::forward(UPnPService* srv,const net::Port & port) { // add all the arguments for the command - QValueList<SOAP::Arg> args; + TQValueList<SOAP::Arg> args; SOAP::Arg a; a.element = "NewRemoteHost"; args.append(a); // the external port a.element = "NewExternalPort"; - a.value = QString::number(port.number); + a.value = TQString::number(port.number); args.append(a); // the protocol @@ -213,7 +213,7 @@ namespace kt // the local port a.element = "NewInternalPort"; - a.value = QString::number(port.number); + a.value = TQString::number(port.number); args.append(a); // the local IP address @@ -227,19 +227,19 @@ namespace kt a.element = "NewPortMappingDescription"; static Uint32 cnt = 0; - a.value = QString("KTorrent UPNP %1").arg(cnt++); // TODO: change this + a.value = TQString("KTorrent UPNP %1").tqarg(cnt++); // TODO: change this args.append(a); a.element = "NewLeaseDuration"; a.value = "0"; args.append(a); - QString action = "AddPortMapping"; - QString comm = SOAP::createCommand(action,srv->servicetype,args); + TQString action = "AddPortMapping"; + TQString comm = SOAP::createCommand(action,srv->servicetype,args); Forwarding fw = {port,0,srv}; // erase old forwarding if one exists - QValueList<Forwarding>::iterator itr = fwds.begin(); + TQValueList<Forwarding>::iterator itr = fwds.begin(); while (itr != fwds.end()) { Forwarding & fwo = *itr; @@ -257,7 +257,7 @@ namespace kt { Out(SYS_PNP|LOG_NOTICE) << "Forwarding port " << port.number << " (" << (port.proto == UDP ? "UDP" : "TCP") << ")" << endl; // first find the right service - QValueList<UPnPService>::iterator i = services.begin(); + TQValueList<UPnPService>::iterator i = services.begin(); while (i != services.end()) { UPnPService & s = *i; @@ -274,14 +274,14 @@ namespace kt void UPnPRouter::undoForward(UPnPService* srv,const net::Port & port,bt::WaitJob* waitjob) { // add all the arguments for the command - QValueList<SOAP::Arg> args; + TQValueList<SOAP::Arg> args; SOAP::Arg a; a.element = "NewRemoteHost"; args.append(a); // the external port a.element = "NewExternalPort"; - a.value = QString::number(port.number); + a.value = TQString::number(port.number); args.append(a); // the protocol @@ -290,8 +290,8 @@ namespace kt args.append(a); - QString action = "DeletePortMapping"; - QString comm = SOAP::createCommand(action,srv->servicetype,args); + TQString action = "DeletePortMapping"; + TQString comm = SOAP::createCommand(action,srv->servicetype,args); bt::HTTPRequest* r = sendSoapQuery(comm,srv->servicetype + "#" + action,srv->controlurl,waitjob != 0); if (waitjob) @@ -306,7 +306,7 @@ namespace kt Out(SYS_PNP|LOG_NOTICE) << "Undoing forward of port " << port.number << " (" << (port.proto == UDP ? "UDP" : "TCP") << ")" << endl; - QValueList<Forwarding>::iterator itr = fwds.begin(); + TQValueList<Forwarding>::iterator itr = fwds.begin(); while (itr != fwds.end()) { Forwarding & wd = *itr; @@ -322,29 +322,29 @@ namespace kt } } - bt::HTTPRequest* UPnPRouter::sendSoapQuery(const QString & query,const QString & soapact,const QString & controlurl,bool at_exit) + bt::HTTPRequest* UPnPRouter::sendSoapQuery(const TQString & query,const TQString & soapact,const TQString & controlurl,bool at_exit) { // if port is not set, 0 will be returned // thanks to Diego R. Brogna for spotting this bug if (location.port()==0) location.setPort(80); - QString http_hdr = QString( + TQString http_hdr = TQString( "POST %1 HTTP/1.1\r\n" "HOST: %2:%3\r\n" "Content-length: $CONTENT_LENGTH\r\n" "Content-Type: text/xml\r\n" "SOAPAction: \"%4\"\r\n" - "\r\n").arg(controlurl).arg(location.host()).arg(location.port()).arg(soapact); + "\r\n").tqarg(controlurl).tqarg(location.host()).tqarg(location.port()).tqarg(soapact); HTTPRequest* r = new HTTPRequest(http_hdr,query,location.host(),location.port(),verbose); - connect(r,SIGNAL(replyError(bt::HTTPRequest* ,const QString& )), - this,SLOT(onReplyError(bt::HTTPRequest* ,const QString& ))); - connect(r,SIGNAL(replyOK(bt::HTTPRequest* ,const QString& )), - this,SLOT(onReplyOK(bt::HTTPRequest* ,const QString& ))); - connect(r,SIGNAL(error(bt::HTTPRequest*, bool )), - this,SLOT(onError(bt::HTTPRequest*, bool ))); + connect(r,TQT_SIGNAL(replyError(bt::HTTPRequest* ,const TQString& )), + this,TQT_SLOT(onReplyError(bt::HTTPRequest* ,const TQString& ))); + connect(r,TQT_SIGNAL(replyOK(bt::HTTPRequest* ,const TQString& )), + this,TQT_SLOT(onReplyOK(bt::HTTPRequest* ,const TQString& ))); + connect(r,TQT_SIGNAL(error(bt::HTTPRequest*, bool )), + this,TQT_SLOT(onError(bt::HTTPRequest*, bool ))); r->start(); if (!at_exit) active_reqs.append(r); @@ -353,7 +353,7 @@ namespace kt void UPnPRouter::httpRequestDone(bt::HTTPRequest* r,bool erase_fwd) { - QValueList<Forwarding>::iterator i = fwds.begin(); + TQValueList<Forwarding>::iterator i = fwds.begin(); while (i != fwds.end()) { Forwarding & fw = *i; @@ -372,7 +372,7 @@ namespace kt r->deleteLater(); } - void UPnPRouter::onReplyOK(bt::HTTPRequest* r,const QString &) + void UPnPRouter::onReplyOK(bt::HTTPRequest* r,const TQString &) { if (verbose) Out(SYS_PNP|LOG_NOTICE) << "UPnPRouter : OK" << endl; @@ -380,7 +380,7 @@ namespace kt httpRequestDone(r,false); } - void UPnPRouter::onReplyError(bt::HTTPRequest* r,const QString &) + void UPnPRouter::onReplyError(bt::HTTPRequest* r,const TQString &) { if (verbose) Out(SYS_PNP|LOG_IMPORTANT) << "UPnPRouter : Error" << endl; @@ -395,9 +395,9 @@ namespace kt } #if 0 - QValueList<UPnPService>::iterator UPnPRouter::findPortForwardingService() + TQValueList<UPnPService>::iterator UPnPRouter::findPortForwardingService() { - QValueList<UPnPService>::iterator i = services.begin(); + TQValueList<UPnPService>::iterator i = services.begin(); while (i != services.end()) { UPnPService & s = *i; @@ -413,32 +413,32 @@ namespace kt void UPnPRouter::getExternalIP() { // first find the right service - QValueList<UPnPService>::iterator i = findPortForwardingService(); + TQValueList<UPnPService>::iterator i = findPortForwardingService(); if (i == services.end()) throw Error(i18n("Cannot find port forwarding service in the device's description!")); UPnPService & s = *i; - QString action = "GetExternalIPAddress"; - QString comm = SOAP::createCommand(action,s.servicetype); + TQString action = "GetExternalIPAddress"; + TQString comm = SOAP::createCommand(action,s.servicetype); sendSoapQuery(comm,s.servicetype + "#" + action,s.controlurl); } void UPnPRouter::isPortForwarded(const net::Port & port) { // first find the right service - QValueList<UPnPService>::iterator i = findPortForwardingService(); + TQValueList<UPnPService>::iterator i = findPortForwardingService(); if (i == services.end()) throw Error(i18n("Cannot find port forwarding service in the device's description!")); // add all the arguments for the command - QValueList<SOAP::Arg> args; + TQValueList<SOAP::Arg> args; SOAP::Arg a; a.element = "NewRemoteHost"; args.append(a); // the external port a.element = "NewExternalPort"; - a.value = QString::number(port.number); + a.value = TQString::number(port.number); args.append(a); // the protocol @@ -447,8 +447,8 @@ namespace kt args.append(a); UPnPService & s = *i; - QString action = "GetSpecificPortMappingEntry"; - QString comm = SOAP::createCommand(action,s.servicetype,args); + TQString action = "GetSpecificPortMappingEntry"; + TQString comm = SOAP::createCommand(action,s.servicetype,args); sendSoapQuery(comm,s.servicetype + "#" + action,s.controlurl); } #endif diff --git a/plugins/upnp/upnprouter.h b/plugins/upnp/upnprouter.h index a4d32b4..88b8054 100644 --- a/plugins/upnp/upnprouter.h +++ b/plugins/upnp/upnprouter.h @@ -21,7 +21,7 @@ #define KTUPNPROUTER_H #include <kurl.h> -#include <qstringlist.h> +#include <tqstringlist.h> #include <kstreamsocket.h> #include <net/portlist.h> @@ -45,11 +45,11 @@ namespace kt */ struct UPnPService { - QString serviceid; - QString servicetype; - QString controlurl; - QString eventsuburl; - QString scpdurl; + TQString serviceid; + TQString servicetype; + TQString controlurl; + TQString eventsuburl; + TQString scpdurl; UPnPService(); UPnPService(const UPnPService & s); @@ -59,7 +59,7 @@ namespace kt * @param name Name of the property (matches to variable names) * @param value Value of the property */ - void setProperty(const QString & name,const QString & value); + void setProperty(const TQString & name,const TQString & value); /** * Set all strings to empty. @@ -82,18 +82,18 @@ namespace kt */ struct UPnPDeviceDescription { - QString friendlyName; - QString manufacturer; - QString modelDescription; - QString modelName; - QString modelNumber; + TQString friendlyName; + TQString manufacturer; + TQString modelDescription; + TQString modelName; + TQString modelNumber; /** * Set a property of the description * @param name Name of the property (matches to variable names) * @param value Value of the property */ - void setProperty(const QString & name,const QString & value); + void setProperty(const TQString & name,const TQString & value); }; /** @@ -102,9 +102,10 @@ namespace kt * Class representing a UPnP enabled router. This class is also used to communicate * with the router. */ - class UPnPRouter : public QObject + class UPnPRouter : public TQObject { Q_OBJECT + TQ_OBJECT public: struct Forwarding @@ -114,13 +115,13 @@ namespace kt UPnPService* service; }; private: - QString server; - QString tmp_file; + TQString server; + TQString tmp_file; KURL location; UPnPDeviceDescription desc; - QValueList<UPnPService> services; - QValueList<Forwarding> fwds; - QValueList<bt::HTTPRequest*> active_reqs; + TQValueList<UPnPService> services; + TQValueList<Forwarding> fwds; + TQValueList<bt::HTTPRequest*> active_reqs; public: /** * Construct a router. @@ -128,11 +129,11 @@ namespace kt * @param location The location of it's xml description file * @param verbose Print lots of debug info */ - UPnPRouter(const QString & server,const KURL & location,bool verbose = false); + UPnPRouter(const TQString & server,const KURL & location,bool verbose = false); virtual ~UPnPRouter(); /// Get the name of the server - QString getServer() const {return server;} + TQString getServer() const {return server;} /// Get the location of it's xml description KURL getLocation() const {return location;} @@ -183,12 +184,12 @@ namespace kt void debugPrintData(); - QValueList<Forwarding>::iterator beginPortMappings() {return fwds.begin();} - QValueList<Forwarding>::iterator endPortMappings() {return fwds.end();} + TQValueList<Forwarding>::iterator beginPortMappings() {return fwds.begin();} + TQValueList<Forwarding>::iterator endPortMappings() {return fwds.end();} private slots: - void onReplyOK(bt::HTTPRequest* r,const QString &); - void onReplyError(bt::HTTPRequest* r,const QString &); + void onReplyOK(bt::HTTPRequest* r,const TQString &); + void onReplyError(bt::HTTPRequest* r,const TQString &); void onError(bt::HTTPRequest* r,bool); void downloadFinished(KIO::Job* j); @@ -208,9 +209,9 @@ namespace kt void xmlFileDownloaded(UPnPRouter* r,bool success); private: - QValueList<UPnPService>::iterator findPortForwardingService(); + TQValueList<UPnPService>::iterator findPortForwardingService(); - bt::HTTPRequest* sendSoapQuery(const QString & query,const QString & soapact,const QString & controlurl,bool at_exit = false); + bt::HTTPRequest* sendSoapQuery(const TQString & query,const TQString & soapact,const TQString & controlurl,bool at_exit = false); bool verbose; void forward(UPnPService* srv,const net::Port & port); diff --git a/plugins/upnp/upnpwidget.ui b/plugins/upnp/upnpwidget.ui index a8f0f7a..ffd8900 100644 --- a/plugins/upnp/upnpwidget.ui +++ b/plugins/upnp/upnpwidget.ui @@ -1,6 +1,6 @@ <!DOCTYPE UI><UI version="3.3" stdsetdef="1"> <class>UPnPWidget</class> -<widget class="QWidget"> +<widget class="TQWidget"> <property name="name"> <cstring>UPnPWidget</cstring> </property> @@ -19,15 +19,15 @@ <property name="name"> <cstring>unnamed</cstring> </property> - <widget class="QLayoutWidget"> + <widget class="TQLayoutWidget"> <property name="name"> - <cstring>layout1</cstring> + <cstring>tqlayout1</cstring> </property> <vbox> <property name="name"> <cstring>unnamed</cstring> </property> - <widget class="QLabel"> + <widget class="TQLabel"> <property name="name"> <cstring>textLabel1</cstring> </property> @@ -75,9 +75,9 @@ </widget> </vbox> </widget> - <widget class="QLayoutWidget"> + <widget class="TQLayoutWidget"> <property name="name"> - <cstring>layout3</cstring> + <cstring>tqlayout3</cstring> </property> <hbox> <property name="name"> @@ -109,14 +109,14 @@ <property name="sizeType"> <enum>Expanding</enum> </property> - <property name="sizeHint"> + <property name="tqsizeHint"> <size> <width>70</width> <height>20</height> </size> </property> </spacer> - <widget class="QPushButton"> + <widget class="TQPushButton"> <property name="name"> <cstring>m_rescan</cstring> </property> @@ -130,7 +130,7 @@ </widget> <customwidgets> </customwidgets> -<layoutdefaults spacing="6" margin="11"/> +<tqlayoutdefaults spacing="6" margin="11"/> <includehints> <includehint>klistview.h</includehint> <includehint>kpushbutton.h</includehint> |