X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fircchannel.cpp;h=9f1a91f3cc4d58d385da996404da4e71c4b4bab3;hp=5fad2eb549015ff8daf0d847f23929d97df4e593;hb=e008cd12ef319c4b5f9fe5a8cc1524829551771d;hpb=d6b056e936ec441258d291b7a8af7b83f9f53016 diff --git a/src/common/ircchannel.cpp b/src/common/ircchannel.cpp index 5fad2eb5..9f1a91f3 100644 --- a/src/common/ircchannel.cpp +++ b/src/common/ircchannel.cpp @@ -24,9 +24,11 @@ //#include "nicktreemodel.h" #include "signalproxy.h" #include "ircuser.h" +#include "util.h" #include #include +#include #include @@ -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 { @@ -100,6 +100,42 @@ QString IrcChannel::userModes(const QString &nick) const { return userModes(networkInfo->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 networkInfo->decodeString(text); + return ::decodeString(text, _codecForDecoding); +} + +QByteArray IrcChannel::encodeString(const QString string) const { + if(codecForEncoding()) { + return _codecForEncoding->fromUnicode(string); + } + return networkInfo->encodeString(string); +} + // ==================== // PUBLIC SLOTS: // ==================== @@ -112,7 +148,7 @@ void IrcChannel::join(IrcUser *ircuser) { if(!_userModes.contains(ircuser) && ircuser) { _userModes[ircuser] = QString(); ircuser->joinChannel(name()); - qDebug() << "JOIN" << name() << ircuser->nick() << ircUsers().count(); + //qDebug() << "JOIN" << name() << ircuser->nick() << ircUsers().count(); connect(ircuser, SIGNAL(nickSet(QString)), this, SLOT(ircUserNickSet(QString))); connect(ircuser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed())); // if you wonder why there is no counterpart to ircUserJoined: @@ -129,7 +165,7 @@ void IrcChannel::part(IrcUser *ircuser) { if(isKnownUser(ircuser)) { _userModes.remove(ircuser); ircuser->partChannel(name()); - qDebug() << "PART" << name() << ircuser->nick() << ircUsers().count(); + //qDebug() << "PART" << name() << ircuser->nick() << ircUsers().count(); // if you wonder why there is no counterpart to ircUserParted: // the joines are propagted by the ircuser. the signal ircUserParted is only for convenience emit ircUserParted(ircuser); @@ -211,7 +247,7 @@ void IrcChannel::ircUserDestroyed() { Q_ASSERT(ircUser); _userModes.remove(ircUser); emit ircUserParted(ircUser); - qDebug() << "DEST" << name() << ircUsers().count(); + //qDebug() << "DEST" << name() << ircUsers().count(); } void IrcChannel::ircUserNickSet(QString nick) {