Пример #1
0
/* 
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
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
}
Пример #2
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
}
/**
  Function : ExecuteActionL
  Description : Entry point for the this test action in the test framework
  @internalTechnology
  @param : none
  @return : void
  @pre none 
  @post none
*/
void CMtfTestActionCompareLastSegmentReport::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCompareLastSegmentReport);
	CSmsSettings* smsSettingsOrg = ObtainParameterReferenceL<CSmsSettings>(TestCase(),ActionParameters().Parameter(0) );
	CSmsSettings* smsSettingsRef = ObtainParameterReferenceL<CSmsSettings>(TestCase(),ActionParameters().Parameter(1) );

	if(	smsSettingsOrg->LastSegmentDeliveryReport() !=	smsSettingsRef->LastSegmentDeliveryReport())
		{
		// failed
		TestCase().ERR_PRINTF1(_L("SMS Settings for the last segment report request do not match !"));
		TestCase().SetTestStepResult(EFail);
		}
	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCompareLastSegmentReport);
	TestCase().ActionCompletedL(*this);
	}
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 CMtfTestActionUtilsSmsScripts::ReadSmsSettingsFromConfigurationFileL(CMtfTestCase& aTestCase, const TDesC& aSettingsFile, CSmsSettings& aSmsSettings)
	{
	CMtfTestActionUtilsConfigFileParser* scriptFileParser = CMtfTestActionUtilsConfigFileParser::NewL(aSettingsFile);
	CleanupStack::PushL(scriptFileParser);

	TPtrC stringPtr;
	TInt intValue;

	// Service Centre
	if(scriptFileParser->GetFieldAsString(KScriptItemSC, stringPtr) == KErrNone)
		{
		// get the addresses from the config file
		TLex detailsToParse(stringPtr);
		TPtrC scName;
		TPtrC scNumber;
		
		detailsToParse.SkipSpaceAndMark();
		while(!detailsToParse.Eos())
			{
			scName.Set(_L("Unknown")); // default SC name
			
			while(detailsToParse.Peek() != ';' && !detailsToParse.Eos()) // SCs' details separated by semi-colon
				{
				if(detailsToParse.Peek() == ',')  // name and number separated by comma
					{ // has a name specified
					scName.Set(detailsToParse.MarkedToken());
					detailsToParse.Inc();
					detailsToParse.SkipSpaceAndMark();
					}
				else
					detailsToParse.Inc();
				}
			
			scNumber.Set(detailsToParse.MarkedToken());
			
			// add the address to the SCs list
		
			aSmsSettings.AddServiceCenterL(scName, scNumber);
		
		
			detailsToParse.Inc();
			detailsToParse.SkipSpaceAndMark();
			}
		}
	
	// Default Service Centre
	if(scriptFileParser->GetFieldAsInteger(KScriptItemDefaultSC, intValue) == KErrNone)
		{
	
		aSmsSettings.SetDefaultServiceCenter(intValue);
	
		}
		
	// Bearer
	if(scriptFileParser->GetFieldAsString(KScriptItemBearer, stringPtr) == KErrNone)
		{
		CSmsSettings::TMobileSmsBearer smsBearer = ObtainValueParameterL<CSmsSettings::TMobileSmsBearer>(aTestCase, stringPtr);
		aSmsSettings.SetSmsBearer(smsBearer);
		}

	// Encoding
	if(scriptFileParser->GetFieldAsString(KScriptItemEncoding, stringPtr) == KErrNone)
		{
		TSmsDataCodingScheme::TSmsAlphabet characterSet = ObtainValueParameterL<TSmsDataCodingScheme::TSmsAlphabet>(aTestCase, stringPtr);
		aSmsSettings.SetCharacterSet(characterSet);
		}
		
	// Delivery Report
	if(scriptFileParser->GetFieldAsString(KScriptItemDeliveryReport, stringPtr) == KErrNone)
		{
		if (stringPtr.CompareF(_L("NO")) == 0)
			{
			aSmsSettings.SetDeliveryReport(EFalse);
			}
		else if (stringPtr.CompareF(_L("YES")) == 0)
			{
			aSmsSettings.SetDeliveryReport(ETrue);
			}
		}
		
	// Reply quoted
	if(scriptFileParser->GetFieldAsString(KScriptItemReplyQuoted, stringPtr) == KErrNone)
		{
		if (stringPtr.CompareF(_L("NO")) == 0)
			{
			aSmsSettings.SetReplyQuoted(EFalse);
			}
		else if (stringPtr.CompareF(_L("YES")) == 0)
			{
			aSmsSettings.SetReplyQuoted(ETrue);
			}
		}
	
	// Description length
	if(scriptFileParser->GetFieldAsInteger(KScriptItemDescriptionLength, intValue) == KErrNone)
		{
		aSmsSettings.SetDescriptionLength(intValue);
		}
		
		
	// Can Concatenate
	if(scriptFileParser->GetFieldAsString(KScriptItemCanConcatenate, stringPtr) == KErrNone)
		{
		if (stringPtr.CompareF(_L("NO")) == 0)
			{
			aSmsSettings.SetCanConcatenate(EFalse);
			}
		else if (stringPtr.CompareF(_L("YES")) == 0)
			{
			aSmsSettings.SetCanConcatenate(ETrue);
			}
		}
	
	// Reply path
	if(scriptFileParser->GetFieldAsString(KScriptItemReplyPath, stringPtr) == KErrNone)
		{
		if (stringPtr.CompareF(_L("NO")) == 0)
			{
			aSmsSettings.SetReplyPath(EFalse);
			}
		else if (stringPtr.CompareF(_L("YES")) == 0)
			{
			aSmsSettings.SetReplyPath(ETrue);
			}
		}
		
	// Reject duplicate
	if(scriptFileParser->GetFieldAsString(KScriptItemRejectDuplicate, stringPtr) == KErrNone)
		{
		if (stringPtr.CompareF(_L("NO")) == 0)
			{
			aSmsSettings.SetRejectDuplicate(EFalse);
			}
		else if (stringPtr.CompareF(_L("YES")) == 0)
			{
			aSmsSettings.SetRejectDuplicate(ETrue);
			}
		}
		
	// Validity period, value is read in minutes
	if(scriptFileParser->GetFieldAsInteger(KScriptItemValidityPeriod, intValue) == KErrNone)
		{
		aSmsSettings.SetValidityPeriod(TTimeIntervalMinutes(intValue));
		}
		
	// Delivery
	if(scriptFileParser->GetFieldAsString(KScriptItemDelivery, stringPtr) == KErrNone)
		{
		TSmsDelivery delivery = ObtainValueParameterL<TSmsDelivery>(aTestCase, stringPtr);
		aSmsSettings.SetDelivery(delivery);
		}
	
	// Status Report Handling
	if(scriptFileParser->GetFieldAsString(KScriptItemStatusReportHandling, stringPtr) == KErrNone)
		{
		CSmsSettings::TSmsReportHandling statusReportHandling = ObtainValueParameterL<CSmsSettings::TSmsReportHandling>(aTestCase, stringPtr);
		aSmsSettings.SetStatusReportHandling(statusReportHandling);
		}

	// Special Message Handling
	if(scriptFileParser->GetFieldAsString(KScriptItemSpecialMessageHandling, stringPtr) == KErrNone)
		{
		CSmsSettings::TSmsReportHandling specialMessageHandling = ObtainValueParameterL<CSmsSettings::TSmsReportHandling>(aTestCase, stringPtr);
		aSmsSettings.SetSpecialMessageHandling(specialMessageHandling);
		}

	// Commdb action
	if(scriptFileParser->GetFieldAsString(KScriptItemSmsCommdbAction, stringPtr) == KErrNone)
		{
		CSmsSettings::TSmsSettingsCommDbAction commdbAction = ObtainValueParameterL<CSmsSettings::TSmsSettingsCommDbAction>(aTestCase, stringPtr);
		aSmsSettings.SetCommDbAction(commdbAction);
		}
		
	// Sms Bearer Action
	if(scriptFileParser->GetFieldAsString(KScriptItemSmsBearerAction, stringPtr) == KErrNone)
		{
		CSmsSettings::TSmsSettingsCommDbAction smsBearerAction = ObtainValueParameterL<CSmsSettings::TSmsSettingsCommDbAction>(aTestCase, stringPtr);
		aSmsSettings.SetSmsBearerAction(smsBearerAction);
		}

	// Message Conversion
	if(scriptFileParser->GetFieldAsString(KScriptItemSmsMessageConversion, stringPtr) == KErrNone)
		{
		TSmsPIDConversion messageConversion = ObtainValueParameterL<TSmsPIDConversion>(aTestCase, stringPtr);
		aSmsSettings.SetMessageConversion(messageConversion);
		}
	
	// Vailidity Period Format
	if(scriptFileParser->GetFieldAsString(KScriptItemSmsValidityPeriodFormat, stringPtr) == KErrNone)
		{
		TSmsFirstOctet::TSmsValidityPeriodFormat valPeriodFormat = ObtainValueParameterL<TSmsFirstOctet::TSmsValidityPeriodFormat>(aTestCase, stringPtr);
		aSmsSettings.SetValidityPeriodFormat(valPeriodFormat);
		}
	
	// Class2 Folder
	if(scriptFileParser->GetFieldAsString(KScriptItemClass2Folder, stringPtr) == KErrNone)
		{
		// Try to find a folder with that name
		MDummySessionObserver obser;
		CMsvSession* session = CMsvSession::OpenSyncL(obser);
		CleanupStack::PushL(session);
		
		CMsvEntry* entry = CMsvEntry::NewL(*session, KMsvLocalServiceIndexEntryId, TMsvSelectionOrdering(KMsvGroupByStandardFolders||KMsvGroupByType,EMsvSortByNone));
		CleanupStack::PushL(entry);
		entry->SetEntryL(KMsvLocalServiceIndexEntryId); // Search only the local folders

		TMsvSelectionOrdering order;
		order.SetShowInvisibleEntries(ETrue);
		entry->SetSortTypeL(order);

		CMsvEntrySelection* selection = entry->ChildrenL();
		CleanupStack::PushL(selection);

		TBool found = EFalse;
		TInt count = selection->Count();
		for (TInt i=0; i<count; i++) 
			{	
			entry->SetEntryL((*selection)[i]);
			if ((stringPtr.CompareF(entry->Entry().iDescription) == 0) ||
			    (stringPtr.CompareF(entry->Entry().iDetails) == 0))
				{
				found = ETrue;
				break;
				}
			}

		TMsvId entryId = KMsvGlobalInBoxIndexEntryId;
		if (found)
			entryId = entry->Entry().Id();
		else
			User::Leave(KErrNotFound);

		aSmsSettings.SetClass2Folder(entryId); 
		
		CleanupStack::PopAndDestroy(3, session); // selection, entry, session
		}

	//Last Segment Delivery Report
	if(scriptFileParser->GetFieldAsString(KLastSegmentDeliveryReport, stringPtr) == KErrNone)
		{
		if (stringPtr.CompareF(_L("NO")) == 0)
			{
			aSmsSettings.SetLastSegmentDeliveryReport(EFalse);
			}
		else if (stringPtr.CompareF(_L("YES")) == 0)
			{
			aSmsSettings.SetLastSegmentDeliveryReport(ETrue);
			}
		}
	
	CleanupStack::PopAndDestroy(scriptFileParser);
	}
