// restore away state
QString awayMsg = Core::awayMessage(userId(), networkId());
- if (!awayMsg.isEmpty())
- userInputHandler()->handleAway(BufferInfo(), Core::awayMessage(userId(), networkId()));
+ if (!awayMsg.isEmpty()) {
+ // Don't re-apply any timestamp formatting in order to preserve escaped percent signs, e.g.
+ // '%%%%%%%%' -> '%%%%' If processed again, it'd result in '%%'.
+ userInputHandler()->handleAway(BufferInfo(), awayMsg, true);
+ }
sendPerform();
}
-void CoreSession::globalAway(const QString &msg)
+void CoreSession::globalAway(const QString &msg, const bool skipFormatting)
{
QHash<NetworkId, CoreNetwork *>::iterator netIter = _networks.begin();
CoreNetwork *net = 0;
if (!net->isConnected())
continue;
- net->userInputHandler()->issueAway(msg, false /* no force away */);
+ net->userInputHandler()->issueAway(msg, false /* no force away */, skipFormatting);
}
}
QHash<QString, QString> persistentChannels(NetworkId) const;
- //! Marks us away (or unaway) on all networks
- void globalAway(const QString &msg = QString());
+ /**
+ * Marks us away (or unaway) on all networks
+ *
+ * @param[in] msg Away message, or blank to set unaway
+ * @param[in] skipFormatting If true, skip timestamp formatting codes (e.g. if already done)
+ */
+ void globalAway(const QString &msg = QString(), const bool skipFormatting = false);
signals:
void initialized();
// ====================
// Public Slots
// ====================
-void CoreUserInputHandler::handleAway(const BufferInfo &bufferInfo, const QString &msg)
+void CoreUserInputHandler::handleAway(const BufferInfo &bufferInfo, const QString &msg,
+ const bool skipFormatting)
{
Q_UNUSED(bufferInfo)
if (msg.startsWith("-all")) {
if (msg.length() == 4) {
- coreSession()->globalAway();
+ coreSession()->globalAway(QString(), skipFormatting);
return;
}
Q_ASSERT(msg.length() > 4);
if (msg[4] == ' ') {
- coreSession()->globalAway(msg.mid(5));
+ coreSession()->globalAway(msg.mid(5), skipFormatting);
return;
}
}
- issueAway(msg);
+ issueAway(msg, true /* force away */, skipFormatting);
}
-void CoreUserInputHandler::issueAway(const QString &msg, bool autoCheck)
+void CoreUserInputHandler::issueAway(const QString &msg, bool autoCheck, const bool skipFormatting)
{
QString awayMsg = msg;
IrcUser *me = network()->me();
+ // Only apply timestamp formatting when requested
+ // This avoids re-processing any existing away message when the core restarts, so chained escape
+ // percent signs won't get down-processed.
+ if (!skipFormatting) {
+ // Apply the timestamp formatting to the away message (if empty, nothing will happen)
+ awayMsg = formatCurrentDateTimeInString(awayMsg);
+ }
+
// if there is no message supplied we have to check if we are already away or not
if (autoCheck && msg.isEmpty()) {
if (me && !me->isAway()) {
int lastParamOverrun(const QString &cmd, const QList<QByteArray> ¶ms);
public slots:
- void handleAway(const BufferInfo &bufferInfo, const QString &text);
+ /**
+ * Handle the away command, marking as away or unaway
+ *
+ * Applies to the current network unless text begins with "-all".
+ *
+ * @param[in] bufferInfo Currently active buffer
+ * @param[in] text Away message, or blank to set unaway
+ * @param[in] skipFormatting If true, skip timestamp formatting codes (e.g. if already done)
+ */
+ void handleAway(const BufferInfo &bufferInfo, const QString &text,
+ const bool skipFormatting = true);
void handleBan(const BufferInfo &bufferInfo, const QString &text);
void handleUnban(const BufferInfo &bufferInfo, const QString &text);
void handleCtcp(const BufferInfo &bufferInfo, const QString &text);
* @param forceImmediate Immediately quit, skipping queue of other commands
*/
void issueQuit(const QString &reason, bool forceImmediate = false);
- void issueAway(const QString &msg, bool autoCheck = true);
+
+ /**
+ * Issues the away command, marking as away or unaway on the current network
+ *
+ * @param[in] msg Away message, or blank to set unaway
+ * @param[in] autoCheck If true, always set away, defaulting to the identity away message
+ * @param[in] skipFormatting If true, skip timestamp formatting codes (e.g. if already done)
+ */
+ void issueAway(const QString &msg, bool autoCheck = true, const bool skipFormatting = false);
protected:
void timerEvent(QTimerEvent *event);