1 /** |
|
2 * Copyright (c) 2010 Sasken Communication Technologies Ltd. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html" |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution |
|
11 * |
|
12 * Description: |
|
13 * Represents activities in terms similar to standard activity stream http://activitystrea.ms/ |
|
14 */ |
|
15 |
|
16 #ifndef SMFACTIONS_H_ |
|
17 #define SMFACTIONS_H_ |
|
18 |
|
19 #include <QList> |
|
20 #include <QImage> |
|
21 #include <QDateTime> |
|
22 #include <QStringList> |
|
23 #include <QUrl> |
|
24 #include <qdatastream.h> |
|
25 #include <QSharedData> |
|
26 #include <QMetaType> |
|
27 |
|
28 #include "smfclientglobal.h" |
|
29 |
|
30 |
|
31 /** |
|
32 * The actions in the activity based on Atom Activity Base Schema |
|
33 * see http://activitystrea.ms/schema/1.0/activity-schema-01.html |
|
34 */ |
|
35 enum SmfActivityVerb |
|
36 { |
|
37 SmfActivityMarkAsFavorite, |
|
38 SmfActivityStartFollowing, |
|
39 SmfActivityMarkLiked, |
|
40 SmfActivityMakeFriend, |
|
41 SmfActivityJoin, |
|
42 SmfActivityPlay, |
|
43 SmfActivityPost, |
|
44 SmfActivitySave, |
|
45 SmfActivityShare, |
|
46 SmfActivityTag, |
|
47 SmfActivityUpdate, |
|
48 }; |
|
49 |
|
50 /** |
|
51 * The type of the object on which the activity is performed - as per Atom Activity Base Schema |
|
52 * see http://activitystrea.ms/schema/1.0/activity-schema-01.html |
|
53 */ |
|
54 enum SmfActivityObjectType |
|
55 { |
|
56 SmfActivityObjTypeArticle, |
|
57 SmfActivityObjTypeAudio, |
|
58 SmfActivityObjTypeBookmark, |
|
59 SmfActivityObjTypeComment, |
|
60 SmfActivityObjTypeFile, |
|
61 SmfActivityObjTypeFolder, |
|
62 SmfActivityObjTypeGroup, |
|
63 SmfActivityObjTypeList, |
|
64 SmfActivityObjTypeNote, |
|
65 SmfActivityObjTypePerson, |
|
66 SmfActivityObjTypePhoto, |
|
67 SmfActivityObjTypePhotoAlbum, |
|
68 SmfActivityObjTypePlace, |
|
69 SmfActivityObjTypePlaylist, |
|
70 SmfActivityObjTypeProduct, |
|
71 SmfActivityObjTypeReview, |
|
72 SmfActivityObjTypeService, |
|
73 SmfActivityObjTypeStatus, |
|
74 SmfActivityObjTypeVideo, |
|
75 SmfActivityObjTypeMusic, |
|
76 SmfActivityObjTypeEvent, |
|
77 SmfActivityObjTypeAdvanced |
|
78 }; |
|
79 |
|
80 enum SmfActivityFor |
|
81 { |
|
82 SmfActivitySelf, |
|
83 SmfActivityFriend, |
|
84 SmfActivityOthers |
|
85 }; |
|
86 |
|
87 class SmfActivityObjectPrivate; |
|
88 /** |
|
89 * @ingroup smf_common_group |
|
90 * The object class represents an object in an activity (e.g.a picture or a music track on which somebody commented) |
|
91 */ |
|
92 class SMFCLIENT_EXPORT SmfActivityObject |
|
93 { |
|
94 public: |
|
95 /** |
|
96 * Constructor with default argument |
|
97 */ |
|
98 SmfActivityObject(); |
|
99 |
|
100 /** |
|
101 * Copy Constructor |
|
102 */ |
|
103 SmfActivityObject(const SmfActivityObject& aOther); |
|
104 |
|
105 /** |
|
106 * Destructor |
|
107 */ |
|
108 ~SmfActivityObject(); |
|
109 |
|
110 /** |
|
111 * retruns service specific Id of this object in the entry |
|
112 */ |
|
113 QString id() const; |
|
114 |
|
115 /** |
|
116 * returns thumbnail if availabel for this object in the entry |
|
117 */ |
|
118 QImage thumbnail() const; |
|
119 |
|
120 /** |
|
121 * Captions for this object |
|
122 */ |
|
123 QString caption() const; |
|
124 |
|
125 /** |
|
126 * retruns the type of this object |
|
127 */ |
|
128 SmfActivityObjectType type() const; |
|
129 |
|
130 /** |
|
131 * returns data of the object - see type() for casting |
|
132 */ |
|
133 QVariant objData() const; |
|
134 |
|
135 /** |
|
136 * url of this object, e.g. url of the image on which somebody commented |
|
137 */ |
|
138 QString link() const; |
|
139 |
|
140 /** |
|
141 * Time of creation of this object |
|
142 */ |
|
143 QDateTime time() const; |
|
144 |
|
145 /** |
|
146 * Description of the content of this object |
|
147 */ |
|
148 QString content() const; |
|
149 |
|
150 /** |
|
151 * sets service specific id for this object |
|
152 */ |
|
153 void setId(const QString& aId); |
|
154 |
|
155 /** |
|
156 * sets thumbnail for this object , not mandatory |
|
157 */ |
|
158 void setThumbnail(const QImage& aIcon); |
|
159 |
|
160 /** |
|
161 * sets caption for this object |
|
162 */ |
|
163 void setCaption(const QString& aCap); |
|
164 |
|
165 /** |
|
166 * sets type of this object - ObjData should be set next accordingly |
|
167 */ |
|
168 void setType(const SmfActivityObjectType& aObjType); |
|
169 |
|
170 /** |
|
171 * sets object data e,g, SmfImage, SmfComment, SmfMusic, SmfEvent etc |
|
172 * setType() with suitable type should have been called before |
|
173 */ |
|
174 void setObjData( const QVariant& aData); |
|
175 /** |
|
176 * sets the url for the object |
|
177 */ |
|
178 void setLink( const QString& aLink); |
|
179 /** |
|
180 * sets the time of creation/last modification of the object |
|
181 */ |
|
182 void setTime( const QDateTime& aTime); |
|
183 |
|
184 /** |
|
185 * sets the description of the content of this object |
|
186 */ |
|
187 void setContent( const QString& aText) ; |
|
188 |
|
189 private: |
|
190 QSharedDataPointer<SmfActivityObjectPrivate> d; |
|
191 |
|
192 friend QDataStream& operator >> ( QDataStream &aOut, const SmfActivityObject& aData); |
|
193 friend QDataStream& operator << ( QDataStream &aIn, const SmfActivityObject& aData); |
|
194 }; |
|
195 // Make the class SmfActivityObject known to QMetaType, so that as to register it. |
|
196 Q_DECLARE_METATYPE(SmfActivityObject) |
|
197 |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 class SmfActivityEntryPrivate; |
|
203 /** |
|
204 * @ingroup smf_common_group |
|
205 * The object class represents an entry in the list of activities |
|
206 */ |
|
207 class SMFCLIENT_EXPORT SmfActivityEntry |
|
208 { |
|
209 |
|
210 public: |
|
211 |
|
212 SmfActivityEntry(); |
|
213 SmfActivityEntry(const SmfActivityEntry& aOther); |
|
214 ~SmfActivityEntry(); |
|
215 |
|
216 /** |
|
217 * Returns service specific id of the of entry |
|
218 */ |
|
219 QString id() const; |
|
220 /** |
|
221 * returns the title of the entry - mostly be a string |
|
222 */ |
|
223 SmfPost title() const; |
|
224 |
|
225 /** |
|
226 * returns detail descriptiopn of this entry in the activity list. might be absent if title is sufficient |
|
227 */ |
|
228 SmfPost details() const; |
|
229 |
|
230 /** |
|
231 * returns the author of the activity - the name and the uri field are most commonly used |
|
232 * Other information fields might be empty |
|
233 */ |
|
234 SmfContact author() const; |
|
235 |
|
236 /** |
|
237 * returns the verb of the activity ,e.g. Robin "marked" Joseph as a friend |
|
238 */ |
|
239 SmfActivityVerb actionName() const; |
|
240 |
|
241 /** |
|
242 * There can be multiple objects in a single activity entry, though this may be rare - only for few verbs. |
|
243 * @return list of activity objects (mostly one object) |
|
244 */ |
|
245 QList<SmfActivityObject> activities() const; |
|
246 |
|
247 /** |
|
248 * returns information about the target of the activity, for verbs that support a target. |
|
249 * For example, a target is a photo album to which photos were added |
|
250 */ |
|
251 SmfActivityObject targetObj() const; |
|
252 |
|
253 /** |
|
254 * sets service specific id of the of entry |
|
255 */ |
|
256 bool setId( const QString& aId); |
|
257 |
|
258 /** |
|
259 * sets the title of the entry - mostly be a string |
|
260 */ |
|
261 bool setTitle(const SmfPost& aTitle); |
|
262 |
|
263 /** |
|
264 * sets detail descriptiopn of this entry in the activity list. might be absent if title is sufficient |
|
265 */ |
|
266 bool setDetails(const SmfPost& aDetails); |
|
267 |
|
268 /** |
|
269 * sets the author of the activity - the name and the uri field are most commonly used |
|
270 * Other information fields might be empty |
|
271 */ |
|
272 bool setAuthor(const SmfContact& aContact); |
|
273 |
|
274 /** |
|
275 * sets the verb of the activity ,e.g. Robin "marked" Joseph as a friend |
|
276 */ |
|
277 void setActionName(SmfActivityVerb aVerb); |
|
278 |
|
279 /** |
|
280 * sets single or multiple objects in a single activity entry, though multiple may be rare - only for few verbs. |
|
281 * @param list of activity objects (mostly one object) |
|
282 */ |
|
283 bool setActivities(QList<SmfActivityObject>& aList); |
|
284 |
|
285 /** |
|
286 * returns information about the target of the activity, for verbs that support a target. |
|
287 * For example, a target is a photo album to which photos were added |
|
288 */ |
|
289 bool setTargetObj(const SmfActivityObject& aTarget); |
|
290 |
|
291 private: |
|
292 QSharedDataPointer<SmfActivityEntryPrivate> d; |
|
293 |
|
294 friend QDataStream& operator >> ( QDataStream &aOut, const SmfActivityEntry& aData); |
|
295 friend QDataStream& operator << ( QDataStream &aIn, const SmfActivityEntry& aData); |
|
296 }; |
|
297 // Make the class SmfActivityEntry known to QMetaType, so that as to register it. |
|
298 Q_DECLARE_METATYPE(SmfActivityEntry) |
|
299 |
|
300 #endif /* SMFACTIONS_H_ */ |
|