Пример #6
0
void CSMSSender::CreateSMSMessageL(const TDesC& aText, const TDesC& aAddress)
/**
	Prepare SMS specific objects ready to send via ESOCK
	@param aText buffer containing ascii contents of message to send
	@param aAddress buffer with telephone number of SMS receiver 
*/
	{
#ifndef __WINS__
	TSmsAddr smsAddr;
    smsAddr.SetSmsAddrFamily(ESmsAddrSendOnly);
    smsAddr.SetPort(smsAddr.Port() + 1);//ycf
    __LOGSTR_TOFILE("sockent bind");
	iSocket.Bind(smsAddr);

	CSmsBuffer* smsBuffer = CSmsBuffer::NewL();
	//CleanupStack::PushL(smsBuffer) is NOT used because CSmsMessage takes ownership of our buffer :-)
	CSmsMessage* smsMsg = CSmsMessage::NewL(iFs, CSmsPDU::ESmsSubmit, smsBuffer);
	CleanupStack::PushL(smsMsg);
	
	TSmsUserDataSettings smsSettings;
    smsSettings.SetAlphabet(TSmsDataCodingScheme::ESmsAlphabetUCS2);
	smsSettings.SetTextCompressed(EFalse);
	smsMsg->SetUserDataSettingsL(smsSettings);
	
	TBuf<KMaxAddressSize> toAddress;
	toAddress.Copy(aAddress);
	smsMsg->SetToFromAddressL(toAddress);

	//Get service centre address.
	// The method used here assumes the SMS settings are provisioned, which is true in known cases.
	// There are alternative partner-only APIs, however this allow this source to be kept public
	#ifdef EKA2
		CSmsSettings* smsSCSettings = CSmsSettings::NewL();
		CleanupStack::PushL(smsSCSettings);
    	CSmsAccount* smsAccount=CSmsAccount::NewLC();
    	smsAccount->LoadSettingsL(*smsSCSettings);
 		// index of the default service centre address for this service
 		TInt defIndex;
		User::LeaveIfError(defIndex = smsSCSettings->DefaultServiceCenter());
 		// Get the service center address
		CSmsServiceCenter&  scAddr = smsSCSettings->GetServiceCenter(defIndex);
	
		TPtrC theAddress=scAddr.Address();
		HBufC* serviceCentreAddress=HBufC::NewLC(theAddress.Length());
		*serviceCentreAddress=theAddress;
		smsMsg->SmsPDU().SetServiceCenterAddressL(*serviceCentreAddress);
		CleanupStack::PopAndDestroy(serviceCentreAddress);//
		CleanupStack::PopAndDestroy(smsAccount);
		CleanupStack::PopAndDestroy(smsSCSettings);	
				
	#else
		TMsvId		serviceId;
		CObserver* pObserver = new (ELeave) CObserver();
		CleanupStack::PushL(pObserver);
		CMsvSession* pSession = CMsvSession::OpenSyncL(*pObserver);
		CleanupStack::PushL(pSession);
		TSmsUtilities::ServiceIdL(*pSession, serviceId, KUidMsgTypeSMS);
		CMsvEntry* service = pSession->GetEntryL(serviceId);
		CleanupStack::PushL(service);
		CMsvStore* msvstore = service->ReadStoreL();
		CleanupStack::PushL(msvstore);
		CSmsSettings* smsSCSettings = CSmsSettings::NewL();
		CleanupStack::PushL(smsSCSettings);
		smsSCSettings->RestoreL(*msvstore);
		TInt defIndex;
		User::LeaveIfError(defIndex = smsSCSettings->DefaultSC());
		defIndex = smsSCSettings->DefaultSC();
 		// Get the default service center address
		CSmsNumber&  scAddr = smsSCSettings->SCAddress(defIndex);
		TPtrC theAddress=scAddr.Address();
		HBufC* serviceCentreAddress=HBufC::NewLC(theAddress.Length());
		*serviceCentreAddress=theAddress;
		smsMsg->SmsPDU().SetServiceCenterAddressL(*serviceCentreAddress);
		CleanupStack::PopAndDestroy(serviceCentreAddress);//
		CleanupStack::PopAndDestroy(smsSCSettings); //smsSettings
		CleanupStack::PopAndDestroy(msvstore);
		CleanupStack::PopAndDestroy(service);
		CleanupStack::PopAndDestroy(pSession);
		CleanupStack::PopAndDestroy(pObserver);		
	#endif
	
	//convert to wide
	HBufC* payload = HBufC::NewL(aText.Length());
	CleanupStack::PushL(payload);
	TPtr pPayload=payload->Des();
	pPayload.Copy(aText); //copy from narrow to wide and convert
	smsBuffer->InsertL(0, pPayload); //copies payload
	RSmsSocketWriteStream writeStream(iSocket);
	CleanupClosePushL(writeStream);
	writeStream << *smsMsg; // remember << operator _CAN_ leave
	__LOGSTR_TOFILE("write stream commit");
	writeStream.CommitL();
	CleanupStack::PopAndDestroy(&writeStream);
	CleanupStack::PopAndDestroy(2);//smsMsg, payload	
#endif
	}
