libqutim
0.3.1.0
|
00001 /**************************************************************************** 00002 ** 00003 ** qutIM - instant messenger 00004 ** 00005 ** Copyright © 2011 Ruslan Nigmatullin <euroelessar@yandex.ru> 00006 ** 00007 ***************************************************************************** 00008 ** 00009 ** $QUTIM_BEGIN_LICENSE$ 00010 ** This program is free software: you can redistribute it and/or modify 00011 ** it under the terms of the GNU General Public License as published by 00012 ** the Free Software Foundation, either version 3 of the License, or 00013 ** (at your option) any later version. 00014 ** 00015 ** This program is distributed in the hope that it will be useful, 00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00018 ** See the GNU General Public License for more details. 00019 ** 00020 ** You should have received a copy of the GNU General Public License 00021 ** along with this program. If not, see http://www.gnu.org/licenses/. 00022 ** $QUTIM_END_LICENSE$ 00023 ** 00024 ****************************************************************************/ 00025 00026 #ifndef LIBQUTIM_MESSAGE_H 00027 #define LIBQUTIM_MESSAGE_H 00028 00029 #include "libqutim_global.h" 00030 #include <QSharedData> 00031 #include <QVariant> 00032 #include <QEvent> 00033 00034 class QScriptEngine; 00035 00036 namespace qutim_sdk_0_3 00037 { 00038 class ChatUnit; 00039 class MessagePrivate; 00040 00041 class LIBQUTIM_EXPORT Message 00042 { 00043 public: 00044 Message(); 00045 Message(const QString &text); 00046 Message(const Message &other); 00047 virtual ~Message(); 00048 Message &operator =(const Message &other); 00049 static void scriptRegister(QScriptEngine *engine); 00050 const QString &text() const; 00051 void setText(const QString &text); 00052 QString html() const; 00053 void setHtml(const QString &html); 00054 const QDateTime &time() const; 00055 void setTime(const QDateTime &time); 00056 void setIncoming(bool input); 00057 bool isIncoming() const; 00058 void setChatUnit (ChatUnit *chatUnit); 00059 ChatUnit *chatUnit() const; 00060 QString unitName() const; 00061 QString unitId() const; 00062 QString unitAvatar() const; 00063 quint64 id() const; 00064 QVariant property(const char *name, const QVariant &def = QVariant()) const; 00065 template<typename T> 00066 T property(const char *name, const T &def) const 00067 { return qVariantValue<T>(property(name, qVariantFromValue<T>(def))); } 00068 void setProperty(const char *name, const QVariant &value); 00069 QList<QByteArray> dynamicPropertyNames() const; 00070 private: 00071 QSharedDataPointer<MessagePrivate> p; 00072 }; 00073 00074 class LIBQUTIM_EXPORT MessageReceiptEvent : public QEvent 00075 { 00076 public: 00077 MessageReceiptEvent(quint64 id, bool success); 00078 inline quint64 id() const { return i; } 00079 inline bool success() const { return s; } 00080 static QEvent::Type eventType(); 00081 protected: 00082 quint64 i; 00083 bool s; 00084 }; 00085 00086 LIBQUTIM_EXPORT QString unescape(const QString &html); 00087 00088 typedef QList<Message> MessageList; 00089 } 00090 00091 Q_DECLARE_METATYPE(qutim_sdk_0_3::Message) 00092 Q_DECLARE_METATYPE(qutim_sdk_0_3::Message*) 00093 Q_DECLARE_METATYPE(qutim_sdk_0_3::MessageList) 00094 00095 #endif // LIBQUTIM_MESSAGE_H 00096