smf/smfservermodule/smfclient/smfpostprovider.cpp
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  * SmfPostProvider
       
    17  *
       
    18  */
       
    19 
       
    20 #include <QVector>
       
    21 #include <QTextFormat>
       
    22 
       
    23 #include "smfpostprovider.h"
       
    24 #include "smfpostprovider_p.h"
       
    25 
       
    26 /**
       
    27  * Constructs SmfPostProvider.
       
    28  * @param baseProvider The base provider info
       
    29  * Seeing as this is a plug-in implementation, these will realistically
       
    30  * be generated by SMF factory of some kind
       
    31  */
       
    32 SmfPostProvider::SmfPostProvider(SmfProvider* baseProvider)
       
    33 	{
       
    34 	  m_baseProvider = baseProvider;
       
    35 	  //creating private impl wrapper
       
    36 	  m_private = new SmfPostProviderPrivate(this);
       
    37 	}
       
    38 
       
    39 SmfPostProvider::~SmfPostProvider()
       
    40 	{
       
    41 	
       
    42 	}
       
    43 
       
    44 /**
       
    45  * returns maximum no of chars (unicode) that service provider can post without truncation
       
    46  * negative value means no limit
       
    47  */
       
    48 qint32 SmfPostProvider::maxCharsInPost() const
       
    49 	{ 
       
    50 	return m_private->maxCharsInPost();
       
    51 	}
       
    52 
       
    53 /**
       
    54  * returns maximum no of items that can be returned in a single query to getPosts
       
    55  * negative value means feature not supported.
       
    56  */
       
    57 qint32 SmfPostProvider::maxItems() const
       
    58 	{ 
       
    59 	return m_private->maxItems();
       
    60 	}
       
    61 
       
    62 /**
       
    63  * returns all the formatting of posts that this service provider supports.
       
    64  * May return 0 items to mean only QString is supported.
       
    65  */
       
    66 QVector<QTextFormat> SmfPostProvider::supportedFormats () const
       
    67 	{
       
    68 	return m_private->supportedFormats();
       
    69 	}
       
    70 
       
    71 /**
       
    72  * returns whether this SP supports Appearence @see SmfAppearenceInfo
       
    73  */
       
    74 bool SmfPostProvider::supportsAppearence () const
       
    75 	{ 
       
    76 	return m_private->supportsAppearence();
       
    77 	}
       
    78 
       
    79 /**
       
    80  * Gets the posts asynchronously. The signal postsAvailable()with SmfPostList is emitted
       
    81  * once the post lists are available
       
    82  * @param user user's contact in this SP, omit for self contact
       
    83  * @param pageNum Page number to download, SMF_FIRST_PAGE denotes fresh query.
       
    84  * @param perPage Item per page, default is SMF_ITEMS_PER_PAGE 
       
    85  * @see postsAvailable()
       
    86  */
       
    87 void SmfPostProvider::posts(SmfContact* user ,int pageNum,int perPage)
       
    88 	{ 
       
    89 	m_private->posts(user,pageNum,perPage);
       
    90 	}
       
    91 
       
    92 /**
       
    93  * Updates a post to own area, the success of the post can be checked with signal
       
    94  * updatePostFinished() signal
       
    95  * @param postData data to be posted
       
    96  * @param location location data
       
    97  */
       
    98 void SmfPostProvider::post(SmfPost& postData,SmfLocation& location) 
       
    99 	{
       
   100 	m_private->post(postData,location);
       
   101 	} 
       
   102 
       
   103 /**
       
   104  * Updates the last post to own area with new data, the success of the post can be checked with signal
       
   105  * updatePostFinished() signal
       
   106  * @param postData edited/new data to be posted
       
   107  * @param location location data
       
   108  */
       
   109 void SmfPostProvider::updatePost(SmfPost& postData)
       
   110 	{ 
       
   111 	m_private->updatePost(postData);
       
   112 	} 
       
   113 
       
   114 /**
       
   115  * Updates a post to a particular Smf contact. the success of the post can be checked with signal
       
   116  * updatePostFinished() signal.
       
   117  * @param postData data to be posted
       
   118  * @param contact contact to which the post is to be directed
       
   119  * @param location location data
       
   120  */
       
   121 void SmfPostProvider::postDirected(SmfPost& postData,SmfContact& contact,SmfLocation* location)
       
   122 	{ 
       
   123 	m_private->postDirected(postData,contact,location);
       
   124 	}
       
   125 
       
   126 /**
       
   127  * Method to post a comment on a post.
       
   128  * @param aTarget Post on which comment has to be posted
       
   129  * @param aComment comment to be posted
       
   130  * @param aLocation location data
       
   131  */
       
   132 void SmfPostProvider::commentOnAPost( SmfPost &aTarget, SmfPost &aComment, 
       
   133 		SmfLocation *aLocation)
       
   134 	{
       
   135 	m_private->commentOnAPost(aTarget,aComment,aLocation);
       
   136 	}
       
   137 
       
   138 /**
       
   139  * Posts appearance info of the user.e.g. appear offline, busy, do-not-disturb
       
   140  * @param appearence user appearance
       
   141  * @see SmfPresenceInfo
       
   142  * @return False on Failure/Not supported 
       
   143  */
       
   144 bool SmfPostProvider::postAppearence(SmfAppearenceInfo appearence, const QString &status)
       
   145 	{ 
       
   146 	return m_private->postAppearence(appearence, status);
       
   147 	} 
       
   148 
       
   149 /**
       
   150  * Share /a contact's post to user's friends and followers (e.g. retweet in twitter, share on facebook)
       
   151  * emits updatePostFinished() signal when done.
       
   152  * @param postData data to be posted
       
   153  * @param contact contact to which the post belonged
       
   154  * @param bool whether user changed items within the post
       
   155  */
       
   156 void SmfPostProvider::sharePost(SmfPost& postData,SmfContact& contact,bool edited)
       
   157 	{
       
   158 	m_private->sharePost(postData,contact,edited);
       
   159 	}
       
   160 
       
   161 void SmfPostProvider::customRequest(const int& operationId,QByteArray* customData)
       
   162 	{
       
   163 	m_private->customRequest(operationId, customData);
       
   164 	}
       
   165 
       
   166 /**
       
   167  * Gets the base provider info
       
   168  */
       
   169 SmfProvider* SmfPostProvider::getProvider() const
       
   170 	{
       
   171 	return m_baseProvider;
       
   172 	}
       
   173