diff options
| author | 2010-12-16 04:54:16 +0000 | |
|---|---|---|
| committer | 2010-12-16 04:54:16 +0000 | |
| commit | 0e5af25ef8687d5029b0acaaa620d9e99a993bae (patch) | |
| tree | ae5a32e2ce9e411e984431dfa082f2a335702c50 /src | |
| parent | table object: fixed indentation, added proper doc for $sizeHintCellRequestEve... (diff) | |
| download | KVIrc-0e5af25ef8687d5029b0acaaa620d9e99a993bae.tar.gz KVIrc-0e5af25ef8687d5029b0acaaa620d9e99a993bae.tar.bz2 KVIrc-0e5af25ef8687d5029b0acaaa620d9e99a993bae.zip | |
Added context.clearQueue
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5191 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
| -rw-r--r-- | src/kvirc/kernel/kvi_ircconnection.cpp | 5 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_ircconnection.h | 7 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_irclink.cpp | 15 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_irclink.h | 7 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_ircsocket.cpp | 42 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_ircsocket.h | 12 | ||||
| -rw-r--r-- | src/kvirc/kvs/kvi_kvs_parser.cpp | 1 | ||||
| -rw-r--r-- | src/kvirc/module/kvi_mexlinkfilter.h | 1 | ||||
| -rw-r--r-- | src/modules/context/libkvicontext.cpp | 38 | ||||
| -rw-r--r-- | src/modules/dcc/broker.cpp | 2 |
10 files changed, 129 insertions, 1 deletions
diff --git a/src/kvirc/kernel/kvi_ircconnection.cpp b/src/kvirc/kernel/kvi_ircconnection.cpp index e72966135..981b14453 100644 --- a/src/kvirc/kernel/kvi_ircconnection.cpp +++ b/src/kvirc/kernel/kvi_ircconnection.cpp @@ -160,6 +160,11 @@ KviIrcConnection::~KviIrcConnection() m_pRequestQueue->deleteLater(); } +void KviIrcConnection::clearOutputQueue(bool bPrivateMessagesOnly) +{ + m_pLink->clearOutputQueue(bPrivateMessagesOnly); +} + void KviIrcConnection::setEncoding(const QString & szEncoding) { QTextCodec * c = KviLocale::codecForName(szEncoding.toLatin1()); diff --git a/src/kvirc/kernel/kvi_ircconnection.h b/src/kvirc/kernel/kvi_ircconnection.h index c8850fb9a..a21c8a990 100644 --- a/src/kvirc/kernel/kvi_ircconnection.h +++ b/src/kvirc/kernel/kvi_ircconnection.h @@ -590,6 +590,13 @@ public: bool sendFmtData(const char * pcFmt, ...); /** + * Clears the underlying output queue. + * Exposed basically for /context.clearQueue + * You shouldn't need it for any other reason :) + */ + void clearOutputQueue(bool bPrivateMessagesOnly); + + /** * \brief This function is part of the networking stack. * * It's called by KviIrcLink OR KviMexLinkFilter when a message is arriving diff --git a/src/kvirc/kernel/kvi_irclink.cpp b/src/kvirc/kernel/kvi_irclink.cpp index 4bc7582d7..d55bbbbee 100644 --- a/src/kvirc/kernel/kvi_irclink.cpp +++ b/src/kvirc/kernel/kvi_irclink.cpp @@ -324,6 +324,21 @@ void KviIrcLink::processData(char * buffer, int iLen) // Outgoing data processing // +void KviIrcLink::clearOutputQueue(bool bPrivateMessagesOnly) +{ + if(!m_pSocket) + return; // we have no queue at all + + if(m_pLinkFilter) + { + m_pLinkFilter->clearOutputQueue(bPrivateMessagesOnly); + return; + } + + m_pSocket->clearOutputQueue(bPrivateMessagesOnly); +} + + bool KviIrcLink::sendPacket(KviDataBuffer * pData) { if(!m_pSocket) diff --git a/src/kvirc/kernel/kvi_irclink.h b/src/kvirc/kernel/kvi_irclink.h index 5539b3e14..0b047e2d9 100644 --- a/src/kvirc/kernel/kvi_irclink.h +++ b/src/kvirc/kernel/kvi_irclink.h @@ -143,6 +143,13 @@ protected: virtual bool sendPacket(KviDataBuffer * pData); /** + * \brief Clears the output queue + * + * Requests to clear the underlying packet queue. + */ + virtual void clearOutputQueue(bool bPrivateMessagesOnly); + + /** * \brief Aborts any connection or attempt * \return void */ diff --git a/src/kvirc/kernel/kvi_ircsocket.cpp b/src/kvirc/kernel/kvi_ircsocket.cpp index 1c2566a03..dabd9f8dc 100644 --- a/src/kvirc/kernel/kvi_ircsocket.cpp +++ b/src/kvirc/kernel/kvi_ircsocket.cpp @@ -174,6 +174,15 @@ void KviIrcSocket::reset() setState(Idle); } +void KviIrcSocket::clearOutputQueue(bool bPrivateMessagesOnly) +{ + if(bPrivateMessagesOnly) + queue_removePrivateMessages(); + else + queue_removeAllMessages(); +} + + void KviIrcSocket::outputSSLMessage(const QString & szMsg) { m_pConsole->output(KVI_OUT_SSL,__tr2qs("[SSL]: %Q"),&szMsg); @@ -1700,6 +1709,39 @@ void KviIrcSocket::queue_removeAllMessages() while(queue_removeMessage()) {} } +void KviIrcSocket::queue_removePrivateMessages() +{ + KviIrcSocketMsgEntry * pPrevEntry = 0; + KviIrcSocketMsgEntry * pEntry = m_pSendQueueHead; + while(pEntry) + { + if(pEntry->pData->size() > 7) + { + if(kvi_strEqualCIN((char *)(pEntry->pData->data()),"PRIVMSG",7)) + { + // remove it + if(pPrevEntry) + { + pPrevEntry->next_ptr = pEntry->next_ptr; + if(!pPrevEntry->next_ptr) + m_pSendQueueTail = 0; + free_msgEntry(pEntry); + pEntry = pPrevEntry->next_ptr; + } else { + m_pSendQueueHead = pEntry->next_ptr; + if(!m_pSendQueueHead) + m_pSendQueueTail = 0; + free_msgEntry(pEntry); + pEntry = m_pSendQueueHead; + } + continue; + } + } + pPrevEntry = pEntry; + pEntry = pEntry->next_ptr; + } +} + void KviIrcSocket::flushSendQueue() { // If we're called from the flush timer, stop it diff --git a/src/kvirc/kernel/kvi_ircsocket.h b/src/kvirc/kernel/kvi_ircsocket.h index 1d6c0ee3f..da2d48a02 100644 --- a/src/kvirc/kernel/kvi_ircsocket.h +++ b/src/kvirc/kernel/kvi_ircsocket.h @@ -227,6 +227,12 @@ public: * \return bool */ bool getLocalHostIp(QString & szIp, bool bIPv6); + + /** + * Clears the output queue + */ + void clearOutputQueue(bool bPrivateMessagesOnly); + protected: #ifdef COMPILE_SSL_SUPPORT @@ -403,6 +409,12 @@ protected: void queue_removeAllMessages(); /** + * \brief Removes private messages from the queue. + * \return void + */ + void queue_removePrivateMessages(); + + /** * \brief Sets the state of the socket * \param state The state :) * \return void diff --git a/src/kvirc/kvs/kvi_kvs_parser.cpp b/src/kvirc/kvs/kvi_kvs_parser.cpp index 3b14d5d24..282332228 100644 --- a/src/kvirc/kvs/kvi_kvs_parser.cpp +++ b/src/kvirc/kvs/kvi_kvs_parser.cpp @@ -2512,6 +2512,7 @@ KviKvsTreeNodeData * KviKvsParser::parsePercentOrDollar(bool bInObjScope) if(!r)return 0; } else { // this is @ + static QString szStrayAtRoutineName("@"); static QString szMightBeStrayAtOrThisRoutineName("@?"); diff --git a/src/kvirc/module/kvi_mexlinkfilter.h b/src/kvirc/module/kvi_mexlinkfilter.h index 21e4486ea..7df5c2215 100644 --- a/src/kvirc/module/kvi_mexlinkfilter.h +++ b/src/kvirc/module/kvi_mexlinkfilter.h @@ -40,6 +40,7 @@ public: public: virtual void processData(char * buffer,int len) = 0; virtual bool sendPacket(KviDataBuffer * pData) = 0; + virtual bool clearOutputQueue(bool bPrivateMessagesOnly) = 0; }; #endif //!_KVI_MEXLINKFILTER_H_ diff --git a/src/modules/context/libkvicontext.cpp b/src/modules/context/libkvicontext.cpp index 10ec9e208..bfa9f373c 100644 --- a/src/modules/context/libkvicontext.cpp +++ b/src/modules/context/libkvicontext.cpp @@ -415,6 +415,42 @@ static bool context_kvs_fnc_list(KviKvsModuleFunctionCall * c) return true; } + +/* + @doc: context.clearqueue + @type: + command + @title: + context.clearqueue + @syntax: + context.clearqueue [-a] + @switches: + !sw: -a | --all + Remove ALL messages, not just the private messages. + @short: + Removes messages from the socked output queue. + @description: + Removes the PRIVMSG messages from the socket output queue. + This can be used to save yourself in-extremis if you have pasted a huge amount of text + but otherwise you shouldn't need it. Do not use in scripts. + Be aware that the -a switch MAY CONFUSE KVIRC quite a bit: do not use it unless + you REALLY know what you're doing. +*/ +static bool context_kvs_cmd_clearQueue(KviKvsModuleCommandCall * c) +{ + QString szTarget; + KVSM_PARAMETERS_BEGIN(c) + KVSM_PARAMETER("target",KVS_PT_NONEMPTYSTRING,0,szTarget) + KVSM_PARAMETERS_END(c) + + KVSM_REQUIRE_CONNECTION(c) + + c->window()->connection()->clearOutputQueue(!c->switches()->find('a',"all")); + + return true; +} + + static bool context_module_init(KviModule * m) { KVSM_REGISTER_FUNCTION(m,"serverHostName",context_kvs_fnc_serverHostName); @@ -428,6 +464,8 @@ static bool context_module_init(KviModule * m) KVSM_REGISTER_FUNCTION(m,"list",context_kvs_fnc_list); KVSM_REGISTER_FUNCTION(m,"serverSoftware",context_kvs_fnc_serverSoftware); + KVSM_REGISTER_SIMPLE_COMMAND(m,"clearQueue",context_kvs_cmd_clearQueue); + return true; } diff --git a/src/modules/dcc/broker.cpp b/src/modules/dcc/broker.cpp index 4801a005c..0b389f711 100644 --- a/src/modules/dcc/broker.cpp +++ b/src/modules/dcc/broker.cpp @@ -476,7 +476,7 @@ void KviDccBroker::passiveVideoExecute(KviDccDescriptor * dcc) if(bMinimized)v->minimize(); m_pDccWindowList->append(v); #else -void KviDccBroker::passiveVideoExecute(KviDccDescriptor * dcc) +void KviDccBroker::passiveVideoExecute(KviDccDescriptor *) { #endif } |
