diff options
Diffstat (limited to 'kopete/protocols/jabber/libiris/iris/jabber/filetransfer.cpp')
-rw-r--r-- | kopete/protocols/jabber/libiris/iris/jabber/filetransfer.cpp | 190 |
1 files changed, 95 insertions, 95 deletions
diff --git a/kopete/protocols/jabber/libiris/iris/jabber/filetransfer.cpp b/kopete/protocols/jabber/libiris/iris/jabber/filetransfer.cpp index dd458ef0..87743e7f 100644 --- a/kopete/protocols/jabber/libiris/iris/jabber/filetransfer.cpp +++ b/kopete/protocols/jabber/libiris/iris/jabber/filetransfer.cpp @@ -20,10 +20,10 @@ #include"filetransfer.h" -#include<qtimer.h> -#include<qptrlist.h> -#include<qguardedptr.h> -#include<qfileinfo.h> +#include<tqtimer.h> +#include<tqptrlist.h> +#include<tqguardedptr.h> +#include<tqfileinfo.h> #include"xmpp_xmlcommon.h" #include"s5b.h" @@ -34,13 +34,13 @@ using namespace XMPP; // firstChildElement // // Get an element's first child element -static QDomElement firstChildElement(const QDomElement &e) +static TQDomElement firstChildElement(const TQDomElement &e) { - for(QDomNode n = e.firstChild(); !n.isNull(); n = n.nextSibling()) { + for(TQDomNode n = e.firstChild(); !n.isNull(); n = n.nextSibling()) { if(n.isElement()) return n.toElement(); } - return QDomElement(); + return TQDomElement(); } //---------------------------------------------------------------------------- @@ -52,23 +52,23 @@ public: FileTransferManager *m; JT_FT *ft; Jid peer; - QString fname; + TQString fname; Q_LLONG size; Q_LLONG sent; - QString desc; + TQString desc; bool rangeSupported; Q_LLONG rangeOffset, rangeLength, length; - QString streamType; + TQString streamType; bool needStream; - QString id, iq_id; + TQString id, iq_id; S5BConnection *c; Jid proxy; int state; bool sender; }; -FileTransfer::FileTransfer(FileTransferManager *m, QObject *parent) -:QObject(parent) +FileTransfer::FileTransfer(FileTransferManager *m, TQObject *parent) +:TQObject(parent) { d = new Private; d->m = m; @@ -104,7 +104,7 @@ void FileTransfer::setProxy(const Jid &proxy) d->proxy = proxy; } -void FileTransfer::sendFile(const Jid &to, const QString &fname, Q_LLONG size, const QString &desc) +void FileTransfer::sendFile(const Jid &to, const TQString &fname, Q_LLONG size, const TQString &desc) { d->state = Requesting; d->peer = to; @@ -115,8 +115,8 @@ void FileTransfer::sendFile(const Jid &to, const QString &fname, Q_LLONG size, c d->id = d->m->link(this); d->ft = new JT_FT(d->m->client()->rootTask()); - connect(d->ft, SIGNAL(finished()), SLOT(ft_finished())); - QStringList list; + connect(d->ft, TQT_SIGNAL(finished()), TQT_SLOT(ft_finished())); + TQStringList list; list += "http://jabber.org/protocol/bytestreams"; d->ft->request(to, d->id, fname, size, desc, list); d->ft->go(true); @@ -134,14 +134,14 @@ int FileTransfer::dataSizeNeeded() const return size; } -void FileTransfer::writeFileData(const QByteArray &a) +void FileTransfer::writeFileData(const TQByteArray &a) { int pending = d->c->bytesToWrite(); Q_LLONG left = d->length - (d->sent + pending); if(left == 0) return; - QByteArray block; + TQByteArray block; if((Q_LLONG)a.size() > left) { block = a.copy(); block.resize((uint)left); @@ -156,7 +156,7 @@ Jid FileTransfer::peer() const return d->peer; } -QString FileTransfer::fileName() const +TQString FileTransfer::fileName() const { return d->fname; } @@ -166,7 +166,7 @@ Q_LLONG FileTransfer::fileSize() const return d->size; } -QString FileTransfer::description() const +TQString FileTransfer::description() const { return d->desc; } @@ -228,10 +228,10 @@ void FileTransfer::ft_finished() d->length = d->size - d->rangeOffset; d->streamType = ft->streamType(); d->c = d->m->client()->s5bManager()->createConnection(); - connect(d->c, SIGNAL(connected()), SLOT(s5b_connected())); - connect(d->c, SIGNAL(connectionClosed()), SLOT(s5b_connectionClosed())); - connect(d->c, SIGNAL(bytesWritten(int)), SLOT(s5b_bytesWritten(int))); - connect(d->c, SIGNAL(error(int)), SLOT(s5b_error(int))); + connect(d->c, TQT_SIGNAL(connected()), TQT_SLOT(s5b_connected())); + connect(d->c, TQT_SIGNAL(connectionClosed()), TQT_SLOT(s5b_connectionClosed())); + connect(d->c, TQT_SIGNAL(bytesWritten(int)), TQT_SLOT(s5b_bytesWritten(int))); + connect(d->c, TQT_SIGNAL(error(int)), TQT_SLOT(s5b_error(int))); if(d->proxy.isValid()) d->c->setProxy(d->proxy); @@ -250,14 +250,14 @@ void FileTransfer::ft_finished() void FileTransfer::takeConnection(S5BConnection *c) { d->c = c; - connect(d->c, SIGNAL(connected()), SLOT(s5b_connected())); - connect(d->c, SIGNAL(connectionClosed()), SLOT(s5b_connectionClosed())); - connect(d->c, SIGNAL(readyRead()), SLOT(s5b_readyRead())); - connect(d->c, SIGNAL(error(int)), SLOT(s5b_error(int))); + connect(d->c, TQT_SIGNAL(connected()), TQT_SLOT(s5b_connected())); + connect(d->c, TQT_SIGNAL(connectionClosed()), TQT_SLOT(s5b_connectionClosed())); + connect(d->c, TQT_SIGNAL(readyRead()), TQT_SLOT(s5b_readyRead())); + connect(d->c, TQT_SIGNAL(error(int)), TQT_SLOT(s5b_error(int))); if(d->proxy.isValid()) d->c->setProxy(d->proxy); accepted(); - QTimer::singleShot(0, this, SLOT(doAccept())); + TQTimer::singleShot(0, this, TQT_SLOT(doAccept())); } void FileTransfer::s5b_connected() @@ -274,7 +274,7 @@ void FileTransfer::s5b_connectionClosed() void FileTransfer::s5b_readyRead() { - QByteArray a = d->c->read(); + TQByteArray a = d->c->read(); Q_LLONG need = d->length - d->sent; if((Q_LLONG)a.size() > need) a.resize((uint)need); @@ -327,18 +327,18 @@ class FileTransferManager::Private { public: Client *client; - QPtrList<FileTransfer> list, incoming; + TQPtrList<FileTransfer> list, incoming; JT_PushFT *pft; }; FileTransferManager::FileTransferManager(Client *client) -:QObject(client) +:TQObject(client) { d = new Private; d->client = client; d->pft = new JT_PushFT(d->client->rootTask()); - connect(d->pft, SIGNAL(incoming(const FTRequest &)), SLOT(pft_incoming(const FTRequest &))); + connect(d->pft, TQT_SIGNAL(incoming(const FTRequest &)), TQT_SLOT(pft_incoming(const FTRequest &))); } FileTransferManager::~FileTransferManager() @@ -376,7 +376,7 @@ FileTransfer *FileTransferManager::takeIncoming() void FileTransferManager::pft_incoming(const FTRequest &req) { bool found = false; - for(QStringList::ConstIterator it = req.streamTypes.begin(); it != req.streamTypes.end(); ++it) { + for(TQStringList::ConstIterator it = req.streamTypes.begin(); it != req.streamTypes.end(); ++it) { if((*it) == "http://jabber.org/protocol/bytestreams") { found = true; break; @@ -399,7 +399,7 @@ void FileTransferManager::pft_incoming(const FTRequest &req) void FileTransferManager::s5b_incomingReady(S5BConnection *c) { - QPtrListIterator<FileTransfer> it(d->list); + TQPtrListIterator<FileTransfer> it(d->list); FileTransfer *ft = 0; for(FileTransfer *i; (i = it.current()); ++it) { if(i->d->needStream && i->d->peer.compare(c->peer()) && i->d->id == c->sid()) { @@ -415,7 +415,7 @@ void FileTransferManager::s5b_incomingReady(S5BConnection *c) ft->takeConnection(c); } -QString FileTransferManager::link(FileTransfer *ft) +TQString FileTransferManager::link(FileTransfer *ft) { d->list.append(ft); return d->client->s5bManager()->genUniqueSID(ft->d->peer); @@ -443,11 +443,11 @@ void FileTransferManager::unlink(FileTransfer *ft) class JT_FT::Private { public: - QDomElement iq; + TQDomElement iq; Jid to; Q_LLONG size, rangeOffset, rangeLength; - QString streamType; - QStringList streamTypes; + TQString streamType; + TQStringList streamTypes; }; JT_FT::JT_FT(Task *parent) @@ -461,41 +461,41 @@ JT_FT::~JT_FT() delete d; } -void JT_FT::request(const Jid &to, const QString &_id, const QString &fname, Q_LLONG size, const QString &desc, const QStringList &streamTypes) +void JT_FT::request(const Jid &to, const TQString &_id, const TQString &fname, Q_LLONG size, const TQString &desc, const TQStringList &streamTypes) { - QDomElement iq; + TQDomElement iq; d->to = to; iq = createIQ(doc(), "set", to.full(), id()); - QDomElement si = doc()->createElement("si"); + TQDomElement si = doc()->createElement("si"); si.setAttribute("xmlns", "http://jabber.org/protocol/si"); si.setAttribute("id", _id); si.setAttribute("profile", "http://jabber.org/protocol/si/profile/file-transfer"); - QDomElement file = doc()->createElement("file"); + TQDomElement file = doc()->createElement("file"); file.setAttribute("xmlns", "http://jabber.org/protocol/si/profile/file-transfer"); file.setAttribute("name", fname); - file.setAttribute("size", QString::number(size)); + file.setAttribute("size", TQString::number(size)); if(!desc.isEmpty()) { - QDomElement de = doc()->createElement("desc"); + TQDomElement de = doc()->createElement("desc"); de.appendChild(doc()->createTextNode(desc)); file.appendChild(de); } - QDomElement range = doc()->createElement("range"); + TQDomElement range = doc()->createElement("range"); file.appendChild(range); si.appendChild(file); - QDomElement feature = doc()->createElement("feature"); + TQDomElement feature = doc()->createElement("feature"); feature.setAttribute("xmlns", "http://jabber.org/protocol/feature-neg"); - QDomElement x = doc()->createElement("x"); + TQDomElement x = doc()->createElement("x"); x.setAttribute("xmlns", "jabber:x:data"); x.setAttribute("type", "form"); - QDomElement field = doc()->createElement("field"); + TQDomElement field = doc()->createElement("field"); field.setAttribute("var", "stream-method"); field.setAttribute("type", "list-single"); - for(QStringList::ConstIterator it = streamTypes.begin(); it != streamTypes.end(); ++it) { - QDomElement option = doc()->createElement("option"); - QDomElement value = doc()->createElement("value"); + for(TQStringList::ConstIterator it = streamTypes.begin(); it != streamTypes.end(); ++it) { + TQDomElement option = doc()->createElement("option"); + TQDomElement value = doc()->createElement("value"); value.appendChild(doc()->createTextNode(*it)); option.appendChild(value); field.appendChild(option); @@ -522,7 +522,7 @@ Q_LLONG JT_FT::rangeLength() const return d->rangeLength; } -QString JT_FT::streamType() const +TQString JT_FT::streamType() const { return d->streamType; } @@ -532,26 +532,26 @@ void JT_FT::onGo() send(d->iq); } -bool JT_FT::take(const QDomElement &x) +bool JT_FT::take(const TQDomElement &x) { if(!iqVerify(x, d->to, id())) return false; if(x.attribute("type") == "result") { - QDomElement si = firstChildElement(x); + TQDomElement si = firstChildElement(x); if(si.attribute("xmlns") != "http://jabber.org/protocol/si" || si.tagName() != "si") { setError(900, ""); return true; } - QString id = si.attribute("id"); + TQString id = si.attribute("id"); Q_LLONG range_offset = 0; Q_LLONG range_length = 0; - QDomElement file = si.elementsByTagName("file").item(0).toElement(); + TQDomElement file = si.elementsByTagName("file").item(0).toElement(); if(!file.isNull()) { - QDomElement range = file.elementsByTagName("range").item(0).toElement(); + TQDomElement range = file.elementsByTagName("range").item(0).toElement(); if(!range.isNull()) { int x; bool ok; @@ -587,14 +587,14 @@ bool JT_FT::take(const QDomElement &x) return true; } - QString streamtype; - QDomElement feature = si.elementsByTagName("feature").item(0).toElement(); + TQString streamtype; + TQDomElement feature = si.elementsByTagName("feature").item(0).toElement(); if(!feature.isNull() && feature.attribute("xmlns") == "http://jabber.org/protocol/feature-neg") { - QDomElement x = feature.elementsByTagName("x").item(0).toElement(); + TQDomElement x = feature.elementsByTagName("x").item(0).toElement(); if(!x.isNull() && x.attribute("type") == "submit") { - QDomElement field = x.elementsByTagName("field").item(0).toElement(); + TQDomElement field = x.elementsByTagName("field").item(0).toElement(); if(!field.isNull() && field.attribute("var") == "stream-method") { - QDomElement value = field.elementsByTagName("value").item(0).toElement(); + TQDomElement value = field.elementsByTagName("value").item(0).toElement(); if(!value.isNull()) streamtype = value.text(); } @@ -603,7 +603,7 @@ bool JT_FT::take(const QDomElement &x) // must be one of the offered streamtypes bool found = false; - for(QStringList::ConstIterator it = d->streamTypes.begin(); it != d->streamTypes.end(); ++it) { + for(TQStringList::ConstIterator it = d->streamTypes.begin(); it != d->streamTypes.end(); ++it) { if((*it) == streamtype) { found = true; break; @@ -636,33 +636,33 @@ JT_PushFT::~JT_PushFT() { } -void JT_PushFT::respondSuccess(const Jid &to, const QString &id, Q_LLONG rangeOffset, Q_LLONG rangeLength, const QString &streamType) +void JT_PushFT::respondSuccess(const Jid &to, const TQString &id, Q_LLONG rangeOffset, Q_LLONG rangeLength, const TQString &streamType) { - QDomElement iq = createIQ(doc(), "result", to.full(), id); - QDomElement si = doc()->createElement("si"); + TQDomElement iq = createIQ(doc(), "result", to.full(), id); + TQDomElement si = doc()->createElement("si"); si.setAttribute("xmlns", "http://jabber.org/protocol/si"); if(rangeOffset != 0 || rangeLength != 0) { - QDomElement file = doc()->createElement("file"); + TQDomElement file = doc()->createElement("file"); file.setAttribute("xmlns", "http://jabber.org/protocol/si/profile/file-transfer"); - QDomElement range = doc()->createElement("range"); + TQDomElement range = doc()->createElement("range"); if(rangeOffset > 0) - range.setAttribute("offset", QString::number(rangeOffset)); + range.setAttribute("offset", TQString::number(rangeOffset)); if(rangeLength > 0) - range.setAttribute("length", QString::number(rangeLength)); + range.setAttribute("length", TQString::number(rangeLength)); file.appendChild(range); si.appendChild(file); } - QDomElement feature = doc()->createElement("feature"); + TQDomElement feature = doc()->createElement("feature"); feature.setAttribute("xmlns", "http://jabber.org/protocol/feature-neg"); - QDomElement x = doc()->createElement("x"); + TQDomElement x = doc()->createElement("x"); x.setAttribute("xmlns", "jabber:x:data"); x.setAttribute("type", "submit"); - QDomElement field = doc()->createElement("field"); + TQDomElement field = doc()->createElement("field"); field.setAttribute("var", "stream-method"); - QDomElement value = doc()->createElement("value"); + TQDomElement value = doc()->createElement("value"); value.appendChild(doc()->createTextNode(streamType)); field.appendChild(value); @@ -674,16 +674,16 @@ void JT_PushFT::respondSuccess(const Jid &to, const QString &id, Q_LLONG rangeOf send(iq); } -void JT_PushFT::respondError(const Jid &to, const QString &id, int code, const QString &str) +void JT_PushFT::respondError(const Jid &to, const TQString &id, int code, const TQString &str) { - QDomElement iq = createIQ(doc(), "error", to.full(), id); - QDomElement err = textTag(doc(), "error", str); - err.setAttribute("code", QString::number(code)); + TQDomElement iq = createIQ(doc(), "error", to.full(), id); + TQDomElement err = textTag(doc(), "error", str); + err.setAttribute("code", TQString::number(code)); iq.appendChild(err); send(iq); } -bool JT_PushFT::take(const QDomElement &e) +bool JT_PushFT::take(const TQDomElement &e) { // must be an iq-set tag if(e.tagName() != "iq") @@ -691,20 +691,20 @@ bool JT_PushFT::take(const QDomElement &e) if(e.attribute("type") != "set") return false; - QDomElement si = firstChildElement(e); + TQDomElement si = firstChildElement(e); if(si.attribute("xmlns") != "http://jabber.org/protocol/si" || si.tagName() != "si") return false; if(si.attribute("profile") != "http://jabber.org/protocol/si/profile/file-transfer") return false; Jid from(e.attribute("from")); - QString id = si.attribute("id"); + TQString id = si.attribute("id"); - QDomElement file = si.elementsByTagName("file").item(0).toElement(); + TQDomElement file = si.elementsByTagName("file").item(0).toElement(); if(file.isNull()) return true; - QString fname = file.attribute("name"); + TQString fname = file.attribute("name"); if(fname.isEmpty()) { respondError(from, id, 400, "Bad file name"); return true; @@ -712,7 +712,7 @@ bool JT_PushFT::take(const QDomElement &e) // ensure kosher { - QFileInfo fi(fname); + TQFileInfo fi(fname); fname = fi.fileName(); } @@ -727,27 +727,27 @@ bool JT_PushFT::take(const QDomElement &e) return true; } - QString desc; - QDomElement de = file.elementsByTagName("desc").item(0).toElement(); + TQString desc; + TQDomElement de = file.elementsByTagName("desc").item(0).toElement(); if(!de.isNull()) desc = de.text(); bool rangeSupported = false; - QDomElement range = file.elementsByTagName("range").item(0).toElement(); + TQDomElement range = file.elementsByTagName("range").item(0).toElement(); if(!range.isNull()) rangeSupported = true; - QStringList streamTypes; - QDomElement feature = si.elementsByTagName("feature").item(0).toElement(); + TQStringList streamTypes; + TQDomElement feature = si.elementsByTagName("feature").item(0).toElement(); if(!feature.isNull() && feature.attribute("xmlns") == "http://jabber.org/protocol/feature-neg") { - QDomElement x = feature.elementsByTagName("x").item(0).toElement(); + TQDomElement x = feature.elementsByTagName("x").item(0).toElement(); if(!x.isNull() /*&& x.attribute("type") == "form"*/) { - QDomElement field = x.elementsByTagName("field").item(0).toElement(); + TQDomElement field = x.elementsByTagName("field").item(0).toElement(); if(!field.isNull() && field.attribute("var") == "stream-method" && field.attribute("type") == "list-single") { - QDomNodeList nl = field.elementsByTagName("option"); + TQDomNodeList nl = field.elementsByTagName("option"); for(uint n = 0; n < nl.count(); ++n) { - QDomElement e = nl.item(n).toElement(); - QDomElement value = e.elementsByTagName("value").item(0).toElement(); + TQDomElement e = nl.item(n).toElement(); + TQDomElement value = e.elementsByTagName("value").item(0).toElement(); if(!value.isNull()) streamTypes += value.text(); } |