/***************************************************************************
- * Copyright (C) 2005-07 by The Quassel Team *
+ * Copyright (C) 2005-08 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
+ * (at your option) version 3. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#include "core.h"
#include "coresession.h"
+#include "ircuser.h"
#include "networkinfo.h"
-#include "synchronizer.h"
#include "ircserverhandler.h"
#include "userinputhandler.h"
#include "ctcphandler.h"
-Server::Server(UserId uid, uint networkId, QString net)
+Server::Server(UserId uid, NetworkId networkId, QString net, const QVariant &state)
: _userId(uid),
_networkId(networkId),
_ircServerHandler(new IrcServerHandler(this)),
_userInputHandler(new UserInputHandler(this)),
_ctcpHandler(new CtcpHandler(this)),
- _networkInfo(new NetworkInfo(networkId, coreSession()->signalProxy(), this))
+ _networkInfo(new NetworkInfo(networkId, this)),
+ _previousState(state)
{
+ connect(networkInfo(), SIGNAL(currentServerSet(const QString &)), this, SLOT(sendPerform()));
+ networkInfo()->setCodecForEncoding("ISO-8859-15"); // FIXME
+ networkInfo()->setCodecForDecoding("ISO-8859-15"); // FIXME
networkInfo()->setNetworkName(net);
+ networkInfo()->setProxy(coreSession()->signalProxy());
}
Server::~Server() {
exec();
}
+QString Server::serverDecode(const QByteArray &string) const {
+ return networkInfo()->decodeString(string);
+}
+
+QString Server::bufferDecode(const QString &bufferName, const QByteArray &string) const {
+ Q_UNUSED(bufferName);
+ // TODO: Implement buffer-specific encodings
+ return networkInfo()->decodeString(string);
+}
+
+QString Server::userDecode(const QString &userNick, const QByteArray &string) const {
+ IrcUser *user = networkInfo()->ircUser(userNick);
+ if(user) return user->decodeString(string);
+ return networkInfo()->decodeString(string);
+}
+
+QByteArray Server::serverEncode(const QString &string) const {
+ return networkInfo()->encodeString(string);
+}
+
+QByteArray Server::bufferEncode(const QString &bufferName, const QString &string) const {
+ Q_UNUSED(bufferName);
+ // TODO: Implement buffer-specific encodings
+ return networkInfo()->encodeString(string);
+}
+
+QByteArray Server::userEncode(const QString &userNick, const QString &string) const {
+ IrcUser *user = networkInfo()->ircUser(userNick);
+ if(user) return user->encodeString(string);
+ return networkInfo()->encodeString(string);
+}
+
+
void Server::connectToIrc(QString net) {
if(net != networkName())
return; // not me!
socket.connectToHost(host, port);
}
+void Server::sendPerform() {
+ // TODO: reimplement perform List!
+ //// send performlist
+ //QStringList performList = networkSettings["Perform"].toString().split( "\n" );
+ //int count = performList.count();
+ //for(int a = 0; a < count; a++) {
+ // if(!performList[a].isEmpty() ) {
+ // userInput(network, "", performList[a]);
+ // }
+ //}
+
+ // rejoin channels we've been in
+ QStringList chans = _previousState.toStringList();
+ if(chans.count() > 0) {
+ qDebug() << "autojoining" << chans;
+ QString list = chans.join(",");
+ putCmd("join", QStringList(list));
+ }
+ // delete _previousState, we won't need it again
+ _previousState = QVariant();
+}
+
+QVariant Server::state() {
+ IrcUser *me = networkInfo()->ircUser(networkInfo()->myNick());
+ if(!me) return QVariant(); // this shouldn't really happen, I guess
+ return me->channels();
+}
+
void Server::disconnectFromIrc(QString net) {
if(net != networkName())
return; // not me!
return _networkId;
}
-QString Server::networkName() {
+QString Server::networkName() const {
return networkInfo()->networkName();
}
/* Exception classes for message handling */
Server::ParseError::ParseError(QString cmd, QString prefix, QStringList params) {
+ Q_UNUSED(prefix);
_msg = QString("Command Parse Error: ") + cmd + params.join(" ");
}
Server::UnknownCmdError::UnknownCmdError(QString cmd, QString prefix, QStringList params) {
- _msg = QString("Unknown Command: ") + cmd;
+ Q_UNUSED(prefix);
+ _msg = QString("Unknown Command: ") + cmd + params.join(" ");
}