X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fircchannel.cpp;h=832a5a993b05cdf01b3c02bd5241d30d186c8868;hp=ba2fd3c2f8ed079462f4e8e13c90dc835f0e71ea;hb=da3aa4136fe01e142238f0f42fe1273481037b9d;hpb=8699dd758516d0ded076811e8ea656adc95e69d0 diff --git a/src/common/ircchannel.cpp b/src/common/ircchannel.cpp index ba2fd3c2..832a5a99 100644 --- a/src/common/ircchannel.cpp +++ b/src/common/ircchannel.cpp @@ -20,7 +20,7 @@ #include "ircchannel.h" -#include "networkinfo.h" +#include "network.h" //#include "nicktreemodel.h" #include "signalproxy.h" #include "ircuser.h" @@ -33,18 +33,18 @@ #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), + _codecForEncoding(0), + _codecForDecoding(0) { - setObjectName(QString::number(networkInfo->networkId()) + "/" + channelname); + setObjectName(QString::number(network->networkId().toInt()) + "/" + channelname); } IrcChannel::~IrcChannel() { - } // ==================== @@ -73,22 +73,6 @@ bool IrcChannel::isValidChannelUserMode(const QString &mode) const { return isvalid; } -bool IrcChannel::initialized() const { - return _initialized; -} - -QString IrcChannel::name() const { - return _name; -} - -QString IrcChannel::topic() const { - return _topic; -} - -QList IrcChannel::ircUsers() const { - return _userModes.keys(); -} - QString IrcChannel::userModes(IrcUser *ircuser) const { if(_userModes.contains(ircuser)) return _userModes[ircuser]; @@ -97,11 +81,7 @@ QString IrcChannel::userModes(IrcUser *ircuser) const { } QString IrcChannel::userModes(const QString &nick) const { - return userModes(networkInfo->ircUser(nick)); -} - -QTextCodec *IrcChannel::codecForEncoding() const { - return _codecForEncoding; + return userModes(network->ircUser(nick)); } void IrcChannel::setCodecForEncoding(const QString &name) { @@ -112,10 +92,6 @@ void IrcChannel::setCodecForEncoding(QTextCodec *codec) { _codecForEncoding = codec; } -QTextCodec *IrcChannel::codecForDecoding() const { - return _codecForDecoding; -} - void IrcChannel::setCodecForDecoding(const QString &name) { setCodecForDecoding(QTextCodec::codecForName(name.toAscii())); } @@ -125,15 +101,15 @@ void IrcChannel::setCodecForDecoding(QTextCodec *codec) { } QString IrcChannel::decodeString(const QByteArray &text) const { - if(!codecForDecoding()) return networkInfo->decodeString(text); + if(!codecForDecoding()) return network->decodeString(text); return ::decodeString(text, _codecForDecoding); } -QByteArray IrcChannel::encodeString(const QString string) const { +QByteArray IrcChannel::encodeString(const QString &string) const { if(codecForEncoding()) { return _codecForEncoding->fromUnicode(string); } - return networkInfo->encodeString(string); + return network->encodeString(string); } // ==================== @@ -144,10 +120,15 @@ void IrcChannel::setTopic(const QString &topic) { emit topicSet(topic); } +void IrcChannel::setPassword(const QString &password) { + _password = password; + emit passwordSet(password); +} + void IrcChannel::join(IrcUser *ircuser) { if(!_userModes.contains(ircuser) && ircuser) { _userModes[ircuser] = QString(); - ircuser->joinChannel(name()); + ircuser->joinChannel(this); //qDebug() << "JOIN" << name() << ircuser->nick() << ircUsers().count(); connect(ircuser, SIGNAL(nickSet(QString)), this, SLOT(ircUserNickSet(QString))); connect(ircuser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed())); @@ -158,22 +139,25 @@ void IrcChannel::join(IrcUser *ircuser) { } void IrcChannel::join(const QString &nick) { - join(networkInfo->ircUser(nick)); + join(network->ircUser(nick)); } void IrcChannel::part(IrcUser *ircuser) { if(isKnownUser(ircuser)) { _userModes.remove(ircuser); - ircuser->partChannel(name()); + ircuser->partChannel(this); //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 + disconnect(ircuser, 0, this, 0); emit ircUserParted(ircuser); + if(network->isMe(ircuser)) + deleteLater(); } } void IrcChannel::part(const QString &nick) { - part(networkInfo->ircUser(nick)); + part(network->ircUser(nick)); } // SET USER MODE @@ -186,7 +170,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 @@ -203,7 +187,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 @@ -220,7 +204,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 @@ -246,8 +230,8 @@ void IrcChannel::ircUserDestroyed() { IrcUser *ircUser = static_cast(sender()); Q_ASSERT(ircUser); _userModes.remove(ircUser); - emit ircUserParted(ircUser); - //qDebug() << "DEST" << name() << ircUsers().count(); + // no further propagation. + // this leads only to fuck ups. } void IrcChannel::ircUserNickSet(QString nick) { @@ -256,8 +240,3 @@ void IrcChannel::ircUserNickSet(QString nick) { emit ircUserNickSet(ircUser, nick); } -void IrcChannel::setInitialized() { - _initialized = true; - emit initDone(); -} -