/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ void CFakeSMSSender::AppendMessageDataL(TMsvId aEntryId,const TDesC& aRecipient) { CMsvEntry* entry = iMsvSession->GetEntryL(aEntryId); CleanupStack::PushL(entry); CSmsClientMtm* MySmsMtm = static_cast<CSmsClientMtm*>(iMtmReg->NewMtmL(KUidMsgTypeSMS)); MySmsMtm->SetCurrentEntryL(entry); CleanupStack::Pop(); //entry entry = NULL; CleanupStack::PushL(MySmsMtm); MySmsMtm->RestoreServiceAndSettingsL(); CMsvStore* srore = MySmsMtm->Entry().EditStoreL(); CleanupStack::PushL(srore); if(srore) { MySmsMtm->SmsHeader().RestoreL(*srore); } CleanupStack::PopAndDestroy(srore); CSmsHeader& header = MySmsMtm->SmsHeader(); if (header.Message().ServiceCenterAddress().Length() == 0) { CSmsSettings* serviceSettings = &(MySmsMtm->ServiceSettings()); const TInt numSCAddresses = serviceSettings->ServiceCenterCount(); if (numSCAddresses) { TInt scIndex=0; scIndex = serviceSettings->DefaultServiceCenter(); if ((scIndex < 0) || (scIndex >= numSCAddresses)) { scIndex = 0; //??? } //get the service center number: TPtrC serviceCentreNumber = serviceSettings->GetServiceCenter(scIndex).Address(); //This can only be used on SMS-SUBMIT type messages. The message PDU //type can be checked by using the CSmsHeader::Type API. header.SetServiceCenterAddressL(serviceCentreNumber); } } MySmsMtm->SmsHeader().SetFromAddressL(aRecipient); MySmsMtm->SaveMessageL(); CleanupStack::PopAndDestroy(1);//MySmsMtm }
TBool CSMSSender::SetupSmsHeaderL() { if (iMtm) { // To handle the sms specifics we start using SmsMtm CSmsClientMtm* smsMtm = static_cast<CSmsClientMtm*>(iMtm); // smsMtm->RestoreServiceAndSettingsL(); // CSmsHeader encapsulates data specific for sms messages, // like service center number and options for sending. CSmsHeader& header = smsMtm->SmsHeader(); CSmsSettings& serviceSettings = smsMtm->ServiceSettings(); CSmsSettings* sendOptions = CSmsSettings::NewL(); CleanupStack::PushL(sendOptions); sendOptions->CopyL(serviceSettings); // restore existing settings sendOptions->SetCharacterSet(iCharSet); sendOptions->SetDelivery(ESmsDeliveryImmediately); // set to be delivered immediately if(iFlashSMS){ header.Message().SmsPDU().SetClass(ETrue,TSmsDataCodingScheme::ESmsClass0); } header.SetSmsSettingsL(*sendOptions); CleanupStack::PopAndDestroy(sendOptions); #ifdef __WINS__ #else // let's check if there's a service centre 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. const TInt numSCAddresses = serviceSettings.ServiceCenterCount(); if (numSCAddresses) { TInt scIndex=0; scIndex = serviceSettings.DefaultServiceCenter(); if ((scIndex < 0) || (scIndex >= numSCAddresses)) { scIndex = 0; //??? } //get the service center number: TPtrC serviceCentreNumber = serviceSettings.GetServiceCenter(scIndex).Address(); //This can only be used on SMS-SUBMIT type messages. The message PDU //type can be checked by using the CSmsHeader::Type API. header.SetServiceCenterAddressL(serviceCentreNumber); } else { // here there could be a dialog in which user can add sc number iObserver.HandleError(MMsvObserver::ENoServiceCentre); return EFalse; } } #endif return ETrue; } else { return EFalse; } }
// ----------------------------------------------------------------------------- // CMessageMonitorPlugin::HandleMsgMovedL // ----------------------------------------------------------------------------- // void CMessageMonitorPlugin::HandleMsgMovedL( const TMsvId aFolderId1, const TMsvId aFolderId2, const CMsvEntrySelection& aSelection ) { WRITELOG("ENTER CMessageMonitorPlugin::HandleMsgMovedL"); TInt count( aSelection.Count() ); // cycle through every message in the CMsvEntrySelection for ( TInt i=0; i < count; ++i ) { TMsvId msgId = aSelection[i]; WRITELOG1("msgId: %d", msgId ); TMsvId service = 0; TMsvEntry entry; TInt err = iMsvSession->GetEntry( msgId, service, entry ); // if we have a message and it has been moved from the outbox to the sent // items, and it is a valid message if ( ( !err ) && ( KUidMsvMessageEntry == entry.iType ) && ( KMsvSentEntryId == aFolderId1 ) && ( KMsvGlobalOutBoxIndexEntryId == aFolderId2 ) && ( IsValidMessageTypeL( entry, *iMsvSession ) ) ) { HBufC* uri = CreateUriL( entry.iMtm, msgId ); CleanupStack::PushL( uri ); CHarvesterData* hd = CHarvesterData::NewL( uri ); CleanupStack::Pop( uri ); hd->SetEventType( EHarvesterAdd ); hd->SetTakeSnapshot( EFalse ); hd->SetBinary( EFalse ); iMonitorPluginObserver->MonitorEvent( hd ); } #ifdef __WINSCW__ else if (!err && KMsvDraftEntryId == aFolderId2 && KMsvGlobalOutBoxIndexEntryId == aFolderId1 ) { if( entry.iMtm.iUid != KUidMsgTypeMultimedia.iUid ) { CClientMtmRegistry* clientMtmReg; clientMtmReg = CClientMtmRegistry::NewL(*iMsvSession); CleanupStack::PushL(clientMtmReg); CSmsClientMtm* smsMtm = static_cast<CSmsClientMtm*>(clientMtmReg->NewMtmL(KUidMsgTypeSMS)); CleanupStack::PushL(smsMtm); smsMtm->SwitchCurrentEntryL( msgId ); TMsvSelectionOrdering selection; selection.SetShowInvisibleEntries(ETrue); CMsvEntry* parentEntry = CMsvEntry::NewL( smsMtm->Session(), smsMtm->Entry().Entry().Parent(), selection ); CleanupStack::PushL(parentEntry); // Move the message TRAP_IGNORE( parentEntry->MoveL( msgId, KMsvSentEntryId ) ); CleanupStack::PopAndDestroy(3,clientMtmReg); // parentEntry } } #endif } WRITELOG("END CMessageMonitorPlugin::HandleMsgMovedL"); }