1 /***************************************************************************
2 * Copyright (C) 2005-2013 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 ***************************************************************************/
22 #include <QDataStream>
26 #include "bufferinfo.h"
30 BufferInfo::BufferInfo()
35 _bufferName(QString())
40 BufferInfo::BufferInfo(BufferId id, NetworkId networkid, Type type, uint gid, QString buf)
50 BufferInfo BufferInfo::fakeStatusBuffer(NetworkId networkId)
52 return BufferInfo(0, networkId, StatusBuffer);
56 QString BufferInfo::bufferName() const
58 if (isChannelName(_bufferName))
61 return nickFromMask(_bufferName); // FIXME get rid of global functions and use the Network stuff instead!
65 QDebug operator<<(QDebug dbg, const BufferInfo &b)
67 dbg.nospace() << "(bufId: " << b.bufferId() << ", netId: " << b.networkId() << ", groupId: " << b.groupId() << ", buf: " << b.bufferName() << ")";
72 QDataStream &operator<<(QDataStream &out, const BufferInfo &bufferInfo)
74 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);
90 uint qHash(const BufferInfo &bufferid)
92 return qHash(bufferid._bufferId);