X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fircchannel.cpp;h=12f70c235c5c12d8bf617be25c515a25953fe554;hp=2bcb8ca075ef474550414db26dc8e200854f9e4c;hb=fd7c2c4a41b5bb9cffcfe7a8f86a28ab7f38ac27;hpb=8f6f3932998ffb3778e4e077dfb301da4cf34c1f diff --git a/src/common/ircchannel.cpp b/src/common/ircchannel.cpp index 2bcb8ca0..12f70c23 100644 --- a/src/common/ircchannel.cpp +++ b/src/common/ircchannel.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-07 by the Quassel IRC 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 * @@ -20,25 +20,27 @@ #include "ircchannel.h" -#include "networkinfo.h" +#include "network.h" //#include "nicktreemodel.h" #include "signalproxy.h" #include "ircuser.h" +#include "util.h" #include #include +#include #include -IrcChannel::IrcChannel(const QString &channelname, NetworkInfo *networkinfo) - : QObject(networkinfo), +IrcChannel::IrcChannel(const QString &channelname, Network *network) + : SyncableObject(network), _initialized(false), _name(channelname), _topic(QString()), - networkInfo(networkinfo) + network(network) { - setObjectName(QString::number(networkInfo->networkId()) + "/" + channelname); + setObjectName(QString::number(network->networkId()) + "/" + channelname); } IrcChannel::~IrcChannel() { @@ -49,19 +51,17 @@ IrcChannel::~IrcChannel() { // PUBLIC: // ==================== bool IrcChannel::isKnownUser(IrcUser *ircuser) const { - bool isknown = true; - if(ircuser == 0) { qWarning() << "Channel" << name() << "received IrcUser Nullpointer!"; - isknown = false; + return false; } if(!_userModes.contains(ircuser)) { qWarning() << "Channel" << name() << "received data for unknown User" << ircuser->nick(); - isknown = false; + return false; } - - return isknown; + + return true; } bool IrcChannel::isValidChannelUserMode(const QString &mode) const { @@ -97,7 +97,43 @@ QString IrcChannel::userModes(IrcUser *ircuser) const { } QString IrcChannel::userModes(const QString &nick) const { - return userModes(networkInfo->ircUser(nick)); + return userModes(network->ircUser(nick)); +} + +QTextCodec *IrcChannel::codecForEncoding() const { + return _codecForEncoding; +} + +void IrcChannel::setCodecForEncoding(const QString &name) { + setCodecForEncoding(QTextCodec::codecForName(name.toAscii())); +} + +void IrcChannel::setCodecForEncoding(QTextCodec *codec) { + _codecForEncoding = codec; +} + +QTextCodec *IrcChannel::codecForDecoding() const { + return _codecForDecoding; +} + +void IrcChannel::setCodecForDecoding(const QString &name) { + setCodecForDecoding(QTextCodec::codecForName(name.toAscii())); +} + +void IrcChannel::setCodecForDecoding(QTextCodec *codec) { + _codecForDecoding = codec; +} + +QString IrcChannel::decodeString(const QByteArray &text) const { + if(!codecForDecoding()) return network->decodeString(text); + return ::decodeString(text, _codecForDecoding); +} + +QByteArray IrcChannel::encodeString(const QString string) const { + if(codecForEncoding()) { + return _codecForEncoding->fromUnicode(string); + } + return network->encodeString(string); } // ==================== @@ -122,7 +158,7 @@ void IrcChannel::join(IrcUser *ircuser) { } void IrcChannel::join(const QString &nick) { - join(networkInfo->ircUser(nick)); + join(network->ircUser(nick)); } void IrcChannel::part(IrcUser *ircuser) { @@ -137,7 +173,7 @@ void IrcChannel::part(IrcUser *ircuser) { } void IrcChannel::part(const QString &nick) { - part(networkInfo->ircUser(nick)); + part(network->ircUser(nick)); } // SET USER MODE @@ -150,7 +186,7 @@ void IrcChannel::setUserModes(IrcUser *ircuser, const QString &modes) { } void IrcChannel::setUserModes(const QString &nick, const QString &modes) { - setUserModes(networkInfo->ircUser(nick), modes); + setUserModes(network->ircUser(nick), modes); } // ADD USER MODE @@ -167,7 +203,7 @@ void IrcChannel::addUserMode(IrcUser *ircuser, const QString &mode) { } void IrcChannel::addUserMode(const QString &nick, const QString &mode) { - addUserMode(networkInfo->ircUser(nick), mode); + addUserMode(network->ircUser(nick), mode); } // REMOVE USER MODE @@ -184,7 +220,7 @@ void IrcChannel::removeUserMode(IrcUser *ircuser, const QString &mode) { } void IrcChannel::removeUserMode(const QString &nick, const QString &mode) { - removeUserMode(networkInfo->ircUser(nick), mode); + removeUserMode(network->ircUser(nick), mode); } // INIT SET USER MODES