libqutim 0.2.80.1

message.h

Go to the documentation of this file.
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     quint64 id() const;
00061     QVariant property(const char *name, const QVariant &def = QVariant()) const;
00062     template<typename T>
00063     T property(const char *name, const T &def) const
00064     { return qVariantValue<T>(property(name, qVariantFromValue<T>(def))); }
00065     void setProperty(const char *name, const QVariant &value);
00066     QList<QByteArray> dynamicPropertyNames() const;
00067 private:
00068     QSharedDataPointer<MessagePrivate> p;
00069 };
00070 
00071 class LIBQUTIM_EXPORT MessageReceiptEvent : public QEvent
00072 {
00073 public:
00074     MessageReceiptEvent(quint64 id, bool success);
00075     inline quint64 id() const { return i; }
00076     inline bool success() const { return s; }
00077     static QEvent::Type eventType();
00078 protected:
00079     quint64 i;
00080     bool s;
00081 };
00082 
00083 LIBQUTIM_EXPORT QString unescape(const QString &html);
00084 
00085 typedef QList<Message> MessageList;
00086 }
00087 
00088 Q_DECLARE_METATYPE(qutim_sdk_0_3::Message)
00089 Q_DECLARE_METATYPE(qutim_sdk_0_3::Message*)
00090 Q_DECLARE_METATYPE(qutim_sdk_0_3::MessageList)
00091 
00092 #endif // LIBQUTIM_MESSAGE_H
00093