X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fmessage.cpp;h=d83edbd51260c2538d8f886c1c257c3ed253ef2c;hp=f1f7c48af8ca00eab4cdec12ef9609fa8c66b2eb;hb=b2169e5f4cbd3ce724c4808b62ddc2b8941219a5;hpb=f824db0e31b54969e0b7fa0b5405b1e9173d482c diff --git a/src/common/message.cpp b/src/common/message.cpp index f1f7c48a..d83edbd5 100644 --- a/src/common/message.cpp +++ b/src/common/message.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-09 by the Quassel Project * + * Copyright (C) 2005-2014 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,7 +15,7 @@ * 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 "message.h" @@ -25,7 +25,7 @@ #include Message::Message(const BufferInfo &bufferInfo, Type type, const QString &contents, const QString &sender, Flags flags) - : _timestamp(QDateTime::currentDateTime().toUTC()), + : _timestamp(QDateTime::currentDateTime().toUTC()), _bufferInfo(bufferInfo), _contents(contents), _sender(sender), @@ -34,8 +34,9 @@ Message::Message(const BufferInfo &bufferInfo, Type type, const QString &content { } + Message::Message(const QDateTime &ts, const BufferInfo &bufferInfo, Type type, const QString &contents, const QString &sender, Flags flags) - : _timestamp(ts), + : _timestamp(ts), _bufferInfo(bufferInfo), _contents(contents), _sender(sender), @@ -44,37 +45,39 @@ Message::Message(const QDateTime &ts, const BufferInfo &bufferInfo, Type type, c { } -void Message::setFlags(Flags flags) { - _flags = flags; -} -QDataStream &operator<<(QDataStream &out, const Message &msg) { - out << msg.msgId() << (quint32)msg.timestamp().toTime_t() << (quint32)msg.type() << (quint8)msg.flags() - << msg.bufferInfo() << msg.sender().toUtf8() << msg.contents().toUtf8(); - return out; +QDataStream &operator<<(QDataStream &out, const Message &msg) +{ + out << msg.msgId() << (quint32)msg.timestamp().toTime_t() << (quint32)msg.type() << (quint8)msg.flags() + << msg.bufferInfo() << msg.sender().toUtf8() << msg.contents().toUtf8(); + return out; } -QDataStream &operator>>(QDataStream &in, Message &msg) { - quint8 f; - quint32 t; - quint32 ts; - QByteArray s, m; - BufferInfo buf; - in >> msg._msgId >> ts >> t >> f >> buf >> s >> m; - msg._type = (Message::Type)t; - msg._flags = (Message::Flags)f; - msg._bufferInfo = buf; - msg._timestamp = QDateTime::fromTime_t(ts); - msg._sender = QString::fromUtf8(s); - msg._contents = QString::fromUtf8(m); - return in; + +QDataStream &operator>>(QDataStream &in, Message &msg) +{ + quint8 f; + quint32 t; + quint32 ts; + QByteArray s, m; + BufferInfo buf; + in >> msg._msgId >> ts >> t >> f >> buf >> s >> m; + msg._type = (Message::Type)t; + msg._flags = (Message::Flags)f; + msg._bufferInfo = buf; + msg._timestamp = QDateTime::fromTime_t(ts); + msg._sender = QString::fromUtf8(s); + msg._contents = QString::fromUtf8(m); + return in; } -QDebug operator<<(QDebug dbg, const Message &msg) { - dbg.nospace() << qPrintable(QString("Message(MsgId:")) << msg.msgId() - << qPrintable(QString(",")) << msg.timestamp() - << qPrintable(QString(", Type:")) << msg.type() - << qPrintable(QString(", Flags:")) << msg.flags() << qPrintable(QString(")")) - << msg.sender() << ":" << msg.contents(); - return dbg; + +QDebug operator<<(QDebug dbg, const Message &msg) +{ + dbg.nospace() << qPrintable(QString("Message(MsgId:")) << msg.msgId() + << qPrintable(QString(",")) << msg.timestamp() + << qPrintable(QString(", Type:")) << msg.type() + << qPrintable(QString(", Flags:")) << msg.flags() << qPrintable(QString(")")) + << msg.sender() << ":" << msg.contents(); + return dbg; }