X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fserver.cpp;h=6bccd564a5c49c067400f1d1ee2a37c510b83516;hp=e5ed4eb33f32638588c4221da2264049416ad32a;hb=51dc042dd59b491e45951cb9d8371a1f62857945;hpb=077d44f36d2f5c730283ef6be839aea7dd073d56 diff --git a/src/core/server.cpp b/src/core/server.cpp index e5ed4eb3..6bccd564 100644 --- a/src/core/server.cpp +++ b/src/core/server.cpp @@ -17,15 +17,16 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - -#include "util.h" -#include "global.h" #include "server.h" -#include "message.h" #include +#include #include +#include "util.h" +#include "core.h" +#include "coresession.h" + Server::Server(UserId uid, QString net) : user(uid), network(net) { QString MQUOTE = QString('\020'); ctcpMDequoteHash[MQUOTE + '0'] = QString('\000'); @@ -37,10 +38,12 @@ Server::Server(UserId uid, QString net) : user(uid), network(net) { QString XQUOTE = QString('\134'); ctcpXDelimDequoteHash[XQUOTE + XQUOTE] = XQUOTE; ctcpXDelimDequoteHash[XQUOTE + QString('a')] = XDELIM; + + serverinfo = new ServerInfo(); } Server::~Server() { - + delete serverinfo; } void Server::run() { @@ -67,8 +70,11 @@ void Server::sendState() { void Server::connectToIrc(QString net) { if(net != network) return; // not me! - networkSettings = Global::data(user, "Networks").toMap()[net].toMap(); - identity = Global::data(user, "Identities").toMap()[networkSettings["Identity"].toString()].toMap(); + CoreSession *sess = Core::session(user); + //networkSettings = Global::data(user, "Networks").toMap()[net].toMap(); + networkSettings = sess->retrieveSessionData("Networks").toMap()[net].toMap(); + //identity = Global::data(user, "Identities").toMap()[networkSettings["Identity"].toString()].toMap(); + identity = sess->retrieveSessionData("Identities").toMap()[networkSettings["Identity"].toString()].toMap(); QList servers = networkSettings["Servers"].toList(); QString host = servers[0].toMap()["Address"].toString(); quint16 port = servers[0].toMap()["Port"].toUInt(); @@ -83,9 +89,9 @@ void Server::disconnectFromIrc(QString net) { void Server::socketHasData() { while(socket.canReadLine()) { - QString s = socket.readLine().trimmed(); + QByteArray s = socket.readLine().trimmed(); //qDebug() << "Read" << s; - emit recvRawServerMsg(s); + //emit recvRawServerMsg(s); // signal not needed, and we should make sure we consider encodings where we need them //Message *msg = Message::createFromServerString(this, s); handleServerMsg(s); } @@ -159,13 +165,24 @@ void Server::putCmd(QString cmd, QStringList params, QString prefix) { socket.write(m.toAscii()); } -/** Handle a raw message string sent by the server. We try to find a suitable handler, otherwise we call a default handler. */ -void Server::handleServerMsg(QString msg) { +/*! Handle a raw message string sent by the server. We try to find a suitable handler, otherwise we call a default handler. */ +void Server::handleServerMsg(QByteArray rawmsg) { try { - if(msg.isEmpty()) { + if(rawmsg.isEmpty()) { qWarning() << "Received empty string from server!"; return; } + // TODO Implement encoding conversion + /* At this point, we have a raw message as a byte array. This needs to be converted to a QString somewhere. + * Problem is, that at this point we don't know which encoding to use for the various parts of the message. + * This is something the command handler needs to take care of (e.g. PRIVMSG needs to first parse for CTCP, + * and then convert the raw strings into the correct encoding. + * We _can_ safely assume Server encoding for prefix and cmd, but not for the params. Therefore, we need to + * change from a QStringList to a QList in all the handlers, and have the handlers call decodeString + * where needed... + */ + QString msg = QString::fromLatin1(rawmsg); + // OK, first we split the raw message into its various parts... QString prefix = ""; QString cmd;