X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fserver.cpp;h=406fa46dab51b875cad6e08bbfbd22217936d6f1;hp=67cc63250422c3568657b5dd387cea90efaec55a;hb=8699dd758516d0ded076811e8ea656adc95e69d0;hpb=419189f88aa62da0b3dc4564554b2b85f9aa6524 diff --git a/src/core/server.cpp b/src/core/server.cpp index 67cc6325..406fa46d 100644 --- a/src/core/server.cpp +++ b/src/core/server.cpp @@ -1,11 +1,11 @@ /*************************************************************************** - * 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 * @@ -27,22 +27,27 @@ #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() { @@ -62,6 +67,39 @@ void Server::run() { 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! @@ -78,6 +116,34 @@ void Server::connectToIrc(QString net) { 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! @@ -143,7 +209,7 @@ uint Server::networkId() const { return _networkId; } -QString Server::networkName() { +QString Server::networkName() const { return networkInfo()->networkName(); } @@ -153,9 +219,11 @@ CoreSession *Server::coreSession() const { /* 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(" "); }