diff options
Diffstat (limited to 'src/modules/dcc/DccBroker.cpp')
| -rw-r--r-- | src/modules/dcc/DccBroker.cpp | 698 |
1 files changed, 364 insertions, 334 deletions
diff --git a/src/modules/dcc/DccBroker.cpp b/src/modules/dcc/DccBroker.cpp index 53df4ffeb..08e9373d8 100644 --- a/src/modules/dcc/DccBroker.cpp +++ b/src/modules/dcc/DccBroker.cpp @@ -31,11 +31,11 @@ #include "DccVoiceWindow.h" #ifndef COMPILE_DISABLE_DCC_VIDEO - #include "DccVideoWindow.h" +#include "DccVideoWindow.h" #endif #ifdef COMPILE_DCC_CANVAS - #include "DccCanvasWindow.h" +#include "DccCanvasWindow.h" #endif #include "KviApplication.h" @@ -60,7 +60,7 @@ extern KVIRC_API KviSharedFilesManager * g_pSharedFilesManager; //#warning "The broker might lookup the remote host name" DccBroker::DccBroker() -: QObject(0) + : QObject(0) { setObjectName("dcc_broker"); DccFileTransfer::init(); @@ -71,22 +71,23 @@ DccBroker::DccBroker() m_pDccWindowList = new KviPointerList<KviWindow>; m_pDccWindowList->setAutoDelete(false); - m_pZeroPortTags = new KviPointerHashTable<QString,KviDccZeroPortTag>(17); + m_pZeroPortTags = new KviPointerHashTable<QString, KviDccZeroPortTag>(17); m_pZeroPortTags->setAutoDelete(true); } DccBroker::~DccBroker() { delete m_pZeroPortTags; - while(m_pBoxList->first())delete m_pBoxList->first(); + while(m_pBoxList->first()) + delete m_pBoxList->first(); delete m_pBoxList; m_pBoxList = 0; - while(m_pDccWindowList->first())delete m_pDccWindowList->first(); + while(m_pDccWindowList->first()) + delete m_pDccWindowList->first(); delete m_pDccWindowList; DccFileTransfer::done(); } - KviDccZeroPortTag * DccBroker::addZeroPortTag() { static unsigned int g_uNextZeroPortTag = 0; @@ -97,14 +98,15 @@ KviDccZeroPortTag * DccBroker::addZeroPortTag() //t->m_szTag.prepend("mIrc-zero-port-"); t->m_uResumePosition = 0; // FIXME: we should clear this dict if it grows too high.... - m_pZeroPortTags->insert(t->m_szTag,t); + m_pZeroPortTags->insert(t->m_szTag, t); return t; } -KviDccZeroPortTag * DccBroker::findZeroPortTag(const QString &szTag) +KviDccZeroPortTag * DccBroker::findZeroPortTag(const QString & szTag) { KviDccZeroPortTag * t = m_pZeroPortTags->find(szTag); - if(!t)return 0; + if(!t) + return 0; if(t->m_tTimestamp.secsTo(QDateTime::currentDateTime()) > 180) { // too late man... @@ -114,7 +116,7 @@ KviDccZeroPortTag * DccBroker::findZeroPortTag(const QString &szTag) return t; } -void DccBroker::removeZeroPortTag(const QString &szTag) +void DccBroker::removeZeroPortTag(const QString & szTag) { m_pZeroPortTags->remove(szTag); } @@ -124,7 +126,7 @@ unsigned int DccBroker::dccBoxCount() return m_pBoxList->count(); } -void DccBroker::unregisterDccWindow(KviWindow *wnd) +void DccBroker::unregisterDccWindow(KviWindow * wnd) { m_pDccWindowList->removeRef(wnd); } @@ -141,9 +143,10 @@ void DccBroker::cancelDcc(DccDescriptor * dcc) dcc = 0; } -void DccBroker::cancelDcc(DccDialog *box,DccDescriptor * dcc) +void DccBroker::cancelDcc(DccDialog * box, DccDescriptor * dcc) { - if(box)box->forgetDescriptor(); + if(box) + box->forgetDescriptor(); delete dcc; dcc = 0; } @@ -156,42 +159,45 @@ void DccBroker::rsendManage(DccDescriptor * dcc) { // We need the filename... QFileInfo fi(dcc->szLocalFileName); - if(fi.exists())rsendExecute(0,dcc); - else rsendAskForFileName(dcc); + if(fi.exists()) + rsendExecute(0, dcc); + else + rsendAskForFileName(dcc); } void DccBroker::rsendAskForFileName(DccDescriptor * dcc) { QStringList filenames; if( - KviFileDialog::askForOpenFileNames( - filenames, - __tr2qs_ctx("Choose Files to Send - KVIrc","dcc"), - QString(), - QString(), - false, - true, - g_pMainWindow - ) - ) { - if(filenames.count() > 0) + KviFileDialog::askForOpenFileNames( + filenames, + __tr2qs_ctx("Choose Files to Send - KVIrc", "dcc"), + QString(), + QString(), + false, + true, + g_pMainWindow)) + { + if(filenames.count() > 0) + { + DccDescriptor * d; + QStringList::Iterator it = filenames.begin(); + while(it != filenames.end()) { - DccDescriptor * d; - QStringList::Iterator it=filenames.begin(); - while(it != filenames.end()) - { - d = new DccDescriptor(*dcc); - d->szLocalFileName = *(it); - d->szLocalFileName = d->szLocalFileName.trimmed(); - ++it; - if(d->szLocalFileName.isEmpty()) - cancelDcc(d); - else - rsendExecute(d); - } - delete dcc; + d = new DccDescriptor(*dcc); + d->szLocalFileName = *(it); + d->szLocalFileName = d->szLocalFileName.trimmed(); + ++it; + if(d->szLocalFileName.isEmpty()) + cancelDcc(d); + else + rsendExecute(d); } - } else { + delete dcc; + } + } + else + { cancelDcc(dcc); } } @@ -202,8 +208,8 @@ void DccBroker::rsendExecute(DccDescriptor * dcc) { // No way...we NEED the right IRC context... g_pApp->activeConsole()->output(KVI_OUT_DCCERROR, - __tr2qs_ctx("Can't send DCC %Q request to %Q: IRC connection has been terminated","dcc"), - &(dcc->szType),&(dcc->szNick)); + __tr2qs_ctx("Can't send DCC %Q request to %Q: IRC connection has been terminated", "dcc"), + &(dcc->szType), &(dcc->szNick)); delete dcc; return; } @@ -212,8 +218,8 @@ void DccBroker::rsendExecute(DccDescriptor * dcc) QFileInfo fi(dcc->szLocalFileName); if(!(fi.exists() && fi.isReadable() && (fi.isFile()) && (fi.size() > 0))) { - dcc->console()->output(KVI_OUT_DCCERROR,__tr2qs_ctx("Can't open file %Q for reading","dcc"), - &(dcc->szLocalFileName)); + dcc->console()->output(KVI_OUT_DCCERROR, __tr2qs_ctx("Can't open file %Q for reading", "dcc"), + &(dcc->szLocalFileName)); delete dcc; return; } @@ -222,7 +228,7 @@ void DccBroker::rsendExecute(DccDescriptor * dcc) dcc->szFileName = QFileInfo(dcc->szFileName).fileName(); QString fName = dcc->szFileName; - fName.replace(' ',"\\040"); // be cool :) + fName.replace(' ', "\\040"); // be cool :) QString szTag; if(dcc->isZeroPortRequest()) @@ -236,21 +242,23 @@ void DccBroker::rsendExecute(DccDescriptor * dcc) // DCC [ST]SEND <filename> <fakeipaddress> <zero-port> <filesize> <sessionid> dcc->console()->connection()->sendFmtData("PRIVMSG %s :%cDCC %s %s 127.0.0.1 0 %s %s%c", - dcc->console()->connection()->encodeText(dcc->szNick).data(), - 0x01, - dcc->console()->connection()->encodeText(dcc->szType).data(), - dcc->console()->connection()->encodeText(fName).data(), - dcc->console()->connection()->encodeText(QString::number(fi.size())).data(), - dcc->console()->connection()->encodeText(szTag).data(), - 0x01); - } else { + dcc->console()->connection()->encodeText(dcc->szNick).data(), + 0x01, + dcc->console()->connection()->encodeText(dcc->szType).data(), + dcc->console()->connection()->encodeText(fName).data(), + dcc->console()->connection()->encodeText(QString::number(fi.size())).data(), + dcc->console()->connection()->encodeText(szTag).data(), + 0x01); + } + else + { dcc->console()->connection()->sendFmtData("PRIVMSG %s :%cDCC %s %s %s%c", - dcc->console()->connection()->encodeText(dcc->szNick).data(), - 0x01, - dcc->console()->connection()->encodeText(dcc->szType).data(), - dcc->console()->connection()->encodeText(fName).data(), - dcc->console()->connection()->encodeText(QString::number(fi.size())).data(), - 0x01); + dcc->console()->connection()->encodeText(dcc->szNick).data(), + 0x01, + dcc->console()->connection()->encodeText(dcc->szType).data(), + dcc->console()->connection()->encodeText(fName).data(), + dcc->console()->connection()->encodeText(QString::number(fi.size())).data(), + 0x01); szTag = dcc->szFileName; } @@ -259,18 +267,18 @@ void DccBroker::rsendExecute(DccDescriptor * dcc) QString szMask = dcc->szNick; szMask += "!*@*"; - g_pSharedFilesManager->addSharedFile(szTag,dcc->szLocalFileName,szMask,120); + g_pSharedFilesManager->addSharedFile(szTag, dcc->szLocalFileName, szMask, 120); delete dcc; } -void DccBroker::rsendExecute(DccDialog * box,DccDescriptor * dcc) +void DccBroker::rsendExecute(DccDialog * box, DccDescriptor * dcc) { - if(box)box->forgetDescriptor(); + if(box) + box->forgetDescriptor(); rsendExecute(dcc); } - /////////////////////////////////////////////////////////////////////////////// // DCC CHAT /////////////////////////////////////////////////////////////////////////////// @@ -281,46 +289,51 @@ void DccBroker::handleChatRequest(DccDescriptor * dcc) { // FIXME: better message ? Secure Direct Client Connection...eventually // need confirmation - QString tmp = __tr2qs_ctx( \ - "<b>%1 [%2@%3]</b> requests a " \ - "<b>Direct Client Connection</b> in <b>%4</b> mode.<br>", \ - "dcc").arg(dcc->szNick, dcc->szUser, dcc->szHost, dcc->szType); + QString tmp = __tr2qs_ctx( + "<b>%1 [%2@%3]</b> requests a " + "<b>Direct Client Connection</b> in <b>%4</b> mode.<br>", + "dcc") + .arg(dcc->szNick, dcc->szUser, dcc->szHost, dcc->szType); #ifdef COMPILE_SSL_SUPPORT - if(dcc->bIsSSL)tmp += __tr2qs_ctx("The connection will be secured using SSL.<br>","dcc"); + if(dcc->bIsSSL) + tmp += __tr2qs_ctx("The connection will be secured using SSL.<br>", "dcc"); #endif if(dcc->isZeroPortRequest()) { - tmp += __tr2qs_ctx( \ - "You will be the passive side of the connection.<br>" \ - ,"dcc"); - } else { - tmp += __tr2qs_ctx( \ - "The connection target will be host <b>%1</b> on port <b>%2</b><br>" \ - ,"dcc").arg(dcc->szIp, dcc->szPort); + tmp += __tr2qs_ctx( + "You will be the passive side of the connection.<br>", "dcc"); + } + else + { + tmp += __tr2qs_ctx( + "The connection target will be host <b>%1</b> on port <b>%2</b><br>", "dcc") + .arg(dcc->szIp, dcc->szPort); } + QString caption = __tr2qs_ctx("DCC %1 Request - KVIrc", "dcc").arg(dcc->szType); - QString caption = __tr2qs_ctx("DCC %1 Request - KVIrc","dcc").arg(dcc->szType); - - DccAcceptDialog * box = new DccAcceptDialog(this,dcc,tmp,caption); + DccAcceptDialog * box = new DccAcceptDialog(this, dcc, tmp, caption); m_pBoxList->append(box); - connect(box,SIGNAL(accepted(DccDialog *,DccDescriptor *)), - this,SLOT(executeChat(DccDialog *,DccDescriptor *))); - connect(box,SIGNAL(rejected(DccDialog *,DccDescriptor *)), - this,SLOT(cancelDcc(DccDialog *,DccDescriptor *))); + connect(box, SIGNAL(accepted(DccDialog *, DccDescriptor *)), + this, SLOT(executeChat(DccDialog *, DccDescriptor *))); + connect(box, SIGNAL(rejected(DccDialog *, DccDescriptor *)), + this, SLOT(cancelDcc(DccDialog *, DccDescriptor *))); box->show(); - } else { + } + else + { // auto accept - executeChat(0,dcc); + executeChat(0, dcc); } } -void DccBroker::executeChat(DccDialog *box,DccDescriptor * dcc) +void DccBroker::executeChat(DccDialog * box, DccDescriptor * dcc) { - if(box)box->forgetDescriptor(); + if(box) + box->forgetDescriptor(); if(!g_pApp->windowExists(dcc->console())) { @@ -332,13 +345,11 @@ void DccBroker::executeChat(DccDialog *box,DccDescriptor * dcc) szSubProto.toLower(); QString tmp = QString("dcc: %1 %2@%3:%4").arg(szSubProto.ptr(), dcc->szNick, dcc->szIp, dcc->szPort); - DccChatWindow * chat = new DccChatWindow(dcc,tmp.toUtf8().data()); + DccChatWindow * chat = new DccChatWindow(dcc, tmp.toUtf8().data()); - bool bMinimized = dcc->bOverrideMinimize ? dcc->bShowMinimized : \ - (KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccChat) || \ - (dcc->bAutoAccept && KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccChatWhenAutoAccepted))); + bool bMinimized = dcc->bOverrideMinimize ? dcc->bShowMinimized : (KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccChat) || (dcc->bAutoAccept && KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccChatWhenAutoAccepted))); - g_pMainWindow->addWindow(chat,!bMinimized); + g_pMainWindow->addWindow(chat, !bMinimized); m_pDccWindowList->append(chat); } @@ -352,28 +363,31 @@ void DccBroker::activeVoiceManage(DccDescriptor * dcc) { // need confirmation QString tmp = __tr2qs_ctx( - "<b>%1 [%2@%3]</b> requests a<br>" \ - "<b>Direct Client Connection</b> in <b>VOICE</b> mode.<br>" \ - "The connection target will be host <b>%4</b> on port <b>%5</b><br>" \ - ,"dcc" \ - ).arg(dcc->szNick, dcc->szUser, dcc->szHost, dcc->szIp, dcc->szPort); + "<b>%1 [%2@%3]</b> requests a<br>" + "<b>Direct Client Connection</b> in <b>VOICE</b> mode.<br>" + "The connection target will be host <b>%4</b> on port <b>%5</b><br>", + "dcc") + .arg(dcc->szNick, dcc->szUser, dcc->szHost, dcc->szIp, dcc->szPort); - DccAcceptDialog * box = new DccAcceptDialog(this,dcc,tmp,__tr2qs_ctx("DCC VOICE request","dcc")); + DccAcceptDialog * box = new DccAcceptDialog(this, dcc, tmp, __tr2qs_ctx("DCC VOICE request", "dcc")); m_pBoxList->append(box); - connect(box,SIGNAL(accepted(DccDialog *,DccDescriptor *)), - this,SLOT(activeVoiceExecute(DccDialog *,DccDescriptor *))); - connect(box,SIGNAL(rejected(DccDialog *,DccDescriptor *)), - this,SLOT(cancelDcc(DccDialog *,DccDescriptor *))); + connect(box, SIGNAL(accepted(DccDialog *, DccDescriptor *)), + this, SLOT(activeVoiceExecute(DccDialog *, DccDescriptor *))); + connect(box, SIGNAL(rejected(DccDialog *, DccDescriptor *)), + this, SLOT(cancelDcc(DccDialog *, DccDescriptor *))); box->show(); - } else { + } + else + { // auto accept - activeVoiceExecute(0,dcc); + activeVoiceExecute(0, dcc); } } -void DccBroker::activeVoiceExecute(DccDialog *box,DccDescriptor * dcc) +void DccBroker::activeVoiceExecute(DccDialog * box, DccDescriptor * dcc) { - if(box)box->forgetDescriptor(); + if(box) + box->forgetDescriptor(); if(!g_pApp->windowExists(dcc->console())) { @@ -381,34 +395,30 @@ void DccBroker::activeVoiceExecute(DccDialog *box,DccDescriptor * dcc) dcc->setConsole(g_pApp->activeConsole()); } - KviCString tmp(KviCString::Format,"dcc: voice %s@%s:%s",dcc->szNick.toUtf8().data(),dcc->szIp.toUtf8().data(),dcc->szPort.toUtf8().data()); - DccVoiceWindow * v = new DccVoiceWindow(dcc,tmp.ptr()); + KviCString tmp(KviCString::Format, "dcc: voice %s@%s:%s", dcc->szNick.toUtf8().data(), dcc->szIp.toUtf8().data(), dcc->szPort.toUtf8().data()); + DccVoiceWindow * v = new DccVoiceWindow(dcc, tmp.ptr()); - bool bMinimized = dcc->bOverrideMinimize ? dcc->bShowMinimized : \ - (KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccVoice) || \ - (dcc->bAutoAccept && KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccVoiceWhenAutoAccepted))); + bool bMinimized = dcc->bOverrideMinimize ? dcc->bShowMinimized : (KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccVoice) || (dcc->bAutoAccept && KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccVoiceWhenAutoAccepted))); - g_pMainWindow->addWindow(v,!bMinimized); + g_pMainWindow->addWindow(v, !bMinimized); m_pDccWindowList->append(v); } - /////////////////////////////////////////////////////////////////////////////// // PASSIVE VOICE /////////////////////////////////////////////////////////////////////////////// void DccBroker::passiveVoiceExecute(DccDescriptor * dcc) { - KviCString tmp(KviCString::Format,"dcc: voice %s@%s:%s",dcc->szNick.toUtf8().data(),dcc->szIp.toUtf8().data(),dcc->szPort.toUtf8().data()); - DccVoiceWindow * v = new DccVoiceWindow(dcc,tmp.ptr()); + KviCString tmp(KviCString::Format, "dcc: voice %s@%s:%s", dcc->szNick.toUtf8().data(), dcc->szIp.toUtf8().data(), dcc->szPort.toUtf8().data()); + DccVoiceWindow * v = new DccVoiceWindow(dcc, tmp.ptr()); //#warning "Create minimized dcc voice ?... or maybe it's too much ? :)" bool bMinimized = dcc->bOverrideMinimize ? dcc->bShowMinimized : KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccChat); - g_pMainWindow->addWindow(v,!bMinimized); + g_pMainWindow->addWindow(v, !bMinimized); m_pDccWindowList->append(v); } - /////////////////////////////////////////////////////////////////////////////// // ACTIVE VIDEO /////////////////////////////////////////////////////////////////////////////// @@ -420,28 +430,31 @@ void DccBroker::activeVideoManage(DccDescriptor * dcc) { // need confirmation QString tmp = __tr2qs_ctx( - "<b>%1 [%2@%3]</b> requests a<br>" \ - "<b>Direct Client Connection</b> in <b>VIDEO</b> mode.<br>" \ - "The connection target will be host <b>%4</b> on port <b>%5</b><br>" \ - ,"dcc" \ - ).arg(dcc->szNick, dcc->szUser, dcc->szHost, dcc->szIp, dcc->szPort); + "<b>%1 [%2@%3]</b> requests a<br>" + "<b>Direct Client Connection</b> in <b>VIDEO</b> mode.<br>" + "The connection target will be host <b>%4</b> on port <b>%5</b><br>", + "dcc") + .arg(dcc->szNick, dcc->szUser, dcc->szHost, dcc->szIp, dcc->szPort); - DccAcceptDialog * box = new DccAcceptDialog(this,dcc,tmp,__tr2qs_ctx("DCC VIDEO request","dcc")); + DccAcceptDialog * box = new DccAcceptDialog(this, dcc, tmp, __tr2qs_ctx("DCC VIDEO request", "dcc")); m_pBoxList->append(box); - connect(box,SIGNAL(accepted(DccDialog *,DccDescriptor *)), - this,SLOT(activeVideoExecute(DccDialog *,DccDescriptor *))); - connect(box,SIGNAL(rejected(DccDialog *,DccDescriptor *)), - this,SLOT(cancelDcc(DccDialog *,DccDescriptor *))); + connect(box, SIGNAL(accepted(DccDialog *, DccDescriptor *)), + this, SLOT(activeVideoExecute(DccDialog *, DccDescriptor *))); + connect(box, SIGNAL(rejected(DccDialog *, DccDescriptor *)), + this, SLOT(cancelDcc(DccDialog *, DccDescriptor *))); box->show(); - } else { + } + else + { // auto accept - activeVideoExecute(0,dcc); + activeVideoExecute(0, dcc); } } -void DccBroker::activeVideoExecute(DccDialog *box,DccDescriptor * dcc) +void DccBroker::activeVideoExecute(DccDialog * box, DccDescriptor * dcc) { - if(box)box->forgetDescriptor(); + if(box) + box->forgetDescriptor(); if(!g_pApp->windowExists(dcc->console())) { @@ -449,23 +462,20 @@ void DccBroker::activeVideoExecute(DccDialog *box,DccDescriptor * dcc) dcc->setConsole(g_pApp->activeConsole()); } - KviCString tmp(KviCString::Format,"dcc: video %s@%s:%s",dcc->szNick.toUtf8().data(),dcc->szIp.toUtf8().data(),dcc->szPort.toUtf8().data()); - DccVideoWindow * v = new DccVideoWindow(dcc,tmp.ptr()); + KviCString tmp(KviCString::Format, "dcc: video %s@%s:%s", dcc->szNick.toUtf8().data(), dcc->szIp.toUtf8().data(), dcc->szPort.toUtf8().data()); + DccVideoWindow * v = new DccVideoWindow(dcc, tmp.ptr()); - bool bMinimized = dcc->bOverrideMinimize ? dcc->bShowMinimized : \ - (KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccVideo) || \ - (dcc->bAutoAccept && KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccVideoWhenAutoAccepted))); + bool bMinimized = dcc->bOverrideMinimize ? dcc->bShowMinimized : (KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccVideo) || (dcc->bAutoAccept && KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccVideoWhenAutoAccepted))); - g_pMainWindow->addWindow(v,!bMinimized); + g_pMainWindow->addWindow(v, !bMinimized); m_pDccWindowList->append(v); #else -void DccBroker::activeVideoExecute(DccDialog *,DccDescriptor *) +void DccBroker::activeVideoExecute(DccDialog *, DccDescriptor *) { #endif } - /////////////////////////////////////////////////////////////////////////////// // PASSIVE VIDEO /////////////////////////////////////////////////////////////////////////////// @@ -473,11 +483,11 @@ void DccBroker::activeVideoExecute(DccDialog *,DccDescriptor *) #ifndef COMPILE_DISABLE_DCC_VIDEO void DccBroker::passiveVideoExecute(DccDescriptor * dcc) { - KviCString tmp(KviCString::Format,"dcc: video %s@%s:%s",dcc->szNick.toUtf8().data(),dcc->szIp.toUtf8().data(),dcc->szPort.toUtf8().data()); - DccVideoWindow * v = new DccVideoWindow(dcc,tmp.ptr()); + KviCString tmp(KviCString::Format, "dcc: video %s@%s:%s", dcc->szNick.toUtf8().data(), dcc->szIp.toUtf8().data(), dcc->szPort.toUtf8().data()); + DccVideoWindow * v = new DccVideoWindow(dcc, tmp.ptr()); //#warning "Create minimized dcc video ?... or maybe it's too much ? :)" bool bMinimized = dcc->bOverrideMinimize ? dcc->bShowMinimized : KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccChat); - g_pMainWindow->addWindow(v,!bMinimized); + g_pMainWindow->addWindow(v, !bMinimized); m_pDccWindowList->append(v); #else void DccBroker::passiveVideoExecute(DccDescriptor *) @@ -485,7 +495,6 @@ void DccBroker::passiveVideoExecute(DccDescriptor *) #endif } - /////////////////////////////////////////////////////////////////////////////// // ACTIVE CANVAS /////////////////////////////////////////////////////////////////////////////// @@ -496,31 +505,34 @@ void DccBroker::activeCanvasManage(DccDescriptor * dcc) if(!dcc->bAutoAccept) { // need confirmation - QString tmp = __tr2qs_ctx( \ - "<b>%1 [%2@%3]</b> requests a<br>" \ - "<b>Direct Client Connection</b> in <b>CANVAS</b> mode.<br>" \ - "The connection target will be host <b>%4</b> on port <b>%5</b><br>" \ - ,"dcc" \ - ).arg(dcc->szNick, dcc->szUser, dcc->szHost, dcc->szIp, dcc->szPort); + QString tmp = __tr2qs_ctx( + "<b>%1 [%2@%3]</b> requests a<br>" + "<b>Direct Client Connection</b> in <b>CANVAS</b> mode.<br>" + "The connection target will be host <b>%4</b> on port <b>%5</b><br>", + "dcc") + .arg(dcc->szNick, dcc->szUser, dcc->szHost, dcc->szIp, dcc->szPort); - DccAcceptDialog * box = new DccAcceptDialog(this,dcc,tmp,__tr2qs_ctx("DCC CANVAS request","dcc")); + DccAcceptDialog * box = new DccAcceptDialog(this, dcc, tmp, __tr2qs_ctx("DCC CANVAS request", "dcc")); m_pBoxList->append(box); - connect(box,SIGNAL(accepted(DccDialog *,DccDescriptor *)), - this,SLOT(activeCanvasExecute(DccDialog *,DccDescriptor *))); - connect(box,SIGNAL(rejected(DccDialog *,DccDescriptor *)), - this,SLOT(cancelDcc(DccDialog *,DccDescriptor *))); + connect(box, SIGNAL(accepted(DccDialog *, DccDescriptor *)), + this, SLOT(activeCanvasExecute(DccDialog *, DccDescriptor *))); + connect(box, SIGNAL(rejected(DccDialog *, DccDescriptor *)), + this, SLOT(cancelDcc(DccDialog *, DccDescriptor *))); box->show(); - } else { + } + else + { // auto accept - activeCanvasExecute(0,dcc); + activeCanvasExecute(0, dcc); } } #endif #ifdef COMPILE_DCC_CANVAS -void DccBroker::activeCanvasExecute(DccDialog *box,DccDescriptor * dcc) +void DccBroker::activeCanvasExecute(DccDialog * box, DccDescriptor * dcc) { - if(box)box->forgetDescriptor(); + if(box) + box->forgetDescriptor(); if(!g_pApp->windowExists(dcc->console())) { @@ -528,19 +540,17 @@ void DccBroker::activeCanvasExecute(DccDialog *box,DccDescriptor * dcc) dcc->setConsole(g_pApp->activeConsole()); } - KviCString tmp(KviCString::Format,"dcc: canvas %s@%s:%s",dcc->szNick.toUtf8().data(),dcc->szIp.toUtf8().data(),dcc->szPort.toUtf8().data()); - DccCanvasWindow * cnv = new DccCanvasWindow(dcc,tmp.ptr()); + KviCString tmp(KviCString::Format, "dcc: canvas %s@%s:%s", dcc->szNick.toUtf8().data(), dcc->szIp.toUtf8().data(), dcc->szPort.toUtf8().data()); + DccCanvasWindow * cnv = new DccCanvasWindow(dcc, tmp.ptr()); //#warning "This option should be dedicated to Dcc Canvas!....for now we are using the DccChat options" - bool bMinimized = dcc->bOverrideMinimize ? dcc->bShowMinimized : \ - (KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccChat) || \ - (dcc->bAutoAccept && KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccChatWhenAutoAccepted))); + bool bMinimized = dcc->bOverrideMinimize ? dcc->bShowMinimized : (KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccChat) || (dcc->bAutoAccept && KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccChatWhenAutoAccepted))); - g_pMainWindow->addWindow(cnv,!bMinimized); + g_pMainWindow->addWindow(cnv, !bMinimized); m_pDccWindowList->append(cnv); #else -void DccBroker::activeCanvasExecute(DccDialog *,DccDescriptor *) +void DccBroker::activeCanvasExecute(DccDialog *, DccDescriptor *) { #endif } @@ -551,11 +561,11 @@ void DccBroker::activeCanvasExecute(DccDialog *,DccDescriptor *) #ifdef COMPILE_DCC_CANVAS void DccBroker::passiveCanvasExecute(DccDescriptor * dcc) { - KviCString tmp(KviCString::Format,"dcc: canvas %s@%s:%s",dcc->szNick.toUtf8().data(),dcc->szIp.toUtf8().data(),dcc->szPort.toUtf8().data()); - DccCanvasWindow * cnv = new DccCanvasWindow(dcc,tmp.ptr()); + KviCString tmp(KviCString::Format, "dcc: canvas %s@%s:%s", dcc->szNick.toUtf8().data(), dcc->szIp.toUtf8().data(), dcc->szPort.toUtf8().data()); + DccCanvasWindow * cnv = new DccCanvasWindow(dcc, tmp.ptr()); //#warning "This option should be dedicated to Dcc Canvas!....for now we are using the DccChat options" bool bMinimized = dcc->bOverrideMinimize ? dcc->bShowMinimized : KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccChat); - g_pMainWindow->addWindow(cnv,!bMinimized); + g_pMainWindow->addWindow(cnv, !bMinimized); m_pDccWindowList->append(cnv); } #endif @@ -570,9 +580,11 @@ void DccBroker::recvFileManage(DccDescriptor * dcc) { bool bOk; quint64 size = dcc->szFileSize.toULongLong(&bOk); - if(bOk) { - if(size>=KVI_OPTION_UINT(KviOption_uintMaximumRequestedAvatarSize)) { - cancelDcc(0,dcc); + if(bOk) + { + if(size >= KVI_OPTION_UINT(KviOption_uintMaximumRequestedAvatarSize)) + { + cancelDcc(0, dcc); return; } } @@ -586,94 +598,102 @@ void DccBroker::recvFileManage(DccDescriptor * dcc) if(dcc->bActive) { // Normal active send: we will be connecting - tmp = __tr2qs_ctx( \ - "<b>%1 [%2@%3]</b> " \ - "wants to send you the file " \ - "'<b>%4</b>', " \ - "<b>%5</b> large.<br>" \ - "The connection target will be host <b>%6</b> on port <b>%7</b><br>" \ - ,"dcc" \ - ).arg(dcc->szNick, dcc->szUser, dcc->szHost, dcc->szFileName) - .arg(KviQString::makeSizeReadable(dcc->szFileSize.toULongLong())) - .arg(dcc->szIp, dcc->szPort); - - } else { + tmp = __tr2qs_ctx( + "<b>%1 [%2@%3]</b> " + "wants to send you the file " + "'<b>%4</b>', " + "<b>%5</b> large.<br>" + "The connection target will be host <b>%6</b> on port <b>%7</b><br>", + "dcc") + .arg(dcc->szNick, dcc->szUser, dcc->szHost, dcc->szFileName) + .arg(KviQString::makeSizeReadable(dcc->szFileSize.toULongLong())) + .arg(dcc->szIp, dcc->szPort); + } + else + { // passive: we will be listening! - tmp = __tr2qs_ctx( \ - "<b>%1 [%2@%3]</b> " - "wants to send you the file " \ - "'<b>%4</b>', " \ - "<b>%5</b> large.<br>" \ - "You will be the passive side of the connection.<br>" \ - ,"dcc" \ - ).arg(dcc->szNick, dcc->szUser, dcc->szHost, dcc->szFileName) - .arg(KviQString::makeSizeReadable(dcc->szFileSize.toULongLong())); + tmp = __tr2qs_ctx( + "<b>%1 [%2@%3]</b> " + "wants to send you the file " + "'<b>%4</b>', " + "<b>%5</b> large.<br>" + "You will be the passive side of the connection.<br>", + "dcc") + .arg(dcc->szNick, dcc->szUser, dcc->szHost, dcc->szFileName) + .arg(KviQString::makeSizeReadable(dcc->szFileSize.toULongLong())); } if(dcc->bIsIncomingAvatar) { - tmp += __tr2qs_ctx( \ - "<b>Note:</b>" \ - "The file appears to be an avatar that you have requested. " \ - "You should not change its filename. " \ - "Save it in a location where KVIrc can find it, such as " \ - "the 'avatars', 'incoming', or 'pics' directories, " \ - "your home directory, or the save directory for the incoming file type. " \ - "The default save path will probably work. " \ - "You can instruct KVIrc to accept incoming avatars automatically " \ - "by setting the option <tt>boolAutoAcceptIncomingAvatars</tt> to true.<br>" \ - ,"dcc" \ - ); + tmp += __tr2qs_ctx( + "<b>Note:</b>" + "The file appears to be an avatar that you have requested. " + "You should not change its filename. " + "Save it in a location where KVIrc can find it, such as " + "the 'avatars', 'incoming', or 'pics' directories, " + "your home directory, or the save directory for the incoming file type. " + "The default save path will probably work. " + "You can instruct KVIrc to accept incoming avatars automatically " + "by setting the option <tt>boolAutoAcceptIncomingAvatars</tt> to true.<br>", + "dcc"); } //#warning "Maybe remove the pending avatar if rejected ?" - QString title = __tr2qs_ctx("DCC %1 Request - KVIrc","dcc").arg(dcc->szType); + QString title = __tr2qs_ctx("DCC %1 Request - KVIrc", "dcc").arg(dcc->szType); - DccAcceptDialog * box = new DccAcceptDialog(this,dcc,tmp,title); + DccAcceptDialog * box = new DccAcceptDialog(this, dcc, tmp, title); m_pBoxList->append(box); - connect(box,SIGNAL(accepted(DccDialog *,DccDescriptor *)), - this,SLOT(chooseSaveFileName(DccDialog *,DccDescriptor *))); - connect(box,SIGNAL(rejected(DccDialog *,DccDescriptor *)), - this,SLOT(cancelDcc(DccDialog *,DccDescriptor *))); + connect(box, SIGNAL(accepted(DccDialog *, DccDescriptor *)), + this, SLOT(chooseSaveFileName(DccDialog *, DccDescriptor *))); + connect(box, SIGNAL(rejected(DccDialog *, DccDescriptor *)), + this, SLOT(cancelDcc(DccDialog *, DccDescriptor *))); box->show(); - } else { + } + else + { // auto accept if(_OUTPUT_VERBOSE) { - dcc->console()->output(KVI_OUT_DCCMSG,__tr2qs_ctx("Auto-accepting DCC %Q request from %Q!%Q@%Q for file %Q","dcc"), - &(dcc->szType),&(dcc->szNick),&(dcc->szUser), - &(dcc->szHost),&(dcc->szFileName)); + dcc->console()->output(KVI_OUT_DCCMSG, __tr2qs_ctx("Auto-accepting DCC %Q request from %Q!%Q@%Q for file %Q", "dcc"), + &(dcc->szType), &(dcc->szNick), &(dcc->szUser), + &(dcc->szHost), &(dcc->szFileName)); } - chooseSaveFileName(0,dcc); + chooseSaveFileName(0, dcc); } } -void DccBroker::chooseSaveFileName(DccDialog *box,DccDescriptor *dcc) +void DccBroker::chooseSaveFileName(DccDialog * box, DccDescriptor * dcc) { - if(box)box->forgetDescriptor(); + if(box) + box->forgetDescriptor(); // Lookup the suggested save directory dcc->szLocalFileName = ""; - if(dcc->bIsIncomingAvatar)g_pApp->getLocalKvircDirectory(dcc->szLocalFileName,KviApplication::Avatars); - else { + if(dcc->bIsIncomingAvatar) + g_pApp->getLocalKvircDirectory(dcc->szLocalFileName, KviApplication::Avatars); + else + { if(KVI_OPTION_BOOL(KviOption_boolUseIncomingDccMediaTypeSavePath)) { g_pMediaManager->lock(); - if(KviMediaType * mt = g_pMediaManager->findMediaType(dcc->szFileName.toUtf8().data(),false)) + if(KviMediaType * mt = g_pMediaManager->findMediaType(dcc->szFileName.toUtf8().data(), false)) { if(mt->szSavePath.hasData()) { - if(KviFileUtils::directoryExists(mt->szSavePath.ptr()))dcc->szLocalFileName = mt->szSavePath; - else { - if(KviFileUtils::makeDir(mt->szSavePath.ptr()))dcc->szLocalFileName = mt->szSavePath; + if(KviFileUtils::directoryExists(mt->szSavePath.ptr())) + dcc->szLocalFileName = mt->szSavePath; + else + { + if(KviFileUtils::makeDir(mt->szSavePath.ptr())) + dcc->szLocalFileName = mt->szSavePath; } if(KVI_OPTION_BOOL(KviOption_boolSortReceivedByDccFilesByNicks)) { - KviQString::ensureLastCharIs(dcc->szLocalFileName,KVI_PATH_SEPARATOR_CHAR); + KviQString::ensureLastCharIs(dcc->szLocalFileName, KVI_PATH_SEPARATOR_CHAR); QString cleanNick = dcc->szNick; KviFileUtils::cleanFileName(cleanNick); dcc->szLocalFileName.append(cleanNick); @@ -687,10 +707,10 @@ void DccBroker::chooseSaveFileName(DccDialog *box,DccDescriptor *dcc) if(dcc->szLocalFileName.isEmpty()) { - g_pApp->getLocalKvircDirectory(dcc->szLocalFileName,KviApplication::Incoming); + g_pApp->getLocalKvircDirectory(dcc->szLocalFileName, KviApplication::Incoming); if(KVI_OPTION_BOOL(KviOption_boolSortReceivedByDccFilesByNicks)) { - KviQString::ensureLastCharIs(dcc->szLocalFileName,KVI_PATH_SEPARATOR_CHAR); + KviQString::ensureLastCharIs(dcc->szLocalFileName, KVI_PATH_SEPARATOR_CHAR); QString cleanNick = dcc->szNick; KviFileUtils::cleanFileName(cleanNick); dcc->szLocalFileName.append(cleanNick); @@ -700,7 +720,7 @@ void DccBroker::chooseSaveFileName(DccDialog *box,DccDescriptor *dcc) } } KviFileUtils::adjustFilePath(dcc->szLocalFileName); - KviQString::ensureLastCharIs(dcc->szLocalFileName,KVI_PATH_SEPARATOR_CHAR); + KviQString::ensureLastCharIs(dcc->szLocalFileName, KVI_PATH_SEPARATOR_CHAR); if(!(dcc->bAutoAccept)) { @@ -708,21 +728,24 @@ void DccBroker::chooseSaveFileName(DccDialog *box,DccDescriptor *dcc) KviFileUtils::cleanFileName(cleanFilename); dcc->szLocalFileName.append(cleanFilename); if(KviFileDialog::askForSaveFileName( - dcc->szLocalFileName, - __tr2qs_ctx("Choose Files to Save - KVIrc","dcc"), - dcc->szLocalFileName, - QString(), - false, - false, - true, - g_pMainWindow - )) + dcc->szLocalFileName, + __tr2qs_ctx("Choose Files to Save - KVIrc", "dcc"), + dcc->szLocalFileName, + QString(), + false, + false, + true, + g_pMainWindow)) + { + renameOverwriteResume(0, dcc); + } + else { - renameOverwriteResume(0,dcc); - } else { cancelDcc(dcc); } - } else { + } + else + { // auto accept // WE choose the filename QString cleanFilename = dcc->szFileName; @@ -731,17 +754,18 @@ void DccBroker::chooseSaveFileName(DccDialog *box,DccDescriptor *dcc) if(_OUTPUT_VERBOSE) { - dcc->console()->output(KVI_OUT_DCCMSG,__tr2qs_ctx("Auto-saving DCC %Q file %Q as \r![!dbl]play $0\r%Q\r","dcc"), - &(dcc->szType),&(dcc->szFileName),&(dcc->szLocalFileName)); + dcc->console()->output(KVI_OUT_DCCMSG, __tr2qs_ctx("Auto-saving DCC %Q file %Q as \r![!dbl]play $0\r%Q\r", "dcc"), + &(dcc->szType), &(dcc->szFileName), &(dcc->szLocalFileName)); } - renameOverwriteResume(0,dcc); + renameOverwriteResume(0, dcc); } } -void DccBroker::renameOverwriteResume(DccDialog *box,DccDescriptor * dcc) +void DccBroker::renameOverwriteResume(DccDialog * box, DccDescriptor * dcc) { - if(box)box->forgetDescriptor(); + if(box) + box->forgetDescriptor(); // Check if file exists QFileInfo fi(dcc->szLocalFileName); @@ -760,62 +784,67 @@ void DccBroker::renameOverwriteResume(DccDialog *box,DccDescriptor * dcc) bool bDisableResume = false; if( - (!bOk) || // remote size is unknown - (iRemoteSize > (quint64)fi.size()) // or it is larger than the actual size on disk - ) + (!bOk) || // remote size is unknown + (iRemoteSize > (quint64)fi.size()) // or it is larger than the actual size on disk + ) + { + tmp = __tr2qs_ctx( + "The file '<b>%1</b>' already exists " + "and is <b>%2</b> large.<br>" + "Do you wish to<br>" + "<b>auto-rename</b> the new file,<br>" + "<b>overwrite</b> the existing file, or<br> " + "<b>resume</b> an incomplete download?", + "dcc") + .arg(dcc->szLocalFileName) + .arg(KviQString::makeSizeReadable(fi.size())); + } + else { - tmp = __tr2qs_ctx( \ - "The file '<b>%1</b>' already exists " \ - "and is <b>%2</b> large.<br>" \ - "Do you wish to<br>" \ - "<b>auto-rename</b> the new file,<br>" \ - "<b>overwrite</b> the existing file, or<br> " \ - "<b>resume</b> an incomplete download?" \ - ,"dcc" \ - ).arg(dcc->szLocalFileName).arg(KviQString::makeSizeReadable(fi.size())); - } else { bDisableResume = true; // the file on disk is larger or equal to the remote one - tmp = __tr2qs_ctx( \ - "The file '<b>%1</b>' already exists " \ - "and is larger than the offered one.<br>" \ - "Do you wish to<br>" \ - "<b>auto-rename</b> the new file, or<br>" \ - "<b>overwrite</b> the existing file?" \ - ,"dcc" \ - ).arg(dcc->szLocalFileName); + tmp = __tr2qs_ctx( + "The file '<b>%1</b>' already exists " + "and is larger than the offered one.<br>" + "Do you wish to<br>" + "<b>auto-rename</b> the new file, or<br>" + "<b>overwrite</b> the existing file?", + "dcc") + .arg(dcc->szLocalFileName); } - DccRenameDialog * box = new DccRenameDialog(this,dcc,tmp,bDisableResume); + DccRenameDialog * box = new DccRenameDialog(this, dcc, tmp, bDisableResume); m_pBoxList->append(box); - connect(box,SIGNAL(renameSelected(DccDialog *,DccDescriptor *)), - this,SLOT(renameDccSendFile(DccDialog *,DccDescriptor *))); - connect(box,SIGNAL(overwriteSelected(DccDialog *,DccDescriptor *)), - this,SLOT(recvFileExecute(DccDialog *,DccDescriptor *))); - connect(box,SIGNAL(cancelSelected(DccDialog *,DccDescriptor *)), - this,SLOT(cancelDcc(DccDialog *,DccDescriptor *))); + connect(box, SIGNAL(renameSelected(DccDialog *, DccDescriptor *)), + this, SLOT(renameDccSendFile(DccDialog *, DccDescriptor *))); + connect(box, SIGNAL(overwriteSelected(DccDialog *, DccDescriptor *)), + this, SLOT(recvFileExecute(DccDialog *, DccDescriptor *))); + connect(box, SIGNAL(cancelSelected(DccDialog *, DccDescriptor *)), + this, SLOT(cancelDcc(DccDialog *, DccDescriptor *))); box->show(); return; } // auto resume ? if( - KVI_OPTION_BOOL(KviOption_boolAutoResumeDccSendWhenAutoAccepted) && - (bOk) && // only if the remote size is really known - (iRemoteSize > (quint64)fi.size()) && // only if the remote size is larger than the local size - (!DccFileTransfer::nonFailedTransferWithLocalFileName(dcc->szLocalFileName)) // only if there is no transfer with this local file name yet - ) + KVI_OPTION_BOOL(KviOption_boolAutoResumeDccSendWhenAutoAccepted) && (bOk) && // only if the remote size is really known + (iRemoteSize > (quint64)fi.size()) && // only if the remote size is larger than the local size + (!DccFileTransfer::nonFailedTransferWithLocalFileName(dcc->szLocalFileName)) // only if there is no transfer with this local file name yet + ) { // yep, auto resume... dcc->bResume = true; - recvFileExecute(0,dcc); - } else if(iRemoteSize == (quint64)fi.size()) + recvFileExecute(0, dcc); + } + else if(iRemoteSize == (quint64)fi.size()) + { + dcc->console()->output(KVI_OUT_DCCMSG, "Transfer aborted: file %Q already completed", &(dcc->szLocalFileName)); + cancelDcc(0, dcc); + } + else { - dcc->console()->output(KVI_OUT_DCCMSG,"Transfer aborted: file %Q already completed",&(dcc->szLocalFileName)); - cancelDcc(0,dcc); - } else { // otherwise auto rename - renameDccSendFile(0,dcc); + renameDccSendFile(0, dcc); } return; } @@ -823,19 +852,20 @@ void DccBroker::renameOverwriteResume(DccDialog *box,DccDescriptor * dcc) dcc->szLocalFileSize = "0"; // everything OK - recvFileExecute(0,dcc); + recvFileExecute(0, dcc); } -void DccBroker::renameDccSendFile(DccDialog *box,DccDescriptor * dcc) +void DccBroker::renameDccSendFile(DccDialog * box, DccDescriptor * dcc) { - if(box)box->forgetDescriptor(); - + if(box) + box->forgetDescriptor(); if(QFileInfo(dcc->szLocalFileName).exists()) { KviCString szOrig = dcc->szLocalFileName; int i = 1; - do { + do + { KviCString szNum; szNum.setNum(i); int idx = szOrig.findLastIdx('.'); @@ -845,7 +875,9 @@ void DccBroker::renameDccSendFile(DccDialog *box,DccDescriptor * dcc) dcc->szLocalFileName += "."; dcc->szLocalFileName += szNum; dcc->szLocalFileName += szOrig.right(szOrig.len() - idx); - } else { + } + else + { dcc->szLocalFileName = szOrig; dcc->szLocalFileName += "."; dcc->szLocalFileName += szNum; @@ -855,19 +887,20 @@ void DccBroker::renameDccSendFile(DccDialog *box,DccDescriptor * dcc) if(_OUTPUT_VERBOSE) { - dcc->console()->output(KVI_OUT_DCCMSG,__tr2qs_ctx("File %s exists, auto-renaming to %Q","dcc"), - szOrig.ptr(),&(dcc->szLocalFileName)); + dcc->console()->output(KVI_OUT_DCCMSG, __tr2qs_ctx("File %s exists, auto-renaming to %Q", "dcc"), + szOrig.ptr(), &(dcc->szLocalFileName)); } } dcc->szLocalFileSize = "0"; // 0 for sure - recvFileExecute(0,dcc); + recvFileExecute(0, dcc); } -void DccBroker::recvFileExecute(DccDialog *box,DccDescriptor * dcc) +void DccBroker::recvFileExecute(DccDialog * box, DccDescriptor * dcc) { - if(box)box->forgetDescriptor(); + if(box) + box->forgetDescriptor(); if(!g_pApp->windowExists(dcc->console())) { @@ -877,31 +910,27 @@ void DccBroker::recvFileExecute(DccDialog *box,DccDescriptor * dcc) DccFileTransfer * send = new DccFileTransfer(dcc); - bool bMinimized = dcc->bOverrideMinimize ? dcc->bShowMinimized : \ - (KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccSend) || \ - (dcc->bAutoAccept && KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccSendWhenAutoAccepted))); + bool bMinimized = dcc->bOverrideMinimize ? dcc->bShowMinimized : (KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccSend) || (dcc->bAutoAccept && KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccSendWhenAutoAccepted))); - send->invokeTransferWindow(bMinimized,bMinimized); + send->invokeTransferWindow(bMinimized, bMinimized); } - void DccBroker::sendFileManage(DccDescriptor * dcc) { QStringList filenames; if(KviFileDialog::askForOpenFileNames( - filenames, - __tr2qs_ctx("Choose Files to Send - KVIrc","dcc"), - QString(), - QString(), - false, - true, - g_pMainWindow - )) + filenames, + __tr2qs_ctx("Choose Files to Send - KVIrc", "dcc"), + QString(), + QString(), + false, + true, + g_pMainWindow)) { if(filenames.count() > 0) { DccDescriptor * d; - QStringList::Iterator it=filenames.begin(); + QStringList::Iterator it = filenames.begin(); while(it != filenames.end()) { d = new DccDescriptor(*dcc); @@ -911,18 +940,21 @@ void DccBroker::sendFileManage(DccDescriptor * dcc) if(d->szLocalFileName.isEmpty()) cancelDcc(d); else - sendFileExecute(0,d); + sendFileExecute(0, d); } delete dcc; } - } else { + } + else + { cancelDcc(dcc); } } -void DccBroker::sendFileExecute(DccDialog * box,DccDescriptor *dcc) +void DccBroker::sendFileExecute(DccDialog * box, DccDescriptor * dcc) { - if(box)box->forgetDescriptor(); + if(box) + box->forgetDescriptor(); if(!g_pApp->windowExists(dcc->console())) { @@ -933,8 +965,8 @@ void DccBroker::sendFileExecute(DccDialog * box,DccDescriptor *dcc) QFileInfo fi(dcc->szLocalFileName); if(!(fi.exists() && fi.isReadable() && (fi.isFile()) && (fi.size() > 0))) { - dcc->console()->output(KVI_OUT_DCCERROR,__tr2qs_ctx("Can't open file %Q for reading","dcc"), - &(dcc->szLocalFileName)); + dcc->console()->output(KVI_OUT_DCCERROR, __tr2qs_ctx("Can't open file %Q for reading", "dcc"), + &(dcc->szLocalFileName)); delete dcc; return; } @@ -948,30 +980,29 @@ void DccBroker::sendFileExecute(DccDialog * box,DccDescriptor *dcc) bool bMinimized = dcc->bOverrideMinimize ? dcc->bShowMinimized : KVI_OPTION_BOOL(KviOption_boolCreateMinimizedDccSend); - send->invokeTransferWindow(bMinimized,bMinimized); + send->invokeTransferWindow(bMinimized, bMinimized); } bool DccBroker::canUnload() { if(m_pBoxList) { - if((m_pBoxList->count() != 0) || - (m_pDccWindowList->count() != 0) || - (DccFileTransfer::transferCount() != 0))return false; + if((m_pBoxList->count() != 0) || (m_pDccWindowList->count() != 0) || (DccFileTransfer::transferCount() != 0)) + return false; } // else in the destructor anyway (going to die) return true; } -bool DccBroker::handleResumeAccepted(const char * filename,const char * port,const char * szZeroPortTag) +bool DccBroker::handleResumeAccepted(const char * filename, const char * port, const char * szZeroPortTag) { - return DccFileTransfer::handleResumeAccepted(filename,port,szZeroPortTag); + return DccFileTransfer::handleResumeAccepted(filename, port, szZeroPortTag); } -bool DccBroker::handleResumeRequest(KviDccRequest * dcc,const char * filename,const char * port,unsigned long filePos,const char * szZeroPortTag) +bool DccBroker::handleResumeRequest(KviDccRequest * dcc, const char * filename, const char * port, unsigned long filePos, const char * szZeroPortTag) { //qDebug("HANDLE %s %s %u %s",filename,port,filePos,szZeroPortTag); // the zeroPOrtTag is nonempty here only if port == 0 - if(kvi_strEqualCI("0",port) && szZeroPortTag) + if(kvi_strEqualCI("0", port) && szZeroPortTag) { // zero port resume request (we have sent out a DCC SEND <filename> <fakeip> 0 <tag> KviDccZeroPortTag * t = findZeroPortTag(QString(szZeroPortTag)); @@ -985,23 +1016,22 @@ bool DccBroker::handleResumeRequest(KviDccRequest * dcc,const char * filename,co t->m_uResumePosition = filePos; KviCString szBuffy; - KviIrcServerParser::encodeCtcpParameter(filename,szBuffy); + KviIrcServerParser::encodeCtcpParameter(filename, szBuffy); dcc->ctcpMsg->msg->console()->connection()->sendFmtData( - "PRIVMSG %s :%cDCC ACCEPT %s %s %s %s%c", - dcc->ctcpMsg->msg->console()->connection()->encodeText(dcc->ctcpMsg->pSource->nick()).data(), - 0x01, - szBuffy.ptr(), - port, - dcc->ctcpMsg->msg->console()->connection()->encodeText(QString::number(filePos)).data(), - szZeroPortTag, - 0x01 - ); + "PRIVMSG %s :%cDCC ACCEPT %s %s %s %s%c", + dcc->ctcpMsg->msg->console()->connection()->encodeText(dcc->ctcpMsg->pSource->nick()).data(), + 0x01, + szBuffy.ptr(), + port, + dcc->ctcpMsg->msg->console()->connection()->encodeText(QString::number(filePos)).data(), + szZeroPortTag, + 0x01); return true; } } //qDebug("NOT A ZeRO PORT"); - return DccFileTransfer::handleResumeRequest(filename,port,filePos); + return DccFileTransfer::handleResumeRequest(filename, port, filePos); } |
