libqutim  0.3.1.0
message.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** qutIM - instant messenger
4 **
5 ** Copyright © 2011 Ruslan Nigmatullin <euroelessar@yandex.ru>
6 **
7 *****************************************************************************
8 **
9 ** $QUTIM_BEGIN_LICENSE$
10 ** This program is free software: you can redistribute it and/or modify
11 ** it under the terms of the GNU General Public License as published by
12 ** the Free Software Foundation, either version 3 of the License, or
13 ** (at your option) any later version.
14 **
15 ** This program is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 ** See the GNU General Public License for more details.
19 **
20 ** You should have received a copy of the GNU General Public License
21 ** along with this program. If not, see http://www.gnu.org/licenses/.
22 ** $QUTIM_END_LICENSE$
23 **
24 ****************************************************************************/
25 
26 #ifndef LIBQUTIM_MESSAGE_H
27 #define LIBQUTIM_MESSAGE_H
28 
29 #include "libqutim_global.h"
30 #include <QSharedData>
31 #include <QVariant>
32 #include <QEvent>
33 
34 class QScriptEngine;
35 
36 namespace qutim_sdk_0_3
37 {
38 class ChatUnit;
39 class MessagePrivate;
40 
42 {
43 public:
44  Message();
45  Message(const QString &text);
46  Message(const Message &other);
47  virtual ~Message();
48  Message &operator =(const Message &other);
49  static void scriptRegister(QScriptEngine *engine);
50  const QString &text() const;
51  void setText(const QString &text);
52  QString html() const;
53  void setHtml(const QString &html);
54  const QDateTime &time() const;
55  void setTime(const QDateTime &time);
56  void setIncoming(bool input);
57  bool isIncoming() const;
58  void setChatUnit (ChatUnit *chatUnit);
59  ChatUnit *chatUnit() const;
60  QString unitName() const;
61  QString unitId() const;
62  QString unitAvatar() const;
63  quint64 id() const;
64  QVariant property(const char *name, const QVariant &def = QVariant()) const;
65  template<typename T>
66  T property(const char *name, const T &def) const;
67  void setProperty(const char *name, const QVariant &value);
68  QList<QByteArray> dynamicPropertyNames() const;
69 private:
70  QSharedDataPointer<MessagePrivate> p;
71 };
72 
73 template<typename T>
74 T Message::property(const char *name, const T &def) const
75 {
76  QVariant var = property(name, QVariant::fromValue<T>(def));
77  return var.value<T>();
78 }
79 
80 
81 class LIBQUTIM_EXPORT MessageReceiptEvent : public QEvent
82 {
83 public:
84  MessageReceiptEvent(quint64 id, bool success);
85  inline quint64 id() const { return i; }
86  inline bool success() const { return s; }
87  static QEvent::Type eventType();
88 protected:
89  quint64 i;
90  bool s;
91 };
92 
93 LIBQUTIM_EXPORT QString unescape(const QString &html);
94 
95 typedef QList<Message> MessageList;
96 }
97 
98 LIBQUTIM_EXPORT QDebug operator<<(QDebug dbg, const qutim_sdk_0_3::Message &msg);
99 
100 
102 Q_DECLARE_METATYPE(qutim_sdk_0_3::Message*)
103 Q_DECLARE_METATYPE(qutim_sdk_0_3::MessageList)
104 
105 #endif // LIBQUTIM_MESSAGE_H
106 

Generated by Doxygen