void CEntryObserver::HandleEntryEventL(TMsvEntryEvent aEvent, TAny* aArg1, TAny* /*aArg2*/, TAny* /*aArg3*/) { if (aEvent == EMsvNewChildren && iCurrentMessageNum > -1) { CMsvEntrySelection* msgs = (CMsvEntrySelection*)aArg1; TInt count = msgs->Count(); TInt msgRecv = 0; while (count--) { TMsvId id = (*msgs)[count]; CSmsHeader* header = iSmsTest.GetHeaderLC(id); if (header->Type() == CSmsPDU::ESmsDeliver) { iReceived->AppendL(id); msgRecv++; } CleanupStack::PopAndDestroy(header); } if (msgRecv) iSmsTest.Printf(_L("%d Messages Received in inbox\n"), msgRecv); } }
TInt CSmsSendRecvTest::CountRecipientsL(TMsvId aId) { CSmsHeader* header = iSmsTest.GetHeaderLC(aId); const TInt count = header->Recipients().Count(); CleanupStack::PopAndDestroy(header); return count; }
TInt CMtfTestActionUtilsSmsScripts::SetSmsHeaderInfoFromConfigurationFileL(CMtfTestCase& aTestCase, const TDesC& aSettingsFile, CSmsHeader& aSmsHeader) { CMtfTestActionUtilsConfigFileParser* scriptFileParser = CMtfTestActionUtilsConfigFileParser::NewL(aSettingsFile); CleanupStack::PushL(scriptFileParser); // Recipient Number: If the recipient number is not present in the file, Leave. TPtrC stringPtr; User::LeaveIfError(scriptFileParser->GetFieldAsString(KRecipient,stringPtr)); CSmsNumber* recipientNumber = CSmsNumber::NewL(); CleanupStack::PushL(recipientNumber); recipientNumber->SetAddressL(stringPtr); aSmsHeader.Recipients().AppendL(recipientNumber); //Bio UId Type if((scriptFileParser->GetFieldAsString(KBioUId,stringPtr)) == KErrNone) { TBioMsgIdType bioIdType = ObtainValueParameterL<TBioMsgIdType>(aTestCase, stringPtr); aSmsHeader.SetBioMsgIdType(bioIdType); } else { aSmsHeader.SetBioMsgIdType(); //Sets the message's BIO message type identifier as EBioMsgIdNbs } CleanupStack::Pop(2); return KErrNone; }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ void CFakeSMSSender::AppendPDUDataL(TMsvId aEntryId, const TDesC& aRecipient,TBool aUnicodeMsg,const TDesC& aBody) { CMsvEntry* entry = iMsvSession->GetEntryL(aEntryId); CleanupStack::PushL(entry); CMsvStore* srore= entry->EditStoreL(); CleanupStack::PushL(srore); if(srore) { CSmsBuffer* smsBuffer = CSmsBuffer::NewL(); CSmsMessage* smsMsg = CSmsMessage::NewL(iFsSession,CSmsPDU::ESmsDeliver, smsBuffer); CleanupStack::PushL(smsMsg); smsMsg->SetTime(entry->Entry().iDate); if(aRecipient.Length() > 20) smsMsg->SetToFromAddressL(aRecipient.Left(20)); else smsMsg->SetToFromAddressL(aRecipient); smsBuffer->InsertL(0,aBody); CSmsDeliver& DSMSPDU = STATIC_CAST(CSmsDeliver&,smsMsg->SmsPDU()); DSMSPDU.SetMoreMessagesToSend(EFalse); DSMSPDU.SetReplyPath(EFalse); DSMSPDU.SetStatusReportIndication(EFalse); TInt Hours(0x20); DSMSPDU.SetServiceCenterTimeStamp(entry->Entry().iDate,Hours); DSMSPDU.SetTextCompressed(EFalse); DSMSPDU.SetPIDType(TSmsProtocolIdentifier::ESmsPIDShortMessageType); //DSMSPDU.SetTextCompressed(TBool aCompressed); //DSMSPDU.SetAlphabet(TSmsDataCodingScheme::TSmsAlphabet aAlphabet); CSmsHeader* MyHeader = CSmsHeader::NewL(smsMsg); CleanupStack::Pop(1);//smsMsg CleanupStack::PushL(MyHeader); CSmsSettings* MySetting = CSmsSettings::NewL(); CleanupStack::PushL(MySetting); if(aUnicodeMsg) MySetting->SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabetUCS2); else MySetting->SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabet7Bit); //MySetting->StoreL(*srore);//InternalizeL MyHeader->SetSmsSettingsL(*MySetting); MyHeader->StoreL(*srore); srore->CommitL(); CleanupStack::PopAndDestroy(2);//MySetting,MyHeader, } CleanupStack::PopAndDestroy(2);//entry,srore }
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::StoreMsgL // ----------------------------------------------------------------------------- // void CWPMessage::StoreMsgL( TInt aResource ) { FLOG( _L( "CWPMessage::StoreMsgL(aResource)" ) ); // create an invisible blank entry TMsvEntry entry; PrepareEntryLC( entry ); // details on cleanup stack entry.iMtm = KUidMsgTypeSMS; // Store entry in inbox CMsvEntry* msvEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId); CleanupStack::PushL(msvEntry); msvEntry->CreateL(entry); msvEntry->Session().CleanupEntryPushL(entry.Id()); msvEntry->SetEntryL(entry.Id()); // Save the message body CMsvStore* store = msvEntry->EditStoreL(); CleanupStack::PushL(store); CParaFormatLayer* paraFormat = CParaFormatLayer::NewL(); CleanupStack::PushL( paraFormat ); CCharFormatLayer* charFormat = CCharFormatLayer::NewL(); CleanupStack::PushL( charFormat ); CRichText* body = CRichText::NewL( paraFormat, charFormat ); CleanupStack::PushL( body ); HBufC* text = LoadStringLC( aResource ); body->InsertL( body->DocumentLength(), *text ); store->StoreBodyTextL( *body ); // Store the actual message for post-mortem analysis iMessage->StoreL( *store ); // Save the SMS header and create a description field CSmsHeader* header = CSmsHeader::NewL( CSmsPDU::ESmsDeliver, *body ); CleanupStack::PushL( header ); TBuf<KSmsDescriptionLength> description; CSmsGetDetDescInterface* smsPlugin = CSmsGetDetDescInterface::NewL(); CleanupStack::PushL( smsPlugin ); smsPlugin->GetDescription( header->Message(), description ); CleanupStack::PopAndDestroy( smsPlugin ); entry.iDescription.Set( description ); header->StoreL( *store ); store->CommitL(); CleanupStack::PopAndDestroy( 5 ); // header, text, body, charformat, paraFormat // Complete processing the message PostprocessEntryL( *msvEntry, entry ); CleanupStack::PopAndDestroy(); //store msvEntry->Session().CleanupEntryPop(); //entry CleanupStack::PopAndDestroy(2); //details, msvEntry }
void CSmsReplyToStep::SetRecipientsL(CSmsHeader& aHeader) { iTestUtils->Printf(_L("--Setting single recipient\n")); CSmsNumber* rcpt = CSmsNumber::NewL(); CleanupStack::PushL(rcpt); rcpt->SetAddressL(KRecipientOk); aHeader.Recipients().AppendL(rcpt); CleanupStack::Pop(rcpt); }
TBool CSmsReplyToStep::CheckMessageL() { INFO_PRINTF1(_L("Received new message in Inbox - should be status report...")); TMsvSelectionOrdering ordering; ordering.ShowInvisibleEntries(); CMsvEntry* entry = CMsvEntry::NewL(*iSession, KMsvGlobalInBoxIndexEntryId,ordering); CleanupStack::PushL(entry); CMsvEntrySelection* msvEntrySelection; msvEntrySelection=entry->ChildrenL(); CleanupStack::PushL(msvEntrySelection); // Check how many mesasges there are - should be just 1 TInt count = msvEntrySelection->Count(); INFO_PRINTF3(_L("Number of new messages: %d, should be: %d"), count, 1); // Restore the message CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsDeliver, *iTestUtils->iRichText); CleanupStack::PushL(header); entry->SetEntryL((*msvEntrySelection)[0]); CMsvStore* store = entry->ReadStoreL(); CleanupStack::PushL(store); header->RestoreL(*store); if(store->HasBodyTextL()) { store->RestoreBodyTextL(*iTestUtils->iRichText); } TBuf<KSmsDescriptionLength> desc; User::LeaveIfError(TSmsUtilities::GetDescription(header->Message(), desc)); //Check for a reply address field CSmsReplyAddressOperations& operations = STATIC_CAST(CSmsReplyAddressOperations&,header->Message().GetOperationsForIEL(CSmsInformationElement::ESmsReplyAddressFormat)); TBool result=operations.ContainsReplyAddressIEL(); CleanupStack::PopAndDestroy(4,entry); return result; }
void CCreateSmsMessageTestStep::SetRecipientsL(CSmsHeader& aHeader) { INFO_PRINTF1(_L("--Setting single recipient\n")); _LIT(KRecipient, "SentToAddress"); TPtrC rcptTag; if ( !GetStringFromConfig(ConfigSection(),KRecipient,rcptTag)) { ERR_PRINTF1(_L("No Input for FileName in CreateSmsMessage")); User::Leave(KErrNotReady); } HBufC* recipientAdd = rcptTag.AllocLC(); CSmsNumber* rcpt = CSmsNumber::NewL(); CleanupStack::PushL(rcpt); rcpt->SetAddressL(*recipientAdd); aHeader.Recipients().AppendL(rcpt); CleanupStack::Pop(rcpt); CleanupStack::PopAndDestroy(recipientAdd); }
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(); }
void CSmsSendRecvTest::TestParseL() { const TMsvId id = iEntryObserver->LastReceived(); iSmsTest.SetEntryL(id); if (iSaveToFile) { iSmsTest.Printf(_L("Saving BIO message to file\n")); iSmsTest.SaveBodyToFileL(id); } CSmsHeader* header = iSmsTest.GetHeaderLC(id); CSmsDeliver& pdu = header->Deliver(); TBool found = EFalse; TInt destination, originator, is16Bit; destination = originator = is16Bit = 0; if (pdu.UserDataPresent()) { const CSmsUserData& userData = pdu.UserData(); TInt count = userData.NumInformationElements(); iSmsTest.Printf(_L("Pdu contains %d information elements\n"), count); while (!found && count--) { CSmsInformationElement& nextIE=userData.InformationElement(count); switch(nextIE.Identifier()) { case CSmsInformationElement::ESmsIEIApplicationPortAddressing8Bit: case CSmsInformationElement::ESmsIEIApplicationPortAddressing16Bit: { pdu.ApplicationPortAddressing(destination, originator, &is16Bit); found = ETrue; break; } default: break; } } } CleanupStack::PopAndDestroy(header); if (found) iSmsTest.Printf(_L("Application Port Addressing: Dest %d, Origin %d, is16Bit %d\n"), destination, originator, is16Bit); else iSmsTest.Printf(_L("Application Port Addressing: Not Found\n")); if (!iParse) return; if (!iSmsTest.Entry().iBioType) return; iState = EStateParsing; iSmsTest.Printf(_L("Parsing BIO message\n")); CMsvEntrySelection* sel = new (ELeave) CMsvEntrySelection(); CleanupStack::PushL(sel); sel->AppendL(id); delete iOperation; iOperation = NULL; iOperation = Session().TransferCommandL(*sel, KBiosMtmParse, KNullDesC8, iStatus); SetActive(); CleanupStack::PopAndDestroy(sel); }
void TestUniDataModelVCalPlugin::CreateBioEntryClientSideL(TMsvEntry& aEntry, CRichText& aBody) { if (inbox) { iMsvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId); } else if (drafts) { iMsvEntry->SetEntryL(KMsvDraftEntryId); } // Get the global inbox. iMsvEntry->CreateL(aEntry); iMsvEntry->SetEntryL(aEntry.Id()); // Save all the changes CMsvStore* store = iMsvEntry->EditStoreL(); CleanupStack::PushL(store); if (store->HasBodyTextL()) { store->DeleteBodyTextL(); } CPlainText* pText = CPlainText::NewL(); CleanupStack::PushL(pText); if (inbox) { CSmsHeader* smsHeader = CSmsHeader::NewL(CSmsPDU::ESmsDeliver, *pText); CleanupStack::PushL(smsHeader); smsHeader->SetFromAddressL(*tempNumber); smsHeader->StoreL(*store); } else if (drafts) { QString recepient(TEST_MSG_FROM1); QString recepient2(TEST_MSG_FROM2); QString alias(TEST_MSG_ALIAS1); HBufC* addr = XQConversions::qStringToS60Desc(recepient); HBufC* addr2 = XQConversions::qStringToS60Desc(recepient2); HBufC* alias1 = XQConversions::qStringToS60Desc(alias); CSmsHeader* smsHeader = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *pText); CleanupStack::PushL(smsHeader); CSmsNumber* number1 = CSmsNumber::NewL(); // create the instance CleanupStack::PushL(number1); number1->SetNameL(TPtrC()); number1->SetAddressL(*addr); smsHeader->Recipients().AppendL(number1); CleanupStack::Pop(number1); CSmsNumber* number2 = CSmsNumber::NewL(); CleanupStack::PushL(number2); number2->SetNameL(*alias1); number2->SetAddressL(*addr2); smsHeader->Recipients().AppendL(number2); CleanupStack::Pop(number2); smsHeader->StoreL(*store); } store->StoreBodyTextL(aBody); store->CommitL(); CleanupStack::PopAndDestroy(3); //store - close the store aEntry.SetComplete(ETrue); // Update the entry iMsvEntry->ChangeL(aEntry); iMsvEntry->SetEntryL(KMsvRootIndexEntryId); }
// --------------------------------------------------------- // MsgStoreHandler::HandleClass0SmsL() // --------------------------------------------------------- // void MsgStoreHandler::HandleClass0SmsL(CMsvEntry* aMsgEntry, TMsvId aMsgId) { CleanupStack::PushL(aMsgEntry); CMsvStore* store = aMsgEntry->ReadStoreL(); CleanupStack::PushL(store); CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL(); CleanupStack::PushL(paraFormatLayer); CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL(); CleanupStack::PushL(charFormatLayer); CRichText* richText = CRichText::NewL(paraFormatLayer, charFormatLayer); CleanupStack::PushL(richText); store->RestoreBodyTextL(*richText); TInt len = richText->DocumentLength(); HBufC* bufBody = HBufC::NewLC(len * 2); // Get Body content of SMS message TPtr bufBodyPtr = bufBody->Des(); richText->Extract(bufBodyPtr, 0, len); //convert bufbody to qstring.. QString body = XQConversions::s60DescToQString(*bufBody); Class0Info class0Info; class0Info.body = body; CleanupStack::PopAndDestroy(bufBody); // Get From address of SMS message CPlainText* nullString = CPlainText::NewL(); CleanupStack::PushL(nullString); CSmsHeader* smsheader = CSmsHeader::NewL(CSmsPDU::ESmsDeliver, *nullString); CleanupStack::PushL(smsheader); smsheader->RestoreL(*store); QString address = XQConversions::s60DescToQString(smsheader->FromAddress()); class0Info.address = address; // Get alias of SMS message QString alias; int count; MsgContactHandler::resolveContactDisplayName(address, alias, count); class0Info.alias = alias; // Get timestamp of SMS message QDateTime timeStamp; TTime time = aMsgEntry->Entry().iDate; TTime unixEpoch(KUnixEpoch); TTimeIntervalSeconds seconds; time.SecondsFrom(unixEpoch, seconds); timeStamp.setTime_t(seconds.Int()); const QString times = timeStamp.toString("dd/MM/yy hh:mm ap"); class0Info.time = times; class0Info.messageId = aMsgId; CleanupStack::PopAndDestroy(7); aMsgEntry = NULL; // Show the SMS message.. iNotifier->ShowClass0Message(class0Info); }