projects
/
quassel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixing .arg().arg() in UserInputHandler, fixes BR #365
[quassel.git]
/
src
/
core
/
userinputhandler.cpp
diff --git
a/src/core/userinputhandler.cpp
b/src/core/userinputhandler.cpp
index
00aabc2
..
3219d4d
100644
(file)
--- a/
src/core/userinputhandler.cpp
+++ b/
src/core/userinputhandler.cpp
@@
-27,6
+27,7
@@
#include "ircuser.h"
#include <QDebug>
#include "ircuser.h"
#include <QDebug>
+#include <QRegExp>
UserInputHandler::UserInputHandler(NetworkConnection *parent) : BasicHandler(parent) {
}
UserInputHandler::UserInputHandler(NetworkConnection *parent) : BasicHandler(parent) {
}
@@
-37,11
+38,11
@@
void UserInputHandler::handleUserInput(const BufferInfo &bufferInfo, const QStri
return;
QString cmd;
QString msg = msg_;
return;
QString cmd;
QString msg = msg_;
- // leading slashes indicate there's a command to call unless there is another
e
one in the first section (like a path /proc/cpuinfo)
+ // leading slashes indicate there's a command to call unless there is another one in the first section (like a path /proc/cpuinfo)
int secondSlashPos = msg.indexOf('/', 1);
int firstSpacePos = msg.indexOf(' ');
if(!msg.startsWith('/') || (secondSlashPos != -1 && (secondSlashPos < firstSpacePos || firstSpacePos == -1))) {
int secondSlashPos = msg.indexOf('/', 1);
int firstSpacePos = msg.indexOf(' ');
if(!msg.startsWith('/') || (secondSlashPos != -1 && (secondSlashPos < firstSpacePos || firstSpacePos == -1))) {
- if(
secondSlashPos == 1
)
+ if(
msg.startsWith("//")
)
msg.remove(0, 1); // //asdf is transformed to /asdf
cmd = QString("SAY");
} else {
msg.remove(0, 1); // //asdf is transformed to /asdf
cmd = QString("SAY");
} else {
@@
-71,7
+72,7
@@
void UserInputHandler::handleAway(const BufferInfo &bufferInfo, const QString &m
}
if(me)
me->setAwayMessage(awayMsg);
}
if(me)
me->setAwayMessage(awayMsg);
-
+
putCmd("AWAY", serverEncode(awayMsg));
}
putCmd("AWAY", serverEncode(awayMsg));
}
@@
-103,12
+104,12
@@
void UserInputHandler::handleBan(const BufferInfo &bufferInfo, const QString &ms
int secondLastPeriodPosition = generalizedHost.lastIndexOf(".", generalizedHost.lastIndexOf(".")-1);
generalizedHost.replace(0, secondLastPeriodPosition, "*");
}
int secondLastPeriodPosition = generalizedHost.lastIndexOf(".", generalizedHost.lastIndexOf(".")-1);
generalizedHost.replace(0, secondLastPeriodPosition, "*");
}
- banUser = QString("*!%1@%2").arg(ircuser->user()
).arg(
generalizedHost);
+ banUser = QString("*!%1@%2").arg(ircuser->user()
,
generalizedHost);
} else {
banUser = params.join(" ");
}
} else {
banUser = params.join(" ");
}
- QString banMsg = QString("MODE %1 +b %2").arg(banChannel
).arg(
banUser);
+ QString banMsg = QString("MODE %1 +b %2").arg(banChannel
,
banUser);
emit putRawLine(serverEncode(banMsg));
}
emit putRawLine(serverEncode(banMsg));
}
@@
-152,13
+153,23
@@
void UserInputHandler::handleInvite(const BufferInfo &bufferInfo, const QString
}
void UserInputHandler::handleJoin(const BufferInfo &bufferInfo, const QString &msg) {
}
void UserInputHandler::handleJoin(const BufferInfo &bufferInfo, const QString &msg) {
- Q_UNUSED(bufferInfo)
- QStringList params = msg.trimmed().split(" ");
+ Q_UNUSED(bufferInfo);
+
+ // trim spaces before chans or keys
+ QString sane_msg = msg;
+ sane_msg.replace(QRegExp(", +"), ",");
+ QStringList params = sane_msg.trimmed().split(" ");
QStringList chans = params[0].split(",");
QStringList keys;
QStringList chans = params[0].split(",");
QStringList keys;
+ int i;
+ for(i = 0; i < chans.count(); i++) {
+ if(!network()->isChannelName(chans[i]))
+ chans[i].prepend('#');
+ }
+ params[0] = chans.join(",");
if(params.count() > 1) keys = params[1].split(",");
emit putCmd("JOIN", serverEncode(params)); // FIXME handle messages longer than 512 bytes!
if(params.count() > 1) keys = params[1].split(",");
emit putCmd("JOIN", serverEncode(params)); // FIXME handle messages longer than 512 bytes!
- i
nt i
= 0;
+ i = 0;
for(; i < keys.count(); i++) {
if(i >= chans.count()) break;
networkConnection()->addChannelKey(chans[i], keys[i]);
for(; i < keys.count(); i++) {
if(i >= chans.count()) break;
networkConnection()->addChannelKey(chans[i], keys[i]);
@@
-197,7
+208,7
@@
void UserInputHandler::handleList(const BufferInfo &bufferInfo, const QString &m
void UserInputHandler::handleMe(const BufferInfo &bufferInfo, const QString &msg) {
if(bufferInfo.bufferName().isEmpty()) return; // server buffer
networkConnection()->ctcpHandler()->query(bufferInfo.bufferName(), "ACTION", msg);
void UserInputHandler::handleMe(const BufferInfo &bufferInfo, const QString &msg) {
if(bufferInfo.bufferName().isEmpty()) return; // server buffer
networkConnection()->ctcpHandler()->query(bufferInfo.bufferName(), "ACTION", msg);
- emit displayMsg(Message::Action, bufferInfo.type(), bufferInfo.bufferName(), msg, network()->myNick());
+ emit displayMsg(Message::Action, bufferInfo.type(), bufferInfo.bufferName(), msg, network()->myNick()
, Message::Self
);
}
void UserInputHandler::handleMode(const BufferInfo &bufferInfo, const QString &msg) {
}
void UserInputHandler::handleMode(const BufferInfo &bufferInfo, const QString &msg) {
@@
-207,7
+218,7
@@
void UserInputHandler::handleMode(const BufferInfo &bufferInfo, const QString &m
// if the first argument is neither a channel nor us (user modes are only to oneself) the current buffer is assumed to be the target
if(!params.isEmpty() && !network()->isChannelName(params[0]) && !network()->isMyNick(params[0]))
params.prepend(bufferInfo.bufferName());
// if the first argument is neither a channel nor us (user modes are only to oneself) the current buffer is assumed to be the target
if(!params.isEmpty() && !network()->isChannelName(params[0]) && !network()->isMyNick(params[0]))
params.prepend(bufferInfo.bufferName());
-
+
// TODO handle correct encoding for buffer modes (channelEncode())
emit putCmd("MODE", serverEncode(params));
}
// TODO handle correct encoding for buffer modes (channelEncode())
emit putCmd("MODE", serverEncode(params));
}
@@
-256,7
+267,7
@@
void UserInputHandler::handlePart(const BufferInfo &bufferInfo, const QString &m
} else {
partReason = msg.mid(channelName.length() + 1);
}
} else {
partReason = msg.mid(channelName.length() + 1);
}
-
+
if(partReason.isEmpty())
partReason = networkConnection()->identity()->partReason();
if(partReason.isEmpty())
partReason = networkConnection()->identity()->partReason();
@@
-353,7
+364,7
@@
void UserInputHandler::defaultHandler(QString cmd, const BufferInfo &bufferInfo,
return;
}
}
return;
}
}
- emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", QString("Error: %1 %2").arg(cmd
).arg(
msg));
+ emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", QString("Error: %1 %2").arg(cmd
,
msg));
}
void UserInputHandler::expand(const QString &alias, const BufferInfo &bufferInfo, const QString &msg) {
}
void UserInputHandler::expand(const QString &alias, const BufferInfo &bufferInfo, const QString &msg) {
@@
-362,6
+373,8
@@
void UserInputHandler::expand(const QString &alias, const BufferInfo &bufferInfo
for(int i = 0; i < commands.count(); i++) {
QString command = commands[i];
for(int j = params.count(); j > 0; j--) {
for(int i = 0; i < commands.count(); i++) {
QString command = commands[i];
for(int j = params.count(); j > 0; j--) {
+ IrcUser *ircUser = network()->ircUser(params[j - 1]);
+ command = command.replace(QString("$%1:hostname").arg(j), ircUser ? ircUser->host() : QString("*"));
command = command.replace(QString("$%1").arg(j), params[j - 1]);
}
command = command.replace("$0", msg);
command = command.replace(QString("$%1").arg(j), params[j - 1]);
}
command = command.replace("$0", msg);