smf/smfservermodule/smfclient/smfpostprovider_p.h
changeset 18 013a02bf2bb0
child 25 a180113055cb
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  * Private implementation of SmfPostProvider
       
    17  *
       
    18  */
       
    19 
       
    20 #ifndef SMFPOSTPROVIDER_P_H_
       
    21 #define SMFPOSTPROVIDER_P_H_
       
    22 
       
    23 #include <QVector>
       
    24 #include <QTextFormat>
       
    25 #include <smfclientglobal.h>
       
    26 #include <smfglobal.h>
       
    27 #include <smfobserver.h>
       
    28 #include <smfpost.h>
       
    29 
       
    30 // Forward declaration
       
    31 class SmfProvider;
       
    32 class SmfContact;
       
    33 class SmfLocation;
       
    34 class SmfPostProvider;
       
    35 #ifdef Q_OS_SYMBIAN
       
    36 	class CSmfClientSymbian;
       
    37 #else
       
    38 	class SmfClientQt;
       
    39 #endif
       
    40 
       
    41 /**
       
    42  * Data size limits
       
    43  */
       
    44 /**
       
    45  * Single Post-1 MB
       
    46  */
       
    47 const int KSmfPostMaxSize = 1000000;
       
    48 
       
    49 
       
    50 /**
       
    51  * Private Qt wrapper
       
    52  * Provided to accomodate diff facilities in diff platforms.
       
    53  * Uses Symbian client-server for Symbian
       
    54  * QDbus for linux
       
    55  * QLocalserver for rest of the platforms
       
    56  * Note:- only symbian client-server impl is provided at the moment
       
    57  **/
       
    58 class SmfPostProviderPrivate: public smfObserver
       
    59 	{
       
    60 	Q_OBJECT
       
    61 
       
    62 public:
       
    63 	/**
       
    64 	 * Constructor
       
    65 	 */
       
    66 	SmfPostProviderPrivate(SmfPostProvider* postProvider=0);
       
    67 	
       
    68 	/**
       
    69 	 * Destructor
       
    70 	 */
       
    71 	~SmfPostProviderPrivate();
       
    72 	
       
    73 public:
       
    74 	/**
       
    75 	 * returns maximum no of chars (unicode) that service provider can post without truncation
       
    76 	 * negative value means no limit
       
    77 	 */
       
    78 	qint32 maxCharsInPost();
       
    79 	
       
    80 	/**
       
    81 	 * returns maximum no of items that can be returned in a single query to getPosts
       
    82 	 * negative value means feature not supported.
       
    83 	 */
       
    84 	qint32 maxItems();
       
    85 
       
    86 	/**
       
    87 	 * returns all the formatting of posts that this service provider supports.
       
    88 	 * May return 0 items to mean only QString is supported.
       
    89 	 */
       
    90 	QVector<QTextFormat> supportedFormats();
       
    91 	
       
    92 	/**
       
    93 	 * returns whether this SP supports Appearence @see SmfAppearenceInfo
       
    94 	 */
       
    95 	bool supportsAppearence();
       
    96 
       
    97 	/**
       
    98 	 * Gets the posts asynchronously. The signal postsAvailable()with SmfPostList is emitted
       
    99 	 * once the post lists are available
       
   100 	 * @param user user's contact in this SP, omit for self contact
       
   101 	 * @param pageNum Page number to download, SMF_FIRST_PAGE denotes fresh query.
       
   102      * @param perPage Item per page, default is SMF_ITEMS_PER_PAGE 
       
   103 	 * @see postsAvailable()
       
   104 	 */
       
   105 	void posts(SmfContact* user = 0,int pageNum=SMF_FIRST_PAGE,int perPage=SMF_ITEMS_PER_PAGE);
       
   106 	
       
   107 	/**
       
   108 	 * Updates a post to own area, the success of the post can be checked with signal
       
   109 	 * updatePostFinished() signal
       
   110 	 * @param postData data to be posted
       
   111 	 * @param location location data
       
   112 	 */
       
   113 	void post(SmfPost& postData,SmfLocation& location) ; 
       
   114 	
       
   115 	/**
       
   116 	 * Updates the last post to own area with new data, the success of the post can be checked with signal
       
   117 	 * updatePostFinished() signal
       
   118 	 * @param postData edited/new data to be posted
       
   119 	 * @param location location data
       
   120 	 */
       
   121 	void updatePost(SmfPost& postData); 
       
   122 	
       
   123 	/**
       
   124 	 * Updates a post to a particular Smf contact. the success of the post can be checked with signal
       
   125 	 * updatePostFinished() signal.
       
   126 	 * @param postData data to be posted
       
   127 	 * @param contact contact to which the post is to be directed
       
   128 	 * @param location location data
       
   129 	 */
       
   130 	void postDirected(SmfPost& postData,SmfContact& contact,SmfLocation* location=0);
       
   131 	
       
   132 	/**
       
   133 	 * Method to post a comment on a post.
       
   134 	 * @param aTarget Post on which comment has to be posted
       
   135 	 * @param aComment comment to be posted
       
   136 	 * @param aLocation location data
       
   137 	 */
       
   138 	void commentOnAPost( SmfPost &aTarget, SmfPost &aComment, SmfLocation *aLocation = NULL);
       
   139 	
       
   140 	/**
       
   141 	 * Posts appearance info of the user.e.g. appear offline, busy, do-not-disturb
       
   142 	 * @param appearence user appearance
       
   143 	 * @see SmfPresenceInfo
       
   144 	 * @return False on Failure/Not supported 
       
   145 	 */
       
   146 	bool postAppearence(SmfAppearenceInfo appearence, const QString &status); 
       
   147 	
       
   148 	/**
       
   149 	 * Share /a contact's post to user's friends and followers (e.g. retweet in twitter, share on facebook)
       
   150 	 * emits updatePostFinished() signal when done.
       
   151 	 * @param postData data to be posted
       
   152 	 * @param contact contact to which the post belonged
       
   153 	 * @param bool whether user changed items within the post
       
   154 	 */
       
   155 	void sharePost(SmfPost& postData,SmfContact& contact,bool edited);
       
   156 	
       
   157 	/**
       
   158 	 * Request for a custom operation.
       
   159 	 * @param operationId OperationId
       
   160 	 * @param customData Custom data to be sent
       
   161 	 * Note:-Interpretation of operationId and customData is upto the concerned
       
   162 	 * plugin and client application. service provider should provide some
       
   163 	 * serializing-deserializing utilities for these custom data
       
   164 	 */
       
   165 	void customRequest(const int& operationId,QByteArray* customData);
       
   166    
       
   167 public:	//From smfobserver 
       
   168 	/**
       
   169 	 * To notify availibility of asynchronous requests.
       
   170 	 * @param result Requested result, before using must check error param.
       
   171 	 * @param opcode Requested opcode, for which the result has arrived.
       
   172 	 * @param error Error
       
   173 	 */
       
   174 	void resultsAvailable(QByteArray result,SmfRequestTypeID opcode,SmfError error);
       
   175 
       
   176 private:
       
   177 	SmfPostProvider* m_postProvider;
       
   178 	QByteArray m_serializedDataToServer;	//serialized xtra info, order of serialization follows order of param
       
   179 	quint8 m_argFlag;
       
   180 #ifdef Q_OS_SYMBIAN
       
   181 	CSmfClientSymbian* m_SmfClientPrivate;
       
   182 	friend class CSmfClientSymbian;
       
   183 #else
       
   184 	SmfClientQt* m_SmfClientPrivate;
       
   185 	friend class SmfClientQt;
       
   186 #endif
       
   187 	};
       
   188 
       
   189 #endif /* SMFPOSTPROVIDER_P_H_ */