X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Fbufferinfo.cpp;h=2583f809a0e8093074444e0785e95f6cb6e4c23a;hb=98ffecc6e97b208712c6f5c5da1b4ba10aa09333;hp=c7cdd73ecbb4807cdb88ea62c84c6f876a78dd68;hpb=902c95728306e5ba115de84800fc8d5d239c9d62;p=quassel.git diff --git a/src/common/bufferinfo.cpp b/src/common/bufferinfo.cpp index c7cdd73e..2583f809 100644 --- a/src/common/bufferinfo.cpp +++ b/src/common/bufferinfo.cpp @@ -1,11 +1,11 @@ /*************************************************************************** - * Copyright (C) 2005-07 by The Quassel IRC Development Team * + * Copyright (C) 2005-2018 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 * @@ -15,54 +15,78 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#include -#include -#include - #include "bufferinfo.h" +#include + +#include +#include +#include +#include + #include "util.h" BufferInfo::BufferInfo() - : _id(0), - _netid(0), - _gid(0), - _networkName(QString()), - _bufferName(QString()) { + : _bufferId(0) + , _netid(0) + , _bufferName(QString()) +{} + +BufferInfo::BufferInfo(BufferId id, NetworkId networkid, Type type, uint gid, QString buf) + : _bufferId(id) + , _netid(networkid) + , _type(type) + , _groupId(gid) + , _bufferName(std::move(buf)) +{} + +BufferInfo BufferInfo::fakeStatusBuffer(NetworkId networkId) +{ + return BufferInfo(0, networkId, StatusBuffer); } -BufferInfo::BufferInfo(uint id, uint networkid, uint gid, QString net, QString buf) - : _id(id), - _netid(networkid), - _gid(gid), - _networkName(net), - _bufferName(buf) { +QString BufferInfo::bufferName() const +{ + if (isChannelName(_bufferName)) + return _bufferName; + else + return nickFromMask(_bufferName); // FIXME get rid of global functions and use the Network stuff instead! } -QString BufferInfo::buffer() const { - if(isChannelName(_bufferName)) - return _bufferName; - else - return nickFromMask(_bufferName); +bool BufferInfo::acceptsRegularMessages() const +{ + if (_type == StatusBuffer || _type == InvalidBuffer) + return false; + return true; } -QDataStream &operator<<(QDataStream &out, const BufferInfo &bufferInfo) { - out << bufferInfo._id << bufferInfo._netid << bufferInfo._gid << bufferInfo._networkName.toUtf8() << bufferInfo._bufferName.toUtf8(); - return out; +QDebug operator<<(QDebug dbg, const BufferInfo& b) +{ + dbg.nospace() << "(bufId: " << b.bufferId() << ", netId: " << b.networkId() << ", groupId: " << b.groupId() + << ", buf: " << b.bufferName() << ")"; + return dbg.space(); } -QDataStream &operator>>(QDataStream &in, BufferInfo &bufferInfo) { - QByteArray n, b; - in >> bufferInfo._id >> bufferInfo._netid >> bufferInfo._gid >> n >> b; - bufferInfo._networkName = QString::fromUtf8(n); - bufferInfo._bufferName = QString::fromUtf8(b); - return in; +QDataStream& operator<<(QDataStream& out, const BufferInfo& bufferInfo) +{ + out << bufferInfo._bufferId << bufferInfo._netid << (qint16)bufferInfo._type << bufferInfo._groupId << bufferInfo._bufferName.toUtf8(); + return out; } -uint qHash(const BufferInfo &bufferid) { - return qHash(bufferid._id); +QDataStream& operator>>(QDataStream& in, BufferInfo& bufferInfo) +{ + QByteArray buffername; + qint16 bufferType; + in >> bufferInfo._bufferId >> bufferInfo._netid >> bufferType >> bufferInfo._groupId >> buffername; + bufferInfo._type = (BufferInfo::Type)bufferType; + bufferInfo._bufferName = QString::fromUtf8(buffername); + return in; } +uint qHash(const BufferInfo& bufferid) +{ + return qHash(bufferid._bufferId); +}