X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fbufferinfo.cpp;h=8ac1f4b04a0f6b3f80f82806e8f2b562480786a7;hp=19e627918f17e002a4ee01f0e30c7d2201327847;hb=3a3e844f9fcfd12235a0086af75ecd503b621ef4;hpb=5b560ec1a01349562ac58051ca7e7fa899d4b994 diff --git a/src/common/bufferinfo.cpp b/src/common/bufferinfo.cpp index 19e62791..8ac1f4b0 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-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,20 +15,21 @@ * 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 +#include #include "bufferinfo.h" #include "util.h" BufferInfo::BufferInfo() - : _bufferId(0), + : _bufferId(0), _netid(0), _type(InvalidBuffer), _groupId(0), @@ -36,42 +37,66 @@ BufferInfo::BufferInfo() { } + BufferInfo::BufferInfo(BufferId id, NetworkId networkid, Type type, uint gid, QString buf) - : _bufferId(id), + : _bufferId(id), _netid(networkid), _type(type), _groupId(gid), - _bufferName(buf) + _bufferName(std::move(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! + +BufferInfo BufferInfo::fakeStatusBuffer(NetworkId networkId) +{ + return BufferInfo(0, networkId, StatusBuffer); } -QDebug operator<<(QDebug dbg, const BufferInfo &b) { - dbg.nospace() << "(bufId: " << b.bufferId() << ", netId: " << b.networkId() << ", groupId: " << b.groupId() << ", buf: " << b.bufferName() << ")"; - return dbg.space(); + +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! +} + + +bool BufferInfo::acceptsRegularMessages() const +{ + if(_type == StatusBuffer || _type == InvalidBuffer) + return false; + return true; } -QDataStream &operator<<(QDataStream &out, const BufferInfo &bufferInfo) { - out << bufferInfo._bufferId << bufferInfo._netid << (qint16)bufferInfo._type << bufferInfo._groupId << 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 buffername; - qint16 bufferType; - in >> bufferInfo._bufferId >> bufferInfo._netid >> bufferType >> bufferInfo._groupId >> buffername; - bufferInfo._type = (BufferInfo::Type)bufferType; - bufferInfo._bufferName = QString::fromUtf8(buffername); - 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._bufferId); + +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); +}