|
1 /* |
|
2 * Copyright (c) 2007 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 the License "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: Defination of class CMessagingInterface |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __MESSAGINGINTERFACE_H |
|
20 #define __MESSAGINGINTERFACE_H |
|
21 |
|
22 #include <LiwCommon.h> |
|
23 #include <LiwServiceIfBase.h> |
|
24 #include <LiwBufferExtension.h> |
|
25 |
|
26 #include "messageheader.h" |
|
27 |
|
28 class CMessagingService; |
|
29 class TInputValidator; |
|
30 /** |
|
31 * This class provides the Messaging SAPI interface to LIW Framework |
|
32 */ |
|
33 class CMessagingInterface : public CBase, public MLiwInterface |
|
34 { |
|
35 public: |
|
36 |
|
37 /** |
|
38 * Two-phased constructor. |
|
39 * @return CMessagingInterface* |
|
40 */ |
|
41 static CMessagingInterface* NewL(); |
|
42 |
|
43 /** |
|
44 * Destructor. |
|
45 */ |
|
46 virtual ~CMessagingInterface(); |
|
47 |
|
48 private: |
|
49 |
|
50 /** |
|
51 * Constructor |
|
52 */ |
|
53 CMessagingInterface(); |
|
54 |
|
55 /** |
|
56 * Symbian Constructor |
|
57 */ |
|
58 void ConstructL(); |
|
59 |
|
60 /* |
|
61 * Function which checks the type of the source and leaves upon |
|
62 * setting the error message accordingly if the aLeaveFlag is set and |
|
63 * returns ETrue in case of success, EFalse in case of failure and not leaving |
|
64 * |
|
65 * @param aSource |
|
66 * @param aLeaveFlag |
|
67 * @param aExpectedType |
|
68 * @param aCmdName Command Name |
|
69 * @param aParameter Parameter Name |
|
70 * @param aMessage Error message |
|
71 * |
|
72 * @return TBool |
|
73 */ |
|
74 TBool CMessagingInterface::CheckInputTypeL( const TLiwVariant* aSource, |
|
75 TBool aLeaveFlag, |
|
76 LIW::TVariantTypeId aExpectedtype, |
|
77 const TDesC8& aCmdName, |
|
78 const TDesC8& aParameter, |
|
79 const TDesC& aMessage ); |
|
80 |
|
81 |
|
82 /** |
|
83 * Appends error message |
|
84 * @param aCmdName Command Name |
|
85 * @param aParameter Parameter Name |
|
86 * @param aMessage Error message |
|
87 * @param aMissingOrIncorrectOrNone 0 for none or 1 for missing or 2 for incorrect |
|
88 * For missing it leave with errorcode SErrMissingArgument |
|
89 * For incorrect it leaves with errorcode KErrArgument |
|
90 * For none it wont leave |
|
91 * |
|
92 * @return void |
|
93 */ |
|
94 void AppendErrorMessageL( const TDesC8& aCmdName, |
|
95 const TDesC8& aParameter, |
|
96 const TDesC& aMessage, |
|
97 TInt aNoneOrMissingOrIncorrect ); |
|
98 |
|
99 |
|
100 /** |
|
101 * Function called from sync APIs to check whether Async set up is done |
|
102 * if yes then leaves |
|
103 * |
|
104 * @param aCmdOptions Command option |
|
105 * @param aCallback Callback object pointer |
|
106 * @param aCmdName Command Name |
|
107 * @param aMessage Error message |
|
108 * |
|
109 * @return void |
|
110 */ |
|
111 void LeaveIfAsynchronousL( TUint aCmdOptions, |
|
112 MLiwNotifyCallback* aCallback, |
|
113 const TDesC8& aCmdName, |
|
114 const TDesC& aMessage ); |
|
115 |
|
116 |
|
117 // MLiwInterface member functions |
|
118 public: |
|
119 |
|
120 /** |
|
121 * Executes the SAPI as per params |
|
122 * @param aCmdName Command name defining which operation is to be performed |
|
123 * @param aInParamList Input param list |
|
124 * @param aOutParamList Output list |
|
125 * @param aCmdOptions Command option |
|
126 * @param aCallback Callback object pointer |
|
127 */ |
|
128 virtual void ExecuteCmdL( const TDesC8& aCmdName, |
|
129 const CLiwGenericParamList& aInParamList, |
|
130 CLiwGenericParamList& aOutParamList, |
|
131 TUint aCmdOptions = 0, |
|
132 MLiwNotifyCallback* aCallback = 0 ); |
|
133 |
|
134 /** |
|
135 * Closes the interface |
|
136 */ |
|
137 virtual void Close(); |
|
138 |
|
139 private: |
|
140 |
|
141 /** |
|
142 * Issues SendMessage request to Messaging Service |
|
143 * @param aInParamList Input param list |
|
144 * @param aOutParamList Output list |
|
145 * @param aCmdOptions Command option |
|
146 * @param aCallback Callback object pointer |
|
147 */ |
|
148 void SendMessageL( const CLiwGenericParamList& aInParamList, |
|
149 CLiwGenericParamList& aOutParamList, |
|
150 TUint aCmdOptions, |
|
151 MLiwNotifyCallback* aCallback ); |
|
152 |
|
153 /** |
|
154 * Cancels the async operation issued earlier |
|
155 * @param aCmdName Command name i.e.., Cancel |
|
156 * @param aInParamList Input param list |
|
157 * @param aOutParamList Output list |
|
158 * @param aCmdOptions Command option |
|
159 */ |
|
160 void CancelAsyncL( const TDesC8& aCmdName, |
|
161 const CLiwGenericParamList& aInParamList, |
|
162 CLiwGenericParamList& aOutParamList, |
|
163 TUint aCmdOptions); |
|
164 /** |
|
165 * Issues GetList request to Messaging Service |
|
166 * @param aInParamList Input param list |
|
167 * @param aOutParamList Output list |
|
168 * @param aCmdOptions Command option |
|
169 * @param aCallback Callback object pointer |
|
170 */ |
|
171 void GetHeaderListL( const CLiwGenericParamList& aInParamList, |
|
172 CLiwGenericParamList& aOutParamList, |
|
173 TUint aCmdOptions, |
|
174 MLiwNotifyCallback* aCallback ); |
|
175 |
|
176 /** |
|
177 * Issues New Message notification request to Messaging Service |
|
178 * @param aInParamList Input param list |
|
179 * @param aOutParamList Output list |
|
180 * @param aCmdOptions Command option |
|
181 * @param aCallback Callback object pointer |
|
182 */ |
|
183 void RequestNotificationL( const CLiwGenericParamList& aInParamList, |
|
184 CLiwGenericParamList& aOutParamList, |
|
185 TUint aCmdOptions, |
|
186 MLiwNotifyCallback* aCallback ); |
|
187 |
|
188 /** |
|
189 * Cancels New Message notification Messaging Service |
|
190 * @param aInParamList Input param list |
|
191 * @param aOutParamList Output list |
|
192 * @param aCmdOptions Command option |
|
193 * @param aCallback Callback object pointer |
|
194 */ |
|
195 void CancelNotificationL( const CLiwGenericParamList& aInParamList, |
|
196 CLiwGenericParamList& aOutParamList, |
|
197 TUint aCmdOptions, |
|
198 MLiwNotifyCallback* aCallback ); |
|
199 |
|
200 /** |
|
201 * Issues request for Deleteing Message to Messaging Service |
|
202 * @param aInParamList Input param list |
|
203 * @param aOutParamList Output list |
|
204 * @param aCmdOptions Command option |
|
205 * @param aCallback Callback object pointer |
|
206 */ |
|
207 void DeleteMessageL( const CLiwGenericParamList& aInParamList, |
|
208 CLiwGenericParamList& aOutParamList, |
|
209 TUint aCmdOptions, |
|
210 MLiwNotifyCallback* aCallback ); |
|
211 |
|
212 /** |
|
213 * Issues request for Changing message status to Messaging Service |
|
214 * @param aInParamList Input param list |
|
215 * @param aOutParamList Output list |
|
216 * @param aCmdOptions Command option |
|
217 * @param aCallback Callback object pointer |
|
218 */ |
|
219 void ChangeStatusL( const CLiwGenericParamList& aInParamList, |
|
220 CLiwGenericParamList& aOutParamList, |
|
221 TUint aCmdOptions, |
|
222 MLiwNotifyCallback* aCallback ); |
|
223 |
|
224 /** |
|
225 * Gets the param list for sending message form the inputparam list |
|
226 * @param aInParamList A CLiwGenericParamList containing required input params |
|
227 * @return TSendMessageParams* A send message params structure |
|
228 */ |
|
229 CSendMessageParams* GetSendParametersL( const CLiwGenericParamList& aInParamList ); |
|
230 |
|
231 /** |
|
232 * Gets the filter parameters, sorting option from the inputparam list |
|
233 * @param aInParamList A CLiwGenericParamList containing required input parameters |
|
234 * @return CFilterParamInfo* Filter parameter structure |
|
235 */ |
|
236 CFilterParamInfo* GetFilterParametersL( const CLiwGenericParamList& aInParamList, TBool aIndexBaseInp ); |
|
237 |
|
238 /** |
|
239 * Gets the message id from liw input parameter |
|
240 * @param aInParamList input param list |
|
241 * @param aMessageId Output parameter containing message id |
|
242 * @return TInt Error code |
|
243 */ |
|
244 void GetMessageIdL( const CLiwGenericParamList& aInParamList, TMsvId& aMessageId, |
|
245 const TDesC8& aCmdName ); |
|
246 |
|
247 /** |
|
248 * Gets the transaction id from liw input parameter |
|
249 * @param aInParamList input param list |
|
250 * @param aTransactionId Output param containing transaction id |
|
251 * @return TInt Error code |
|
252 */ |
|
253 void GetTransactionIdL( const CLiwGenericParamList& aInParamList, |
|
254 TInt32& aTransactionId, |
|
255 const TDesC8& aCmdName ); |
|
256 |
|
257 /** |
|
258 * Gets the status flag and its value |
|
259 * @param aInParamList input param list |
|
260 * @param aStatusFlag Status flag |
|
261 * @param aFlagValue Flag value |
|
262 * @return TInt Error code |
|
263 */ |
|
264 void GetStatusFlagAndValueL( const CLiwGenericParamList& aInParamList, |
|
265 TMessageStatusFlag& aStatusFlag, |
|
266 TBool& aFlagValue, |
|
267 const TDesC8& aCmdName ); |
|
268 |
|
269 /** |
|
270 * Gets the notification type |
|
271 * @param aInParamList input param list |
|
272 * @param aNotificationType Notification type |
|
273 * @return void |
|
274 */ |
|
275 void GetNotificationTypeL( const CLiwGenericParamList& aInParamList, |
|
276 TNotificationType& aNotificationType, |
|
277 const TDesC8& aCmdName ); |
|
278 |
|
279 /** |
|
280 * Gives the sort type |
|
281 * @param aSortField Sort Field as input string |
|
282 * @param aSortOrder Sort type as input string |
|
283 * @return TMsvSorting Sort type |
|
284 */ |
|
285 TMsvSorting SortType( const TDesC& aSortField, const TDesC& aSortOrder ); |
|
286 |
|
287 |
|
288 private: |
|
289 |
|
290 /** |
|
291 * CMessagingService class pointer |
|
292 */ |
|
293 CMessagingService* iMsgService; |
|
294 |
|
295 /** |
|
296 * iErrorString Heap Descriptor used to store the error message |
|
297 * in case of error, initially set to NULL |
|
298 */ |
|
299 HBufC* iErrorMessage; |
|
300 }; |
|
301 |
|
302 /** |
|
303 * Callback class for asynchronous SAPI whose result is Integer |
|
304 */ |
|
305 class CMsgCallbackInt : public CMsgCallbackBase |
|
306 { |
|
307 private: |
|
308 |
|
309 /** |
|
310 * Constructor |
|
311 */ |
|
312 CMsgCallbackInt(); |
|
313 |
|
314 public: |
|
315 |
|
316 /** |
|
317 * Two-phase Constructor |
|
318 * @return CMsgCallbackBase* |
|
319 */ |
|
320 static CMsgCallbackBase* NewL(); |
|
321 |
|
322 /** |
|
323 * Gives the result of asynchronous SAPI |
|
324 * @param aErrCode errcode |
|
325 * @param aResult Result |
|
326 * @return void |
|
327 */ |
|
328 void NotifyResultL(TInt aErrCode, TAny* aResult); |
|
329 }; |
|
330 |
|
331 /** |
|
332 * Callback class for asynchronous SAPI message header |
|
333 */ |
|
334 class CMsgCallbackHeader : public CMsgCallbackBase |
|
335 { |
|
336 public: |
|
337 |
|
338 /** |
|
339 * Two-phase Constructor |
|
340 * @return CMsgCallbackHeader* |
|
341 */ |
|
342 static CMsgCallbackHeader* NewL(); |
|
343 |
|
344 /** |
|
345 * Destructor |
|
346 */ |
|
347 virtual ~CMsgCallbackHeader(); |
|
348 |
|
349 private: |
|
350 |
|
351 /** |
|
352 * Constructor |
|
353 */ |
|
354 CMsgCallbackHeader(); |
|
355 |
|
356 public: |
|
357 |
|
358 /** |
|
359 * Gives the result of asynchronous SAPI |
|
360 * @param aErrCode errcode |
|
361 * @param aResult Result |
|
362 * @return void |
|
363 */ |
|
364 virtual void NotifyResultL(TInt aErrCode, TAny* aResult); |
|
365 }; |
|
366 |
|
367 /** |
|
368 * Implemenation of abstract interface to iterate over the collection of message IDs. |
|
369 * |
|
370 * @see CLiwIterable |
|
371 * |
|
372 */ |
|
373 class CIterableIdList : public CLiwIterable |
|
374 { |
|
375 public: |
|
376 /** |
|
377 * Two-phase Constructor |
|
378 * @param aList list to be iterated |
|
379 * @return new CIterableIdList object |
|
380 */ |
|
381 static CIterableIdList* NewL(CMsvEntrySelection* aList, |
|
382 CMessagingService* aMsgService, |
|
383 CFilterParamInfo* aFilter ); |
|
384 |
|
385 /** |
|
386 * Resets the iterator. |
|
387 * |
|
388 */ |
|
389 void Reset(); |
|
390 |
|
391 /** |
|
392 * Iterates over the collection entries to fetch the next data element. |
|
393 * |
|
394 * @param aEntry contains the next data element and its corresponding data type |
|
395 * |
|
396 * @return false if there are no more data elements to be fetched; |
|
397 * true otherwise |
|
398 * |
|
399 */ |
|
400 TBool NextL(TLiwVariant&); |
|
401 |
|
402 /** |
|
403 * Destructor. |
|
404 */ |
|
405 ~CIterableIdList(); |
|
406 |
|
407 private: |
|
408 |
|
409 /** |
|
410 * Constructor |
|
411 * @param aList list to be iterated |
|
412 * @return void |
|
413 */ |
|
414 CIterableIdList(CMsvEntrySelection* aList, |
|
415 CMessagingService* aMsgService, |
|
416 CFilterParamInfo* aFilter ); |
|
417 |
|
418 |
|
419 private: |
|
420 |
|
421 /** |
|
422 * CMsvEntrySelection class pointer |
|
423 */ |
|
424 CMsvEntrySelection* iList; |
|
425 |
|
426 /** |
|
427 * CMessagingService class pointer |
|
428 */ |
|
429 CMessagingService* iMsgService; |
|
430 |
|
431 /** |
|
432 * CFilterParamInfo class pointer |
|
433 */ |
|
434 CFilterParamInfo* iFilter; |
|
435 |
|
436 /** |
|
437 * Index on list |
|
438 */ |
|
439 TInt iIndex; |
|
440 }; |
|
441 |
|
442 /** |
|
443 * An associative array or dictionary class. The collection |
|
444 * key entries are of type string (Descriptor type) and their |
|
445 * associated values can be an variant type. |
|
446 * |
|
447 * \c CLiwDefaultMap provides default map implementation to |
|
448 * <ul> |
|
449 * <li>insert a key-value pair</li> |
|
450 * <li>find a stored value based on a key</li> |
|
451 * <li>get a key based on an index</li> |
|
452 * <li>remove a key-value pair based on a key</li> |
|
453 * <li>get the total number of stored key-value pairs</li> |
|
454 * </ul> |
|
455 * |
|
456 * |
|
457 * @see CLiwContainer |
|
458 * @see TLiwVariant |
|
459 * @see CLiwMap |
|
460 * |
|
461 */ |
|
462 class CLiwMessagingMap : public CLiwMap |
|
463 { |
|
464 public: |
|
465 |
|
466 /* |
|
467 * Creates an instance of \c CLiwMessagingMap |
|
468 * |
|
469 * @return an instance of \c CLiwMessagingMap |
|
470 */ |
|
471 static CLiwMessagingMap* NewL( CMessagingService* aMsgService ); |
|
472 |
|
473 |
|
474 /** |
|
475 * Inserts a key-value pair element to the map collection. If |
|
476 * the specified key already exists, it will be removed from |
|
477 * the collection and the new key-value pair will be added to the |
|
478 * map. |
|
479 * |
|
480 * @param aKey the key to be stored |
|
481 * @param aValue the value associated with the key to be stored |
|
482 */ |
|
483 void InsertL(const TDesC8& aKey, const TLiwVariant& aValue); |
|
484 |
|
485 /** |
|
486 * Finds a value stored in the map collection based on the key. |
|
487 * |
|
488 * @param aKey the key to be searched |
|
489 * @param aFndValue the value associated with the found key |
|
490 * |
|
491 * @return false if there is no key stored; true otherwise |
|
492 */ |
|
493 TBool FindL(const TDesC8& aKey, TLiwVariant& aValue) const; |
|
494 |
|
495 /** |
|
496 * Returns the number of key-value pair stored in the map collection. |
|
497 * |
|
498 * @return the number of key-value pair stored in the map collection |
|
499 */ |
|
500 TInt Count() const; |
|
501 |
|
502 /** |
|
503 * Returns the key stored at a specified index. |
|
504 * |
|
505 * @param aIndex the index of the key to be found |
|
506 * @param aFndKey the key found at the passed index |
|
507 * |
|
508 * @return true if a key-value entry is found at the passed index; |
|
509 * false otherwise |
|
510 */ |
|
511 TBool AtL(TInt aIndex, TDes8& aFndKey) const; |
|
512 |
|
513 /** |
|
514 * Removes a key from the map collection. |
|
515 * |
|
516 * @param aKey the key to be removed from the map |
|
517 */ |
|
518 void Remove(const TDesC8& aKey); |
|
519 |
|
520 private: |
|
521 |
|
522 /* |
|
523 * Constructor |
|
524 */ |
|
525 CLiwMessagingMap(CLiwGenericParamList* aMap, CMessagingService* aMsgService) |
|
526 : iMap(aMap), iMsgService(aMsgService) |
|
527 {} |
|
528 |
|
529 /* |
|
530 * Destructor |
|
531 */ |
|
532 virtual ~CLiwMessagingMap(); |
|
533 |
|
534 /* |
|
535 * the underlying generic parameter list |
|
536 */ |
|
537 CLiwGenericParamList* iMap; |
|
538 |
|
539 /** |
|
540 * CMessagingService class pointer |
|
541 */ |
|
542 CMessagingService* iMsgService; |
|
543 |
|
544 }; |
|
545 |
|
546 class CMsgFileBuffer : public CLiwFileBuffer |
|
547 { |
|
548 public: |
|
549 /** |
|
550 * Two-phase Constructor |
|
551 * @param aFile file handle |
|
552 * @return new CMsgFileBuffer object |
|
553 */ |
|
554 static CMsgFileBuffer* NewL(RFile& aFile); |
|
555 |
|
556 /** |
|
557 * Destructor. |
|
558 */ |
|
559 ~CMsgFileBuffer(); |
|
560 |
|
561 /* |
|
562 * @return RFile handle |
|
563 */ |
|
564 RFile& AsFile(); |
|
565 |
|
566 /* |
|
567 * Returns the pointer to the underlying buffer |
|
568 * |
|
569 * @return the pointer to the underlying buffer |
|
570 */ |
|
571 TUint8* Buf() const; |
|
572 |
|
573 /* |
|
574 * Returns the length of the buffer data |
|
575 * |
|
576 * @return the length of the buffer data |
|
577 */ |
|
578 TInt Len(); |
|
579 |
|
580 /* |
|
581 * Reads the specified number of bytes of buffer data |
|
582 * |
|
583 * @param aPtr the pointer to the area into which buffer data is read |
|
584 * @param aLength the number of bytes to be read from the buffer |
|
585 * |
|
586 * @return KErrNone if the operation is successful; Otherwise |
|
587 * TLiwBufferAccess::KLiwBufferNonReadable |
|
588 * |
|
589 */ |
|
590 TInt Read(TUint8* aPtr,TInt aLength); |
|
591 |
|
592 /* |
|
593 * Writes the specified number of bytes into the buffer |
|
594 * |
|
595 * @param aPtr the pointer to the data to be written into buffer |
|
596 * @param aLength the number of bytes to be written into buffer |
|
597 * |
|
598 * @return KErrNone if the operation is successful; Otherwise |
|
599 * TLiwBufferAccess::KLiwBufferReadOnly if writing is not supported |
|
600 * |
|
601 */ |
|
602 TInt Write(const TUint8 aPtr, TInt aLength); |
|
603 |
|
604 /* |
|
605 * Releases the buffer. The service provider implementing concrete buffer |
|
606 * type should provide appropriate implementation |
|
607 */ |
|
608 void Release(); |
|
609 |
|
610 /* |
|
611 * Returns the appropriate type of buffer. |
|
612 */ |
|
613 TInt TypeID(); |
|
614 |
|
615 /* |
|
616 * The concrete implementation of buffer types should perform equality operation |
|
617 * check |
|
618 */ |
|
619 virtual TBool operator==(CLiwBuffer& aBuffer); |
|
620 |
|
621 private: |
|
622 CMsgFileBuffer(RFile& aFile); |
|
623 |
|
624 private: |
|
625 RFile iFile; |
|
626 }; |
|
627 |
|
628 |
|
629 /** |
|
630 * Input Validator Class used internally to check Inputs |
|
631 */ |
|
632 class TInputValidator |
|
633 { |
|
634 public: |
|
635 TInputValidator(); |
|
636 |
|
637 /* |
|
638 * Check whether aTime is valid or not |
|
639 */ |
|
640 TBool CheckValidDate( const TTime &aTime ); |
|
641 |
|
642 /* |
|
643 * Check whether aDes contains valid number or not |
|
644 */ |
|
645 TBool CheckValidNumber( const TDesC &aDes ); |
|
646 |
|
647 /* |
|
648 * Check whether aFileName is a valid file or not |
|
649 */ |
|
650 TBool CheckValidFile( const TDesC &aFileName ); |
|
651 |
|
652 /* |
|
653 * Check whether aDesc is a valid phone number |
|
654 */ |
|
655 TBool CheckValidNumberWithPlus( const TDesC &aDes ); |
|
656 |
|
657 /* |
|
658 * Check whether aDesc size is not zero |
|
659 */ |
|
660 TBool CheckDesSize( const TDesC &aDes ); |
|
661 }; |
|
662 |
|
663 #endif __MESSAGINGINTERFACE_H |