|
1 /* |
|
2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "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 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Interface for WV IM services. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef IMPS_IM_CLIENT_H |
|
21 #define IMPS_IM_CLIENT_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <badesca.h> |
|
26 #include <bamdesca.h> |
|
27 #include "impsconst.h" |
|
28 #include "impsclient.h" |
|
29 |
|
30 // CONSTANTS |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class MImpsImHandler2; |
|
34 class MImpsBlockingHandler2; |
|
35 class CImpsImCommand2; |
|
36 |
|
37 // CLASS DECLARATION |
|
38 |
|
39 /** |
|
40 * RImpsImClient2 API |
|
41 * |
|
42 * Applications use IM service via RImpsImClient2 class. First, they need to |
|
43 * connect to the server by calling RegisterL() member function. |
|
44 * Immediately after that an error handler must be registered by |
|
45 * RegisterErrorObserverL. |
|
46 * |
|
47 * When everything is done, call Unregister() to end |
|
48 * the session. |
|
49 * |
|
50 * A user of this API must be aware that raising/releasing |
|
51 * the PDP context may affect the response times of called functions. |
|
52 * |
|
53 * |
|
54 * Observer methods: |
|
55 * ----------------------- |
|
56 * Client can be notified when a certain type of message is received |
|
57 * from the remote server. |
|
58 * Client has to be connected in the server in order to get notify events. |
|
59 * If the client is disconnected by server by calling Unregister(), all notify |
|
60 * requests and possible incoming events are canceled. |
|
61 * |
|
62 * Notify events are session-specific, ie. if you have several RImpsImClients |
|
63 * connected to the server, each has its own notify requests. |
|
64 * |
|
65 * In order to use notify services, you need to implement MImpsImHandler2 |
|
66 * and give a pointer to your class in RegisterL. |
|
67 * Observer method doesn't need to do anything else than your application |
|
68 * needs it to do. |
|
69 * |
|
70 * |
|
71 * Addressing: |
|
72 * ----------- |
|
73 * WV CSP specification defines characters that must be escaped if they |
|
74 * occur within the User-ID, Resource or Domain portions of a Wireless Village |
|
75 * address. WV engine does NOT escape those characters on behalf of user |
|
76 * application. WV CSP also denies usage of certain characters in UserID |
|
77 * totally. |
|
78 * |
|
79 */ |
|
80 |
|
81 |
|
82 // CLASS DECLARATION |
|
83 |
|
84 |
|
85 class RImpsImClient2 : public RImpsClient2 |
|
86 { |
|
87 |
|
88 public: // Constructors and destructor |
|
89 |
|
90 /** |
|
91 * C++ default constructor. |
|
92 */ |
|
93 IMPORT_C RImpsImClient2(); |
|
94 |
|
95 public: // New functions |
|
96 |
|
97 // INITILIZATION AND CONNECT |
|
98 |
|
99 /** |
|
100 * Registers the listener object for IM events and connects to |
|
101 * the Symbian OS Server. |
|
102 * Leaves with KImpsErrorAlreadyInUse if the client |
|
103 * has already registered. |
|
104 * @param aEngine WV Engine server instance |
|
105 * @param aObserver new message observer. May be NULL. |
|
106 * @param aBlockingHandler block feature observer. May be NULL. |
|
107 * @param aClientId Client-Id. If non zero length then new messages |
|
108 * having this Client-Id only are delivered |
|
109 * when aReceiveNew is ETrue. |
|
110 * @param aReceiveNew determines if new pushed messages are received. |
|
111 * If EFalse then new messages are filtered out and |
|
112 * responses to own requests are deliverd only. |
|
113 * @param aPriority observer priority. Refer to CActive priority. |
|
114 */ |
|
115 IMPORT_C void RegisterL( RImpsEng& aEngine, |
|
116 MImpsImHandler2* aImpsObserver, |
|
117 MImpsBlockingHandler2* aBlockingHandler, |
|
118 const TDesC& aClientId, |
|
119 TBool aReceiveNew = ETrue, |
|
120 TInt aPriority = CActive::EPriorityStandard ); |
|
121 |
|
122 /** |
|
123 * Unregisters listener objects and disconnects from the Symbian server. |
|
124 */ |
|
125 IMPORT_C void Unregister(); |
|
126 |
|
127 |
|
128 // MESSAGING |
|
129 |
|
130 |
|
131 /** |
|
132 * Send a text message. |
|
133 * MImpsImHandler2 handles the server response. |
|
134 * Leaves if out of memory before sending a message to the SOS server. |
|
135 * If sender information is not given then WV engine inserts user's |
|
136 * UserId as a sender. |
|
137 * Recipient must be specified, i.e. at least aUserIds or aGroupId |
|
138 * must be specified. |
|
139 * Errors are handled by MImpsErrorHandler2. |
|
140 * @param aSenderSn, sender's screen name. Optional. |
|
141 * @param aUserIds recipients UserID, optional |
|
142 * @param aGroupId, optional. |
|
143 * 1) Group recipient as such or |
|
144 * 2) GroupID for aScreenNames. |
|
145 * GroupID is used as Recipient( Group ( GroupID ) ) only if |
|
146 * aScreenNames is omitted. |
|
147 * @param aScreenNames recipients' screen names in the group, optional |
|
148 * Recipient(Group*(ScreenName( SName))) |
|
149 * @param aContent UNICODE text/plain content |
|
150 * @param aDeliveryReportWanted True, if the user wats to |
|
151 * order delivery report. HandleDeliveryReportL from |
|
152 * MImpsImHandler handles the arriving report. |
|
153 * @return operation-id |
|
154 */ |
|
155 IMPORT_C TInt SendTextMessageL( const TDesC* aSenderSn, |
|
156 const MDesCArray* aUserIds, |
|
157 const TDesC* aGroupId, |
|
158 const MDesCArray* aScreenNames, |
|
159 const TDesC& aContent, |
|
160 TBool aDeliveryReportWanted ); |
|
161 |
|
162 /** |
|
163 * Send a message with binary content. |
|
164 * MImpsImHandler2 handles the server response. |
|
165 * Leaves if out of memory before sending a message to the SOS server. |
|
166 * Leaves with KErrNotSupported if the content type is not supported. |
|
167 * If sender information is not given then WV engine inserts user's |
|
168 * UserId as a sender. |
|
169 * Recipient must be specified, i.e. at least aUserIds or aGroupId |
|
170 * must be specified. |
|
171 * Errors are handled by MImpsErrorHandler2. |
|
172 * @param aSenderSn, sender's screen name. Optional. |
|
173 * @param aUserIds recipients UserID, optional |
|
174 * @param aGroupId, optional. |
|
175 * 1) Group recipient as such or |
|
176 * 2) GroupID for aScreenNames. |
|
177 * GroupID is used as Recipient( Group ( GroupID ) ) only if |
|
178 * aScreenNames is omitted. |
|
179 * @param aScreenNames recipients' screen names in the group, optional |
|
180 * Recipient(Group*(ScreenName( SName))) |
|
181 * @param aContentType MIME type of the content |
|
182 * @param aContent The content of the message |
|
183 * @param aDeliveryReportWanted True, if the user wats to |
|
184 * order delivery report. HandleDeliveryReportL from |
|
185 * MImpsImHandler2 handles the arriving report. |
|
186 * @return operation-id |
|
187 */ |
|
188 IMPORT_C TInt SendContentMessageL( const TDesC* aSenderSn, |
|
189 const MDesCArray* aUserIds, |
|
190 const TDesC* aGroupId, |
|
191 const MDesCArray* aScreenNames, |
|
192 const TDesC& aContentType, |
|
193 const TDesC8& aContent, |
|
194 TBool aDeliveryReportWanted ); |
|
195 |
|
196 /** |
|
197 * Block, UnBlock, Grant, UnGrant users based on UserID |
|
198 * MImpsBlockHandler2 handles successful server response. |
|
199 * Errors are handled by MImpsErrorHandler2 |
|
200 * @param aBlockEntity entities to be blocked |
|
201 * @param aUnBlockEntity entities to be unblocked |
|
202 * @param aBlockedListInUse is blocked list in use or not |
|
203 * @param aGrantedEntityList entities to be granted |
|
204 * @param aUnGrantEntity entities to be ungranted |
|
205 * @param aGrantedListInUse is granted list in use or not |
|
206 * @return operation-id |
|
207 */ |
|
208 IMPORT_C TInt BlockEntityRequestL( const MDesCArray* aBlockEntity, |
|
209 const MDesCArray* aUnBlockEntity, |
|
210 TBool aBlockedListInUse, |
|
211 const MDesCArray* aGrantedEntityList, |
|
212 const MDesCArray* aUnGrantEntity, |
|
213 TBool aGrantedListInUse ); |
|
214 |
|
215 /** |
|
216 * Get Blocked and granted users list from server |
|
217 * Supports only UserIDs in response. |
|
218 * MImpsBlockHandler2 handles successful server response. |
|
219 * Errors are handled by MImpsErrorHandler2 |
|
220 * @return operation-id |
|
221 */ |
|
222 IMPORT_C TInt GetBlockedListRequestL(); |
|
223 |
|
224 /** |
|
225 * Pointer to the observer handler |
|
226 * @return handler |
|
227 */ |
|
228 MImpsImHandler2* Handler(); |
|
229 |
|
230 /** |
|
231 * Pointer to the block observer handler |
|
232 * @return handler |
|
233 */ |
|
234 MImpsBlockingHandler2* BlockHandler(); |
|
235 |
|
236 private: // New functions |
|
237 |
|
238 /** |
|
239 * Registers the listener object for Access events and connects to |
|
240 * the Symbian OS Server. |
|
241 * @param aEngine WV Engine server instance |
|
242 * @param aHandler the observer |
|
243 * @return general error code |
|
244 */ |
|
245 TInt DoRegister( |
|
246 RImpsEng& aEngine, |
|
247 CImpsHandler2* aHandler ); |
|
248 |
|
249 |
|
250 private: // data |
|
251 |
|
252 MImpsImHandler2* iImHandlerCallback; |
|
253 MImpsBlockingHandler2* iBlockingHandlerCallback; |
|
254 CImpsImCommand2* iCommand; |
|
255 TPtrC8 iMessagePtr; |
|
256 |
|
257 private: // friend classes |
|
258 |
|
259 friend class CImpsImCommand; |
|
260 }; |
|
261 |
|
262 // CLASS DECLARATION |
|
263 |
|
264 /** |
|
265 * MImpsImHandler2 |
|
266 * |
|
267 * Abstract interface for handling the notify events from the server. |
|
268 * User derives his class from this and implements the methods below. |
|
269 */ |
|
270 |
|
271 class MImpsImHandler2 |
|
272 { |
|
273 |
|
274 public: // New functions |
|
275 |
|
276 /** |
|
277 * Observer method for incoming instant message |
|
278 * @param aOpId operation id map response to the |
|
279 * GetMessageFromServerL request. |
|
280 * For new "pushed" messages this is 0. |
|
281 * Operation code may be 0 if the event is no consequence of |
|
282 * the request from this session. (e.g. GetMessage) |
|
283 * @param aMessageId message-id |
|
284 * @param aSender message sender, UserID or ScreenName if aGroupId |
|
285 * @param aGroupId GroupID for ScreenName in aSender, may be zero length. |
|
286 * If aRecipients and aScreenNames are empty then this specifies |
|
287 * message recipient too. |
|
288 * @param aRecipients recipients, UserIDs |
|
289 * @param aScreenNames screen name recipients, |
|
290 * Recipient(Group(ScreenName, SName )) |
|
291 * The groups for screen names are in aSnGroups. |
|
292 * @param aText message text in UNICODE format. |
|
293 * @param aCspId CSP session identifier |
|
294 */ |
|
295 virtual void HandleNewTextMessageL( TInt aOpId, |
|
296 const TDesC& aMessageId, |
|
297 const TDesC& aSender, |
|
298 const TDesC& aGroupId, |
|
299 const MDesCArray& aRecipients, |
|
300 const MDesCArray& aScreenNames, |
|
301 const TDesC& aText, |
|
302 TImpsCspIdentifier& aCspId ) = 0; |
|
303 |
|
304 /** |
|
305 * Observer method for incoming content message |
|
306 * @param aOpId operation id map response to the |
|
307 * GetMessageFromServerL request. |
|
308 * For new "pushed" messages this is 0. |
|
309 * Operation code may be 0 if the event is no consequence of |
|
310 * the request from this session. (e.g. GetMessage) |
|
311 * @param aMessageId message-id |
|
312 * @param aSender message sender, UserID or ScreenName if aGroupId |
|
313 * @param aGroupId GroupID for ScreenName in aSender, may be zero length. |
|
314 * If aRecipients and aScreenNames are empty then this specifies |
|
315 * message recipient too. |
|
316 * @param aRecipients recipients, UserIDs |
|
317 * @param aScreenNames screen name recipients, |
|
318 * Recipient(Group(ScreenName, SName )) |
|
319 * The groups for screen names are in aSnGroups. |
|
320 * @param aContentType MIME type of the content |
|
321 * @param aContent The content of the message |
|
322 * @param aCspId CSP session identifier |
|
323 */ |
|
324 virtual void HandleNewContentMessageL( TInt aOpId, |
|
325 const TDesC& aMessageId, |
|
326 const TDesC& aSender, |
|
327 const TDesC& aGroupId, |
|
328 const MDesCArray& aRecipients, |
|
329 const MDesCArray& aScreenNames, |
|
330 const TDesC& aContentType, |
|
331 const TDesC8& aContent, |
|
332 TImpsCspIdentifier& aCspId ) = 0; |
|
333 |
|
334 /** |
|
335 * Observer for message send completion. |
|
336 * This means that SAP has confirmed the send transaction. |
|
337 * Common for all kind of messages. |
|
338 * @param aOpId operation id to map responses to the requests. |
|
339 * @param aDeliveryReportOrdered ETrue if delivery report wanted. |
|
340 * @param aCspId CSP session identifier |
|
341 */ |
|
342 virtual void HandleSendCompleteL( TInt aOpId, |
|
343 TBool aDeliveryReportOrdered, |
|
344 TImpsCspIdentifier& aCspId ) = 0; |
|
345 |
|
346 |
|
347 /** |
|
348 * Observer for delivery report request. |
|
349 * This means that SAP has delivered the message to all recipients. |
|
350 * @param aMessageId MessageID from message that has been delivered. |
|
351 * @param aResult result code |
|
352 * @param aDescripton result description or NULL |
|
353 * @param aCspId CSP session identifier |
|
354 */ |
|
355 virtual void HandleDeliveryReportL( const TDesC& aMessageId, |
|
356 TInt aResult, |
|
357 const TDesC* aDescription, |
|
358 TImpsCspIdentifier& aCspId ) = 0; |
|
359 |
|
360 }; |
|
361 |
|
362 //Handler |
|
363 class MImpsBlockingHandler2 |
|
364 { |
|
365 public: |
|
366 |
|
367 /** |
|
368 * Handler for GetBlockedListRequestL reponse |
|
369 * @param aBlockedList list of blocked users identified by UserID |
|
370 * @param aBlockedListInUse is blocked list use or not |
|
371 * @param aGrantedList list of granted users identified by UserID |
|
372 * @param aGranedListInUse is granted list use or not |
|
373 * @param aCspId CSP session identifier |
|
374 */ |
|
375 virtual void GetBlockedListResponseL( const MDesCArray* aBlockedList, |
|
376 TBool aBlockedListInUse, |
|
377 const MDesCArray* aGrantedList, |
|
378 TBool aGrantedListInUse, |
|
379 TImpsCspIdentifier& aCspId ) = 0; |
|
380 |
|
381 |
|
382 /** |
|
383 * Handler for BlockEntityRequestL response |
|
384 * @param aOpId operation id to map responses to the requests. |
|
385 * @param aCspId CSP session identifier |
|
386 */ |
|
387 virtual void HandleCompleteL( TInt aOpId, |
|
388 TImpsCspIdentifier& aCspId ) = 0; |
|
389 }; |
|
390 |
|
391 |
|
392 #endif |