1/* Copyright 2012 Martin Klapetek <martin.klapetek@gmail.com>
2
3 This library is free software; you can redistribute it and/or modify
4 it under the terms of the GNU Library General Public License as published
5 by the Free Software Foundation; either version 2 of the License or
6 (at your option) version 3 or, at the discretion of KDE e.V.
7 (which shall act as a proxy as in section 14 of the GPLv3), any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KFBAPI_NOTIFICATIONINFO_H
21#define KFBAPI_NOTIFICATIONINFO_H
22
23#include "libkfbapi_export.h"
24#include "userinfo.h"
25#include "appinfo.h"
26
27#include <KDateTime>
28
29namespace KFbAPI {
30
31/**
32 * Class to represent a facebook notification.
33 * See https://developers.facebook.com/docs/reference/api/user/#notifications
34 */
35
36class LIBKFBAPI_EXPORT NotificationInfo
37{
38public:
39 NotificationInfo();
40 NotificationInfo(const NotificationInfo &other);
41 ~NotificationInfo();
42
43 NotificationInfo &operator=(const NotificationInfo &other);
44
45 /**
46 * Set the notification id of the post
47 * @param id of the notification
48 */
49 void setId(const QString &id);
50 /**
51 * Returns notification id
52 */
53 QString id() const;
54
55 /**
56 * Set the user creating the notification
57 * @param from the user causing the notification
58 */
59 void setFrom(const QVariantMap &from);
60 /**
61 * Returns the user causing the notification as a User Info Object
62 */
63 UserInfo from() const;
64
65 /**
66 * Returns the user causing the notification as a QVariantMap
67 */
68 QVariantMap fromMap() const;
69
70 /**
71 * Set the user receiving the notification
72 * @param to the user receiving the notification
73 */
74 void setTo(const QVariantMap &to);
75 /**
76 * Returns the user receiving the notification as a User Info Object
77 */
78 UserInfo to() const;
79
80 /**
81 * Returns the user receiving the notification as a QVariantMap
82 */
83 QVariantMap toMap() const;
84
85 /**
86 * Set the creation time of the notification
87 * @param createdTime Time in "facebook format"
88 */
89 void setCreatedTimeString(const QString &time);
90 /**
91 * Returns the creation time as a string in "facebook format"
92 */
93 QString createdTimeString() const;
94 /**
95 * Returns the creation time in KDateTime
96 */
97 KDateTime createdTime() const;
98
99 /**
100 * Set the time of the last update of the notification
101 * @param updatedTime The time, in "facebook format", of the last update of
102 * the notification.
103 */
104 void setUpdatedTimeString(const QString &time);
105 /**
106 * Returns the time of the last update of the notification in "facebook format"
107 */
108 QString updatedTimeString() const;
109 /**
110 * Returns the time of the last update of the notification as a KDateTime
111 */
112 KDateTime updatedTime() const;
113
114
115 /**
116 * Set the title of the notification (it's the notification text itself)
117 * @param title Title of the notification
118 */
119 void setTitle(const QString &title);
120 /**
121 * Returns notification title (which is the notification text itself)
122 */
123 QString title() const;
124
125 /**
126 * Sets the message of the notification, which is for example the comment itself
127 * If there was no commenting involved etc, this is empty
128 *
129 * @param message The notification message
130 */
131 void setMessage(const QString &message);
132
133 /**
134 * Returns notification message (usually a comment posted by the user)
135 */
136 QString message() const;
137
138 /**
139 * Set the link for the notification
140 * @param link Link for the notification
141 */
142 void setLink(const QUrl &link);
143 /**
144 * Returns link for the notification
145 */
146 QUrl link() const;
147
148 /**
149 * Set application details that caused the notification
150 * @param app The app that caused the notification
151 */
152 void setApplication(const QVariantMap &app);
153 /**
154 * Returns the creator app that caused the notification
155 */
156 AppInfo application() const;
157
158 /**
159 * Returns the creator app that caused the notification as QVariantMap
160 */
161 QVariantMap applicationMap() const;
162
163 /**
164 * Set the notification as read/unread
165 * @param unread True if the notification is read, false otherwise
166 */
167 void setUnread(bool unread);
168 /**
169 * Returns whether the user has read the notification or not
170 */
171 bool unread() const;
172
173private:
174 class NotificationInfoPrivate;
175 QSharedDataPointer<NotificationInfoPrivate> d;
176};
177
178}
179
180Q_DECLARE_METATYPE(KFbAPI::NotificationInfo)
181
182#endif // NOTIFICATIONINFO_H
183