X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fbufferinfo.cpp;h=f9c01c049c113d46815afe685d236ad70e366209;hp=8d45a47d30e4e9d2120eae7115c1a25f2cb61144;hb=097f625c4bd147f4127573ad8ab48555f9dc62d3;hpb=23ebdc0a422294764ff3be3f8d7e56cc2b323185 diff --git a/src/common/bufferinfo.cpp b/src/common/bufferinfo.cpp index 8d45a47d..f9c01c04 100644 --- a/src/common/bufferinfo.cpp +++ b/src/common/bufferinfo.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * + * Copyright (C) 2005-2020 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,59 +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 "bufferinfo.h" + +#include + +#include #include #include -#include - -#include "bufferinfo.h" +#include #include "util.h" BufferInfo::BufferInfo() - : _id(0), - _netid(0), - _gid(0), - _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(BufferId id, NetworkId networkid, uint gid, QString buf) - : _id(id), - _netid(networkid), - _gid(gid), - _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); // FIXME get rid of global functions and use the Network stuff instead! +bool BufferInfo::acceptsRegularMessages() const +{ + if (_type == StatusBuffer || _type == InvalidBuffer) + return false; + return true; } -QDebug operator<<(QDebug dbg, const BufferInfo &b) { - dbg.nospace() << "(bufId: " << b.uid() << ", netId: " << b.networkId() << ", groupId: " << b.groupId() << ", buf: " << b.buffer() << ")"; - return dbg.space(); +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 &out, const BufferInfo &bufferInfo) { - out << bufferInfo._id << bufferInfo._netid << bufferInfo._gid << bufferInfo._bufferName.toUtf8(); - return out; +QDataStream& operator<<(QDataStream& out, const BufferInfo& bufferInfo) +{ + out << bufferInfo._bufferId << bufferInfo._netid << (qint16)bufferInfo._type << bufferInfo._groupId << bufferInfo._bufferName.toUtf8(); + return out; } -QDataStream &operator>>(QDataStream &in, BufferInfo &bufferInfo) { - QByteArray buffername; - in >> bufferInfo._id >> bufferInfo._netid >> bufferInfo._gid >> buffername; - bufferInfo._bufferName = QString::fromUtf8(buffername); - return in; +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._id.toInt()); +uint qHash(const BufferInfo& bufferid) +{ + return qHash(bufferid._bufferId); } -