diff options
| author | 2010-02-10 23:45:19 +0000 | |
|---|---|---|
| committer | 2010-02-10 23:45:19 +0000 | |
| commit | af8d7b453db1598990225d4c9fded0d150ed5212 (patch) | |
| tree | 8663770f5a5d02454636c04cca7717ce83579fc0 /src | |
| parent | actualizar (diff) | |
| download | KVIrc-af8d7b453db1598990225d4c9fded0d150ed5212.tar.gz KVIrc-af8d7b453db1598990225d4c9fded0d150ed5212.tar.bz2 KVIrc-af8d7b453db1598990225d4c9fded0d150ed5212.zip | |
added doxygen comments; improved hungarian notation
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@3951 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
| -rw-r--r-- | src/kvirc/kernel/kvi_ircconnectionrequestqueue.cpp | 117 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_ircconnectionrequestqueue.h | 79 |
2 files changed, 122 insertions, 74 deletions
diff --git a/src/kvirc/kernel/kvi_ircconnectionrequestqueue.cpp b/src/kvirc/kernel/kvi_ircconnectionrequestqueue.cpp index bd465d508..f1b74eac1 100644 --- a/src/kvirc/kernel/kvi_ircconnectionrequestqueue.cpp +++ b/src/kvirc/kernel/kvi_ircconnectionrequestqueue.cpp @@ -33,129 +33,132 @@ KviRequestQueue::KviRequestQueue() { - curType=ModeRequest; - connect(&timer, SIGNAL(timeout()), this, SLOT(timerSlot())); + m_curType = Mode; + connect(&m_timer, SIGNAL(timeout()), this, SLOT(timerSlot())); } KviRequestQueue::~KviRequestQueue() { - disconnect(&timer, SIGNAL(timeout()), this, SLOT(timerSlot())); + disconnect(&m_timer, SIGNAL(timeout()), this, SLOT(timerSlot())); } -void KviRequestQueue::enqueueChannel(KviChannel *pChan) +void KviRequestQueue::enqueueChannel(KviChannel * pChan) { - if(!channels.contains(pChan)) + if(!m_channels.contains(pChan)) { - channels.enqueue(pChan); - if(!timer.isActive()) timer.start(KVI_OPTION_UINT(KviOption_uintOnJoinRequestsDelay)*1000); + m_channels.enqueue(pChan); + if(!m_timer.isActive()) + { + m_timer.start(KVI_OPTION_UINT(KviOption_uintOnJoinRequestsDelay)*1000); + } } } -void KviRequestQueue::dequeueChannel(KviChannel *pChan) +void KviRequestQueue::dequeueChannel(KviChannel * pChan) { - if(channels.contains(pChan)) + if(m_channels.contains(pChan)) { - channels.removeOne(pChan); - if(channels.isEmpty()) - timer.stop(); + m_channels.removeOne(pChan); + if(m_channels.isEmpty()) + m_timer.stop(); } } void KviRequestQueue::clearAll() { - channels.clear(); - timer.stop(); - curType=ModeRequest; + m_channels.clear(); + m_timer.stop(); + m_curType = Mode; } void KviRequestQueue::timerSlot() { - if(channels.isEmpty()) + if(m_channels.isEmpty()) { - timer.stop(); + m_timer.stop(); } else { - KviChannel* chan = channels.head(); - QByteArray encodedChan = chan->connection()->encodeText(chan->target()).data(); + KviChannel * pChan = m_channels.head(); + QByteArray encodedChan = pChan->connection()->encodeText(pChan->target()).data(); /* The following switch will let the execution flow pass-trought if any request type * is currently disabled (or not available on the server). Channel's "MODE" request is * the only mandatory request. */ - switch(curType) + switch(m_curType) { - case BanERequest: - if(chan->connection()->serverInfo()->supportsModesIe() && + case BanException: + if(pChan->connection()->serverInfo()->supportsModesIe() && !KVI_OPTION_BOOL(KviOption_boolDisableBanExceptionListRequestOnJoin)) { - if(!chan->connection()->sendFmtData("MODE %s e",encodedChan.data())) + if(!pChan->connection()->sendFmtData("MODE %s e",encodedChan.data())) clearAll(); // disconnected - else chan->setSentBanExceptionListRequest(); - curType=InviRequest; + else pChan->setSentBanExceptionListRequest(); + m_curType = Invite; break; } - case InviRequest: - if(chan->connection()->serverInfo()->supportsModesIe() && + case Invite: + if(pChan->connection()->serverInfo()->supportsModesIe() && !KVI_OPTION_BOOL(KviOption_boolDisableInviteListRequestOnJoin)) { - if(!chan->connection()->sendFmtData("MODE %s I",encodedChan.data())) + if(!pChan->connection()->sendFmtData("MODE %s I",encodedChan.data())) clearAll(); // disconnected - else chan->setSentInviteListRequest(); - curType=QuietBanRequest; + else pChan->setSentInviteListRequest(); + m_curType = QuietBan; break; } - case QuietBanRequest: - if(chan->connection()->serverInfo()->supportsModeq() && + case QuietBan: + if(pChan->connection()->serverInfo()->supportsModeq() && !KVI_OPTION_BOOL(KviOption_boolDisableQuietBanListRequestOnJoin)) { - if(!chan->connection()->sendFmtData("MODE %s q",encodedChan.data())) + if(!pChan->connection()->sendFmtData("MODE %s q",encodedChan.data())) clearAll(); // disconnected - else chan->setSentQuietBanListRequest(); - curType=WhoRequest; + else pChan->setSentQuietBanListRequest(); + m_curType = Who; break; } - case WhoRequest: + case Who: if(!KVI_OPTION_BOOL(KviOption_boolDisableWhoRequestOnJoin)) { - chan->connection()->stateData()->setLastSentChannelWhoRequest(kvi_unixTime()); - if(chan->connection()->lagMeter()) + pChan->connection()->stateData()->setLastSentChannelWhoRequest(kvi_unixTime()); + if(pChan->connection()->lagMeter()) { KviStr tmp; tmp.sprintf("WHO %s",encodedChan.data()); - chan->connection()->lagMeter()->lagCheckRegister(tmp.ptr(),60); + pChan->connection()->lagMeter()->lagCheckRegister(tmp.ptr(),60); } - if(!chan->connection()->sendFmtData("WHO %s",encodedChan.data())) + if(!pChan->connection()->sendFmtData("WHO %s",encodedChan.data())) clearAll(); // disconnected - else chan->setSentWhoRequest(); - curType=BanRequest; + else pChan->setSentWhoRequest(); + m_curType = Ban; break; } - case BanRequest: + case Ban: if(!KVI_OPTION_BOOL(KviOption_boolDisableBanListRequestOnJoin)) { - if(!chan->connection()->sendFmtData("MODE %s b",encodedChan.data())) + if(!pChan->connection()->sendFmtData("MODE %s b",encodedChan.data())) clearAll(); // disconnected - else chan->setSentBanListRequest(); - channels.dequeue(); - curType=ModeRequest; + else pChan->setSentBanListRequest(); + m_channels.dequeue(); + m_curType = Mode; break; } default: - //we're at the end of the list - channels.dequeue(); - if(channels.isEmpty()) + // we're at the end of the list + m_channels.dequeue(); + if(m_channels.isEmpty()) { - timer.stop(); + m_timer.stop(); return; } - chan = channels.head(); - encodedChan = chan->connection()->encodeText(chan->target()); - curType=ModeRequest; - case ModeRequest: - if(!chan->connection()->sendFmtData("MODE %s",encodedChan.data())) + pChan = m_channels.head(); + encodedChan = pChan->connection()->encodeText(pChan->target()); + m_curType = Mode; + case Mode: + if(!pChan->connection()->sendFmtData("MODE %s",encodedChan.data())) { clearAll(); // disconnected break; } - curType=BanERequest; + m_curType = BanException; break; } } diff --git a/src/kvirc/kernel/kvi_ircconnectionrequestqueue.h b/src/kvirc/kernel/kvi_ircconnectionrequestqueue.h index 6f4f3a981..c1d1cd2b3 100644 --- a/src/kvirc/kernel/kvi_ircconnectionrequestqueue.h +++ b/src/kvirc/kernel/kvi_ircconnectionrequestqueue.h @@ -24,6 +24,12 @@ // //============================================================================= +/** +* \file kvi_ircconnectionrequestqueue.h +* \author Fabio Bas +* \brief IRC connection request queue +*/ + #include "kvi_settings.h" #include <QTimer> @@ -31,32 +37,71 @@ class KviChannel; +/** +* \class KviRequestQueue +* \brief Class to enqueue commands to IRC server +* +* This class is designed to delay channel requests like MODE and WHO to avoid +* excess floods on some servers +*/ class KVIRC_API KviRequestQueue: public QObject { Q_OBJECT -protected: - QQueue<KviChannel *> channels; - QTimer timer; - // MODE %s b MUST BE THE LAST AUTOMATIC CHANNEL QUERY - // so we get RPL_ENDOFBANLIST as the last reply - // and we know that the channel is in sync - enum requestTypes { - ModeRequest = 0, - BanERequest = 1, - InviRequest = 2, - WhoRequest = 3, - QuietBanRequest = 4, - BanRequest = 5 - }; - requestTypes curType; public: + /** + * \brief Constructs the request queue objects + * \return KviRequestQueue + */ KviRequestQueue(); + + /** + * \brief Destroys the request queue objects + */ virtual ~KviRequestQueue(); +protected: + /** + * \enum RequestType + * + * MODE %s b MUST BE THE LAST AUTOMATIC CHANNEL QUERY so we get + * RPL_ENDOFBANLIST as the last reply and we know that the channel is in sync + */ + enum RequestTypes { + Mode = 0, /**< Channel modes request */ + BanException = 1, /**< Ban exceptions request */ + Invite = 2, /**< Invites request */ + Who = 3, /**< Who request */ + QuietBan = 4, /**< Quiet ban request */ + Ban = 5 /**< Ban request */ + }; + + QQueue<KviChannel *> m_channels; + QTimer m_timer; + RequestTypes m_curType; public: - void enqueueChannel(KviChannel *pChan); - void dequeueChannel(KviChannel *pChan); + /** + * \brief Enqueues the channel in the queue stack + * \param pChan The channel to enqueue + * \return void + */ + void enqueueChannel(KviChannel * pChan); + + /** + * \brief Removes the channel from the queue stack + * \param pChan The channel to dequeue + * \return void + */ + void dequeueChannel(KviChannel * pChan); + + /** + * \brief Clears the queue stack + * \return void + */ void clearAll(); private slots: + /** + * \brief Performs time based requests + * \return void + */ void timerSlot(); }; |
