diff options
| author | 2008-08-07 17:51:02 +0000 | |
|---|---|---|
| committer | 2008-08-07 17:51:02 +0000 | |
| commit | ac5e88740eb64a1d9a0caa3b5f5756114dea565d (patch) | |
| tree | 049419bc0a70cdd369627b067bf5caa456c05e27 /src/modules/dcc | |
| parent | modules editor (wip), objects(wip) QT4 port. (diff) | |
| download | KVIrc-ac5e88740eb64a1d9a0caa3b5f5756114dea565d.tar.gz KVIrc-ac5e88740eb64a1d9a0caa3b5f5756114dea565d.tar.bz2 KVIrc-ac5e88740eb64a1d9a0caa3b5f5756114dea565d.zip | |
DCC module QT4 port (wip)
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@2210 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/dcc')
| -rw-r--r-- | src/modules/dcc/broker.cpp | 5 | ||||
| -rw-r--r-- | src/modules/dcc/chat.cpp | 3 | ||||
| -rw-r--r-- | src/modules/dcc/descriptor.cpp | 16 | ||||
| -rw-r--r-- | src/modules/dcc/dialogs.cpp | 18 | ||||
| -rw-r--r-- | src/modules/dcc/libkvidcc.cpp | 6 | ||||
| -rw-r--r-- | src/modules/dcc/send.cpp | 55 |
6 files changed, 61 insertions, 42 deletions
diff --git a/src/modules/dcc/broker.cpp b/src/modules/dcc/broker.cpp index ab120d2f1..cb99e66ab 100644 --- a/src/modules/dcc/broker.cpp +++ b/src/modules/dcc/broker.cpp @@ -51,8 +51,9 @@ extern KVIRC_API KviSharedFilesManager * g_pSharedFilesManager; //#warning "The broker might lookup the remote host name" KviDccBroker::KviDccBroker() -: QObject(0,"dcc_broker") +: QObject(0) { + setObjectName("dcc_broker"); KviDccFileTransfer::init(); m_pBoxList = new KviPointerList<KviDccBox>; @@ -214,7 +215,7 @@ void KviDccBroker::rsendExecute(KviDccDescriptor * dcc) // retag it with something more reasonable KviDccZeroPortTag * t = addZeroPortTag(); t->m_uFileSize = fi.size(); - dcc->setZeroPortRequestTag(t->m_szTag.latin1()); // latin1() should be ok here + dcc->setZeroPortRequestTag(t->m_szTag.toLatin1()); // latin1() should be ok here szTag = t->m_szTag; // DCC [ST]SEND <filename> <fakeipaddress> <zero-port> <filesize> <sessionid> diff --git a/src/modules/dcc/chat.cpp b/src/modules/dcc/chat.cpp index d68a69eb9..cda540b2e 100644 --- a/src/modules/dcc/chat.cpp +++ b/src/modules/dcc/chat.cpp @@ -97,7 +97,8 @@ KviDccChat::KviDccChat(KviFrame *pFrm,KviDccDescriptor * dcc,const char * name) createCryptControllerButton(box); #endif - m_pSplitter = new QSplitter(Qt::Horizontal,this,"splitter"); + m_pSplitter = new QSplitter(Qt::Horizontal,this); + m_pSplitter->setObjectName("dcc_chat_splitter"); m_pIrcView = new KviIrcView(m_pSplitter,pFrm,this); connect(m_pIrcView,SIGNAL(rightClicked()),this,SLOT(textViewRightClicked())); m_pInput = new KviInput(this); diff --git a/src/modules/dcc/descriptor.cpp b/src/modules/dcc/descriptor.cpp index 640791d0c..1007ecfda 100644 --- a/src/modules/dcc/descriptor.cpp +++ b/src/modules/dcc/descriptor.cpp @@ -203,29 +203,29 @@ void KviDccDescriptor::copyFrom(const KviDccDescriptor &src) bool KviDccDescriptor::isFileUpload() { - if(szType.upper()=="SEND")return true; - if(szType.upper()=="TSEND")return true; + if(szType.toUpper()=="SEND")return true; + if(szType.toUpper()=="TSEND")return true; #ifdef COMPILE_SSL_SUPPORT - if(szType.upper()=="SSEND")return true; + if(szType.toUpper()=="SSEND")return true; #endif return false; } bool KviDccDescriptor::isFileDownload() { - if(szType.upper()=="RECV")return true; - if(szType.upper()=="TRECV")return true; + if(szType.toUpper()=="RECV")return true; + if(szType.toUpper()=="TRECV")return true; #ifdef COMPILE_SSL_SUPPORT - if(szType.upper()=="SRECV")return true; + if(szType.toUpper()=="SRECV")return true; #endif return false; } bool KviDccDescriptor::isDccChat() { - if(szType.upper()=="CHAT")return true; + if(szType.toUpper()=="CHAT")return true; #ifdef COMPILE_SSL_SUPPORT - if(szType.upper()=="SCHAT")return true; + if(szType.toUpper()=="SCHAT")return true; #endif return false; } diff --git a/src/modules/dcc/dialogs.cpp b/src/modules/dcc/dialogs.cpp index 84ca3dc18..56193a65b 100644 --- a/src/modules/dcc/dialogs.cpp +++ b/src/modules/dcc/dialogs.cpp @@ -57,12 +57,17 @@ KviDccAcceptBox::KviDccAcceptBox(KviDccBroker * br,KviDccDescriptor * dcc,const : QWidget(0) , KviDccBox(br,dcc) { setObjectName("dcc_accept_box"); - QVBoxLayout * vb = new QVBoxLayout(this,4,4); + //QVBoxLayout * vb = new QVBoxLayout(this,4,4); + QVBoxLayout * vb = new QVBoxLayout(this); + vb->setMargin(4); + vb->setSpacing(4); QLabel * l = new QLabel(text,this); l->setWordWrap(true); vb->addWidget(l); - QHBoxLayout *hb = new QHBoxLayout(4); + //QHBoxLayout *hb = new QHBoxLayout(4); + QHBoxLayout *hb = new QHBoxLayout(); + hb->setSpacing(4); vb->addLayout(hb,Qt::AlignCenter); QPushButton * btn = new QPushButton(__tr2qs_ctx("&Accept","dcc"),this); btn->setDefault(true); @@ -118,12 +123,17 @@ KviDccRenameBox::KviDccRenameBox(KviDccBroker * br,KviDccDescriptor * dcc,const : QWidget(0) , KviDccBox(br,dcc) { setObjectName("dcc_rename_box"); - QVBoxLayout * vb = new QVBoxLayout(this,4,4); + //QVBoxLayout * vb = new QVBoxLayout(this,4,4); + QVBoxLayout * vb = new QVBoxLayout(this); + vb->setMargin(4); + vb->setSpacing(4); QLabel * l = new QLabel(text,this); l->setWordWrap(true); vb->addWidget(l); - QHBoxLayout *hb = new QHBoxLayout(4); + //QHBoxLayout *hb = new QHBoxLayout(4); + QHBoxLayout *hb = new QHBoxLayout(); + hb->setSpacing(4); vb->addLayout(hb,Qt::AlignCenter); QPushButton * btn = new QPushButton(__tr2qs_ctx("&Rename","dcc"),this); diff --git a/src/modules/dcc/libkvidcc.cpp b/src/modules/dcc/libkvidcc.cpp index f362f2f94..786fe7da7 100644 --- a/src/modules/dcc/libkvidcc.cpp +++ b/src/modules/dcc/libkvidcc.cpp @@ -2614,9 +2614,9 @@ static bool dcc_kvs_fnc_sessionList(KviKvsModuleFunctionCall * c) ++it; } } else { - bool bWantFileUploads = szFlags.find('u',false) != -1; - bool bWantFileDownloads = szFlags.contains('d',false) != -1; - bool bWantChats = szFlags.contains('c',false) != -1; + bool bWantFileUploads = szFlags.indexOf('u',Qt::CaseInsensitive) != -1; + bool bWantFileDownloads = szFlags.contains('d',Qt::CaseInsensitive) != -1; + bool bWantChats = szFlags.contains('c',Qt::CaseInsensitive) != -1; while(KviDccDescriptor * dcc = it.current()) { diff --git a/src/modules/dcc/send.cpp b/src/modules/dcc/send.cpp index e5b6eaa3c..65884ded4 100644 --- a/src/modules/dcc/send.cpp +++ b/src/modules/dcc/send.cpp @@ -136,7 +136,7 @@ void KviDccRecvThread::updateStats() unsigned long uElapsedTime = uCurTime - m_uStartTime; if(uElapsedTime < 1)uElapsedTime = 1; - m_iFilePosition = m_pFile->at(); + m_iFilePosition = m_pFile->pos(); m_iAverageSpeed = m_iTotalReceivedBytes / uElapsedTime; if(m_uInstantSpeedInterval > INSTANT_BANDWIDTH_CHECK_INTERVAL_IN_MSECS) @@ -195,13 +195,13 @@ void KviDccRecvThread::run() if(m_pOpt->bResume) { - if(!m_pFile->open(IO_WriteOnly | IO_Append)) + if(!m_pFile->open(QIODevice::WriteOnly | QIODevice::Append)) { postErrorEvent(KviError_cantOpenFileForAppending); goto exit_dcc; } // else pFile is already at end } else { - if(!m_pFile->open(IO_WriteOnly)) + if(!m_pFile->open(QIODevice::WriteOnly)) { postErrorEvent(KviError_cantOpenFileForWriting); goto exit_dcc; @@ -210,7 +210,7 @@ void KviDccRecvThread::run() if(m_pOpt->bSendZeroAck && (!m_pOpt->bNoAcks)) { - if(!sendAck(m_pFile->at()))goto exit_dcc; + if(!sendAck(m_pFile->pos()))goto exit_dcc; } for(;;) @@ -255,21 +255,21 @@ void KviDccRecvThread::run() if(readLen > 0) { // Readed something useful...write back - if((m_pOpt->iTotalFileSize > -1) && ((readLen + (int)m_pFile->at()) > m_pOpt->iTotalFileSize)) + if((m_pOpt->iTotalFileSize > -1) && ((readLen + (int)m_pFile->pos()) > m_pOpt->iTotalFileSize)) { postMessageEvent(__tr_no_lookup_ctx("WARNING: The peer is sending garbage data past the end of the file","dcc")); postMessageEvent(__tr_no_lookup_ctx("WARNING: Ignoring data past the declared end of file and closing the connection","dcc")); - readLen = m_pOpt->iTotalFileSize - m_pFile->at(); + readLen = m_pOpt->iTotalFileSize - m_pFile->pos(); if(readLen > 0) { - if(m_pFile->writeBlock(buffer,readLen) != readLen) + if(m_pFile->write(buffer,readLen) != readLen) postErrorEvent(KviError_fileIOError); } break; } else { - if(m_pFile->writeBlock(buffer,readLen) != readLen) + if(m_pFile->write(buffer,readLen) != readLen) { postErrorEvent(KviError_fileIOError); break; @@ -288,7 +288,7 @@ void KviDccRecvThread::run() // Interrupt if the whole file has been received if(m_pOpt->iTotalFileSize > 0) { - if(((int)(m_pFile->at())) == m_pOpt->iTotalFileSize) + if(((int)(m_pFile->pos())) == m_pOpt->iTotalFileSize) { // Received the whole file...die KviThreadEvent * e = new KviThreadEvent(KVI_DCC_THREAD_EVENT_SUCCESS); @@ -298,7 +298,7 @@ void KviDccRecvThread::run() } } else { // Must send the ack... the peer must close the connection - if(!sendAck(m_pFile->at()))break; + if(!sendAck(m_pFile->pos()))break; } // now take care of short reads @@ -323,7 +323,7 @@ void KviDccRecvThread::run() if(readLen == 0) { // readed EOF.. - if((((int)(m_pFile->at())) == m_pOpt->iTotalFileSize) || (m_pOpt->iTotalFileSize < 0)) + if((((int)(m_pFile->pos())) == m_pOpt->iTotalFileSize) || (m_pOpt->iTotalFileSize < 0)) { // success if we got the whole file or if we don't know the file size (we trust the peer) KviThreadEvent * e = new KviThreadEvent(KVI_DCC_THREAD_EVENT_SUCCESS); @@ -352,7 +352,7 @@ void KviDccRecvThread::run() if(iFailedSelects > 3) msleep(3 * iFailedSelects); - if(((int)(m_pFile->at())) == m_pOpt->iTotalFileSize) + if(((int)(m_pFile->pos())) == m_pOpt->iTotalFileSize) { // Wait for the peer to close the connection if(iProbableTerminationTime == 0) @@ -483,14 +483,14 @@ void KviDccSendThread::run() int iFailedSelects = 0; char ackbuffer[4]; int iBytesInAckBuffer = 0; - Q_UINT32 iLastAck = 0; + quint32 iLastAck = 0; if(m_pOpt->iPacketSize < 32)m_pOpt->iPacketSize = 32; char * buffer = (char *)kvi_malloc(m_pOpt->iPacketSize * sizeof(char)); QFile * pFile = new QFile(QString::fromUtf8(m_pOpt->szFileName.ptr())); - if(!pFile->open(IO_ReadOnly)) + if(!pFile->open(QIODevice::ReadOnly)) { postErrorEvent(KviError_cantOpenFileForReading); goto exit_dcc; @@ -505,7 +505,7 @@ void KviDccSendThread::run() if(m_pOpt->iStartPosition > 0) { // seek - if(!(pFile->at(m_pOpt->iStartPosition))) + if(!(pFile->seek(m_pOpt->iStartPosition))) { postErrorEvent(KviError_fileIOError); goto exit_dcc; @@ -547,8 +547,8 @@ void KviDccSendThread::run() iBytesInAckBuffer += readLen; if(iBytesInAckBuffer == 4) { - Q_UINT32 iNewAck = ntohl(*((Q_UINT32 *)ackbuffer)); - if((iNewAck > pFile->at()) || (iNewAck < iLastAck)) + quint32 iNewAck = ntohl(*((quint32 *)ackbuffer)); + if((iNewAck > pFile->pos()) || (iNewAck < iLastAck)) { // the peer is drunk or is trying to fool us postErrorEvent(KviError_acknowledgeError); @@ -606,10 +606,10 @@ void KviDccSendThread::run() { if(!pFile->atEnd()) { - if(m_pOpt->bFastSend || m_pOpt->bNoAcks || (iLastAck == pFile->at())) + if(m_pOpt->bFastSend || m_pOpt->bNoAcks || (iLastAck == pFile->pos())) { // maximum readable size - int toRead = pFile->size() - pFile->at(); + int toRead = pFile->size() - pFile->pos(); // the max number of bytes we can send in this interval (bandwidth limit) m_pMutex->lock(); // FIXME: how to remove this lock ? int iMaxPossible = m_pOpt->uMaxBandwidth < MAX_DCC_BANDWIDTH_LIMIT ? m_pOpt->uMaxBandwidth * INSTANT_BANDWIDTH_CHECK_INTERVAL_IN_SECS : MAX_DCC_BANDWIDTH_LIMIT * INSTANT_BANDWIDTH_CHECK_INTERVAL_IN_SECS; @@ -626,7 +626,7 @@ void KviDccSendThread::run() if(toRead > 0) { // read data - int readed = pFile->readBlock(buffer,toRead); + int readed = pFile->read(buffer,toRead); if(readed < toRead) { postErrorEvent(KviError_fileIOError); @@ -642,7 +642,7 @@ void KviDccSendThread::run() if(!handleInvalidSocketRead(written))break; } else { // seek back to the right position - pFile->at(pFile->at() - (toRead - written)); + pFile->seek(pFile->pos() - (toRead - written)); } } } else { @@ -659,7 +659,7 @@ void KviDccSendThread::run() m_iTotalSentBytes += written; m_iInstantSentBytes += written; - m_iFilePosition = pFile->at(); + m_iFilePosition = pFile->pos(); updateStats(); } } else { @@ -849,7 +849,9 @@ void KviDccFileTransfer::startConnection() if(m_pResumeTimer)delete m_pResumeTimer; m_pResumeTimer = new QTimer(this); connect(m_pResumeTimer,SIGNAL(timeout()),this,SLOT(resumeTimedOut())); - m_pResumeTimer->start(KVI_OPTION_UINT(KviOption_uintDccSocketTimeout) * 1000,true); + m_pResumeTimer->setInterval(KVI_OPTION_UINT(KviOption_uintDccSocketTimeout) * 1000); + m_pResumeTimer->setSingleShot(true); + m_pResumeTimer->start(); } else { listenOrConnect(); } @@ -1825,7 +1827,12 @@ KviDccFileTransferBandwidthDialog::KviDccFileTransferBandwidthDialog(QWidget * p m_pEnableLimitCheck->setChecked((iVal >= 0) && (iVal < MAX_DCC_BANDWIDTH_LIMIT)); - m_pLimitBox = new QSpinBox(0,MAX_DCC_BANDWIDTH_LIMIT-1,1,this); + //m_pLimitBox = new QSpinBox(0,MAX_DCC_BANDWIDTH_LIMIT-1,1,this); + m_pLimitBox = new QSpinBox(this); + m_pLimitBox->setMinimum(0); + m_pLimitBox->setMaximum(MAX_DCC_BANDWIDTH_LIMIT-1); + m_pLimitBox->setSingleStep(1); + m_pLimitBox->setEnabled((iVal >= 0) && (iVal < MAX_DCC_BANDWIDTH_LIMIT)); connect(m_pEnableLimitCheck,SIGNAL(toggled(bool)),m_pLimitBox,SLOT(setEnabled(bool))); g->addWidget(m_pLimitBox,0,1,1,2); |
