Added coordinates to Messages, added Message type.
[situare] / src / situareservice / message.h
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5       Jussi Laitinen - jussi.laitinen@ixonos.com
6
7    Situare is free software; you can redistribute it and/or
8    modify it under the terms of the GNU General Public License
9    version 2 as published by the Free Software Foundation.
10
11    Situare is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with Situare; if not, write to the Free Software
18    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
19    USA.
20 */
21
22 #ifndef MESSAGE_H
23 #define MESSAGE_H
24
25 #include <QDateTime>
26 #include <QMetaType>
27 #include <QPixmap>
28 #include <QString>
29
30 #include "coordinates/geocoordinate.h"
31
32 /**
33  * @brief Container for a single message.
34  *
35  * @author Jussi Laitinen - jussi.laitinen@ixonos.com
36  */
37 class Message
38 {
39 public:
40     enum Type{MessageTypeReceived, MessageTypeSent};
41
42     /**
43     * @brief Constructor
44     *
45     * Constructs empty Message object.
46     */
47     Message(const Type type = Message::MessageTypeReceived);
48
49 /*******************************************************************************
50  * MEMBER FUNCTIONS AND SLOTS
51  ******************************************************************************/
52  public:
53     /**
54     * @brief Returns message's coordinates
55     *
56     * @return message's coordinates as GeoCoordinate
57     */
58     const GeoCoordinate &coordinates() const;
59
60     /**
61     * @brief Returns message's ID
62     *
63     * @return message's ID
64     */
65     const QString &id() const;
66
67     /**
68     * @brief Returns message's image
69     *
70     * @return message's image
71     */
72     const QPixmap &image() const;
73
74     /**
75     * @brief Returns message receiver's ID
76     *
77     * @return message receiver's ID
78     */
79     const QString &receiverId() const;
80
81     /**
82     * @brief Returns message sender's ID
83     *
84     * @return message sender's ID
85     */
86     const QString &senderId() const;
87
88     /**
89     * @brief Returns message sender's name
90     *
91     * @return message sender's name
92     */
93     const QString &senderName() const;
94
95     /**
96     * @brief Sets message's coordinates
97     *
98     * @param coordinates message's coordinates
99     */
100     void setCoordinates(const GeoCoordinate &coordinates);
101
102     /**
103     * @brief Sets message's image
104     *
105     * @param image message's image
106     */
107     void setImage(const QPixmap &image);
108
109     /**
110     * @brief Sets message's ID
111     *
112     * @param id message's ID
113     */
114     void setId(const QString &id);
115
116     /**
117     * @brief Sets message receiver's ID
118     *
119     * @param id message receiver's ID
120     */
121     void setReceiverId(const QString &receiverId);
122
123     /**
124     * @brief Sets message's text
125     *
126     * @param text message's text
127     */
128     void setText(const QString &text);
129
130     /**
131     * @brief Sets message's timestamp
132     *
133     * @param image message's timestamp
134     */
135     void setTimestamp(const QDateTime &timestamp);
136
137     /**
138     * @brief Sets message's title
139     *
140     * @param title message's title
141     */
142     void setTitle(const QString &title);
143
144     /**
145     * @brief Sets message's type
146     *
147     * @param type message's type
148     */
149     void setType(const Type type);
150
151     /**
152     * @brief Sets message sender's ID
153     *
154     * @param id message sender's ID
155     */
156     void setSenderId(const QString &senderId);
157
158     /**
159     * @brief Sets message sender's name
160     *
161     * @param id message sender's name
162     */
163     void setSenderName(const QString &senderName);
164
165     /**
166     * @brief Returns message's text
167     *
168     * @return message's text
169     */
170     const QString &text() const;
171
172     /**
173     * @brief Returns message's timestamp
174     *
175     * @return message's timestamp
176     */
177     const QDateTime &timestamp() const;
178
179     /**
180     * @brief Returns message's title
181     *
182     * @return message's title
183     */
184     const QString &title() const;
185
186     /**
187     * @brief Returns message's type
188     *
189     * @return message's type
190     */
191     const Message::Type &type() const;
192
193 /*******************************************************************************
194  * DATA MEMBERS
195  ******************************************************************************/
196 private:
197     QDateTime m_timestamp;          ///< message's timestamp
198     QString m_id;                   ///< message's ID
199     QPixmap m_image;                ///< message's image
200     QString m_receiverId;           ///< message receiver's ID
201     QString m_senderId;             ///< message sender's ID
202     QString m_senderName;           ///< message sender's name
203     QString m_text;                 ///< message's text
204     QString m_title;                ///< message's title
205
206     GeoCoordinate m_coordinates;    ///< message's coordinates
207
208     Type m_type;                    ///< message's type
209 };
210
211 Q_DECLARE_METATYPE(Message)
212
213 #endif // MESSAGE_H