18
|
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 |
* Contributors:
|
|
13 |
* Manasij Roy, Nalina Hariharan
|
|
14 |
*
|
|
15 |
* Description:
|
|
16 |
* Represents activities in terms similar to standard activity
|
|
17 |
* stream http://activitystrea.ms/
|
|
18 |
*
|
|
19 |
*/
|
|
20 |
|
|
21 |
#include "smfactions.h"
|
|
22 |
#include "smfactions_p.h"
|
|
23 |
|
|
24 |
|
|
25 |
/**
|
|
26 |
* Constructor
|
|
27 |
*/
|
|
28 |
SmfActivityObject::SmfActivityObject( )
|
|
29 |
{
|
|
30 |
d = new SmfActivityObjectPrivate;
|
|
31 |
}
|
|
32 |
|
|
33 |
/**
|
|
34 |
* Copy Constructor
|
|
35 |
* @param aOther The reference object
|
|
36 |
*/
|
|
37 |
SmfActivityObject::SmfActivityObject( const SmfActivityObject &aOther )
|
|
38 |
: d( aOther.d )
|
|
39 |
{
|
|
40 |
}
|
|
41 |
|
|
42 |
/**
|
|
43 |
* Overloaded = operator
|
|
44 |
* @param aOther The reference object
|
|
45 |
* @return The target reference value
|
|
46 |
*/
|
|
47 |
SmfActivityObject& SmfActivityObject::operator=( const SmfActivityObject &aOther )
|
|
48 |
{
|
|
49 |
d->m_id = aOther.d->m_id;
|
|
50 |
d->m_thumbnail = aOther.d->m_thumbnail;
|
|
51 |
d->m_caption = aOther.d->m_caption;
|
|
52 |
d->m_type = aOther.d->m_type;
|
|
53 |
d->m_objData = aOther.d->m_objData;
|
|
54 |
d->m_link = aOther.d->m_link;
|
|
55 |
d->m_time = aOther.d->m_time;
|
|
56 |
d->m_content = aOther.d->m_content;
|
|
57 |
return *this;
|
|
58 |
}
|
|
59 |
|
|
60 |
/**
|
|
61 |
* Destructor
|
|
62 |
*/
|
|
63 |
SmfActivityObject::~SmfActivityObject( )
|
|
64 |
{
|
|
65 |
}
|
|
66 |
|
|
67 |
|
|
68 |
/**
|
|
69 |
* @return returns service specific Id of this object in the entry
|
|
70 |
*/
|
|
71 |
QString SmfActivityObject::id( ) const
|
|
72 |
{
|
|
73 |
return d->m_id;
|
|
74 |
}
|
|
75 |
|
|
76 |
/**
|
|
77 |
* @return returns thumbnail if availabel for this object in the entry
|
|
78 |
*/
|
|
79 |
QImage SmfActivityObject::thumbnail( ) const
|
|
80 |
{
|
|
81 |
return d->m_thumbnail;
|
|
82 |
}
|
|
83 |
|
|
84 |
/**
|
|
85 |
* @return Captions for this object
|
|
86 |
*/
|
|
87 |
QString SmfActivityObject::caption( ) const
|
|
88 |
{
|
|
89 |
return d->m_caption;
|
|
90 |
}
|
|
91 |
|
|
92 |
/**
|
|
93 |
* @return retruns the type of this object
|
|
94 |
*/
|
|
95 |
SmfActivityObjectType SmfActivityObject::type( ) const
|
|
96 |
{
|
|
97 |
return d->m_type;
|
|
98 |
}
|
|
99 |
|
|
100 |
/**
|
|
101 |
* @return returns data of the object - see type() for casting
|
|
102 |
*/
|
|
103 |
QVariant SmfActivityObject::objData( ) const
|
|
104 |
{
|
|
105 |
return d->m_objData;
|
|
106 |
}
|
|
107 |
|
|
108 |
/**
|
|
109 |
* @return url of this object, e.g. url of the image on which somebody commented
|
|
110 |
*/
|
|
111 |
QString SmfActivityObject::link( ) const
|
|
112 |
{
|
|
113 |
return d->m_link;
|
|
114 |
}
|
|
115 |
|
|
116 |
/**
|
|
117 |
* @return Time of creation of this object
|
|
118 |
*/
|
|
119 |
QDateTime SmfActivityObject::time( ) const
|
|
120 |
{
|
|
121 |
return d->m_time;
|
|
122 |
}
|
|
123 |
|
|
124 |
/**
|
|
125 |
* @return Description of the content of this object
|
|
126 |
*/
|
|
127 |
QString SmfActivityObject::content( ) const
|
|
128 |
{
|
|
129 |
return d->m_content;
|
|
130 |
}
|
|
131 |
|
|
132 |
/**
|
|
133 |
* Sets service specific id for this object
|
|
134 |
* @param aId The id to be set
|
|
135 |
*/
|
|
136 |
void SmfActivityObject::setId(const QString& aId)
|
|
137 |
{
|
|
138 |
d->m_id = aId;
|
|
139 |
}
|
|
140 |
|
|
141 |
/**
|
|
142 |
* Sets thumbnail for this object , not mandatory
|
|
143 |
* @param aIcon The thumbnail image
|
|
144 |
*/
|
|
145 |
void SmfActivityObject::setThumbnail(const QImage& aIcon)
|
|
146 |
{
|
|
147 |
d->m_thumbnail = aIcon;
|
|
148 |
}
|
|
149 |
|
|
150 |
/**
|
|
151 |
* Sets caption for this object
|
|
152 |
* @param aCaption The caption to be set
|
|
153 |
*/
|
|
154 |
void SmfActivityObject::setCaption(const QString& aCap)
|
|
155 |
{
|
|
156 |
d->m_caption = aCap;
|
|
157 |
}
|
|
158 |
|
|
159 |
/**
|
|
160 |
* Sets type of this object - ObjData should be set next accordingly
|
|
161 |
* @param aObjType The activity type to be set
|
|
162 |
*/
|
|
163 |
void SmfActivityObject::setType(const SmfActivityObjectType& aObjType)
|
|
164 |
{
|
|
165 |
d->m_type = aObjType;
|
|
166 |
}
|
|
167 |
|
|
168 |
/**
|
|
169 |
* Sets object data e,g, SmfImage, SmfComment, SmfMusic, SmfEvent etc
|
|
170 |
* setType() with suitable type should have been called before
|
|
171 |
* @param aData The object data to be set
|
|
172 |
*/
|
|
173 |
void SmfActivityObject::setObjData( const QVariant& aData)
|
|
174 |
{
|
|
175 |
d->m_objData = aData;
|
|
176 |
}
|
|
177 |
|
|
178 |
/**
|
|
179 |
* Sets the url for the object
|
|
180 |
* @param aLink The Link to be set
|
|
181 |
*/
|
|
182 |
void SmfActivityObject::setLink( const QString& aLink)
|
|
183 |
{
|
|
184 |
d->m_link = aLink;
|
|
185 |
}
|
|
186 |
|
|
187 |
/**
|
|
188 |
* Sets the time of creation/last modification of the object
|
|
189 |
* @param aTime The time to be set
|
|
190 |
*/
|
|
191 |
void SmfActivityObject::setTime( const QDateTime& aTime)
|
|
192 |
{
|
|
193 |
d->m_time = aTime;
|
|
194 |
}
|
|
195 |
|
|
196 |
/**
|
|
197 |
* Sets the description of the content of this object
|
|
198 |
* @param aText The content to be set
|
|
199 |
*/
|
|
200 |
void SmfActivityObject::setContent( const QString& aText)
|
|
201 |
{
|
|
202 |
d->m_content = aText;
|
|
203 |
}
|
|
204 |
|
|
205 |
/**
|
|
206 |
* Method for Externalization. Writes the SmfActivityObject object to
|
|
207 |
* the stream and returns a reference to the stream.
|
|
208 |
* @param aDataStream Stream to be written
|
|
209 |
* @param aObj The SmfActivityObject object to be externalized
|
|
210 |
* @return reference to the written stream
|
|
211 |
*/
|
|
212 |
QDataStream &operator<<( QDataStream &aDataStream,
|
|
213 |
const SmfActivityObject &aObj )
|
|
214 |
{
|
|
215 |
aDataStream<<aObj.d->m_id;
|
|
216 |
aDataStream<<aObj.d->m_thumbnail;
|
|
217 |
aDataStream<<aObj.d->m_caption;
|
|
218 |
aDataStream<<aObj.d->m_type;
|
|
219 |
aDataStream<<aObj.d->m_objData;
|
|
220 |
aDataStream<<aObj.d->m_link;
|
|
221 |
aDataStream<<aObj.d->m_time;
|
|
222 |
aDataStream<<aObj.d->m_content;
|
|
223 |
|
|
224 |
return aDataStream;
|
|
225 |
}
|
|
226 |
|
|
227 |
/**
|
|
228 |
* Method for Internalization. Reads a SmfActivityObject object from
|
|
229 |
* the stream and returns a reference to the stream.
|
|
230 |
* @param aDataStream Stream to be read
|
|
231 |
* @param aObj The SmfActivityObject object to be internalized
|
|
232 |
* @return reference to the stream
|
|
233 |
*/
|
|
234 |
QDataStream &operator>>( QDataStream &aDataStream,
|
|
235 |
SmfActivityObject &aObj)
|
|
236 |
{
|
|
237 |
aDataStream>>aObj.d->m_id;
|
|
238 |
aDataStream>>aObj.d->m_thumbnail;
|
|
239 |
aDataStream>>aObj.d->m_caption;
|
|
240 |
int i;
|
|
241 |
aDataStream>>i;
|
|
242 |
aObj.d->m_type = (SmfActivityObjectType)i;
|
|
243 |
aDataStream>>aObj.d->m_objData;
|
|
244 |
aDataStream>>aObj.d->m_link;
|
|
245 |
aDataStream>>aObj.d->m_time;
|
|
246 |
aDataStream>>aObj.d->m_content;
|
|
247 |
|
|
248 |
return aDataStream;
|
|
249 |
}
|
|
250 |
|
|
251 |
|
|
252 |
|
|
253 |
SmfActivityEntry::SmfActivityEntry()
|
|
254 |
{
|
|
255 |
d = new SmfActivityEntryPrivate;
|
|
256 |
}
|
|
257 |
SmfActivityEntry::SmfActivityEntry( const SmfActivityEntry &aOther )
|
|
258 |
:d( aOther.d )
|
|
259 |
{
|
|
260 |
}
|
|
261 |
SmfActivityEntry::~SmfActivityEntry()
|
|
262 |
{
|
|
263 |
|
|
264 |
}
|
|
265 |
/**
|
|
266 |
* @return Returns service specific id of the of entry
|
|
267 |
*/
|
|
268 |
QString SmfActivityEntry::id() const
|
|
269 |
{
|
|
270 |
return d->m_id;
|
|
271 |
}
|
|
272 |
|
|
273 |
/**
|
|
274 |
* @return Returns the title of the entry - mostly be a string
|
|
275 |
*/
|
|
276 |
SmfPost SmfActivityEntry::title() const
|
|
277 |
{
|
|
278 |
return d->m_title;
|
|
279 |
}
|
|
280 |
|
|
281 |
/**
|
|
282 |
* @return Returns detail descriptiopn of this entry in the activity list. might be absent if title is sufficient
|
|
283 |
*/
|
|
284 |
SmfPost SmfActivityEntry::details() const
|
|
285 |
{
|
|
286 |
return d->m_details;
|
|
287 |
}
|
|
288 |
|
|
289 |
/**
|
|
290 |
* @return Returns the author of the activity - the name and the uri field are most commonly used
|
|
291 |
* Other information fields might be empty
|
|
292 |
*/
|
|
293 |
SmfContact SmfActivityEntry::author() const
|
|
294 |
{
|
|
295 |
return d->m_author;
|
|
296 |
}
|
|
297 |
|
|
298 |
/**
|
|
299 |
* @return Returns the verb of the activity ,e.g. Robin "marked" Joseph as a friend
|
|
300 |
*/
|
|
301 |
SmfActivityVerb SmfActivityEntry::actionName() const
|
|
302 |
{
|
|
303 |
return d->m_actionName;
|
|
304 |
}
|
|
305 |
|
|
306 |
/**
|
|
307 |
* There can be multiple objects in a single activity entry, though this may be rare - only for few verbs.
|
|
308 |
* @return list of activity objects (mostly one object)
|
|
309 |
*/
|
|
310 |
QList<SmfActivityObject> SmfActivityEntry::activities() const
|
|
311 |
{
|
|
312 |
return d->m_activities;
|
|
313 |
}
|
|
314 |
|
|
315 |
/**
|
|
316 |
* @return Returns information about the target of the activity, for verbs that support a target.
|
|
317 |
* For example, a target is a photo album to which photos were added
|
|
318 |
*/
|
|
319 |
SmfActivityObject SmfActivityEntry::targetObj() const
|
|
320 |
{
|
|
321 |
return d->m_targetObj;
|
|
322 |
}
|
|
323 |
|
|
324 |
/**
|
|
325 |
* Sets service specific id of the of entry
|
|
326 |
* @param aId The id to be set
|
|
327 |
*/
|
|
328 |
bool SmfActivityEntry::setId( const QString& aId)
|
|
329 |
{
|
|
330 |
d->m_id = aId;
|
|
331 |
return true;
|
|
332 |
}
|
|
333 |
|
|
334 |
/**
|
|
335 |
* Sets the title of the entry - mostly be a string
|
|
336 |
* @param aTitle The title to be set
|
|
337 |
*/
|
|
338 |
bool SmfActivityEntry::setTitle(const SmfPost& aTitle)
|
|
339 |
{
|
|
340 |
d->m_title = aTitle;
|
|
341 |
return true;
|
|
342 |
}
|
|
343 |
|
|
344 |
/**
|
|
345 |
* Sets detail description of this entry in the activity list. might be absent if title is sufficient
|
|
346 |
* @param aDetails The details to be set
|
|
347 |
*/
|
|
348 |
bool SmfActivityEntry::setDetails(const SmfPost& aDetails)
|
|
349 |
{
|
|
350 |
d->m_details = aDetails;
|
|
351 |
return true;
|
|
352 |
}
|
|
353 |
|
|
354 |
/**
|
|
355 |
* Sets the author of the activity - the name and the uri field are most commonly used
|
|
356 |
* Oher information fields might be empty
|
|
357 |
* @param aContact The author to be set
|
|
358 |
*/
|
|
359 |
bool SmfActivityEntry::setAuthor(const SmfContact& aContact)
|
|
360 |
{
|
|
361 |
d->m_author = aContact;
|
|
362 |
return true;
|
|
363 |
}
|
|
364 |
|
|
365 |
/**
|
|
366 |
* Sets the verb of the activity ,e.g. Robin "marked" Joseph as a friend
|
|
367 |
* @param aVerb The action name to be set
|
|
368 |
*/
|
|
369 |
void SmfActivityEntry::setActionName(SmfActivityVerb aVerb)
|
|
370 |
{
|
|
371 |
d->m_actionName = aVerb;
|
|
372 |
}
|
|
373 |
|
|
374 |
/**
|
|
375 |
* Sets single or multiple objects in a single activity entry, though multiple may be rare - only for few verbs.
|
|
376 |
* @param list of activity objects (mostly one object)
|
|
377 |
*/
|
|
378 |
bool SmfActivityEntry::setActivities(QList<SmfActivityObject>& aList)
|
|
379 |
{
|
|
380 |
d->m_activities = aList;
|
|
381 |
return true;
|
|
382 |
}
|
|
383 |
|
|
384 |
/**
|
|
385 |
* Returns information about the target of the activity, for verbs that support a target.
|
|
386 |
* For example, a target is a photo album to which photos were added
|
|
387 |
* @param aTarget The activity object to be set
|
|
388 |
*/
|
|
389 |
bool SmfActivityEntry::setTargetObj(const SmfActivityObject& aTarget)
|
|
390 |
{
|
|
391 |
d->m_targetObj = aTarget;
|
|
392 |
return true;
|
|
393 |
}
|
|
394 |
|
|
395 |
|
|
396 |
/**
|
|
397 |
* Method for Externalization. Writes the SmfActivityEntry object to
|
|
398 |
* the stream and returns a reference to the stream.
|
|
399 |
* @param aDataStream Stream to be written
|
|
400 |
* @param aObj The SmfActivityEntry object to be externalized
|
|
401 |
* @return reference to the written stream
|
|
402 |
*/
|
|
403 |
QDataStream &operator<<( QDataStream &aDataStream,
|
|
404 |
const SmfActivityEntry &aObj )
|
|
405 |
{
|
|
406 |
aDataStream<<aObj.d->m_id;
|
|
407 |
aDataStream<<aObj.d->m_title;
|
|
408 |
aDataStream<<aObj.d->m_details;
|
|
409 |
aDataStream<<aObj.d->m_author;
|
|
410 |
aDataStream<<aObj.d->m_actionName;
|
|
411 |
aDataStream<<aObj.d->m_activities;
|
|
412 |
aDataStream<<aObj.d->m_targetObj;
|
|
413 |
|
|
414 |
return aDataStream;
|
|
415 |
}
|
|
416 |
|
|
417 |
/**
|
|
418 |
* Method for Internalization. Reads a SmfActivityEntry object from
|
|
419 |
* the stream and returns a reference to the stream.
|
|
420 |
* @param aDataStream Stream to be read
|
|
421 |
* @param aObj The SmfActivityEntry object to be internalized
|
|
422 |
* @return reference to the stream
|
|
423 |
*/
|
|
424 |
QDataStream &operator>>( QDataStream &aDataStream,
|
|
425 |
SmfActivityEntry &aObj)
|
|
426 |
{
|
|
427 |
aDataStream>>aObj.d->m_id;
|
|
428 |
aDataStream>>aObj.d->m_title;
|
|
429 |
aDataStream>>aObj.d->m_details;
|
|
430 |
aDataStream>>aObj.d->m_author;
|
|
431 |
int i;
|
|
432 |
aDataStream>>i;
|
|
433 |
aObj.d->m_actionName = (SmfActivityVerb)i;
|
|
434 |
aDataStream>>aObj.d->m_activities;
|
|
435 |
aDataStream>>aObj.d->m_targetObj;
|
|
436 |
|
|
437 |
return aDataStream;
|
|
438 |
}
|
|
439 |
|
|
440 |
|