QXmpp  Version:0.4.92
 All Classes Functions Enumerations Enumerator Properties Groups
QXmppMessage.h
1 /*
2  * Copyright (C) 2008-2011 The QXmpp developers
3  *
4  * Author:
5  * Manjeet Dahiya
6  *
7  * Source:
8  * http://code.google.com/p/qxmpp
9  *
10  * This file is a part of QXmpp library.
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * Lesser General Public License for more details.
21  *
22  */
23 
24 
25 #ifndef QXMPPMESSAGE_H
26 #define QXMPPMESSAGE_H
27 
28 #include <QDateTime>
29 #include "QXmppStanza.h"
30 
35 
36 class QXMPP_EXPORT QXmppMessage : public QXmppStanza
37 {
38 public:
40  enum Type
41  {
42  Error = 0,
43  Normal,
44  Chat,
45  GroupChat,
46  Headline
47  };
48 
51  enum State
52  {
53  None = 0,
56  Gone,
59  };
60 
61  QXmppMessage(const QString& from = "", const QString& to = "",
62  const QString& body = "", const QString& thread = "");
63  ~QXmppMessage();
64 
65  QString body() const;
66  void setBody(const QString&);
67 
68  bool isAttentionRequested() const;
69  void setAttentionRequested(bool requested);
70 
71  bool isReceiptRequested() const;
72  void setReceiptRequested(bool requested);
73 
74  QString receiptId() const;
75  void setReceiptId(const QString &id);
76 
77  QDateTime stamp() const;
78  void setStamp(const QDateTime &stamp);
79 
80  QXmppMessage::State state() const;
81  void setState(QXmppMessage::State);
82 
83  QString subject() const;
84  void setSubject(const QString&);
85 
86  QString thread() const;
87  void setThread(const QString&);
88 
89  QXmppMessage::Type type() const;
90  void setType(QXmppMessage::Type);
91 
93  void parse(const QDomElement &element);
94  void toXml(QXmlStreamWriter *writer) const;
96 
97 private:
99  enum StampType
100  {
101  LegacyDelayedDelivery,
102  DelayedDelivery,
103  };
104 
105  QString getTypeStr() const;
106  void setTypeFromStr(const QString&);
107 
108  Type m_type;
109  QDateTime m_stamp;
110  StampType m_stampType;
111  State m_state;
112 
113  bool m_attentionRequested;
114  QString m_body;
115  QString m_subject;
116  QString m_thread;
117 
118  // Request message receipt as per XEP-0184.
119  QString m_receiptId;
120  bool m_receiptRequested;
121 };
122 
123 #endif // QXMPPMESSAGE_H