X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcoreirclisthelper.cpp;h=bb7d1decb5b29ffee4411d9fff1c5a3c4227feea;hp=312ed3deb6a745689c6f1590085aa06ed81bc652;hb=1fc8eb59a87c005ddfe7d21bc225bef8692b9743;hpb=a5dfcc8ecf8b81025d24b3c5c816169e3e030ea4 diff --git a/src/core/coreirclisthelper.cpp b/src/core/coreirclisthelper.cpp index 312ed3de..bb7d1dec 100644 --- a/src/core/coreirclisthelper.cpp +++ b/src/core/coreirclisthelper.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * + * Copyright (C) 2005-2013 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,71 +15,85 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "coreirclisthelper.h" #include "corenetwork.h" -#include "userinputhandler.h" +#include "coreuserinputhandler.h" -QVariantList CoreIrcListHelper::requestChannelList(const NetworkId &netId, const QStringList &channelFilters) { - if(_finishedChannelLists.contains(netId)) - return _finishedChannelLists.take(netId); - - if(_channelLists.contains(netId)) { - _queuedQuery[netId] = channelFilters.join(","); - } else { - dispatchQuery(netId, channelFilters.join(",")); - } - return QVariantList(); +INIT_SYNCABLE_OBJECT(CoreIrcListHelper) +QVariantList CoreIrcListHelper::requestChannelList(const NetworkId &netId, const QStringList &channelFilters) +{ + if (_finishedChannelLists.contains(netId)) + return _finishedChannelLists.take(netId); + + if (_channelLists.contains(netId)) { + _queuedQuery[netId] = channelFilters.join(","); + } + else { + dispatchQuery(netId, channelFilters.join(",")); + } + return QVariantList(); } -bool CoreIrcListHelper::addChannel(const NetworkId &netId, const QString &channelName, quint32 userCount, const QString &topic) { - if(!_channelLists.contains(netId)) - return false; - _channelLists[netId] << ChannelDescription(channelName, userCount, topic); - return true; -} +bool CoreIrcListHelper::addChannel(const NetworkId &netId, const QString &channelName, quint32 userCount, const QString &topic) +{ + if (!_channelLists.contains(netId)) + return false; -bool CoreIrcListHelper::dispatchQuery(const NetworkId &netId, const QString &query) { - CoreNetwork *network = coreSession()->network(netId); - if(network) { - _channelLists[netId] = QList(); - network->userInputHandler()->handleList(BufferInfo(), query); - _queryTimeout[startTimer(10000)] = netId; + _channelLists[netId] << ChannelDescription(channelName, userCount, topic); return true; - } else { - return false; - } } -bool CoreIrcListHelper::endOfChannelList(const NetworkId &netId) { - if(_queuedQuery.contains(netId)) { - // we're no longer interessted in the current data. drop it and issue a new request. - return dispatchQuery(netId, _queuedQuery.take(netId)); - } else if(_channelLists.contains(netId)) { - QVariantList channelList; - foreach(ChannelDescription channel, _channelLists[netId]) { - QVariantList channelVariant; - channelVariant << channel.channelName - << channel.userCount - << channel.topic; - channelList << qVariantFromValue(channelVariant); + +bool CoreIrcListHelper::dispatchQuery(const NetworkId &netId, const QString &query) +{ + CoreNetwork *network = coreSession()->network(netId); + if (network) { + _channelLists[netId] = QList(); + network->userInputHandler()->handleList(BufferInfo(), query); + _queryTimeout[startTimer(10000)] = netId; + return true; + } + else { + return false; } - _finishedChannelLists[netId] = channelList; - _channelLists.remove(netId); - reportFinishedList(netId); - return true; - } else { - return false; - } } -void CoreIrcListHelper::timerEvent(QTimerEvent *event) { - int timerId = event->timerId(); - killTimer(timerId); - NetworkId netId = _queryTimeout.take(timerId); - endOfChannelList(netId); + +bool CoreIrcListHelper::endOfChannelList(const NetworkId &netId) +{ + if (_queuedQuery.contains(netId)) { + // we're no longer interessted in the current data. drop it and issue a new request. + return dispatchQuery(netId, _queuedQuery.take(netId)); + } + else if (_channelLists.contains(netId)) { + QVariantList channelList; + foreach(ChannelDescription channel, _channelLists[netId]) { + QVariantList channelVariant; + channelVariant << channel.channelName + << channel.userCount + << channel.topic; + channelList << qVariantFromValue(channelVariant); + } + _finishedChannelLists[netId] = channelList; + _channelLists.remove(netId); + reportFinishedList(netId); + return true; + } + else { + return false; + } +} + + +void CoreIrcListHelper::timerEvent(QTimerEvent *event) +{ + int timerId = event->timerId(); + killTimer(timerId); + NetworkId netId = _queryTimeout.take(timerId); + endOfChannelList(netId); }