/***************************************************************************
- * Copyright (C) 2005-2016 by the Quassel Project *
+ * Copyright (C) 2005-2018 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
if (e->testFlag(EventManager::Netsplit))
return;
- displayMsg(e, Message::Join, e->params()[0], e->prefix(), e->params()[0]);
+ Message::Flag msgFlags = Message::Flag::None;
+ if (e->testFlag(EventManager::Self)) {
+ // Mark the message as Self
+ msgFlags = Message::Self;
+ }
+
+ displayMsg(e, Message::Join, e->params()[0], e->prefix(), e->params()[0], msgFlags);
}
if (e->params().count() > 2)
msg += " " + e->params().at(2);
- displayMsg(e, Message::Kick, msg, e->prefix(), channel);
+ Message::Flag msgFlags = Message::Flag::None;
+ if (e->testFlag(EventManager::Self)) {
+ // Mark the message as Self
+ msgFlags = Message::Self;
+ }
+
+ displayMsg(e, Message::Kick, msg, e->prefix(), channel, msgFlags);
}
}
else {
// User Modes
// FIXME: redirect
- displayMsg(e, Message::Mode, e->params().join(" "), e->prefix());
+
+ Message::Flag msgFlags = Message::Flag::None;
+ if (e->testFlag(EventManager::Self)) {
+ // Mark the message as Self
+ msgFlags = Message::Self;
+ }
+ displayMsg(e, Message::Mode, e->params().join(" "), e->prefix(), QString(), msgFlags);
}
}
}
QString newnick = e->params().at(0);
- QString oldnick = ircuser->nick();
- QString sender = e->network()->isMyNick(oldnick) ? newnick : e->prefix();
- foreach(const QString &channel, ircuser->channels())
- displayMsg(e, Message::Nick, newnick, sender, channel);
+ QString sender;
+ Message::Flag msgFlags = Message::Flag::None;
+ if (e->testFlag(EventManager::Self)) {
+ // Treat the sender as the new nickname, mark the message as Self
+ sender = newnick;
+ msgFlags = Message::Self;
+ } else {
+ // Take the sender from the event prefix, don't mark the message
+ sender = e->prefix();
+ }
+
+ // Announce to all channels the IrcUser is in
+ foreach(const QString &channel, ircuser->channels()) {
+ displayMsg(e, Message::Nick, newnick, sender, channel, msgFlags);
+ }
}
QString channel = e->params().at(0);
QString msg = e->params().count() > 1 ? e->params().at(1) : QString();
- displayMsg(e, Message::Part, msg, e->prefix(), channel);
+
+ Message::Flag msgFlags = Message::Flag::None;
+ if (e->testFlag(EventManager::Self)) {
+ // Mark the message as Self
+ msgFlags = Message::Self;
+ }
+
+ displayMsg(e, Message::Part, msg, e->prefix(), channel, msgFlags);
}
if (!ircuser)
return;
- foreach(const QString &channel, ircuser->channels())
- displayMsg(e, Message::Quit, e->params().count() ? e->params().first() : QString(), e->prefix(), channel);
+
+ Message::Flag msgFlags = Message::Flag::None;
+ if (e->testFlag(EventManager::Self)) {
+ // Mark the message as Self
+ msgFlags = Message::Self;
+ }
+
+ // Announce to all channels the IrcUser is in
+ foreach(const QString &channel, ircuser->channels()) {
+ displayMsg(e, Message::Quit, e->params().count() ? e->params().first() : QString(),
+ e->prefix(), channel, msgFlags);
+ }
}
void EventStringifier::processIrcEventTopic(IrcEvent *e)
{
+ Message::Flag msgFlags = Message::Flag::None;
+ if (e->testFlag(EventManager::Self)) {
+ // Mark the message as Self
+ msgFlags = Message::Self;
+ }
+
displayMsg(e, Message::Topic, tr("%1 has changed topic for %2 to: \"%3\"")
- .arg(e->nick(), e->params().at(0), e->params().at(1)), QString(), e->params().at(0));
+ .arg(e->nick(), e->params().at(0), e->params().at(1)), QString(), e->params().at(0),
+ msgFlags);
}
void EventStringifier::processIrcEventError(IrcEvent *e)
target = nick;
IrcUser *ircuser = e->network()->ircUser(nick);
if (ircuser) {
- int now = QDateTime::currentDateTime().toTime_t();
+ QDateTime now = QDateTime::currentDateTime();
+ now.setTimeSpec(Qt::UTC);
+ // Don't print "user is away" messages more often than this
const int silenceTime = 60;
- if (ircuser->lastAwayMessage() + silenceTime >= now)
+ if (ircuser->lastAwayMessageTime().addSecs(silenceTime) >= now)
send = false;
- ircuser->setLastAwayMessage(now);
+ ircuser->setLastAwayMessageTime(now);
}
}
if (send)
int idleSecs = e->params()[1].toInt();
if (e->params().count() > 3) { // if we have more then 3 params we have the above mentioned "real life" situation
- QDateTime loginTime = QDateTime::fromTime_t(e->params()[2].toInt()).toUTC();
+ // Time in IRC protocol is defined as seconds. Convert from seconds instead.
+ // See https://doc.qt.io/qt-5/qdatetime.html#fromSecsSinceEpoch
+#if QT_VERSION >= 0x050800
+ QDateTime loginTime = QDateTime::fromSecsSinceEpoch(e->params()[2].toLongLong()).toUTC();
+#else
+ // fromSecsSinceEpoch() was added in Qt 5.8. Manually downconvert to seconds for now.
+ // See https://doc.qt.io/qt-5/qdatetime.html#fromMSecsSinceEpoch
+ QDateTime loginTime = QDateTime::fromMSecsSinceEpoch(
+ (qint64)(e->params()[2].toLongLong() * 1000)).toUTC();
+#endif
displayMsg(e, Message::Server, tr("[Whois] %1 is logged in since %2")
.arg(e->params()[0], loginTime.toString("yyyy-MM-dd hh:mm:ss UTC")));
}
switch (e->params().count()) {
case 3:
topic = e->params()[2];
+ [[clang::fallthrough]];
case 2:
userCount = e->params()[1].toUInt();
+ [[clang::fallthrough]];
case 1:
channelName = e->params()[0];
+ [[clang::fallthrough]];
default:
break;
}
return;
QString channel = e->params()[0];
- uint unixtime = e->params()[1].toUInt();
+ // Allow for 64-bit time
+ qint64 unixtime = e->params()[1].toLongLong();
if (!unixtime) {
qWarning() << Q_FUNC_INFO << "received invalid timestamp:" << e->params()[1];
return;
}
- QDateTime time = QDateTime::fromTime_t(unixtime).toUTC();
+ // Time in IRC protocol is defined as seconds. Convert from seconds instead.
+ // See https://doc.qt.io/qt-5/qdatetime.html#fromSecsSinceEpoch
+#if QT_VERSION >= 0x050800
+ QDateTime time = QDateTime::fromSecsSinceEpoch(unixtime).toUTC();
+#else
+ // fromSecsSinceEpoch() was added in Qt 5.8. Manually downconvert to seconds for now.
+ // See https://doc.qt.io/qt-5/qdatetime.html#fromMSecsSinceEpoch
+ QDateTime time = QDateTime::fromMSecsSinceEpoch((qint64)(unixtime * 1000)).toUTC();
+#endif
displayMsg(e, Message::Topic, tr("Channel %1 created on %2")
.arg(channel, time.toString("yyyy-MM-dd hh:mm:ss UTC")),
QString(), channel);
return;
QString channel = e->params().first();
- QDateTime topicSetTime = QDateTime::fromTime_t(e->params()[2].toInt()).toUTC();
+ // Time in IRC protocol is defined as seconds. Convert from seconds instead.
+ // See https://doc.qt.io/qt-5/qdatetime.html#fromSecsSinceEpoch
+#if QT_VERSION >= 0x050800
+ QDateTime topicSetTime = QDateTime::fromSecsSinceEpoch(e->params()[2].toLongLong()).toUTC();
+#else
+ // fromSecsSinceEpoch() was added in Qt 5.8. Manually downconvert to seconds for now.
+ // See https://doc.qt.io/qt-5/qdatetime.html#fromMSecsSinceEpoch
+ QDateTime topicSetTime = QDateTime::fromMSecsSinceEpoch(
+ (qint64)(e->params()[2].toLongLong() * 1000)).toUTC();
+#endif
displayMsg(e, Message::Topic, tr("Topic set by %1 on %2")
.arg(e->params()[1],
topicSetTime.toString("yyyy-MM-dd hh:mm:ss UTC")), QString(), channel);
return;
if (e->testFlag(EventManager::Self)) {
- displayMsg(e, Message::Action, tr("sending CTCP-%1 request to %2").arg(e->ctcpCmd(), e->target()), e->network()->myNick());
+ displayMsg(e, Message::Action,
+ tr("sending CTCP-%1 request to %2").arg(e->ctcpCmd(), e->target()),
+ e->network()->myNick(), QString(), Message::Flag::Self);
return;
}