Exemplo n.º 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
}
Exemplo n.º 2
0
/**
Returns a boolean value indicating where this SMS message will be stored.
If it rerurns EFalse, message will be stored in normal re-assembly store,
otherwise it will be stored in class 0 re-assembly store.

@internalComponent
*/
TBool CFacadeSmsReassemblyStore::IsForClass0ReassemblyStore(const CSmsMessage& aSmsMessage)
	{
	if (iClass0ReassemblyStore == NULL)
		{
		return EFalse;
		}

	TSmsDataCodingScheme::TSmsClass  msgClass;

	if (aSmsMessage.SmsPDU().DataCodingSchemePresent()	&&	aSmsMessage.SmsPDU().Class(msgClass))
		{
		if (msgClass == TSmsDataCodingScheme::ESmsClass0)
			{
			//Check also whether it is a WAP Datagram
			// In that case return EFalse otherwise ETrue (REQ7012)
			if (!IsWapSMS(aSmsMessage))
				{
				return ETrue;
				}
			}
		}
	return EFalse;
	}
Exemplo n.º 3
0
/**
 *  Decodes SMS-SUBMIT-REPORT PDU and checks if it is SMS-SUBMIT-REPORT for
 *  RP-ERROR.
 *
 *  @leave Leaves if CSmsBuffer::NewL or CSmsMessage::NewL leaves.
 *
 */
void CSmsMessageSend::DecodeSubmitReportL()
{
    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGESEND_DECODESUBMITREPORTL_1, "CSmsMessageSend::DecodeSubmitReportL()");

    //
    // Only try to decode the submit report if error is a RP-error, in which case there should be a valid PDU
    //
    if (IsRPError())
    {
        TGsmSms sms;
        sms.SetPdu(iMobileSmsSendAttributesV1.iSubmitReport);
        CSmsBuffer* buffer=CSmsBuffer::NewL();

        // try to create a sms message from the submit report PDU (smsMessage takes ownership of the buffer)
        CSmsMessage*  smsMessage = CSmsMessage::NewL(iSegmentationStore.FileSession(),
                                   sms,buffer,IsRPError(),ETrue);
        CleanupStack::PushL(smsMessage);

        if (smsMessage->SmsPDU().Type() == CSmsPDU::ESmsSubmitReport)
        {
            CSmsSubmitReport&  submitReport =(CSmsSubmitReport&) smsMessage->SmsPDU();
            TInt  failureCause = submitReport.FailureCause();

            if (failureCause != TSmsFailureCause::ESmsErrorFree)
            {
                iStatus = FailureCauseToError(failureCause);
            }
        }
        else
        {
            OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGESEND_DECODESUBMITREPORTL_2, "Invalid PDU Type = %d with iStatus = %d",  smsMessage->SmsPDU().Type(),  iStatus.Int()  );
        }

        CleanupStack::PopAndDestroy(smsMessage);
    }
} // CSmsMessageSend::DecodeSubmitReportL
Exemplo n.º 4
0
void CBaseSmsActiveSocketWatcher::ReplaceTypeMessageL(CMsvEntry& aEntry, CSmsMessage& aMessage, TBool& aRetainOriginalMessage)
	{
    if (aMessage.Type() == CSmsPDU::ESmsDeliver)
        {
        TUint8 pid(0);
        const CSmsPDU& sms = aMessage.SmsPDU();
        const CSmsDeliver& smsTemp = STATIC_CAST(const CSmsDeliver&,sms);
        pid = (TUint8)*smsTemp.ProtocolIdentifier();

        if ((pid & TSmsProtocolIdentifier::ESmsPIDTypeMask) == TSmsProtocolIdentifier::ESmsPIDShortMessageType)
            {
            if ( ((pid & TSmsProtocolIdentifier::ESmsShortMessageTypeMask) <= TSmsProtocolIdentifier::ESmsReplaceShortMessageType7)
                || ((pid & TSmsProtocolIdentifier::ESmsShortMessageTypeMask) == TSmsProtocolIdentifier::ESmsReturnCallMesage) )
                {
                DeleteReplaceTypeMessagesL(aEntry, pid, aMessage, aRetainOriginalMessage);
                }
            }
        }   // Type()
Exemplo n.º 5
0
void CWapDgrmTestStep::_Print(CSmsMessage& aSms)
/**
 *  print a SMS message to the console
 */
{
	TSmsUserDataSettings UserDataSettings;
	TBool                IsComplete = EFalse;
	const TPtrC&         Address = aSms.ToFromAddress();
	TInt                 ToPort = 0;
	TInt                 FromPort = 0;
	TInt                 Is16BitPorts = 0;
	TBool                IsPorts = EFalse;
	TSmsDataCodingScheme::TSmsAlphabet Alphabet;

	// Print CSmsMessage settings
	CSmsPDU& Pdu = aSms.SmsPDU();

	IsComplete = aSms.IsComplete();
	aSms.UserDataSettings(UserDataSettings);
	Alphabet = UserDataSettings.Alphabet();

	_Print(_L8("CSmsMessage:: IsComplete: ToFromAddress: Alphabet\n"));
	_PrintBool(IsComplete);
	_Print(_L8(": "));
	_Print(Address);
	_Print(_L8(": "));
	_Print(Alphabet);
	_Print(_L8("\n"));

	IsPorts = Pdu.ApplicationPortAddressing(ToPort,FromPort,&Is16BitPorts);
	_Print(_L8("IsPorts: FromPort: ToPort: Is16BitPorts\n"));
	_PrintBool(IsPorts);
	_Print(_L8(": "));
	_Print(FromPort);
	_Print(_L8(": "));
	_Print(ToPort);
	_Print(_L8(": "));
	_PrintBool(Is16BitPorts);
	_Print(_L8("\n"));
}
Exemplo n.º 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
	}
