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