QXmpp Version:0.3.0
QXmppMessage.h
00001 /*
00002  * Copyright (C) 2008-2011 The QXmpp developers
00003  *
00004  * Author:
00005  *  Manjeet Dahiya
00006  *
00007  * Source:
00008  *  http://code.google.com/p/qxmpp
00009  *
00010  * This file is a part of QXmpp library.
00011  *
00012  * This library is free software; you can redistribute it and/or
00013  * modify it under the terms of the GNU Lesser General Public
00014  * License as published by the Free Software Foundation; either
00015  * version 2.1 of the License, or (at your option) any later version.
00016  *
00017  * This library is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020  * Lesser General Public License for more details.
00021  *
00022  */
00023 
00024 
00025 #ifndef QXMPPMESSAGE_H
00026 #define QXMPPMESSAGE_H
00027 
00028 #include <QDateTime>
00029 #include "QXmppStanza.h"
00030 
00035 
00036 class QXmppMessage : public QXmppStanza
00037 {
00038 public:
00040     enum Type
00041     {
00042         Error = 0,
00043         Normal,
00044         Chat,
00045         GroupChat,
00046         Headline
00047     };
00048 
00051     enum State
00052     {
00053         None = 0,   
00054         Active,     
00055         Inactive,   
00056         Gone,       
00057         Composing,  
00058         Paused,     
00059     };
00060 
00061     QXmppMessage(const QString& from = "", const QString& to = "",
00062                  const QString& body = "", const QString& thread = "");
00063     ~QXmppMessage();
00064     
00065     QString body() const;
00066     void setBody(const QString&);
00067 
00068     QString getXhtml() const;
00069     void setXhtml(const QString&);
00070 
00071     QDateTime stamp() const;
00072     void setStamp(const QDateTime &stamp);
00073 
00074     QXmppMessage::State state() const;
00075     void setState(QXmppMessage::State);
00076 
00077     QString subject() const;
00078     void setSubject(const QString&);
00079 
00080     QString thread() const;
00081     void setThread(const QString&);
00082 
00083     QXmppMessage::Type type() const;
00084     void setType(QXmppMessage::Type);
00085 
00086     bool requestReceipt() const;
00087     void setRequestReceipt(bool);
00088 
00089     bool isAttention() const;
00090     void setAttention(bool);
00091 
00093     void parse(const QDomElement &element);
00094     void toXml(QXmlStreamWriter *writer) const;
00096 
00097 private:
00099     enum StampType
00100     {
00101         LegacyDelayedDelivery,  
00102         DelayedDelivery,        
00103     };
00104 
00105     QString getTypeStr() const;
00106     void setTypeFromStr(const QString&);
00107 
00108     Type m_type;
00109     QDateTime m_stamp;
00110     StampType m_stampType;
00111     State m_state;
00112 
00113     QString m_body;
00114     QString m_subject;
00115     QString m_thread;
00116 
00117     // Request message receipt as per XEP-0184.
00118     bool m_requestReceipt;
00119 
00120     // Attention message as per XEP-0224.
00121     bool m_attention;
00122 
00123     // Rich contents as per XEP-0071. Contains raw XML.
00124     QString m_xhtml;
00125 };
00126 
00127 #endif // QXMPPMESSAGE_H
 All Classes Functions Enumerations Enumerator Properties