Пример #1
0
/* 
-----------------------------------------------------------------------------

-----------------------------------------------------------------------------
*/
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
}
Пример #2
0
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;
    }
}