1 /***************************************************************************
2 * Copyright (C) 2005-2018 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
21 #include "bufferinfo.h"
26 #include <QDataStream>
32 BufferInfo::BufferInfo()
35 , _bufferName(QString())
38 BufferInfo::BufferInfo(BufferId id, NetworkId networkid, Type type, uint gid, QString buf)
43 , _bufferName(std::move(buf))
46 BufferInfo BufferInfo::fakeStatusBuffer(NetworkId networkId)
48 return BufferInfo(0, networkId, StatusBuffer);
51 QString BufferInfo::bufferName() const
53 if (isChannelName(_bufferName))
56 return nickFromMask(_bufferName); // FIXME get rid of global functions and use the Network stuff instead!
59 bool BufferInfo::acceptsRegularMessages() const
61 if (_type == StatusBuffer || _type == InvalidBuffer)
66 QDebug operator<<(QDebug dbg, const BufferInfo& b)
68 dbg.nospace() << "(bufId: " << b.bufferId() << ", netId: " << b.networkId() << ", groupId: " << b.groupId()
69 << ", buf: " << b.bufferName() << ")";
73 QDataStream& operator<<(QDataStream& out, const BufferInfo& bufferInfo)
75 out << bufferInfo._bufferId << bufferInfo._netid << (qint16)bufferInfo._type << bufferInfo._groupId << bufferInfo._bufferName.toUtf8();
79 QDataStream& operator>>(QDataStream& in, BufferInfo& bufferInfo)
81 QByteArray buffername;
83 in >> bufferInfo._bufferId >> bufferInfo._netid >> bufferType >> bufferInfo._groupId >> buffername;
84 bufferInfo._type = (BufferInfo::Type)bufferType;
85 bufferInfo._bufferName = QString::fromUtf8(buffername);
89 uint qHash(const BufferInfo& bufferid)
91 return qHash(bufferid._bufferId);