X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcoreirclisthelper.cpp;h=0545471381b88a44d27855bf394b8fc9bbc0229d;hp=d8a317cdd59d7b5b9c0114bf0c4ee4cd297c1a1c;hb=412b5319d090f122ae8c99be6578bc25023c8f24;hpb=fe4b38e66592f11fdf4c4651863968983daecd2d diff --git a/src/core/coreirclisthelper.cpp b/src/core/coreirclisthelper.cpp index d8a317cd..05454713 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-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -20,10 +20,10 @@ #include "coreirclisthelper.h" -#include "networkconnection.h" -#include "userinputhandler.h" - +#include "corenetwork.h" +#include "coreuserinputhandler.h" +INIT_SYNCABLE_OBJECT(CoreIrcListHelper) QVariantList CoreIrcListHelper::requestChannelList(const NetworkId &netId, const QStringList &channelFilters) { if(_finishedChannelLists.contains(netId)) return _finishedChannelLists.take(netId); @@ -31,13 +31,8 @@ QVariantList CoreIrcListHelper::requestChannelList(const NetworkId &netId, const if(_channelLists.contains(netId)) { _queuedQuery[netId] = channelFilters.join(","); } else { - _channelLists[netId] = QList(); - - NetworkConnection *networkConnection = coreSession()->networkConnection(netId); - if(networkConnection) - networkConnection->userInputHandler()->handleList(BufferInfo(), channelFilters.join(",")); + dispatchQuery(netId, channelFilters.join(",")); } - return QVariantList(); } @@ -49,17 +44,22 @@ bool CoreIrcListHelper::addChannel(const NetworkId &netId, const QString &channe return true; } +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; + } +} + 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. - _channelLists[netId] = QList(); - - NetworkConnection *networkConnection = coreSession()->networkConnection(netId); - if(networkConnection) - networkConnection->userInputHandler()->handleList(BufferInfo(), _queuedQuery[netId]); - - _queuedQuery.remove(netId); - return true; + return dispatchQuery(netId, _queuedQuery.take(netId)); } else if(_channelLists.contains(netId)) { QVariantList channelList; foreach(ChannelDescription channel, _channelLists[netId]) { @@ -78,3 +78,9 @@ bool CoreIrcListHelper::endOfChannelList(const NetworkId &netId) { } } +void CoreIrcListHelper::timerEvent(QTimerEvent *event) { + int timerId = event->timerId(); + killTimer(timerId); + NetworkId netId = _queryTimeout.take(timerId); + endOfChannelList(netId); +}