author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 18 Jan 2010 21:02:57 +0200 | |
changeset 27 | 02682e02e51f |
parent 10 | fc9cf246af83 |
child 32 | 4ac3198c2c5b |
permissions | -rw-r--r-- |
5 | 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: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#include <e32base.h> |
|
20 |
#include <e32def.h> |
|
21 |
#include <msvapi.h> |
|
22 |
#include <msvids.h> |
|
23 |
||
24 |
#include <cmsvattachment.h> |
|
25 |
||
26 |
#include "messageheader.h" |
|
27 |
#include "messagingservice.h" |
|
28 |
#include "messaginginterface.h" |
|
29 |
#include "serviceerrno.h" |
|
30 |
||
31 |
using namespace LIW; |
|
32 |
||
33 |
_LIT8(KErrorCode, "ErrorCode"); |
|
34 |
_LIT8(KTransactionID, "TransactionID"); |
|
35 |
_LIT8(KReturnValue, "ReturnValue"); |
|
36 |
_LIT8(KContentType, "Type"); |
|
37 |
||
38 |
||
39 |
||
40 |
// Messaging Command Names |
|
41 |
_LIT8(KCmdSendMessage, "Send"); |
|
42 |
_LIT8(KCmdGetHeaderList, "GetList"); |
|
43 |
_LIT8(KCmdRegNotification, "RegisterNotification"); |
|
44 |
_LIT8(KCmdCancelNotification,"CancelNotification"); |
|
45 |
_LIT8(KCmdDeleteMsg, "Delete"); |
|
46 |
_LIT8(KCmdChangeStatus, "ChangeStatus"); |
|
47 |
_LIT8(KCmdCancel, "Cancel"); |
|
48 |
||
49 |
// Send Message Parameters |
|
50 |
_LIT8(KMessageParam, "MessageParam"); |
|
51 |
_LIT8(KMtm, "MessageType"); |
|
52 |
_LIT8(KTemplateId, "TemplateId"); |
|
53 |
_LIT8(KSubject, "Subject"); |
|
54 |
_LIT8(KBodyText, "BodyText"); |
|
55 |
_LIT8(KLaunchEditor, "LaunchEditor"); |
|
56 |
_LIT8(KRecipientTo, "To"); |
|
57 |
_LIT8(KRecipientToElement, "To List Element"); |
|
58 |
_LIT8(KRecipientCc, "Cc"); |
|
59 |
_LIT8(KRecipientCcElement, "Cc List Element"); |
|
60 |
_LIT8(KRecipientBcc, "Bcc"); |
|
61 |
_LIT8(KAttachmentName, "Attachment"); |
|
62 |
_LIT8(KRecipientBccElement, "Bcc List Element"); |
|
63 |
_LIT8(KAttachmentList, "AttachmentList"); |
|
64 |
_LIT8(KAttachmentListElement,"AttachmentList Element"); |
|
65 |
_LIT8(KAttachmentType, "AttachmentType" ); |
|
66 |
_LIT8(KFileName, "FileName" ); |
|
67 |
_LIT8(KMimeType, "MimeType" ); |
|
68 |
||
69 |
_LIT(KAttachmentFile, "File" ); |
|
70 |
_LIT(KAttachmentLinkedFile, "LinkedFile" ); |
|
71 |
||
72 |
// Header List Input Parameters |
|
73 |
_LIT8(KFilter, "Filter" ); |
|
74 |
_LIT8(KSortOrder, "SortOrder" ); |
|
75 |
_LIT8(KField, "Key"); |
|
76 |
_LIT8(KOrder, "Order"); |
|
77 |
||
78 |
_LIT(KSortByDate, "Date" ); |
|
79 |
_LIT(KSortBySize, "Size" ); |
|
80 |
_LIT(KSortBySender, "Sender" ); |
|
81 |
_LIT(KSortBySubject, "Subject" ); |
|
82 |
_LIT(KSortById, "MessageId" ); |
|
83 |
_LIT(KSortAsc, "Ascending" ); |
|
84 |
_LIT(KSortDec, "Descending" ); |
|
85 |
||
86 |
_LIT8(KSenderList, "SenderList"); |
|
87 |
_LIT8(KMtmList, "MessageTypeList" ); |
|
88 |
||
89 |
_LIT8(KSenderElement, "SenderList Number"); |
|
90 |
_LIT8(KMtmElement, "MessageTypeList Element" ); |
|
91 |
_LIT8(KMessageId, "MessageId"); |
|
92 |
_LIT8(KStartDate, "StartDate" ); |
|
93 |
_LIT8(KEndDate, "EndDate" ); |
|
94 |
||
95 |
// Header List Output Parameters |
|
96 |
_LIT8(KUnreadFlag, "Unread"); |
|
97 |
_LIT8(KAttachFlag, "Attachment"); |
|
98 |
_LIT8(KPriority, "Priority"); |
|
99 |
_LIT8(KTime, "Time"); |
|
100 |
||
101 |
||
102 |
// Message detail Output Parameters |
|
103 |
_LIT8(KSender, "Sender"); |
|
104 |
_LIT8(KFileSize, "FileSize" ); |
|
105 |
_LIT8(KFileHandle, "FileHandle" ); |
|
106 |
||
107 |
||
108 |
// Change status parameters |
|
109 |
_LIT8(KStatus, "Status"); |
|
110 |
_LIT(KInbox, "Inbox"); |
|
111 |
_LIT(KStatusFlagRead, "Read"); |
|
112 |
_LIT(KStatusFlagUnread, "Unread"); |
|
113 |
_LIT(KStatusFlagReplied, "Replied"); |
|
114 |
_LIT(KStatusFlagForward, "Forwarded"); |
|
115 |
_LIT(KStatusFlagDeleted, "Deleted"); |
|
116 |
||
117 |
// New Message Notification Parameters |
|
118 |
_LIT8(KNotificationType, "Type"); |
|
119 |
_LIT(KNotificationNewMsg, "NewMessage"); |
|
120 |
||
121 |
//ErrorMessages |
|
122 |
_LIT8( KErrorMessage, "ErrorMessage"); |
|
123 |
const TInt KMaxMsgSize = 256; |
|
124 |
||
125 |
_LIT(KDomainName,"Messaging"); |
|
126 |
_LIT(KErrorMsgSeparator,":"); |
|
127 |
_LIT( KIncorrectValue, " Value Incorrect" ); |
|
128 |
_LIT( KDateMismatch, " Start Date greater than EndDate in Filter" ); |
|
129 |
_LIT( KTypeInvalid, " Type Invalid" ); |
|
130 |
_LIT( KMissing, " Missing" ); |
|
131 |
_LIT( KErrMsgMissingLiwCancel, "Liw Cancel Options Not Set" ); |
|
132 |
_LIT( KInvalidCallbackSetup, "Insufficent argument for asynchronous request" ); |
|
133 |
_LIT( KInvalidCMD, "Command not supported"); |
|
134 |
_LIT( KAsyncNotSupported,"Asynchronous Operation not supported" ); |
|
135 |
_LIT( KSyncNotSupported,"Synchronous Operation not supported" ); |
|
136 |
||
137 |
||
138 |
void UpdateOutputAsHeaderL( CLiwGenericParamList* aOutParamList, TAny* aResult ); |
|
139 |
||
140 |
void UpdateOutputAsIdListL( CLiwGenericParamList* aOutParamList, |
|
141 |
CMsvEntrySelection* aEntrySelection, |
|
142 |
CMessagingService* aMsgService, |
|
143 |
CFilterParamInfo* aFilter ); |
|
144 |
||
145 |
void UpdateMessageDetailToMapL( CLiwMap* aResultMap, CMessageDetailInfo* aMessageDetail ); |
|
146 |
||
147 |
||
148 |
TBool GetLiwHeaderL( CMessageHeader* aHeader, |
|
149 |
TLiwVariant& aElement, |
|
150 |
CMessagingService* aMsgService = NULL, |
|
151 |
TBool aCustomMap = EFalse ); |
|
152 |
||
153 |
TInt32 ErrCodeConversion(TInt code); |
|
154 |
||
155 |
// --------------------------------------------------------------------------- |
|
156 |
// Check the Type of Liw variant... whether they match or not.... |
|
157 |
// If they dont match leave |
|
158 |
// If source is of nullvariant type then leave only if aLeaveflag is set |
|
159 |
// --------------------------------------------------------------------------- |
|
160 |
// |
|
161 |
TBool CMessagingInterface::CheckInputTypeL( const TLiwVariant* aSource, |
|
162 |
TBool aLeaveFlag, |
|
163 |
LIW::TVariantTypeId aExpectedtype, |
|
164 |
const TDesC8& aCmdName, |
|
165 |
const TDesC8& aParameter, |
|
166 |
const TDesC& aMessage ) |
|
167 |
{ |
|
168 |
if ( aSource->TypeId() == aExpectedtype ) |
|
169 |
{ |
|
170 |
return ETrue; |
|
171 |
} |
|
172 |
||
173 |
else if ( ( aSource->TypeId() != LIW::EVariantTypeNull ) || aLeaveFlag ) |
|
174 |
{ |
|
175 |
AppendErrorMessageL( aCmdName, aParameter, aMessage, 0 ); |
|
176 |
((TLiwVariant*)aSource)->Reset(); |
|
177 |
User::Leave( KErrBadName ); |
|
178 |
} |
|
179 |
||
180 |
return EFalse; |
|
181 |
} |
|
182 |
||
183 |
// --------------------------------------------------------------------------- |
|
184 |
// Append Error Message |
|
185 |
// --------------------------------------------------------------------------- |
|
186 |
// |
|
187 |
void CMessagingInterface::AppendErrorMessageL( const TDesC8& aCmdName, |
|
188 |
const TDesC8& aParameter, |
|
189 |
const TDesC& aMessage, |
|
190 |
TInt aNoneOrMissingOrIncorrect ) |
|
191 |
{ |
|
192 |
iErrorMessage = HBufC::NewL( KMaxMsgSize ); |
|
193 |
TPtr tmpMsgPtr = iErrorMessage->Des(); |
|
194 |
tmpMsgPtr.Copy(KDomainName); |
|
195 |
||
196 |
HBufC* temp = HBufC::New( KMaxMsgSize ); |
|
197 |
||
198 |
if ( aCmdName.Length() ) |
|
199 |
{ |
|
200 |
tmpMsgPtr.Append( KErrorMsgSeparator ); |
|
201 |
temp->Des().Copy( aCmdName ); |
|
202 |
tmpMsgPtr.Append( temp->Des() ); |
|
203 |
} |
|
204 |
||
205 |
tmpMsgPtr.Append(KErrorMsgSeparator); |
|
206 |
||
207 |
if ( aParameter.Length() ) |
|
208 |
{ |
|
209 |
temp->Des().Copy(aParameter); |
|
210 |
tmpMsgPtr.Append(temp->Des()); |
|
211 |
} |
|
212 |
||
213 |
if ( aMessage.Length() ) |
|
214 |
{ |
|
215 |
tmpMsgPtr.Append( aMessage ); |
|
216 |
} |
|
217 |
||
218 |
delete temp; |
|
219 |
||
220 |
switch( aNoneOrMissingOrIncorrect ) |
|
221 |
{ |
|
222 |
case 1: |
|
223 |
User::Leave(SErrMissingArgument); |
|
224 |
case 2: |
|
225 |
User::Leave(KErrArgument); |
|
226 |
default: |
|
227 |
break; |
|
228 |
} |
|
229 |
} |
|
230 |
||
231 |
// --------------------------------------------------------------------------------------- |
|
232 |
// Function called from sync APIs to check whether Async set up is done if yes then leaves |
|
233 |
// --------------------------------------------------------------------------------------- |
|
234 |
// |
|
235 |
inline void CMessagingInterface::LeaveIfAsynchronousL( TUint aCmdOptions, |
|
236 |
MLiwNotifyCallback* aCallback, |
|
237 |
const TDesC8& aCmdName, |
|
238 |
const TDesC& aMessage ) |
|
239 |
{ |
|
240 |
if( aCallback && ( KLiwOptASyncronous & aCmdOptions ) ) |
|
241 |
{ |
|
242 |
AppendErrorMessageL( aCmdName, KNullDesC8, aMessage, 2/*For KErrArgument*/ ); |
|
243 |
} |
|
244 |
} |
|
245 |
||
246 |
// --------------------------------------------------------------------------- |
|
247 |
// Two-phased constructor. |
|
248 |
// --------------------------------------------------------------------------- |
|
249 |
// |
|
250 |
CMessagingInterface* CMessagingInterface::NewL() |
|
251 |
{ |
|
252 |
CMessagingInterface* self = new (ELeave) CMessagingInterface(); |
|
253 |
CleanupStack::PushL( self ); |
|
254 |
self->ConstructL(); |
|
255 |
CleanupStack::Pop( self ); |
|
256 |
return self; |
|
257 |
} |
|
258 |
// --------------------------------------------------------------------------- |
|
259 |
// Destructor. |
|
260 |
// --------------------------------------------------------------------------- |
|
261 |
// |
|
262 |
CMessagingInterface::~CMessagingInterface() |
|
263 |
{ |
|
264 |
delete iErrorMessage; |
|
265 |
delete iMsgService; |
|
266 |
} |
|
267 |
||
268 |
// --------------------------------------------------------------------------- |
|
269 |
// Closes the interface |
|
270 |
// --------------------------------------------------------------------------- |
|
271 |
// |
|
272 |
||
273 |
void CMessagingInterface::Close() |
|
274 |
{ |
|
275 |
delete this; |
|
276 |
} |
|
277 |
||
278 |
// --------------------------------------------------------------------------- |
|
279 |
// Constructor |
|
280 |
// --------------------------------------------------------------------------- |
|
281 |
// |
|
282 |
CMessagingInterface::CMessagingInterface(): iErrorMessage(0) |
|
283 |
{ |
|
284 |
} |
|
285 |
||
286 |
// --------------------------------------------------------------------------- |
|
287 |
// Symbian Constructor |
|
288 |
// --------------------------------------------------------------------------- |
|
289 |
// |
|
290 |
void CMessagingInterface::ConstructL() |
|
291 |
{ |
|
292 |
iMsgService = CMessagingService::NewL(); |
|
293 |
} |
|
294 |
||
295 |
// --------------------------------------------------------------------------- |
|
296 |
// Executes the SAPI as per params |
|
297 |
// --------------------------------------------------------------------------- |
|
298 |
// |
|
299 |
void CMessagingInterface::ExecuteCmdL( const TDesC8& aCmdName, |
|
300 |
const CLiwGenericParamList& aInParamList, |
|
301 |
CLiwGenericParamList& aOutParamList, |
|
302 |
TUint aCmdOptions, |
|
303 |
MLiwNotifyCallback* aCallback ) |
|
304 |
{ |
|
305 |
TInt errcode = KErrNotSupported; |
|
306 |
TInt32 transactionId(-1); |
|
307 |
if( ( aCallback && !( KLiwOptASyncronous & aCmdOptions ) ) |
|
308 |
|| ( !aCallback && ( KLiwOptASyncronous & aCmdOptions ) ) ) |
|
309 |
{//if any one of them is set it is an error |
|
310 |
errcode = KErrArgument; |
|
311 |
AppendErrorMessageL( aCmdName, KNullDesC8, KInvalidCallbackSetup, 0 ); |
|
312 |
} |
|
313 |
||
314 |
if ( aCmdName.CompareF( KCmdGetHeaderList ) == 0 ) |
|
315 |
{ |
|
316 |
TRAP( errcode, GetHeaderListL( aInParamList, aOutParamList, aCmdOptions, aCallback ) ); |
|
317 |
} |
|
318 |
else if ( aCmdName.CompareF( KCmdSendMessage ) == 0 ) |
|
319 |
{ |
|
320 |
TRAP( errcode, SendMessageL( aInParamList, aOutParamList, aCmdOptions, aCallback ) ); |
|
321 |
} |
|
322 |
else if ( aCmdName.CompareF( KCmdRegNotification ) == 0 ) |
|
323 |
{ |
|
324 |
TRAP( errcode, RequestNotificationL( aInParamList, aOutParamList, aCmdOptions, aCallback ) ); |
|
325 |
} |
|
326 |
else if ( aCmdName.CompareF( KCmdCancelNotification ) == 0 ) |
|
327 |
{ |
|
328 |
TRAP( errcode, CancelNotificationL( aInParamList, aOutParamList, aCmdOptions, aCallback ) ); |
|
329 |
} |
|
330 |
else if ( aCmdName.CompareF( KCmdDeleteMsg ) == 0 ) |
|
331 |
{ |
|
332 |
TRAP( errcode, DeleteMessageL( aInParamList, aOutParamList, aCmdOptions, aCallback ) ); |
|
333 |
} |
|
334 |
else if ( aCmdName.CompareF( KCmdChangeStatus ) == 0 ) |
|
335 |
{ |
|
336 |
TRAP( errcode, ChangeStatusL( aInParamList, aOutParamList, aCmdOptions, aCallback ) ); |
|
337 |
} |
|
338 |
else if ( aCmdName.CompareF( KCmdCancel ) == 0 ) |
|
339 |
{ |
|
340 |
TRAP( errcode, CancelAsyncL( aCmdName, aInParamList, aOutParamList, aCmdOptions) ); |
|
341 |
} |
|
342 |
else |
|
343 |
{ |
|
344 |
AppendErrorMessageL( aCmdName, KNullDesC8, KInvalidCMD, 0 ); |
|
345 |
} |
|
346 |
||
347 |
aOutParamList.AppendL(TLiwGenericParam( KErrorCode, |
|
348 |
TLiwVariant(ErrCodeConversion(errcode)))); |
|
349 |
if( errcode != KErrNone ) |
|
350 |
{ |
|
351 |
aOutParamList.Reset(); |
|
352 |
aOutParamList.AppendL(TLiwGenericParam( KErrorCode, |
|
353 |
TLiwVariant(ErrCodeConversion(errcode)))); |
|
354 |
if ( iErrorMessage ) |
|
355 |
{ |
|
356 |
aOutParamList.AppendL(TLiwGenericParam( KErrorMessage, |
|
357 |
TLiwVariant(iErrorMessage->Des()))); |
|
358 |
delete iErrorMessage; |
|
359 |
iErrorMessage = NULL; |
|
360 |
} |
|
361 |
} |
|
362 |
} |
|
363 |
||
364 |
// --------------------------------------------------------------------------- |
|
365 |
// Issues SendMessage request to MessagingService |
|
366 |
// --------------------------------------------------------------------------- |
|
367 |
// |
|
368 |
void CMessagingInterface::SendMessageL( const CLiwGenericParamList& aInParamList, |
|
369 |
CLiwGenericParamList& aOutParamList, |
|
370 |
TUint aCmdOptions, |
|
371 |
MLiwNotifyCallback* aCallback ) |
|
372 |
{ |
|
373 |
CSendMessageParams* sendParam = GetSendParametersL( aInParamList ); |
|
374 |
||
375 |
CleanupStack::PushL(sendParam); |
|
376 |
||
377 |
CMsgCallbackBase* callback = NULL; |
|
378 |
||
379 |
if ( aCallback && ( KLiwOptASyncronous & aCmdOptions )) |
|
380 |
{ |
|
381 |
callback = CMsgCallbackInt::NewL(); |
|
382 |
CleanupStack::PushL( callback ); |
|
383 |
callback->iPtrInParamList = &aInParamList; |
|
384 |
callback->iPtrNotifyCallback = aCallback; |
|
385 |
callback->iTransactionId = aCallback->GetTransactionID(); |
|
386 |
||
387 |
aOutParamList.AppendL(TLiwGenericParam( KTransactionID, |
|
388 |
TLiwVariant( callback->iTransactionId ))); |
|
389 |
} |
|
390 |
||
391 |
||
392 |
// callback ownership Passed to SendMessageL |
|
393 |
iMsgService->SendMessageL( sendParam, callback ); |
|
394 |
||
395 |
if ( callback ) |
|
396 |
CleanupStack::Pop( callback ); |
|
397 |
||
398 |
CleanupStack::PopAndDestroy( sendParam ); |
|
399 |
} |
|
400 |
||
401 |
// --------------------------------------------------------------------------- |
|
402 |
// Cancel an Asynch request |
|
403 |
// --------------------------------------------------------------------------- |
|
404 |
// |
|
405 |
void CMessagingInterface::CancelAsyncL( const TDesC8& aCmdName, |
|
406 |
const CLiwGenericParamList& aInParamList, |
|
407 |
CLiwGenericParamList& aOutParamList, |
|
408 |
TUint aCmdOptions) |
|
409 |
||
410 |
{ |
|
411 |
TInt errcode = KErrNotSupported; |
|
412 |
TInt32 transactionId(-1); |
|
413 |
||
414 |
if( KLiwOptCancel & aCmdOptions ) |
|
415 |
{ |
|
416 |
GetTransactionIdL( aInParamList, transactionId, KCmdCancel); |
|
417 |
errcode = iMsgService->Cancel( transactionId ); |
|
418 |
if ( errcode == KErrNotFound ) |
|
419 |
{ |
|
420 |
AppendErrorMessageL( aCmdName, KTransactionID, KIncorrectValue, 2 ); |
|
421 |
} |
|
422 |
} |
|
423 |
else |
|
424 |
{ |
|
425 |
AppendErrorMessageL( aCmdName, KNullDesC8, KErrMsgMissingLiwCancel, 2 ); |
|
426 |
} |
|
427 |
} |
|
428 |
||
429 |
// --------------------------------------------------------------------------- |
|
430 |
// Issues GetList request to MessagingService |
|
431 |
// --------------------------------------------------------------------------- |
|
432 |
// |
|
433 |
void CMessagingInterface::GetHeaderListL( const CLiwGenericParamList& aInParamList, |
|
434 |
CLiwGenericParamList& aOutParamList, |
|
435 |
TUint aCmdOptions, |
|
436 |
MLiwNotifyCallback* aCallback ) |
|
437 |
{ |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
438 |
|
5 | 439 |
|
440 |
const TLiwGenericParam* param = NULL; |
|
441 |
||
442 |
TBool indexBaseInp = EFalse; |
|
443 |
||
444 |
TInt pos = 0; |
|
445 |
||
446 |
TMsvId folderId = KMsvGlobalInBoxIndexEntryId;//default is inbox |
|
447 |
||
448 |
param = aInParamList.FindFirst( pos, KContentType ); |
|
449 |
||
450 |
if( !param ) |
|
451 |
{ |
|
452 |
if( aInParamList.Count() ) //changed from 1 to non zero |
|
453 |
{ |
|
454 |
param = &aInParamList[0];//changed from 1 to 0 |
|
455 |
if( param->Name().Compare( KNullDesC8 ) ) |
|
456 |
{ |
|
457 |
AppendErrorMessageL( KCmdGetHeaderList, KContentType, KMissing, 1 ); |
|
458 |
} |
|
459 |
indexBaseInp = ETrue; //Indexed based parsing not name value based |
|
460 |
} |
|
461 |
} |
|
462 |
||
463 |
if ( param && CheckInputTypeL( ¶m->Value(), ETrue, LIW::EVariantTypeDesC, KCmdGetHeaderList, KContentType, KTypeInvalid ) ) |
|
464 |
{ |
|
465 |
TPtrC value = param->Value().AsDes(); |
|
466 |
if ( value.CompareF( KInbox ) == 0 ) |
|
467 |
{ |
|
468 |
folderId = KMsvGlobalInBoxIndexEntryId; |
|
469 |
} |
|
470 |
else |
|
471 |
{ |
|
472 |
AppendErrorMessageL( KCmdGetHeaderList, KContentType, KIncorrectValue, 2 ); |
|
473 |
} |
|
474 |
} |
|
475 |
else |
|
476 |
{ |
|
477 |
AppendErrorMessageL( KCmdGetHeaderList, KContentType, KMissing, 1 ); |
|
478 |
} |
|
479 |
||
480 |
CFilterParamInfo* filterParam = GetFilterParametersL( aInParamList, indexBaseInp ); |
|
481 |
||
482 |
CleanupStack::PushL( filterParam ); |
|
483 |
||
484 |
CMsvEntrySelection* entrySelection = NULL; |
|
485 |
||
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
486 |
CMsgCallbackBase* callback = NULL; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
487 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
488 |
if ( aCallback && ( KLiwOptASyncronous & aCmdOptions )) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
489 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
490 |
callback = CMsgCallbackHeader::NewL(iMsgService); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
491 |
CleanupStack::PushL( callback ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
492 |
callback->iPtrInParamList = &aInParamList; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
493 |
callback->iPtrNotifyCallback = aCallback; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
494 |
callback->iTransactionId = aCallback->GetTransactionID(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
495 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
496 |
aOutParamList.AppendL(TLiwGenericParam( KTransactionID, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
497 |
TLiwVariant( callback->iTransactionId ))); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
498 |
} |
5 | 499 |
|
500 |
iMsgService->GetIdListL( filterParam, |
|
501 |
folderId, |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
502 |
callback/*Callback*/, |
5 | 503 |
entrySelection ); |
504 |
||
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
505 |
if ( callback ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
506 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
507 |
CleanupStack::Pop( callback ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
508 |
CleanupStack::PopAndDestroy(filterParam); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
509 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
510 |
if(!callback) |
5 | 511 |
CleanupStack::Pop( filterParam ); |
512 |
||
513 |
// Successfull completion |
|
514 |
// filterParam and entrySelection ownership passed to called function |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
515 |
if(!callback) |
5 | 516 |
UpdateOutputAsIdListL( &aOutParamList, entrySelection, iMsgService, filterParam ); |
517 |
} |
|
518 |
||
519 |
||
520 |
||
521 |
// --------------------------------------------------------------------------- |
|
522 |
// Issues request for new message notifications to MessagingService |
|
523 |
// --------------------------------------------------------------------------- |
|
524 |
// |
|
525 |
void CMessagingInterface::RequestNotificationL( const CLiwGenericParamList& aInParamList, |
|
526 |
CLiwGenericParamList& aOutParamList, |
|
527 |
TUint aCmdOptions, |
|
528 |
MLiwNotifyCallback* aCallback ) |
|
529 |
{ |
|
530 |
if ( ! (aCallback && ( KLiwOptASyncronous & aCmdOptions ) ) ) |
|
531 |
{ |
|
532 |
AppendErrorMessageL( KCmdRegNotification, KNullDesC8, KSyncNotSupported, 2 ); |
|
533 |
} |
|
534 |
||
535 |
TNotificationType notificationType; |
|
536 |
||
537 |
GetNotificationTypeL( aInParamList, notificationType, KCmdRegNotification ); |
|
538 |
||
539 |
CMsgCallbackBase* callback = NULL; |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
540 |
callback = CMsgCallbackHeader::NewL(iMsgService); |
5 | 541 |
callback->iPtrInParamList = &aInParamList; |
542 |
callback->iPtrNotifyCallback = aCallback; |
|
543 |
callback->iTransactionId = aCallback->GetTransactionID(); |
|
544 |
TInt errcode = iMsgService->RequestNotification( notificationType, callback ); |
|
545 |
||
546 |
if ( errcode != KErrNone ) |
|
547 |
{ |
|
548 |
delete callback; |
|
549 |
User::Leave( errcode ); |
|
550 |
} |
|
551 |
||
552 |
aOutParamList.AppendL(TLiwGenericParam( KTransactionID, |
|
553 |
TLiwVariant( callback->iTransactionId ))); |
|
554 |
} |
|
555 |
||
556 |
||
557 |
// --------------------------------------------------------------------------- |
|
558 |
// Issues request for new message notifications to MessagingService |
|
559 |
// --------------------------------------------------------------------------- |
|
560 |
// |
|
561 |
void CMessagingInterface::CancelNotificationL( const CLiwGenericParamList& aInParamList, |
|
562 |
CLiwGenericParamList& /*aOutParamList*/, |
|
563 |
TUint aCmdOptions, |
|
564 |
MLiwNotifyCallback* aCallback ) |
|
565 |
{ |
|
566 |
LeaveIfAsynchronousL( aCmdOptions, aCallback, KCmdCancelNotification, KAsyncNotSupported ); |
|
567 |
||
568 |
TNotificationType notificationType; |
|
569 |
GetNotificationTypeL( aInParamList, notificationType, KCmdCancelNotification ); |
|
570 |
User::LeaveIfError( iMsgService->CancelNotification( notificationType )); |
|
571 |
} |
|
572 |
||
573 |
// --------------------------------------------------------------------------- |
|
574 |
// Issues request for delete message to MessagingService |
|
575 |
// --------------------------------------------------------------------------- |
|
576 |
// |
|
577 |
void CMessagingInterface::DeleteMessageL( const CLiwGenericParamList& aInParamList, |
|
578 |
CLiwGenericParamList& /*aOutParamList*/, |
|
579 |
TUint aCmdOptions, |
|
580 |
MLiwNotifyCallback* aCallback ) |
|
581 |
{ |
|
582 |
LeaveIfAsynchronousL( aCmdOptions, aCallback, KCmdDeleteMsg, KAsyncNotSupported ); |
|
583 |
||
584 |
TMsvId messageId; |
|
585 |
||
586 |
GetMessageIdL( aInParamList, messageId , KCmdDeleteMsg); |
|
587 |
||
588 |
if ( messageId > 0 ) |
|
589 |
{ |
|
590 |
iMsgService->DeleteMessageL( messageId ); |
|
591 |
} |
|
592 |
else |
|
593 |
{ |
|
594 |
AppendErrorMessageL( KCmdDeleteMsg, KMessageId, KIncorrectValue, 2 ); |
|
595 |
} |
|
596 |
} |
|
597 |
||
598 |
// --------------------------------------------------------------------------- |
|
599 |
// Issues request for changing status of a message to MessagingService |
|
600 |
// --------------------------------------------------------------------------- |
|
601 |
// |
|
602 |
void CMessagingInterface::ChangeStatusL( const CLiwGenericParamList& aInParamList, |
|
603 |
CLiwGenericParamList& /*aOutParamList*/, |
|
604 |
TUint aCmdOptions, |
|
605 |
MLiwNotifyCallback* aCallback ) |
|
606 |
{ |
|
607 |
LeaveIfAsynchronousL( aCmdOptions, aCallback, KCmdChangeStatus, KAsyncNotSupported ); |
|
608 |
TMsvId messageId; |
|
609 |
TMessageStatusFlag statusFlag; |
|
610 |
TBool flagValue; |
|
611 |
||
612 |
GetMessageIdL( aInParamList, messageId, KCmdChangeStatus ); |
|
613 |
GetStatusFlagAndValueL( aInParamList, statusFlag, flagValue, KCmdChangeStatus ); |
|
614 |
||
615 |
if ( messageId > 0 ) |
|
616 |
{ |
|
617 |
iMsgService->ChangeStatusL( messageId, statusFlag, flagValue ); |
|
618 |
} |
|
619 |
else |
|
620 |
{ |
|
621 |
AppendErrorMessageL( KCmdChangeStatus, KMessageId, KIncorrectValue, 2 ); |
|
622 |
} |
|
623 |
} |
|
624 |
||
625 |
// --------------------------------------------------------------------------- |
|
626 |
// Gets the message id |
|
627 |
// --------------------------------------------------------------------------- |
|
628 |
// |
|
629 |
void CMessagingInterface::GetMessageIdL( const CLiwGenericParamList& aInParamList, |
|
630 |
TMsvId& aMessageId, |
|
631 |
const TDesC8& aCmdName ) |
|
632 |
{ |
|
633 |
TInt pos = 0; |
|
634 |
const TLiwGenericParam* param = aInParamList.FindFirst( pos, KMessageId ); |
|
635 |
||
636 |
if(!param && aInParamList.Count() ) |
|
637 |
{ |
|
638 |
param = &aInParamList[0]; |
|
639 |
||
640 |
if( param->Name().Compare( KNullDesC8 ) ) |
|
641 |
{ |
|
642 |
AppendErrorMessageL( aCmdName, KMessageId, KMissing, 1 ); |
|
643 |
} |
|
644 |
} |
|
645 |
||
646 |
||
647 |
if ( param && CheckInputTypeL( ¶m->Value(), ETrue, LIW::EVariantTypeTInt32, aCmdName, KMessageId, KTypeInvalid ) ) |
|
648 |
{ |
|
649 |
aMessageId = param->Value().AsTInt32(); |
|
650 |
return; |
|
651 |
} |
|
652 |
AppendErrorMessageL( aCmdName, KMessageId, KMissing, 1 ); |
|
653 |
} |
|
654 |
||
655 |
// --------------------------------------------------------------------------- |
|
656 |
// Gets the Transaction id |
|
657 |
// --------------------------------------------------------------------------- |
|
658 |
// |
|
659 |
void CMessagingInterface::GetTransactionIdL( const CLiwGenericParamList& aInParamList, |
|
660 |
TInt32& aTransactionId, |
|
661 |
const TDesC8& aCmdName ) |
|
662 |
{ |
|
663 |
TInt pos = 0; |
|
664 |
||
665 |
const TLiwGenericParam* param = aInParamList.FindFirst( pos, |
|
666 |
KTransactionID ); |
|
667 |
if(!param && aInParamList.Count() ) |
|
668 |
{ |
|
669 |
param = &aInParamList[0]; |
|
670 |
||
671 |
if( param->Name().Compare( KNullDesC8 ) ) |
|
672 |
{ |
|
673 |
AppendErrorMessageL( aCmdName, KTransactionID, KMissing, 1 ); |
|
674 |
} |
|
675 |
} |
|
676 |
||
677 |
if ( param && CheckInputTypeL( ¶m->Value(), ETrue, LIW::EVariantTypeTInt32, aCmdName, KTransactionID, KTypeInvalid ) ) |
|
678 |
{ |
|
679 |
aTransactionId = param->Value().AsTInt32(); |
|
680 |
if( aTransactionId < 0 ) |
|
681 |
{ |
|
682 |
AppendErrorMessageL( aCmdName, KTransactionID, KIncorrectValue, 2 ); |
|
683 |
} |
|
684 |
return; |
|
685 |
} |
|
686 |
AppendErrorMessageL( aCmdName, KTransactionID, KMissing, 1 ); |
|
687 |
} |
|
688 |
||
689 |
// --------------------------------------------------------------------------- |
|
690 |
// Gets the status flag and its value |
|
691 |
// --------------------------------------------------------------------------- |
|
692 |
// |
|
693 |
void CMessagingInterface::GetStatusFlagAndValueL( const CLiwGenericParamList& aInParamList, |
|
694 |
TMessageStatusFlag& aStatusFlag, |
|
695 |
TBool& aFlagValue, |
|
696 |
const TDesC8& aCmdName ) |
|
697 |
{ |
|
698 |
TInt pos = 0; |
|
699 |
||
700 |
const TLiwGenericParam* paramMandatory = aInParamList.FindFirst( pos, KMessageId ); |
|
701 |
||
702 |
const TLiwGenericParam* param = NULL; |
|
703 |
||
704 |
pos = 0; |
|
705 |
if ( paramMandatory ) |
|
706 |
param = aInParamList.FindFirst( pos, KStatus ); |
|
707 |
else if( aInParamList.Count() > 1 ) |
|
708 |
param = &aInParamList[1]; |
|
709 |
||
710 |
if ( param && CheckInputTypeL( ¶m->Value(), ETrue, LIW::EVariantTypeDesC, aCmdName, KStatus, KTypeInvalid ) ) |
|
711 |
{ |
|
712 |
TPtrC value = param->Value().AsDes(); |
|
713 |
aFlagValue = ETrue; |
|
714 |
if ( value.CompareF( KStatusFlagRead ) == 0 ) |
|
715 |
{ |
|
716 |
aStatusFlag = EUnread; |
|
717 |
aFlagValue = EFalse; |
|
718 |
} |
|
719 |
else if ( value.CompareF( KStatusFlagUnread ) == 0 ) |
|
720 |
{ |
|
721 |
aStatusFlag = EUnread; |
|
722 |
} |
|
723 |
else if ( value.CompareF( KStatusFlagReplied ) == 0 ) |
|
724 |
{ |
|
725 |
aStatusFlag = EReplied; |
|
726 |
} |
|
727 |
else if ( value.CompareF( KStatusFlagForward ) == 0 ) |
|
728 |
{ |
|
729 |
aStatusFlag = EForward; |
|
730 |
} |
|
731 |
else if ( value.CompareF( KStatusFlagDeleted ) == 0 ) |
|
732 |
{ |
|
733 |
aStatusFlag = EDelete; |
|
734 |
} |
|
735 |
else |
|
736 |
{ |
|
737 |
AppendErrorMessageL( aCmdName, KStatus, KIncorrectValue, 2 ); |
|
738 |
} |
|
739 |
return; |
|
740 |
} |
|
741 |
AppendErrorMessageL( aCmdName, KStatus, KMissing, 1 ); |
|
742 |
} |
|
743 |
||
744 |
// --------------------------------------------------------------------------- |
|
745 |
// Gets the notification type |
|
746 |
// --------------------------------------------------------------------------- |
|
747 |
// |
|
748 |
void CMessagingInterface::GetNotificationTypeL( const CLiwGenericParamList& aInParamList, |
|
749 |
TNotificationType& aNotificationType, |
|
750 |
const TDesC8& aCmdName ) |
|
751 |
{ |
|
752 |
TInt pos = 0; |
|
753 |
const TLiwGenericParam* param = aInParamList.FindFirst( pos, KNotificationType ); |
|
754 |
||
755 |
if(!param && aInParamList.Count() ) |
|
756 |
{ |
|
757 |
param = &aInParamList[0]; |
|
758 |
if( param->Name().Compare( KNullDesC8 ) ) |
|
759 |
{ |
|
760 |
AppendErrorMessageL( aCmdName, KNotificationType, KMissing, 1 ); |
|
761 |
} |
|
762 |
} |
|
763 |
||
764 |
if ( param && CheckInputTypeL( ¶m->Value(), ETrue, LIW::EVariantTypeDesC, aCmdName, KNotificationType, KTypeInvalid) ) |
|
765 |
{ |
|
766 |
TPtrC notifType = param->Value().AsDes(); |
|
767 |
if( notifType.CompareF( KNotificationNewMsg ) == 0 ) |
|
768 |
{ |
|
769 |
aNotificationType = ENewMessage; |
|
770 |
} |
|
771 |
else |
|
772 |
{ |
|
773 |
AppendErrorMessageL( aCmdName, KNotificationType, KIncorrectValue, 2 ); |
|
774 |
} |
|
775 |
} |
|
776 |
else |
|
777 |
{ |
|
778 |
AppendErrorMessageL( aCmdName, KNotificationType, KMissing, 1 ); |
|
779 |
} |
|
780 |
} |
|
781 |
||
782 |
// --------------------------------------------------------------------------- |
|
783 |
// Gets the param list for sending message form the inputparam list |
|
784 |
// --------------------------------------------------------------------------- |
|
785 |
// |
|
786 |
CSendMessageParams* CMessagingInterface::GetSendParametersL( |
|
787 |
const CLiwGenericParamList& aInParamList ) |
|
788 |
{ |
|
789 |
TInputValidator validator; |
|
790 |
CSendMessageParams* sendParams = CSendMessageParams::NewL(); |
|
791 |
CleanupStack::PushL(sendParams); |
|
792 |
||
793 |
TInt pos = 0; |
|
794 |
TBool indexBaseInp = ETrue; |
|
795 |
||
796 |
const TLiwGenericParam* inMessageType = aInParamList.FindFirst( pos, KMtm ); |
|
797 |
if ( inMessageType ) |
|
798 |
{ |
|
799 |
indexBaseInp = EFalse; |
|
800 |
} |
|
801 |
else |
|
802 |
{ |
|
803 |
if( aInParamList.Count() ) |
|
804 |
{ |
|
805 |
inMessageType = &aInParamList[0]; |
|
806 |
if( inMessageType->Name().Compare( KNullDesC8 ) ) |
|
807 |
{ |
|
808 |
AppendErrorMessageL( KCmdSendMessage, KMtm, KMissing, 1 ); |
|
809 |
} |
|
810 |
} |
|
811 |
else |
|
812 |
{ |
|
813 |
AppendErrorMessageL( KCmdSendMessage, KMtm, KMissing, 1 ); |
|
814 |
} |
|
815 |
} |
|
816 |
||
817 |
CheckInputTypeL( &inMessageType->Value(), ETrue, LIW::EVariantTypeDesC, KCmdSendMessage, KMtm, KTypeInvalid ); |
|
818 |
||
819 |
TPtrC type = inMessageType->Value().AsDes(); |
|
820 |
if( sendParams->SetMessageTypeL( type ) != KErrNone ) |
|
821 |
{ |
|
822 |
AppendErrorMessageL( KCmdSendMessage, KMtm, KIncorrectValue, 2 ); |
|
823 |
} |
|
824 |
||
825 |
const TLiwGenericParam* inTmpParam = NULL; |
|
826 |
||
827 |
// Read Recipient "To" |
|
828 |
if ( indexBaseInp ) |
|
829 |
{ |
|
830 |
if ( aInParamList.Count() > 1 ) |
|
831 |
inTmpParam = &aInParamList[1]; |
|
832 |
} |
|
833 |
else |
|
834 |
{ |
|
835 |
pos = 0; |
|
836 |
inTmpParam = aInParamList.FindFirst( pos, KRecipientTo ); |
|
837 |
} |
|
838 |
||
839 |
if ( inTmpParam && CheckInputTypeL( &inTmpParam->Value(), ETrue, LIW::EVariantTypeDesC, KCmdSendMessage, KRecipientTo, KTypeInvalid )) |
|
840 |
{ |
|
841 |
TPtrC recipient = inTmpParam->Value().AsDes(); |
|
842 |
if( validator.CheckValidNumberWithPlus( recipient ) ) |
|
843 |
{ |
|
844 |
sendParams->AddRecipientL(recipient, EMsvRecipientTo); |
|
845 |
inTmpParam = NULL; |
|
846 |
} |
|
847 |
else |
|
848 |
{ |
|
849 |
AppendErrorMessageL( KCmdSendMessage, KRecipientTo, KIncorrectValue, 2 ); |
|
850 |
} |
|
851 |
} |
|
852 |
else |
|
853 |
{ |
|
854 |
AppendErrorMessageL( KCmdSendMessage, KRecipientTo, KMissing, 1 ); |
|
855 |
} |
|
856 |
||
857 |
// Read BodyText |
|
858 |
if ( indexBaseInp ) |
|
859 |
{ |
|
860 |
if ( aInParamList.Count() > 2 ) |
|
861 |
inTmpParam = &aInParamList[2]; |
|
862 |
} |
|
863 |
else |
|
864 |
{ |
|
865 |
pos = 0; |
|
866 |
inTmpParam = aInParamList.FindFirst( pos, KBodyText ); |
|
867 |
} |
|
868 |
||
869 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL |
|
870 |
if ( inTmpParam && CheckInputTypeL( &inTmpParam->Value(), EFalse, LIW::EVariantTypeDesC, KCmdSendMessage, KBodyText, KTypeInvalid ) ) |
|
871 |
{ |
|
872 |
TPtrC bodytext = inTmpParam->Value().AsDes(); |
|
873 |
sendParams->SetBodyTextL( bodytext ); |
|
874 |
inTmpParam = NULL; |
|
875 |
} |
|
876 |
||
877 |
// Read Subject |
|
878 |
if ( indexBaseInp ) |
|
879 |
{ |
|
880 |
if ( aInParamList.Count() > 3 ) |
|
881 |
inTmpParam = &aInParamList[3]; |
|
882 |
} |
|
883 |
else |
|
884 |
{ |
|
885 |
pos = 0; |
|
886 |
inTmpParam = aInParamList.FindFirst( pos, KSubject ); |
|
887 |
} |
|
888 |
||
889 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL |
|
890 |
if ( inTmpParam && CheckInputTypeL( &inTmpParam->Value(), EFalse, LIW::EVariantTypeDesC, KCmdSendMessage, KSubject, KTypeInvalid ) ) |
|
891 |
{ |
|
892 |
TPtrC subject = inTmpParam->Value().AsDes(); |
|
893 |
sendParams->SetSubjectL( subject ); |
|
894 |
inTmpParam = NULL; |
|
895 |
} |
|
896 |
||
897 |
// Read Attachment |
|
898 |
if ( indexBaseInp ) |
|
899 |
{ |
|
900 |
if ( aInParamList.Count() > 4 ) |
|
901 |
inTmpParam = &aInParamList[4]; |
|
902 |
} |
|
903 |
else |
|
904 |
{ |
|
905 |
pos = 0; |
|
906 |
inTmpParam = aInParamList.FindFirst( pos, KAttachmentName ); |
|
907 |
} |
|
908 |
||
909 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL |
|
910 |
if ( inTmpParam && CheckInputTypeL( &inTmpParam->Value(), EFalse, LIW::EVariantTypeDesC, KCmdSendMessage, KAttachmentName, KTypeInvalid ) ) |
|
911 |
{ |
|
912 |
TBuf<KMaxFileName> attachmentfile; |
|
913 |
TBuf8<KMaxFileName> mimeType; |
|
914 |
||
915 |
if( ! validator.CheckDesSize(inTmpParam->Value().AsDes()) ) |
|
916 |
{ |
|
917 |
AppendErrorMessageL( KCmdSendMessage, KAttachmentName, KIncorrectValue, 2 ); |
|
918 |
} |
|
919 |
||
920 |
attachmentfile.Copy( inTmpParam->Value().AsDes() ); |
|
921 |
inTmpParam = NULL; |
|
922 |
||
923 |
if(attachmentfile.Length()) |
|
924 |
{ |
|
925 |
// Read Attachment Mime type |
|
926 |
if ( indexBaseInp ) |
|
927 |
{ |
|
928 |
if ( aInParamList.Count() > 5 ) |
|
929 |
inTmpParam = &aInParamList[5]; |
|
930 |
} |
|
931 |
else |
|
932 |
{ |
|
933 |
pos = 0; |
|
934 |
inTmpParam = aInParamList.FindFirst( pos, KMimeType ); |
|
935 |
} |
|
936 |
||
937 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL |
|
938 |
if ( inTmpParam && CheckInputTypeL( &inTmpParam->Value(), EFalse, LIW::EVariantTypeDesC, KCmdSendMessage, KMimeType, KTypeInvalid ) ) |
|
939 |
{ |
|
940 |
if( ! validator.CheckDesSize( inTmpParam->Value().AsDes() ) ) |
|
941 |
{ |
|
942 |
AppendErrorMessageL( KCmdSendMessage, KMimeType, KIncorrectValue, 2 ); |
|
943 |
} |
|
944 |
mimeType.Copy( inTmpParam->Value().AsDes() ); |
|
945 |
} |
|
946 |
||
947 |
inTmpParam = NULL; |
|
948 |
||
949 |
CMsvAttachment* attachment = CMsvAttachment::NewL( CMsvAttachment::EMsvFile ); |
|
950 |
||
951 |
CleanupStack::PushL(attachment); |
|
952 |
||
953 |
attachment->SetAttachmentNameL( attachmentfile ); |
|
954 |
||
955 |
if ( mimeType.Length() ) |
|
956 |
attachment->SetMimeTypeL( mimeType ); |
|
957 |
||
958 |
sendParams->AddAttachmentL( attachment ); |
|
959 |
||
960 |
CleanupStack::Pop(attachment); |
|
961 |
} |
|
962 |
} |
|
963 |
||
964 |
const TLiwGenericParam* inMessageParam = NULL; |
|
965 |
||
966 |
if ( indexBaseInp ) |
|
967 |
{ |
|
968 |
if ( aInParamList.Count() > 6 ) |
|
969 |
inMessageParam = &aInParamList[6]; |
|
970 |
} |
|
971 |
else |
|
972 |
{ |
|
973 |
pos = 0; |
|
974 |
inMessageParam = aInParamList.FindFirst( pos, KMessageParam ); |
|
975 |
} |
|
976 |
||
977 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL |
|
978 |
if ( inMessageParam && CheckInputTypeL( &inMessageParam->Value(), EFalse, LIW::EVariantTypeMap, KCmdSendMessage, KMessageParam, KTypeInvalid ) ) |
|
979 |
{ |
|
980 |
const CLiwMap* inMap = inMessageParam->Value().AsMap(); |
|
981 |
||
982 |
if(inMap) |
|
983 |
{ |
|
984 |
||
985 |
TLiwVariant inParam; |
|
986 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &inParam) ); |
|
987 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL |
|
988 |
if ( inMap->FindL( KTemplateId, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeTInt32, KCmdSendMessage, KTemplateId, KTypeInvalid ) ) |
|
989 |
{ |
|
990 |
sendParams->SetTemplateId( (TMsvId)(inParam.AsTInt32()) ); |
|
991 |
} |
|
992 |
||
993 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL |
|
994 |
if ( inMap->FindL( KLaunchEditor, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeTBool, KCmdSendMessage, KLaunchEditor, KTypeInvalid ) ) |
|
995 |
{ |
|
996 |
sendParams->SetLaunchEditor( inParam.AsTBool() ); |
|
997 |
} |
|
998 |
||
999 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL |
|
1000 |
if ( inMap->FindL( KRecipientTo, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeList, KCmdSendMessage, KRecipientTo, KTypeInvalid ) ) |
|
1001 |
{ |
|
1002 |
CLiwList* obj = (CLiwList*)(inParam.AsList()); |
|
1003 |
||
1004 |
||
1005 |
for ( int index = 0; index < obj->Count(); index++ ) |
|
1006 |
{ |
|
1007 |
TLiwVariant element; |
|
1008 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &element) ); |
|
1009 |
obj->AtL(index, element); |
|
1010 |
||
1011 |
if( CheckInputTypeL( &element, EFalse, LIW::EVariantTypeDesC, KCmdSendMessage, KRecipientToElement, KTypeInvalid ) ) |
|
1012 |
{ |
|
1013 |
if( validator.CheckValidNumberWithPlus( element.AsDes() ) ) |
|
1014 |
{ |
|
1015 |
sendParams->AddRecipientL( element.AsDes(), EMsvRecipientTo); |
|
1016 |
} |
|
1017 |
else |
|
1018 |
{ |
|
1019 |
AppendErrorMessageL( KCmdSendMessage, KRecipientToElement, KIncorrectValue, 2 ); |
|
1020 |
} |
|
1021 |
} |
|
1022 |
CleanupStack::PopAndDestroy( &element ); |
|
1023 |
//element.Reset(); |
|
1024 |
} |
|
1025 |
} |
|
1026 |
||
1027 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL |
|
1028 |
if ( inMap->FindL( KRecipientCc, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeList, KCmdSendMessage, KRecipientCc, KTypeInvalid ) ) |
|
1029 |
{ |
|
1030 |
CLiwList* obj = (CLiwList*)(inParam.AsList()); |
|
1031 |
||
1032 |
||
1033 |
for ( int index = 0; index < obj->Count(); index++ ) |
|
1034 |
{ |
|
1035 |
TLiwVariant element; |
|
1036 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &element) ); |
|
1037 |
obj->AtL(index, element); |
|
1038 |
||
1039 |
if( CheckInputTypeL( &element, EFalse, LIW::EVariantTypeDesC, KCmdSendMessage, KRecipientCcElement, KTypeInvalid ) ) |
|
1040 |
{ |
|
1041 |
if( validator.CheckValidNumberWithPlus( element.AsDes() ) ) |
|
1042 |
{ |
|
1043 |
sendParams->AddRecipientL( element.AsDes(), EMsvRecipientTo); |
|
1044 |
} |
|
1045 |
else |
|
1046 |
{ |
|
1047 |
AppendErrorMessageL( KCmdSendMessage, KRecipientCcElement, KIncorrectValue, 2 ); |
|
1048 |
} |
|
1049 |
} |
|
1050 |
CleanupStack::PopAndDestroy( &element ); |
|
1051 |
//element.Reset(); |
|
1052 |
} |
|
1053 |
} |
|
1054 |
||
1055 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL |
|
1056 |
if ( inMap->FindL( KRecipientBcc, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeList, KCmdSendMessage, KRecipientBcc, KTypeInvalid ) ) |
|
1057 |
{ |
|
1058 |
CLiwList* obj = (CLiwList*)(inParam.AsList()); |
|
1059 |
||
1060 |
||
1061 |
for ( int index = 0; index < obj->Count(); index++ ) |
|
1062 |
{ |
|
1063 |
TLiwVariant element; |
|
1064 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &element) ); |
|
1065 |
obj->AtL(index, element); |
|
1066 |
||
1067 |
if( CheckInputTypeL( &element, EFalse, LIW::EVariantTypeDesC, KCmdSendMessage, KRecipientBccElement, KTypeInvalid ) ) |
|
1068 |
{ |
|
1069 |
if( validator.CheckValidNumberWithPlus( element.AsDes() ) ) |
|
1070 |
{ |
|
1071 |
sendParams->AddRecipientL( element.AsDes(), EMsvRecipientTo); |
|
1072 |
} |
|
1073 |
else |
|
1074 |
{ |
|
1075 |
AppendErrorMessageL( KCmdSendMessage, KRecipientBccElement, KIncorrectValue, 2 ); |
|
1076 |
} |
|
1077 |
} |
|
1078 |
CleanupStack::PopAndDestroy( &element ); |
|
1079 |
//element.Reset(); |
|
1080 |
} |
|
1081 |
} |
|
1082 |
||
1083 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL |
|
1084 |
if ( inMap->FindL( KAttachmentList, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeList, KCmdSendMessage, KAttachmentList, KTypeInvalid ) ) |
|
1085 |
{ |
|
1086 |
CLiwList* obj = (CLiwList*)(inParam.AsList()); |
|
1087 |
||
1088 |
if( obj && ( obj->Count() > 0 ) ) |
|
1089 |
{ |
|
1090 |
for ( int index = 0; index < obj->Count(); index++ ) |
|
1091 |
{ |
|
1092 |
TLiwVariant list; |
|
1093 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &list) ); |
|
1094 |
if( obj->AtL(index, list) && CheckInputTypeL( &list, EFalse, LIW::EVariantTypeMap, KCmdSendMessage, KAttachmentListElement, KTypeInvalid ) ) |
|
1095 |
{ |
|
1096 |
CLiwMap* map = (CLiwMap*)(list.AsMap()); |
|
1097 |
||
1098 |
TLiwVariant element; |
|
1099 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &element) ); |
|
1100 |
TBuf<KMaxFileName> fileName; |
|
1101 |
if ( map->FindL(KFileName, element) && CheckInputTypeL( &element, EFalse, LIW::EVariantTypeDesC, KCmdSendMessage, KFileName, KTypeInvalid ) ) |
|
1102 |
{ |
|
1103 |
if( ! validator.CheckDesSize( element.AsDes() ) ) |
|
1104 |
{ |
|
1105 |
AppendErrorMessageL( KCmdSendMessage, KFileName, KIncorrectValue, 2 ); |
|
1106 |
} |
|
1107 |
fileName.Copy( element.AsDes() ); |
|
1108 |
element.Reset(); |
|
1109 |
} |
|
1110 |
||
1111 |
CMsvAttachment::TMsvAttachmentType fltype = CMsvAttachment::EMsvFile; |
|
1112 |
if ( map->FindL(KAttachmentType, element) && CheckInputTypeL( &element, EFalse, LIW::EVariantTypeDesC, KCmdSendMessage, KAttachmentType, KTypeInvalid ) ) |
|
1113 |
{ |
|
1114 |
TPtrC fileType = element.AsDes(); |
|
1115 |
if ( fileType.CompareF( KAttachmentLinkedFile ) == 0 ) |
|
1116 |
fltype = CMsvAttachment::EMsvLinkedFile; |
|
1117 |
if ( fileType.CompareF( KAttachmentFile ) != 0 ) |
|
1118 |
User::Leave( ErrCodeConversion(KErrNotSupported)); |
|
1119 |
element.Reset(); |
|
1120 |
} |
|
1121 |
||
1122 |
TBuf8<KMaxFileName> mimeType; |
|
1123 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL |
|
1124 |
if ( map->FindL(KMimeType, element) && CheckInputTypeL( &element, EFalse, LIW::EVariantTypeDesC, KCmdSendMessage, KMimeType, KTypeInvalid ) ) |
|
1125 |
{ |
|
1126 |
if( ! validator.CheckDesSize( element.AsDes() ) ) |
|
1127 |
{ |
|
1128 |
AppendErrorMessageL( KCmdSendMessage, KMimeType, KIncorrectValue, 2 ); |
|
1129 |
} |
|
1130 |
mimeType.Copy( element.AsDes() ); |
|
1131 |
} |
|
1132 |
CleanupStack::PopAndDestroy( &element ); |
|
1133 |
//element.Reset(); |
|
1134 |
||
1135 |
CMsvAttachment* attachment = CMsvAttachment::NewL(fltype); |
|
1136 |
CleanupStack::PushL(attachment); |
|
1137 |
attachment->SetAttachmentNameL( fileName ); |
|
1138 |
if ( mimeType.Length() ) |
|
1139 |
attachment->SetMimeTypeL( mimeType ); |
|
1140 |
||
1141 |
sendParams->AddAttachmentL( attachment ); |
|
1142 |
||
1143 |
CleanupStack::Pop(attachment); |
|
1144 |
} |
|
1145 |
CleanupStack::PopAndDestroy( &list ); |
|
1146 |
//list.Reset(); |
|
1147 |
} |
|
1148 |
} |
|
1149 |
} |
|
1150 |
CleanupStack::PopAndDestroy( &inParam ); |
|
1151 |
//inParam.Reset(); |
|
1152 |
} |
|
1153 |
||
1154 |
} |
|
1155 |
||
1156 |
CleanupStack::Pop( sendParams ); |
|
1157 |
return sendParams; |
|
1158 |
} |
|
1159 |
||
1160 |
// --------------------------------------------------------------------------- |
|
1161 |
// Gives the sort type |
|
1162 |
// --------------------------------------------------------------------------- |
|
1163 |
// |
|
1164 |
TMsvSorting CMessagingInterface::SortType( const TDesC& aSortField, const TDesC& aSortOrder ) |
|
1165 |
{ |
|
1166 |
TMsvSorting retValue = EMsvSortByNone;//this indicates mismatch in either the sortfield or sortorder |
|
1167 |
||
1168 |
if ( aSortOrder.CompareF( KSortAsc)== 0 ) |
|
1169 |
{ |
|
1170 |
if ( aSortField.CompareF( KSortByDate ) == 0 ) |
|
1171 |
retValue = EMsvSortByDate; |
|
1172 |
else if ( aSortField.CompareF( KSortBySize ) == 0 ) |
|
1173 |
retValue = EMsvSortBySize; |
|
1174 |
else if ( aSortField.CompareF( KSortBySender ) == 0 ) |
|
1175 |
retValue = EMsvSortByDetails; |
|
1176 |
else if ( aSortField.CompareF( KSortBySubject ) == 0 ) |
|
1177 |
retValue = EMsvSortByDescription; |
|
1178 |
else if ( aSortField.CompareF( KSortById ) == 0 ) |
|
1179 |
retValue = EMsvSortById; |
|
1180 |
} |
|
1181 |
else if ( aSortOrder.CompareF( KSortDec) == 0 ) |
|
1182 |
{ |
|
1183 |
if ( aSortField.CompareF( KSortByDate ) == 0 ) |
|
1184 |
retValue = EMsvSortByDateReverse; |
|
1185 |
else if ( aSortField.CompareF( KSortBySize ) == 0 ) |
|
1186 |
retValue = EMsvSortBySizeReverse; |
|
1187 |
else if ( aSortField.CompareF( KSortBySender ) == 0 ) |
|
1188 |
retValue = EMsvSortByDetailsReverse; |
|
1189 |
else if ( aSortField.CompareF( KSortBySubject ) == 0 ) |
|
1190 |
retValue = EMsvSortByDescriptionReverse; |
|
1191 |
else if ( aSortField.CompareF( KSortById ) == 0 ) |
|
1192 |
retValue = EMsvSortByIdReverse; |
|
1193 |
} |
|
1194 |
||
1195 |
return retValue; |
|
1196 |
} |
|
1197 |
||
1198 |
// --------------------------------------------------------------------------- |
|
1199 |
// Gets the filter parameters and sorting option from the inputparam list |
|
1200 |
// --------------------------------------------------------------------------- |
|
1201 |
// |
|
1202 |
CFilterParamInfo* CMessagingInterface::GetFilterParametersL( |
|
1203 |
const CLiwGenericParamList& aInParamList, TBool aIndexBaseInp ) |
|
1204 |
{ |
|
1205 |
TInputValidator validator; |
|
1206 |
TInt pos = 0 ; |
|
1207 |
CFilterParamInfo* filterparam = CFilterParamInfo::NewL(); |
|
1208 |
CleanupStack::PushL( filterparam ); |
|
1209 |
||
1210 |
const TLiwGenericParam* filter = NULL; |
|
1211 |
||
1212 |
if ( aIndexBaseInp ) |
|
1213 |
{ |
|
1214 |
if ( aInParamList.Count() > 1 ) |
|
1215 |
filter = &aInParamList[1]; |
|
1216 |
} |
|
1217 |
else |
|
1218 |
{ |
|
1219 |
pos = 0 ; |
|
1220 |
filter = aInParamList.FindFirst( pos, KFilter ); |
|
1221 |
} |
|
1222 |
||
1223 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL |
|
1224 |
if ( filter && CheckInputTypeL( &filter->Value(), EFalse, LIW::EVariantTypeMap, KCmdGetHeaderList, KFilter, KTypeInvalid ) ) |
|
1225 |
{ |
|
1226 |
const CLiwMap* inputMap = filter->Value().AsMap(); |
|
1227 |
||
1228 |
if ( inputMap ) |
|
1229 |
{ |
|
1230 |
// FromArray |
|
1231 |
TLiwVariant inParam; |
|
1232 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &inParam) ); |
|
1233 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL |
|
1234 |
if ( inputMap->FindL( KSenderList, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeList, KCmdGetHeaderList, KSenderList, KTypeInvalid ) ) |
|
1235 |
{ |
|
1236 |
CLiwList* obj = (CLiwList*)( inParam.AsList() ); |
|
1237 |
for ( int index = 0; index < obj->Count(); index++ ) |
|
1238 |
{ |
|
1239 |
TLiwVariant element; |
|
1240 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &element) ); |
|
1241 |
if( obj->AtL(index, element) && CheckInputTypeL( &element, EFalse, LIW::EVariantTypeDesC, KCmdGetHeaderList, KSenderElement, KTypeInvalid ) ) |
|
1242 |
{ |
|
1243 |
TPtrC fromaddr = element.AsDes(); |
|
1244 |
filterparam->AddFromL(fromaddr); |
|
1245 |
||
1246 |
//This check needs to be relaxed |
|
1247 |
/*if( validator.CheckValidNumberWithPlus( fromaddr ) ) |
|
1248 |
{ |
|
1249 |
filterparam->AddFromL(fromaddr); |
|
1250 |
} |
|
1251 |
else |
|
1252 |
{ |
|
1253 |
AppendErrorMessageL( KCmdGetHeaderList, KSenderElement, KIncorrectValue, 2 ); |
|
1254 |
} */ |
|
1255 |
} |
|
1256 |
CleanupStack::PopAndDestroy( &element ); |
|
1257 |
//element.Reset(); |
|
1258 |
} |
|
1259 |
} |
|
1260 |
||
1261 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL |
|
1262 |
// Mtmarray |
|
1263 |
if ( inputMap->FindL( KMtmList, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeList, KCmdGetHeaderList, KMtmList, KTypeInvalid ) ) |
|
1264 |
{ |
|
1265 |
CLiwList* obj = (CLiwList*)( inParam.AsList() ); |
|
1266 |
||
1267 |
||
1268 |
||
1269 |
for ( int index = 0; index < obj->Count(); index++ ) |
|
1270 |
{ |
|
1271 |
TLiwVariant element; |
|
1272 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &element) ); |
|
1273 |
if( obj->AtL(index, element) && CheckInputTypeL( &element, EFalse, LIW::EVariantTypeDesC, KCmdGetHeaderList, KMtmElement, KTypeInvalid ) ) |
|
1274 |
{ |
|
1275 |
TPtrC mtm = element.AsDes(); |
|
1276 |
if( filterparam->AddMtmL(mtm) != KErrNone ) |
|
1277 |
{ |
|
1278 |
AppendErrorMessageL( KCmdGetHeaderList, KMtmElement, KIncorrectValue, 2 ); |
|
1279 |
} |
|
1280 |
} |
|
1281 |
CleanupStack::PopAndDestroy( &element ); |
|
1282 |
//element.Reset(); |
|
1283 |
} |
|
1284 |
} |
|
1285 |
||
1286 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL |
|
1287 |
// Subject |
|
1288 |
if ( inputMap->FindL( KSubject, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeDesC, KCmdGetHeaderList, KSubject, KTypeInvalid ) ) |
|
1289 |
{ |
|
1290 |
TPtrC obj = inParam.AsDes(); |
|
1291 |
filterparam->SetSubjectL(obj); |
|
1292 |
} |
|
1293 |
||
1294 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL |
|
1295 |
//MessageId |
|
1296 |
if ( inputMap->FindL( KMessageId, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeTInt32, KCmdGetHeaderList, KMessageId, KTypeInvalid ) ) |
|
1297 |
{ |
|
1298 |
TInt32 messageid = (TInt32)inParam.AsTInt32(); |
|
1299 |
||
1300 |
filterparam->SetMessageIdFilter( messageid ); |
|
1301 |
} |
|
1302 |
||
1303 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL |
|
1304 |
//StartDate |
|
1305 |
TTime startDate = Time::NullTTime(); |
|
1306 |
if ( inputMap->FindL( KStartDate, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeTTime, KCmdGetHeaderList, KStartDate, KTypeInvalid ) ) |
|
1307 |
{ |
|
1308 |
startDate = inParam.AsTTime(); |
|
1309 |
||
1310 |
filterparam->SetStartDateFilter( startDate ); |
|
1311 |
} |
|
1312 |
||
1313 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL |
|
1314 |
//EndDate |
|
1315 |
TTime endDate = Time::NullTTime(); |
|
1316 |
if ( inputMap->FindL( KEndDate, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeTTime, KCmdGetHeaderList, KEndDate, KTypeInvalid ) ) |
|
1317 |
{ |
|
1318 |
endDate = inParam.AsTTime(); |
|
1319 |
||
1320 |
filterparam->SetEndDate( endDate ); |
|
1321 |
} |
|
1322 |
||
1323 |
if( ( startDate != Time::NullTTime() && endDate != Time::NullTTime() ) && |
|
1324 |
startDate > endDate ) |
|
1325 |
{ |
|
1326 |
AppendErrorMessageL( KCmdGetHeaderList, KStartDate, KDateMismatch, 2 ); |
|
1327 |
} |
|
1328 |
||
1329 |
CleanupStack::PopAndDestroy( &inParam ); |
|
1330 |
//inParam.Reset(); |
|
1331 |
} |
|
1332 |
||
1333 |
} |
|
1334 |
||
1335 |
//SortType |
|
1336 |
const TLiwGenericParam* sortOrder = NULL; |
|
1337 |
if ( aIndexBaseInp ) |
|
1338 |
{ |
|
1339 |
if( aInParamList.Count() > 2 ) |
|
1340 |
sortOrder = &aInParamList[2]; |
|
1341 |
} |
|
1342 |
else |
|
1343 |
{ |
|
1344 |
pos = 0 ; |
|
1345 |
sortOrder = aInParamList.FindFirst( pos, KSortOrder ); |
|
1346 |
} |
|
1347 |
||
1348 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL |
|
1349 |
if ( sortOrder && CheckInputTypeL( &sortOrder->Value(), EFalse, LIW::EVariantTypeMap, KCmdGetHeaderList, KSortOrder, KTypeInvalid ) ) |
|
1350 |
{ |
|
1351 |
const CLiwMap* sortMap = sortOrder->Value().AsMap(); |
|
1352 |
if ( sortMap ) |
|
1353 |
{ |
|
1354 |
TLiwVariant sortParam; |
|
1355 |
||
1356 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL |
|
1357 |
if ( sortMap->FindL( KField, sortParam ) && CheckInputTypeL( &sortParam, EFalse, LIW::EVariantTypeDesC, KCmdGetHeaderList, KField, KTypeInvalid ) ) |
|
1358 |
{ |
|
1359 |
HBufC* sordField = sortParam.AsDes().AllocL(); |
|
1360 |
CleanupStack::PushL( sordField ); |
|
1361 |
||
1362 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL |
|
1363 |
if ( sortMap->FindL( KOrder, sortParam ) && CheckInputTypeL( &sortParam, EFalse, LIW::EVariantTypeDesC, KCmdGetHeaderList, KOrder, KTypeInvalid ) ) |
|
1364 |
{ |
|
1365 |
TPtrC sortOrder = sortParam.AsDes(); |
|
1366 |
TMsvSorting sortCriterion = SortType( *sordField, sortOrder ); |
|
1367 |
if( sortCriterion == EMsvSortByNone ) |
|
1368 |
{ |
|
1369 |
sortParam.Reset(); |
|
1370 |
AppendErrorMessageL( KCmdGetHeaderList, KSortOrder, KIncorrectValue, 2 ); |
|
1371 |
} |
|
1372 |
else |
|
1373 |
filterparam->SetSortType( sortCriterion ); |
|
1374 |
} |
|
1375 |
||
1376 |
CleanupStack::PopAndDestroy( sordField ); |
|
1377 |
} |
|
1378 |
sortParam.Reset(); |
|
1379 |
} |
|
1380 |
} |
|
1381 |
||
1382 |
||
1383 |
||
1384 |
CleanupStack::Pop( filterparam ); |
|
1385 |
return filterparam; |
|
1386 |
} |
|
1387 |
||
1388 |
// --------------------------------------------------------------------------- |
|
1389 |
// Two-phase Constructor |
|
1390 |
// --------------------------------------------------------------------------- |
|
1391 |
// |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1392 |
CMsgCallbackHeader* CMsgCallbackHeader::NewL(CMessagingService* aMsgService) |
5 | 1393 |
{ |
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1394 |
CMsgCallbackHeader* self = new (ELeave) CMsgCallbackHeader(aMsgService); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1395 |
|
5 | 1396 |
return self; |
1397 |
} |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1398 |
|
5 | 1399 |
// --------------------------------------------------------------------------- |
1400 |
// Destructor |
|
1401 |
// --------------------------------------------------------------------------- |
|
1402 |
// |
|
1403 |
CMsgCallbackHeader::~CMsgCallbackHeader() |
|
1404 |
{ |
|
1405 |
} |
|
1406 |
||
1407 |
// --------------------------------------------------------------------------- |
|
1408 |
// Constructor |
|
1409 |
// --------------------------------------------------------------------------- |
|
1410 |
// |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1411 |
CMsgCallbackHeader::CMsgCallbackHeader(CMessagingService* aMsgService):iMsg(aMsgService) |
5 | 1412 |
{ |
1413 |
} |
|
1414 |
||
1415 |
// --------------------------------------------------------------------------- |
|
1416 |
// Gives the result of asynchronous SAPI |
|
1417 |
// --------------------------------------------------------------------------- |
|
1418 |
// |
|
1419 |
void CMsgCallbackHeader::NotifyResultL( TInt aErrCode, TAny* aResult ) |
|
1420 |
{ |
|
1421 |
CLiwGenericParamList* outParams = CLiwGenericParamList::NewL(); |
|
1422 |
||
1423 |
CleanupStack::PushL( outParams ); |
|
1424 |
||
1425 |
outParams->AppendL(TLiwGenericParam(KErrorCode, |
|
1426 |
TLiwVariant(ErrCodeConversion(aErrCode)))); |
|
1427 |
||
1428 |
if ( aErrCode == KErrNone && aResult ) |
|
1429 |
{ |
|
1430 |
UpdateOutputAsHeaderL( outParams, aResult ); |
|
1431 |
} |
|
1432 |
||
1433 |
TInt event = KLiwEventInProgress; |
|
1434 |
||
1435 |
if ( aErrCode == KErrCancel ) |
|
1436 |
{ |
|
1437 |
event = KLiwEventCanceled; |
|
1438 |
} |
|
1439 |
else if ( aErrCode != KErrNone ) |
|
1440 |
{ |
|
1441 |
event = KLiwEventStopped; |
|
1442 |
} |
|
1443 |
||
1444 |
((MLiwNotifyCallback*)iPtrNotifyCallback)->HandleNotifyL( iTransactionId, |
|
1445 |
event, |
|
1446 |
*(outParams), |
|
1447 |
*((CLiwGenericParamList*)iPtrInParamList) ); |
|
1448 |
||
1449 |
CleanupStack::PopAndDestroy( outParams ); |
|
1450 |
} |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1451 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1452 |
// --------------------------------------------------------------------------- |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1453 |
// Gives the result of getlist asynchronous SAPI |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1454 |
// --------------------------------------------------------------------------- |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1455 |
// |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1456 |
void CMsgCallbackHeader::HandleGetlistL( TInt aErrCode, CMsvEntrySelection* aEntrySelection, CFilterParamInfo* aFilter ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1457 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1458 |
CLiwGenericParamList* outParams = CLiwGenericParamList::NewL(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1459 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1460 |
CleanupStack::PushL( outParams ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1461 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1462 |
outParams->AppendL(TLiwGenericParam(KErrorCode, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1463 |
TLiwVariant(ErrCodeConversion(aErrCode)))); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1464 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1465 |
if ( aErrCode==KErrNone ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1466 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1467 |
CIterableIdList* iter = CIterableIdList::NewL( aEntrySelection, iMsg, aFilter ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1468 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1469 |
CleanupStack::PushL( iter ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1470 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1471 |
TLiwVariant listVal; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1472 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1473 |
listVal.Set( iter ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1474 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1475 |
outParams->AppendL( TLiwGenericParam( KReturnValue/*KMessageList*/, listVal )); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1476 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1477 |
CleanupStack::Pop( iter ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1478 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1479 |
listVal.Reset(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1480 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1481 |
iter->DecRef(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1482 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1483 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1484 |
TInt event = KLiwEventCompleted; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1485 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1486 |
if ( aErrCode == KErrCancel ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1487 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1488 |
event = KLiwEventCanceled; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1489 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1490 |
else if ( aErrCode != KErrNone ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1491 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1492 |
event = KLiwEventStopped; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1493 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1494 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1495 |
((MLiwNotifyCallback*)iPtrNotifyCallback)->HandleNotifyL( iTransactionId, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1496 |
event, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1497 |
*(outParams), |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1498 |
*((CLiwGenericParamList*)iPtrInParamList) ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1499 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1500 |
CleanupStack::PopAndDestroy( outParams ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1501 |
} |
5 | 1502 |
|
1503 |
// --------------------------------------------------------------------------- |
|
1504 |
// Two-phase Constructor |
|
1505 |
// --------------------------------------------------------------------------- |
|
1506 |
// |
|
1507 |
CMsgCallbackBase* CMsgCallbackInt::NewL() |
|
1508 |
{ |
|
1509 |
return new (ELeave) CMsgCallbackInt; |
|
1510 |
} |
|
1511 |
||
1512 |
// --------------------------------------------------------------------------- |
|
1513 |
// Constructor |
|
1514 |
// --------------------------------------------------------------------------- |
|
1515 |
// |
|
1516 |
CMsgCallbackInt::CMsgCallbackInt() |
|
1517 |
{ |
|
1518 |
} |
|
1519 |
||
1520 |
// --------------------------------------------------------------------------- |
|
1521 |
// Gives the result of asynchronous SAPI |
|
1522 |
// --------------------------------------------------------------------------- |
|
1523 |
// |
|
1524 |
void CMsgCallbackInt::NotifyResultL( TInt aErrCode, TAny* /*aResult*/ ) |
|
1525 |
{ |
|
1526 |
CLiwGenericParamList* outParams = CLiwGenericParamList::NewL(); |
|
1527 |
||
1528 |
CleanupStack::PushL( outParams ); |
|
1529 |
||
1530 |
outParams->AppendL(TLiwGenericParam(KErrorCode, |
|
1531 |
TLiwVariant(ErrCodeConversion(aErrCode)))); |
|
1532 |
||
1533 |
TInt event = KLiwEventCompleted; |
|
1534 |
if ( aErrCode == KErrCancel ) |
|
1535 |
{ |
|
1536 |
event = KLiwEventCanceled; |
|
1537 |
} |
|
1538 |
else if ( aErrCode != KErrNone ) |
|
1539 |
{ |
|
1540 |
event = KLiwEventStopped; |
|
1541 |
} |
|
1542 |
||
1543 |
((MLiwNotifyCallback*)iPtrNotifyCallback)->HandleNotifyL( iTransactionId, |
|
1544 |
event, |
|
1545 |
*(outParams), |
|
1546 |
*((CLiwGenericParamList*)iPtrInParamList) ); |
|
1547 |
||
1548 |
CleanupStack::PopAndDestroy( outParams ); |
|
1549 |
} |
|
1550 |
||
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1551 |
void CMsgCallbackInt::HandleGetlistL( TInt aErrCode, CMsvEntrySelection* aEntrySelection, CFilterParamInfo* aFilter ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1552 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1553 |
//Dummy Function |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1554 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
1555 |
|
5 | 1556 |
// --------------------------------------------------------------------------- |
1557 |
// Updates the output for message header |
|
1558 |
// --------------------------------------------------------------------------- |
|
1559 |
// |
|
1560 |
void UpdateOutputAsHeaderL( CLiwGenericParamList* aOutParamList, TAny* aResult ) |
|
1561 |
{ |
|
1562 |
CMessageHeader* header = (CMessageHeader*)aResult; |
|
1563 |
TLiwVariant newElement; |
|
1564 |
if( GetLiwHeaderL( header, newElement ) ) |
|
1565 |
{ |
|
1566 |
aOutParamList->AppendL( TLiwGenericParam( KReturnValue/*KMessage*/, newElement )); |
|
1567 |
} |
|
1568 |
newElement.Reset(); |
|
1569 |
} |
|
1570 |
||
1571 |
// --------------------------------------------------------------------------- |
|
1572 |
// Gets the message header |
|
1573 |
// --------------------------------------------------------------------------- |
|
1574 |
// |
|
1575 |
TBool GetLiwHeaderL( CMessageHeader* aHeader, TLiwVariant& aElement, |
|
1576 |
CMessagingService* aMsgService, |
|
1577 |
TBool aCustomMap ) |
|
1578 |
{ |
|
1579 |
if(aHeader) |
|
1580 |
{ |
|
1581 |
CLiwMap* map = NULL; |
|
1582 |
if ( aCustomMap ) |
|
1583 |
map = CLiwMessagingMap::NewL( aMsgService ); |
|
1584 |
else |
|
1585 |
map = CLiwDefaultMap::NewL(); |
|
1586 |
||
1587 |
CleanupClosePushL( *map );//CleanupStack::PushL(map); |
|
1588 |
||
1589 |
map->InsertL( KUnreadFlag, TLiwVariant( aHeader->UnreadFlag() ) ); |
|
1590 |
map->InsertL( KAttachFlag, TLiwVariant( aHeader->AttachFlag() ) ); |
|
1591 |
map->InsertL( KPriority, TLiwVariant( aHeader->Priority() ) ); |
|
1592 |
map->InsertL( KMessageId, TLiwVariant( aHeader->MessageId() ) ); |
|
1593 |
map->InsertL( KTime, TLiwVariant( aHeader->Time() ) ); |
|
1594 |
map->InsertL( KSender, TLiwVariant( aHeader->From() ) ); |
|
1595 |
map->InsertL( KSubject, TLiwVariant( aHeader->Subject() ) ); |
|
1596 |
map->InsertL( KMtm, TLiwVariant( aHeader->Mtm() ) ); |
|
1597 |
||
1598 |
aElement.SetL( map ); |
|
1599 |
||
1600 |
CleanupStack::PopAndDestroy(map); |
|
1601 |
||
1602 |
//map->DecRef(); |
|
1603 |
||
1604 |
return ETrue; |
|
1605 |
} |
|
1606 |
return EFalse; |
|
1607 |
} |
|
1608 |
||
1609 |
// --------------------------------------------------------------------------- |
|
1610 |
// Updates output param list with the headerlist. |
|
1611 |
// aFilter ownership is passed |
|
1612 |
// --------------------------------------------------------------------------- |
|
1613 |
// |
|
1614 |
void UpdateOutputAsIdListL( CLiwGenericParamList* aOutParamList, |
|
1615 |
CMsvEntrySelection* aEntrySelection, |
|
1616 |
CMessagingService* aMsgService, |
|
1617 |
CFilterParamInfo* aFilter ) |
|
1618 |
{ |
|
1619 |
CIterableIdList* iter = CIterableIdList::NewL( aEntrySelection, aMsgService, aFilter ); |
|
1620 |
CleanupStack::PushL( iter ); |
|
1621 |
||
1622 |
TLiwVariant listVal; |
|
1623 |
listVal.Set( iter ); |
|
1624 |
||
1625 |
aOutParamList->AppendL( TLiwGenericParam( KReturnValue/*KMessageList*/, listVal )); |
|
1626 |
||
1627 |
CleanupStack::Pop( iter ); |
|
1628 |
listVal.Reset(); |
|
1629 |
iter->DecRef(); |
|
1630 |
} |
|
1631 |
||
1632 |
// --------------------------------------------------------------------------- |
|
1633 |
// Updates the message details to input map |
|
1634 |
// --------------------------------------------------------------------------- |
|
1635 |
// |
|
1636 |
void UpdateMessageDetailToMapL( CLiwMap* aResultMap, CMessageDetailInfo* aMessageDetail ) |
|
1637 |
{ |
|
1638 |
if ( aResultMap ) |
|
1639 |
{ |
|
1640 |
aResultMap->InsertL( KMessageId, TLiwVariant( aMessageDetail->MessageId() ) ); |
|
1641 |
||
1642 |
aResultMap->InsertL( KBodyText, TLiwVariant( aMessageDetail->BodyText() ) ); |
|
1643 |
||
1644 |
// Update recipient list |
|
1645 |
if ( aMessageDetail->RecipientArray() ) |
|
1646 |
{ |
|
1647 |
CLiwDefaultList* bccList = CLiwDefaultList::NewL(); |
|
1648 |
CleanupClosePushL( *bccList ); //CleanupStack::PushL( bccList ); |
|
1649 |
CLiwDefaultList* ccList = CLiwDefaultList::NewL(); |
|
1650 |
CleanupClosePushL( *ccList ); //CleanupStack::PushL( ccList ); |
|
1651 |
CLiwDefaultList* toList = CLiwDefaultList::NewL(); |
|
1652 |
CleanupClosePushL( *toList ); //CleanupStack::PushL( toList ); |
|
1653 |
||
1654 |
||
1655 |
for( TInt index = 0 ; index < aMessageDetail->RecipientArray()->Count() ;index++ ) |
|
1656 |
{ |
|
1657 |
switch ( aMessageDetail->RecipientArray()->Type( index ) ) |
|
1658 |
{ |
|
1659 |
case EMsvRecipientTo : |
|
1660 |
toList->AppendL(TLiwVariant( (*(aMessageDetail->RecipientArray()))[index] ) ); |
|
1661 |
break; |
|
1662 |
||
1663 |
case EMsvRecipientCc : |
|
1664 |
ccList->AppendL(TLiwVariant( (*(aMessageDetail->RecipientArray()))[index] ) ); |
|
1665 |
break; |
|
1666 |
||
1667 |
case EMsvRecipientBcc : |
|
1668 |
bccList->AppendL(TLiwVariant( (*(aMessageDetail->RecipientArray()))[index] ) ); |
|
1669 |
break; |
|
1670 |
||
1671 |
default : |
|
1672 |
User::Leave( ErrCodeConversion(KErrGeneral) ); |
|
1673 |
break ; |
|
1674 |
} |
|
1675 |
} |
|
1676 |
||
1677 |
if ( toList->Count() > 0 ) |
|
1678 |
{ |
|
1679 |
aResultMap->InsertL( KRecipientTo, TLiwVariant(toList) ); |
|
1680 |
} |
|
1681 |
CleanupStack::PopAndDestroy( toList ); |
|
1682 |
//toList->DecRef(); |
|
1683 |
||
1684 |
if ( ccList->Count() > 0 ) |
|
1685 |
{ |
|
1686 |
aResultMap->InsertL( KRecipientCc, TLiwVariant(ccList) ); |
|
1687 |
} |
|
1688 |
CleanupStack::PopAndDestroy( ccList ); |
|
1689 |
//ccList->DecRef(); |
|
1690 |
||
1691 |
if ( bccList->Count() > 0 ) |
|
1692 |
{ |
|
1693 |
aResultMap->InsertL( KRecipientBcc, TLiwVariant(bccList) ); |
|
1694 |
} |
|
1695 |
CleanupStack::PopAndDestroy( bccList ); |
|
1696 |
//bccList->DecRef(); |
|
1697 |
} |
|
1698 |
||
1699 |
// Update attachment list |
|
1700 |
if ( aMessageDetail->AttachmentInfoArray() ) |
|
1701 |
{ |
|
1702 |
CLiwDefaultList* mapList = CLiwDefaultList::NewL(); |
|
1703 |
CleanupClosePushL( *mapList ); //CleanupStack::PushL( mapList ); |
|
1704 |
||
1705 |
for ( TInt index = 0 ; index < aMessageDetail->AttachmentInfoArray()->Count(); index++ ) |
|
1706 |
{ |
|
1707 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
1708 |
||
1709 |
CleanupClosePushL( *map ); //CleanupStack::PushL( map ); |
|
1710 |
||
1711 |
CMessageAttachInfo* attachinfo = aMessageDetail->AttachmentInfoArray()->At( index ); |
|
1712 |
||
1713 |
map->InsertL(KFileName, TLiwVariant( attachinfo->Name() ) ); |
|
1714 |
||
1715 |
map->InsertL(KFileSize, TLiwVariant( attachinfo->Size() ) ); |
|
1716 |
||
1717 |
map->InsertL(KMimeType, TLiwVariant( attachinfo->MimeType() ) ); |
|
1718 |
||
1719 |
RFile tmpFile = attachinfo->FileHandle(); |
|
1720 |
||
1721 |
CMsgFileBuffer* fileObj = CMsgFileBuffer::NewL( tmpFile ); |
|
1722 |
||
1723 |
CleanupStack::PushL( fileObj ); |
|
1724 |
||
1725 |
map->InsertL(KFileHandle, TLiwVariant( fileObj ) ); |
|
1726 |
||
1727 |
CleanupStack::Pop( fileObj ); |
|
1728 |
fileObj->DecRef(); |
|
1729 |
||
1730 |
mapList->AppendL( TLiwVariant(map) ); |
|
1731 |
||
1732 |
CleanupStack::PopAndDestroy(map); |
|
1733 |
||
1734 |
//map->DecRef(); |
|
1735 |
} |
|
1736 |
||
1737 |
if ( mapList->Count() > 0 ) |
|
1738 |
{ |
|
1739 |
aResultMap->InsertL( KAttachmentList, TLiwVariant(mapList) ); |
|
1740 |
} |
|
1741 |
||
1742 |
CleanupStack::PopAndDestroy( mapList ); |
|
1743 |
||
1744 |
//mapList->DecRef(); |
|
1745 |
} |
|
1746 |
} |
|
1747 |
} |
|
1748 |
||
1749 |
// --------------------------------------------------------------------------- |
|
1750 |
// Two-Phase constructor |
|
1751 |
// --------------------------------------------------------------------------- |
|
1752 |
// |
|
1753 |
CIterableIdList* CIterableIdList::NewL( CMsvEntrySelection* aList, |
|
1754 |
CMessagingService* aMsgService, |
|
1755 |
CFilterParamInfo* aFilter ) |
|
1756 |
{ |
|
1757 |
return new(ELeave) CIterableIdList( aList, aMsgService, aFilter ); |
|
1758 |
} |
|
1759 |
||
1760 |
// --------------------------------------------------------------------------- |
|
1761 |
// Destructor |
|
1762 |
// --------------------------------------------------------------------------- |
|
1763 |
// |
|
1764 |
CIterableIdList::~CIterableIdList() |
|
1765 |
{ |
|
1766 |
if( iList ) |
|
1767 |
{ |
|
1768 |
iList->Reset(); |
|
1769 |
delete iList; |
|
1770 |
} |
|
1771 |
||
1772 |
delete iFilter; |
|
1773 |
} |
|
1774 |
||
1775 |
// --------------------------------------------------------------------------- |
|
1776 |
// Reset the list |
|
1777 |
// --------------------------------------------------------------------------- |
|
1778 |
// |
|
1779 |
void CIterableIdList::Reset() |
|
1780 |
{ |
|
1781 |
if( iList ) |
|
1782 |
{ |
|
1783 |
iIndex = 0; //iList->Reset(); |
|
1784 |
} |
|
1785 |
} |
|
1786 |
||
1787 |
// --------------------------------------------------------------------------- |
|
1788 |
// Gets next element in list |
|
1789 |
// --------------------------------------------------------------------------- |
|
1790 |
// |
|
1791 |
TBool CIterableIdList::NextL(TLiwVariant& aNext) |
|
1792 |
{ |
|
1793 |
TBool retValue = EFalse; |
|
1794 |
if ( iList && iList->Count() > iIndex ) |
|
1795 |
{ |
|
1796 |
CMessageHeader* header = NULL; |
|
1797 |
||
1798 |
TRAPD( err, iMsgService->GetNextHeaderL( iFilter, iList, iIndex, NULL, header ));// Check for trap |
|
1799 |
||
1800 |
if ( ( err == KErrNone ) && header ) |
|
1801 |
{ |
|
1802 |
CleanupStack::PushL( header ); |
|
1803 |
||
1804 |
// Get object of the custom map |
|
1805 |
if ( GetLiwHeaderL( header, aNext, iMsgService, ETrue ) ) |
|
1806 |
{ |
|
1807 |
retValue = ETrue; |
|
1808 |
} |
|
1809 |
||
1810 |
CleanupStack::PopAndDestroy( header ); |
|
1811 |
} |
|
1812 |
else |
|
1813 |
{ |
|
1814 |
User::LeaveIfError( ErrCodeConversion(err)); |
|
1815 |
} |
|
1816 |
} |
|
1817 |
return retValue; |
|
1818 |
} |
|
1819 |
||
1820 |
||
1821 |
// --------------------------------------------------------------------------- |
|
1822 |
// Constructor |
|
1823 |
// --------------------------------------------------------------------------- |
|
1824 |
// |
|
1825 |
CIterableIdList::CIterableIdList(CMsvEntrySelection* aList, |
|
1826 |
CMessagingService* aMsgService, |
|
1827 |
CFilterParamInfo* aFilter ): |
|
1828 |
iList( aList ), |
|
1829 |
iMsgService( aMsgService ), |
|
1830 |
iFilter( aFilter ) |
|
1831 |
{ |
|
1832 |
} |
|
1833 |
||
1834 |
||
1835 |
////////////////////////////////////// |
|
1836 |
//Messaging Custom map Implementation |
|
1837 |
////////////////////////////////////// |
|
1838 |
CLiwMessagingMap* CLiwMessagingMap::NewL( CMessagingService* aMsgService ) |
|
1839 |
{ |
|
1840 |
CLiwGenericParamList* gl = CLiwGenericParamList::NewLC(); |
|
1841 |
CLiwMessagingMap* tempMap = new (ELeave) CLiwMessagingMap(gl, aMsgService); |
|
1842 |
CleanupStack::Pop(gl); |
|
1843 |
return tempMap; |
|
1844 |
} |
|
1845 |
||
1846 |
void CLiwMessagingMap::InsertL(const TDesC8& aKey, const TLiwVariant& aValue) |
|
1847 |
{ |
|
1848 |
Remove(aKey); |
|
1849 |
TLiwGenericParam mp; |
|
1850 |
mp.SetNameAndValueL(aKey, aValue); |
|
1851 |
iMap->AppendL(mp); |
|
1852 |
mp.Reset(); |
|
1853 |
} |
|
1854 |
||
1855 |
TBool CLiwMessagingMap::FindL(const TDesC8& aKey, TLiwVariant& aValue) const |
|
1856 |
{ |
|
1857 |
TInt pos = 0; |
|
1858 |
const TLiwGenericParam* tempParam = iMap->FindFirst(pos, aKey); |
|
1859 |
if (tempParam) |
|
1860 |
{ |
|
1861 |
aValue.SetL(tempParam->Value()); |
|
1862 |
return ETrue; |
|
1863 |
} |
|
1864 |
else |
|
1865 |
{ |
|
1866 |
// add for bodytext/recipient cc bcc to/attachlist |
|
1867 |
if( aKey.CompareF( KBodyText ) == 0 || |
|
1868 |
aKey.CompareF( KRecipientTo ) == 0 || |
|
1869 |
aKey.CompareF( KRecipientCc ) == 0 || |
|
1870 |
aKey.CompareF( KRecipientBcc ) == 0 || |
|
1871 |
aKey.CompareF( KAttachmentList ) == 0 ) |
|
1872 |
{ |
|
1873 |
pos = 0; |
|
1874 |
const TLiwGenericParam* messageIdParam = iMap->FindFirst( pos, KMessageId ); |
|
1875 |
if ( messageIdParam && iMsgService ) |
|
1876 |
{ |
|
1877 |
TMsvId messageId = messageIdParam->Value().AsTInt32(); |
|
1878 |
CMessageDetailInfo* messageDetail = NULL; |
|
1879 |
TRAPD( err, iMsgService->GetMessageDetailL( messageId, NULL, messageDetail )); |
|
1880 |
||
1881 |
if ( err == KErrNone && messageDetail ) |
|
1882 |
{ |
|
1883 |
CleanupStack::PushL( messageDetail ); |
|
1884 |
||
1885 |
UpdateMessageDetailToMapL( (CLiwMap*)this, messageDetail ); |
|
1886 |
||
1887 |
CleanupStack::PopAndDestroy( messageDetail ); |
|
1888 |
||
1889 |
pos = 0; |
|
1890 |
const TLiwGenericParam* detailParam = iMap->FindFirst(pos, aKey); |
|
1891 |
if ( detailParam ) |
|
1892 |
{ |
|
1893 |
aValue.SetL( detailParam->Value() ); |
|
1894 |
return ETrue; |
|
1895 |
} |
|
1896 |
} |
|
1897 |
else |
|
1898 |
{ |
|
1899 |
User::LeaveIfError( ErrCodeConversion(err) ); |
|
1900 |
} |
|
1901 |
} |
|
1902 |
} |
|
1903 |
} |
|
1904 |
return EFalse; |
|
1905 |
} |
|
1906 |
||
1907 |
TInt CLiwMessagingMap::Count() const |
|
1908 |
{ |
|
1909 |
return iMap->Count(); |
|
1910 |
} |
|
1911 |
||
1912 |
TBool CLiwMessagingMap::AtL(TInt aIndex, TDes8& aKey) const |
|
1913 |
{ |
|
1914 |
if(0 <= aIndex && aIndex < iMap->Count()) |
|
1915 |
{ |
|
1916 |
aKey = ((*iMap)[aIndex]).Name(); |
|
1917 |
return ETrue; |
|
1918 |
} |
|
1919 |
else |
|
1920 |
{ |
|
1921 |
return EFalse; |
|
1922 |
} |
|
1923 |
} |
|
1924 |
||
1925 |
void CLiwMessagingMap::Remove(const TDesC8& aKey) |
|
1926 |
{ |
|
1927 |
iMap->Remove( aKey ); |
|
1928 |
} |
|
1929 |
||
1930 |
CLiwMessagingMap::~CLiwMessagingMap() |
|
1931 |
{ |
|
1932 |
delete iMap; |
|
1933 |
} |
|
1934 |
||
1935 |
||
1936 |
////////////////////////////////////// |
|
1937 |
//File Buffer Implementation |
|
1938 |
////////////////////////////////////// |
|
1939 |
CMsgFileBuffer* CMsgFileBuffer::NewL(RFile& aFile) |
|
1940 |
{ |
|
1941 |
return new(ELeave) CMsgFileBuffer(aFile); |
|
1942 |
} |
|
1943 |
||
1944 |
CMsgFileBuffer::~CMsgFileBuffer() |
|
1945 |
{ |
|
1946 |
Release(); |
|
1947 |
} |
|
1948 |
||
1949 |
CMsgFileBuffer::CMsgFileBuffer( RFile& aFile ): |
|
1950 |
iFile( aFile ) |
|
1951 |
{ |
|
1952 |
||
1953 |
} |
|
1954 |
||
1955 |
RFile& CMsgFileBuffer::AsFile() |
|
1956 |
{ |
|
1957 |
return iFile; |
|
1958 |
} |
|
1959 |
||
1960 |
TUint8* CMsgFileBuffer::Buf() const |
|
1961 |
{ |
|
1962 |
return NULL; |
|
1963 |
} |
|
1964 |
||
1965 |
TInt CMsgFileBuffer::Len() |
|
1966 |
{ |
|
1967 |
TInt size = 0; |
|
1968 |
||
1969 |
TInt retValue = iFile.Size( size ); |
|
1970 |
||
1971 |
if ( retValue == KErrNone ) |
|
1972 |
{ |
|
1973 |
return size; |
|
1974 |
} |
|
1975 |
else |
|
1976 |
{ |
|
1977 |
return retValue; |
|
1978 |
} |
|
1979 |
} |
|
1980 |
||
1981 |
TInt CMsgFileBuffer::Read( TUint8* aPtr,TInt aLength ) |
|
1982 |
{ |
|
1983 |
TPtr8 temp(aPtr, aLength); |
|
1984 |
||
1985 |
TInt errCode = iFile.Read( temp, aLength ); |
|
1986 |
||
1987 |
return errCode; |
|
1988 |
} |
|
1989 |
||
1990 |
TInt CMsgFileBuffer::Write(const TUint8 /*aPtr*/, TInt /*aLength*/) |
|
1991 |
{ |
|
1992 |
return KLiwBufferReadOnly; |
|
1993 |
} |
|
1994 |
||
1995 |
void CMsgFileBuffer::Release() |
|
1996 |
{ |
|
1997 |
iFile.Close(); |
|
1998 |
} |
|
1999 |
||
2000 |
TInt CMsgFileBuffer::TypeID() |
|
2001 |
{ |
|
2002 |
return KLiwBufferFile; |
|
2003 |
} |
|
2004 |
||
2005 |
TBool CMsgFileBuffer::operator==(CLiwBuffer& /*aBuffer*/) |
|
2006 |
{ |
|
2007 |
return EFalse; |
|
2008 |
} |
|
2009 |
||
2010 |
// --------------------------------------------------------------------------- |
|
2011 |
// ErrCode Conversion |
|
2012 |
// --------------------------------------------------------------------------- |
|
2013 |
// |
|
2014 |
TInt32 ErrCodeConversion(TInt code) |
|
2015 |
{ |
|
2016 |
TInt32 err; |
|
2017 |
switch (code) |
|
2018 |
{ |
|
2019 |
case KErrCancel: |
|
2020 |
case KErrNone: |
|
2021 |
err= SErrNone; |
|
2022 |
break; |
|
2023 |
||
2024 |
case KErrNotFound: |
|
2025 |
err= SErrNotFound; |
|
2026 |
break; |
|
2027 |
||
2028 |
case KErrNoMemory: |
|
2029 |
err = SErrNoMemory; |
|
2030 |
break; |
|
2031 |
||
2032 |
case KErrInUse: |
|
2033 |
err = SErrServiceInUse; |
|
2034 |
break; |
|
2035 |
||
2036 |
case KErrNotSupported: |
|
2037 |
err = SErrServiceNotSupported; |
|
2038 |
break; |
|
2039 |
||
2040 |
case KErrBadName: |
|
2041 |
err = SErrBadArgumentType; |
|
2042 |
break; |
|
2043 |
||
2044 |
case KErrArgument: |
|
2045 |
err = SErrInvalidServiceArgument; |
|
2046 |
break; |
|
2047 |
||
2048 |
case KErrAlreadyExists: |
|
2049 |
err = SErrEntryExists; |
|
2050 |
break; |
|
2051 |
||
2052 |
case SErrMissingArgument: |
|
2053 |
err = SErrMissingArgument; |
|
2054 |
break; |
|
2055 |
||
2056 |
default : |
|
2057 |
err = SErrGeneralError; |
|
2058 |
break; |
|
2059 |
} |
|
2060 |
||
2061 |
return err; |
|
2062 |
||
2063 |
} |
|
2064 |
||
2065 |
||
2066 |
TInputValidator::TInputValidator() |
|
2067 |
{ |
|
2068 |
||
2069 |
} |
|
2070 |
||
2071 |
||
2072 |
TBool TInputValidator::CheckValidFile( const TDesC &aFileName ) |
|
2073 |
{ |
|
2074 |
if( aFileName.Length() <= KMaxFileName ) |
|
2075 |
{ |
|
2076 |
RFs fileSession; |
|
2077 |
if( fileSession.Connect() == KErrNone ) |
|
2078 |
{ |
|
2079 |
if( fileSession.IsValidName( aFileName ) ) |
|
2080 |
{ |
|
2081 |
RFile tmpfile; |
|
2082 |
if( tmpfile.Open( fileSession, aFileName, EFileRead ) == KErrNone ) |
|
2083 |
{ |
|
2084 |
tmpfile.Close(); |
|
2085 |
return ETrue; |
|
2086 |
} |
|
2087 |
} |
|
2088 |
fileSession.Close(); |
|
2089 |
return EFalse; |
|
2090 |
} |
|
2091 |
} |
|
2092 |
return EFalse; |
|
2093 |
} |
|
2094 |
||
2095 |
TBool TInputValidator::CheckDesSize( const TDesC &aDes ) |
|
2096 |
{ |
|
2097 |
if( aDes.Length() <= KMaxFileName ) |
|
2098 |
{ |
|
2099 |
return ETrue; |
|
2100 |
} |
|
2101 |
return EFalse; |
|
2102 |
} |
|
2103 |
||
2104 |
TBool TInputValidator::CheckValidDate( const TTime &aTime ) |
|
2105 |
{ |
|
2106 |
TTime null = Time::NullTTime(); |
|
2107 |
TTime low = Time::MinTTime(); |
|
2108 |
TTime high = Time::MaxTTime(); |
|
2109 |
if( aTime == null || aTime < low || aTime > high ) |
|
2110 |
{ |
|
2111 |
return EFalse; |
|
2112 |
} |
|
2113 |
return ETrue; |
|
2114 |
} |
|
2115 |
||
2116 |
TBool TInputValidator::CheckValidNumber( const TDesC &aDes ) |
|
2117 |
{ |
|
2118 |
if( aDes.Length() ) |
|
2119 |
{ |
|
2120 |
TLex parser( aDes ); |
|
2121 |
TChar character; |
|
2122 |
while( (character = parser.Get()) !=0 ) |
|
2123 |
{ |
|
2124 |
if( !character.IsDigit() ) |
|
2125 |
{ |
|
2126 |
return EFalse; |
|
2127 |
} |
|
2128 |
} |
|
2129 |
return ETrue; |
|
2130 |
} |
|
2131 |
return EFalse; |
|
2132 |
} |
|
2133 |
||
2134 |
TBool TInputValidator::CheckValidNumberWithPlus( const TDesC &aDes ) |
|
2135 |
{ |
|
2136 |
if( aDes.Length() ) |
|
2137 |
{ |
|
2138 |
TLex parser( aDes ); |
|
2139 |
TChar character; |
|
2140 |
character = parser.Get(); |
|
2141 |
if( !(character == '+') && !character.IsDigit() )//check for the first character |
|
2142 |
{ |
|
2143 |
return EFalse; |
|
2144 |
} |
|
2145 |
while( (character = parser.Get()) !=0 ) |
|
2146 |
{ |
|
2147 |
if( !character.IsDigit() ) |
|
2148 |
{ |
|
2149 |
return EFalse; |
|
2150 |
} |
|
2151 |
} |
|
2152 |
return ETrue; |
|
2153 |
} |
|
2154 |
return EFalse; |
|
2155 |
} |