1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 */ |
|
16 |
|
17 #include <mtmdef.h> |
|
18 #include <CoreApplicationUIsSDKCRKeys.h> |
|
19 #include <mmsheaders.h> |
|
20 #include <mmscmds.h> |
|
21 #include <mmsencode.h> |
|
22 #include <mmscliententry.h> |
|
23 #include <logwrap.h> |
|
24 #include <logcli.h> |
|
25 #include <logview.h> |
|
26 #include "mmssettings.h" //use mmssettings.h instead of cmmssettings.h |
|
27 #include "mmstestbed.h" |
|
28 #include "mmsreadfile.h" |
|
29 #include "mmstestuitimer.h" |
|
30 #include "mmsteststaticutils.h" |
|
31 #include "mmstestbed.hrh" |
|
32 |
|
33 //constants |
|
34 _LIT( KMmsSender, "0601234567" ); |
|
35 |
|
36 MmsTestBed::MmsTestBed() |
|
37 { |
|
38 //start the timer |
|
39 iTimer = CTestUiTimer::NewL(); |
|
40 iTimer->Cancel(); |
|
41 |
|
42 iWait = CMsvOperationActiveSchedulerWait::NewLC(); |
|
43 // don't leave iWait on cleanup stack |
|
44 CleanupStack::Pop(); |
|
45 |
|
46 //open msvsession |
|
47 iSession = CMsvSession::OpenSyncL(*this); |
|
48 //create client registry |
|
49 iClientMtmRegistry = CClientMtmRegistry::NewL(*iSession); |
|
50 //create client mtm |
|
51 iMmsClient = (CMmsClientMtm *) iClientMtmRegistry->NewMtmL( |
|
52 KUidMsgTypeMultimedia); |
|
53 |
|
54 User::LeaveIfError( iFs.Connect() ); |
|
55 iFs.SetSessionPath( KRootPath ); |
|
56 iSettings = CMmsSettings::NewL(); |
|
57 iMmsHeaders = CMmsHeaders::NewL(iSettings->MmsVersion()); |
|
58 findDefaultL(); |
|
59 iServiceId = iDefaultServiceId; |
|
60 |
|
61 //validate the settings |
|
62 iSettings->ValidateSettings(); |
|
63 |
|
64 iLogEvent = CLogEvent::NewL(); |
|
65 iLogEvent->SetEventType(KLogMmsEventTypeUid); |
|
66 iLogClient = NULL; // we test soon if this is available |
|
67 iLogView = NULL; // needs log client |
|
68 if ( checkLogClient() ) |
|
69 { |
|
70 // first we generate a general view of all events |
|
71 // we'll set the filter when we update the view |
|
72 iLogView = CLogViewEvent::NewL( *iLogClient ); |
|
73 } |
|
74 iLogFilter = CLogFilter::NewL(); |
|
75 // we try to filter MMS events |
|
76 iLogFilter->SetEventType(KLogMmsEventTypeUid); |
|
77 } |
|
78 |
|
79 MmsTestBed::~MmsTestBed() |
|
80 { |
|
81 delete iLogView; |
|
82 delete iLogFilter; |
|
83 delete iLogClient; |
|
84 delete iLogEvent; |
|
85 delete iSettings; |
|
86 delete iMmsHeaders; |
|
87 if(iTimer) |
|
88 { |
|
89 iTimer->Cancel(); |
|
90 delete iTimer; |
|
91 } |
|
92 //delete iMsvEntrySelection; |
|
93 delete iMmsClient; |
|
94 delete iClientMtmRegistry; |
|
95 //delete iClientMtmRegistry; |
|
96 delete iSession; |
|
97 delete iWait; |
|
98 } |
|
99 |
|
100 void MmsTestBed::setConnectionLocal(bool value) |
|
101 { |
|
102 //value = true for global off, local on |
|
103 //value = false for global on, local off |
|
104 iSettings->LoadSettingsL(); |
|
105 iSettings->SetLocalMode( value ); |
|
106 iSettings->SaveSettingsL(); |
|
107 } |
|
108 |
|
109 void MmsTestBed::fromOutboxToMmsc() |
|
110 { |
|
111 CMsvEntry* cEntry = NULL; |
|
112 |
|
113 // Get List of services |
|
114 cEntry = iSession->GetEntryL(KMsvGlobalOutBoxIndexEntryIdValue); |
|
115 CleanupStack::PushL(cEntry); |
|
116 // Get all mms messages of outbox |
|
117 CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( |
|
118 KUidMsgTypeMultimedia); |
|
119 CleanupStack::PushL(selection); |
|
120 |
|
121 // Change state to "KMsvSendStateUnknown" in case the entry has been suspended earlier |
|
122 for (TInt i = 0; i < selection->Count(); ++i) |
|
123 { |
|
124 cEntry->SetEntryL(selection->At(i)); |
|
125 TMsvEntry entry = cEntry->Entry(); |
|
126 entry.SetReadOnly(EFalse); |
|
127 entry.SetSendingState(KMsvSendStateUnknown); |
|
128 cEntry->ChangeL(entry); |
|
129 } |
|
130 |
|
131 selection->InsertL(0, iServiceId); |
|
132 |
|
133 CMsvOperation * op = NULL; |
|
134 TCommandParameters parameters; // initialized to zero |
|
135 TCommandParametersBuf paramPack(parameters); |
|
136 |
|
137 op = iSession->TransferCommandL(*selection, EMmsSend, paramPack, |
|
138 iWait->iStatus); |
|
139 |
|
140 CleanupStack::PushL(op); |
|
141 iWait->Start(); |
|
142 |
|
143 while (iWait->iStatus.Int() == KRequestPending) |
|
144 { |
|
145 if (!iTimer->IsActive()) |
|
146 { |
|
147 iTimer->IssueRequest(); |
|
148 } |
|
149 CActiveScheduler::Start(); |
|
150 } |
|
151 |
|
152 if (iWait->iStatus.Int() != KErrNone) |
|
153 { |
|
154 //DEBUG(_L("Testbed tried to send, return status %d"), iWait->iStatus.Int()); |
|
155 } |
|
156 |
|
157 iTimer->Cancel(); |
|
158 |
|
159 CleanupStack::PopAndDestroy(); // op |
|
160 CleanupStack::PopAndDestroy(); // selection |
|
161 CleanupStack::PopAndDestroy(); //cEntry |
|
162 } |
|
163 |
|
164 void MmsTestBed::fromMmscToInbox() |
|
165 { |
|
166 CMsvEntrySelection* msvEntrySelection = new CMsvEntrySelection; |
|
167 CleanupStack::PushL(msvEntrySelection); |
|
168 |
|
169 // if we have a selected service, insert it into selection |
|
170 if (iServiceId != KMsvNullIndexEntryId) |
|
171 { |
|
172 msvEntrySelection->InsertL(0, iServiceId); |
|
173 } |
|
174 |
|
175 CMsvOperation * op = NULL; |
|
176 TCommandParameters parameters; // initialized to zero |
|
177 TCommandParametersBuf paramPack(parameters); |
|
178 |
|
179 op = iMmsClient->InvokeAsyncFunctionL(EMmsReceive, *msvEntrySelection, |
|
180 paramPack, iWait->iStatus); |
|
181 |
|
182 CleanupStack::PushL(op); |
|
183 iWait->Start(); |
|
184 |
|
185 while (iWait->iStatus.Int() == KRequestPending) |
|
186 { |
|
187 if (!iTimer->IsActive()) |
|
188 { |
|
189 iTimer->IssueRequest(); |
|
190 } |
|
191 CActiveScheduler::Start(); |
|
192 } |
|
193 |
|
194 if (iWait->iStatus.Int() != KErrNone) |
|
195 { |
|
196 //DEBUG(_L("Testbed tried to receive, return status %d"),iWait->iStatus.Int()); |
|
197 } |
|
198 |
|
199 iTimer->Cancel(); |
|
200 CleanupStack::PopAndDestroy(); // op |
|
201 CleanupStack::PopAndDestroy(); //msvEntrySelection |
|
202 } |
|
203 |
|
204 void MmsTestBed::findDefaultL() |
|
205 { |
|
206 iSettings->LoadSettingsL(); |
|
207 iDefaultServiceId = iSettings->Service(); |
|
208 } |
|
209 |
|
210 void MmsTestBed::HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, |
|
211 TAny* aArg2, TAny* /*aArg3*/) |
|
212 { |
|
213 iEvent = aEvent; |
|
214 if (aEvent == EMsvGeneralError) |
|
215 { |
|
216 return; |
|
217 } |
|
218 TMsvId parentId = KMsvNullIndexEntryId; |
|
219 if (aArg2 != NULL) |
|
220 { |
|
221 parentId = *(TMsvId*) aArg2; |
|
222 } |
|
223 |
|
224 CMsvEntrySelection* selection = (CMsvEntrySelection*) aArg1; |
|
225 TMsvEntry tEntry; |
|
226 TMsvId service; |
|
227 TInt error = KErrNone; |
|
228 error = iSession->GetEntry(selection->At(0), service, tEntry); |
|
229 |
|
230 CMsvEntry* cEntry = NULL; |
|
231 switch (aEvent) |
|
232 { |
|
233 case EMsvEntriesCreated: |
|
234 { |
|
235 if (parentId == KMsvGlobalInBoxIndexEntryIdValue) |
|
236 { |
|
237 // emit signal for new entry into INBOX |
|
238 emit entryCreatedInInbox(tEntry.Id()); |
|
239 } |
|
240 else if (parentId == KMsvDraftEntryIdValue) |
|
241 { |
|
242 // emit signal for new entry into Draft |
|
243 emit entryCreatedInDraft(tEntry.Id()); |
|
244 } |
|
245 else if (parentId == iServiceId) |
|
246 { |
|
247 // emit signal for new Entry into SERVICE |
|
248 } |
|
249 else |
|
250 { |
|
251 // do nothing |
|
252 } |
|
253 } |
|
254 break; |
|
255 case EMsvEntriesChanged: |
|
256 { |
|
257 TMsvId id; |
|
258 CMsvEntrySelection* selection = (CMsvEntrySelection*) aArg1; |
|
259 if (selection == NULL) |
|
260 { |
|
261 // no selection, cannot handle |
|
262 return; |
|
263 } |
|
264 id = selection->At(0); |
|
265 //DEBUG Entry changed")); |
|
266 if (parentId == KMsvGlobalInBoxIndexEntryIdValue) |
|
267 { |
|
268 /* |
|
269 cEntry = iSession->GetEntryL( parentId ); |
|
270 CleanupStack::PushL( cEntry ); |
|
271 TRAPD (error, cEntry->SetEntryL( id )); |
|
272 if ( error != KErrNone ) |
|
273 { |
|
274 CleanupStack::PopAndDestroy(); // cEntry |
|
275 return; |
|
276 } |
|
277 TMsvEntry tEntry = cEntry->Entry(); |
|
278 if ( tEntry.Visible() ) |
|
279 { |
|
280 // generate fake delivery report |
|
281 CMsvStore* store = cEntry->ReadStoreL(); |
|
282 CleanupStack::PushL( store ); |
|
283 CMmsHeaders* mmsHeaders = CMmsHeaders::NewL( iSettings->MmsVersion() ); |
|
284 CleanupStack::PushL( mmsHeaders ); |
|
285 mmsHeaders->RestoreL( *store ); |
|
286 iEncodeBuffer->ResizeL( 0 ); |
|
287 generateDeliveryReport( mmsHeaders ); |
|
288 CleanupStack::PopAndDestroy( 2 ); // mmsHeaders, store |
|
289 } |
|
290 CleanupStack::PopAndDestroy(); // cEntry |
|
291 */ |
|
292 } |
|
293 } |
|
294 break; |
|
295 case EMsvEntriesDeleted: |
|
296 { |
|
297 //emit signal for entry deleted |
|
298 } |
|
299 break; |
|
300 case EMsvEntriesMoved: |
|
301 { |
|
302 if (parentId == KMsvGlobalOutBoxIndexEntryIdValue) |
|
303 { |
|
304 // entry moved to outbox |
|
305 emit entryMovedToOutbox(tEntry.Id()); |
|
306 } |
|
307 else if (parentId == KMsvSentEntryIdValue) |
|
308 { |
|
309 // entry moved to sent folder |
|
310 emit entryMovedToSent(tEntry.Id()); |
|
311 } |
|
312 else |
|
313 { |
|
314 // do nothing |
|
315 } |
|
316 } |
|
317 break; |
|
318 default: |
|
319 break; |
|
320 } |
|
321 } |
|
322 |
|
323 void MmsTestBed::createMmsService() |
|
324 { |
|
325 CMmsSettings * settings = CMmsSettings::NewL(); |
|
326 CleanupStack::PushL( settings ); |
|
327 settings->CreateNewServiceL( *iSession ); |
|
328 CleanupStack::PopAndDestroy(); // settings |
|
329 return; |
|
330 } |
|
331 |
|
332 void MmsTestBed::cleanup() |
|
333 { |
|
334 TMsvId entryToBeKilled; |
|
335 // Get access to root index |
|
336 CMsvEntry* cEntry = iSession->GetEntryL(KMsvRootIndexEntryId); |
|
337 CleanupStack::PushL(cEntry); |
|
338 |
|
339 entryToBeKilled = iSettings->Service(); |
|
340 cEntry->SetSortTypeL( TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) ); |
|
341 while (entryToBeKilled != KMsvNullIndexEntryId) |
|
342 { |
|
343 // delete child of root entry |
|
344 deleteEntry(entryToBeKilled, *cEntry); |
|
345 entryToBeKilled = iSettings->Service(); |
|
346 } |
|
347 |
|
348 CleanupStack::PopAndDestroy(); // cEntry |
|
349 // We deleted everything! |
|
350 iDefaultServiceId = KMsvNullIndexEntryId; |
|
351 iServiceId = KMsvNullIndexEntryId; |
|
352 } |
|
353 |
|
354 void MmsTestBed::deleteEntry(TMsvId aEntryId, CMsvEntry& aClientEntry) |
|
355 { |
|
356 aClientEntry.DeleteL(aEntryId); |
|
357 } |
|
358 |
|
359 void MmsTestBed::cleanupAndCreateNewService() |
|
360 { |
|
361 cleanup(); |
|
362 // all old service entries have been destroyed, create a new one |
|
363 createMmsService(); |
|
364 } |
|
365 |
|
366 void MmsTestBed::testFile(TFileName& aFilePath, TInt aCommand /* = 0 */, TMsvId aBox /* = KMsvGlobalOutBoxIndexEntryId */ ) |
|
367 { |
|
368 // update settings in mmsclient |
|
369 iMmsClient->RestoreSettingsL(); |
|
370 iSettings->CopyL( iMmsClient->MmsSettings() ); |
|
371 |
|
372 RFileReadStream readStream; |
|
373 readStream.PushL(); |
|
374 // TMsvId id = KMsvNullIndexEntryId; |
|
375 CBufFlat* encodeBuffer = NULL; |
|
376 CMmsEncode* encoder = NULL; |
|
377 |
|
378 // Open the file |
|
379 TInt err = readStream.Open(iFs, aFilePath, EFileShareReadersOnly ); |
|
380 if (err != KErrNone) User::Leave( err ); |
|
381 |
|
382 TInt retCode = 0; |
|
383 CMmsReadFile* readFile = NULL; |
|
384 readFile = CMmsReadFile::NewL( iFs, readStream ); |
|
385 CleanupStack::PushL( readFile ); |
|
386 |
|
387 TInt messageCounter = 0; |
|
388 CMsvEntry* cEntry = NULL; |
|
389 |
|
390 while(!retCode) |
|
391 { |
|
392 // READ MESSAGE TO BUFFERS |
|
393 iMmsHeaders->Reset(iSettings); |
|
394 // put in some message type just for fun (testing...) |
|
395 iMmsHeaders->SetMessageType( KMmsMessageTypeForwardReq ); |
|
396 retCode = readFile->CompleteTestL( messageCounter++, *iMmsHeaders ); |
|
397 if(readFile->iMessageType == ETestNewMessage) |
|
398 { |
|
399 // CREATE MESSAGE ENTRY |
|
400 switch ( aCommand ) |
|
401 { |
|
402 case ECreateToInbox: |
|
403 case ECreateNotification: |
|
404 cEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId); |
|
405 break; |
|
406 case ECreateToSentItems: |
|
407 cEntry = iSession->GetEntryL(KMsvSentEntryId); |
|
408 break; |
|
409 case ECreateToDrafts: |
|
410 cEntry = iSession->GetEntryL(KMsvDraftEntryId); |
|
411 break; |
|
412 case ECreateHeadersFromFile: |
|
413 // here we just encode headers, no message entry |
|
414 // the entry is fake. |
|
415 break; |
|
416 case ECreateMMBoxViewConf: |
|
417 if ( iMmsHeaders->MessageType() == KMmsMessageTypeMboxViewConf ) |
|
418 { |
|
419 // entry is not created for the description items |
|
420 // they become attachments |
|
421 cEntry = iSession->GetEntryL(KMsvDraftEntryId); |
|
422 } |
|
423 break; |
|
424 default: |
|
425 cEntry = iSession->GetEntryL(aBox); |
|
426 break; |
|
427 } |
|
428 |
|
429 // if we are just playing with headers we have no entry |
|
430 if ( aCommand != ECreateHeadersFromFile && aCommand != ECreateMMBoxViewConf ) |
|
431 { |
|
432 CleanupStack::PushL(cEntry); |
|
433 iMmsClient->SwitchCurrentEntryL(cEntry->EntryId()); |
|
434 |
|
435 // CREATE MESSAGE |
|
436 iMmsClient->CreateMessageL(iServiceId); |
|
437 } |
|
438 else if ( aCommand == ECreateMMBoxViewConf ) |
|
439 { |
|
440 if ( iMmsHeaders->MessageType() == KMmsMessageTypeMboxViewConf ) |
|
441 { |
|
442 CleanupStack::PushL(cEntry); |
|
443 iMmsClient->SwitchCurrentEntryL(cEntry->EntryId()); |
|
444 |
|
445 // CREATE MESSAGE |
|
446 iMmsClient->CreateMessageL(iServiceId); |
|
447 } |
|
448 else |
|
449 { |
|
450 encodeBuffer = CBufFlat::NewL( 4 * 1024 ); // should be plenty |
|
451 CleanupStack::PushL( encodeBuffer ); |
|
452 encoder = CMmsEncode::NewL( iFs ); |
|
453 CleanupStack::PushL( encoder ); |
|
454 |
|
455 // encode headers to a binary file |
|
456 encoder->EncodeHeadersL( *iMmsHeaders, *encodeBuffer ); |
|
457 |
|
458 iFilename = KMmsMMBoxDescriptionDirectory; |
|
459 TMmsTestUtils::Dump( *encodeBuffer, iFilename, iParse, iFs ); |
|
460 |
|
461 CleanupStack::PopAndDestroy( 2 ); // encodeBuffer, encoder |
|
462 encodeBuffer = NULL; |
|
463 encoder = NULL; |
|
464 } |
|
465 } |
|
466 else |
|
467 { |
|
468 encodeBuffer = CBufFlat::NewL( 4 * 1024 ); // should be plenty |
|
469 CleanupStack::PushL( encodeBuffer ); |
|
470 encoder = CMmsEncode::NewL( iFs ); |
|
471 CleanupStack::PushL( encoder ); |
|
472 |
|
473 // encode headers to a binary file |
|
474 encoder->EncodeHeadersL( *iMmsHeaders, *encodeBuffer ); |
|
475 |
|
476 iFilename = KMmsDumpDirectory; |
|
477 TMmsTestUtils::Dump( *encodeBuffer, iFilename, iParse, iFs ); |
|
478 |
|
479 CleanupStack::PopAndDestroy( 2 ); // encodeBuffer, encoder |
|
480 encodeBuffer = NULL; |
|
481 encoder = NULL; |
|
482 } |
|
483 } |
|
484 |
|
485 if ( aCommand != ECreateHeadersFromFile && |
|
486 ( aCommand != ECreateMMBoxViewConf || iMmsHeaders->MessageType() == KMmsMessageTypeMboxViewConf ) ) |
|
487 { |
|
488 if(readFile->iMessageType == ETestSettings) |
|
489 { |
|
490 TMsvId ServiceId = iMmsClient->DefaultServiceL(); |
|
491 iMmsClient->RestoreSettingsL(); |
|
492 iSettings->CopyL( iMmsClient->MmsSettings() ); |
|
493 } |
|
494 |
|
495 TMemoryInfoV1Buf memory; |
|
496 UserHal::MemoryInfo( memory ); |
|
497 TInt available = memory().iFreeRamInBytes; |
|
498 // TMmsLogger::Log(_L("Free memory before CreateMessageL %d"), available ); |
|
499 |
|
500 TRAP (err, readFile->CreateMessageL(iMmsClient, iMmsHeaders)); |
|
501 |
|
502 available = memory().iFreeRamInBytes; |
|
503 // TMmsLogger::Log(_L("Free memory after CreateMessageL %d"), available ); |
|
504 |
|
505 if(readFile->iMessageType == ETestNewMessage) |
|
506 { |
|
507 TMsvEntry tEntry = iMmsClient->Entry().Entry(); |
|
508 TMsvId id = tEntry.Id(); |
|
509 if ( err == KErrNone ) |
|
510 { |
|
511 // SAVE MESSAGE |
|
512 iMmsClient->SaveMessageL(); |
|
513 |
|
514 // If we are creating a MMBox View confirmation, |
|
515 // we add all binary files from KMmsMMBoxDirectory |
|
516 // as attachments. |
|
517 |
|
518 if ( iMmsHeaders->MessageType() == KMmsMessageTypeMboxViewConf ) |
|
519 { |
|
520 addMMBoxDescriptions(); |
|
521 } |
|
522 |
|
523 // reload the entry in case mms client put something into it |
|
524 // MESSAGE MUST BE SET VISIBLE |
|
525 tEntry = iMmsClient->Entry().Entry(); |
|
526 if ( iMmsClient->MessageClass() == EMmsClassAdvertisement ) |
|
527 { |
|
528 tEntry.iMtmData1 |= KMmsMessageAdvertisement; |
|
529 } |
|
530 else if ( iMmsClient->MessageClass() == EMmsClassInformational ) |
|
531 { |
|
532 tEntry.iMtmData1 |= KMmsMessageInformational; |
|
533 } |
|
534 tEntry.iMtmData1 &= ~KMmsMessageMobileTerminated; |
|
535 |
|
536 // Test: Set all as editor oriented - except notifications! |
|
537 if ( aCommand == ECreateNotification ) |
|
538 { |
|
539 tEntry.iMtm = KUidMsgMMSNotification; |
|
540 } |
|
541 else |
|
542 { |
|
543 tEntry.iMtmData1 |= KMmsMessageEditorOriented; |
|
544 } |
|
545 if ( aCommand == ECreateToInbox ) |
|
546 { |
|
547 tEntry.iMtmData1 |= KMmsMessageMobileTerminated; |
|
548 tEntry.SetReadOnly( ETrue ); |
|
549 tEntry.SetNew( ETrue ); |
|
550 tEntry.SetUnread( ETrue ); |
|
551 } |
|
552 else if ( aCommand == ECreateToSentItems ) |
|
553 { |
|
554 tEntry.SetReadOnly( ETrue ); |
|
555 } |
|
556 tEntry.SetVisible( ETrue ); |
|
557 tEntry.SetInPreparation( EFalse ); |
|
558 TTime now; |
|
559 now.UniversalTime(); |
|
560 tEntry.iDate = now; |
|
561 TMsvId entryId = tEntry.Id(); |
|
562 iMmsClient->Entry().ChangeL( tEntry ); |
|
563 if ( iMmsHeaders->MessageType() == KMmsMessageTypeMboxViewConf ) |
|
564 { |
|
565 // Encode to the directory that is used to fetch MMBox view |
|
566 iFilename.Copy( KMmsMMBoxDirectory ); |
|
567 encodeMessageFromDrafts(); |
|
568 cEntry->SetEntryL( KMsvDraftEntryId ); |
|
569 cEntry->DeleteL( entryId ); |
|
570 } |
|
571 } |
|
572 else |
|
573 { |
|
574 //TMmsLogger::Log(_L("CreateMessageL left with error %d"), err ); |
|
575 iSession->RemoveEntry(id); |
|
576 err = KErrNone; // clear error |
|
577 } |
|
578 CleanupStack::PopAndDestroy(); // cEntry |
|
579 cEntry = NULL; |
|
580 } |
|
581 if(readFile->iMessageType == ETestSettings) |
|
582 { |
|
583 iMmsClient->SetSettingsL( *iSettings ); |
|
584 iMmsClient->StoreSettingsL(); |
|
585 } |
|
586 } |
|
587 } |
|
588 |
|
589 CleanupStack::PopAndDestroy(); //readFile |
|
590 |
|
591 readStream.Close(); |
|
592 readStream.Pop(); |
|
593 |
|
594 /* |
|
595 iMmsClient->SwitchCurrentEntryL(id); |
|
596 */ |
|
597 } |
|
598 |
|
599 void MmsTestBed::addMMBoxDescriptions() |
|
600 { |
|
601 // add the contents of KMmsMMBoxDescriptionDirectory as attachments |
|
602 CDir* fileList = NULL; |
|
603 TInt i = 0; // general counter |
|
604 TInt error = KErrNone; |
|
605 iCurrentPath = KMmsMMBoxDescriptionDirectory; |
|
606 |
|
607 iFs.SetSessionPath(iCurrentPath); |
|
608 |
|
609 TFindFile finder( iFs ); |
|
610 error = finder.FindWildByPath( KWild, NULL, fileList ); |
|
611 CleanupStack::PushL( fileList ); |
|
612 TInt fileCounter = 0; |
|
613 |
|
614 if ( error == KErrNone ) |
|
615 { |
|
616 fileCounter = fileList->Count(); |
|
617 } |
|
618 |
|
619 TEntry entry; |
|
620 |
|
621 if ( error == KErrNone ) |
|
622 { |
|
623 for ( i = 0; i < fileCounter; ++i ) |
|
624 { |
|
625 // Reset inactivity timer to keep viewServer from crashing |
|
626 User::ResetInactivityTime(); |
|
627 entry = (*fileList)[i]; // name is entry.iName |
|
628 iFilename.Copy( iCurrentPath ); |
|
629 iFilename.Append( entry.iName ); |
|
630 TPtrC ptr; |
|
631 ptr.Set( iFilename ); |
|
632 iWait->iStatus = KErrNone; |
|
633 iMmsClient->AddAttachmentL( ptr, KMmsMimeType, 0, iWait->iStatus ); |
|
634 |
|
635 iWait->Start(); |
|
636 // The descriptions are cleared after being used |
|
637 iFs.Delete( ptr); |
|
638 } |
|
639 } |
|
640 |
|
641 iMmsClient->SaveMessageL(); // just in case somthing must be updated |
|
642 CleanupStack::PopAndDestroy(); // fileList |
|
643 fileList = NULL; |
|
644 } |
|
645 |
|
646 void MmsTestBed::encodeMessageFromDrafts() |
|
647 { |
|
648 CMmsEncode* encoder = CMmsEncode::NewL( iFs ); |
|
649 CleanupStack::PushL( encoder ); |
|
650 // encode a message iMmsClientPoints to |
|
651 iMmsClient->LoadMessageL(); |
|
652 CMsvStore* store = iMmsClient->Entry().ReadStoreL(); |
|
653 CleanupStack::PushL( store ); |
|
654 iMmsHeaders->RestoreL( *store ); |
|
655 CleanupStack::PopAndDestroy(); // store |
|
656 store = NULL; |
|
657 iWait->iStatus = KErrNone; |
|
658 |
|
659 // caller sets the directory |
|
660 // iFilename = KMmsMessageDumpDirectory; |
|
661 |
|
662 CMmsClientEntry* entryWrapper = CMmsClientEntry::NewL( iFs, iMmsClient->Entry(), iServiceId ); |
|
663 CleanupStack::PushL( entryWrapper ); |
|
664 iEncodeBuffer->ResizeL(0); |
|
665 encoder->StartL( *entryWrapper, *iMmsHeaders, *iEncodeBuffer, iWait->iStatus ); |
|
666 iWait->Start(); |
|
667 if ( iWait->iStatus == KErrNone ) |
|
668 { |
|
669 TMmsTestUtils::Dump( *iEncodeBuffer, iFilename, iParse, iFs ); |
|
670 } |
|
671 iEncodeBuffer->ResizeL(0); |
|
672 CleanupStack::PopAndDestroy(); // entryWrapper |
|
673 CleanupStack::PopAndDestroy(); // encoder |
|
674 } |
|
675 |
|
676 void MmsTestBed::deleteNotifications() |
|
677 { |
|
678 TMsvId mmsFolderId = KMsvNullIndexEntryId; |
|
679 mmsFolderId = findMMSFolder(); |
|
680 |
|
681 CMsvEntry* cEntry = NULL; |
|
682 // delete all messages from the specified box |
|
683 cEntry = iSession->GetEntryL(KMsvRootIndexEntryId); |
|
684 CleanupStack::PushL(cEntry); |
|
685 |
|
686 if ( mmsFolderId != KMsvNullIndexEntryId ) |
|
687 { |
|
688 cEntry->SetEntryL(mmsFolderId); |
|
689 |
|
690 // show invisible entries |
|
691 cEntry->SetSortTypeL( TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) ); |
|
692 CMsvEntrySelection* msvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia); |
|
693 CleanupStack::PushL(msvEntrySelection); |
|
694 |
|
695 TCommandParameters parameters; // initialized to zero |
|
696 TCommandParametersBuf paramPack( parameters ); |
|
697 |
|
698 if (msvEntrySelection->Count() > 0) |
|
699 { |
|
700 CMsvOperation* op = iSession->TransferCommandL( |
|
701 *msvEntrySelection, |
|
702 EMmsDeleteEntries, |
|
703 paramPack, |
|
704 iWait->iStatus); |
|
705 CleanupStack::PushL(op); |
|
706 iWait->Start(); |
|
707 CleanupStack::PopAndDestroy(); // op |
|
708 } |
|
709 |
|
710 // These cannot be deleted unless we have the a server mtm |
|
711 // corresponding to this mtm type. |
|
712 cEntry->SetSortTypeL( TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) ); |
|
713 CleanupStack::PopAndDestroy(); //msvEntrySelection |
|
714 msvEntrySelection = cEntry->ChildrenWithMtmL( KUidMsgMMSNotification ); |
|
715 CleanupStack::PushL(msvEntrySelection); |
|
716 |
|
717 if (msvEntrySelection->Count() > 0) |
|
718 { |
|
719 CMsvOperation* op = iSession->TransferCommandL( |
|
720 *msvEntrySelection, |
|
721 EMmsDeleteEntries, |
|
722 paramPack, |
|
723 iWait->iStatus); |
|
724 CleanupStack::PushL(op); |
|
725 iWait->Start(); |
|
726 CleanupStack::PopAndDestroy(); // op |
|
727 } |
|
728 |
|
729 CleanupStack::PopAndDestroy(); //msvEntrySelection |
|
730 |
|
731 CleanupStack::PopAndDestroy(); //cEntry |
|
732 } |
|
733 } |
|
734 |
|
735 TMsvId MmsTestBed::findMMSFolder() |
|
736 { |
|
737 return iSettings->NotificationFolder(); |
|
738 } |
|
739 |
|
740 void MmsTestBed::restoreFactorySettings() |
|
741 { |
|
742 iMmsClient->RestoreSettingsL(); |
|
743 iSettings->CopyL( iMmsClient->MmsSettings() ); |
|
744 // do not reset access point |
|
745 TInt accessPoint = iSettings->AccessPoint( 0 ); |
|
746 iSettings->RestoreFactorySettingsL( iMmsClient->Session(), EMmsFactorySettingsLevelDeep ); |
|
747 TInt count = iSettings->AccessPointCount(); |
|
748 TInt i = 0; |
|
749 for ( i = count - 1; i >= 0; --i ) |
|
750 { |
|
751 iSettings->DeleteAccessPointL( i ); |
|
752 } |
|
753 // restore the original access point |
|
754 if ( accessPoint > 0 ) |
|
755 { |
|
756 // a negative access point is an error (most likely "KErrNotFound") |
|
757 iSettings->AddAccessPointL( accessPoint, 0 ); |
|
758 } |
|
759 iMmsClient->SetSettingsL( *iSettings ); |
|
760 iMmsClient->StoreSettingsL(); |
|
761 } |
|
762 |
|
763 void MmsTestBed::setFetchingState( TMmsReceivingMode aState ) |
|
764 { |
|
765 iMmsClient->RestoreSettingsL(); |
|
766 iSettings->CopyL( iMmsClient->MmsSettings() ); |
|
767 |
|
768 iSettings->SetReceivingModeHome( aState ); |
|
769 |
|
770 iMmsClient->SetSettingsL( *iSettings ); |
|
771 iMmsClient->StoreSettingsL(); |
|
772 } |
|
773 |
|
774 void MmsTestBed::sendFromFile() |
|
775 { |
|
776 CMsvOperation * op = NULL; |
|
777 |
|
778 CMsvEntry* cEntry = iSession->GetEntryL(KMsvGlobalOutBoxIndexEntryId); |
|
779 CleanupStack::PushL( cEntry ); |
|
780 |
|
781 CMsvEntrySelection* selection = NULL; |
|
782 selection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia); |
|
783 CleanupStack::PopAndDestroy(); // cEntry |
|
784 CleanupStack::PushL( selection ); |
|
785 |
|
786 TRAPD (error, op = iMmsClient->SendL(*selection, iWait->iStatus)); |
|
787 if ( error != KErrNone ) |
|
788 { |
|
789 CleanupStack::PopAndDestroy(); // selection |
|
790 delete op; |
|
791 return; |
|
792 } |
|
793 CleanupStack::PushL(op); |
|
794 iWait->Start(); |
|
795 |
|
796 while (iWait->iStatus.Int() == KRequestPending ) |
|
797 { |
|
798 if (!iTimer->IsActive()) |
|
799 { |
|
800 iTimer->IssueRequest(); |
|
801 } |
|
802 CActiveScheduler::Start(); |
|
803 } |
|
804 |
|
805 if ( iWait->iStatus.Int() != KErrNone ) |
|
806 { |
|
807 //TMmsLogger::Log(_L("Testbed tried to send, return status %d"), iWait->iStatus.Int()); |
|
808 } |
|
809 |
|
810 iTimer->Cancel(); |
|
811 CleanupStack::PopAndDestroy(2); // op, selection |
|
812 } |
|
813 |
|
814 void MmsTestBed::sendOneByOne() |
|
815 { |
|
816 CMsvEntry* cEntry = iSession->GetEntryL(KMsvGlobalOutBoxIndexEntryId); |
|
817 CleanupStack::PushL( cEntry ); |
|
818 |
|
819 CMsvEntrySelection* selection = NULL; |
|
820 selection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia); |
|
821 CleanupStack::PushL( selection ); |
|
822 |
|
823 CMsvEntrySelection* shortSelection = new (ELeave) CMsvEntrySelection; |
|
824 CleanupStack::PushL( shortSelection ); |
|
825 |
|
826 TInt i; |
|
827 |
|
828 for ( i = 0; i < selection->Count(); ++i ) |
|
829 { |
|
830 shortSelection->Reset(); |
|
831 shortSelection->AppendL( selection->At( i ) ); |
|
832 |
|
833 CMsvOperation * op = NULL; |
|
834 |
|
835 TTime now; |
|
836 now.UniversalTime(); |
|
837 |
|
838 TRAPD (error, op = iMmsClient->SendL(*shortSelection, iWait->iStatus, now )); |
|
839 if ( error != KErrNone ) |
|
840 { |
|
841 delete op; |
|
842 CleanupStack::PopAndDestroy( 3 ); // entry, selection, shortSelection |
|
843 return; |
|
844 } |
|
845 CleanupStack::PushL(op); |
|
846 iWait->Start(); |
|
847 |
|
848 while (iWait->iStatus.Int() == KRequestPending ) |
|
849 { |
|
850 if (!iTimer->IsActive()) |
|
851 { |
|
852 iTimer->IssueRequest(); |
|
853 } |
|
854 CActiveScheduler::Start(); |
|
855 } |
|
856 |
|
857 if ( iWait->iStatus.Int() != KErrNone ) |
|
858 { |
|
859 //TMmsLogger::Log(_L("Testbed tried to send, return status %d"), iWait->iStatus.Int()); |
|
860 } |
|
861 |
|
862 iTimer->Cancel(); |
|
863 CleanupStack::PopAndDestroy(); // op |
|
864 |
|
865 } |
|
866 CleanupStack::PopAndDestroy( 3 ); // entry, selection, shortSelection |
|
867 } |
|
868 |
|
869 void MmsTestBed::sendNotifications() |
|
870 { |
|
871 // Only send one notification!! |
|
872 |
|
873 TInt error = KErrNone; |
|
874 |
|
875 if (! TMmsTestUtils::IsFile(iCurrentFile, iFs) ) |
|
876 { |
|
877 //Not a file |
|
878 return; |
|
879 } |
|
880 TMsvId mmsFolder = findMMSFolder(); |
|
881 |
|
882 TEntry entry; |
|
883 |
|
884 |
|
885 // now I think we have a filename |
|
886 TEntry orgEntry; |
|
887 TUint size = 0; |
|
888 error = iFs.Entry( iCurrentFile, orgEntry ); |
|
889 size = orgEntry.iSize; |
|
890 |
|
891 //TMmsLogger::Log(_L("- notification %S "), &iCurrentFile); |
|
892 if ( size == 0 ) |
|
893 { |
|
894 //empty file |
|
895 //TMmsLogger::Log(_L("- empty file")); |
|
896 return; |
|
897 } |
|
898 |
|
899 if ( iEncodeBuffer == NULL ) |
|
900 { |
|
901 iEncodeBuffer = CBufFlat::NewL( size ); |
|
902 } |
|
903 else |
|
904 { |
|
905 iEncodeBuffer->ResizeL( 0 ); |
|
906 iEncodeBuffer->ResizeL( size ); |
|
907 } |
|
908 |
|
909 RFile inFile; |
|
910 error = inFile.Open( iFs, iCurrentFile, EFileShareReadersOnly ); |
|
911 TPtr8 ptr = iEncodeBuffer->Ptr( 0 ); |
|
912 if ( error == KErrNone ) |
|
913 { |
|
914 error = inFile.Read( ptr, size ); |
|
915 inFile.Close(); |
|
916 } |
|
917 else |
|
918 { |
|
919 //Error |
|
920 //TMmsLogger::Log(_L("- can't read file")); |
|
921 return; |
|
922 } |
|
923 |
|
924 TUint8 byte; |
|
925 TUint position = 0; |
|
926 TUint32 uintvar = 0; |
|
927 |
|
928 if ( size > 2 ) |
|
929 { |
|
930 iEncodeBuffer->Read( 1, &byte, 1 ); |
|
931 if ( byte == 6 ) // PUSH PDU |
|
932 { |
|
933 // try to find out length of header |
|
934 position = 2; |
|
935 iEncodeBuffer->Read( position, &byte, 1); |
|
936 |
|
937 while ( byte & 0x80 && position < size ) |
|
938 { |
|
939 uintvar += ( byte & 0x7f ); |
|
940 uintvar <<= 7; |
|
941 position++; |
|
942 iEncodeBuffer->Read( position, &byte, 1 ); |
|
943 } |
|
944 |
|
945 // add last byte without shift |
|
946 uintvar += byte; |
|
947 position++; |
|
948 } |
|
949 } |
|
950 |
|
951 position += uintvar; |
|
952 |
|
953 if ( position < size ) |
|
954 { |
|
955 ptr = iEncodeBuffer->Ptr( position ); |
|
956 size = ptr.Length(); |
|
957 } |
|
958 |
|
959 if ( size == 0 ) |
|
960 { |
|
961 //no MMS stuff |
|
962 //TMmsLogger::Log(_L("- no MMS stuff")); |
|
963 return; |
|
964 } |
|
965 |
|
966 TMsvId entryId = TMmsTestUtils::CreateNotificationEntryL( mmsFolder, iServiceId, iEncodeBuffer, *iSession ); |
|
967 |
|
968 // Now we have streamed our data into this entry. |
|
969 // Now we have an entry that says: local service, MMS MTM |
|
970 CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection; |
|
971 CleanupStack::PushL( selection ); |
|
972 if ( entryId != KMsvNullIndexEntryId ) |
|
973 { |
|
974 selection->AppendL( entryId ); |
|
975 } |
|
976 else |
|
977 { |
|
978 selection->AppendL( iDefaultServiceId ); |
|
979 } |
|
980 |
|
981 TWatcherParameters parameters; // initialized to zero |
|
982 parameters.iWatcherId = RThread().Id(); |
|
983 parameters.iDataPointer = &ptr; |
|
984 TWatcherParametersBuf paramPack( parameters ); |
|
985 |
|
986 CMsvOperation * op = NULL; |
|
987 |
|
988 op = iSession->TransferCommandL( |
|
989 *selection, EMmsDecodePushedMessage, paramPack, iWait->iStatus ); |
|
990 CleanupStack::PushL(op); |
|
991 iWait->Start(); |
|
992 |
|
993 while (iWait->iStatus.Int() == KRequestPending ) |
|
994 { |
|
995 if (!iTimer->IsActive()) |
|
996 { |
|
997 iTimer->IssueRequest(); |
|
998 } |
|
999 CActiveScheduler::Start(); |
|
1000 } |
|
1001 |
|
1002 iTimer->Cancel(); |
|
1003 User::After(1000000); |
|
1004 |
|
1005 CleanupStack::PopAndDestroy(); // op |
|
1006 CleanupStack::PopAndDestroy(); // selection |
|
1007 } |
|
1008 |
|
1009 void MmsTestBed::copyDrafts() |
|
1010 { |
|
1011 CMsvEntry* cEntry = NULL; |
|
1012 // Copies contents of sent folder to drafts for retrying sending. |
|
1013 |
|
1014 cEntry = iSession->GetEntryL(KMsvSentEntryId); |
|
1015 CleanupStack::PushL(cEntry); |
|
1016 // Get all mms messages in drafts |
|
1017 CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia ); |
|
1018 CleanupStack::PushL( selection ); |
|
1019 |
|
1020 TMsvLocalOperationProgress progress; |
|
1021 cEntry->CopyL( *selection, KMsvDraftEntryId, progress ); |
|
1022 |
|
1023 TInt i = 0; |
|
1024 for ( i = 0; i < selection->Count(); ++i ) |
|
1025 { |
|
1026 cEntry->SetEntryL( selection->At( i ) ); |
|
1027 TMsvEntry entry = cEntry->Entry(); |
|
1028 entry.SetReadOnly( EFalse ); |
|
1029 cEntry->ChangeL( entry ); |
|
1030 } |
|
1031 |
|
1032 CleanupStack::PopAndDestroy(2); // selection, cEntry |
|
1033 } |
|
1034 |
|
1035 void MmsTestBed::garbageCollection(TUint32 aReason) |
|
1036 { |
|
1037 CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection; |
|
1038 CleanupStack::PushL( selection ); |
|
1039 selection->InsertL(0, iDefaultServiceId); |
|
1040 |
|
1041 CMsvOperation * op = NULL; |
|
1042 |
|
1043 TMMSGarbageCollectionParameters parameters; // initialized to zero |
|
1044 parameters.iReasonFlags = aReason; |
|
1045 TMMSGarbageCollectionParametersBuf paramPack( parameters ); |
|
1046 op = iSession->TransferCommandL( |
|
1047 *selection, EMmsGarbageCollection, paramPack, iWait->iStatus ); |
|
1048 CleanupStack::PushL(op); |
|
1049 iWait->Start(); |
|
1050 |
|
1051 while (iWait->iStatus.Int() == KRequestPending ) |
|
1052 { |
|
1053 if (!iTimer->IsActive()) |
|
1054 { |
|
1055 iTimer->IssueRequest(); |
|
1056 } |
|
1057 CActiveScheduler::Start(); |
|
1058 } |
|
1059 |
|
1060 iTimer->Cancel(); |
|
1061 |
|
1062 CleanupStack::PopAndDestroy(); // op |
|
1063 CleanupStack::PopAndDestroy(); // selection |
|
1064 } |
|
1065 |
|
1066 void MmsTestBed::messageVariation() |
|
1067 { |
|
1068 CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection; |
|
1069 CleanupStack::PushL( selection ); |
|
1070 selection->InsertL(0, iDefaultServiceId); |
|
1071 |
|
1072 CMsvOperation * op = NULL; |
|
1073 |
|
1074 op = iSession->TransferCommandL( |
|
1075 *selection, EMmsMessageGeneration, TPtrC8(), iWait->iStatus ); |
|
1076 CleanupStack::PushL(op); |
|
1077 iWait->Start(); |
|
1078 |
|
1079 while (iWait->iStatus.Int() == KRequestPending ) |
|
1080 { |
|
1081 if (!iTimer->IsActive()) |
|
1082 { |
|
1083 iTimer->IssueRequest(); |
|
1084 } |
|
1085 CActiveScheduler::Start(); |
|
1086 } |
|
1087 |
|
1088 iTimer->Cancel(); |
|
1089 |
|
1090 CleanupStack::PopAndDestroy(); // op |
|
1091 CleanupStack::PopAndDestroy(); // selection |
|
1092 } |
|
1093 |
|
1094 void MmsTestBed::cancelSendScheduling() |
|
1095 { |
|
1096 CMsvEntry* cEntry = NULL; |
|
1097 setFetchingState( EMmsReceivingPostpone ); |
|
1098 testFile( iCurrentFile ); |
|
1099 scheduledSend(KMsvGlobalOutBoxIndexEntryIdValue, 10000); // long delay so that we have time to cancel |
|
1100 deleteSendSchedule(); |
|
1101 |
|
1102 cEntry = iSession->GetEntryL(KMsvRootIndexEntryId); |
|
1103 CleanupStack::PushL(cEntry); |
|
1104 cEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryIdValue); |
|
1105 if (iMsvEntrySelection != NULL) |
|
1106 { |
|
1107 delete iMsvEntrySelection; |
|
1108 iMsvEntrySelection = NULL; |
|
1109 } |
|
1110 iMsvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia); |
|
1111 CleanupStack::PopAndDestroy(); |
|
1112 } |
|
1113 |
|
1114 void MmsTestBed::scheduledSend(TMsvId aBoxId, TInt aDelay /* = 5 */) |
|
1115 { |
|
1116 CMsvEntry* cEntry = NULL; |
|
1117 TCommandParameters parameters; |
|
1118 parameters.iInitialDelay = aDelay; |
|
1119 TCommandParametersBuf paramPack( parameters ); |
|
1120 |
|
1121 cEntry = iSession->GetEntryL(aBoxId); |
|
1122 CleanupStack::PushL(cEntry); |
|
1123 // Get all mms messages of outbox |
|
1124 CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia ); |
|
1125 CleanupStack::PushL( selection ); |
|
1126 // selection->InsertL(0, iDefaultServiceId); |
|
1127 |
|
1128 CMsvOperation * op = NULL; |
|
1129 op = iMmsClient->InvokeAsyncFunctionL( |
|
1130 EMmsScheduledSend, |
|
1131 *selection, |
|
1132 paramPack, |
|
1133 iWait->iStatus); |
|
1134 CleanupStack::PushL(op); |
|
1135 iWait->Start(); |
|
1136 |
|
1137 while (iWait->iStatus.Int() == KRequestPending ) |
|
1138 { |
|
1139 if (!iTimer->IsActive()) |
|
1140 { |
|
1141 iTimer->IssueRequest(); |
|
1142 } |
|
1143 CActiveScheduler::Start(); |
|
1144 } |
|
1145 |
|
1146 iTimer->Cancel(); |
|
1147 |
|
1148 CleanupStack::PopAndDestroy(); // op |
|
1149 CleanupStack::PopAndDestroy(2); // cEntry, selection |
|
1150 } |
|
1151 |
|
1152 void MmsTestBed::deleteSendSchedule() |
|
1153 { |
|
1154 CMsvEntry* cEntry = NULL; |
|
1155 |
|
1156 TCommandParameters parameters; // initialized to zero |
|
1157 TCommandParametersBuf paramPack( parameters ); |
|
1158 |
|
1159 cEntry = iSession->GetEntryL(KMsvGlobalOutBoxIndexEntryIdValue); |
|
1160 CleanupStack::PushL(cEntry); |
|
1161 // Get all mms messages of outbox |
|
1162 CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia ); |
|
1163 CleanupStack::PushL( selection ); |
|
1164 selection->InsertL(0, iDefaultServiceId); |
|
1165 |
|
1166 CMsvOperation * op = NULL; |
|
1167 op = iMmsClient->InvokeAsyncFunctionL( |
|
1168 EMmsDeleteSchedule, |
|
1169 *selection, |
|
1170 paramPack, |
|
1171 iWait->iStatus); |
|
1172 CleanupStack::PushL(op); |
|
1173 iWait->Start(); |
|
1174 |
|
1175 while (iWait->iStatus.Int() == KRequestPending ) |
|
1176 { |
|
1177 if (!iTimer->IsActive()) |
|
1178 { |
|
1179 iTimer->IssueRequest(); |
|
1180 } |
|
1181 CActiveScheduler::Start(); |
|
1182 } |
|
1183 |
|
1184 iTimer->Cancel(); |
|
1185 |
|
1186 CleanupStack::PopAndDestroy(); // op |
|
1187 CleanupStack::PopAndDestroy(2); // cEntry, selection |
|
1188 } |
|
1189 |
|
1190 void MmsTestBed::cancelFetchScheduling() |
|
1191 { |
|
1192 TMsvId mmsFolder = findMMSFolder(); |
|
1193 CMsvEntry* cEntry = NULL; |
|
1194 setFetchingState( EMmsReceivingPostpone ); |
|
1195 testFile( iCurrentFile ); |
|
1196 fromOutboxToMmsc(); // immediate send (EMmsSend) |
|
1197 |
|
1198 // Wait until notification has arrived - may take a while in global mode |
|
1199 TInt i = 0; |
|
1200 while ( TMmsTestUtils::CountChildrenL( mmsFolder, iMsvEntrySelection, *iSession ) == 0 |
|
1201 && i < 2000 ) |
|
1202 { |
|
1203 if (!iTimer->IsActive()) |
|
1204 { |
|
1205 iTimer->IssueRequest(); |
|
1206 } |
|
1207 i++; |
|
1208 if ( (i/100) * 100 == i ) |
|
1209 { |
|
1210 //TMmsLogger::Log(_L("%d:th wait cycle"), i ); |
|
1211 } |
|
1212 CActiveScheduler::Start(); |
|
1213 } |
|
1214 iTimer->Cancel(); |
|
1215 |
|
1216 fetchForced( 10000 ); // delay to allow cancelling |
|
1217 deleteFetchSchedule(); |
|
1218 |
|
1219 cEntry = iSession->GetEntryL(KMsvRootIndexEntryId); |
|
1220 CleanupStack::PushL(cEntry); |
|
1221 cEntry->SetEntryL(mmsFolder); |
|
1222 if (iMsvEntrySelection != NULL) |
|
1223 { |
|
1224 delete iMsvEntrySelection; |
|
1225 iMsvEntrySelection = NULL; |
|
1226 } |
|
1227 iMsvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia); |
|
1228 CleanupStack::PopAndDestroy(); // cEntry |
|
1229 } |
|
1230 |
|
1231 void MmsTestBed::fetchForced(TInt aDelay /* = 5 */) |
|
1232 { |
|
1233 TCommandParameters parameters; |
|
1234 parameters.iInitialDelay = aDelay; |
|
1235 TCommandParametersBuf paramPack( parameters ); |
|
1236 |
|
1237 CMsvEntrySelection* selection = new CMsvEntrySelection; |
|
1238 CleanupStack::PushL( selection ); |
|
1239 // if we have a selected service, insert it into selection |
|
1240 if (iServiceId != KMsvNullIndexEntryId) |
|
1241 { |
|
1242 selection->InsertL(0, iServiceId); |
|
1243 } |
|
1244 else |
|
1245 { |
|
1246 selection->InsertL(0, iDefaultServiceId); |
|
1247 } |
|
1248 |
|
1249 |
|
1250 CMsvOperation * op = NULL; |
|
1251 op = iMmsClient->InvokeAsyncFunctionL( |
|
1252 EMmsScheduledReceiveForced, |
|
1253 *selection, |
|
1254 paramPack, |
|
1255 iWait->iStatus); |
|
1256 |
|
1257 CleanupStack::PushL(op); |
|
1258 iWait->Start(); |
|
1259 |
|
1260 while (iWait->iStatus.Int() == KRequestPending ) |
|
1261 { |
|
1262 if (!iTimer->IsActive()) |
|
1263 { |
|
1264 iTimer->IssueRequest(); |
|
1265 } |
|
1266 CActiveScheduler::Start(); |
|
1267 } |
|
1268 |
|
1269 iTimer->Cancel(); |
|
1270 |
|
1271 CleanupStack::PopAndDestroy(); // op |
|
1272 CleanupStack::PopAndDestroy(); // selection |
|
1273 } |
|
1274 |
|
1275 void MmsTestBed::deleteFetchSchedule() |
|
1276 { |
|
1277 CMsvEntry* cEntry = NULL; |
|
1278 |
|
1279 TCommandParameters parameters; // initialized to zero |
|
1280 TCommandParametersBuf paramPack( parameters ); |
|
1281 |
|
1282 TMsvId mmsFolderId = KMsvNullIndexEntryId; |
|
1283 mmsFolderId = findMMSFolder(); |
|
1284 cEntry = iSession->GetEntryL( mmsFolderId ); |
|
1285 CleanupStack::PushL(cEntry); |
|
1286 // Get all notifications |
|
1287 CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia ); |
|
1288 CleanupStack::PushL( selection ); |
|
1289 selection->InsertL(0, iDefaultServiceId); |
|
1290 |
|
1291 CMsvOperation * op = NULL; |
|
1292 op = iMmsClient->InvokeAsyncFunctionL( |
|
1293 EMmsDeleteSchedule, |
|
1294 *selection, |
|
1295 paramPack, |
|
1296 iWait->iStatus); |
|
1297 CleanupStack::PushL(op); |
|
1298 iWait->Start(); |
|
1299 |
|
1300 while (iWait->iStatus.Int() == KRequestPending ) |
|
1301 { |
|
1302 if (!iTimer->IsActive()) |
|
1303 { |
|
1304 iTimer->IssueRequest(); |
|
1305 } |
|
1306 CActiveScheduler::Start(); |
|
1307 } |
|
1308 |
|
1309 iTimer->Cancel(); |
|
1310 |
|
1311 CleanupStack::PopAndDestroy(); // op |
|
1312 CleanupStack::PopAndDestroy(2); // cEntry, selection |
|
1313 } |
|
1314 |
|
1315 void MmsTestBed::doAFetchCycle() |
|
1316 { |
|
1317 // Sends a message from iCurrentFile and lets it come back |
|
1318 TMsvId mmsFolder = findMMSFolder(); |
|
1319 testFile( iCurrentFile ); |
|
1320 fromOutboxToMmsc(); // immediate send (EMmsSend) |
|
1321 // fetching will start automatically |
|
1322 |
|
1323 TInt i = 0; |
|
1324 while ( TMmsTestUtils::CountChildrenL( KMsvGlobalInBoxIndexEntryId, iMsvEntrySelection, *iSession ) == 0 |
|
1325 && i < 2000 |
|
1326 && TMmsTestUtils::CountChildrenL( mmsFolder, iMsvEntrySelection, *iSession ) > 0 ) |
|
1327 { |
|
1328 if (!iTimer->IsActive()) |
|
1329 { |
|
1330 iTimer->IssueRequest(); |
|
1331 } |
|
1332 i++; |
|
1333 if ( (i/100) * 100 == i ) |
|
1334 { |
|
1335 //TMmsLogger::Log(_L("%d:th wait cycle"), i ); |
|
1336 } |
|
1337 CActiveScheduler::Start(); |
|
1338 } |
|
1339 iTimer->Cancel(); |
|
1340 } |
|
1341 |
|
1342 bool MmsTestBed::checkLogClient() |
|
1343 { |
|
1344 if ( iLogClient == NULL ) |
|
1345 { |
|
1346 TRAP_IGNORE( iLogClient = CLogClient::NewL( iFs ) ); |
|
1347 } |
|
1348 return ( iLogClient != NULL ); |
|
1349 } |
|
1350 |
|
1351 int MmsTestBed::getLogEntries() |
|
1352 { |
|
1353 TInt count = 0; |
|
1354 if ( !iLogView ) |
|
1355 { |
|
1356 return 0; |
|
1357 } |
|
1358 |
|
1359 if ( iLogView->SetFilterL( *iLogFilter, iWait->iStatus ) ) |
|
1360 { |
|
1361 // should complete with KErrNone |
|
1362 iWait->Start(); |
|
1363 if ( iWait->iStatus.Int() == KErrNone ) |
|
1364 { |
|
1365 count = iLogView->CountL(); |
|
1366 } |
|
1367 } |
|
1368 return count; |
|
1369 } |
|
1370 |
|
1371 void MmsTestBed::createEntry(TMsvEntry& aNewEntry, CMsvEntry& aClientEntry) |
|
1372 { |
|
1373 CMsvOperation* opert = aClientEntry.CreateL(aNewEntry, iWait->iStatus); |
|
1374 iWait->Start(); |
|
1375 if (!opert->iStatus.Int()==KErrNone) |
|
1376 { |
|
1377 // what should we do? panic? |
|
1378 } |
|
1379 |
|
1380 TPckgBuf<TMsvLocalOperationProgress> package; |
|
1381 package.Copy(opert->ProgressL()); |
|
1382 *(TMsvId*)&aNewEntry = package().iId; |
|
1383 |
|
1384 delete opert; opert=NULL; |
|
1385 } |
|
1386 |
|
1387 void MmsTestBed::cleanOutbox() |
|
1388 { |
|
1389 TMmsTestUtils::CleanBoxL(KMsvGlobalOutBoxIndexEntryId, *iSession); |
|
1390 } |
|
1391 |
|
1392 void MmsTestBed::cleanInbox() |
|
1393 { |
|
1394 TMmsTestUtils::CleanBoxL(KMsvGlobalInBoxIndexEntryId, *iSession); |
|
1395 } |
|
1396 |
|
1397 void MmsTestBed::cleanSent() |
|
1398 { |
|
1399 TMmsTestUtils::CleanBoxL(KMsvSentEntryId, *iSession); |
|
1400 } |
|
1401 |
|
1402 void MmsTestBed::cleanDrafts() |
|
1403 { |
|
1404 TMmsTestUtils::CleanBoxL(KMsvDraftEntryId, *iSession); |
|
1405 } |
|
1406 |
|
1407 void MmsTestBed::cleanAll() |
|
1408 { |
|
1409 cleanInbox(); |
|
1410 cleanOutbox(); |
|
1411 cleanSent(); |
|
1412 cleanDrafts(); |
|
1413 TMmsTestUtils::CleanBoxL( iSettings->MMBoxFolder(), *iSession ); |
|
1414 deleteNotifications(); |
|
1415 } |
|
1416 |
|
1417 void MmsTestBed::reply() |
|
1418 { |
|
1419 // The first message from inbox is replied to |
|
1420 CMsvEntry* cEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId); |
|
1421 CleanupStack::PushL(cEntry); |
|
1422 delete iMsvEntrySelection; |
|
1423 iMsvEntrySelection = NULL; |
|
1424 iMsvEntrySelection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia ); |
|
1425 if ( iMsvEntrySelection->Count() > 0 ) |
|
1426 { |
|
1427 TMsvId originalEntry = iMsvEntrySelection->At(0); |
|
1428 iMmsClient->SwitchCurrentEntryL( originalEntry ); |
|
1429 TMsvPartList partList = KMsvMessagePartOriginator | KMsvMessagePartDescription; |
|
1430 CMsvOperation * op = NULL; |
|
1431 op = iMmsClient->ReplyL( KMsvGlobalOutBoxIndexEntryId, partList, iWait->iStatus); |
|
1432 CleanupStack::PushL(op); |
|
1433 iWait->Start(); |
|
1434 while (iWait->iStatus.Int() == KRequestPending ) |
|
1435 { |
|
1436 if (!iTimer->IsActive()) |
|
1437 { |
|
1438 iTimer->IssueRequest(); |
|
1439 } |
|
1440 CActiveScheduler::Start(); |
|
1441 } |
|
1442 |
|
1443 iTimer->Cancel(); |
|
1444 if ( iWait->iStatus.Int() != KErrNone ) |
|
1445 { |
|
1446 //TMmsLogger::Log(_L("Create reply, return status %d"), iWait->iStatus.Int()); |
|
1447 } |
|
1448 else |
|
1449 { |
|
1450 TMsvId newEntry = KMsvNullIndexEntryId; |
|
1451 TPckgBuf<TMsvId> package; |
|
1452 package.Copy(op->ProgressL()); |
|
1453 newEntry = package(); |
|
1454 if ( newEntry != KMsvNullIndexEntryId ) |
|
1455 { |
|
1456 cEntry->SetEntryL( newEntry ); |
|
1457 TMsvEntry entry = cEntry->Entry(); |
|
1458 entry.SetInPreparation( EFalse ); |
|
1459 entry.SetVisible( ETrue ); |
|
1460 cEntry->ChangeL(entry); |
|
1461 } |
|
1462 } |
|
1463 CleanupStack::PopAndDestroy(); // op |
|
1464 } |
|
1465 CleanupStack::PopAndDestroy(); // cEntry |
|
1466 } |
|
1467 |
|
1468 void MmsTestBed::replyToAll() |
|
1469 { |
|
1470 // The first message from inbox is replied to |
|
1471 CMsvEntry* cEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId); |
|
1472 CleanupStack::PushL(cEntry); |
|
1473 delete iMsvEntrySelection; |
|
1474 iMsvEntrySelection = NULL; |
|
1475 iMsvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia); |
|
1476 |
|
1477 if ( iMsvEntrySelection->Count() > 0 ) |
|
1478 { |
|
1479 TMsvId originalEntry = iMsvEntrySelection->At(0); |
|
1480 iMmsClient->SwitchCurrentEntryL( originalEntry ); |
|
1481 TMsvPartList partList = KMsvMessagePartOriginator | KMsvMessagePartDescription | |
|
1482 KMsvMessagePartRecipient; |
|
1483 CMsvOperation * op = NULL; |
|
1484 op = iMmsClient->ReplyL( KMsvGlobalOutBoxIndexEntryId, partList, iWait->iStatus); |
|
1485 CleanupStack::PushL(op); |
|
1486 iWait->Start(); |
|
1487 while (iWait->iStatus.Int() == KRequestPending ) |
|
1488 { |
|
1489 if (!iTimer->IsActive()) |
|
1490 { |
|
1491 iTimer->IssueRequest(); |
|
1492 } |
|
1493 CActiveScheduler::Start(); |
|
1494 } |
|
1495 |
|
1496 iTimer->Cancel(); |
|
1497 if ( iWait->iStatus.Int() != KErrNone ) |
|
1498 { |
|
1499 //TMmsLogger::Log(_L("Create reply to all, return status %d"), iWait->iStatus.Int()); |
|
1500 } |
|
1501 else |
|
1502 { |
|
1503 TMsvId newEntry = KMsvNullIndexEntryId; |
|
1504 TPckgBuf<TMsvId> package; |
|
1505 package.Copy(op->ProgressL()); |
|
1506 newEntry = package(); |
|
1507 if ( newEntry != KMsvNullIndexEntryId ) |
|
1508 { |
|
1509 cEntry->SetEntryL( newEntry ); |
|
1510 TMsvEntry entry = cEntry->Entry(); |
|
1511 entry.SetInPreparation( EFalse ); |
|
1512 entry.SetVisible( ETrue ); |
|
1513 cEntry->ChangeL(entry); |
|
1514 } |
|
1515 } |
|
1516 CleanupStack::PopAndDestroy(); // op |
|
1517 } |
|
1518 CleanupStack::PopAndDestroy(); // cEntry |
|
1519 } |
|
1520 |
|
1521 void MmsTestBed::forward() |
|
1522 { |
|
1523 // The first message from inbox is forwarded |
|
1524 CMsvEntry* cEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId); |
|
1525 CleanupStack::PushL(cEntry); |
|
1526 delete iMsvEntrySelection; |
|
1527 iMsvEntrySelection = NULL; |
|
1528 iMsvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia); |
|
1529 |
|
1530 if ( iMsvEntrySelection->Count() > 0 ) |
|
1531 { |
|
1532 TMsvId originalEntry = iMsvEntrySelection->At(0); |
|
1533 iMmsClient->SwitchCurrentEntryL( originalEntry ); |
|
1534 TMsvPartList partList = KMsvMessagePartOriginator | KMsvMessagePartDescription | |
|
1535 KMsvMessagePartRecipient | KMsvMessagePartAttachments; |
|
1536 CMsvOperation * op = NULL; |
|
1537 op = iMmsClient->ForwardL( KMsvGlobalOutBoxIndexEntryId, partList, iWait->iStatus); |
|
1538 CleanupStack::PushL(op); |
|
1539 iWait->Start(); |
|
1540 while (iWait->iStatus.Int() == KRequestPending ) |
|
1541 { |
|
1542 if (!iTimer->IsActive()) |
|
1543 { |
|
1544 iTimer->IssueRequest(); |
|
1545 } |
|
1546 CActiveScheduler::Start(); |
|
1547 } |
|
1548 |
|
1549 iTimer->Cancel(); |
|
1550 if ( iWait->iStatus.Int() != KErrNone ) |
|
1551 { |
|
1552 //TMmsLogger::Log(_L("Create forward, return status %d"), iWait->iStatus.Int()); |
|
1553 } |
|
1554 else |
|
1555 { |
|
1556 TMsvId newEntry = KMsvNullIndexEntryId; |
|
1557 TPckgBuf<TMsvId> package; |
|
1558 package.Copy(op->ProgressL()); |
|
1559 newEntry = package(); |
|
1560 if ( newEntry != KMsvNullIndexEntryId ) |
|
1561 { |
|
1562 iMmsClient->SwitchCurrentEntryL( newEntry ); |
|
1563 // Add a sender: 0601234567 |
|
1564 iMmsClient->LoadMessageL(); |
|
1565 iMmsClient->SetSenderL( KMmsSender ); |
|
1566 iMmsClient->SaveMessageL(); |
|
1567 cEntry->SetEntryL( newEntry ); |
|
1568 TMsvEntry entry = cEntry->Entry(); |
|
1569 entry.SetInPreparation( EFalse ); |
|
1570 entry.SetVisible( ETrue ); |
|
1571 cEntry->ChangeL(entry); |
|
1572 } |
|
1573 } |
|
1574 CleanupStack::PopAndDestroy(); // op |
|
1575 } |
|
1576 CleanupStack::PopAndDestroy(); // cEntry |
|
1577 } |
|
1578 |
|
1579 void MmsTestBed::sendReadReport() |
|
1580 { |
|
1581 // TURN READ REPORTS ON (until available from menu) |
|
1582 iSettings->LoadSettingsL(); |
|
1583 iSettings->SetReadReplyReportSendingAllowed( ETrue ); |
|
1584 iSettings->SaveSettingsL(); |
|
1585 iMmsClient->RestoreSettingsL(); |
|
1586 |
|
1587 |
|
1588 // Read report is sent for the first message in inbox |
|
1589 CMsvEntry* cEntry = iSession->GetEntryL( KMsvGlobalInBoxIndexEntryId ); |
|
1590 CleanupStack::PushL(cEntry); |
|
1591 delete iMsvEntrySelection; |
|
1592 iMsvEntrySelection = NULL; |
|
1593 iMsvEntrySelection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia ); |
|
1594 |
|
1595 if ( iMsvEntrySelection->Count() == 0 ) |
|
1596 { |
|
1597 return; |
|
1598 } |
|
1599 TMsvId originalEntry = iMsvEntrySelection->At( 0 ); |
|
1600 |
|
1601 // new test using Client MTM |
|
1602 CMsvOperation * op = NULL; |
|
1603 op = iMmsClient->SendReadReportL( originalEntry, iWait->iStatus, EMmsReadStatusRead ); |
|
1604 CleanupStack::PushL(op); |
|
1605 iWait->Start(); |
|
1606 |
|
1607 while (iWait->iStatus.Int() == KRequestPending ) |
|
1608 { |
|
1609 if (!iTimer->IsActive()) |
|
1610 { |
|
1611 iTimer->IssueRequest(); |
|
1612 } |
|
1613 CActiveScheduler::Start(); |
|
1614 } |
|
1615 |
|
1616 if ( iWait->iStatus.Int() != KErrNone ) |
|
1617 { |
|
1618 //TMmsLogger::Log(_L("Testbed tried to send read report, return status %d"), iWait->iStatus.Int()); |
|
1619 } |
|
1620 |
|
1621 iTimer->Cancel(); |
|
1622 |
|
1623 CleanupStack::PopAndDestroy( op ); |
|
1624 op = NULL; |
|
1625 |
|
1626 // Try sending the read report to current entry |
|
1627 |
|
1628 iMmsClient->SwitchCurrentEntryL( originalEntry ); |
|
1629 op = iMmsClient->SendReadReportL( originalEntry, iWait->iStatus, EMmsReadStatusRead ); |
|
1630 CleanupStack::PushL(op); |
|
1631 iWait->Start(); |
|
1632 |
|
1633 while (iWait->iStatus.Int() == KRequestPending ) |
|
1634 { |
|
1635 if (!iTimer->IsActive()) |
|
1636 { |
|
1637 iTimer->IssueRequest(); |
|
1638 } |
|
1639 CActiveScheduler::Start(); |
|
1640 } |
|
1641 |
|
1642 if ( iWait->iStatus.Int() != KErrNone ) |
|
1643 { |
|
1644 //TMmsLogger::Log(_L("Testbed tried to send read report, return status %d"), iWait->iStatus.Int()); |
|
1645 } |
|
1646 |
|
1647 iTimer->Cancel(); |
|
1648 CleanupStack::PopAndDestroy( op ); |
|
1649 op = NULL; |
|
1650 |
|
1651 /* |
|
1652 cEntry->SetEntryL( originalEntry ); |
|
1653 iMmsHeaders->Reset(); |
|
1654 CMsvStore* store = cEntry->ReadStoreL(); |
|
1655 CleanupStack::PushL( store ); |
|
1656 iMmsHeaders->RestoreL( *store ); |
|
1657 CleanupStack::PopAndDestroy( store ); |
|
1658 store = NULL; |
|
1659 HBufC8* messageId = HBufC8::NewL( iMmsHeaders->MessageId().Length() ); |
|
1660 CleanupStack::PushL( messageId ); |
|
1661 messageId->Des().Copy( iMmsHeaders->MessageId() ); |
|
1662 |
|
1663 iMmsClient->SwitchCurrentEntryL( originalEntry ); |
|
1664 iMmsClient->LoadMessageL(); |
|
1665 |
|
1666 iMmsHeaders->Reset(); |
|
1667 iMmsHeaders->SetMessageType( KMmsMessageTypeReadRecInd ); |
|
1668 // Message id cannot be accessed via MMS Client MTM! |
|
1669 |
|
1670 iMmsHeaders->SetMessageIdL( messageId->Des() ); |
|
1671 CleanupStack::PopAndDestroy( messageId ); |
|
1672 |
|
1673 iMmsHeaders->AddTypedAddresseeL( iMmsClient->Sender(), EMsvRecipientTo ); |
|
1674 // sender must be insert-address-token because we don't know our number |
|
1675 TTime now; |
|
1676 now.UniversalTime(); |
|
1677 |
|
1678 _LIT( K1970, "19700000:000000.000000" ); // 1-Jan 1970 0:00:00 |
|
1679 |
|
1680 TTime y1970( K1970 ); |
|
1681 TTimeIntervalMicroSeconds interval; |
|
1682 // we can't use "seconds from" as it only returns a |
|
1683 // 32 bit signed integer. If fails in 2038. |
|
1684 // "microseconds from" returns a 64 bit signed integer |
|
1685 interval = now.MicroSecondsFrom( y1970 ); |
|
1686 // date in iMmsHeaders() in seconds from 1.1.1970. |
|
1687 iMmsHeaders->SetDate( (interval.Int64() ) / KMmsMillion ); |
|
1688 iMmsHeaders->SetReadStatus( KMmsReadStatusRead ); |
|
1689 |
|
1690 TMsvId mmsFolderId = KMsvNullIndexEntryId; |
|
1691 mmsFolderId = FindMMSFolderL(); |
|
1692 |
|
1693 cEntry->SetEntryL( mmsFolderId ); |
|
1694 |
|
1695 TMsvEntry entry; |
|
1696 entry.iType = KUidMsvMessageEntry; |
|
1697 entry.iMtm = KUidMsgTypeMultimedia; |
|
1698 entry.SetVisible( ETrue ); |
|
1699 entry.SetInPreparation( EFalse ); |
|
1700 entry.iServiceId = KMsvLocalServiceIndexEntryId; |
|
1701 entry.iRelatedId = iDefaultServiceId; |
|
1702 entry.iMtmData1 = KMmsMessageReadRecInd; |
|
1703 cEntry->CreateL( entry ); |
|
1704 TMsvId entryId = entry.Id(); |
|
1705 |
|
1706 cEntry->SetEntryL( entryId ); |
|
1707 |
|
1708 store = cEntry->EditStoreL(); |
|
1709 CleanupStack::PushL( store ); |
|
1710 iMmsHeaders->StoreL( *store ); |
|
1711 store->CommitL(); |
|
1712 CleanupStack::PopAndDestroy( store ); |
|
1713 store = NULL; |
|
1714 |
|
1715 CMsvEntrySelection* selection = new ( ELeave ) CMsvEntrySelection; |
|
1716 CleanupStack::PushL( selection ); |
|
1717 selection->InsertL(0, entryId); |
|
1718 |
|
1719 CMsvOperation * op = NULL; |
|
1720 TCommandParameters parameters; // initialized to zero |
|
1721 TCommandParametersBuf paramPack( parameters ); |
|
1722 |
|
1723 op = iSession->TransferCommandL(*selection,EMmsScheduledReadReport,paramPack,iWait->iStatus); |
|
1724 |
|
1725 CleanupStack::PushL(op); |
|
1726 iWait->Start(); |
|
1727 |
|
1728 while (iWait->iStatus.Int() == KRequestPending ) |
|
1729 { |
|
1730 if (!iTimer->IsActive()) |
|
1731 { |
|
1732 iTimer->IssueRequest(); |
|
1733 } |
|
1734 CActiveScheduler::Start(); |
|
1735 } |
|
1736 |
|
1737 if ( iWait->iStatus.Int() != KErrNone ) |
|
1738 { |
|
1739 //TMmsLogger::Log(_L("Testbed tried to send read report, return status %d"), iWait->iStatus.Int()); |
|
1740 } |
|
1741 |
|
1742 iTimer->Cancel(); |
|
1743 |
|
1744 CleanupStack::PopAndDestroy( op ); |
|
1745 CleanupStack::PopAndDestroy( selection ); |
|
1746 */ |
|
1747 CleanupStack::PopAndDestroy( cEntry ); |
|
1748 } |
|
1749 |
|
1750 int MmsTestBed::fromOutboxToMmscWithMemoryFailure() |
|
1751 { |
|
1752 TInt error = KErrNone; |
|
1753 TInt messageCount = 0; |
|
1754 TInt failureCount = 0; |
|
1755 do { |
|
1756 CMsvEntry* cEntry = NULL; |
|
1757 |
|
1758 // Get List of services |
|
1759 cEntry = iSession->GetEntryL(KMsvGlobalOutBoxIndexEntryIdValue); |
|
1760 CleanupStack::PushL(cEntry); |
|
1761 // Get all mms messages of outbox |
|
1762 CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia ); |
|
1763 CleanupStack::PushL( selection ); |
|
1764 failureCount++; |
|
1765 // These are failures that fail in Message server. |
|
1766 if ( failureCount >= 63 && failureCount <= 64 ) |
|
1767 { |
|
1768 failureCount = 65; |
|
1769 } |
|
1770 cEntry->SetEntryL( iServiceId ); |
|
1771 TMsvEntry entry = cEntry->Entry(); |
|
1772 entry.iMtmData3 &= 0x0000000FF; |
|
1773 entry.iMtmData3 |= failureCount << 8; |
|
1774 cEntry->ChangeL( entry ); |
|
1775 |
|
1776 selection->InsertL(0, iServiceId); |
|
1777 |
|
1778 CMsvOperation * op = NULL; |
|
1779 TCommandParameters parameters; // initialized to zero |
|
1780 TCommandParametersBuf paramPack( parameters ); |
|
1781 |
|
1782 TRAP (error, op = iSession->TransferCommandL(*selection,EMmsSend,paramPack,iWait->iStatus)); |
|
1783 |
|
1784 if ( error == KErrNone ) |
|
1785 { |
|
1786 CleanupStack::PushL(op); |
|
1787 iWait->Start(); |
|
1788 |
|
1789 while (iWait->iStatus.Int() == KRequestPending ) |
|
1790 { |
|
1791 if (!iTimer->IsActive()) |
|
1792 { |
|
1793 iTimer->IssueRequest(); |
|
1794 } |
|
1795 CActiveScheduler::Start(); |
|
1796 } |
|
1797 |
|
1798 if ( iWait->iStatus.Int() != KErrNone ) |
|
1799 { |
|
1800 error = iWait->iStatus.Int(); |
|
1801 if ( iWait->iStatus.Int() != KErrNoMemory ) |
|
1802 { |
|
1803 //TMmsLogger::Log(_L("Testbed tried to send, return status %d"), iWait->iStatus.Int()); |
|
1804 } |
|
1805 } |
|
1806 |
|
1807 CleanupStack::PopAndDestroy(); // op |
|
1808 } |
|
1809 iTimer->Cancel(); |
|
1810 CleanupStack::PopAndDestroy(); // selection |
|
1811 CleanupStack::PopAndDestroy(); // cEntry |
|
1812 selection = NULL; |
|
1813 cEntry = NULL; |
|
1814 cEntry = iSession->GetEntryL( KMsvGlobalOutBoxIndexEntryIdValue ); |
|
1815 CleanupStack::PushL(cEntry); |
|
1816 selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia ); |
|
1817 messageCount = selection->Count(); |
|
1818 delete selection; |
|
1819 selection = 0; |
|
1820 CleanupStack::PopAndDestroy(); //cEntry |
|
1821 } |
|
1822 while ( error == KErrNoMemory || messageCount > 0 ); |
|
1823 return failureCount; |
|
1824 } |
|
1825 |
|
1826 int MmsTestBed::fromMmscToInboxWithMemoryFailure() |
|
1827 { |
|
1828 TInt error = KErrNone; |
|
1829 TInt failureCount = 0; |
|
1830 TInt messageCount = 0; |
|
1831 TMsvId mmsFolderId = KMsvNullIndexEntryId; |
|
1832 mmsFolderId = findMMSFolder(); |
|
1833 |
|
1834 do { |
|
1835 // Inbox must be cleaned if failure makes message to be fetched more than once. |
|
1836 // should not happen, but this test is quite stressful, and perfect result |
|
1837 // cannot be guaranteed. |
|
1838 // What is expected: |
|
1839 // 1. Program does not crash |
|
1840 // 2. After sufficient number of retries the message is fetched and notification deleted. |
|
1841 TMmsTestUtils::CleanBoxL(KMsvGlobalInBoxIndexEntryId, *iSession); |
|
1842 CMsvEntry* cEntry = NULL; |
|
1843 CMsvEntrySelection* msvEntrySelection = new CMsvEntrySelection; |
|
1844 CleanupStack::PushL(msvEntrySelection); |
|
1845 |
|
1846 cEntry = iSession->GetEntryL(iServiceId); |
|
1847 CleanupStack::PushL(cEntry); |
|
1848 |
|
1849 failureCount++; |
|
1850 // These are failures that fail in Message server. |
|
1851 if ( failureCount >= 63 && failureCount <= 64 ) |
|
1852 { |
|
1853 failureCount = 65; |
|
1854 } |
|
1855 cEntry->SetEntryL( iServiceId ); |
|
1856 |
|
1857 TMsvEntry entry = cEntry->Entry(); |
|
1858 entry.iMtmData3 &= 0x0000000FF; |
|
1859 entry.iMtmData3 |= failureCount << 8; |
|
1860 cEntry->ChangeL( entry ); |
|
1861 |
|
1862 // if we have a selected service, insert it into selection |
|
1863 if (iServiceId != KMsvNullIndexEntryId) |
|
1864 { |
|
1865 msvEntrySelection->InsertL(0, iServiceId); |
|
1866 } |
|
1867 |
|
1868 CMsvOperation * op = NULL; |
|
1869 TCommandParameters parameters; // initialized to zero |
|
1870 TCommandParametersBuf paramPack( parameters ); |
|
1871 |
|
1872 TRAP (error, op = iMmsClient->InvokeAsyncFunctionL( |
|
1873 EMmsReceiveForced, |
|
1874 *msvEntrySelection, |
|
1875 paramPack, |
|
1876 iWait->iStatus) ); |
|
1877 |
|
1878 if ( error == KErrNone ) |
|
1879 { |
|
1880 CleanupStack::PushL(op); |
|
1881 iWait->Start(); |
|
1882 |
|
1883 while (iWait->iStatus.Int() == KRequestPending ) |
|
1884 { |
|
1885 if (!iTimer->IsActive()) |
|
1886 { |
|
1887 iTimer->IssueRequest(); |
|
1888 } |
|
1889 CActiveScheduler::Start(); |
|
1890 } |
|
1891 |
|
1892 if ( iWait->iStatus.Int() != KErrNone ) |
|
1893 { |
|
1894 error = iWait->iStatus.Int(); |
|
1895 if ( iWait->iStatus.Int() != KErrNoMemory ) |
|
1896 { |
|
1897 //TMmsLogger::Log(_L("Testbed tried to receive, return status %d"), iWait->iStatus.Int()); |
|
1898 } |
|
1899 } |
|
1900 |
|
1901 CleanupStack::PopAndDestroy(); // op |
|
1902 } |
|
1903 |
|
1904 iTimer->Cancel(); |
|
1905 CleanupStack::PopAndDestroy(); // msvEntrySelection |
|
1906 CleanupStack::PopAndDestroy(); // cEntry |
|
1907 msvEntrySelection = NULL; |
|
1908 cEntry = NULL; |
|
1909 cEntry = iSession->GetEntryL( mmsFolderId ); |
|
1910 CleanupStack::PushL(cEntry); |
|
1911 msvEntrySelection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia ); |
|
1912 messageCount = msvEntrySelection->Count(); |
|
1913 delete msvEntrySelection; |
|
1914 msvEntrySelection = 0; |
|
1915 CleanupStack::PopAndDestroy(); //cEntry |
|
1916 } |
|
1917 while ( error == KErrNoMemory || messageCount > 0 ); |
|
1918 if ( error != KErrNoMemory && error != KErrNone ) |
|
1919 { |
|
1920 //TMmsLogger::Log(_L("Memory failure loop ended with %d"), error); |
|
1921 } |
|
1922 return failureCount; |
|
1923 } |
|
1924 |
|
1925 void MmsTestBed::sendViaClient() |
|
1926 { |
|
1927 CMsvEntry* cEntry = NULL; |
|
1928 |
|
1929 cEntry = iSession->GetEntryL(KMsvDraftEntryId); |
|
1930 CleanupStack::PushL(cEntry); |
|
1931 // Get all mms messages in drafts |
|
1932 CMsvEntrySelection* selection = cEntry->ChildrenWithMtmL( KUidMsgTypeMultimedia ); |
|
1933 CleanupStack::PushL( selection ); |
|
1934 |
|
1935 CMsvOperation * op = NULL; |
|
1936 TTime now; |
|
1937 now.UniversalTime(); |
|
1938 op = iMmsClient->SendL( *selection, iWait->iStatus, now ); |
|
1939 |
|
1940 CleanupStack::PushL(op); |
|
1941 iWait->Start(); |
|
1942 |
|
1943 while (iWait->iStatus.Int() == KRequestPending ) |
|
1944 { |
|
1945 if (!iTimer->IsActive()) |
|
1946 { |
|
1947 iTimer->IssueRequest(); |
|
1948 } |
|
1949 CActiveScheduler::Start(); |
|
1950 } |
|
1951 |
|
1952 iTimer->Cancel(); |
|
1953 CleanupStack::PopAndDestroy(); // op |
|
1954 CleanupStack::PopAndDestroy(2); // cEntry, selection |
|
1955 } |
|
1956 |
|
1957 void MmsTestBed::scheduledFetch(TInt aDelay /* = 5 */) |
|
1958 { |
|
1959 TCommandParameters parameters; |
|
1960 parameters.iInitialDelay = aDelay; |
|
1961 TCommandParametersBuf paramPack( parameters ); |
|
1962 |
|
1963 CMsvEntrySelection* selection = new CMsvEntrySelection; |
|
1964 CleanupStack::PushL( selection ); |
|
1965 // if we have a selected service, insert it into selection |
|
1966 if (iServiceId != KMsvNullIndexEntryId) |
|
1967 { |
|
1968 selection->InsertL(0, iServiceId); |
|
1969 } |
|
1970 else |
|
1971 { |
|
1972 selection->InsertL(0, iDefaultServiceId); |
|
1973 } |
|
1974 |
|
1975 CMsvOperation * op = NULL; |
|
1976 op = iMmsClient->InvokeAsyncFunctionL( |
|
1977 EMmsScheduledReceive, |
|
1978 *selection, |
|
1979 paramPack, |
|
1980 iWait->iStatus); |
|
1981 |
|
1982 CleanupStack::PushL(op); |
|
1983 iWait->Start(); |
|
1984 |
|
1985 while (iWait->iStatus.Int() == KRequestPending ) |
|
1986 { |
|
1987 if (!iTimer->IsActive()) |
|
1988 { |
|
1989 iTimer->IssueRequest(); |
|
1990 } |
|
1991 CActiveScheduler::Start(); |
|
1992 } |
|
1993 |
|
1994 iTimer->Cancel(); |
|
1995 CleanupStack::PopAndDestroy(); // op |
|
1996 CleanupStack::PopAndDestroy(); // selection |
|
1997 } |
|
1998 |
|
1999 void MmsTestBed::fetchForcedImmediate() |
|
2000 { |
|
2001 TCommandParameters parameters; |
|
2002 TCommandParametersBuf paramPack( parameters ); |
|
2003 |
|
2004 CMsvEntrySelection* selection = new CMsvEntrySelection; |
|
2005 CleanupStack::PushL( selection ); |
|
2006 // if we have a selected service, insert it into selection |
|
2007 if (iServiceId != KMsvNullIndexEntryId) |
|
2008 { |
|
2009 selection->InsertL(0, iServiceId); |
|
2010 } |
|
2011 else |
|
2012 { |
|
2013 selection->InsertL(0, iDefaultServiceId); |
|
2014 } |
|
2015 |
|
2016 |
|
2017 CMsvOperation * op = NULL; |
|
2018 op = iMmsClient->InvokeAsyncFunctionL( |
|
2019 EMmsReceiveForced, |
|
2020 *selection, |
|
2021 paramPack, |
|
2022 iWait->iStatus); |
|
2023 |
|
2024 CleanupStack::PushL(op); |
|
2025 iWait->Start(); |
|
2026 |
|
2027 while (iWait->iStatus.Int() == KRequestPending ) |
|
2028 { |
|
2029 if (!iTimer->IsActive()) |
|
2030 { |
|
2031 iTimer->IssueRequest(); |
|
2032 } |
|
2033 CActiveScheduler::Start(); |
|
2034 } |
|
2035 |
|
2036 iTimer->Cancel(); |
|
2037 CleanupStack::PopAndDestroy(); // op |
|
2038 CleanupStack::PopAndDestroy(); // selection |
|
2039 } |
|
2040 |
|
2041 void MmsTestBed::getEventType() |
|
2042 { |
|
2043 if ( !checkLogClient() ) |
|
2044 { |
|
2045 return; // not available |
|
2046 } |
|
2047 |
|
2048 CLogEventType* eventType = CLogEventType::NewL(); |
|
2049 CleanupStack::PushL( eventType ); |
|
2050 eventType->SetUid(iLogEvent->EventType()); |
|
2051 iLogClient->GetEventType( *eventType, iWait->iStatus ); |
|
2052 |
|
2053 iWait->Start(); |
|
2054 CleanupStack::PopAndDestroy(); // eventType |
|
2055 } |
|
2056 |
|
2057 void MmsTestBed::addEventType() |
|
2058 { |
|
2059 if ( !checkLogClient() ) |
|
2060 { |
|
2061 return; // not available |
|
2062 } |
|
2063 |
|
2064 CLogEventType* eventType = CLogEventType::NewL(); |
|
2065 CleanupStack::PushL( eventType ); |
|
2066 eventType->SetUid(iLogEvent->EventType()); |
|
2067 eventType->SetDescription(_L("Multimedia Message") ); |
|
2068 eventType->SetLoggingEnabled( ETrue ); |
|
2069 |
|
2070 // iWait->iStatus = KRequestPending; |
|
2071 iLogClient->AddEventType( *eventType, iWait->iStatus ); |
|
2072 iWait->Start(); |
|
2073 CleanupStack::PopAndDestroy(); // eventType |
|
2074 } |
|
2075 |
|
2076 void MmsTestBed::deleteEventType() |
|
2077 { |
|
2078 if ( !checkLogClient() ) |
|
2079 { |
|
2080 return; // not available |
|
2081 } |
|
2082 // iWait->iStatus = KRequestPending; |
|
2083 iLogClient->DeleteEventType( iLogEvent->EventType(), iWait->iStatus ); |
|
2084 iWait->Start(); |
|
2085 } |
|
2086 |
|
2087 void MmsTestBed::cleanLog() |
|
2088 { |
|
2089 TInt count = 0; |
|
2090 |
|
2091 count = getLogEntries(); |
|
2092 |
|
2093 TInt i; |
|
2094 for ( i = 0; i < count; ++i ) |
|
2095 { |
|
2096 // when a view is created, it will be positioned on the first event |
|
2097 // iWait->iStatus = KRequestPending; |
|
2098 iLogClient->DeleteEvent(iLogView->Event().Id(), iWait->iStatus); |
|
2099 iWait->Start(); |
|
2100 |
|
2101 if ( iLogView->NextL( iWait->iStatus ) ) |
|
2102 { |
|
2103 // should complete with KErrNone |
|
2104 iWait->Start(); |
|
2105 if ( iWait->iStatus.Int() != KErrNone ) |
|
2106 { |
|
2107 // could not get next event! |
|
2108 break; |
|
2109 } |
|
2110 } |
|
2111 else |
|
2112 { |
|
2113 break; // no more events! |
|
2114 } |
|
2115 } |
|
2116 } |
|
2117 |
|
2118 void MmsTestBed::setOnline(bool value) |
|
2119 { |
|
2120 //value = true for online mode |
|
2121 //value = false for offline mode |
|
2122 CRepository* repository = NULL; |
|
2123 TInt retval = KErrNone; |
|
2124 TRAP( retval, repository = CRepository::NewL( KCRUidCoreApplicationUIs ) ); |
|
2125 if( retval == KErrNone ) |
|
2126 { |
|
2127 repository->Set( KCoreAppUIsNetworkConnectionAllowed, value ); |
|
2128 delete repository; |
|
2129 } |
|
2130 } |
|
2131 |
|
2132 void MmsTestBed::generateDeliveryReport( CMmsHeaders* aMmsHeaders ) |
|
2133 { |
|
2134 iEncodeBuffer->ResizeL( 1024 ); |
|
2135 |
|
2136 TInt position = 0; |
|
2137 |
|
2138 // encode message type |
|
2139 iEncodeBuffer->Write( position, &KMmsAssignedMessageType, 1 ); |
|
2140 position++; |
|
2141 iEncodeBuffer->Write( position, &KMmsMessageTypeDeliveryInd, 1 ); |
|
2142 position++; |
|
2143 |
|
2144 // version |
|
2145 iEncodeBuffer->Write( position, &KMmsAssignedMmsVersion, 1 ); |
|
2146 position++; |
|
2147 |
|
2148 TUint8 version = aMmsHeaders->MmsVersion() | 0x80; // current version as short integer |
|
2149 iEncodeBuffer->Write( position, &version, 1 ); |
|
2150 position++; |
|
2151 |
|
2152 // message id from the headers |
|
2153 // At least once MMSC did not send us the message id! |
|
2154 // if message id is missing, we cannot match the entry! |
|
2155 // This only a fake. Real delivery reports should always |
|
2156 // contain the message id. |
|
2157 if ( aMmsHeaders->MessageId().Length() > 0 ) |
|
2158 { |
|
2159 iEncodeBuffer->Write( position, &KMmsAssignedMessageId, 1 ); |
|
2160 position++; |
|
2161 iEncodeBuffer->Write( position, &(aMmsHeaders->MessageId()[0]), aMmsHeaders->MessageId().Length() ); |
|
2162 position += aMmsHeaders->MessageId().Length(); |
|
2163 iEncodeBuffer->Write( position, &KMmsNull, 1 ); |
|
2164 position++; |
|
2165 } |
|
2166 |
|
2167 // To is taken from the headers |
|
2168 iEncodeBuffer->Write( position, &KMmsAssignedTo, 1 ); |
|
2169 position++; |
|
2170 |
|
2171 TPtrC recipient; |
|
2172 if ( aMmsHeaders->ToRecipients().MdcaCount() > 0 && |
|
2173 aMmsHeaders->ToRecipients()[0].Length() > 0 ) |
|
2174 { |
|
2175 recipient.Set( aMmsHeaders->ToRecipients()[0] ); |
|
2176 } |
|
2177 else if( aMmsHeaders->CcRecipients().MdcaCount() > 0 && |
|
2178 aMmsHeaders->CcRecipients()[0].Length() > 0 ) |
|
2179 { |
|
2180 recipient.Set( aMmsHeaders->CcRecipients()[0] ); |
|
2181 } |
|
2182 else if( aMmsHeaders->BccRecipients().MdcaCount() > 0 && |
|
2183 aMmsHeaders->BccRecipients()[0].Length() > 0 ) |
|
2184 { |
|
2185 recipient.Set( aMmsHeaders->BccRecipients()[0] ); |
|
2186 } |
|
2187 else |
|
2188 { |
|
2189 recipient.Set( _L("Jasso-Kissa@jii.fi") ); |
|
2190 } |
|
2191 |
|
2192 TMmsAddressType addressType = EMmsAddressTypeUnknown; |
|
2193 |
|
2194 if ( recipient.Find( KMiuMau ) != KErrNotFound ) |
|
2195 { |
|
2196 addressType = EMmsAddressTypeEmail; |
|
2197 } |
|
2198 else |
|
2199 { |
|
2200 addressType = EMmsAddressTypeMobile; |
|
2201 } |
|
2202 |
|
2203 TUint8 character; |
|
2204 TInt i; |
|
2205 if ( addressType == EMmsAddressTypeEmail ) |
|
2206 { |
|
2207 // email address - ASCII ONLY - THIS IS JUST A TEST! |
|
2208 |
|
2209 for ( i = 0; i < recipient.Length(); ++i ) |
|
2210 { |
|
2211 character = TUint8( recipient[i] & 0xff ); |
|
2212 iEncodeBuffer->Write( position, &character, 1 ); |
|
2213 position++; |
|
2214 } |
|
2215 iEncodeBuffer->Write( position, &KMmsNull, 1 ); |
|
2216 position++; |
|
2217 |
|
2218 } |
|
2219 else |
|
2220 { |
|
2221 // must be a phone number |
|
2222 // We expect for now that the format is correct as is |
|
2223 // All legal characters present in a phone number are ASCII |
|
2224 |
|
2225 TInt i; |
|
2226 for ( i = 0; i < recipient.Length(); ++i ) |
|
2227 { |
|
2228 character = TUint8( recipient[i] & 0xff ); |
|
2229 iEncodeBuffer->Write( position, &character, 1 ); |
|
2230 position++; |
|
2231 } |
|
2232 iEncodeBuffer->Write( position, KMmsPlmn, KMmsPlmnLength ); |
|
2233 position += KMmsPlmnLength; |
|
2234 iEncodeBuffer->Write( position, &KMmsNull, 1 ); |
|
2235 position++; |
|
2236 } |
|
2237 |
|
2238 // date |
|
2239 iEncodeBuffer->Write( position, &KMmsAssignedDate, 1 ); |
|
2240 position++; |
|
2241 |
|
2242 TLocale locale; |
|
2243 locale.Refresh(); |
|
2244 TInt64 UtcDate; |
|
2245 TTimeIntervalSeconds universalTimeOffset( locale.UniversalTimeOffset() ); |
|
2246 |
|
2247 TTime now; |
|
2248 now.UniversalTime(); |
|
2249 UtcDate = ( now.MicroSecondsFrom( TTime( KMmsYear1970String ) ).Int64() ) / 1000000 ; |
|
2250 |
|
2251 UtcDate -= universalTimeOffset.Int(); |
|
2252 |
|
2253 if ( locale.QueryHomeHasDaylightSavingOn() ) |
|
2254 { |
|
2255 TTimeIntervalSeconds daylightSaving( 60 * 60 ); |
|
2256 UtcDate -= daylightSaving.Int(); |
|
2257 } |
|
2258 |
|
2259 TUint8 len; // number of bytes we will need |
|
2260 len = 0; |
|
2261 TUint8 array[8]; |
|
2262 |
|
2263 TInt64 temp = UtcDate; |
|
2264 |
|
2265 for (i = 7; i >= 0; --i) |
|
2266 { |
|
2267 array[i] = TInt8( ( I64INT( temp ) ) & 0xFF ); |
|
2268 I64LSR( temp, 8 ); |
|
2269 } |
|
2270 |
|
2271 len = 8; |
|
2272 i = 0; |
|
2273 while( ( array[i]== 0 ) && ( i < 8 ) ) |
|
2274 { |
|
2275 i++; |
|
2276 len--; |
|
2277 } |
|
2278 |
|
2279 // a zero should be coded as short integer. |
|
2280 // However, if there is a valid reason to code a zero as a long integer, |
|
2281 // we allow it. The caller should know what he is doing. |
|
2282 if ( len == 0 ) |
|
2283 { |
|
2284 len = 1; |
|
2285 } |
|
2286 // write short length |
|
2287 iEncodeBuffer->Write( position, &len, 1 ); |
|
2288 position++; |
|
2289 // write as many bytes as were non-zero |
|
2290 iEncodeBuffer->Write( position, &(array[8 - len] ), len ); |
|
2291 position+= len; |
|
2292 // status |
|
2293 iEncodeBuffer->Write( position, &KMmsAssignedStatus, 1 ); |
|
2294 position++; |
|
2295 iEncodeBuffer->Write( position, &KMmsMessageStatusRetrieved, 1 ); |
|
2296 position++; |
|
2297 // DONE!!! |
|
2298 iEncodeBuffer->ResizeL( position ); |
|
2299 return; |
|
2300 } |
|
2301 |
|
2302 void MmsTestBed::sendDeliveryReport() |
|
2303 { |
|
2304 if ( iEncodeBuffer->Size() == 0 ) |
|
2305 { |
|
2306 //No delivery report |
|
2307 return; |
|
2308 } |
|
2309 |
|
2310 |
|
2311 TMsvId mmsFolder = findMMSFolder(); |
|
2312 CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection; |
|
2313 CleanupStack::PushL( selection ); |
|
2314 |
|
2315 TMsvId entryId = TMmsTestUtils::CreateNotificationEntryL( mmsFolder, iServiceId, iEncodeBuffer, *iSession ); |
|
2316 TPtr8 ptr = iEncodeBuffer->Ptr( 0 ); |
|
2317 |
|
2318 // Now we have streamed our data into this entry. |
|
2319 // Now we have an entry that says: local service, MMS MTM |
|
2320 |
|
2321 if ( entryId != KMsvNullIndexEntryId ) |
|
2322 { |
|
2323 selection->AppendL( entryId ); |
|
2324 } |
|
2325 else |
|
2326 { |
|
2327 selection->AppendL( iDefaultServiceId ); |
|
2328 } |
|
2329 |
|
2330 TWatcherParameters parameters; // initialized to zero |
|
2331 parameters.iWatcherId = RThread().Id(); |
|
2332 parameters.iDataPointer = &ptr; |
|
2333 TWatcherParametersBuf paramPack( parameters ); |
|
2334 |
|
2335 CMsvOperation * op = NULL; |
|
2336 |
|
2337 // iWait->iStatus = KRequestPending; |
|
2338 op = iSession->TransferCommandL( |
|
2339 *selection, EMmsDecodePushedMessage, paramPack, iWait->iStatus ); |
|
2340 CleanupStack::PushL(op); |
|
2341 iWait->Start(); |
|
2342 |
|
2343 while (iWait->iStatus.Int() == KRequestPending ) |
|
2344 { |
|
2345 if (!iTimer->IsActive()) |
|
2346 { |
|
2347 iTimer->IssueRequest(); |
|
2348 } |
|
2349 CActiveScheduler::Start(); |
|
2350 } |
|
2351 |
|
2352 iTimer->Cancel(); |
|
2353 |
|
2354 CleanupStack::PopAndDestroy(); // op |
|
2355 CleanupStack::PopAndDestroy(); // selection |
|
2356 } |
|
2357 |
|