aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Szymon Tomasz Stefanek2011-03-24 04:33:50 +0000
committerGravatar Szymon Tomasz Stefanek2011-03-24 04:33:50 +0000
commit37d393e28cc12d56c3be0f854446068a154829ac (patch)
tree2cdbdd4146dd732dda3d635dbc59a9c02edce5ee /src
parentRemove a highlighting popup warning (diff)
downloadKVIrc-37d393e28cc12d56c3be0f854446068a154829ac.tar.gz
KVIrc-37d393e28cc12d56c3be0f854446068a154829ac.tar.bz2
KVIrc-37d393e28cc12d56c3be0f854446068a154829ac.zip
Add .queueSize()
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5683 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
-rw-r--r--src/kvirc/kernel/KviIrcConnection.cpp5
-rw-r--r--src/kvirc/kernel/KviIrcConnection.h5
-rw-r--r--src/kvirc/kernel/KviIrcLink.cpp9
-rw-r--r--src/kvirc/kernel/KviIrcLink.h5
-rw-r--r--src/kvirc/kernel/KviIrcSocket.cpp16
-rw-r--r--src/kvirc/kernel/KviIrcSocket.h7
-rw-r--r--src/kvirc/module/KviMexLinkFilter.h1
-rw-r--r--src/modules/context/libkvicontext.cpp29
8 files changed, 76 insertions, 1 deletions
diff --git a/src/kvirc/kernel/KviIrcConnection.cpp b/src/kvirc/kernel/KviIrcConnection.cpp
index 62462bd84..6fb97623b 100644
--- a/src/kvirc/kernel/KviIrcConnection.cpp
+++ b/src/kvirc/kernel/KviIrcConnection.cpp
@@ -161,6 +161,11 @@ KviIrcConnection::~KviIrcConnection()
m_pRequestQueue->deleteLater();
}
+unsigned int KviIrcConnection::outputQueueSize()
+{
+ return m_pLink->outputQueueSize();
+}
+
void KviIrcConnection::clearOutputQueue(bool bPrivateMessagesOnly)
{
m_pLink->clearOutputQueue(bPrivateMessagesOnly);
diff --git a/src/kvirc/kernel/KviIrcConnection.h b/src/kvirc/kernel/KviIrcConnection.h
index 74012ee04..d2a3e3171 100644
--- a/src/kvirc/kernel/KviIrcConnection.h
+++ b/src/kvirc/kernel/KviIrcConnection.h
@@ -617,6 +617,11 @@ public:
void clearOutputQueue(bool bPrivateMessagesOnly);
/**
+ * Returns the current size of the output queue.
+ */
+ unsigned int outputQueueSize();
+
+ /**
* \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/KviIrcLink.cpp b/src/kvirc/kernel/KviIrcLink.cpp
index ff67510ee..75eee7df6 100644
--- a/src/kvirc/kernel/KviIrcLink.cpp
+++ b/src/kvirc/kernel/KviIrcLink.cpp
@@ -339,6 +339,15 @@ void KviIrcLink::clearOutputQueue(bool bPrivateMessagesOnly)
m_pSocket->clearOutputQueue(bPrivateMessagesOnly);
}
+unsigned int KviIrcLink::outputQueueSize()
+{
+ if(!m_pSocket)
+ return 0;
+ if(m_pLinkFilter)
+ return m_pLinkFilter->outputQueueSize();
+ return m_pSocket->outputQueueSize();
+}
+
bool KviIrcLink::sendPacket(KviDataBuffer * pData)
{
diff --git a/src/kvirc/kernel/KviIrcLink.h b/src/kvirc/kernel/KviIrcLink.h
index a88fde846..0cc50858f 100644
--- a/src/kvirc/kernel/KviIrcLink.h
+++ b/src/kvirc/kernel/KviIrcLink.h
@@ -150,6 +150,11 @@ protected:
virtual void clearOutputQueue(bool bPrivateMessagesOnly);
/**
+ * Returns the current size of the output queue.
+ */
+ unsigned int outputQueueSize();
+
+ /**
* \brief Aborts any connection or attempt
* \return void
*/
diff --git a/src/kvirc/kernel/KviIrcSocket.cpp b/src/kvirc/kernel/KviIrcSocket.cpp
index 7a4a6eeb5..ff4fa0293 100644
--- a/src/kvirc/kernel/KviIrcSocket.cpp
+++ b/src/kvirc/kernel/KviIrcSocket.cpp
@@ -182,6 +182,22 @@ void KviIrcSocket::clearOutputQueue(bool bPrivateMessagesOnly)
queue_removeAllMessages();
}
+unsigned int KviIrcSocket::outputQueueSize()
+{
+ KviIrcSocketMsgEntry * pMsg = m_pSendQueueTail;
+ if(!pMsg)
+ return 0;
+
+ unsigned int uCount = 0;
+
+ do {
+ uCount++;
+ pMsg = pMsg->next_ptr;
+ } while(pMsg);
+
+ return uCount;
+}
+
void KviIrcSocket::outputSSLMessage(const QString & szMsg)
{
diff --git a/src/kvirc/kernel/KviIrcSocket.h b/src/kvirc/kernel/KviIrcSocket.h
index ded242bab..6378cc1a5 100644
--- a/src/kvirc/kernel/KviIrcSocket.h
+++ b/src/kvirc/kernel/KviIrcSocket.h
@@ -233,7 +233,12 @@ public:
* Clears the output queue
*/
void clearOutputQueue(bool bPrivateMessagesOnly);
-
+
+ /**
+ * Returns the current size of the output queue.
+ */
+ unsigned int outputQueueSize();
+
protected:
#ifdef COMPILE_SSL_SUPPORT
diff --git a/src/kvirc/module/KviMexLinkFilter.h b/src/kvirc/module/KviMexLinkFilter.h
index b96eb0766..ae099dccf 100644
--- a/src/kvirc/module/KviMexLinkFilter.h
+++ b/src/kvirc/module/KviMexLinkFilter.h
@@ -41,6 +41,7 @@ public:
virtual void processData(char * buffer,int len) = 0;
virtual bool sendPacket(KviDataBuffer * pData) = 0;
virtual bool clearOutputQueue(bool bPrivateMessagesOnly) = 0;
+ virtual unsigned int outputQueueSize() = 0;
};
#endif //!_KVI_MEXLINKFILTER_H_
diff --git a/src/modules/context/libkvicontext.cpp b/src/modules/context/libkvicontext.cpp
index e7ce372d7..c1eb06851 100644
--- a/src/modules/context/libkvicontext.cpp
+++ b/src/modules/context/libkvicontext.cpp
@@ -571,6 +571,34 @@ static bool context_kvs_cmd_clearQueue(KviKvsModuleCommandCall * c)
return true;
}
+/*
+ @doc: context.queueSize
+ @type:
+ function
+ @title:
+ $context.queueSize
+ @short:
+ Returns the size of the current server message queue
+ @syntax:
+ <integer> $context.queueSize
+ <integer> $context.queueSize(<irc_context_id:uint>)
+ @description:
+ Returns the number of messages currently in the server message queue.
+ If no irc_context_id is specified then the current irc_context is used.
+ If the irc_context_id specification is not valid then this function
+ returns 0.
+ @seealso:
+ [cmd]context.clearqueue[/cmd],
+*/
+
+static bool context_kvs_fnc_queueSize(KviKvsModuleFunctionCall * c)
+{
+ GET_CONNECTION_FROM_STANDARD_PARAMS;
+
+ c->returnValue()->setInteger(pConnection ? pConnection->outputQueueSize() : 0);
+
+ return true;
+}
static bool context_module_init(KviModule * m)
{
@@ -588,6 +616,7 @@ static bool context_module_init(KviModule * m)
KVSM_REGISTER_FUNCTION(m,"serverSoftware",context_kvs_fnc_serverSoftware);
KVSM_REGISTER_FUNCTION(m,"connectionStartTime",context_kvs_fnc_connectionStartTime);
KVSM_REGISTER_FUNCTION(m,"lastMessageTime",context_kvs_fnc_lastMessageTime);
+ KVSM_REGISTER_FUNCTION(m,"queueSize",context_kvs_fnc_queueSize);
KVSM_REGISTER_SIMPLE_COMMAND(m,"clearQueue",context_kvs_cmd_clearQueue);