Exemplo n.º 7
0
void CSmsEventLogger::SetDataL(const CSmsMessage& aSmsMessage,TInt* aStatusId, const TTime* aDischargeTime)
	{

	__ASSERT_DEBUG(iSmsPDUData.iType==aSmsMessage.Type(),SmsuPanic(ESmsuUnexpectedSmsPDUType));
	TBuf<KLogMaxStatusLength> status;
#ifdef _DEBUG
	if (aStatusId!=NULL)
		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_SETDATAL_1, "CSmsEventLogger::SetDataL StatusID = %d", *aStatusId);
#endif
	if (aStatusId==NULL)
		{
		CSmsPDU::TSmsPDUType type=aSmsMessage.Type();
		switch (type)
			{
			//  Incoming SMS
			case CSmsPDU::ESmsDeliver:
				{
				if (iSmsPDUData.iTotal==iSmsPDUData.iReceived)
					{
					OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_SETDATAL_2, "SetDataL ESmsDeliver R_LOG_DEL_DONE");
					GetStringL(status,R_LOG_DEL_DONE);
					}
				else if (iSmsPDUData.iTotal>iSmsPDUData.iReceived)
					{
					OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_SETDATAL_3, "SetDataL ESmsDeliver R_LOG_DEL_PENDING");
					GetStringL(status,R_LOG_DEL_PENDING);
					}
				break;
				}
			case CSmsPDU::ESmsStatusReport:
				{
				if (iSmsPDUData.iTotal==iSmsPDUData.iReceived)
					{
					OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_SETDATAL_4, "SetDataL ESmsStatusReport R_LOG_DEL_DONE");
					GetStringL(status,R_LOG_DEL_DONE);
					}
				else if (iSmsPDUData.iTotal>iSmsPDUData.iReceived)
					{
					OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_SETDATAL_5, "SetDataL ESmsStatusReport R_LOG_DEL_PENDING");
					GetStringL(status,R_LOG_DEL_PENDING);
					}
				break;
				}
			//  Outgoing SMS
			case CSmsPDU::ESmsSubmit:
			case CSmsPDU::ESmsCommand:
				{
				TBool statusreportrequest=EFalse;
				if (type==CSmsPDU::ESmsSubmit)
					{
					CSmsSubmit& submit=(CSmsSubmit&) aSmsMessage.SmsPDU();
					statusreportrequest=submit.StatusReportRequest();
					}
				else
					{
					CSmsCommand& command=(CSmsCommand&) aSmsMessage.SmsPDU();
					statusreportrequest=command.StatusReportRequest();
					}
				if (statusreportrequest)
					{
					if (iSmsPDUData.iSent==0)
						{
						// None sent yet
						GetStringL(status,R_LOG_DEL_NOT_SENT);
						OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_SETDATAL_6, "SetDataL ESmsSubmit R_LOG_DEL_NOT_SENT SR");
						}
					else if (iSmsPDUData.iTotal==iSmsPDUData.iDelivered)
						{
						// All have been delivered
						OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_SETDATAL_7, "SetDataL ESmsSubmit R_LOG_DEL_DONE SR iSmsPDUData.iDelivered=%d", iSmsPDUData.iDelivered);
						GetStringL(status,R_LOG_DEL_DONE);
						}
					else if (iSmsPDUData.iSent<=iSmsPDUData.iTotal && iSmsPDUData.iFailed==0)
						{
						// One or more sent but not all, no failures
						OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_SETDATAL_8, "SetDataL ESmsSubmit R_LOG_DEL_PENDING SR iSmsPDUData.iSent==%d, iSmsPDUData.iTotal==%d, iFailed==0", iSmsPDUData.iSent, iSmsPDUData.iTotal);
						GetStringL(status,R_LOG_DEL_PENDING);
						}
					else
						{
						// One or more failures or corruption of iSmsPDUData values
						OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_SETDATAL_9, "SetDataL ESmsSubmit R_LOG_DEL_FAILED SR");
                        OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_SETDATAL_10, "   Total:  %d, Sent: %d",iSmsPDUData.iTotal, iSmsPDUData.iSent );
                        OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_SETDATAL_11, "   Failed: %d, Delivered: %d",iSmsPDUData.iFailed, iSmsPDUData.iDelivered );
                        GetStringL(status,R_LOG_DEL_FAILED);
                        }
                    if (aDischargeTime != NULL)
                        {
                        iLogEvent->SetTime(*aDischargeTime);
                        }                   
                    }
                else
                    {
                    if (iSmsPDUData.iSent<iSmsPDUData.iTotal)
                        {
                        // IF not all PDUs sent, state is "NOT SENT".
                        OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_SETDATAL_12, "SetDataL ESmsSubmit R_LOG_DEL_NOT_SENT NOSR");
                        OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_SETDATAL_13, "   Total:  %d, Sent: %d", iSmsPDUData.iTotal, iSmsPDUData.iSent );
                        GetStringL(status,R_LOG_DEL_NOT_SENT);
                        }
					else if (iSmsPDUData.iTotal==iSmsPDUData.iSent)
						{
						// All sent
						OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_SETDATAL_14, "SetDataL ESmsSubmit R_LOG_DEL_SENT NOSR");
						GetStringL(status,R_LOG_DEL_SENT);
						}
					else
						{
						// The iSmsPDUData values have become corrupt
						OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_SETDATAL_15, "SetDataL ESmsSubmit R_LOG_DEL_FAILED NOSR");
                        OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_SETDATAL_16, "   Total:  %d, Sent: %d",iSmsPDUData.iTotal, iSmsPDUData.iSent );
                        OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_SETDATAL_17, "   Failed: %d, Delivered: %d",iSmsPDUData.iFailed, iSmsPDUData.iDelivered );
                        GetStringL(status,R_LOG_DEL_FAILED);
                        }
                    }
                OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_SETDATAL_18, "SetDataL [status string=%S]",status);
                break;
                }
			default:
				{
				OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_SETDATAL_19, "SetDataL ESmsuUnexpectedSmsPDUType");
				SmsuPanic(ESmsuUnexpectedSmsPDUType);
				}
			}
		}
	else
		GetStringL(status,*aStatusId);

 	TBuf<KLogMaxSubjectLength> subject;
	//
	// EDNAVSA-4VA9FQ Incoming SMSes with special chars are entered in the log as "data messages"
	// only 8 bit messages are displayed as data message in the log viewer
	//
 	if (aSmsMessage.SmsPDU().DataCodingSchemePresent() && aSmsMessage.SmsPDU().Alphabet() == TSmsDataCodingScheme::ESmsAlphabet8Bit)
 		{
 		GetStringL(subject, R_LOG_SUBJECT_DATA_MESSAGE);
 		}
 	else if (aSmsMessage.TextPresent())
   		{
   		const TInt length= Min(KLogMaxSubjectLength, aSmsMessage.Buffer().Length());
 		aSmsMessage.Buffer().Extract(subject, 0, length);
 		subject.Trim();
 		}
 	if (subject.Length() == 0)
 		{
 		GetStringL(subject, R_LOG_SUBJECT_NONE);
   		}
 	iLogEvent->SetSubject(subject);

	iLogEvent->SetStatus(status);
	TPckg<TLogSmsPduData> packeddata(iSmsPDUData);
	iLogEvent->SetDataL(packeddata);
	} // CSmsEventLogger::SetDataL