-void NetworkConnection::putCmd(const QString &cmd, const QVariantList ¶ms, const QByteArray &prefix) {
- QByteArray msg;
- if(!prefix.isEmpty())
- msg += ":" + prefix + " ";
- msg += cmd.toUpper().toAscii();
+// returns 0 if the message will not be chopped by the irc server or number of chopped bytes if message is too long
+int NetworkConnection::lastParamOverrun(const QString &cmd, const QList<QByteArray> ¶ms) {
+ //the server will pass our message that trunkated to 512 bytes including CRLF with the following format:
+ // ":prefix COMMAND param0 param1 :lastparam"
+ // where prefix = "nickname!user@host"
+ // that means that the last message can be as long as:
+ // 512 - nicklen - userlen - hostlen - commandlen - sum(param[0]..param[n-1])) - 2 (for CRLF) - 4 (":!@" + 1space between prefix and command) - max(paramcount - 1, 0) (space for simple params) - 2 (space and colon for last param)
+ IrcUser *me = network()->me();
+ int maxLen = 480 - cmd.toAscii().count(); // educated guess in case we don't know us (yet?)