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 * The SmfEvent class represents an event |
|
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 "smfprovider.h" |
|
29 #include "smfcontact.h" |
|
30 #include "smfplace.h" |
|
31 |
|
32 class SmfProvider; //base-class for service provider |
|
33 class SmfContact; //class for Contact in a social network |
|
34 |
|
35 |
|
36 |
|
37 /** |
|
38 * class for information (text, image and url) contained in post in social network |
|
39 * This could be changed to contain html data |
|
40 * |
|
41 * For those service provider which supports only string format, @see supportedFormats() |
|
42 */ |
|
43 class SmfPost : public QTextDocument |
|
44 { |
|
45 Q_OBJECT |
|
46 |
|
47 public: |
|
48 SmfPost ( QObject * parent = 0 ); |
|
49 SmfPost ( const QString & text, QObject * parent = 0 ); |
|
50 |
|
51 private: |
|
52 QString* id; |
|
53 SmfProvider* provider; |
|
54 }; |
|
55 |
|
56 /** |
|
57 * Presence info of the user |
|
58 */ |
|
59 enum SmfAppearenceInfo |
|
60 { |
|
61 ENotSupported, |
|
62 EOnline, |
|
63 EOffline, |
|
64 EBusy, |
|
65 EDoNotDisturb, |
|
66 EAppearOffline, |
|
67 EOther |
|
68 }; |
|
69 |
|
70 //Post lists |
|
71 typedef QList<SmfPost> SmfPostList; |
|
72 |
|
73 /** |
|
74 * @ingroup smf_client_group |
|
75 * Interface to post scrap/tweet like info. |
|
76 * Note that branding information for the particular service implementation |
|
77 * is available from getProvider() API. See also: |
|
78 * SmfProvider::serviceName(), SmfProvider::serviceIcon(), SmfProvider::description() |
|
79 * |
|
80 * Interface name for SmfPostProvider is org.symbian.smf.client.contact.posts |
|
81 */ |
|
82 class SMFCLIENT_EXPORT SmfPostProvider : public QObject |
|
83 { |
|
84 Q_OBJECT |
|
85 |
|
86 public: |
|
87 /** |
|
88 * Constructs SmfPostProvider. |
|
89 * @param baseProvider The base provider info |
|
90 * Seeing as this is a plug-in implementation, these will realistically |
|
91 * be generated by SMF factory of some kind |
|
92 */ |
|
93 SmfPostProvider(SmfProvider* baseProvider); |
|
94 ~SmfPostProvider(); |
|
95 |
|
96 |
|
97 public: |
|
98 /** |
|
99 * returns maximum no of chars (unicode) that service provider can post without truncation |
|
100 * negative value means no limit |
|
101 */ |
|
102 qint32 maxCharsInPost() const; |
|
103 /** |
|
104 * returns maximum no of items that can be returned in a single query to getPosts |
|
105 * negative value means feature not supported. |
|
106 */ |
|
107 qint32 maxItems() const; |
|
108 |
|
109 /** |
|
110 * returns all the formatting of posts that this service provider supports. |
|
111 * May return 0 items to mean only QString is supported. |
|
112 */ |
|
113 QVector<QTextFormat> supportedFormats () const; |
|
114 |
|
115 /** |
|
116 * returns whether this SP supports Appearence @see SmfAppearenceInfo |
|
117 */ |
|
118 bool supportsAppearence () const; |
|
119 |
|
120 public slots: |
|
121 /** |
|
122 * Gets the posts asynchronously. The signal postsAvailable()with SmfPostList is emitted |
|
123 * once the post lists are available |
|
124 * @param user user's contact in this SP, omit for self contact |
|
125 * @param pageNum Page number to download, SMF_FIRST_PAGE denotes fresh query. |
|
126 * @param perPage Item per page, default is SMF_ITEMS_PER_PAGE |
|
127 * @see postsAvailable() |
|
128 */ |
|
129 void posts(SmfContact* user = 0,int pageNum=SMF_FIRST_PAGE,int perPage=SMF_ITEMS_PER_PAGE); |
|
130 |
|
131 /** |
|
132 * Updates a post to own area, the success of the post can be checked with signal |
|
133 * updatePostFinished() signal |
|
134 * @param postData data to be posted |
|
135 * @param location location data |
|
136 */ |
|
137 void post(SmfPost& postData,SmfPlace& location) ; |
|
138 /** |
|
139 * Updates the last post to own area with new data, the success of the post can be checked with signal |
|
140 * updatePostFinished() signal |
|
141 * @param postData edited/new data to be posted |
|
142 * @param location location data |
|
143 */ |
|
144 void updatePost(SmfPost& postData); |
|
145 |
|
146 /** |
|
147 * Updates a post to a particular Smf contact. the success of the post can be checked with signal |
|
148 * updatePostFinished() signal. |
|
149 * @param postData data to be posted |
|
150 * @param contact contact to which the post is to be directed |
|
151 * @param location location data |
|
152 */ |
|
153 void postDirected(SmfPost& postData,SmfContact& contact,SmfPlace* location=0); |
|
154 |
|
155 /** |
|
156 * Posts appearance info of the user.e.g. appear offline, busy, do-not-disturb |
|
157 * @param appearence user appearance |
|
158 * @see SmfPresenceInfo |
|
159 * @return False on Failure/Not supported |
|
160 */ |
|
161 bool postAppearence(SmfAppearenceInfo appearence); |
|
162 /** |
|
163 * Share /a contact's post to user's friends and followers (e.g. retweet in twitter, share on facebook) |
|
164 * emits updatePostFinished() signal when done. |
|
165 * @param postData data to be posted |
|
166 * @param contact contact to which the post belonged |
|
167 * @param bool whether user changed items within the post |
|
168 */ |
|
169 void sharePost(SmfPost& postData,SmfContact& contact,bool edited); |
|
170 |
|
171 //APIs to get/set base provider info (SmfProvider) |
|
172 |
|
173 /** |
|
174 * Gets the base provider info |
|
175 */ |
|
176 SmfProvider* getProvider() const; |
|
177 |
|
178 signals: |
|
179 |
|
180 /** |
|
181 * Emitted when a request to getPosts() is finished |
|
182 * Note if number of posts is large, then it can download the list page by page |
|
183 * In that case this signal is emitted multiple times. |
|
184 * @param list list of posts |
|
185 * @param error error string |
|
186 * @param resultPage Page number info |
|
187 */ |
|
188 void postsAvailable(SmfPostList* list, QString error, SmfResultPage resultPage); |
|
189 |
|
190 /** |
|
191 * Emitted when update post is finished. |
|
192 * @param success the success of the update |
|
193 */ |
|
194 void postFinished(bool success); |
|
195 |
|
196 private: |
|
197 SmfProvider* m_baseProvider; |
|
198 }; |
|
199 |
|
200 SMF_SERVICE_NAME(SmfPostProvider, "org.symbian.smf.client.contact.posts\0.2") |
|
201 #endif // SMFPOSTPROVIDER_H |
|