/***************************************************************************
- * 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 *
#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);
if(_channelLists.contains(netId)) {
_queuedQuery[netId] = channelFilters.join(",");
} else {
- _channelLists[netId] = QList<ChannelDescription>();
-
- NetworkConnection *networkConnection = coreSession()->networkConnection(netId);
- if(networkConnection)
- networkConnection->userInputHandler()->handleList(BufferInfo(), channelFilters.join(","));
+ dispatchQuery(netId, channelFilters.join(","));
}
-
return QVariantList();
}
return true;
}
+bool CoreIrcListHelper::dispatchQuery(const NetworkId &netId, const QString &query) {
+ CoreNetwork *network = coreSession()->network(netId);
+ if(network) {
+ _channelLists[netId] = QList<ChannelDescription>();
+ 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<ChannelDescription>();
-
- 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]) {
}
}
+void CoreIrcListHelper::timerEvent(QTimerEvent *event) {
+ int timerId = event->timerId();
+ killTimer(timerId);
+ NetworkId netId = _queryTimeout.take(timerId);
+ endOfChannelList(netId);
+}