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 |
{
|
|
438 |
LeaveIfAsynchronousL( aCmdOptions, aCallback, KCmdGetHeaderList, KAsyncNotSupported );
|
|
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 |
|
|
486 |
|
|
487 |
|
|
488 |
iMsgService->GetIdListL( filterParam,
|
|
489 |
folderId,
|
|
490 |
NULL/*Callback*/,
|
|
491 |
entrySelection );
|
|
492 |
|
|
493 |
CleanupStack::Pop( filterParam );
|
|
494 |
|
|
495 |
// Successfull completion
|
|
496 |
// filterParam and entrySelection ownership passed to called function
|
|
497 |
UpdateOutputAsIdListL( &aOutParamList, entrySelection, iMsgService, filterParam );
|
|
498 |
}
|
|
499 |
|
|
500 |
|
|
501 |
|
|
502 |
// ---------------------------------------------------------------------------
|
|
503 |
// Issues request for new message notifications to MessagingService
|
|
504 |
// ---------------------------------------------------------------------------
|
|
505 |
//
|
|
506 |
void CMessagingInterface::RequestNotificationL( const CLiwGenericParamList& aInParamList,
|
|
507 |
CLiwGenericParamList& aOutParamList,
|
|
508 |
TUint aCmdOptions,
|
|
509 |
MLiwNotifyCallback* aCallback )
|
|
510 |
{
|
|
511 |
if ( ! (aCallback && ( KLiwOptASyncronous & aCmdOptions ) ) )
|
|
512 |
{
|
|
513 |
AppendErrorMessageL( KCmdRegNotification, KNullDesC8, KSyncNotSupported, 2 );
|
|
514 |
}
|
|
515 |
|
|
516 |
TNotificationType notificationType;
|
|
517 |
|
|
518 |
GetNotificationTypeL( aInParamList, notificationType, KCmdRegNotification );
|
|
519 |
|
|
520 |
CMsgCallbackBase* callback = NULL;
|
|
521 |
callback = CMsgCallbackHeader::NewL();
|
|
522 |
callback->iPtrInParamList = &aInParamList;
|
|
523 |
callback->iPtrNotifyCallback = aCallback;
|
|
524 |
callback->iTransactionId = aCallback->GetTransactionID();
|
|
525 |
TInt errcode = iMsgService->RequestNotification( notificationType, callback );
|
|
526 |
|
|
527 |
if ( errcode != KErrNone )
|
|
528 |
{
|
|
529 |
delete callback;
|
|
530 |
User::Leave( errcode );
|
|
531 |
}
|
|
532 |
|
|
533 |
aOutParamList.AppendL(TLiwGenericParam( KTransactionID,
|
|
534 |
TLiwVariant( callback->iTransactionId )));
|
|
535 |
}
|
|
536 |
|
|
537 |
|
|
538 |
// ---------------------------------------------------------------------------
|
|
539 |
// Issues request for new message notifications to MessagingService
|
|
540 |
// ---------------------------------------------------------------------------
|
|
541 |
//
|
|
542 |
void CMessagingInterface::CancelNotificationL( const CLiwGenericParamList& aInParamList,
|
|
543 |
CLiwGenericParamList& /*aOutParamList*/,
|
|
544 |
TUint aCmdOptions,
|
|
545 |
MLiwNotifyCallback* aCallback )
|
|
546 |
{
|
|
547 |
LeaveIfAsynchronousL( aCmdOptions, aCallback, KCmdCancelNotification, KAsyncNotSupported );
|
|
548 |
|
|
549 |
TNotificationType notificationType;
|
|
550 |
GetNotificationTypeL( aInParamList, notificationType, KCmdCancelNotification );
|
|
551 |
User::LeaveIfError( iMsgService->CancelNotification( notificationType ));
|
|
552 |
}
|
|
553 |
|
|
554 |
// ---------------------------------------------------------------------------
|
|
555 |
// Issues request for delete message to MessagingService
|
|
556 |
// ---------------------------------------------------------------------------
|
|
557 |
//
|
|
558 |
void CMessagingInterface::DeleteMessageL( const CLiwGenericParamList& aInParamList,
|
|
559 |
CLiwGenericParamList& /*aOutParamList*/,
|
|
560 |
TUint aCmdOptions,
|
|
561 |
MLiwNotifyCallback* aCallback )
|
|
562 |
{
|
|
563 |
LeaveIfAsynchronousL( aCmdOptions, aCallback, KCmdDeleteMsg, KAsyncNotSupported );
|
|
564 |
|
|
565 |
TMsvId messageId;
|
|
566 |
|
|
567 |
GetMessageIdL( aInParamList, messageId , KCmdDeleteMsg);
|
|
568 |
|
|
569 |
if ( messageId > 0 )
|
|
570 |
{
|
|
571 |
iMsgService->DeleteMessageL( messageId );
|
|
572 |
}
|
|
573 |
else
|
|
574 |
{
|
|
575 |
AppendErrorMessageL( KCmdDeleteMsg, KMessageId, KIncorrectValue, 2 );
|
|
576 |
}
|
|
577 |
}
|
|
578 |
|
|
579 |
// ---------------------------------------------------------------------------
|
|
580 |
// Issues request for changing status of a message to MessagingService
|
|
581 |
// ---------------------------------------------------------------------------
|
|
582 |
//
|
|
583 |
void CMessagingInterface::ChangeStatusL( const CLiwGenericParamList& aInParamList,
|
|
584 |
CLiwGenericParamList& /*aOutParamList*/,
|
|
585 |
TUint aCmdOptions,
|
|
586 |
MLiwNotifyCallback* aCallback )
|
|
587 |
{
|
|
588 |
LeaveIfAsynchronousL( aCmdOptions, aCallback, KCmdChangeStatus, KAsyncNotSupported );
|
|
589 |
TMsvId messageId;
|
|
590 |
TMessageStatusFlag statusFlag;
|
|
591 |
TBool flagValue;
|
|
592 |
|
|
593 |
GetMessageIdL( aInParamList, messageId, KCmdChangeStatus );
|
|
594 |
GetStatusFlagAndValueL( aInParamList, statusFlag, flagValue, KCmdChangeStatus );
|
|
595 |
|
|
596 |
if ( messageId > 0 )
|
|
597 |
{
|
|
598 |
iMsgService->ChangeStatusL( messageId, statusFlag, flagValue );
|
|
599 |
}
|
|
600 |
else
|
|
601 |
{
|
|
602 |
AppendErrorMessageL( KCmdChangeStatus, KMessageId, KIncorrectValue, 2 );
|
|
603 |
}
|
|
604 |
}
|
|
605 |
|
|
606 |
// ---------------------------------------------------------------------------
|
|
607 |
// Gets the message id
|
|
608 |
// ---------------------------------------------------------------------------
|
|
609 |
//
|
|
610 |
void CMessagingInterface::GetMessageIdL( const CLiwGenericParamList& aInParamList,
|
|
611 |
TMsvId& aMessageId,
|
|
612 |
const TDesC8& aCmdName )
|
|
613 |
{
|
|
614 |
TInt pos = 0;
|
|
615 |
const TLiwGenericParam* param = aInParamList.FindFirst( pos, KMessageId );
|
|
616 |
|
|
617 |
if(!param && aInParamList.Count() )
|
|
618 |
{
|
|
619 |
param = &aInParamList[0];
|
|
620 |
|
|
621 |
if( param->Name().Compare( KNullDesC8 ) )
|
|
622 |
{
|
|
623 |
AppendErrorMessageL( aCmdName, KMessageId, KMissing, 1 );
|
|
624 |
}
|
|
625 |
}
|
|
626 |
|
|
627 |
|
|
628 |
if ( param && CheckInputTypeL( ¶m->Value(), ETrue, LIW::EVariantTypeTInt32, aCmdName, KMessageId, KTypeInvalid ) )
|
|
629 |
{
|
|
630 |
aMessageId = param->Value().AsTInt32();
|
|
631 |
return;
|
|
632 |
}
|
|
633 |
AppendErrorMessageL( aCmdName, KMessageId, KMissing, 1 );
|
|
634 |
}
|
|
635 |
|
|
636 |
// ---------------------------------------------------------------------------
|
|
637 |
// Gets the Transaction id
|
|
638 |
// ---------------------------------------------------------------------------
|
|
639 |
//
|
|
640 |
void CMessagingInterface::GetTransactionIdL( const CLiwGenericParamList& aInParamList,
|
|
641 |
TInt32& aTransactionId,
|
|
642 |
const TDesC8& aCmdName )
|
|
643 |
{
|
|
644 |
TInt pos = 0;
|
|
645 |
|
|
646 |
const TLiwGenericParam* param = aInParamList.FindFirst( pos,
|
|
647 |
KTransactionID );
|
|
648 |
if(!param && aInParamList.Count() )
|
|
649 |
{
|
|
650 |
param = &aInParamList[0];
|
|
651 |
|
|
652 |
if( param->Name().Compare( KNullDesC8 ) )
|
|
653 |
{
|
|
654 |
AppendErrorMessageL( aCmdName, KTransactionID, KMissing, 1 );
|
|
655 |
}
|
|
656 |
}
|
|
657 |
|
|
658 |
if ( param && CheckInputTypeL( ¶m->Value(), ETrue, LIW::EVariantTypeTInt32, aCmdName, KTransactionID, KTypeInvalid ) )
|
|
659 |
{
|
|
660 |
aTransactionId = param->Value().AsTInt32();
|
|
661 |
if( aTransactionId < 0 )
|
|
662 |
{
|
|
663 |
AppendErrorMessageL( aCmdName, KTransactionID, KIncorrectValue, 2 );
|
|
664 |
}
|
|
665 |
return;
|
|
666 |
}
|
|
667 |
AppendErrorMessageL( aCmdName, KTransactionID, KMissing, 1 );
|
|
668 |
}
|
|
669 |
|
|
670 |
// ---------------------------------------------------------------------------
|
|
671 |
// Gets the status flag and its value
|
|
672 |
// ---------------------------------------------------------------------------
|
|
673 |
//
|
|
674 |
void CMessagingInterface::GetStatusFlagAndValueL( const CLiwGenericParamList& aInParamList,
|
|
675 |
TMessageStatusFlag& aStatusFlag,
|
|
676 |
TBool& aFlagValue,
|
|
677 |
const TDesC8& aCmdName )
|
|
678 |
{
|
|
679 |
TInt pos = 0;
|
|
680 |
|
|
681 |
const TLiwGenericParam* paramMandatory = aInParamList.FindFirst( pos, KMessageId );
|
|
682 |
|
|
683 |
const TLiwGenericParam* param = NULL;
|
|
684 |
|
|
685 |
pos = 0;
|
|
686 |
if ( paramMandatory )
|
|
687 |
param = aInParamList.FindFirst( pos, KStatus );
|
|
688 |
else if( aInParamList.Count() > 1 )
|
|
689 |
param = &aInParamList[1];
|
|
690 |
|
|
691 |
if ( param && CheckInputTypeL( ¶m->Value(), ETrue, LIW::EVariantTypeDesC, aCmdName, KStatus, KTypeInvalid ) )
|
|
692 |
{
|
|
693 |
TPtrC value = param->Value().AsDes();
|
|
694 |
aFlagValue = ETrue;
|
|
695 |
if ( value.CompareF( KStatusFlagRead ) == 0 )
|
|
696 |
{
|
|
697 |
aStatusFlag = EUnread;
|
|
698 |
aFlagValue = EFalse;
|
|
699 |
}
|
|
700 |
else if ( value.CompareF( KStatusFlagUnread ) == 0 )
|
|
701 |
{
|
|
702 |
aStatusFlag = EUnread;
|
|
703 |
}
|
|
704 |
else if ( value.CompareF( KStatusFlagReplied ) == 0 )
|
|
705 |
{
|
|
706 |
aStatusFlag = EReplied;
|
|
707 |
}
|
|
708 |
else if ( value.CompareF( KStatusFlagForward ) == 0 )
|
|
709 |
{
|
|
710 |
aStatusFlag = EForward;
|
|
711 |
}
|
|
712 |
else if ( value.CompareF( KStatusFlagDeleted ) == 0 )
|
|
713 |
{
|
|
714 |
aStatusFlag = EDelete;
|
|
715 |
}
|
|
716 |
else
|
|
717 |
{
|
|
718 |
AppendErrorMessageL( aCmdName, KStatus, KIncorrectValue, 2 );
|
|
719 |
}
|
|
720 |
return;
|
|
721 |
}
|
|
722 |
AppendErrorMessageL( aCmdName, KStatus, KMissing, 1 );
|
|
723 |
}
|
|
724 |
|
|
725 |
// ---------------------------------------------------------------------------
|
|
726 |
// Gets the notification type
|
|
727 |
// ---------------------------------------------------------------------------
|
|
728 |
//
|
|
729 |
void CMessagingInterface::GetNotificationTypeL( const CLiwGenericParamList& aInParamList,
|
|
730 |
TNotificationType& aNotificationType,
|
|
731 |
const TDesC8& aCmdName )
|
|
732 |
{
|
|
733 |
TInt pos = 0;
|
|
734 |
const TLiwGenericParam* param = aInParamList.FindFirst( pos, KNotificationType );
|
|
735 |
|
|
736 |
if(!param && aInParamList.Count() )
|
|
737 |
{
|
|
738 |
param = &aInParamList[0];
|
|
739 |
if( param->Name().Compare( KNullDesC8 ) )
|
|
740 |
{
|
|
741 |
AppendErrorMessageL( aCmdName, KNotificationType, KMissing, 1 );
|
|
742 |
}
|
|
743 |
}
|
|
744 |
|
|
745 |
if ( param && CheckInputTypeL( ¶m->Value(), ETrue, LIW::EVariantTypeDesC, aCmdName, KNotificationType, KTypeInvalid) )
|
|
746 |
{
|
|
747 |
TPtrC notifType = param->Value().AsDes();
|
|
748 |
if( notifType.CompareF( KNotificationNewMsg ) == 0 )
|
|
749 |
{
|
|
750 |
aNotificationType = ENewMessage;
|
|
751 |
}
|
|
752 |
else
|
|
753 |
{
|
|
754 |
AppendErrorMessageL( aCmdName, KNotificationType, KIncorrectValue, 2 );
|
|
755 |
}
|
|
756 |
}
|
|
757 |
else
|
|
758 |
{
|
|
759 |
AppendErrorMessageL( aCmdName, KNotificationType, KMissing, 1 );
|
|
760 |
}
|
|
761 |
}
|
|
762 |
|
|
763 |
// ---------------------------------------------------------------------------
|
|
764 |
// Gets the param list for sending message form the inputparam list
|
|
765 |
// ---------------------------------------------------------------------------
|
|
766 |
//
|
|
767 |
CSendMessageParams* CMessagingInterface::GetSendParametersL(
|
|
768 |
const CLiwGenericParamList& aInParamList )
|
|
769 |
{
|
|
770 |
TInputValidator validator;
|
|
771 |
CSendMessageParams* sendParams = CSendMessageParams::NewL();
|
|
772 |
CleanupStack::PushL(sendParams);
|
|
773 |
|
|
774 |
TInt pos = 0;
|
|
775 |
TBool indexBaseInp = ETrue;
|
|
776 |
|
|
777 |
const TLiwGenericParam* inMessageType = aInParamList.FindFirst( pos, KMtm );
|
|
778 |
if ( inMessageType )
|
|
779 |
{
|
|
780 |
indexBaseInp = EFalse;
|
|
781 |
}
|
|
782 |
else
|
|
783 |
{
|
|
784 |
if( aInParamList.Count() )
|
|
785 |
{
|
|
786 |
inMessageType = &aInParamList[0];
|
|
787 |
if( inMessageType->Name().Compare( KNullDesC8 ) )
|
|
788 |
{
|
|
789 |
AppendErrorMessageL( KCmdSendMessage, KMtm, KMissing, 1 );
|
|
790 |
}
|
|
791 |
}
|
|
792 |
else
|
|
793 |
{
|
|
794 |
AppendErrorMessageL( KCmdSendMessage, KMtm, KMissing, 1 );
|
|
795 |
}
|
|
796 |
}
|
|
797 |
|
|
798 |
CheckInputTypeL( &inMessageType->Value(), ETrue, LIW::EVariantTypeDesC, KCmdSendMessage, KMtm, KTypeInvalid );
|
|
799 |
|
|
800 |
TPtrC type = inMessageType->Value().AsDes();
|
|
801 |
if( sendParams->SetMessageTypeL( type ) != KErrNone )
|
|
802 |
{
|
|
803 |
AppendErrorMessageL( KCmdSendMessage, KMtm, KIncorrectValue, 2 );
|
|
804 |
}
|
|
805 |
|
|
806 |
const TLiwGenericParam* inTmpParam = NULL;
|
|
807 |
|
|
808 |
// Read Recipient "To"
|
|
809 |
if ( indexBaseInp )
|
|
810 |
{
|
|
811 |
if ( aInParamList.Count() > 1 )
|
|
812 |
inTmpParam = &aInParamList[1];
|
|
813 |
}
|
|
814 |
else
|
|
815 |
{
|
|
816 |
pos = 0;
|
|
817 |
inTmpParam = aInParamList.FindFirst( pos, KRecipientTo );
|
|
818 |
}
|
|
819 |
|
|
820 |
if ( inTmpParam && CheckInputTypeL( &inTmpParam->Value(), ETrue, LIW::EVariantTypeDesC, KCmdSendMessage, KRecipientTo, KTypeInvalid ))
|
|
821 |
{
|
|
822 |
TPtrC recipient = inTmpParam->Value().AsDes();
|
|
823 |
if( validator.CheckValidNumberWithPlus( recipient ) )
|
|
824 |
{
|
|
825 |
sendParams->AddRecipientL(recipient, EMsvRecipientTo);
|
|
826 |
inTmpParam = NULL;
|
|
827 |
}
|
|
828 |
else
|
|
829 |
{
|
|
830 |
AppendErrorMessageL( KCmdSendMessage, KRecipientTo, KIncorrectValue, 2 );
|
|
831 |
}
|
|
832 |
}
|
|
833 |
else
|
|
834 |
{
|
|
835 |
AppendErrorMessageL( KCmdSendMessage, KRecipientTo, KMissing, 1 );
|
|
836 |
}
|
|
837 |
|
|
838 |
// Read BodyText
|
|
839 |
if ( indexBaseInp )
|
|
840 |
{
|
|
841 |
if ( aInParamList.Count() > 2 )
|
|
842 |
inTmpParam = &aInParamList[2];
|
|
843 |
}
|
|
844 |
else
|
|
845 |
{
|
|
846 |
pos = 0;
|
|
847 |
inTmpParam = aInParamList.FindFirst( pos, KBodyText );
|
|
848 |
}
|
|
849 |
|
|
850 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL
|
|
851 |
if ( inTmpParam && CheckInputTypeL( &inTmpParam->Value(), EFalse, LIW::EVariantTypeDesC, KCmdSendMessage, KBodyText, KTypeInvalid ) )
|
|
852 |
{
|
|
853 |
TPtrC bodytext = inTmpParam->Value().AsDes();
|
|
854 |
sendParams->SetBodyTextL( bodytext );
|
|
855 |
inTmpParam = NULL;
|
|
856 |
}
|
|
857 |
|
|
858 |
// Read Subject
|
|
859 |
if ( indexBaseInp )
|
|
860 |
{
|
|
861 |
if ( aInParamList.Count() > 3 )
|
|
862 |
inTmpParam = &aInParamList[3];
|
|
863 |
}
|
|
864 |
else
|
|
865 |
{
|
|
866 |
pos = 0;
|
|
867 |
inTmpParam = aInParamList.FindFirst( pos, KSubject );
|
|
868 |
}
|
|
869 |
|
|
870 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL
|
|
871 |
if ( inTmpParam && CheckInputTypeL( &inTmpParam->Value(), EFalse, LIW::EVariantTypeDesC, KCmdSendMessage, KSubject, KTypeInvalid ) )
|
|
872 |
{
|
|
873 |
TPtrC subject = inTmpParam->Value().AsDes();
|
|
874 |
sendParams->SetSubjectL( subject );
|
|
875 |
inTmpParam = NULL;
|
|
876 |
}
|
|
877 |
|
|
878 |
// Read Attachment
|
|
879 |
if ( indexBaseInp )
|
|
880 |
{
|
|
881 |
if ( aInParamList.Count() > 4 )
|
|
882 |
inTmpParam = &aInParamList[4];
|
|
883 |
}
|
|
884 |
else
|
|
885 |
{
|
|
886 |
pos = 0;
|
|
887 |
inTmpParam = aInParamList.FindFirst( pos, KAttachmentName );
|
|
888 |
}
|
|
889 |
|
|
890 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL
|
|
891 |
if ( inTmpParam && CheckInputTypeL( &inTmpParam->Value(), EFalse, LIW::EVariantTypeDesC, KCmdSendMessage, KAttachmentName, KTypeInvalid ) )
|
|
892 |
{
|
|
893 |
TBuf<KMaxFileName> attachmentfile;
|
|
894 |
TBuf8<KMaxFileName> mimeType;
|
|
895 |
|
|
896 |
if( ! validator.CheckDesSize(inTmpParam->Value().AsDes()) )
|
|
897 |
{
|
|
898 |
AppendErrorMessageL( KCmdSendMessage, KAttachmentName, KIncorrectValue, 2 );
|
|
899 |
}
|
|
900 |
|
|
901 |
attachmentfile.Copy( inTmpParam->Value().AsDes() );
|
|
902 |
inTmpParam = NULL;
|
|
903 |
|
|
904 |
if(attachmentfile.Length())
|
|
905 |
{
|
|
906 |
// Read Attachment Mime type
|
|
907 |
if ( indexBaseInp )
|
|
908 |
{
|
|
909 |
if ( aInParamList.Count() > 5 )
|
|
910 |
inTmpParam = &aInParamList[5];
|
|
911 |
}
|
|
912 |
else
|
|
913 |
{
|
|
914 |
pos = 0;
|
|
915 |
inTmpParam = aInParamList.FindFirst( pos, KMimeType );
|
|
916 |
}
|
|
917 |
|
|
918 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL
|
|
919 |
if ( inTmpParam && CheckInputTypeL( &inTmpParam->Value(), EFalse, LIW::EVariantTypeDesC, KCmdSendMessage, KMimeType, KTypeInvalid ) )
|
|
920 |
{
|
|
921 |
if( ! validator.CheckDesSize( inTmpParam->Value().AsDes() ) )
|
|
922 |
{
|
|
923 |
AppendErrorMessageL( KCmdSendMessage, KMimeType, KIncorrectValue, 2 );
|
|
924 |
}
|
|
925 |
mimeType.Copy( inTmpParam->Value().AsDes() );
|
|
926 |
}
|
|
927 |
|
|
928 |
inTmpParam = NULL;
|
|
929 |
|
|
930 |
CMsvAttachment* attachment = CMsvAttachment::NewL( CMsvAttachment::EMsvFile );
|
|
931 |
|
|
932 |
CleanupStack::PushL(attachment);
|
|
933 |
|
|
934 |
attachment->SetAttachmentNameL( attachmentfile );
|
|
935 |
|
|
936 |
if ( mimeType.Length() )
|
|
937 |
attachment->SetMimeTypeL( mimeType );
|
|
938 |
|
|
939 |
sendParams->AddAttachmentL( attachment );
|
|
940 |
|
|
941 |
CleanupStack::Pop(attachment);
|
|
942 |
}
|
|
943 |
}
|
|
944 |
|
|
945 |
const TLiwGenericParam* inMessageParam = NULL;
|
|
946 |
|
|
947 |
if ( indexBaseInp )
|
|
948 |
{
|
|
949 |
if ( aInParamList.Count() > 6 )
|
|
950 |
inMessageParam = &aInParamList[6];
|
|
951 |
}
|
|
952 |
else
|
|
953 |
{
|
|
954 |
pos = 0;
|
|
955 |
inMessageParam = aInParamList.FindFirst( pos, KMessageParam );
|
|
956 |
}
|
|
957 |
|
|
958 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL
|
|
959 |
if ( inMessageParam && CheckInputTypeL( &inMessageParam->Value(), EFalse, LIW::EVariantTypeMap, KCmdSendMessage, KMessageParam, KTypeInvalid ) )
|
|
960 |
{
|
|
961 |
const CLiwMap* inMap = inMessageParam->Value().AsMap();
|
|
962 |
|
|
963 |
if(inMap)
|
|
964 |
{
|
|
965 |
|
|
966 |
TLiwVariant inParam;
|
|
967 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &inParam) );
|
|
968 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL
|
|
969 |
if ( inMap->FindL( KTemplateId, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeTInt32, KCmdSendMessage, KTemplateId, KTypeInvalid ) )
|
|
970 |
{
|
|
971 |
sendParams->SetTemplateId( (TMsvId)(inParam.AsTInt32()) );
|
|
972 |
}
|
|
973 |
|
|
974 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL
|
|
975 |
if ( inMap->FindL( KLaunchEditor, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeTBool, KCmdSendMessage, KLaunchEditor, KTypeInvalid ) )
|
|
976 |
{
|
|
977 |
sendParams->SetLaunchEditor( inParam.AsTBool() );
|
|
978 |
}
|
|
979 |
|
|
980 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL
|
|
981 |
if ( inMap->FindL( KRecipientTo, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeList, KCmdSendMessage, KRecipientTo, KTypeInvalid ) )
|
|
982 |
{
|
|
983 |
CLiwList* obj = (CLiwList*)(inParam.AsList());
|
|
984 |
|
|
985 |
|
|
986 |
for ( int index = 0; index < obj->Count(); index++ )
|
|
987 |
{
|
|
988 |
TLiwVariant element;
|
|
989 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &element) );
|
|
990 |
obj->AtL(index, element);
|
|
991 |
|
|
992 |
if( CheckInputTypeL( &element, EFalse, LIW::EVariantTypeDesC, KCmdSendMessage, KRecipientToElement, KTypeInvalid ) )
|
|
993 |
{
|
|
994 |
if( validator.CheckValidNumberWithPlus( element.AsDes() ) )
|
|
995 |
{
|
|
996 |
sendParams->AddRecipientL( element.AsDes(), EMsvRecipientTo);
|
|
997 |
}
|
|
998 |
else
|
|
999 |
{
|
|
1000 |
AppendErrorMessageL( KCmdSendMessage, KRecipientToElement, KIncorrectValue, 2 );
|
|
1001 |
}
|
|
1002 |
}
|
|
1003 |
CleanupStack::PopAndDestroy( &element );
|
|
1004 |
//element.Reset();
|
|
1005 |
}
|
|
1006 |
}
|
|
1007 |
|
|
1008 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL
|
|
1009 |
if ( inMap->FindL( KRecipientCc, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeList, KCmdSendMessage, KRecipientCc, KTypeInvalid ) )
|
|
1010 |
{
|
|
1011 |
CLiwList* obj = (CLiwList*)(inParam.AsList());
|
|
1012 |
|
|
1013 |
|
|
1014 |
for ( int index = 0; index < obj->Count(); index++ )
|
|
1015 |
{
|
|
1016 |
TLiwVariant element;
|
|
1017 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &element) );
|
|
1018 |
obj->AtL(index, element);
|
|
1019 |
|
|
1020 |
if( CheckInputTypeL( &element, EFalse, LIW::EVariantTypeDesC, KCmdSendMessage, KRecipientCcElement, KTypeInvalid ) )
|
|
1021 |
{
|
|
1022 |
if( validator.CheckValidNumberWithPlus( element.AsDes() ) )
|
|
1023 |
{
|
|
1024 |
sendParams->AddRecipientL( element.AsDes(), EMsvRecipientTo);
|
|
1025 |
}
|
|
1026 |
else
|
|
1027 |
{
|
|
1028 |
AppendErrorMessageL( KCmdSendMessage, KRecipientCcElement, KIncorrectValue, 2 );
|
|
1029 |
}
|
|
1030 |
}
|
|
1031 |
CleanupStack::PopAndDestroy( &element );
|
|
1032 |
//element.Reset();
|
|
1033 |
}
|
|
1034 |
}
|
|
1035 |
|
|
1036 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL
|
|
1037 |
if ( inMap->FindL( KRecipientBcc, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeList, KCmdSendMessage, KRecipientBcc, KTypeInvalid ) )
|
|
1038 |
{
|
|
1039 |
CLiwList* obj = (CLiwList*)(inParam.AsList());
|
|
1040 |
|
|
1041 |
|
|
1042 |
for ( int index = 0; index < obj->Count(); index++ )
|
|
1043 |
{
|
|
1044 |
TLiwVariant element;
|
|
1045 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &element) );
|
|
1046 |
obj->AtL(index, element);
|
|
1047 |
|
|
1048 |
if( CheckInputTypeL( &element, EFalse, LIW::EVariantTypeDesC, KCmdSendMessage, KRecipientBccElement, KTypeInvalid ) )
|
|
1049 |
{
|
|
1050 |
if( validator.CheckValidNumberWithPlus( element.AsDes() ) )
|
|
1051 |
{
|
|
1052 |
sendParams->AddRecipientL( element.AsDes(), EMsvRecipientTo);
|
|
1053 |
}
|
|
1054 |
else
|
|
1055 |
{
|
|
1056 |
AppendErrorMessageL( KCmdSendMessage, KRecipientBccElement, KIncorrectValue, 2 );
|
|
1057 |
}
|
|
1058 |
}
|
|
1059 |
CleanupStack::PopAndDestroy( &element );
|
|
1060 |
//element.Reset();
|
|
1061 |
}
|
|
1062 |
}
|
|
1063 |
|
|
1064 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL
|
|
1065 |
if ( inMap->FindL( KAttachmentList, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeList, KCmdSendMessage, KAttachmentList, KTypeInvalid ) )
|
|
1066 |
{
|
|
1067 |
CLiwList* obj = (CLiwList*)(inParam.AsList());
|
|
1068 |
|
|
1069 |
if( obj && ( obj->Count() > 0 ) )
|
|
1070 |
{
|
|
1071 |
for ( int index = 0; index < obj->Count(); index++ )
|
|
1072 |
{
|
|
1073 |
TLiwVariant list;
|
|
1074 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &list) );
|
|
1075 |
if( obj->AtL(index, list) && CheckInputTypeL( &list, EFalse, LIW::EVariantTypeMap, KCmdSendMessage, KAttachmentListElement, KTypeInvalid ) )
|
|
1076 |
{
|
|
1077 |
CLiwMap* map = (CLiwMap*)(list.AsMap());
|
|
1078 |
|
|
1079 |
TLiwVariant element;
|
|
1080 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &element) );
|
|
1081 |
TBuf<KMaxFileName> fileName;
|
|
1082 |
if ( map->FindL(KFileName, element) && CheckInputTypeL( &element, EFalse, LIW::EVariantTypeDesC, KCmdSendMessage, KFileName, KTypeInvalid ) )
|
|
1083 |
{
|
|
1084 |
if( ! validator.CheckDesSize( element.AsDes() ) )
|
|
1085 |
{
|
|
1086 |
AppendErrorMessageL( KCmdSendMessage, KFileName, KIncorrectValue, 2 );
|
|
1087 |
}
|
|
1088 |
fileName.Copy( element.AsDes() );
|
|
1089 |
element.Reset();
|
|
1090 |
}
|
|
1091 |
|
|
1092 |
CMsvAttachment::TMsvAttachmentType fltype = CMsvAttachment::EMsvFile;
|
|
1093 |
if ( map->FindL(KAttachmentType, element) && CheckInputTypeL( &element, EFalse, LIW::EVariantTypeDesC, KCmdSendMessage, KAttachmentType, KTypeInvalid ) )
|
|
1094 |
{
|
|
1095 |
TPtrC fileType = element.AsDes();
|
|
1096 |
if ( fileType.CompareF( KAttachmentLinkedFile ) == 0 )
|
|
1097 |
fltype = CMsvAttachment::EMsvLinkedFile;
|
|
1098 |
if ( fileType.CompareF( KAttachmentFile ) != 0 )
|
|
1099 |
User::Leave( ErrCodeConversion(KErrNotSupported));
|
|
1100 |
element.Reset();
|
|
1101 |
}
|
|
1102 |
|
|
1103 |
TBuf8<KMaxFileName> mimeType;
|
|
1104 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL
|
|
1105 |
if ( map->FindL(KMimeType, element) && CheckInputTypeL( &element, EFalse, LIW::EVariantTypeDesC, KCmdSendMessage, KMimeType, KTypeInvalid ) )
|
|
1106 |
{
|
|
1107 |
if( ! validator.CheckDesSize( element.AsDes() ) )
|
|
1108 |
{
|
|
1109 |
AppendErrorMessageL( KCmdSendMessage, KMimeType, KIncorrectValue, 2 );
|
|
1110 |
}
|
|
1111 |
mimeType.Copy( element.AsDes() );
|
|
1112 |
}
|
|
1113 |
CleanupStack::PopAndDestroy( &element );
|
|
1114 |
//element.Reset();
|
|
1115 |
|
|
1116 |
CMsvAttachment* attachment = CMsvAttachment::NewL(fltype);
|
|
1117 |
CleanupStack::PushL(attachment);
|
|
1118 |
attachment->SetAttachmentNameL( fileName );
|
|
1119 |
if ( mimeType.Length() )
|
|
1120 |
attachment->SetMimeTypeL( mimeType );
|
|
1121 |
|
|
1122 |
sendParams->AddAttachmentL( attachment );
|
|
1123 |
|
|
1124 |
CleanupStack::Pop(attachment);
|
|
1125 |
}
|
|
1126 |
CleanupStack::PopAndDestroy( &list );
|
|
1127 |
//list.Reset();
|
|
1128 |
}
|
|
1129 |
}
|
|
1130 |
}
|
|
1131 |
CleanupStack::PopAndDestroy( &inParam );
|
|
1132 |
//inParam.Reset();
|
|
1133 |
}
|
|
1134 |
|
|
1135 |
}
|
|
1136 |
|
|
1137 |
CleanupStack::Pop( sendParams );
|
|
1138 |
return sendParams;
|
|
1139 |
}
|
|
1140 |
|
|
1141 |
// ---------------------------------------------------------------------------
|
|
1142 |
// Gives the sort type
|
|
1143 |
// ---------------------------------------------------------------------------
|
|
1144 |
//
|
|
1145 |
TMsvSorting CMessagingInterface::SortType( const TDesC& aSortField, const TDesC& aSortOrder )
|
|
1146 |
{
|
|
1147 |
TMsvSorting retValue = EMsvSortByNone;//this indicates mismatch in either the sortfield or sortorder
|
|
1148 |
|
|
1149 |
if ( aSortOrder.CompareF( KSortAsc)== 0 )
|
|
1150 |
{
|
|
1151 |
if ( aSortField.CompareF( KSortByDate ) == 0 )
|
|
1152 |
retValue = EMsvSortByDate;
|
|
1153 |
else if ( aSortField.CompareF( KSortBySize ) == 0 )
|
|
1154 |
retValue = EMsvSortBySize;
|
|
1155 |
else if ( aSortField.CompareF( KSortBySender ) == 0 )
|
|
1156 |
retValue = EMsvSortByDetails;
|
|
1157 |
else if ( aSortField.CompareF( KSortBySubject ) == 0 )
|
|
1158 |
retValue = EMsvSortByDescription;
|
|
1159 |
else if ( aSortField.CompareF( KSortById ) == 0 )
|
|
1160 |
retValue = EMsvSortById;
|
|
1161 |
}
|
|
1162 |
else if ( aSortOrder.CompareF( KSortDec) == 0 )
|
|
1163 |
{
|
|
1164 |
if ( aSortField.CompareF( KSortByDate ) == 0 )
|
|
1165 |
retValue = EMsvSortByDateReverse;
|
|
1166 |
else if ( aSortField.CompareF( KSortBySize ) == 0 )
|
|
1167 |
retValue = EMsvSortBySizeReverse;
|
|
1168 |
else if ( aSortField.CompareF( KSortBySender ) == 0 )
|
|
1169 |
retValue = EMsvSortByDetailsReverse;
|
|
1170 |
else if ( aSortField.CompareF( KSortBySubject ) == 0 )
|
|
1171 |
retValue = EMsvSortByDescriptionReverse;
|
|
1172 |
else if ( aSortField.CompareF( KSortById ) == 0 )
|
|
1173 |
retValue = EMsvSortByIdReverse;
|
|
1174 |
}
|
|
1175 |
|
|
1176 |
return retValue;
|
|
1177 |
}
|
|
1178 |
|
|
1179 |
// ---------------------------------------------------------------------------
|
|
1180 |
// Gets the filter parameters and sorting option from the inputparam list
|
|
1181 |
// ---------------------------------------------------------------------------
|
|
1182 |
//
|
|
1183 |
CFilterParamInfo* CMessagingInterface::GetFilterParametersL(
|
|
1184 |
const CLiwGenericParamList& aInParamList, TBool aIndexBaseInp )
|
|
1185 |
{
|
|
1186 |
TInputValidator validator;
|
|
1187 |
TInt pos = 0 ;
|
|
1188 |
CFilterParamInfo* filterparam = CFilterParamInfo::NewL();
|
|
1189 |
CleanupStack::PushL( filterparam );
|
|
1190 |
|
|
1191 |
const TLiwGenericParam* filter = NULL;
|
|
1192 |
|
|
1193 |
if ( aIndexBaseInp )
|
|
1194 |
{
|
|
1195 |
if ( aInParamList.Count() > 1 )
|
|
1196 |
filter = &aInParamList[1];
|
|
1197 |
}
|
|
1198 |
else
|
|
1199 |
{
|
|
1200 |
pos = 0 ;
|
|
1201 |
filter = aInParamList.FindFirst( pos, KFilter );
|
|
1202 |
}
|
|
1203 |
|
|
1204 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL
|
|
1205 |
if ( filter && CheckInputTypeL( &filter->Value(), EFalse, LIW::EVariantTypeMap, KCmdGetHeaderList, KFilter, KTypeInvalid ) )
|
|
1206 |
{
|
|
1207 |
const CLiwMap* inputMap = filter->Value().AsMap();
|
|
1208 |
|
|
1209 |
if ( inputMap )
|
|
1210 |
{
|
|
1211 |
// FromArray
|
|
1212 |
TLiwVariant inParam;
|
|
1213 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &inParam) );
|
|
1214 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL
|
|
1215 |
if ( inputMap->FindL( KSenderList, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeList, KCmdGetHeaderList, KSenderList, KTypeInvalid ) )
|
|
1216 |
{
|
|
1217 |
CLiwList* obj = (CLiwList*)( inParam.AsList() );
|
|
1218 |
for ( int index = 0; index < obj->Count(); index++ )
|
|
1219 |
{
|
|
1220 |
TLiwVariant element;
|
|
1221 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &element) );
|
|
1222 |
if( obj->AtL(index, element) && CheckInputTypeL( &element, EFalse, LIW::EVariantTypeDesC, KCmdGetHeaderList, KSenderElement, KTypeInvalid ) )
|
|
1223 |
{
|
|
1224 |
TPtrC fromaddr = element.AsDes();
|
|
1225 |
filterparam->AddFromL(fromaddr);
|
|
1226 |
|
|
1227 |
//This check needs to be relaxed
|
|
1228 |
/*if( validator.CheckValidNumberWithPlus( fromaddr ) )
|
|
1229 |
{
|
|
1230 |
filterparam->AddFromL(fromaddr);
|
|
1231 |
}
|
|
1232 |
else
|
|
1233 |
{
|
|
1234 |
AppendErrorMessageL( KCmdGetHeaderList, KSenderElement, KIncorrectValue, 2 );
|
|
1235 |
} */
|
|
1236 |
}
|
|
1237 |
CleanupStack::PopAndDestroy( &element );
|
|
1238 |
//element.Reset();
|
|
1239 |
}
|
|
1240 |
}
|
|
1241 |
|
|
1242 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL
|
|
1243 |
// Mtmarray
|
|
1244 |
if ( inputMap->FindL( KMtmList, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeList, KCmdGetHeaderList, KMtmList, KTypeInvalid ) )
|
|
1245 |
{
|
|
1246 |
CLiwList* obj = (CLiwList*)( inParam.AsList() );
|
|
1247 |
|
|
1248 |
|
|
1249 |
|
|
1250 |
for ( int index = 0; index < obj->Count(); index++ )
|
|
1251 |
{
|
|
1252 |
TLiwVariant element;
|
|
1253 |
CleanupStack::PushL( TCleanupItem( TLiwVariant::VariantCleanup , &element) );
|
|
1254 |
if( obj->AtL(index, element) && CheckInputTypeL( &element, EFalse, LIW::EVariantTypeDesC, KCmdGetHeaderList, KMtmElement, KTypeInvalid ) )
|
|
1255 |
{
|
|
1256 |
TPtrC mtm = element.AsDes();
|
|
1257 |
if( filterparam->AddMtmL(mtm) != KErrNone )
|
|
1258 |
{
|
|
1259 |
AppendErrorMessageL( KCmdGetHeaderList, KMtmElement, KIncorrectValue, 2 );
|
|
1260 |
}
|
|
1261 |
}
|
|
1262 |
CleanupStack::PopAndDestroy( &element );
|
|
1263 |
//element.Reset();
|
|
1264 |
}
|
|
1265 |
}
|
|
1266 |
|
|
1267 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL
|
|
1268 |
// Subject
|
|
1269 |
if ( inputMap->FindL( KSubject, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeDesC, KCmdGetHeaderList, KSubject, KTypeInvalid ) )
|
|
1270 |
{
|
|
1271 |
TPtrC obj = inParam.AsDes();
|
|
1272 |
filterparam->SetSubjectL(obj);
|
|
1273 |
}
|
|
1274 |
|
|
1275 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL
|
|
1276 |
//MessageId
|
|
1277 |
if ( inputMap->FindL( KMessageId, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeTInt32, KCmdGetHeaderList, KMessageId, KTypeInvalid ) )
|
|
1278 |
{
|
|
1279 |
TInt32 messageid = (TInt32)inParam.AsTInt32();
|
|
1280 |
|
|
1281 |
filterparam->SetMessageIdFilter( messageid );
|
|
1282 |
}
|
|
1283 |
|
|
1284 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL
|
|
1285 |
//StartDate
|
|
1286 |
TTime startDate = Time::NullTTime();
|
|
1287 |
if ( inputMap->FindL( KStartDate, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeTTime, KCmdGetHeaderList, KStartDate, KTypeInvalid ) )
|
|
1288 |
{
|
|
1289 |
startDate = inParam.AsTTime();
|
|
1290 |
|
|
1291 |
filterparam->SetStartDateFilter( startDate );
|
|
1292 |
}
|
|
1293 |
|
|
1294 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL
|
|
1295 |
//EndDate
|
|
1296 |
TTime endDate = Time::NullTTime();
|
|
1297 |
if ( inputMap->FindL( KEndDate, inParam ) && CheckInputTypeL( &inParam, EFalse, LIW::EVariantTypeTTime, KCmdGetHeaderList, KEndDate, KTypeInvalid ) )
|
|
1298 |
{
|
|
1299 |
endDate = inParam.AsTTime();
|
|
1300 |
|
|
1301 |
filterparam->SetEndDate( endDate );
|
|
1302 |
}
|
|
1303 |
|
|
1304 |
if( ( startDate != Time::NullTTime() && endDate != Time::NullTTime() ) &&
|
|
1305 |
startDate > endDate )
|
|
1306 |
{
|
|
1307 |
AppendErrorMessageL( KCmdGetHeaderList, KStartDate, KDateMismatch, 2 );
|
|
1308 |
}
|
|
1309 |
|
|
1310 |
CleanupStack::PopAndDestroy( &inParam );
|
|
1311 |
//inParam.Reset();
|
|
1312 |
}
|
|
1313 |
|
|
1314 |
}
|
|
1315 |
|
|
1316 |
//SortType
|
|
1317 |
const TLiwGenericParam* sortOrder = NULL;
|
|
1318 |
if ( aIndexBaseInp )
|
|
1319 |
{
|
|
1320 |
if( aInParamList.Count() > 2 )
|
|
1321 |
sortOrder = &aInParamList[2];
|
|
1322 |
}
|
|
1323 |
else
|
|
1324 |
{
|
|
1325 |
pos = 0 ;
|
|
1326 |
sortOrder = aInParamList.FindFirst( pos, KSortOrder );
|
|
1327 |
}
|
|
1328 |
|
|
1329 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL
|
|
1330 |
if ( sortOrder && CheckInputTypeL( &sortOrder->Value(), EFalse, LIW::EVariantTypeMap, KCmdGetHeaderList, KSortOrder, KTypeInvalid ) )
|
|
1331 |
{
|
|
1332 |
const CLiwMap* sortMap = sortOrder->Value().AsMap();
|
|
1333 |
if ( sortMap )
|
|
1334 |
{
|
|
1335 |
TLiwVariant sortParam;
|
|
1336 |
|
|
1337 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL
|
|
1338 |
if ( sortMap->FindL( KField, sortParam ) && CheckInputTypeL( &sortParam, EFalse, LIW::EVariantTypeDesC, KCmdGetHeaderList, KField, KTypeInvalid ) )
|
|
1339 |
{
|
|
1340 |
HBufC* sordField = sortParam.AsDes().AllocL();
|
|
1341 |
CleanupStack::PushL( sordField );
|
|
1342 |
|
|
1343 |
//this is an optional parameter so check for not null constraint, ignore this in case of NULL
|
|
1344 |
if ( sortMap->FindL( KOrder, sortParam ) && CheckInputTypeL( &sortParam, EFalse, LIW::EVariantTypeDesC, KCmdGetHeaderList, KOrder, KTypeInvalid ) )
|
|
1345 |
{
|
|
1346 |
TPtrC sortOrder = sortParam.AsDes();
|
|
1347 |
TMsvSorting sortCriterion = SortType( *sordField, sortOrder );
|
|
1348 |
if( sortCriterion == EMsvSortByNone )
|
|
1349 |
{
|
|
1350 |
sortParam.Reset();
|
|
1351 |
AppendErrorMessageL( KCmdGetHeaderList, KSortOrder, KIncorrectValue, 2 );
|
|
1352 |
}
|
|
1353 |
else
|
|
1354 |
filterparam->SetSortType( sortCriterion );
|
|
1355 |
}
|
|
1356 |
|
|
1357 |
CleanupStack::PopAndDestroy( sordField );
|
|
1358 |
}
|
|
1359 |
sortParam.Reset();
|
|
1360 |
}
|
|
1361 |
}
|
|
1362 |
|
|
1363 |
|
|
1364 |
|
|
1365 |
CleanupStack::Pop( filterparam );
|
|
1366 |
return filterparam;
|
|
1367 |
}
|
|
1368 |
|
|
1369 |
// ---------------------------------------------------------------------------
|
|
1370 |
// Two-phase Constructor
|
|
1371 |
// ---------------------------------------------------------------------------
|
|
1372 |
//
|
|
1373 |
CMsgCallbackHeader* CMsgCallbackHeader::NewL()
|
|
1374 |
{
|
|
1375 |
CMsgCallbackHeader* self = new (ELeave) CMsgCallbackHeader();
|
|
1376 |
return self;
|
|
1377 |
}
|
|
1378 |
|
|
1379 |
// ---------------------------------------------------------------------------
|
|
1380 |
// Destructor
|
|
1381 |
// ---------------------------------------------------------------------------
|
|
1382 |
//
|
|
1383 |
CMsgCallbackHeader::~CMsgCallbackHeader()
|
|
1384 |
{
|
|
1385 |
}
|
|
1386 |
|
|
1387 |
// ---------------------------------------------------------------------------
|
|
1388 |
// Constructor
|
|
1389 |
// ---------------------------------------------------------------------------
|
|
1390 |
//
|
|
1391 |
CMsgCallbackHeader::CMsgCallbackHeader()
|
|
1392 |
{
|
|
1393 |
}
|
|
1394 |
|
|
1395 |
// ---------------------------------------------------------------------------
|
|
1396 |
// Gives the result of asynchronous SAPI
|
|
1397 |
// ---------------------------------------------------------------------------
|
|
1398 |
//
|
|
1399 |
void CMsgCallbackHeader::NotifyResultL( TInt aErrCode, TAny* aResult )
|
|
1400 |
{
|
|
1401 |
CLiwGenericParamList* outParams = CLiwGenericParamList::NewL();
|
|
1402 |
|
|
1403 |
CleanupStack::PushL( outParams );
|
|
1404 |
|
|
1405 |
outParams->AppendL(TLiwGenericParam(KErrorCode,
|
|
1406 |
TLiwVariant(ErrCodeConversion(aErrCode))));
|
|
1407 |
|
|
1408 |
if ( aErrCode == KErrNone && aResult )
|
|
1409 |
{
|
|
1410 |
UpdateOutputAsHeaderL( outParams, aResult );
|
|
1411 |
}
|
|
1412 |
|
|
1413 |
TInt event = KLiwEventInProgress;
|
|
1414 |
|
|
1415 |
if ( aErrCode == KErrCancel )
|
|
1416 |
{
|
|
1417 |
event = KLiwEventCanceled;
|
|
1418 |
}
|
|
1419 |
else if ( aErrCode != KErrNone )
|
|
1420 |
{
|
|
1421 |
event = KLiwEventStopped;
|
|
1422 |
}
|
|
1423 |
|
|
1424 |
((MLiwNotifyCallback*)iPtrNotifyCallback)->HandleNotifyL( iTransactionId,
|
|
1425 |
event,
|
|
1426 |
*(outParams),
|
|
1427 |
*((CLiwGenericParamList*)iPtrInParamList) );
|
|
1428 |
|
|
1429 |
CleanupStack::PopAndDestroy( outParams );
|
|
1430 |
}
|
|
1431 |
|
|
1432 |
|
|
1433 |
// ---------------------------------------------------------------------------
|
|
1434 |
// Two-phase Constructor
|
|
1435 |
// ---------------------------------------------------------------------------
|
|
1436 |
//
|
|
1437 |
CMsgCallbackBase* CMsgCallbackInt::NewL()
|
|
1438 |
{
|
|
1439 |
return new (ELeave) CMsgCallbackInt;
|
|
1440 |
}
|
|
1441 |
|
|
1442 |
// ---------------------------------------------------------------------------
|
|
1443 |
// Constructor
|
|
1444 |
// ---------------------------------------------------------------------------
|
|
1445 |
//
|
|
1446 |
CMsgCallbackInt::CMsgCallbackInt()
|
|
1447 |
{
|
|
1448 |
}
|
|
1449 |
|
|
1450 |
// ---------------------------------------------------------------------------
|
|
1451 |
// Gives the result of asynchronous SAPI
|
|
1452 |
// ---------------------------------------------------------------------------
|
|
1453 |
//
|
|
1454 |
void CMsgCallbackInt::NotifyResultL( TInt aErrCode, TAny* /*aResult*/ )
|
|
1455 |
{
|
|
1456 |
CLiwGenericParamList* outParams = CLiwGenericParamList::NewL();
|
|
1457 |
|
|
1458 |
CleanupStack::PushL( outParams );
|
|
1459 |
|
|
1460 |
outParams->AppendL(TLiwGenericParam(KErrorCode,
|
|
1461 |
TLiwVariant(ErrCodeConversion(aErrCode))));
|
|
1462 |
|
|
1463 |
TInt event = KLiwEventCompleted;
|
|
1464 |
if ( aErrCode == KErrCancel )
|
|
1465 |
{
|
|
1466 |
event = KLiwEventCanceled;
|
|
1467 |
}
|
|
1468 |
else if ( aErrCode != KErrNone )
|
|
1469 |
{
|
|
1470 |
event = KLiwEventStopped;
|
|
1471 |
}
|
|
1472 |
|
|
1473 |
((MLiwNotifyCallback*)iPtrNotifyCallback)->HandleNotifyL( iTransactionId,
|
|
1474 |
event,
|
|
1475 |
*(outParams),
|
|
1476 |
*((CLiwGenericParamList*)iPtrInParamList) );
|
|
1477 |
|
|
1478 |
CleanupStack::PopAndDestroy( outParams );
|
|
1479 |
}
|
|
1480 |
|
|
1481 |
// ---------------------------------------------------------------------------
|
|
1482 |
// Updates the output for message header
|
|
1483 |
// ---------------------------------------------------------------------------
|
|
1484 |
//
|
|
1485 |
void UpdateOutputAsHeaderL( CLiwGenericParamList* aOutParamList, TAny* aResult )
|
|
1486 |
{
|
|
1487 |
CMessageHeader* header = (CMessageHeader*)aResult;
|
|
1488 |
TLiwVariant newElement;
|
|
1489 |
if( GetLiwHeaderL( header, newElement ) )
|
|
1490 |
{
|
|
1491 |
aOutParamList->AppendL( TLiwGenericParam( KReturnValue/*KMessage*/, newElement ));
|
|
1492 |
}
|
|
1493 |
newElement.Reset();
|
|
1494 |
}
|
|
1495 |
|
|
1496 |
// ---------------------------------------------------------------------------
|
|
1497 |
// Gets the message header
|
|
1498 |
// ---------------------------------------------------------------------------
|
|
1499 |
//
|
|
1500 |
TBool GetLiwHeaderL( CMessageHeader* aHeader, TLiwVariant& aElement,
|
|
1501 |
CMessagingService* aMsgService,
|
|
1502 |
TBool aCustomMap )
|
|
1503 |
{
|
|
1504 |
if(aHeader)
|
|
1505 |
{
|
|
1506 |
CLiwMap* map = NULL;
|
|
1507 |
if ( aCustomMap )
|
|
1508 |
map = CLiwMessagingMap::NewL( aMsgService );
|
|
1509 |
else
|
|
1510 |
map = CLiwDefaultMap::NewL();
|
|
1511 |
|
|
1512 |
CleanupClosePushL( *map );//CleanupStack::PushL(map);
|
|
1513 |
|
|
1514 |
map->InsertL( KUnreadFlag, TLiwVariant( aHeader->UnreadFlag() ) );
|
|
1515 |
map->InsertL( KAttachFlag, TLiwVariant( aHeader->AttachFlag() ) );
|
|
1516 |
map->InsertL( KPriority, TLiwVariant( aHeader->Priority() ) );
|
|
1517 |
map->InsertL( KMessageId, TLiwVariant( aHeader->MessageId() ) );
|
|
1518 |
map->InsertL( KTime, TLiwVariant( aHeader->Time() ) );
|
|
1519 |
map->InsertL( KSender, TLiwVariant( aHeader->From() ) );
|
|
1520 |
map->InsertL( KSubject, TLiwVariant( aHeader->Subject() ) );
|
|
1521 |
map->InsertL( KMtm, TLiwVariant( aHeader->Mtm() ) );
|
|
1522 |
|
|
1523 |
aElement.SetL( map );
|
|
1524 |
|
|
1525 |
CleanupStack::PopAndDestroy(map);
|
|
1526 |
|
|
1527 |
//map->DecRef();
|
|
1528 |
|
|
1529 |
return ETrue;
|
|
1530 |
}
|
|
1531 |
return EFalse;
|
|
1532 |
}
|
|
1533 |
|
|
1534 |
// ---------------------------------------------------------------------------
|
|
1535 |
// Updates output param list with the headerlist.
|
|
1536 |
// aFilter ownership is passed
|
|
1537 |
// ---------------------------------------------------------------------------
|
|
1538 |
//
|
|
1539 |
void UpdateOutputAsIdListL( CLiwGenericParamList* aOutParamList,
|
|
1540 |
CMsvEntrySelection* aEntrySelection,
|
|
1541 |
CMessagingService* aMsgService,
|
|
1542 |
CFilterParamInfo* aFilter )
|
|
1543 |
{
|
|
1544 |
CIterableIdList* iter = CIterableIdList::NewL( aEntrySelection, aMsgService, aFilter );
|
|
1545 |
CleanupStack::PushL( iter );
|
|
1546 |
|
|
1547 |
TLiwVariant listVal;
|
|
1548 |
listVal.Set( iter );
|
|
1549 |
|
|
1550 |
aOutParamList->AppendL( TLiwGenericParam( KReturnValue/*KMessageList*/, listVal ));
|
|
1551 |
|
|
1552 |
CleanupStack::Pop( iter );
|
|
1553 |
listVal.Reset();
|
|
1554 |
iter->DecRef();
|
|
1555 |
}
|
|
1556 |
|
|
1557 |
// ---------------------------------------------------------------------------
|
|
1558 |
// Updates the message details to input map
|
|
1559 |
// ---------------------------------------------------------------------------
|
|
1560 |
//
|
|
1561 |
void UpdateMessageDetailToMapL( CLiwMap* aResultMap, CMessageDetailInfo* aMessageDetail )
|
|
1562 |
{
|
|
1563 |
if ( aResultMap )
|
|
1564 |
{
|
|
1565 |
aResultMap->InsertL( KMessageId, TLiwVariant( aMessageDetail->MessageId() ) );
|
|
1566 |
|
|
1567 |
aResultMap->InsertL( KBodyText, TLiwVariant( aMessageDetail->BodyText() ) );
|
|
1568 |
|
|
1569 |
// Update recipient list
|
|
1570 |
if ( aMessageDetail->RecipientArray() )
|
|
1571 |
{
|
|
1572 |
CLiwDefaultList* bccList = CLiwDefaultList::NewL();
|
|
1573 |
CleanupClosePushL( *bccList ); //CleanupStack::PushL( bccList );
|
|
1574 |
CLiwDefaultList* ccList = CLiwDefaultList::NewL();
|
|
1575 |
CleanupClosePushL( *ccList ); //CleanupStack::PushL( ccList );
|
|
1576 |
CLiwDefaultList* toList = CLiwDefaultList::NewL();
|
|
1577 |
CleanupClosePushL( *toList ); //CleanupStack::PushL( toList );
|
|
1578 |
|
|
1579 |
|
|
1580 |
for( TInt index = 0 ; index < aMessageDetail->RecipientArray()->Count() ;index++ )
|
|
1581 |
{
|
|
1582 |
switch ( aMessageDetail->RecipientArray()->Type( index ) )
|
|
1583 |
{
|
|
1584 |
case EMsvRecipientTo :
|
|
1585 |
toList->AppendL(TLiwVariant( (*(aMessageDetail->RecipientArray()))[index] ) );
|
|
1586 |
break;
|
|
1587 |
|
|
1588 |
case EMsvRecipientCc :
|
|
1589 |
ccList->AppendL(TLiwVariant( (*(aMessageDetail->RecipientArray()))[index] ) );
|
|
1590 |
break;
|
|
1591 |
|
|
1592 |
case EMsvRecipientBcc :
|
|
1593 |
bccList->AppendL(TLiwVariant( (*(aMessageDetail->RecipientArray()))[index] ) );
|
|
1594 |
break;
|
|
1595 |
|
|
1596 |
default :
|
|
1597 |
User::Leave( ErrCodeConversion(KErrGeneral) );
|
|
1598 |
break ;
|
|
1599 |
}
|
|
1600 |
}
|
|
1601 |
|
|
1602 |
if ( toList->Count() > 0 )
|
|
1603 |
{
|
|
1604 |
aResultMap->InsertL( KRecipientTo, TLiwVariant(toList) );
|
|
1605 |
}
|
|
1606 |
CleanupStack::PopAndDestroy( toList );
|
|
1607 |
//toList->DecRef();
|
|
1608 |
|
|
1609 |
if ( ccList->Count() > 0 )
|
|
1610 |
{
|
|
1611 |
aResultMap->InsertL( KRecipientCc, TLiwVariant(ccList) );
|
|
1612 |
}
|
|
1613 |
CleanupStack::PopAndDestroy( ccList );
|
|
1614 |
//ccList->DecRef();
|
|
1615 |
|
|
1616 |
if ( bccList->Count() > 0 )
|
|
1617 |
{
|
|
1618 |
aResultMap->InsertL( KRecipientBcc, TLiwVariant(bccList) );
|
|
1619 |
}
|
|
1620 |
CleanupStack::PopAndDestroy( bccList );
|
|
1621 |
//bccList->DecRef();
|
|
1622 |
}
|
|
1623 |
|
|
1624 |
// Update attachment list
|
|
1625 |
if ( aMessageDetail->AttachmentInfoArray() )
|
|
1626 |
{
|
|
1627 |
CLiwDefaultList* mapList = CLiwDefaultList::NewL();
|
|
1628 |
CleanupClosePushL( *mapList ); //CleanupStack::PushL( mapList );
|
|
1629 |
|
|
1630 |
for ( TInt index = 0 ; index < aMessageDetail->AttachmentInfoArray()->Count(); index++ )
|
|
1631 |
{
|
|
1632 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL();
|
|
1633 |
|
|
1634 |
CleanupClosePushL( *map ); //CleanupStack::PushL( map );
|
|
1635 |
|
|
1636 |
CMessageAttachInfo* attachinfo = aMessageDetail->AttachmentInfoArray()->At( index );
|
|
1637 |
|
|
1638 |
map->InsertL(KFileName, TLiwVariant( attachinfo->Name() ) );
|
|
1639 |
|
|
1640 |
map->InsertL(KFileSize, TLiwVariant( attachinfo->Size() ) );
|
|
1641 |
|
|
1642 |
map->InsertL(KMimeType, TLiwVariant( attachinfo->MimeType() ) );
|
|
1643 |
|
|
1644 |
RFile tmpFile = attachinfo->FileHandle();
|
|
1645 |
|
|
1646 |
CMsgFileBuffer* fileObj = CMsgFileBuffer::NewL( tmpFile );
|
|
1647 |
|
|
1648 |
CleanupStack::PushL( fileObj );
|
|
1649 |
|
|
1650 |
map->InsertL(KFileHandle, TLiwVariant( fileObj ) );
|
|
1651 |
|
|
1652 |
CleanupStack::Pop( fileObj );
|
|
1653 |
fileObj->DecRef();
|
|
1654 |
|
|
1655 |
mapList->AppendL( TLiwVariant(map) );
|
|
1656 |
|
|
1657 |
CleanupStack::PopAndDestroy(map);
|
|
1658 |
|
|
1659 |
//map->DecRef();
|
|
1660 |
}
|
|
1661 |
|
|
1662 |
if ( mapList->Count() > 0 )
|
|
1663 |
{
|
|
1664 |
aResultMap->InsertL( KAttachmentList, TLiwVariant(mapList) );
|
|
1665 |
}
|
|
1666 |
|
|
1667 |
CleanupStack::PopAndDestroy( mapList );
|
|
1668 |
|
|
1669 |
//mapList->DecRef();
|
|
1670 |
}
|
|
1671 |
}
|
|
1672 |
}
|
|
1673 |
|
|
1674 |
// ---------------------------------------------------------------------------
|
|
1675 |
// Two-Phase constructor
|
|
1676 |
// ---------------------------------------------------------------------------
|
|
1677 |
//
|
|
1678 |
CIterableIdList* CIterableIdList::NewL( CMsvEntrySelection* aList,
|
|
1679 |
CMessagingService* aMsgService,
|
|
1680 |
CFilterParamInfo* aFilter )
|
|
1681 |
{
|
|
1682 |
return new(ELeave) CIterableIdList( aList, aMsgService, aFilter );
|
|
1683 |
}
|
|
1684 |
|
|
1685 |
// ---------------------------------------------------------------------------
|
|
1686 |
// Destructor
|
|
1687 |
// ---------------------------------------------------------------------------
|
|
1688 |
//
|
|
1689 |
CIterableIdList::~CIterableIdList()
|
|
1690 |
{
|
|
1691 |
if( iList )
|
|
1692 |
{
|
|
1693 |
iList->Reset();
|
|
1694 |
delete iList;
|
|
1695 |
}
|
|
1696 |
|
|
1697 |
delete iFilter;
|
|
1698 |
}
|
|
1699 |
|
|
1700 |
// ---------------------------------------------------------------------------
|
|
1701 |
// Reset the list
|
|
1702 |
// ---------------------------------------------------------------------------
|
|
1703 |
//
|
|
1704 |
void CIterableIdList::Reset()
|
|
1705 |
{
|
|
1706 |
if( iList )
|
|
1707 |
{
|
|
1708 |
iIndex = 0; //iList->Reset();
|
|
1709 |
}
|
|
1710 |
}
|
|
1711 |
|
|
1712 |
// ---------------------------------------------------------------------------
|
|
1713 |
// Gets next element in list
|
|
1714 |
// ---------------------------------------------------------------------------
|
|
1715 |
//
|
|
1716 |
TBool CIterableIdList::NextL(TLiwVariant& aNext)
|
|
1717 |
{
|
|
1718 |
TBool retValue = EFalse;
|
|
1719 |
if ( iList && iList->Count() > iIndex )
|
|
1720 |
{
|
|
1721 |
CMessageHeader* header = NULL;
|
|
1722 |
|
|
1723 |
TRAPD( err, iMsgService->GetNextHeaderL( iFilter, iList, iIndex, NULL, header ));// Check for trap
|
|
1724 |
|
|
1725 |
if ( ( err == KErrNone ) && header )
|
|
1726 |
{
|
|
1727 |
CleanupStack::PushL( header );
|
|
1728 |
|
|
1729 |
// Get object of the custom map
|
|
1730 |
if ( GetLiwHeaderL( header, aNext, iMsgService, ETrue ) )
|
|
1731 |
{
|
|
1732 |
retValue = ETrue;
|
|
1733 |
}
|
|
1734 |
|
|
1735 |
CleanupStack::PopAndDestroy( header );
|
|
1736 |
}
|
|
1737 |
else
|
|
1738 |
{
|
|
1739 |
User::LeaveIfError( ErrCodeConversion(err));
|
|
1740 |
}
|
|
1741 |
}
|
|
1742 |
return retValue;
|
|
1743 |
}
|
|
1744 |
|
|
1745 |
|
|
1746 |
// ---------------------------------------------------------------------------
|
|
1747 |
// Constructor
|
|
1748 |
// ---------------------------------------------------------------------------
|
|
1749 |
//
|
|
1750 |
CIterableIdList::CIterableIdList(CMsvEntrySelection* aList,
|
|
1751 |
CMessagingService* aMsgService,
|
|
1752 |
CFilterParamInfo* aFilter ):
|
|
1753 |
iList( aList ),
|
|
1754 |
iMsgService( aMsgService ),
|
|
1755 |
iFilter( aFilter )
|
|
1756 |
{
|
|
1757 |
}
|
|
1758 |
|
|
1759 |
|
|
1760 |
//////////////////////////////////////
|
|
1761 |
//Messaging Custom map Implementation
|
|
1762 |
//////////////////////////////////////
|
|
1763 |
CLiwMessagingMap* CLiwMessagingMap::NewL( CMessagingService* aMsgService )
|
|
1764 |
{
|
|
1765 |
CLiwGenericParamList* gl = CLiwGenericParamList::NewLC();
|
|
1766 |
CLiwMessagingMap* tempMap = new (ELeave) CLiwMessagingMap(gl, aMsgService);
|
|
1767 |
CleanupStack::Pop(gl);
|
|
1768 |
return tempMap;
|
|
1769 |
}
|
|
1770 |
|
|
1771 |
void CLiwMessagingMap::InsertL(const TDesC8& aKey, const TLiwVariant& aValue)
|
|
1772 |
{
|
|
1773 |
Remove(aKey);
|
|
1774 |
TLiwGenericParam mp;
|
|
1775 |
mp.SetNameAndValueL(aKey, aValue);
|
|
1776 |
iMap->AppendL(mp);
|
|
1777 |
mp.Reset();
|
|
1778 |
}
|
|
1779 |
|
|
1780 |
TBool CLiwMessagingMap::FindL(const TDesC8& aKey, TLiwVariant& aValue) const
|
|
1781 |
{
|
|
1782 |
TInt pos = 0;
|
|
1783 |
const TLiwGenericParam* tempParam = iMap->FindFirst(pos, aKey);
|
|
1784 |
if (tempParam)
|
|
1785 |
{
|
|
1786 |
aValue.SetL(tempParam->Value());
|
|
1787 |
return ETrue;
|
|
1788 |
}
|
|
1789 |
else
|
|
1790 |
{
|
|
1791 |
// add for bodytext/recipient cc bcc to/attachlist
|
|
1792 |
if( aKey.CompareF( KBodyText ) == 0 ||
|
|
1793 |
aKey.CompareF( KRecipientTo ) == 0 ||
|
|
1794 |
aKey.CompareF( KRecipientCc ) == 0 ||
|
|
1795 |
aKey.CompareF( KRecipientBcc ) == 0 ||
|
|
1796 |
aKey.CompareF( KAttachmentList ) == 0 )
|
|
1797 |
{
|
|
1798 |
pos = 0;
|
|
1799 |
const TLiwGenericParam* messageIdParam = iMap->FindFirst( pos, KMessageId );
|
|
1800 |
if ( messageIdParam && iMsgService )
|
|
1801 |
{
|
|
1802 |
TMsvId messageId = messageIdParam->Value().AsTInt32();
|
|
1803 |
CMessageDetailInfo* messageDetail = NULL;
|
|
1804 |
TRAPD( err, iMsgService->GetMessageDetailL( messageId, NULL, messageDetail ));
|
|
1805 |
|
|
1806 |
if ( err == KErrNone && messageDetail )
|
|
1807 |
{
|
|
1808 |
CleanupStack::PushL( messageDetail );
|
|
1809 |
|
|
1810 |
UpdateMessageDetailToMapL( (CLiwMap*)this, messageDetail );
|
|
1811 |
|
|
1812 |
CleanupStack::PopAndDestroy( messageDetail );
|
|
1813 |
|
|
1814 |
pos = 0;
|
|
1815 |
const TLiwGenericParam* detailParam = iMap->FindFirst(pos, aKey);
|
|
1816 |
if ( detailParam )
|
|
1817 |
{
|
|
1818 |
aValue.SetL( detailParam->Value() );
|
|
1819 |
return ETrue;
|
|
1820 |
}
|
|
1821 |
}
|
|
1822 |
else
|
|
1823 |
{
|
|
1824 |
User::LeaveIfError( ErrCodeConversion(err) );
|
|
1825 |
}
|
|
1826 |
}
|
|
1827 |
}
|
|
1828 |
}
|
|
1829 |
return EFalse;
|
|
1830 |
}
|
|
1831 |
|
|
1832 |
TInt CLiwMessagingMap::Count() const
|
|
1833 |
{
|
|
1834 |
return iMap->Count();
|
|
1835 |
}
|
|
1836 |
|
|
1837 |
TBool CLiwMessagingMap::AtL(TInt aIndex, TDes8& aKey) const
|
|
1838 |
{
|
|
1839 |
if(0 <= aIndex && aIndex < iMap->Count())
|
|
1840 |
{
|
|
1841 |
aKey = ((*iMap)[aIndex]).Name();
|
|
1842 |
return ETrue;
|
|
1843 |
}
|
|
1844 |
else
|
|
1845 |
{
|
|
1846 |
return EFalse;
|
|
1847 |
}
|
|
1848 |
}
|
|
1849 |
|
|
1850 |
void CLiwMessagingMap::Remove(const TDesC8& aKey)
|
|
1851 |
{
|
|
1852 |
iMap->Remove( aKey );
|
|
1853 |
}
|
|
1854 |
|
|
1855 |
CLiwMessagingMap::~CLiwMessagingMap()
|
|
1856 |
{
|
|
1857 |
delete iMap;
|
|
1858 |
}
|
|
1859 |
|
|
1860 |
|
|
1861 |
//////////////////////////////////////
|
|
1862 |
//File Buffer Implementation
|
|
1863 |
//////////////////////////////////////
|
|
1864 |
CMsgFileBuffer* CMsgFileBuffer::NewL(RFile& aFile)
|
|
1865 |
{
|
|
1866 |
return new(ELeave) CMsgFileBuffer(aFile);
|
|
1867 |
}
|
|
1868 |
|
|
1869 |
CMsgFileBuffer::~CMsgFileBuffer()
|
|
1870 |
{
|
|
1871 |
Release();
|
|
1872 |
}
|
|
1873 |
|
|
1874 |
CMsgFileBuffer::CMsgFileBuffer( RFile& aFile ):
|
|
1875 |
iFile( aFile )
|
|
1876 |
{
|
|
1877 |
|
|
1878 |
}
|
|
1879 |
|
|
1880 |
RFile& CMsgFileBuffer::AsFile()
|
|
1881 |
{
|
|
1882 |
return iFile;
|
|
1883 |
}
|
|
1884 |
|
|
1885 |
TUint8* CMsgFileBuffer::Buf() const
|
|
1886 |
{
|
|
1887 |
return NULL;
|
|
1888 |
}
|
|
1889 |
|
|
1890 |
TInt CMsgFileBuffer::Len()
|
|
1891 |
{
|
|
1892 |
TInt size = 0;
|
|
1893 |
|
|
1894 |
TInt retValue = iFile.Size( size );
|
|
1895 |
|
|
1896 |
if ( retValue == KErrNone )
|
|
1897 |
{
|
|
1898 |
return size;
|
|
1899 |
}
|
|
1900 |
else
|
|
1901 |
{
|
|
1902 |
return retValue;
|
|
1903 |
}
|
|
1904 |
}
|
|
1905 |
|
|
1906 |
TInt CMsgFileBuffer::Read( TUint8* aPtr,TInt aLength )
|
|
1907 |
{
|
|
1908 |
TPtr8 temp(aPtr, aLength);
|
|
1909 |
|
|
1910 |
TInt errCode = iFile.Read( temp, aLength );
|
|
1911 |
|
|
1912 |
return errCode;
|
|
1913 |
}
|
|
1914 |
|
|
1915 |
TInt CMsgFileBuffer::Write(const TUint8 /*aPtr*/, TInt /*aLength*/)
|
|
1916 |
{
|
|
1917 |
return KLiwBufferReadOnly;
|
|
1918 |
}
|
|
1919 |
|
|
1920 |
void CMsgFileBuffer::Release()
|
|
1921 |
{
|
|
1922 |
iFile.Close();
|
|
1923 |
}
|
|
1924 |
|
|
1925 |
TInt CMsgFileBuffer::TypeID()
|
|
1926 |
{
|
|
1927 |
return KLiwBufferFile;
|
|
1928 |
}
|
|
1929 |
|
|
1930 |
TBool CMsgFileBuffer::operator==(CLiwBuffer& /*aBuffer*/)
|
|
1931 |
{
|
|
1932 |
return EFalse;
|
|
1933 |
}
|
|
1934 |
|
|
1935 |
// ---------------------------------------------------------------------------
|
|
1936 |
// ErrCode Conversion
|
|
1937 |
// ---------------------------------------------------------------------------
|
|
1938 |
//
|
|
1939 |
TInt32 ErrCodeConversion(TInt code)
|
|
1940 |
{
|
|
1941 |
TInt32 err;
|
|
1942 |
switch (code)
|
|
1943 |
{
|
|
1944 |
case KErrCancel:
|
|
1945 |
case KErrNone:
|
|
1946 |
err= SErrNone;
|
|
1947 |
break;
|
|
1948 |
|
|
1949 |
case KErrNotFound:
|
|
1950 |
err= SErrNotFound;
|
|
1951 |
break;
|
|
1952 |
|
|
1953 |
case KErrNoMemory:
|
|
1954 |
err = SErrNoMemory;
|
|
1955 |
break;
|
|
1956 |
|
|
1957 |
case KErrInUse:
|
|
1958 |
err = SErrServiceInUse;
|
|
1959 |
break;
|
|
1960 |
|
|
1961 |
case KErrNotSupported:
|
|
1962 |
err = SErrServiceNotSupported;
|
|
1963 |
break;
|
|
1964 |
|
|
1965 |
case KErrBadName:
|
|
1966 |
err = SErrBadArgumentType;
|
|
1967 |
break;
|
|
1968 |
|
|
1969 |
case KErrArgument:
|
|
1970 |
err = SErrInvalidServiceArgument;
|
|
1971 |
break;
|
|
1972 |
|
|
1973 |
case KErrAlreadyExists:
|
|
1974 |
err = SErrEntryExists;
|
|
1975 |
break;
|
|
1976 |
|
|
1977 |
case SErrMissingArgument:
|
|
1978 |
err = SErrMissingArgument;
|
|
1979 |
break;
|
|
1980 |
|
|
1981 |
default :
|
|
1982 |
err = SErrGeneralError;
|
|
1983 |
break;
|
|
1984 |
}
|
|
1985 |
|
|
1986 |
return err;
|
|
1987 |
|
|
1988 |
}
|
|
1989 |
|
|
1990 |
|
|
1991 |
TInputValidator::TInputValidator()
|
|
1992 |
{
|
|
1993 |
|
|
1994 |
}
|
|
1995 |
|
|
1996 |
|
|
1997 |
TBool TInputValidator::CheckValidFile( const TDesC &aFileName )
|
|
1998 |
{
|
|
1999 |
if( aFileName.Length() <= KMaxFileName )
|
|
2000 |
{
|
|
2001 |
RFs fileSession;
|
|
2002 |
if( fileSession.Connect() == KErrNone )
|
|
2003 |
{
|
|
2004 |
if( fileSession.IsValidName( aFileName ) )
|
|
2005 |
{
|
|
2006 |
RFile tmpfile;
|
|
2007 |
if( tmpfile.Open( fileSession, aFileName, EFileRead ) == KErrNone )
|
|
2008 |
{
|
|
2009 |
tmpfile.Close();
|
|
2010 |
return ETrue;
|
|
2011 |
}
|
|
2012 |
}
|
|
2013 |
fileSession.Close();
|
|
2014 |
return EFalse;
|
|
2015 |
}
|
|
2016 |
}
|
|
2017 |
return EFalse;
|
|
2018 |
}
|
|
2019 |
|
|
2020 |
TBool TInputValidator::CheckDesSize( const TDesC &aDes )
|
|
2021 |
{
|
|
2022 |
if( aDes.Length() <= KMaxFileName )
|
|
2023 |
{
|
|
2024 |
return ETrue;
|
|
2025 |
}
|
|
2026 |
return EFalse;
|
|
2027 |
}
|
|
2028 |
|
|
2029 |
TBool TInputValidator::CheckValidDate( const TTime &aTime )
|
|
2030 |
{
|
|
2031 |
TTime null = Time::NullTTime();
|
|
2032 |
TTime low = Time::MinTTime();
|
|
2033 |
TTime high = Time::MaxTTime();
|
|
2034 |
if( aTime == null || aTime < low || aTime > high )
|
|
2035 |
{
|
|
2036 |
return EFalse;
|
|
2037 |
}
|
|
2038 |
return ETrue;
|
|
2039 |
}
|
|
2040 |
|
|
2041 |
TBool TInputValidator::CheckValidNumber( const TDesC &aDes )
|
|
2042 |
{
|
|
2043 |
if( aDes.Length() )
|
|
2044 |
{
|
|
2045 |
TLex parser( aDes );
|
|
2046 |
TChar character;
|
|
2047 |
while( (character = parser.Get()) !=0 )
|
|
2048 |
{
|
|
2049 |
if( !character.IsDigit() )
|
|
2050 |
{
|
|
2051 |
return EFalse;
|
|
2052 |
}
|
|
2053 |
}
|
|
2054 |
return ETrue;
|
|
2055 |
}
|
|
2056 |
return EFalse;
|
|
2057 |
}
|
|
2058 |
|
|
2059 |
TBool TInputValidator::CheckValidNumberWithPlus( const TDesC &aDes )
|
|
2060 |
{
|
|
2061 |
if( aDes.Length() )
|
|
2062 |
{
|
|
2063 |
TLex parser( aDes );
|
|
2064 |
TChar character;
|
|
2065 |
character = parser.Get();
|
|
2066 |
if( !(character == '+') && !character.IsDigit() )//check for the first character
|
|
2067 |
{
|
|
2068 |
return EFalse;
|
|
2069 |
}
|
|
2070 |
while( (character = parser.Get()) !=0 )
|
|
2071 |
{
|
|
2072 |
if( !character.IsDigit() )
|
|
2073 |
{
|
|
2074 |
return EFalse;
|
|
2075 |
}
|
|
2076 |
}
|
|
2077 |
return ETrue;
|
|
2078 |
}
|
|
2079 |
return EFalse;
|
|
2080 |
}
|