_connectedToCore(false),
_syncedToCore(false)
{
- _monitorBuffer = new Buffer(BufferInfo(), this);
_signalProxy->synchronize(_ircListHelper);
connect(_backlogManager, SIGNAL(backlog(BufferId, const QVariantList &)),
p->attachSignal(this, SIGNAL(requestNetworkStates()));
p->attachSignal(this, SIGNAL(requestCreateIdentity(const Identity &)), SIGNAL(createIdentity(const Identity &)));
- p->attachSignal(this, SIGNAL(requestUpdateIdentity(const Identity &)), SIGNAL(updateIdentity(const Identity &)));
p->attachSignal(this, SIGNAL(requestRemoveIdentity(IdentityId)), SIGNAL(removeIdentity(IdentityId)));
p->attachSlot(SIGNAL(identityCreated(const Identity &)), this, SLOT(coreIdentityCreated(const Identity &)));
p->attachSlot(SIGNAL(identityRemoved(IdentityId)), this, SLOT(coreIdentityRemoved(IdentityId)));
p->attachSignal(this, SIGNAL(requestCreateNetwork(const NetworkInfo &)), SIGNAL(createNetwork(const NetworkInfo &)));
- p->attachSignal(this, SIGNAL(requestUpdateNetwork(const NetworkInfo &)), SIGNAL(updateNetwork(const NetworkInfo &)));
p->attachSignal(this, SIGNAL(requestRemoveNetwork(NetworkId)), SIGNAL(removeNetwork(NetworkId)));
p->attachSlot(SIGNAL(networkCreated(NetworkId)), this, SLOT(coreNetworkCreated(NetworkId)));
p->attachSlot(SIGNAL(networkRemoved(NetworkId)), this, SLOT(coreNetworkRemoved(NetworkId)));
return 0;
}
-Buffer *Client::buffer(BufferId bufferId) {
- if(instance()->_buffers.contains(bufferId))
- return instance()->_buffers[bufferId];
- else
- return 0;
-}
-
Buffer *Client::buffer(BufferInfo bufferInfo) {
- Buffer *buff = buffer(bufferInfo.bufferId());
+ Buffer *buff = 0;
+ if(instance()->_buffers.contains(bufferInfo.bufferId()))
+ buff = instance()->_buffers[bufferInfo.bufferId()];
if(!buff) {
Client *client = Client::instance();
emit instance()->requestCreateNetwork(info);
}
-void Client::updateNetwork(const NetworkInfo &info) {
- emit instance()->requestUpdateNetwork(info);
-}
-
void Client::removeNetwork(NetworkId id) {
emit instance()->requestRemoveNetwork(id);
}
+void Client::updateNetwork(const NetworkInfo &info) {
+ Network *netptr = instance()->_networks.value(info.networkId, 0);
+ if(!netptr) {
+ qWarning() << "Update for unknown network requested:" << info;
+ return;
+ }
+ netptr->requestSetNetworkInfo(info);
+}
+
void Client::addNetwork(Network *net) {
net->setProxy(signalProxy());
signalProxy()->synchronize(net);
emit instance()->requestCreateIdentity(id);
}
-void Client::updateIdentity(const Identity &id) {
- emit instance()->requestUpdateIdentity(id);
+void Client::updateIdentity(IdentityId id, const QVariantMap &ser) {
+ Identity *idptr = instance()->_identities.value(id, 0);
+ if(!idptr) {
+ qWarning() << "Update for unknown identity requested:" << id;
+ return;
+ }
+ idptr->requestUpdate(ser);
}
void Client::removeIdentity(IdentityId id) {
// create buffersyncer
Q_ASSERT(!_bufferSyncer);
_bufferSyncer = new BufferSyncer(this);
- connect(bufferSyncer(), SIGNAL(lastSeenMsgSet(BufferId, MsgId)), this, SLOT(updateLastSeenMsg(BufferId, MsgId)));
+ connect(bufferSyncer(), SIGNAL(lastSeenMsgSet(BufferId, MsgId)), _networkModel, SLOT(setLastSeenMsgId(BufferId, MsgId)));
connect(bufferSyncer(), SIGNAL(bufferRemoved(BufferId)), this, SLOT(bufferRemoved(BufferId)));
connect(bufferSyncer(), SIGNAL(bufferRenamed(BufferId, QString)), this, SLOT(bufferRenamed(BufferId, QString)));
signalProxy()->synchronize(bufferSyncer());
emit disconnected();
emit coreConnectionStateChanged(false);
+ messageProcessor()->reset();
+
// Clear internal data. Hopefully nothing relies on it at this point.
setCurrentCoreAccount(0);
//QTime start = QTime::currentTime();
QList<Message> msglist;
foreach(QVariant v, msgs) {
- msglist << v.value<Message>();
+ Message msg = v.value<Message>();
+ msg.setFlags(msg.flags() | Message::Backlog);
+ msglist << msg;
}
messageProcessor()->process(msglist);
//qDebug() << "processed" << msgs.count() << "backlog lines in" << start.msecsTo(QTime::currentTime());
}
-// TODO optimize checkForHighlight
-void Client::checkForHighlight(Message &msg) {
- if(!((msg.type() & (Message::Plain | Message::Notice | Message::Action)) && !(msg.flags() & Message::Self)))
- return;
-
- NotificationSettings notificationSettings;
- const Network *net = network(msg.bufferInfo().networkId());
- if(net && !net->myNick().isEmpty()) {
- QStringList nickList;
- if(notificationSettings.highlightNick() == NotificationSettings::CurrentNick) {
- nickList << net->myNick();
- } else if(notificationSettings.highlightNick() == NotificationSettings::AllNicks) {
- const Identity *myIdentity = identity(net->identity());
- if(myIdentity)
- nickList = myIdentity->nicks();
- }
- foreach(QString nickname, nickList) {
- QRegExp nickRegExp("^(.*\\W)?" + QRegExp::escape(nickname) + "(\\W.*)?$");
- if(nickRegExp.exactMatch(msg.contents())) {
- msg.setFlags(msg.flags() | Message::Highlight);
- return;
- }
- }
-
- foreach(QVariant highlight, notificationSettings.highlightList()) {
- QVariantMap highlightRule = highlight.toMap();
- if(!highlightRule["enable"].toBool())
- continue;
- Qt::CaseSensitivity caseSensitivity = highlightRule["cs"].toBool() ? Qt::CaseSensitive : Qt::CaseInsensitive;
- QString name = highlightRule["name"].toString();
- QRegExp userRegExp;
- if(highlightRule["regex"].toBool()) {
- userRegExp = QRegExp(name, caseSensitivity);
- } else {
- userRegExp = QRegExp("^(.*\\W)?" + QRegExp::escape(name) + "(\\W.*)?$", caseSensitivity);
- }
- if(userRegExp.exactMatch(msg.contents())) {
- msg.setFlags(msg.flags() | Message::Highlight);
- return;
- }
- }
- }
-}
-
-void Client::updateLastSeenMsg(BufferId id, const MsgId &msgId) {
- Buffer *b = buffer(id);
- if(!b) {
- qWarning() << "Client::updateLastSeen(): Unknown buffer" << id;
- return;
- }
- b->setLastSeenMsg(msgId);
-}
-
void Client::setBufferLastSeenMsg(BufferId id, const MsgId &msgId) {
if(!bufferSyncer())
return;