diff options
Diffstat (limited to 'kopete/protocols/msn/dispatcher.cpp')
-rw-r--r-- | kopete/protocols/msn/dispatcher.cpp | 166 |
1 files changed, 83 insertions, 83 deletions
diff --git a/kopete/protocols/msn/dispatcher.cpp b/kopete/protocols/msn/dispatcher.cpp index 8b8bbed6..fb88e8bc 100644 --- a/kopete/protocols/msn/dispatcher.cpp +++ b/kopete/protocols/msn/dispatcher.cpp @@ -37,11 +37,11 @@ using P2P::OutgoingTransfer; #include <ktempfile.h> // Qt includes -#include <qdatastream.h> -#include <qfile.h> -#include <qregexp.h> -#include <qtextcodec.h> -#include <qtextstream.h> +#include <tqdatastream.h> +#include <tqfile.h> +#include <tqregexp.h> +#include <tqtextcodec.h> +#include <tqtextstream.h> // Kopete includes #include <kopetechatsession.h> // Just for getting the contact @@ -50,8 +50,8 @@ using P2P::OutgoingTransfer; #include <stdlib.h> -Dispatcher::Dispatcher(QObject *parent, const QString& contact, const QStringList &ip) - : QObject(parent) , m_contact(contact) , m_callbackChannel(0l) , m_ip(ip) +Dispatcher::Dispatcher(TQObject *parent, const TQString& contact, const TQStringList &ip) + : TQObject(parent) , m_contact(contact) , m_callbackChannel(0l) , m_ip(ip) {} Dispatcher::~Dispatcher() @@ -71,12 +71,12 @@ void Dispatcher::detach(TransferContext* transfer) transfer->deleteLater(); } -QString Dispatcher::localContact() +TQString Dispatcher::localContact() { return m_contact; } -void Dispatcher::requestDisplayIcon(const QString& from, const QString& msnObject) +void Dispatcher::requestDisplayIcon(const TQString& from, const TQString& msnObject) { Q_UINT32 sessionId = rand()%0xFFFFFF00 + 4; TransferContext* current = @@ -91,13 +91,13 @@ void Dispatcher::requestDisplayIcon(const QString& from, const QString& msnObjec kdDebug(14140) << k_funcinfo << "Requesting, " << msnObject << endl; - QString context = QString::fromUtf8(KCodecs::base64Encode(msnObject.utf8())); + TQString context = TQString::fromUtf8(KCodecs::base64Encode(msnObject.utf8())); // NOTE remove the \0 character automatically - // appended to a QCString. - context.replace("=", QString::null); - QString content = + // appended to a TQCString. + context.replace("=", TQString::null); + TQString content = "EUF-GUID: {A4268EEC-FEC5-49E5-95C3-F126696BDBF6}\r\n" - "SessionID: " + QString::number(sessionId) + "\r\n" + "SessionID: " + TQString::number(sessionId) + "\r\n" "AppID: 1\r\n" "Context: " + context + "\r\n" "\r\n"; @@ -105,7 +105,7 @@ void Dispatcher::requestDisplayIcon(const QString& from, const QString& msnObjec current->sendMessage(INVITE, content); } -void Dispatcher::sendFile(const QString& path, Q_INT64 fileSize, const QString& to) +void Dispatcher::sendFile(const TQString& path, Q_INT64 fileSize, const TQString& to) { // Create a new transfer context that will handle // the file transfer. @@ -119,14 +119,14 @@ void Dispatcher::sendFile(const QString& path, Q_INT64 fileSize, const QString& m_sessions.insert(sessionId, current); // Set the transfer context file. - current->m_file = new QFile(path); + current->m_file = new TQFile(path); // Create the file context data. - QString context; + TQString context; - QByteArray header(638); + TQByteArray header(638); header.fill('\0'); - QDataStream writer(header, IO_WriteOnly); - writer.setByteOrder(QDataStream::LittleEndian); + TQDataStream writer(header, IO_WriteOnly); + writer.setByteOrder(TQDataStream::LittleEndian); // Write the header length to the stream. writer << (Q_INT32)638; @@ -138,8 +138,8 @@ void Dispatcher::sendFile(const QString& path, Q_INT64 fileSize, const QString& // TODO support file preview. For now disable file preview. writer << (Q_INT32)1; // Write the file name in utf-16 to the stream. - QTextStream ts(header, IO_WriteOnly); - ts.setEncoding(QTextStream::RawUnicode); + TQTextStream ts(header, IO_WriteOnly); + ts.setEncoding(TQTextStream::RawUnicode); ts.device()->at(20); ts << path.section('/', -1); // NOTE Background Sharing base64 [540..569] @@ -151,21 +151,21 @@ void Dispatcher::sendFile(const QString& path, Q_INT64 fileSize, const QString& writer << (Q_UINT32)0xFFFFFFFF; // Encode the file context header to base64 encoding. - context = QString::fromUtf8(KCodecs::base64Encode(header)); + context = TQString::fromUtf8(KCodecs::base64Encode(header)); // Send an INVITE message to the recipient. - QString content = "EUF-GUID: {5D3E02AB-6190-11D3-BBBB-00C04F795683}\r\n" - "SessionID: " + QString::number(sessionId) + "\r\n" + TQString content = "EUF-GUID: {5D3E02AB-6190-11D3-BBBB-00C04F795683}\r\n" + "SessionID: " + TQString::number(sessionId) + "\r\n" "AppID: 2\r\n" "Context: " + context + "\r\n" "\r\n"; current->sendMessage(INVITE, content); } -void Dispatcher::sendImage(const QString& /*fileName*/, const QString& /*to*/) +void Dispatcher::sendImage(const TQString& /*fileName*/, const TQString& /*to*/) { // TODO kdDebug(14140) << k_funcinfo << endl; -// QFile imageFile(fileName); +// TQFile imageFile(fileName); // if(!imageFile.open(IO_ReadOnly)) // { // kdDebug(14140) << k_funcinfo << "Error opening image file." @@ -180,7 +180,7 @@ void Dispatcher::sendImage(const QString& /*fileName*/, const QString& /*to*/) } #if MSN_WEBCAM -void Dispatcher::startWebcam(const QString &/*myHandle*/, const QString &msgHandle, bool wantToReceive) +void Dispatcher::startWebcam(const TQString &/*myHandle*/, const TQString &msgHandle, bool wantToReceive) { Q_UINT32 sessionId = rand()%0xFFFFFF00 + 4; Webcam::Who who= wantToReceive ? Webcam::wViewer : Webcam::wProducer; @@ -195,10 +195,10 @@ void Dispatcher::startWebcam(const QString &/*myHandle*/, const QString &msgHand // {4BD96FC0-AB17-4425-A14A-439185962DC8} <- i want to show you my webcam // {1C9AA97E-9C05-4583-A3BD-908A196F1E92} <- i want to see your webcam - QString GUID= (who==Webcam::wProducer) ? "4BD96FC0-AB17-4425-A14A-439185962DC8" : "1C9AA97E-9C05-4583-A3BD-908A196F1E92" ; + TQString GUID= (who==Webcam::wProducer) ? "4BD96FC0-AB17-4425-A14A-439185962DC8" : "1C9AA97E-9C05-4583-A3BD-908A196F1E92" ; - QString content="EUF-GUID: {"+GUID+"}\r\n" - "SessionID: "+ QString::number(sessionId)+"\r\n" + TQString content="EUF-GUID: {"+GUID+"}\r\n" + "SessionID: "+ TQString::number(sessionId)+"\r\n" "AppID: 4\r\n" "Context: ewBCADgAQgBFADcAMABEAEUALQBFADIAQwBBAC0ANAA0ADAAMAAtAEEARQAwADMALQA4ADgARgBGADgANQBCADkARgA0AEUAOAB9AA==\r\n\r\n"; @@ -210,7 +210,7 @@ void Dispatcher::startWebcam(const QString &/*myHandle*/, const QString &msgHand -void Dispatcher::slotReadMessage(const QString &from, const QByteArray& stream) +void Dispatcher::slotReadMessage(const TQString &from, const TQByteArray& stream) { P2P::Message receivedMessage = m_messageFormatter.readMessage(stream); @@ -222,7 +222,7 @@ void Dispatcher::slotReadMessage(const QString &from, const QByteArray& stream) if((receivedMessage.header.dataSize == 0)/* && ((receivedMessage.header.flag & 0x02) == 0x02)*/) { TransferContext *current = 0l; - QMap<Q_UINT32, TransferContext*>::Iterator it = m_sessions.begin(); + TQMap<Q_UINT32, TransferContext*>::Iterator it = m_sessions.begin(); for(; it != m_sessions.end(); it++) { if(receivedMessage.header.ackSessionIdentifier == it.data()->m_identifier){ @@ -250,7 +250,7 @@ void Dispatcher::slotReadMessage(const QString &from, const QByteArray& stream) if(m_messageBuffer.contains(receivedMessage.header.identifier)) { kdDebug(14140) << k_funcinfo - << QString("retrieving buffered messsage, %1").arg(receivedMessage.header.identifier) + << TQString("retrieving buffered messsage, %1").arg(receivedMessage.header.identifier) << endl; // The message was split, try to reconstruct the message @@ -288,9 +288,9 @@ void Dispatcher::dispatch(const P2P::Message& message) } else { - QString body = - QCString(message.body.data(), message.header.dataSize); - QRegExp regex("SessionID: ([0-9]*)\r\n"); + TQString body = + TQCString(message.body.data(), message.header.dataSize); + TQRegExp regex("SessionID: ([0-9]*)\r\n"); if(regex.search(body) > 0) { Q_UINT32 sessionId = regex.cap(1).toUInt(); @@ -312,12 +312,12 @@ void Dispatcher::dispatch(const P2P::Message& message) { // If the message handler still has not been found, // try to retrieve the handler based on the call id. - regex = QRegExp("Call-ID: \\{([0-9A-F\\-]*)\\}\r\n"); + regex = TQRegExp("Call-ID: \\{([0-9A-F\\-]*)\\}\r\n"); regex.search(body); - QString callId = regex.cap(1); + TQString callId = regex.cap(1); TransferContext *current = 0l; - QMap<Q_UINT32, TransferContext*>::Iterator it = m_sessions.begin(); + TQMap<Q_UINT32, TransferContext*>::Iterator it = m_sessions.begin(); for(; it != m_sessions.end(); it++) { current = it.data(); @@ -347,14 +347,14 @@ void Dispatcher::dispatch(const P2P::Message& message) // The entire message has not been received; // buffer the recevied portion of the original message. kdDebug(14140) << k_funcinfo - << QString("Buffering messsage, %1").arg(message.header.identifier) + << TQString("Buffering messsage, %1").arg(message.header.identifier) << endl; m_messageBuffer.insert(message.header.identifier, message); return; } - QString body = - QCString(message.body.data(), message.header.dataSize); + TQString body = + TQCString(message.body.data(), message.header.dataSize); kdDebug(14140) << k_funcinfo << "received, " << body << endl; if(body.startsWith("INVITE")) @@ -362,23 +362,23 @@ void Dispatcher::dispatch(const P2P::Message& message) // Retrieve the branch, call id, and session id. // These fields will be used later on in the p2p // transaction. - QRegExp regex(";branch=\\{([0-9A-F\\-]*)\\}\r\n"); + TQRegExp regex(";branch=\\{([0-9A-F\\-]*)\\}\r\n"); regex.search(body); - QString branch = regex.cap(1); - regex = QRegExp("Call-ID: \\{([0-9A-F\\-]*)\\}\r\n"); + TQString branch = regex.cap(1); + regex = TQRegExp("Call-ID: \\{([0-9A-F\\-]*)\\}\r\n"); regex.search(body); - QString callId = regex.cap(1); - regex = QRegExp("SessionID: ([0-9]*)\r\n"); + TQString callId = regex.cap(1); + regex = TQRegExp("SessionID: ([0-9]*)\r\n"); regex.search(body); - QString sessionId = regex.cap(1); + TQString sessionId = regex.cap(1); // Retrieve the contact that requested the session. - regex = QRegExp("From: <msnmsgr:([^>]*)>"); + regex = TQRegExp("From: <msnmsgr:([^>]*)>"); regex.search(body); - QString from = regex.cap(1); + TQString from = regex.cap(1); // Retrieve the application identifier which // is used to determine what type of session // is being requested. - regex = QRegExp("AppID: ([0-9]*)\r\n"); + regex = TQRegExp("AppID: ([0-9]*)\r\n"); regex.search(body); Q_UINT32 applicationId = regex.cap(1).toUInt(); @@ -387,9 +387,9 @@ void Dispatcher::dispatch(const P2P::Message& message) // A contact has requested a session to download // a display icon (User Display Icon or CustomEmotion). - regex = QRegExp("Context: ([0-9a-zA-Z+/=]*)"); + regex = TQRegExp("Context: ([0-9a-zA-Z+/=]*)"); regex.search(body); - QCString msnobj; + TQCString msnobj; // Decode the msn object from base64 encoding. KCodecs::base64Decode(regex.cap(1).utf8() , msnobj); @@ -407,10 +407,10 @@ void Dispatcher::dispatch(const P2P::Message& message) m_sessions.insert(sessionId.toUInt(), current); // Determine the display icon being requested. - QString fileName = objectList.contains(msnobj) + TQString fileName = objectList.contains(msnobj) ? objectList[msnobj] : m_pictureUrl; - QFile *source = new QFile(fileName); + TQFile *source = new TQFile(fileName); // Try to open the source file for reading. // If an error occurs, send an internal // error message to the recipient. @@ -427,7 +427,7 @@ void Dispatcher::dispatch(const P2P::Message& message) current->m_ackSessionIdentifier = message.header.identifier; current->m_ackUniqueIdentifier = message.header.ackSessionIdentifier; // Send a 200 OK message to the recipient. - QString content = QString("SessionID: %1\r\n\r\n").arg(sessionId); + TQString content = TQString("SessionID: %1\r\n\r\n").arg(sessionId); current->sendMessage(OK, content); } else if(applicationId == 2) @@ -447,14 +447,14 @@ void Dispatcher::dispatch(const P2P::Message& message) // Add the transfer to the list. m_sessions.insert(sessionId.toUInt(), transfer); - regex = QRegExp("Context: ([0-9a-zA-Z+/=]*)"); + regex = TQRegExp("Context: ([0-9a-zA-Z+/=]*)"); regex.search(body); - QByteArray context; + TQByteArray context; // Decode the file context from base64 encoding. KCodecs::base64Decode(regex.cap(1).utf8(), context); - QDataStream reader(context, IO_ReadOnly); - reader.setByteOrder(QDataStream::LittleEndian); + TQDataStream reader(context, IO_ReadOnly); + reader.setByteOrder(TQDataStream::LittleEndian); //Retrieve the file info from the context field. // File Size [8..15] Int64 reader.device()->at(8); @@ -468,17 +468,17 @@ void Dispatcher::dispatch(const P2P::Message& message) reader >> flag; kdDebug(14140) << flag << endl; // FileName UTF16 (Unicode) [19..539] - QByteArray bytes(520); + TQByteArray bytes(520); reader.readRawBytes(bytes.data(), bytes.size()); - QTextStream ts(bytes, IO_ReadOnly); - ts.setEncoding(QTextStream::Unicode); - QString fileName; + TQTextStream ts(bytes, IO_ReadOnly); + ts.setEncoding(TQTextStream::Unicode); + TQString fileName; fileName = ts.readLine().utf8(); emit incomingTransfer(from, fileName, fileSize); kdDebug(14140) << - QString("%1, %2 bytes.").arg(fileName, QString::number(fileSize)) + TQString("%1, %2 bytes.").arg(fileName, TQString::number(fileSize)) << endl << endl; @@ -493,11 +493,11 @@ void Dispatcher::dispatch(const P2P::Message& message) transfer->m_ackSessionIdentifier = message.header.identifier; transfer->m_ackUniqueIdentifier = message.header.ackSessionIdentifier; - QObject::connect(Kopete::TransferManager::transferManager(), SIGNAL(accepted(Kopete::Transfer*, const QString&)), transfer, SLOT(slotTransferAccepted(Kopete::Transfer*, const QString&))); - QObject::connect(Kopete::TransferManager::transferManager(), SIGNAL(refused(const Kopete::FileTransferInfo&)), transfer, SLOT(slotTransferRefused(const Kopete::FileTransferInfo&))); + TQObject::connect(Kopete::TransferManager::transferManager(), TQT_SIGNAL(accepted(Kopete::Transfer*, const TQString&)), transfer, TQT_SLOT(slotTransferAccepted(Kopete::Transfer*, const TQString&))); + TQObject::connect(Kopete::TransferManager::transferManager(), TQT_SIGNAL(refused(const Kopete::FileTransferInfo&)), transfer, TQT_SLOT(slotTransferRefused(const Kopete::FileTransferInfo&))); // Show the file transfer accept/decline dialog. - Kopete::TransferManager::transferManager()->askIncomingTransfer(contact, fileName, fileSize, QString::null, sessionId); + Kopete::TransferManager::transferManager()->askIncomingTransfer(contact, fileName, fileSize, TQString::null, sessionId); } else { @@ -512,9 +512,9 @@ void Dispatcher::dispatch(const P2P::Message& message) else if(applicationId == 4) { #if MSN_WEBCAM - regex = QRegExp("EUF-GUID: \\{([0-9a-zA-Z\\-]*)\\}"); + regex = TQRegExp("EUF-GUID: \\{([0-9a-zA-Z\\-]*)\\}"); regex.search(body); - QString GUID=regex.cap(1); + TQString GUID=regex.cap(1); kdDebug(14140) << k_funcinfo << "webcam " << GUID << endl; @@ -542,7 +542,7 @@ void Dispatcher::dispatch(const P2P::Message& message) m_sessions.insert(sessionId.toUInt(), current); // Acknowledge the session request. current->acknowledge(message); - QTimer::singleShot(0,current, SLOT(askIncommingInvitation()) ); + TQTimer::singleShot(0,current, TQT_SLOT(askIncommingInvitation()) ); #endif } } @@ -550,26 +550,26 @@ void Dispatcher::dispatch(const P2P::Message& message) { // A contact has sent an inkformat (handwriting) gif. // NOTE The entire message body is UTF16 encoded. - QString body = ""; + TQString body = ""; for (Q_UINT32 i=0; i < message.header.totalDataSize; i++){ - if (message.body[i] != QChar('\0')){ - body += QChar(message.body[i]); + if (message.body[i] != TQChar('\0')){ + body += TQChar(message.body[i]); } } - QRegExp regex("Content-Type: ([A-Za-z0-9$!*/\\-]*)"); + TQRegExp regex("Content-Type: ([A-Za-z0-9$!*/\\-]*)"); regex.search(body); - QString contentType = regex.cap(1); + TQString contentType = regex.cap(1); if(contentType == "image/gif") { IncomingTransfer transfer(message.source, this, message.header.sessionId); transfer.acknowledge(message); - regex = QRegExp("base64:([0-9a-zA-Z+/=]*)"); + regex = TQRegExp("base64:([0-9a-zA-Z+/=]*)"); regex.search(body); - QString base64 = regex.cap(1); - QByteArray image; + TQString base64 = regex.cap(1); + TQByteArray image; // Convert from base64 encoding to byte array. KCodecs::base64Decode(base64.utf8(), image); // Create a temporary file to store the image data. @@ -590,7 +590,7 @@ void Dispatcher::messageAcknowledged(unsigned int correlationId, bool fullReceiv if(fullReceive) { TransferContext *current = 0l; - QMap<Q_UINT32, TransferContext*>::Iterator it = m_sessions.begin(); + TQMap<Q_UINT32, TransferContext*>::Iterator it = m_sessions.begin(); for(; it != m_sessions.end(); it++) { current = it.data(); @@ -604,7 +604,7 @@ void Dispatcher::messageAcknowledged(unsigned int correlationId, bool fullReceiv } } -Kopete::Contact* Dispatcher::getContactByAccountId(const QString& accountId) +Kopete::Contact* Dispatcher::getContactByAccountId(const TQString& accountId) { Kopete::Contact *contact = 0l; if(parent()) @@ -628,7 +628,7 @@ Dispatcher::CallbackChannel::CallbackChannel(MSNSwitchBoardSocket *switchboard) Dispatcher::CallbackChannel::~CallbackChannel() {} -Q_UINT32 Dispatcher::CallbackChannel::send(const QByteArray& stream) +Q_UINT32 Dispatcher::CallbackChannel::send(const TQByteArray& stream) { return m_switchboard->sendCommand("MSG", "D", true, stream, true); } |