/** Creates a New Service If a Service Exists it doesnot create a new one @param aSession Current Session reference @param aDescription Entry Description Descriptor @param aDetail Entry Details Descriptor @internalTechnology */ void CentralRepoUtils::CreateServiceL(CMsvSession* aSession, const TDesC& aDescription, const TDesC& aDetail) { TMsvId serviceId=0; TRAPD(err,TSmsUtilities::ServiceIdL(*aSession,serviceId)); if(err == KErrNotFound) // If Service Already Exists Do not create new One { TInt priority = EMsvMediumPriority; TInt readOnlyFlag = EFalse; TInt visibleFlag = ETrue; TMsvEntry indexEntry; indexEntry.iType = KUidMsvServiceEntry; indexEntry.iMtm = KUidMsgTypeSMS; indexEntry.SetReadOnly(readOnlyFlag); indexEntry.SetVisible(visibleFlag); indexEntry.SetPriority(TMsvPriority(priority)); indexEntry.iDescription.Set(aDescription); indexEntry.iDetails.Set(aDetail); indexEntry.iDate.HomeTime(); CMsvEntry* entry = CMsvEntry::NewL(*aSession,KMsvRootIndexEntryId,TMsvSelectionOrdering()); CleanupStack::PushL(entry); entry->CreateL(indexEntry); CleanupStack::PopAndDestroy(entry); } }
// ----------------------------------------------------------------------------- // CWPMessage::PostprocessEntryL // ----------------------------------------------------------------------------- // void CWPMessage::PostprocessEntryL( CMsvEntry& aCEntry, TMsvEntry& aTEntry ) { FLOG( _L( "CWPMessage::PostprocessEntryL" ) ); aTEntry.SetReadOnly(EFalse); aTEntry.SetVisible(ETrue); aTEntry.SetInPreparation(EFalse); aCEntry.ChangeL(aTEntry); }
void CSmsReplyToStep::CreateMessageL() { INFO_PRINTF1(_L("Creating message...")); TMsvEntry entry; entry.SetVisible(ETrue); entry.SetInPreparation(ETrue); entry.iServiceId = iTestUtils->iSmsServiceId; entry.iType = KUidMsvMessageEntry; entry.iMtm = KUidMsgTypeSMS; entry.iDate.HomeTime(); entry.iSize = 0; entry.iDescription.Set(KNullDesC); entry.iDetails.Set(KNullDesC); entry.SetSendingState(KMsvSendStateScheduled); // Create the SMS header object... CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils->iRichText); CleanupStack::PushL(header); // Set the body text... iTestUtils->iRichText->Reset(); iTestUtils->iRichText->InsertL(0, KMessageData); // Copy the message settings... header->SetSmsSettingsL(*iTestUtils->iServiceSettings); // Set the service centre TInt defaultIndex = iTestUtils->iServiceSettings->DefaultServiceCenter(); header->SetServiceCenterAddressL(iTestUtils->iServiceSettings->GetServiceCenter(defaultIndex).Address()); // Set recipient - ask derived class SetRecipientsL(*header); // Update entry description and details... CArrayPtrFlat<CSmsNumber>& recipient = header->Recipients(); entry.iDetails.Set(recipient[0]->Address()); entry.iDescription.Set(iTestUtils->iRichText->Read(0, iTestUtils->iServiceSettings->DescriptionLength())); entry.SetInPreparation(EFalse); // Create the entry - set context to the global outbox. iTestUtils->iMsvEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryId); iTestUtils->iMsvEntry->CreateL(entry); // Create new store and save header information iTestUtils->iMsvEntry->SetEntryL(entry.Id()); CMsvStore* store = iTestUtils->iMsvEntry->EditStoreL(); CleanupStack::PushL(store); header->StoreL(*store); store->StoreBodyTextL(*iTestUtils->iRichText); store->CommitL(); CleanupStack::PopAndDestroy(2, header); iMessageId = entry.Id(); }
// ----------------------------------------------------------------------------- // CWPMessage::PrepareEntry // ----------------------------------------------------------------------------- // void CWPMessage::PrepareEntryLC( TMsvEntry& aEntry ) { FLOG( _L( "CWPMessage::PrepareEntryLC" ) ); // Current time TTime time; // Get Universal time time.UniversalTime(); FLOG( _L( "CWPMessage::PrepareEntryLC create an invisible blank entry" ) ); // create an invisible blank entry aEntry.iType = KUidMsvMessageEntry; aEntry.SetVisible(EFalse); aEntry.SetInPreparation(ETrue); aEntry.SetReadOnly(EFalse); aEntry.SetUnread(ETrue); aEntry.iDate = time; aEntry.iServiceId = KMsvLocalServiceIndexEntryId; aEntry.iError = KErrNone; // iMtmData1 is been used/reserved for count, please don't use for any other purpose. aEntry.SetMtmData1(3); FLOG( _L( "CWPMessage::PrepareEntryLC create an invisible blank entry done" ) ); // Look up the details HBufC* details = NULL; if( iMessage->Authenticated() ) { FLOG( _L( "CWPMessage::PrepareEntryLC iMessage->Authenticated() true" ) ); details = LoadStringLC( R_FROM_SERVICEPROVIDER ); FLOG( _L( "CWPMessage::PrepareEntryLC LoadString done" ) ); } else { FLOG( _L( "CWPMessage::PrepareEntryLC iMessage->Authenticated() false" ) ); if( iSender ) { FLOG( _L( "CWPMessage::PrepareEntryLC iSender true" ) ); details = HBufC::NewLC( iSender->Length() ); details->Des().Copy( *iSender ); } else { FLOG( _L( "CWPMessage::PrepareEntryLC iSender false" ) ); details = KNullDesC().AllocLC(); } } FLOG( _L( "CWPMessage::PrepareEntryLC iDetails.Set" ) ); aEntry.iDetails.Set( *details ); FLOG( _L( "CWPMessage::PrepareEntryLC Done" ) ); }
EXPORT_C TMsvId CMsvTestUtils::CreateServiceL(const TUid aMtm, TBool aReadOnly, TBool aVisible) { TMsvId id = 0; TMsvEntry entry; entry.iMtm = aMtm; entry.iType = KUidMsvServiceEntry; entry.SetReadOnly(aReadOnly); entry.SetVisible(aVisible); SetEntryL(KMsvRootIndexEntryId); CreateEntryL(entry); id = entry.Id(); SetEntryL(id); return id; }
void CBulkCommitServerMtm::CreateBulkEntries(TUint aEntryCount, TMsvId aServiceId) { TMsvEntry newEntry; for (TInt i = 0; i < aEntryCount; ++i) { newEntry.iType = KUidMsvMessageEntry; newEntry.iMtm = KUidBulkCommitTestMtm; newEntry.iServiceId = aServiceId; newEntry.SetVisible(ETrue); newEntry.SetReadOnly(EFalse); newEntry.SetUnread(ETrue); newEntry.iDescription.Set(_L("Bulk Entry")); newEntry.SetSendingState(KMsvSendStateNotApplicable); iServerEntry->CreateEntryBulk(newEntry); } }
/* Creates two folders and then creates bulk entries under each folder. After bulk commit, creates an entry to let the client know about bulk commit is done. @param aEntryCount - Bulk entries to be created under each root entry */ void CBulkCommitServerMtm::CreateBulkEntryWithMultipleParentsL(TUint aEntryCount) { iServerEntry->SetEntry(iServiceId); TMsvEntry folderEntry1, folderEntry2; //create the first folder folderEntry1.iType=KUidMsvFolderEntry; folderEntry1.iMtm = KUidBulkCommitTestMtm; folderEntry1.iServiceId = iServiceId; iServerEntry->CreateEntry(folderEntry1); //create the second folder entry folderEntry2.iType=KUidMsvFolderEntry; folderEntry2.iMtm = KUidBulkCommitTestMtm; folderEntry2.iServiceId = iServiceId; iServerEntry->CreateEntry(folderEntry2); iServerEntry->SetEntry(folderEntry1.Id()); //Create a series of entries using the bulk API under the first folder CreateBulkEntries(aEntryCount, folderEntry1.Id()); iServerEntry->SetEntry(folderEntry2.Id()); //Create a series of entries using the bulk API under the second folder CreateBulkEntries(aEntryCount, folderEntry2.Id()); //commit the bulk entries iServerEntry->CompleteBulk(); iServerEntry->SetEntry(iServiceId); //Let the client know that the bulk commit is done TMsvEntry childEntry; childEntry.iType = KUidMsvMessageEntry; childEntry.iMtm = KUidBulkCommitTestMtm; childEntry.iServiceId = iServiceId; childEntry.SetVisible(ETrue); childEntry.SetReadOnly(EFalse); childEntry.SetUnread(ETrue); childEntry.iDescription.Set(_L("Bulk Commit Done")); childEntry.SetSendingState(KMsvSendStateNotApplicable); iServerEntry->CreateEntry(childEntry); //Set entry to NULL entry to avoid locking iServerEntry->SetEntry(KMsvNullIndexEntryId); }
TMsvId TestUniDataModelVCalPlugin::SetBIOServiceIdL() { // Haven't found an entry so create a BIO Message service: TMsvEntry bioServiceEntry; bioServiceEntry.iMtm = KUidBIOMessageTypeMtm; bioServiceEntry.iType = KUidMsvServiceEntry; bioServiceEntry.SetVisible(EFalse); bioServiceEntry.iDate.UniversalTime(); bioServiceEntry.iDescription.Set(_L("BIO Message Service ")); // Is there such a thing? bioServiceEntry.iDetails.Set(_L("BIO Message Service")); TMsvId newBIOServiceId; iMsvEntry->SetEntryL(KMsvRootIndexEntryId); iMsvEntry->CreateL(bioServiceEntry); // Needs to be a child of the root! newBIOServiceId = bioServiceEntry.Id(); return newBIOServiceId; }
// ----------------------------------------------------------------------------- // CMmsAdapterMsvApi::AddUserFolderL // Creates new user folder // ----------------------------------------------------------------------------- TInt CMmsAdapterMsvApi::AddUserFolderL( TMsvId& aFolder, const TDesC& aName ) { TRACE_FUNC_ENTRY; LOGGER_WRITE_1( "aName: %S", &aName ); // Make sure that we are not going to add same folder twise TBool found( EFalse ); found = FindUserFolderL( aName, aFolder ); if ( found ) { LOGGER_WRITE( "Folder already exists" ); LOGGER_LEAVEFN( "CMmsAdapterMsvApi::AddUserFolderL" ); return KErrNone; } CMsvEntry* entry = iSession.GetEntryL(KMsvMyFoldersEntryIdValue); CleanupStack::PushL( entry ); TTime date; date.UniversalTime(); TMsvEntry folderEntry; folderEntry.iType = KUidMsvFolderEntry; folderEntry.iMtm = KUidMsvLocalServiceMtm; folderEntry.iDetails.Set( aName ); folderEntry.iServiceId = KMsvLocalServiceIndexEntryIdValue; folderEntry.iSize = sizeof( folderEntry ); folderEntry.iDate = date; folderEntry.SetStandardFolder( EFalse ); folderEntry.SetVisible( ETrue ); folderEntry.SetComplete( ETrue ); folderEntry.SetInPreparation( EFalse ); folderEntry.SetReadOnly( EFalse ); entry->CreateL( folderEntry ); CleanupStack::PopAndDestroy( entry ); aFolder = folderEntry.Id(); TRACE_FUNC_EXIT; return KErrNone; }
TVerdict CCreateSmsMessageTestStep::doTestStepL() { CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; CActiveScheduler::Install(scheduler); CleanupStack::PushL(scheduler); CSessionObserver* sessionObserver = new (ELeave) CSessionObserver; CleanupStack::PushL(sessionObserver); CMsvSession* session = CMsvSession::OpenSyncL(*sessionObserver); CleanupStack::PushL(session); _LIT(KFileName,"FileName"); TPtrC tag; if ( !GetStringFromConfig(ConfigSection(),KFileName,tag)) { ERR_PRINTF1(_L("No Input for FileName in CreateSmsMessage")); User::Leave(KErrNotReady); } HBufC* fileName = tag.AllocLC(); // Create a Rich Text object CPlainText::TTextOrganisation ttOrg = {CPlainText::EOrganiseByLine}; CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL(); CleanupStack::PushL(paraFormatLayer); CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL(); CleanupStack::PushL(charFormatLayer); CRichText* bodyRichText = CRichText::NewL(paraFormatLayer, charFormatLayer); CleanupStack::PushL(bodyRichText); // Store the file contents into the CRichText object bodyRichText->ImportTextFileL(0, fileName->Des(), ttOrg); // Create the SMS header object... CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *bodyRichText); CleanupStack::PushL(header); // Set the body text... CSmsSettings* smsSettings = CSmsSettings::NewL(); CleanupStack::PushL(smsSettings); CSmsAccount* account = CSmsAccount::NewLC(); account->LoadSettingsL(*smsSettings); // Copy the message settings... header->SetSmsSettingsL(*smsSettings); // Set the service centre TInt defaultIndex = smsSettings->DefaultServiceCenter(); header->SetServiceCenterAddressL(smsSettings->GetServiceCenter(defaultIndex).Address()); // Set recipient - ask derived class SetRecipientsL(*header); CArrayPtrFlat<CSmsNumber>& recipient = header->Recipients(); INFO_PRINTF1(_L("Creating message...")); TMsvEntry entry; entry.SetVisible(ETrue); entry.SetInPreparation(ETrue); TMsvId srvcId=0; TSmsUtilities::ServiceIdL(*session, srvcId); entry.iServiceId = srvcId; entry.iType = KUidMsvMessageEntry; entry.iMtm = KUidMsgTypeSMS; entry.iDate.UniversalTime(); entry.iSize = 0; entry.iDescription.Set(KNullDesC); entry.iDetails.Set(KNullDesC); entry.SetSendingState(KMsvSendStateWaiting); // Update entry description and details... entry.iDetails.Set(recipient[0]->Address()); entry.iDescription.Set(recipient[0]->Address()); entry.SetInPreparation(EFalse); //TPtrC tag; _LIT(KParent,"Parent"); TPtrC parentTag; if ( !GetStringFromConfig(ConfigSection(),KParent,parentTag)) { ERR_PRINTF1(_L("No Input for Outbox")); User::Leave(KErrNotReady); } // Create the entry - set context to the global outbox. TMsvId paramParentId = MsgingUtils::GetLocalFolderId(parentTag);//KMsvGlobalOutBoxIndexEntryId; CMsvEntry* newEntry = CMsvEntry::NewL(*session,paramParentId,TMsvSelectionOrdering()); CleanupStack::PushL(newEntry); newEntry->SetEntryL(paramParentId); newEntry->CreateL(entry); // Create new store and save header information newEntry->SetEntryL(entry.Id()); CMsvStore* store = newEntry->EditStoreL(); CleanupStack::PushL(store); header->StoreL(*store); store->StoreBodyTextL(*bodyRichText); store->CommitL(); //store,newEntry,account, smsSettings, header, bodyRichText,charFormatLayer, paraFormatLayer,fileName CleanupStack::PopAndDestroy(9,fileName); CleanupStack::PopAndDestroy(3, scheduler); SetTestStepResult(EPass); return TestStepResult(); }
TMsvId TestUniDataModelVCalPlugin::CreateBIOEntryL(TDesC& aText, TBIOMessageType aMessageType) { // Ensure that we have a valid service ID to work with: TMsvId iBioServiceId; iBioServiceId = SetBIOServiceIdL(); HBufC* localBuffer = aText.AllocL(); CleanupStack::PushL(localBuffer); TPtr messDes = localBuffer->Des(); if (aMessageType != EBiovCardMessage && aMessageType != EBiovCalenderMessage) { // convert \r\n to \n since this is what is expected from SMS when not vCard data for (TInt i = 0; i < messDes.Length(); i++) { if (messDes[i] == (TText) '\r' && i < messDes.Length() - 1 && messDes[i + 1] == (TText) '\n') messDes.Delete(i, 1); } } // Create and fill a CRichText object for the jobbie: CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL(); CleanupStack::PushL(paraFormatLayer); CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL(); CleanupStack::PushL(charFormatLayer); CRichText* richText = CRichText::NewL(paraFormatLayer, charFormatLayer); CleanupStack::PushL(richText); TInt pos = richText->DocumentLength(); richText->InsertL(pos, messDes); TMsvEntry newBioEntry; newBioEntry.SetNew(ETrue); newBioEntry.SetComplete(EFalse); newBioEntry.SetUnread(ETrue); newBioEntry.SetVisible(ETrue); newBioEntry.SetReadOnly(EFalse); newBioEntry.SetFailed(EFalse); newBioEntry.SetOperation(EFalse); newBioEntry.SetMultipleRecipients(EFalse); newBioEntry.SetAttachment(EFalse); newBioEntry.iMtm = KUidBIOMessageTypeMtm; newBioEntry.iType = KUidMsvMessageEntry; newBioEntry.iServiceId = iBioServiceId; TTime now; now.UniversalTime(); newBioEntry.iDate = now; TTime unixEpoch(KUnixEpoch); TTimeIntervalSeconds seconds; TTime timeStamp = newBioEntry.iDate; timeStamp.SecondsFrom(unixEpoch, seconds); retTimeStamp.setTime_t(seconds.Int()); newBioEntry.iDescription.Set(richText->Read(0, richText->DocumentLength())); TBufC<KTelephoneNumberMaxLength> telNumber; QString recepient(TEST_MSG_FROM1); tempNumber = XQConversions::qStringToS60Desc(recepient); telNumber = tempNumber->Des(); newBioEntry.iDetails.Set(telNumber); SetForMtmTypeL(newBioEntry, aMessageType); newBioEntry.iSize = richText->DocumentLength();// msgSize; CreateBioEntryClientSideL(newBioEntry, *richText); CleanupStack::PopAndDestroy(4); // richText, charFormatLayer, paraFormatLayer, localBuffer return newBioEntry.Id(); }
LOCAL_C void doMainL() { InitL(); TInt globalError = KErrNone; testUtils->FileSession().SetSessionPath(_L("c:\\")); testUtils->GoClientSideL(); testUtils->CreateSmtpServiceL(); pop3Service = testUtils->CreatePopServiceL(); testUtils->GoServerSideL(); testUtils->CreateMessageL(K_T_MIUT10_PLAIN_MSG, pop3Service, pop3Service); testUtils->CreateMessageL(K_T_MIUT10_PLAIN_MSG, pop3Service, pop3Service); testUtils->CreateMessageL(K_T_MIUT10_HTML_ATTACHMENT_MSG, pop3Service, pop3Service); test.Printf(_L("\nPerforming Cache Management Tests\n")); testUtils->GoClientSideL(); testUtils->iMsvEntry->SetEntryL(pop3Service); TMsvEntry entry = testUtils->iMsvEntry->Entry(); entry.SetVisible(ETrue); testUtils->iMsvEntry->ChangeL(entry); TRequestStatus observerStatus; CImCacheManager* cacheManager = CFilteredCacheManager::NewL(*testUtils->iMsvSession, observerStatus); CleanupStack::PushL(cacheManager); TestUiTimer* testUiTimer = TestUiTimer::NewLC(test.Console(), cacheManager); CTestActive* testActive = new (ELeave) CTestActive(); CleanupStack::PushL(testActive); testActive->StartL(); testUiTimer->IssueRequest(); testUtils->TestStart(0, K_T_MIUT10_DESCRIPTION); cacheManager->StartL(pop3Service, testActive->iStatus); CActiveScheduler::Start(); // DEF066273: rewrite-Messaging regression test T_MIUT10 failing consistently // DEF049479: is no longer valid it has therefore not been taken into consideration //ensure at correct service entry testUtils->iMsvEntry->SetEntryL(pop3Service); //store msg entires of this service CMsvEntrySelection* popEntrySelection; popEntrySelection=testUtils->iMsvEntry->ChildrenL(); CleanupStack::PushL(popEntrySelection); TInt count=popEntrySelection->Count(); TInt childEntries; TMsvId msgId; TMsvEntry msgEntry; TBuf<128> msgFail,msgPass; for(TInt i=0; i<count; ++i) { //ensure at correct location msgId=popEntrySelection->At(i); testUtils->iMsvEntry->SetEntryL(msgId); // testUtils->iMsvEntry->Entry(); //ensure that there are no more child entries childEntries=testUtils->iMsvEntry->Count(); if (childEntries!=0 && DONT_PRUNE_ID!=msgId) { //body text or attachments still exist msgFail.Format(K_T_MIUT10_MSG_NOT_PRUNED,msgId); testUtils->WriteComment(msgFail); globalError = KErrMsgNotPruned; } else { //email successfully-prunned header saved. msgPass.Format(K_T_MIUT10_MSG_PRUNED,msgId); testUtils->WriteComment(msgPass); } } testUtils->TestFinish(0, globalError); if (globalError == KErrNone) { testUtils->TestHarnessCompleted(); } else { testUtils->TestHarnessFailed(globalError); } CleanupStack::PopAndDestroy(4,cacheManager); // testActive, testUiTimer, cacheManager,popEntrySelection Closedown(); }