1
1
/***************************************************************************
2
* Copyright (C) 2005-09 by the Quassel Project *
2
* Copyright (C) 2005-10 by the Quassel Project *
3
3
* devel@quassel-irc.org *
5
5
* This program is free software; you can redistribute it and/or modify *
169
169
QString sane_msg = msg;
170
170
sane_msg.replace(QRegExp(", +"), ",");
171
171
QStringList params = sane_msg.trimmed().split(" ");
172
173
QStringList chans = params[0].split(",", QString::SkipEmptyParts);
173
174
QStringList keys;
175
if(params.count() > 1)
176
keys = params[1].split(",");
175
179
for(i = 0; i < chans.count(); i++) {
176
180
if(!network()->isChannelName(chans[i]))
177
181
chans[i].prepend('#');
183
if(i < keys.count()) {
184
network()->addChannelKey(chans[i], keys[i]);
186
network()->removeChannelKey(chans[i]);
179
params[0] = chans.join(",");
180
if(params.count() > 1) keys = params[1].split(",");
181
emit putCmd("JOIN", serverEncode(params)); // FIXME handle messages longer than 512 bytes!
190
static const char *cmd = "JOIN";
183
for(; i < keys.count(); i++) {
184
if(i >= chans.count()) break;
185
network()->addChannelKey(chans[i], keys[i]);
187
for(; i < chans.count(); i++) {
188
network()->removeChannelKey(chans[i]);
192
QStringList joinChans, joinKeys;
193
int slicesize = chans.count();
194
QList<QByteArray> encodedParams;
196
// go through all to-be-joined channels and (re)build the join list
197
while(i < chans.count()) {
198
joinChans.append(chans.at(i));
200
joinKeys.append(keys.at(i));
202
// if the channel list we built so far either contains all requested channels or exceeds
203
// the desired amount of channels in this slice, try to send what we have so far
204
if(++i == chans.count() || joinChans.count() >= slicesize) {
206
params.append(joinChans.join(","));
207
params.append(joinKeys.join(","));
208
encodedParams = serverEncode(params);
209
// check if it fits in one command
210
if(lastParamOverrun(cmd, encodedParams) == 0) {
211
emit putCmd(cmd, encodedParams);
212
} else if(slicesize > 1) {
213
// back to start of slice, try again with half the amount of channels
388
419
void CoreUserInputHandler::defaultHandler(QString cmd, const BufferInfo &bufferInfo, const QString &msg) {
389
420
Q_UNUSED(bufferInfo);
390
emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", QString("Error: %1 %2").arg(cmd, msg));
421
emit putCmd(serverEncode(cmd.toUpper()), serverEncode(msg.split(" ")));
393
424
void CoreUserInputHandler::putPrivmsg(const QByteArray &target, const QByteArray &message) {
414
445
// returns 0 if the message will not be chopped by the irc server or number of chopped bytes if message is too long
415
446
int CoreUserInputHandler::lastParamOverrun(const QString &cmd, const QList<QByteArray> ¶ms) {
416
// the server will pass our message trunkated to 512 bytes including CRLF with the following format:
447
// the server will pass our message truncated to 512 bytes including CRLF with the following format:
417
448
// ":prefix COMMAND param0 param1 :lastparam"
418
449
// where prefix = "nickname!user@host"
419
450
// that means that the last message can be as long as: