Quassel IRC  Pre-Release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
messageevent.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2015 by the Quassel Project *
3  * devel@quassel-irc.org *
4  * *
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. *
9  * *
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. *
14  * *
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  ***************************************************************************/
20 
21 #ifndef MESSAGEEVENT_H
22 #define MESSAGEEVENT_H
23 
24 #include "message.h"
25 #include "networkevent.h"
26 
27 // this corresponds to CoreSession::RawMessage for now and should contain the information we need to convert events
28 // into messages for the legacy code to work with
29 
30 class MessageEvent : public NetworkEvent
31 {
32 public:
35  const QString &msg,
36  const QString &sender = QString(),
37  const QString &target = QString(),
38  Message::Flags msgFlags = Message::None,
39  const QDateTime &timestamp = QDateTime()
40  );
41 
42  inline Message::Type msgType() const { return _msgType; }
44 
45  inline BufferInfo::Type bufferType() const { return _bufferType; }
47 
48  inline QString target() const { return _target; }
49  inline QString text() const { return _text; }
50  inline QString sender() const { return _sender; }
51 
52  inline Message::Flags msgFlags() const { return _msgFlags; }
53  inline void setMsgFlag(Message::Flag flag) { _msgFlags |= flag; }
54  inline void setMsgFlags(Message::Flags flags) { _msgFlags = flags; }
55 
56  static Event *create(EventManager::EventType type, QVariantMap &map, Network *network);
57 
58 protected:
59  explicit MessageEvent(EventManager::EventType type, QVariantMap &map, Network *network);
60  void toVariantMap(QVariantMap &map) const;
61 
62  virtual inline QString className() const { return "MessageEvent"; }
63  virtual inline void debugInfo(QDebug &dbg) const
64  {
66  dbg.nospace() << ", sender = " << qPrintable(sender())
67  << ", target = " << qPrintable(target())
68  << ", text = " << text()
69  << ", msgtype = " << qPrintable(QString::number(msgType(), 16))
70  << ", buffertype = " << qPrintable(QString::number(bufferType(), 16))
71  << ", msgflags = " << qPrintable(QString::number(msgFlags(), 16));
72  }
73 
74 
75 private:
76  BufferInfo::Type bufferTypeByTarget(const QString &target) const;
77 
80  QString _text, _sender, _target;
81  Message::Flags _msgFlags;
82 };
83 
84 
85 #endif