smf/smfservermodule/smfclient/client/smfpostprovider.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  * SmfPostProvider
       
    17  *
       
    18  */
       
    19 #ifndef SMFPOSTPROVIDER_H
       
    20 #define SMFPOSTPROVIDER_H
       
    21 
       
    22 #include <QObject>
       
    23 #include <qmobilityglobal.h>
       
    24 #include <qgeopositioninfo.h>
       
    25 #include <QTextDocument>
       
    26 
       
    27 #include "smfglobal.h"
       
    28 #include "smfclientglobal.h"
       
    29 #include "smfprovider.h"
       
    30 #include "smfcontact.h"
       
    31 #include "smflocation.h"
       
    32 #include "smfpost.h"
       
    33 #include "smfpostprovider_p.h"
       
    34 
       
    35 /**
       
    36  * @ingroup smf_client_group 
       
    37  * Interface to post scrap/tweet like info.
       
    38  * Note that branding information for the particular service implementation
       
    39  * is available from getProvider() API. See also:
       
    40  * SmfProvider::serviceName(), SmfProvider::serviceIcon(), SmfProvider::description()
       
    41  *
       
    42  * Interface name for SmfPostProvider is org.symbian.smf.client.contact.posts
       
    43  */
       
    44 class SMFCLIENT_EXPORT SmfPostProvider : public QObject
       
    45 	{
       
    46 	Q_OBJECT
       
    47 
       
    48 public:
       
    49 	/**
       
    50 	 * Constructs SmfPostProvider.
       
    51 	 * @param baseProvider The base provider info
       
    52 	 * Seeing as this is a plug-in implementation, these will realistically
       
    53 	 * be generated by SMF factory of some kind
       
    54 	 */
       
    55 	SmfPostProvider(SmfProvider* baseProvider);
       
    56 	~SmfPostProvider();
       
    57 
       
    58 
       
    59 public:
       
    60 	/**
       
    61 	 * returns maximum no of chars (unicode) that service provider can post without truncation
       
    62 	 * negative value means no limit
       
    63 	 */
       
    64 	qint32 maxCharsInPost() const;
       
    65 	/**
       
    66 	 * returns maximum no of items that can be returned in a single query to getPosts
       
    67 	 * negative value means feature not supported.
       
    68 	 */
       
    69 	qint32 maxItems() const;
       
    70 
       
    71 	/**
       
    72 	 * returns all the formatting of posts that this service provider supports.
       
    73 	 * May return 0 items to mean only QString is supported.
       
    74 	 */
       
    75 	QVector<QTextFormat> supportedFormats () const;
       
    76 	
       
    77 	/**
       
    78 	 * returns whether this SP supports Appearence @see SmfAppearenceInfo
       
    79 	 */
       
    80 	bool supportsAppearence () const;
       
    81 
       
    82 public slots:
       
    83 	/**
       
    84 	 * Gets the posts asynchronously. The signal postsAvailable()with SmfPostList is emitted
       
    85 	 * once the post lists are available
       
    86 	 * @param user user's contact in this SP, omit for self contact
       
    87 	 * @param pageNum Page number to download, SMF_FIRST_PAGE denotes fresh query.
       
    88      * @param perPage Item per page, default is SMF_ITEMS_PER_PAGE 
       
    89 	 * @see postsAvailable()
       
    90 	 */
       
    91 	void posts(SmfContact* user = 0,int pageNum=SMF_FIRST_PAGE,int perPage=SMF_ITEMS_PER_PAGE);
       
    92 	
       
    93 	/**
       
    94 	 * Updates a post to own area, the success of the post can be checked with signal
       
    95 	 * updatePostFinished() signal
       
    96 	 * @param postData data to be posted
       
    97 	 * @param location location data
       
    98 	 */
       
    99 	void post(SmfPost& postData,SmfLocation& location) ; 
       
   100 	/**
       
   101 	 * Updates the last post to own area with new data, the success of the post can be checked with signal
       
   102 	 * updatePostFinished() signal
       
   103 	 * @param postData edited/new data to be posted
       
   104 	 * @param location location data
       
   105 	 */
       
   106 	void updatePost(SmfPost& postData); 
       
   107 	
       
   108 	/**
       
   109 	 * Updates a post to a particular Smf contact. the success of the post can be checked with signal
       
   110 	 * updatePostFinished() signal.
       
   111 	 * @param postData data to be posted
       
   112 	 * @param contact contact to which the post is to be directed
       
   113 	 * @param location location data
       
   114 	 */
       
   115 	void postDirected(SmfPost& postData,SmfContact& contact,SmfLocation* location=0);
       
   116 	
       
   117 	/**
       
   118 	 * Posts appearance info of the user.e.g. appear offline, busy, do-not-disturb
       
   119 	 * @param appearence user appearance
       
   120 	 * @see SmfPresenceInfo
       
   121 	 * @return False on Failure/Not supported 
       
   122 	 */
       
   123 	bool postAppearence(SmfAppearenceInfo appearence); 
       
   124 	/**
       
   125 	 * Share /a contact's post to user's friends and followers (e.g. retweet in twitter, share on facebook)
       
   126 	 * emits updatePostFinished() signal when done.
       
   127 	 * @param postData data to be posted
       
   128 	 * @param contact contact to which the post belonged
       
   129 	 * @param bool whether user changed items within the post
       
   130 	 */
       
   131 	void sharePost(SmfPost& postData,SmfContact& contact,bool edited);
       
   132    /**
       
   133 	* Request for a custom operation.
       
   134 	* @param operationId OperationId
       
   135 	* @param customData Custom data to be sent
       
   136 	* Note:-Interpretation of operationId and customData is upto the concerned
       
   137 	* plugin and client application. service provider should provide some
       
   138 	* serializing-deserializing utilities for these custom data
       
   139 	*/
       
   140    void customRequest(const int& operationId,QByteArray* customData){/*to be implemented*/};
       
   141 	//APIs to get/set base provider info (SmfProvider)
       
   142 	
       
   143 	/**
       
   144 	 * Gets the base provider info
       
   145 	 */
       
   146 	SmfProvider* getProvider() const;
       
   147 	
       
   148 signals:
       
   149 	
       
   150 	/**
       
   151 	 * Emitted when a request to  getPosts() is finished
       
   152 	 * Note if number of posts is large, then it can download the list page by page
       
   153 	 * In that case this signal is emitted multiple times.
       
   154 	 * @param list list of posts
       
   155 	 * @param error error string
       
   156 	 * @param resultPage Page number info
       
   157 	 */
       
   158 	void postsAvailable(SmfPostList* list, SmfError error, SmfResultPage resultPage);
       
   159 	
       
   160 	/**
       
   161 	 * Emitted when update post is finished.
       
   162 	 * @param success the success of the update
       
   163 	 */
       
   164 	void postFinished(SmfError success);
       
   165 	/**
       
   166 	 * Emitted when custom data is available
       
   167 	 * @param operationId Requested operation id
       
   168 	 * @param customData Custom data received, interpretation is not the responsibility of Smf
       
   169 	 */
       
   170 	void customDataAvailable(int operationId, QByteArray* customData);
       
   171 	//friend so that it can directly emit SmfPostProvider's signal
       
   172 	friend class SmfPostProviderPrivate;
       
   173 private:
       
   174 	SmfProvider* m_baseProvider;
       
   175 	//private impl wrapper
       
   176 	SmfPostProviderPrivate* m_private;
       
   177 };
       
   178 
       
   179 SMF_SERVICE_NAME(SmfPostProvider, "org.symbian.smf.client.contact.posts\0.2")
       
   180 #endif // SMFPOSTPROVIDER_H