connect(this, SIGNAL(displayMsg(Message::Type, BufferInfo::Type, const QString &, const QString &, const QString &, Message::Flags)),
network(), SLOT(displayMsg(Message::Type, BufferInfo::Type, const QString &, const QString &, const QString &, Message::Flags)));
- connect(this, SIGNAL(putCmd(QString, const QList<QByteArray> &, const QByteArray &)),
- network(), SLOT(putCmd(QString, const QList<QByteArray> &, const QByteArray &)));
+ connect(this, SIGNAL(putCmd(QString, const QList<QByteArray> &, const QByteArray &, const bool)),
+ network(), SLOT(putCmd(QString, const QList<QByteArray> &, const QByteArray &, const bool)));
- connect(this, SIGNAL(putCmd(QString, const QList<QList<QByteArray>> &, const QByteArray &)),
- network(), SLOT(putCmd(QString, const QList<QList<QByteArray>> &, const QByteArray &)));
+ connect(this, SIGNAL(putCmd(QString, const QList<QList<QByteArray>> &, const QByteArray &, const bool)),
+ network(), SLOT(putCmd(QString, const QList<QList<QByteArray>> &, const QByteArray &, const bool)));
- connect(this, SIGNAL(putRawLine(const QByteArray &)),
- network(), SLOT(putRawLine(const QByteArray &)));
+ connect(this, SIGNAL(putRawLine(const QByteArray &, const bool)),
+ network(), SLOT(putRawLine(const QByteArray &, const bool)));
}
}
-void CoreBasicHandler::putCmd(const QString &cmd, const QByteArray ¶m, const QByteArray &prefix)
+void CoreBasicHandler::putCmd(const QString &cmd, const QByteArray ¶m, const QByteArray &prefix, const bool prepend)
{
QList<QByteArray> list;
list << param;
- emit putCmd(cmd, list, prefix);
+ emit putCmd(cmd, list, prefix, prepend);
}
signals:
void displayMsg(Message::Type, BufferInfo::Type, const QString &target, const QString &text, const QString &sender = "", Message::Flags flags = Message::None);
- void putCmd(const QString &cmd, const QList<QByteArray> ¶ms, const QByteArray &prefix = QByteArray());
- void putCmd(const QString &cmd, const QList<QList<QByteArray>> ¶ms, const QByteArray &prefix = QByteArray());
- void putRawLine(const QByteArray &msg);
+
+ /**
+ * Sends the raw (encoded) line, adding to the queue if needed, optionally with higher priority.
+ *
+ * @see CoreNetwork::putRawLine()
+ */
+ void putRawLine(const QByteArray &msg, const bool prepend = false);
+
+ /**
+ * Sends the command with encoded parameters, with optional prefix or high priority.
+ *
+ * @see CoreNetwork::putCmd(const QString &cmd, const QList<QByteArray> ¶ms, const QByteArray &prefix = QByteArray(), const bool prepend = false)
+ */
+ void putCmd(const QString &cmd, const QList<QByteArray> ¶ms, const QByteArray &prefix = QByteArray(), const bool prepend = false);
+
+ /**
+ * Sends the command for each set of encoded parameters, with optional prefix or high priority.
+ *
+ * @see CoreNetwork::putCmd(const QString &cmd, const QList<QList<QByteArray>> ¶ms, const QByteArray &prefix = QByteArray(), const bool prepend = false)
+ */
+ void putCmd(const QString &cmd, const QList<QList<QByteArray>> ¶ms, const QByteArray &prefix = QByteArray(), const bool prepend = false);
protected:
- void putCmd(const QString &cmd, const QByteArray ¶m, const QByteArray &prefix = QByteArray());
+ /**
+ * Sends the command with one parameter, with optional prefix or high priority.
+ *
+ * @param[in] cmd Command to send, ignoring capitalization
+ * @param[in] param Parameter for the command, encoded within a QByteArray
+ * @param[in] prefix Optional command prefix
+ * @param[in] prepend
+ * @parmblock
+ * If true, the command is prepended into the start of the queue, otherwise, it's appended to
+ * the end. This should be used sparingly, for if either the core or the IRC server cannot
+ * maintain PING/PONG replies, the other side will close the connection.
+ * @endparmblock
+ */
+ void putCmd(const QString &cmd, const QByteArray ¶m, const QByteArray &prefix = QByteArray(), const bool prepend = false);
inline CoreNetwork *network() const { return _network; }
inline CoreSession *coreSession() const { return _network->coreSession(); }
}
-void CoreNetwork::putRawLine(QByteArray s)
+void CoreNetwork::putRawLine(const QByteArray s, const bool prepend)
{
- if (_tokenBucket > 0)
+ if (_tokenBucket > 0) {
writeToSocket(s);
- else
- _msgQueue.append(s);
+ } else {
+ if (prepend) {
+ _msgQueue.prepend(s);
+ } else {
+ _msgQueue.append(s);
+ }
+ }
}
-void CoreNetwork::putCmd(const QString &cmd, const QList<QByteArray> ¶ms, const QByteArray &prefix)
+void CoreNetwork::putCmd(const QString &cmd, const QList<QByteArray> ¶ms, const QByteArray &prefix, const bool prepend)
{
QByteArray msg;
msg += params[i];
}
- putRawLine(msg);
+ putRawLine(msg, prepend);
}
-void CoreNetwork::putCmd(const QString &cmd, const QList<QList<QByteArray>> ¶ms, const QByteArray &prefix)
+void CoreNetwork::putCmd(const QString &cmd, const QList<QList<QByteArray>> ¶ms, const QByteArray &prefix, const bool prependAll)
{
QListIterator<QList<QByteArray>> i(params);
while (i.hasNext()) {
QList<QByteArray> msg = i.next();
- putCmd(cmd, msg, prefix);
+ putCmd(cmd, msg, prefix, prependAll);
}
}
void disconnectFromIrc(bool requested = true, const QString &reason = QString(), bool withReconnect = false);
void userInput(BufferInfo bufferInfo, QString msg);
- void putRawLine(QByteArray input);
- void putCmd(const QString &cmd, const QList<QByteArray> ¶ms, const QByteArray &prefix = QByteArray());
- void putCmd(const QString &cmd, const QList<QList<QByteArray>> ¶ms, const QByteArray &prefix = QByteArray());
+
+ /**
+ * Sends the raw (encoded) line, adding to the queue if needed, optionally with higher priority.
+ *
+ * @param[in] input QByteArray of encoded characters
+ * @param[in] prepend
+ * @parmblock
+ * If true, the line is prepended into the start of the queue, otherwise, it's appended to the
+ * end. This should be used sparingly, for if either the core or the IRC server cannot maintain
+ * PING/PONG replies, the other side will close the connection.
+ * @endparmblock
+ */
+ void putRawLine(const QByteArray input, const bool prepend = false);
+
+ /**
+ * Sends the command with encoded parameters, with optional prefix or high priority.
+ *
+ * @param[in] cmd Command to send, ignoring capitalization
+ * @param[in] params Parameters for the command, encoded within a QByteArray
+ * @param[in] prefix Optional command prefix
+ * @param[in] prepend
+ * @parmblock
+ * If true, the command is prepended into the start of the queue, otherwise, it's appended to
+ * the end. This should be used sparingly, for if either the core or the IRC server cannot
+ * maintain PING/PONG replies, the other side will close the connection.
+ * @endparmblock
+ */
+ void putCmd(const QString &cmd, const QList<QByteArray> ¶ms, const QByteArray &prefix = QByteArray(), const bool prepend = false);
+
+ /**
+ * Sends the command for each set of encoded parameters, with optional prefix or high priority.
+ *
+ * @param[in] cmd Command to send, ignoring capitalization
+ * @param[in] params
+ * @parmblock
+ * List of parameter lists for the command, encoded within a QByteArray. The command will be
+ * sent multiple times, once for each set of params stored within the outer list.
+ * @endparmblock
+ * @param[in] prefix Optional command prefix
+ * @param[in] prependAll
+ * @parmblock
+ * If true, ALL of the commands are prepended into the start of the queue, otherwise, they're
+ * appended to the end. This should be used sparingly, for if either the core or the IRC server
+ * cannot maintain PING/PONG replies, the other side will close the connection.
+ * @endparmblock
+ */
+ void putCmd(const QString &cmd, const QList<QList<QByteArray>> ¶ms, const QByteArray &prefix = QByteArray(), const bool prependAll = false);
void setChannelJoined(const QString &channel);
void setChannelParted(const QString &channel);
{
QString param = e->params().count() ? e->params().first() : QString();
// FIXME use events
- coreNetwork(e)->putRawLine("PONG " + coreNetwork(e)->serverEncode(param));
+ // Take priority so this won't get stuck behind other queued messages.
+ coreNetwork(e)->putRawLine("PONG " + coreNetwork(e)->serverEncode(param), true);
}
if (param.isEmpty())
param = QTime::currentTime().toString("hh:mm:ss.zzz");
- putCmd("PING", serverEncode(param));
+ // Take priority so this won't get stuck behind other queued messages.
+ putCmd("PING", serverEncode(param), QByteArray(), true);
}