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(); }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ void CSMSSender::CreateNewMessageL() { Cancel(); iMessageMade = iMessageSent = iMessageReceived = EFalse; delete iMtm; iMtm = NULL; TMsvEntry newEntry; // This represents an entry in the Message Server index newEntry.iMtm = KUidMsgTypeSMS; // message type is SMS newEntry.iType = KUidMsvMessageEntry; // this defines the type of the entry: message newEntry.iServiceId = KMsvLocalServiceIndexEntryId; // ID of local service (containing the standard folders) newEntry.iDate.UniversalTime(); // set the date of the entry to home time newEntry.SetInPreparation(ETrue); // a flag that this message is in preparation newEntry.SetReadOnly(EFalse); // - CMsvEntry accesses and acts upon a particular Message Server entry. // - NewL() does not create a new entry, but simply a new object to access an existing entry. // - It takes in as parameters the client's message server session, // ID of the entry to access and initial sorting order of the children of the entry. CMsvEntry* entry = CMsvEntry::NewL(*iSession, KMsvDraftEntryIdValue, TMsvSelectionOrdering()); CleanupStack::PushL(entry); delete iOperation; iOperation = NULL; iOperation = entry->CreateL(newEntry, iStatus); CleanupStack::PopAndDestroy(entry); iPhase = EWaitingForCreate; SetActive(); }
TMsvId CFakeSMSSender::CreateNewMessageL(TTime aMsgTime) { CMsvEntry* Draftentry = CMsvEntry::NewL(*iMsvSession, KMsvDraftEntryIdValue ,TMsvSelectionOrdering()); CleanupStack::PushL(Draftentry); CMsvOperationWait* wait = CMsvOperationWait::NewLC(); wait->Start(); TMsvEntry newEntry; // This represents an entry in the Message Server index newEntry.iMtm = KUidMsgTypeSMS; // message type is SMS newEntry.iType = KUidMsvMessageEntry; //KUidMsvServiceEntry // this defines the type of the entry: message newEntry.iServiceId = KMsvLocalServiceIndexEntryId; // // ID of local service (containing the standard folders) newEntry.iDate = aMsgTime; // set the date of the entry to home time newEntry.SetInPreparation(ETrue); // a flag that this message is in preparation newEntry.SetReadOnly(EFalse); CMsvOperation* oper = Draftentry->CreateL(newEntry,wait->iStatus); CleanupStack::PushL(oper); CActiveScheduler::Start(); while( wait->iStatus.Int() == KRequestPending ) { CActiveScheduler::Start(); } // ...and keep track of the progress of the create operation. TMsvLocalOperationProgress progress = McliUtils::GetLocalProgressL(*oper); User::LeaveIfError(progress.iError); // Draftentry->MoveL(progress.iId,KMsvGlobalInBoxIndexEntryId); CleanupStack::PopAndDestroy(3);//Draftentry,wait,oper return progress.iId; }
// ----------------------------------------------------------------------------- // 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); }
// ----------------------------------------------------------------------------- // 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" ) ); }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ void CSMSSender::PopulateMessageL(TMsvEntry& aMsvEntry,TDes& aDescription,TDes& aDetails) { ASSERT(iMtm); // We get the message body from Mtm and insert a bodytext CRichText& mtmBody = iMtm->Body(); mtmBody.Reset(); mtmBody.InsertL(0, iMessage); // insert our msg tag as the body text if(iDescription) { if(iDescription->Des().Length() > 30) aDescription.Copy(iDescription->Des().Left(30)); else aDescription.Copy(iDescription->Des()); } else { if(iMessage.Length() > 30) aDescription.Copy(iMessage.Left(30)); else aDescription.Copy(iMessage); } if(iDetails) { if(iDetails->Des().Length() > 30) aDetails.Copy(iDetails->Des().Left(30)); else aDetails.Copy(iDetails->Des()); } else { if(iRecipients.Length() > 30) aDetails.Copy(iRecipients.Left(30)); else aDetails.Copy(iRecipients); } aMsvEntry.SetInPreparation(EFalse); aMsvEntry.SetScheduled(EFalse); aMsvEntry.iDate.UniversalTime(); aMsvEntry.SetSendingState(KMsvSendStateWaiting); }
// ----------------------------------------------------------------------------- // 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(); }
void CSmsFile::send_messageL(const TDesC& recipient, const TDesC& body) { if (iStatus==KRequestPending) { User::Leave(KErrServerBusy); } state=_L("send_messageL"); TMsvEntry newEntry; // This represents an entry in the Message Server index newEntry.iMtm = KUidMsgTypeSMS; // message type is CSmsFile newEntry.iType = KUidMsvMessageEntry; // this defines the type of the entry: message newEntry.iServiceId = KMsvLocalServiceIndexEntryId; // ID of local service (containing the standard folders) newEntry.iDate.HomeTime(); // set the date of the entry to home time newEntry.SetInPreparation(ETrue); // a flag that this message is in preparation // get ref to outbox state=_L("NewL"); CMsvEntry *entry =CMsvEntry::NewL(*iSession, KMsvGlobalOutBoxIndexEntryId ,TMsvSelectionOrdering()); CleanupStack::PushL(entry); // create message in outbox state=_L("CreateL"); entry->CreateL(newEntry); state=_L("GetEntry"); entry = iSession->GetEntryL(newEntry.Id()); // SetCurrentEntryL takes ownership of the CMsvEntry state=_L("SetCurrentEntry"); iMtm->SetCurrentEntryL(entry); CleanupStack::Pop(); // entry state=_L("Entry()"); TMsvEntry msvEntry = (iMtm->Entry()).Entry(); state=_L("Body()"); CRichText& mtmBody = iMtm->Body(); mtmBody.Reset(); state=_L("set message"); mtmBody.InsertL(0, body); // insert our msg tag as the body text // set iRecipient into the Details of the entry msvEntry.iDetails.Set(recipient); // set recipient info in details msvEntry.SetInPreparation(EFalse); // set inPreparation to false msvEntry.SetSendingState(KMsvSendStateWaiting); // set the sending state (immediately) msvEntry.iDate.HomeTime(); // set time to Home Time // To handle the CSmsFile specifics we start using SmsMtm CSmsClientMtm* smsMtm = STATIC_CAST(CSmsClientMtm*, iMtm); state=_L("RestoreServiceAndSettingsL"); smsMtm->RestoreServiceAndSettingsL(); state=_L("set header"); // CSmsHeader encapsulates data specific for CSmsFile messages, // like service center number and options for sending. CSmsHeader& header = smsMtm->SmsHeader(); state=_L("get options"); if (!sendOptions) { sendOptions = CSmsSettings::NewL(); sendOptions->CopyL(smsMtm->ServiceSettings()); // restore existing settings state=_L("SetDelivery"); sendOptions->SetDelivery(ESmsDeliveryImmediately); // set to be delivered immediately } // set send options // ERROR HERE! state=_L("SetSmsSettingsL"); header.SetSmsSettingsL(*sendOptions); state=_L("check sc"); // let's check if there's sc address if (header.Message().ServiceCenterAddress().Length() == 0) { // no, there isn't. We assume there is at least one sc number set and use // the default SC number. CSmsSettings* serviceSettings = &(smsMtm->ServiceSettings()); // if number of scaddresses in the list is null if (!serviceSettings->NumSCAddresses()) { // FIXME: what to do? User::Leave(1); } else { // set sc address to default. CSmsNumber* sc = 0; sc = &(serviceSettings->SCAddress(serviceSettings->DefaultSC())); header.Message().SetServiceCenterAddressL(sc->Address()); } } state=_L("add addresses"); // Add our recipient to the list, takes in two TDesCs, first is real address and second is an alias // works also without the alias parameter. smsMtm->AddAddresseeL(recipient, msvEntry.iDetails); // if message is to be deleted after sending, mark with our UID msvEntry.iMtmData3 = KUidRippleVaultApp.iUid; state=_L("save"); // save message iMtm->Entry().ChangeL(msvEntry); // make sure that we are handling the right entry smsMtm->SaveMessageL(); // closes the message state=_L("move"); // This moves the message entry to outbox, we'll schedule it for sending after this. // TMsvId movedId = MoveMessageEntryL( KMsvGlobalOutBoxIndexEntryId ); // move message to outbox TMsvId movedId = iMtm->Entry().Entry().Id(); // We must create an entry selection for message copies (although now we only have one message in selection) CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection; CleanupStack::PushL(selection); selection->AppendL(movedId); // add our message to the selection TBuf8<1> dummyParams; // CCommandAbsorbingControl::NewLC(); state=_L("InvokeAsyncFunctionL"); // invoking async schedule copy command on our mtm op=iMtm->InvokeAsyncFunctionL( ESmsMtmCommandScheduleCopy, *selection, dummyParams, iStatus); CleanupStack::Pop(); // selection #ifdef __LOGME__ iAppUi.LogText.Copy(_L("SENT\n")); iAppUi.WriteLogFile(iAppUi.LogText); #endif SetActive(); //return KErrNone; }