Пример #7
0
/**
Create SMS settings from the file

@param aFileName	Name of file from which the settings need to be loaded
@internalTechnology
*/
void CentralRepoUtils::SetSmsServiceSettingsL(TDesC& aFileName)
	{
	CSmsSettings* smsSettings = CSmsSettings::NewL();
	CleanupStack::PushL(smsSettings);

	CSmsAccount* account = CSmsAccount::NewLC();
	account->InitialiseDefaultSettingsL(*smsSettings);

	// now override the settings with the config file contents
	CSmsScriptUtils::ReadSmsSettingsFromConfigurationFileL(aFileName, *smsSettings);
	
	//Set these settings which will keep the PDU VP bits for the msg constant...
	smsSettings->SetValidityPeriod(ESmsVPWeek);	// week
	smsSettings->SetValidityPeriodFormat(TSmsFirstOctet::ESmsVPFInteger); //relative
	smsSettings->SetReplyQuoted(EFalse);
	smsSettings->SetRejectDuplicate(ETrue);
	smsSettings->SetDelivery(ESmsDeliveryImmediately);
	smsSettings->SetDeliveryReport(ETrue);
	smsSettings->SetReplyPath(EFalse);
	smsSettings->SetMessageConversion(ESmsConvPIDNone);
	smsSettings->SetCanConcatenate(ETrue);
	smsSettings->SetDeliveryReport(ETrue);
	smsSettings->SetStatusReportHandling(CSmsSettings::EMoveReportToInboxVisibleAndMatch);

	account->SaveSettingsL(*smsSettings);
	CleanupStack::PopAndDestroy(2, smsSettings); // account smsSettings		
	}
Пример #8
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;
    }
}
Пример #9
0
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;
}