|
1 /* |
|
2 # |
|
3 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 # All rights reserved. |
|
5 # This component and the accompanying materials are made available |
|
6 # under the terms of "Eclipse Public License v1.0" |
|
7 # which accompanies this distribution, and is available |
|
8 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
9 # |
|
10 # Initial Contributors: |
|
11 # Nokia Corporation - initial contribution. |
|
12 # |
|
13 # Contributors: |
|
14 # |
|
15 # Description: Main test class for CS Message Plugin |
|
16 #*/ |
|
17 |
|
18 // [INCLUDE FILES] - do not remove |
|
19 #include <e32svr.h> |
|
20 #include <msvsearchsortoperation.h> |
|
21 #include <msvsearchsortquery.h> |
|
22 #include <StifParser.h> |
|
23 #include <Stiftestinterface.h> |
|
24 #include <TXTRICH.H> |
|
25 #include <SMUTHDR.H> |
|
26 #include <smut.h> |
|
27 #include <msvstd.h> |
|
28 #include <rsendas.h> |
|
29 #include <rsendasmessage.h> |
|
30 #include <ecom\ECom.h> |
|
31 #include "test_plugin.h" |
|
32 #include "CCsPlugin.h" |
|
33 |
|
34 |
|
35 // ============================ MEMBER FUNCTIONS =============================== |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // Ctest_plugin::Delete |
|
39 // |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 void Ctest_plugin::Delete() |
|
43 { |
|
44 iResultConversationEntryList.ResetAndDestroy(); |
|
45 iResultConversationEntryList.Close(); |
|
46 |
|
47 iTestConversationEntryList.ResetAndDestroy(); |
|
48 iTestConversationEntryList.Close(); |
|
49 |
|
50 if( iPlugin ) |
|
51 { |
|
52 delete iPlugin; |
|
53 iPlugin = NULL; |
|
54 } |
|
55 |
|
56 if (iSession) |
|
57 { |
|
58 delete iSession; |
|
59 iSession = NULL; |
|
60 } |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // Ctest_plugin::RunMethodL |
|
65 // |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 TInt Ctest_plugin::RunMethodL( CStifItemParser& aItem ) |
|
69 { |
|
70 TStifFunctionInfo const KFunctions[] = |
|
71 { |
|
72 // Copy this line for every implemented function. |
|
73 // First string is the function name used in TestScripter script file. |
|
74 // Second is the actual implementation member function. |
|
75 |
|
76 ENTRY( "Example", Ctest_plugin::ExampleL ), |
|
77 ENTRY( "CacheFromCcsPluginL", Ctest_plugin::CacheFromCcsPluginL ), |
|
78 ENTRY( "CreateCCsMsgL", Ctest_plugin::CreateCCsMsgL ), |
|
79 |
|
80 ENTRY( "CreateCcsPluginL", Ctest_plugin::CreateCcsPluginL ), |
|
81 ENTRY( "SendCcsMessageL", Ctest_plugin::SendCcsMessageL ), |
|
82 ENTRY( "SmsMsgPluginValidationL", Ctest_plugin::SmsMsgPluginValidationL), |
|
83 ENTRY( "MmsMsgPluginValidationL",Ctest_plugin::MmsMsgPluginValidationL), |
|
84 ENTRY( "BioMsgPluginValidationL",Ctest_plugin::BioMsgPluginValidationL) |
|
85 |
|
86 }; |
|
87 |
|
88 const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo ); |
|
89 return RunInternalL( KFunctions, count, aItem ); |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // Ctestsmsplugin::ExampleL |
|
94 // Example test method function. |
|
95 // (other items were commented in a header). |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 TInt Ctest_plugin::ExampleL( CStifItemParser& aItem ) |
|
99 { |
|
100 |
|
101 // Print to UI |
|
102 _LIT( Ktestplugin, "testplugin" ); |
|
103 _LIT( KExample, "In Example" ); |
|
104 TestModuleIf().Printf( 0, Ktestplugin, KExample ); |
|
105 // Print to log file |
|
106 iLog->Log( KExample ); |
|
107 |
|
108 TInt i = 0; |
|
109 TPtrC string; |
|
110 _LIT( KParam, "Param[%i]: %S" ); |
|
111 while ( aItem.GetNextString ( string ) == KErrNone ) |
|
112 { |
|
113 TestModuleIf().Printf( i, Ktestplugin, |
|
114 KParam, i, &string ); |
|
115 i++; |
|
116 } |
|
117 |
|
118 return KErrNone; |
|
119 |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // Ctest_plugin::CreateCCsMsgL |
|
124 // Example test method function. |
|
125 // (other items were commented in a header). |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 TInt Ctest_plugin::CreateCCsMsgL( CStifItemParser& /*aItem*/ ) |
|
129 { |
|
130 |
|
131 // Print to UI |
|
132 _LIT( Ktestplugin, "CreateCCsMsgL" ); |
|
133 _LIT( KFunction, "In CreateCCsMsgL" ); |
|
134 TestModuleIf().Printf( 0, Ktestplugin, KFunction ); |
|
135 // Print to log file |
|
136 iLog->Log( KFunction ); |
|
137 iPlugin = CCsMsg::NewL(this); |
|
138 iPlugin->GetConversationsL(); |
|
139 |
|
140 return KErrNone; |
|
141 |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // Ctest_plugin::CacheFromCcsPluginL |
|
146 // Creates the ccs plugin and initiates the caching |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 TInt Ctest_plugin::CacheFromCcsPluginL( CStifItemParser& /*aItem*/ ) |
|
150 { |
|
151 // Print to UI |
|
152 _LIT( Ktestplugin, "CacheFromCcsPluginL" ); |
|
153 _LIT( KFunction, "In CacheFromCcsPluginL" ); |
|
154 TestModuleIf().Printf( 0, Ktestplugin, KFunction ); |
|
155 // Print to log file |
|
156 iLog->Log( KFunction ); |
|
157 |
|
158 iTestConversationEntryList.ResetAndDestroy(); |
|
159 iResultConversationEntryList.ResetAndDestroy(); |
|
160 |
|
161 iPlugin = CCsMsg::NewL(this); |
|
162 iPlugin->GetConversationsL(); |
|
163 |
|
164 return KErrNone; |
|
165 } |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // Ctest_plugin::CreateCcsPluginL |
|
169 // Creates ccs plugin. |
|
170 // ----------------------------------------------------------------------------- |
|
171 // |
|
172 TInt Ctest_plugin::CreateCcsPluginL( CStifItemParser& /*aItem*/ ) |
|
173 { |
|
174 // Print to UI |
|
175 _LIT( Ktestplugin, "CreateCcsPluginL" ); |
|
176 _LIT( KFunction, "In CreateCcsPluginL" ); |
|
177 TestModuleIf().Printf( 0, Ktestplugin, KFunction ); |
|
178 // Print to log file |
|
179 iLog->Log( KFunction ); |
|
180 |
|
181 iTestConversationEntryList.ResetAndDestroy(); |
|
182 iResultConversationEntryList.ResetAndDestroy(); |
|
183 |
|
184 iPlugin = CCsMsg::NewL(this); |
|
185 |
|
186 return KErrNone; |
|
187 } |
|
188 |
|
189 // ----------------------------------------------------------------------------- |
|
190 // Ctestsmsplugin::SendCcsMessageL |
|
191 // Send ccs message using RSendAs api |
|
192 // ----------------------------------------------------------------------------- |
|
193 // |
|
194 TInt Ctest_plugin::SendCcsMessageL( CStifItemParser& /*aItem*/ ) |
|
195 { |
|
196 // Print to UI |
|
197 _LIT( Ktestplugin, "SendCcsMessageL" ); |
|
198 _LIT( KFunction, "In SendCcsMessageL" ); |
|
199 TestModuleIf().Printf( 0, Ktestplugin, KFunction ); |
|
200 // Print to log file |
|
201 iLog->Log( KFunction ); |
|
202 |
|
203 iTestConversationEntryList.ResetAndDestroy(); |
|
204 iResultConversationEntryList.ResetAndDestroy(); |
|
205 |
|
206 RSendAs sendas; |
|
207 CleanupClosePushL(sendas); |
|
208 TInt res = sendas.Connect(); |
|
209 User::LeaveIfError(res); |
|
210 |
|
211 RSendAsMessage message; |
|
212 CleanupClosePushL(message); |
|
213 TRAP(res, message.CreateL(sendas, KUidMsgTypeSMS)); |
|
214 User::LeaveIfError(res); |
|
215 |
|
216 TBuf<512> MsgText; |
|
217 MsgText.Copy(_L("Message being sent")); |
|
218 message.SetBodyTextL(MsgText); |
|
219 TBuf<15> RecAdd; |
|
220 RecAdd.Copy(_L("123456789")); |
|
221 message.AddRecipientL(RecAdd,RSendAsMessage::ESendAsRecipientTo ); |
|
222 |
|
223 |
|
224 message.SendMessageAndCloseL(); |
|
225 CleanupStack::Pop(1); // RMessage |
|
226 CleanupStack::PopAndDestroy(1); // RSendAs |
|
227 |
|
228 return KErrNone; |
|
229 } |
|
230 |
|
231 |
|
232 // ----------------------------------------------------------------------------- |
|
233 // Ctest_plugin::CreateMmsMessageL |
|
234 // Creates messages in the different folders and populates the |
|
235 // iTestConversationEntryList |
|
236 // ----------------------------------------------------------------------------- |
|
237 // |
|
238 void Ctest_plugin::CreateMmsMessageL(const TMsvId aFolderId, |
|
239 TBool aUnReadFlag) |
|
240 { |
|
241 |
|
242 // create a new object to access an existing entry |
|
243 CMsvEntry* msvEntry = CMsvEntry::NewL(*iSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering()); |
|
244 CleanupStack::PushL(msvEntry); |
|
245 |
|
246 TMsvId defaultServiceId = 0; |
|
247 defaultServiceId = iMmsClientMtm->DefaultServiceL(); |
|
248 |
|
249 _LIT( KMMSBody, " Hi !!!"); |
|
250 |
|
251 CleanupStack::Pop(msvEntry); |
|
252 iMmsClientMtm->SetCurrentEntryL(msvEntry); |
|
253 iMmsClientMtm->CreateMessageL(defaultServiceId); |
|
254 iMmsClientMtm->SetSubjectL(KMMSBody); |
|
255 |
|
256 // set some mms defaults |
|
257 iMmsClientMtm->SetMessageClass(EMmsClassPersonal); |
|
258 iMmsClientMtm->SetExpiryInterval(86400); |
|
259 iMmsClientMtm->SetDeliveryTimeInterval(3600); |
|
260 iMmsClientMtm->SetMessagePriority(EMmsPriorityLow); |
|
261 iMmsClientMtm->SetSenderVisibility(EMmsMaximumSenderVisibility); |
|
262 iMmsClientMtm->SetDeliveryReport(EMmsDeliveryReportYes); |
|
263 iMmsClientMtm->SetReadReply(EMmsReadReplyYes); |
|
264 |
|
265 _LIT(KPhoneNumberString,"234567"); |
|
266 TBuf<15> phoneNumberString; |
|
267 phoneNumberString.Copy(KPhoneNumberString); |
|
268 _LIT(KPhoneNumberString1,"mine<98450>"); |
|
269 _LIT(KResultPhoneNumberString,"98450"); |
|
270 |
|
271 if (aFolderId == KMsvGlobalInBoxIndexEntryId) |
|
272 { |
|
273 iMmsClientMtm->SetSenderL(KResultPhoneNumberString); |
|
274 } |
|
275 |
|
276 iMmsClientMtm->AddAddresseeL(KResultPhoneNumberString); |
|
277 |
|
278 CMsvStore* store = msvEntry->EditStoreL(); |
|
279 CleanupStack::PushL(store); |
|
280 |
|
281 // set body as an attachment |
|
282 CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL(); |
|
283 CleanupStack::PushL(mimeHeaders); |
|
284 mimeHeaders->SetContentTypeL( _L8("text") ); |
|
285 mimeHeaders->SetContentSubTypeL( _L8("plain") ); |
|
286 mimeHeaders->SetMimeCharset( KMmsUtf8 ); |
|
287 mimeHeaders->SetSuggestedFilenameL( _L("body.txt") ); |
|
288 |
|
289 MMsvAttachmentManager& attachMan = store->AttachmentManagerL(); |
|
290 CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); // ownership of attachmentInfo will be transferred |
|
291 CleanupStack::PushL(attachmentInfo); |
|
292 attachmentInfo->SetAttachmentNameL( _L("body.txt") ); |
|
293 attachmentInfo->SetMimeTypeL( _L8("text/plain") ); |
|
294 mimeHeaders->StoreL( *attachmentInfo ); |
|
295 |
|
296 RFile textFile; |
|
297 |
|
298 CMsvOperationActiveSchedulerWait* waiter = CMsvOperationActiveSchedulerWait::NewLC(); |
|
299 attachMan.CreateAttachmentL(_L("body.txt"), textFile, attachmentInfo, waiter->iStatus ); |
|
300 CleanupStack::Pop(); // waiter |
|
301 CleanupStack::Pop(); // attachmentInfo |
|
302 CleanupStack::PushL(waiter); |
|
303 waiter->Start(); |
|
304 CleanupStack::PopAndDestroy(waiter); |
|
305 |
|
306 HBufC8* tempBuf = HBufC8::NewLC( 10 ); |
|
307 tempBuf->Des().Copy( KMMSBody ); |
|
308 textFile.Write( tempBuf->Des() ); |
|
309 textFile.Close(); |
|
310 CleanupStack::PopAndDestroy(); //tempBuf |
|
311 |
|
312 CleanupStack::PopAndDestroy(); //mimeHeaders |
|
313 |
|
314 // get the entry of the message |
|
315 TMsvEntry messageEntry = iMmsClientMtm->Entry().Entry(); |
|
316 |
|
317 // set the description field same as the message subject |
|
318 messageEntry.iDescription.Set( KMMSBody ); |
|
319 |
|
320 // save the changes done above |
|
321 iMmsClientMtm->Entry().ChangeL(messageEntry); |
|
322 |
|
323 TFileName attachmentFile( _L("c:\\pictures\\picture123.txt") ); |
|
324 HandleAttachementL(store,attachmentFile ); |
|
325 |
|
326 // save the changes made to the message store |
|
327 store->CommitL(); |
|
328 CleanupStack::PopAndDestroy(store); |
|
329 |
|
330 // save the message |
|
331 iMmsClientMtm->SaveMessageL(); |
|
332 |
|
333 // final fine tuning |
|
334 messageEntry.SetAttachment(ETrue); |
|
335 messageEntry.iDate.HomeTime(); |
|
336 messageEntry.SetVisible(ETrue); |
|
337 messageEntry.SetInPreparation(EFalse); |
|
338 |
|
339 if( aUnReadFlag ) |
|
340 { |
|
341 messageEntry.SetUnread(ETrue); |
|
342 messageEntry.SetNew(ETrue); |
|
343 } |
|
344 else |
|
345 { |
|
346 messageEntry.SetUnread(EFalse); |
|
347 messageEntry.SetNew(EFalse); |
|
348 } |
|
349 messageEntry.SetComplete(ETrue); |
|
350 messageEntry.iServiceId = defaultServiceId; |
|
351 messageEntry.iRelatedId = 0; |
|
352 |
|
353 if (aFolderId == KMsvDraftEntryId) |
|
354 messageEntry.SetReadOnly(EFalse); |
|
355 else |
|
356 messageEntry.SetReadOnly(ETrue); |
|
357 |
|
358 messageEntry.iMtmData1 = KMmsMessageMRetrieveConf | KMmsMessageMobileTerminated; |
|
359 |
|
360 iMmsClientMtm->Entry().ChangeL(messageEntry); |
|
361 |
|
362 } |
|
363 |
|
364 void Ctest_plugin:: HandleAttachementL(CMsvStore* store,TFileName& sourceFileName ) |
|
365 { |
|
366 |
|
367 // attachment settings |
|
368 MMsvAttachmentManager& attachMan = store->AttachmentManagerL(); |
|
369 CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); // ownership of attachmentInfo will be transferred |
|
370 CleanupStack::PushL(attachmentInfo); |
|
371 attachmentInfo->SetAttachmentNameL( sourceFileName); |
|
372 attachmentInfo->SetMimeTypeL(_L8("text") ); |
|
373 |
|
374 CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL(); |
|
375 CleanupStack::PushL(mimeHeaders); |
|
376 mimeHeaders->SetContentTypeL( _L8("text") ); |
|
377 mimeHeaders->SetContentSubTypeL( _L8("plain") ); |
|
378 mimeHeaders->SetMimeCharset( KMmsUtf8 ); |
|
379 mimeHeaders->StoreL( *attachmentInfo ); |
|
380 CleanupStack::PopAndDestroy( mimeHeaders ); |
|
381 |
|
382 CMsvOperationActiveSchedulerWait* waiter = CMsvOperationActiveSchedulerWait::NewLC(); |
|
383 TInt err; |
|
384 TRAP(err, attachMan.AddAttachmentL(sourceFileName, attachmentInfo, waiter->iStatus )); |
|
385 if (err == KErrNone) |
|
386 { |
|
387 waiter->Start(); |
|
388 CleanupStack::PopAndDestroy(waiter); |
|
389 CleanupStack::Pop(); // attachmentInfo, the ownership is transferred |
|
390 } |
|
391 else |
|
392 { |
|
393 CleanupStack::PopAndDestroy(waiter); |
|
394 CleanupStack::PopAndDestroy(); // attachmentInfo, ownership is not transferred (leave occurs) |
|
395 _LIT( Ktestplugin, "HandleAttachment" ); |
|
396 _LIT( KFunction, "In HandleAttachment::Failed" ); |
|
397 } |
|
398 |
|
399 } |
|
400 |
|
401 |
|
402 // ----------------------------------------------------------------------------- |
|
403 // Ctest_plugin::CreateSmartMessageL |
|
404 // Creates messages in the different folders and populates the |
|
405 // iTestConversationEntryList |
|
406 // ----------------------------------------------------------------------------- |
|
407 // |
|
408 void Ctest_plugin::CreateSmartMessageL(const TMsvId aFolderId,TBool aUnReadFlag) |
|
409 { |
|
410 |
|
411 // create a new object to access an existing entry |
|
412 CMsvEntry* msvEntry = CMsvEntry::NewL(*iSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering()); |
|
413 CleanupStack::PushL(msvEntry); |
|
414 |
|
415 TMsvId defaultServiceId = 0; |
|
416 defaultServiceId = iSmsClientMtm->DefaultServiceL(); |
|
417 |
|
418 // mtm takes ownership of entry context |
|
419 CleanupStack::Pop(msvEntry); |
|
420 iSmsClientMtm->SetCurrentEntryL(msvEntry); |
|
421 |
|
422 // create a new message |
|
423 iSmsClientMtm->CreateMessageL(defaultServiceId); |
|
424 |
|
425 // Add addressee |
|
426 _LIT(KPhoneNumberString,"234567"); |
|
427 TBuf<15> phoneNumberString; |
|
428 phoneNumberString.Copy(KPhoneNumberString); |
|
429 |
|
430 _LIT(KPhoneNumberString1,"mine<98450>"); |
|
431 _LIT(KResultPhoneNumberString,"98450"); |
|
432 |
|
433 // set the from field to sms header |
|
434 if (aFolderId == KMsvGlobalInBoxIndexEntryId) |
|
435 { |
|
436 CSmsHeader& smsHeader = iSmsClientMtm->SmsHeader(); |
|
437 smsHeader.SetFromAddressL(KResultPhoneNumberString); |
|
438 } |
|
439 |
|
440 // set body, the BIO message itself |
|
441 iSmsClientMtm->Body().Reset(); |
|
442 iSmsClientMtm->Body().InsertL(0, _L("Business Card\nTester Mike\nThe Company Ltd.\nSoftware Engineer\ntel +358 66 1234567\n")); |
|
443 |
|
444 // get the entry of the message |
|
445 TMsvEntry messageEntry = iSmsClientMtm->Entry().Entry(); |
|
446 |
|
447 // TO-DO: Add support for all BIO messages, currently just insert a business card message ... : |
|
448 // set the message type |
|
449 // parameters.iBIOMessageType ... |
|
450 iSmsClientMtm->BioTypeChangedL(KMsgBioUidVCard); |
|
451 messageEntry.iBioType = KMsgBioUidVCard.iUid; |
|
452 |
|
453 if (aFolderId == KMsvGlobalInBoxIndexEntryId) |
|
454 { |
|
455 iMmsClientMtm->SetSenderL(KResultPhoneNumberString); |
|
456 } |
|
457 |
|
458 _LIT( KBioBody, " Hi !!!"); |
|
459 |
|
460 messageEntry.iDescription.Set(KBioBody); |
|
461 |
|
462 // set correct MTM type |
|
463 messageEntry.iMtm= KUidBIOMessageTypeMtm; |
|
464 |
|
465 // save the changes done above |
|
466 iSmsClientMtm->Entry().ChangeL(messageEntry); |
|
467 |
|
468 // save the message |
|
469 iSmsClientMtm->SaveMessageL(); |
|
470 |
|
471 // final fine tuning |
|
472 messageEntry.SetAttachment(EFalse); |
|
473 messageEntry.iDate.HomeTime(); |
|
474 messageEntry.SetVisible(ETrue); |
|
475 messageEntry.SetInPreparation(EFalse); |
|
476 |
|
477 if( aUnReadFlag ) |
|
478 { |
|
479 messageEntry.SetUnread(ETrue); |
|
480 messageEntry.SetNew(ETrue); |
|
481 } |
|
482 else |
|
483 { |
|
484 messageEntry.SetUnread(EFalse); |
|
485 messageEntry.SetNew(EFalse); |
|
486 } |
|
487 |
|
488 messageEntry.SetComplete(ETrue); |
|
489 messageEntry.iServiceId = defaultServiceId; |
|
490 messageEntry.iRelatedId = 0; |
|
491 iSmsClientMtm->Entry().ChangeL(messageEntry); |
|
492 |
|
493 |
|
494 } |
|
495 |
|
496 // ----------------------------------------------------------------------------- |
|
497 // Ctest_plugin::CreateMessageL |
|
498 // Creates messages in the different folders and populates the |
|
499 // iTestConversationEntryList |
|
500 // ----------------------------------------------------------------------------- |
|
501 // |
|
502 void Ctest_plugin::CreateMessageL(const TMsvId aFolderId, |
|
503 TBool aUnReadFlag) |
|
504 { |
|
505 CCsConversationEntry *conversationEntry = CCsConversationEntry::NewL(); |
|
506 CleanupStack::PushL(conversationEntry); |
|
507 |
|
508 //Create entry from this index entry |
|
509 iSmsClientMtm->SwitchCurrentEntryL( aFolderId ); |
|
510 iSmsClientMtm->CreateMessageL(KUidMsgTypeSMS.iUid); |
|
511 |
|
512 TMsvEntry indexEntry = iSmsClientMtm->Entry().Entry(); |
|
513 |
|
514 indexEntry.SetInPreparation(ETrue); |
|
515 indexEntry.iMtm = KUidMsgTypeSMS; |
|
516 indexEntry.iType = KUidMsvMessageEntry; |
|
517 indexEntry.iServiceId = iSmsClientMtm->ServiceId(); |
|
518 indexEntry.iDate.HomeTime(); |
|
519 |
|
520 //AddBody |
|
521 _LIT( KSMSBody, " Hi,Hello Phone Owner !!!"); |
|
522 TBuf<160> shortDescription; |
|
523 shortDescription.Append(KSMSBody); |
|
524 CRichText& body = iSmsClientMtm->Body(); |
|
525 body.Reset(); |
|
526 body.InsertL( 0, KSMSBody ); |
|
527 indexEntry.iDescription.Set(KSMSBody); |
|
528 |
|
529 // Add addressee |
|
530 _LIT(KPhoneNumberString,"234567"); |
|
531 TBuf<15> phoneNumberString; |
|
532 phoneNumberString.Copy(KPhoneNumberString); |
|
533 |
|
534 _LIT(KPhoneNumberString1,"mine<98450>"); |
|
535 _LIT(KResultPhoneNumberString,"98450"); |
|
536 |
|
537 if( aFolderId == KMsvDraftEntryId ) |
|
538 { |
|
539 iSmsClientMtm->AddAddresseeL(KPhoneNumberString,TPtrC()); |
|
540 iSmsClientMtm->AddAddresseeL(KPhoneNumberString1,TPtrC()); |
|
541 |
|
542 CCsConversationEntry *conversationEntry1 = CCsConversationEntry::NewL(); |
|
543 conversationEntry->SetContactL(KPhoneNumberString); |
|
544 conversationEntry->SetEntryId( indexEntry.Id()); |
|
545 conversationEntry->SetTimeStampL( indexEntry.iDate.Int64()); |
|
546 conversationEntry->SetDescriptionL(shortDescription); |
|
547 conversationEntry->ChangeAttributes(ECsAttributeDraft, ECsAttributeNone); |
|
548 conversationEntry->SetConversationDir(ECsDirectionOutgoing); |
|
549 conversationEntry->SetSendState( ECsSendStateUnknown ); |
|
550 conversationEntry->SetType( ECsSMS ); |
|
551 |
|
552 conversationEntry1->SetContactL(KResultPhoneNumberString); |
|
553 conversationEntry1->SetEntryId( indexEntry.Id()); |
|
554 conversationEntry1->SetTimeStampL( indexEntry.iDate.Int64()); |
|
555 conversationEntry1->SetDescriptionL(shortDescription); |
|
556 conversationEntry1->ChangeAttributes(ECsAttributeDraft, ECsAttributeNone); |
|
557 conversationEntry1->SetConversationDir(ECsDirectionOutgoing); |
|
558 conversationEntry1->SetSendState( ECsSendStateUnknown ); |
|
559 conversationEntry1->SetType( ECsSMS ); |
|
560 |
|
561 CleanupStack::PushL(conversationEntry1); |
|
562 iTestConversationEntryList.AppendL(conversationEntry); |
|
563 iTestConversationEntryList.AppendL(conversationEntry1); |
|
564 CleanupStack::Pop(conversationEntry1); |
|
565 } |
|
566 else if( aFolderId == KMsvGlobalOutBoxIndexEntryId ) |
|
567 { |
|
568 iSmsClientMtm->AddAddresseeL(KPhoneNumberString,TPtrC()); |
|
569 indexEntry.SetSendingState( KMsvSendStateWaiting ); |
|
570 |
|
571 conversationEntry->SetContactL(KPhoneNumberString); |
|
572 conversationEntry->SetEntryId( indexEntry.Id()); |
|
573 conversationEntry->SetTimeStampL( indexEntry.iDate.Int64()); |
|
574 conversationEntry->SetDescriptionL(shortDescription); |
|
575 conversationEntry->SetConversationDir(ECsDirectionOutgoing); |
|
576 conversationEntry->SetSendState( ECsSendStateWaiting ); |
|
577 conversationEntry->SetType( ECsSMS ); |
|
578 |
|
579 iTestConversationEntryList.AppendL(conversationEntry); |
|
580 } |
|
581 else if( aFolderId == KMsvSentEntryId ) |
|
582 { |
|
583 CSmsHeader& smsHeader = iSmsClientMtm->SmsHeader(); |
|
584 smsHeader.SetFromAddressL(KPhoneNumberString); |
|
585 indexEntry.iDetails.Set( KPhoneNumberString ); |
|
586 |
|
587 conversationEntry->SetContactL(KPhoneNumberString); |
|
588 conversationEntry->SetEntryId( indexEntry.Id()); |
|
589 conversationEntry->SetTimeStampL( indexEntry.iDate.Int64()); |
|
590 conversationEntry->SetDescriptionL(shortDescription); |
|
591 conversationEntry->SetConversationDir(ECsDirectionOutgoing); |
|
592 conversationEntry->SetSendState( ECsSendStateUnknown ); |
|
593 conversationEntry->SetType( ECsSMS ); |
|
594 |
|
595 iTestConversationEntryList.AppendL(conversationEntry); |
|
596 } |
|
597 // final fine tuning |
|
598 indexEntry.SetAttachment(EFalse); |
|
599 |
|
600 indexEntry.SetVisible(ETrue); |
|
601 indexEntry.SetInPreparation(EFalse); |
|
602 |
|
603 if ( aFolderId == KMsvGlobalInBoxIndexEntryId ) |
|
604 { |
|
605 CSmsHeader& smsHeader = iSmsClientMtm->SmsHeader(); |
|
606 smsHeader.SetFromAddressL(KPhoneNumberString); |
|
607 indexEntry.iDetails.Set( KPhoneNumberString ); |
|
608 |
|
609 if( aUnReadFlag ) |
|
610 { |
|
611 indexEntry.SetUnread(ETrue); |
|
612 conversationEntry->SetSendState( ECsSendStateUnknown ); |
|
613 conversationEntry->ChangeAttributes( ECsAttributeUnread, ECsAttributeNone ); |
|
614 } |
|
615 else |
|
616 { |
|
617 conversationEntry->SetSendState( ECsSendStateUnknown ); |
|
618 conversationEntry->ChangeAttributes( ECsAttributeNone, ECsAttributeUnread ); |
|
619 } |
|
620 conversationEntry->SetContactL(KPhoneNumberString); |
|
621 conversationEntry->SetEntryId( indexEntry.Id()); |
|
622 conversationEntry->SetTimeStampL( indexEntry.iDate.Int64()); |
|
623 conversationEntry->SetDescriptionL(shortDescription); |
|
624 conversationEntry->SetConversationDir(ECsDirectionIncoming); |
|
625 conversationEntry->SetType( ECsSMS ); |
|
626 |
|
627 iTestConversationEntryList.AppendL(conversationEntry); |
|
628 |
|
629 indexEntry.SetNew(ETrue); |
|
630 } |
|
631 |
|
632 indexEntry.SetComplete(ETrue); |
|
633 iSmsClientMtm->Entry().ChangeL(indexEntry); |
|
634 iSmsClientMtm->SaveMessageL(); |
|
635 |
|
636 if ( iTestConversationEntryList.Count() == 0 ) |
|
637 { |
|
638 CleanupStack::PopAndDestroy(conversationEntry); |
|
639 } |
|
640 else |
|
641 { |
|
642 CleanupStack::Pop(conversationEntry); |
|
643 } |
|
644 |
|
645 } |
|
646 |
|
647 |
|
648 // ----------------------------------------------------------------------------- |
|
649 // Ctest_plugin::CacheFromCcsPluginValidationL |
|
650 // Validates the initial Caching of sms plugin |
|
651 // ----------------------------------------------------------------------------- |
|
652 // |
|
653 TInt Ctest_plugin::SmsMsgPluginValidationL( CStifItemParser& /*aItem*/ ) |
|
654 { |
|
655 // Print to UI |
|
656 _LIT(Ktestplugin, "CacheFromCcsPluginValidationL" ); |
|
657 _LIT( KFunction, "In CacheFromCcsPluginValidationL" ); |
|
658 TestModuleIf().Printf( 0, Ktestplugin, KFunction ); |
|
659 // Print to log file |
|
660 iLog->Log( KFunction ); |
|
661 |
|
662 CleanAllFoldersL(); |
|
663 CreateInitialCacheL(); |
|
664 |
|
665 iPlugin = CCsMsg::NewL(this); |
|
666 iPlugin->GetConversationsL(); |
|
667 |
|
668 return KErrNone; |
|
669 } |
|
670 |
|
671 // ----------------------------------------------------------------------------- |
|
672 // Ctest_plugin::MmsPluginValidationL |
|
673 // Validates the initial Caching of sms plugin |
|
674 // ----------------------------------------------------------------------------- |
|
675 // |
|
676 TInt Ctest_plugin::MmsMsgPluginValidationL( CStifItemParser& /*aItem*/ ) |
|
677 { |
|
678 // Print to UI |
|
679 _LIT(Ktestplugin, "MmsPluginValidationL" ); |
|
680 _LIT( KFunction, "In MmsPluginValidationL" ); |
|
681 TestModuleIf().Printf( 0, Ktestplugin, KFunction ); |
|
682 // Print to log file |
|
683 iLog->Log( KFunction ); |
|
684 |
|
685 CleanAllFoldersL(); |
|
686 |
|
687 iTestConversationEntryList.ResetAndDestroy(); |
|
688 iResultConversationEntryList.ResetAndDestroy(); |
|
689 |
|
690 CreateMmsMessageL(KMsvGlobalInBoxIndexEntryId); |
|
691 CreateMmsMessageL(KMsvSentEntryId); |
|
692 CreateMmsMessageL(KMsvDraftEntryId); |
|
693 CreateMmsMessageL(KMsvGlobalOutBoxIndexEntryId);; |
|
694 |
|
695 iPlugin = CCsMsg::NewL(this); |
|
696 iPlugin->GetConversationsL(); |
|
697 |
|
698 return KErrNone; |
|
699 } |
|
700 |
|
701 // ----------------------------------------------------------------------------- |
|
702 // Ctest_plugin::BioMsgPluginValidationL |
|
703 // Validates the initial Caching of sms plugin |
|
704 // ----------------------------------------------------------------------------- |
|
705 // |
|
706 TInt Ctest_plugin::BioMsgPluginValidationL( CStifItemParser& /*aItem*/ ) |
|
707 { |
|
708 // Print to UI |
|
709 _LIT(Ktestplugin, "BioMsgPluginValidationL" ); |
|
710 _LIT( KFunction, "In BioMsgPluginValidationL" ); |
|
711 TestModuleIf().Printf( 0, Ktestplugin, KFunction ); |
|
712 // Print to log file |
|
713 iLog->Log( KFunction ); |
|
714 |
|
715 CleanAllFoldersL(); |
|
716 |
|
717 iTestConversationEntryList.ResetAndDestroy(); |
|
718 iResultConversationEntryList.ResetAndDestroy(); |
|
719 |
|
720 CreateSmartMessageL(KMsvGlobalOutBoxIndexEntryId); |
|
721 CreateSmartMessageL(KMsvSentEntryId); |
|
722 CreateSmartMessageL(KMsvDraftEntryId); |
|
723 CreateSmartMessageL(KMsvGlobalOutBoxIndexEntryId); |
|
724 |
|
725 iPlugin = CCsMsg::NewL(this); |
|
726 iPlugin->GetConversationsL(); |
|
727 |
|
728 return KErrNone; |
|
729 |
|
730 } |
|
731 |
|
732 // ----------------------------------------------------------------------------- |
|
733 // Ctest_plugin::CleanAllFoldersL |
|
734 // Cleans messages from all folders |
|
735 // ----------------------------------------------------------------------------- |
|
736 void Ctest_plugin::CleanAllFoldersL() |
|
737 { |
|
738 CleanMessagesInFolderL(KMsvGlobalInBoxIndexEntryId); |
|
739 CleanMessagesInFolderL(KMsvGlobalOutBoxIndexEntryId); |
|
740 CleanMessagesInFolderL(KMsvDraftEntryId); |
|
741 // CleanMessagesInFolderL(KMsvSentEntryId); |
|
742 } |
|
743 // ----------------------------------------------------------------------------- |
|
744 // Ctest_plugin::CreateInitialCacheL |
|
745 // Populates the messages in different folders which are used |
|
746 // to verify the caching logic of ccs plugin |
|
747 // ----------------------------------------------------------------------------- |
|
748 void Ctest_plugin::CreateInitialCacheL() |
|
749 { |
|
750 |
|
751 iTestConversationEntryList.ResetAndDestroy(); |
|
752 iResultConversationEntryList.ResetAndDestroy(); |
|
753 |
|
754 CreateMessageL(KMsvGlobalInBoxIndexEntryId); |
|
755 CreateMessageL(KMsvSentEntryId); |
|
756 CreateMessageL(KMsvDraftEntryId); |
|
757 CreateMessageL(KMsvGlobalOutBoxIndexEntryId); |
|
758 |
|
759 } |
|
760 |
|
761 // ----------------------------------------------------------------------------- |
|
762 // Ctest_plugin::CleanMessagesInFolderL |
|
763 // Cleans messages from the specified folder |
|
764 // ----------------------------------------------------------------------------- |
|
765 void Ctest_plugin::CleanMessagesInFolderL(TMsvId aBoxId,TBool aDeleteOne) |
|
766 { |
|
767 iLog->Log(_L("In CleanMessagesInFolderL")); |
|
768 TInt count; |
|
769 CMsvEntry* cEntry = NULL; |
|
770 // delete messages from the specified box |
|
771 cEntry = iSession->GetEntryL(KMsvRootIndexEntryId); |
|
772 CleanupStack::PushL(cEntry); |
|
773 cEntry->SetEntryL(aBoxId); |
|
774 // show invisible entries |
|
775 cEntry->SetSortTypeL( TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) ); |
|
776 CMsvEntrySelection* msvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeSMS); |
|
777 CleanupStack::PushL(msvEntrySelection); |
|
778 |
|
779 if( aDeleteOne ) |
|
780 { |
|
781 count =1; |
|
782 } |
|
783 else |
|
784 { |
|
785 count = msvEntrySelection->Count(); |
|
786 } |
|
787 |
|
788 for ( int i = 0; i < count ; i++ ) |
|
789 { |
|
790 CMsvEntry* entry = iSession->GetEntryL( msvEntrySelection->At(i) ); |
|
791 CleanupStack::PushL( entry ); |
|
792 TMsvEntry tEntry = entry->Entry(); |
|
793 tEntry.SetReadOnly(EFalse); |
|
794 entry->ChangeL(tEntry); |
|
795 cEntry->DeleteL( msvEntrySelection->At(i) ); |
|
796 CleanupStack::PopAndDestroy( entry ); |
|
797 } |
|
798 |
|
799 CleanupStack::PopAndDestroy(msvEntrySelection); |
|
800 CleanupStack::PopAndDestroy(cEntry); |
|
801 iLog->Log(_L("End of CleanMessagesInFolderL")); |
|
802 } |
|
803 |
|
804 |
|
805 |
|
806 |
|
807 // ----------------------------------------------------------------------------- |
|
808 // Ctest_plugin::CachingCompleted. |
|
809 // Caching error event from Plugins |
|
810 // ----------------------------------------------------------------------------- |
|
811 // |
|
812 void Ctest_plugin::CachingError(const TInt /*aError*/) |
|
813 { |
|
814 Signal(KErrGeneral); |
|
815 } |
|
816 |
|
817 // ----------------------------------------------------------------------------- |
|
818 // Ctest_plugin::CachingCompleted. |
|
819 // Caching complete event from Plugins |
|
820 // ----------------------------------------------------------------------------- |
|
821 // |
|
822 void Ctest_plugin::CachingCompleted() |
|
823 { |
|
824 if( iTestConversationEntryList.Count() == 0 ) |
|
825 { |
|
826 Signal(KErrNone); |
|
827 return; |
|
828 } |
|
829 if( iResultConversationEntryList.Count() != iTestConversationEntryList.Count() ) |
|
830 { |
|
831 // Delete(); |
|
832 Signal(KErrCancel); |
|
833 } |
|
834 else |
|
835 { |
|
836 TInt i; |
|
837 for( i=0; i < iResultConversationEntryList.Count() ; i++ ) |
|
838 { |
|
839 if( Compare(iResultConversationEntryList[i],iTestConversationEntryList[i] )!=0 ) |
|
840 { |
|
841 break; |
|
842 } |
|
843 } |
|
844 if( i == iResultConversationEntryList.Count() ) |
|
845 { |
|
846 iTestConversationEntryList.ResetAndDestroy(); |
|
847 iResultConversationEntryList.ResetAndDestroy(); |
|
848 Signal(KErrNone); |
|
849 } |
|
850 else |
|
851 { |
|
852 Signal(KErrNotFound); |
|
853 } |
|
854 } |
|
855 } |
|
856 |
|
857 // ----------------------------------------------------------------------------- |
|
858 // Ctest_plugin::Compare |
|
859 // Compares the conversation entry stored conversation entry with |
|
860 // the conversation entry returned from sms plugin |
|
861 // ----------------------------------------------------------------------------- |
|
862 TInt Ctest_plugin::Compare(CCsConversationEntry *aResult, CCsConversationEntry *aTest) |
|
863 { |
|
864 TInt comparison = 0; |
|
865 |
|
866 if( aResult->Contact()->Des().Compare(aTest->Contact()->Des()) ) |
|
867 comparison++; |
|
868 |
|
869 if( aResult->EntryId() != aTest->EntryId() ) |
|
870 comparison ++; |
|
871 |
|
872 if( aResult->TimeStamp() != aTest->TimeStamp() ) |
|
873 comparison++; |
|
874 |
|
875 if( aResult->ConversationDir() != aTest->ConversationDir() ) |
|
876 comparison++; |
|
877 |
|
878 if( aResult->GetSendState() != aTest->GetSendState() ) |
|
879 comparison++; |
|
880 |
|
881 if( aResult->GetType() != aTest->GetType() ) |
|
882 comparison++; |
|
883 |
|
884 return comparison; |
|
885 } |
|
886 |
|
887 |
|
888 // ----------------------------------------------------------------------------- |
|
889 // Ctest_plugin::AddConversations. |
|
890 // Handle Conversation event from Plugins |
|
891 // ----------------------------------------------------------------------------- |
|
892 // |
|
893 void Ctest_plugin::AddConversations( |
|
894 const RPointerArray<CCsConversationEntry>& aConversationEntryLists) |
|
895 { |
|
896 CCsConversationEntry *conversationEntry ; |
|
897 |
|
898 for ( TInt i=0; i < aConversationEntryLists.Count(); i++ ) |
|
899 { |
|
900 TRAP_IGNORE( |
|
901 conversationEntry = aConversationEntryLists[i]->CloneL(); |
|
902 iResultConversationEntryList.AppendL(conversationEntry); |
|
903 ); |
|
904 } |
|
905 |
|
906 } |
|
907 |
|
908 // ----------------------------------------------------------------------------- |
|
909 // Ctest_plugin::ModifyConversations. |
|
910 // Update Conversation event from Plugins |
|
911 // ----------------------------------------------------------------------------- |
|
912 // |
|
913 void Ctest_plugin::ModifyConversations( |
|
914 const RPointerArray<CCsConversationEntry>& aConversationEntryLists) |
|
915 { |
|
916 if( iTestConversationEntryList.Count() == 0 ) |
|
917 { |
|
918 Signal(KErrNone); |
|
919 return; |
|
920 } |
|
921 //Expecting update for one entry at a time |
|
922 TInt i; |
|
923 for( i=0; i < aConversationEntryLists.Count() ; i++ ) |
|
924 { |
|
925 if( Compare(aConversationEntryLists[i],iTestConversationEntryList[i] )!=0 ) |
|
926 { |
|
927 break; |
|
928 } |
|
929 } |
|
930 if( i == aConversationEntryLists.Count() ) |
|
931 { |
|
932 iTestConversationEntryList.ResetAndDestroy(); |
|
933 iResultConversationEntryList.ResetAndDestroy(); |
|
934 Signal(KErrNone); |
|
935 } |
|
936 else |
|
937 { |
|
938 Signal(KErrNotFound); |
|
939 } |
|
940 } |
|
941 |
|
942 // ----------------------------------------------------------------------------- |
|
943 // Ctest_plugin::DeleteConversations. |
|
944 // Delete Conversation event from Plugins |
|
945 // ----------------------------------------------------------------------------- |
|
946 // |
|
947 |
|
948 void Ctest_plugin::DeleteConversations( |
|
949 const RPointerArray<CCsConversationEntry>& aConversationEntryLists) |
|
950 { |
|
951 if( iTestConversationEntryList.Count() == 0 ) |
|
952 { |
|
953 Signal(KErrNone); |
|
954 return; |
|
955 } |
|
956 //Expecting update for one entry at a time |
|
957 TInt i; |
|
958 for( i=0; i < aConversationEntryLists.Count() ; i++ ) |
|
959 { |
|
960 if( aConversationEntryLists[i]->EntryId() != iTestConversationEntryList[i]->EntryId() ) |
|
961 { |
|
962 break; |
|
963 } |
|
964 } |
|
965 if( i == aConversationEntryLists.Count() ) |
|
966 { |
|
967 iTestConversationEntryList.ResetAndDestroy(); |
|
968 iResultConversationEntryList.ResetAndDestroy(); |
|
969 Signal(KErrNone); |
|
970 } |
|
971 else |
|
972 { |
|
973 Signal(KErrNotFound); |
|
974 } |
|
975 } |
|
976 |
|
977 // ----------------------------------------------------------------------------- |
|
978 // Ctest_plugin::RefreshConversations |
|
979 // Notify server to refresh conversations. |
|
980 // ----------------------------------------------------------------------------- |
|
981 // |
|
982 void Ctest_plugin::RefreshConversations() |
|
983 { |
|
984 |
|
985 } |