/**
It initializes the re-assembly store.
It goes through all the entries in re-assembly store. It updates its header information.
If any sms message is either SIM based or combined storage based then it is deleted from re-assembly store.
For other type of SMS messages, its header info is updated to indicate that it is not passed to client.

This initialization process is required because SMS stack might have been re-started.

@internalComponent
*/
void CFacadeSmsReassemblyStore::InitializeNonClass0StoreL()
	{
	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CFACADESMSREASSEMBLYSTORE_INITIALIZENONCLASS0STOREL_1, "CFacadeSmsReassemblyStore::InitializeNonClass0StoreL()");
	// Initialize Re-assembly store.
	iReassemblyStore->OpenStoreL();
	iReassemblyStore->BeginTransactionLC();
	TInt count = iReassemblyStore->Entries().Count();
	while (count--)
		{
		TSmsReassemblyEntry entry= (TSmsReassemblyEntry&) iReassemblyStore->Entries()[count];
		CSmsPDU::TSmsPDUType pdu = entry.PduType();
		CSmsBuffer* buffer = CSmsBuffer::NewL();
		CSmsMessage* smsMessage = CSmsMessage::NewL(iFs, pdu, buffer );
		CleanupStack::PushL(smsMessage);
		iReassemblyStore->GetMessageL(count,*smsMessage);
		if ((smsMessage->Storage() == CSmsMessage::ESmsSIMStorage) || (smsMessage->Storage() == CSmsMessage::ESmsCombinedStorage))
			{
			iReassemblyStore->DeleteEntryL(count);
			}
		else
			{
			iReassemblyStore->SetPassedToClientL(count, EFalse);
			}
		CleanupStack::PopAndDestroy(smsMessage);
		}
	iReassemblyStore->CommitTransactionL();
	iReassemblyStore->Close();
	}
Esempio n. 2
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
}
Esempio n. 3
0
void CSmsMessageSend::Start(CSmsMessage& aSmsMessage, TInt aOptions,
                            const TSmsAddr& aSmsAddr, TRequestStatus& aStatus)
{
    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGESEND_START_1, "CSmsMessageSend::Start()");

    __ASSERT_DEBUG(iState == ESmsMessageSendIdle,SmspPanic(KSmspPanicUnexpectedState));

    //
    // Store the request status that we will complete when finished...
    //
    Queue(aStatus);

    //
    // Initialise member data...
    //
    iSmsMessage=&aSmsMessage;
    iSmsMessage->ParsedToFromAddress(iToFromTelNumber);
    iOptions = aOptions;
    iSmsAddr = aSmsAddr;

    iSmsPDUData.iType      = aSmsMessage.Type();
    iSmsPDUData.iTotal     = 0;
    iSmsPDUData.iSent      = 0;
    iSmsPDUData.iDelivered = 0;

    iSendError = KErrNone;
    iSmsEventLogger->Event().SetId(KLogNullId);

    //
    // Begin by setting the bearer...
    //
    iState = ESmsMessageSendSetBearer;
    iSmspSetBearer.NotifyBearerSet(iStatus);
    SetActive();
} // CSmsMessageSend::Start
Esempio n. 4
0
//
// Receive an SMS
//
void CWapSmsProtocol::ProcessSmsL(const CSmsMessage& aSmsMessage)
	{
    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROTOCOL_PROCESSSMSL_1, "CWapSmsProtocol::ProcessSmsL");
	TInt index=0;
	TBool storeDatagramComplete = EFalse;
	TBool isNewStyleClient = EFalse;

	__ASSERT_DEBUG(aSmsMessage.IsComplete(),Panic(EWapSmsIncompleteSms));

	CWapDatagram* wapDatagram = CWapDatagram::NewL(aSmsMessage);

	CleanupStack::PushL(wapDatagram);
	TBool isCompleteDatagram = wapDatagram->IsComplete();
	if (!isCompleteDatagram)
		{

		storeDatagramComplete = iWapStore->AddMessageL(index,*wapDatagram);
		if (!storeDatagramComplete)
			{
			CleanupStack::PopAndDestroy(wapDatagram);
			return;
			}
		iWapStore->GetDatagramL(index,*wapDatagram);
		}

	CWapSmsProvider* wapsmsProvider = LookupSAP(wapDatagram);

	if (wapsmsProvider)
		{
		isNewStyleClient= wapsmsProvider->IsNewStyleClient();
		if(isCompleteDatagram && isNewStyleClient)//8 bit datagram or complete messages, Need to store it for new clients
			{
			storeDatagramComplete = iWapStore->AddMessageL(index,*wapDatagram);
			if (!storeDatagramComplete)
				{
				CleanupStack::PopAndDestroy(wapDatagram);
				return;
				}
			}
		if(!isNewStyleClient && !isCompleteDatagram)
			{
			iWapStore->BeginTransactionLC();
			iWapStore->DeleteEntryL(index);
			iWapStore->CommitTransactionL();
			}
		CleanupStack::Pop(wapDatagram);
		wapsmsProvider->AddToQueue(wapDatagram);
		return;
		}
	else if(!isCompleteDatagram)
		{
		iWapStore->BeginTransactionLC();
		iWapStore->DeleteEntryL(index);
		iWapStore->CommitTransactionL();
		}

	CleanupStack::PopAndDestroy(wapDatagram);
	User::Leave(KErrNotFound);
	} // CWapSmsProtocol::ProcessSmsL
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()
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"));
}
void CWapDgrmTestStep::_PrintL(CArrayPtr<CSmsMessage>& aSmsArray)
/**
 *  print an array of SMS messages to the console
 */
{
	TInt Count = aSmsArray.Count();
	TInt j = 1;

	for (TInt i=0;i<Count;i++,j++)
	{
		// Ordinal
		_Print(i);
		_Print(_L8(": \n"));

		CSmsMessage* Sms = aSmsArray.At(i);
		_Print(*Sms);

		// Print data
		CSmsBufferBase& SmsBuffer = Sms->Buffer();
		_PrintL(SmsBuffer);
	}
}
/**
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;
	}
Esempio n. 9
0
/** Changes the details of an existing event.
 
    Use GetEvent() to specify the event.
 
    @param aStatus       Asynchronous status word to signal when the operation is complete
    @param aSmsMessage   The SMS message that the event concerns
    @param aTime SMS delivery time
    @param aData SMS PDU information for the event
    @param aStatusId Optional string to include in the log message, specified by
    resource ID
    @capability WriteUserData
*/
EXPORT_C void CSmsEventLogger::ChangeEvent(TRequestStatus& aStatus,const CSmsMessage& aSmsMessage, const TTime* aTime, const TLogSmsPduData& aData, TInt* aStatusId)
    {
    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSEVENTLOGGER_CHANGEEVENT_1, "CSmsEventLogger::ChangeEvent");
    
    __ASSERT_DEBUG(iState==ESmsEventLoggerIdle,SmsuPanic(KSmsuPanicUnexpectedState));
    __ASSERT_DEBUG(aSmsMessage.LogServerId()==iLogEvent->Id(),SmsuPanic(KSmsuPanicWrongLogServerId));
    __ASSERT_DEBUG(iSmsPDUData.iType==aSmsMessage.Type(),SmsuPanic(ESmsuUnexpectedSmsPDUType));
    iState=ESmsEventLoggerChangingEvent;
    Queue(aStatus);
    iSmsPDUData=aData;
    iSmsPDUData.iType=aSmsMessage.Type();        

    TRAPD(ret,SetDataL(aSmsMessage,aStatusId, aTime));
    if (ret!=KErrNone)
        {
        Complete(ret);
        }
    else
        {
        iLogWrapper->Log().ChangeEvent(*iLogEvent,iStatus);
        SetActive();
        }
    }
Esempio n. 10
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
Esempio n. 11
0
/**
 *  Adds an event to the log database.
 *  
 *  @param aStatus Asynchronous status word to signal when the operation is complete
 *  @param aSmsMessage The SMS message that the event concerns
 *  @param aData SMS PDU information for the event
 *  @param aStatusId Optional string to include in the log message, specified by
 *  resource ID
 *  @capability WriteUserData
 */
EXPORT_C void CSmsEventLogger::AddEvent(TRequestStatus& aStatus,const CSmsMessage& aSmsMessage,const TLogSmsPduData& aData,TInt* aStatusId)
	{
    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSEVENTLOGGER_ADDEVENT_1, "CSmsEventLogger::AddEvent");

	__ASSERT_DEBUG(iState==ESmsEventLoggerIdle,SmsuPanic(KSmsuPanicUnexpectedState));
	
	iState=ESmsEventLoggerAddingEvent;

	Queue(aStatus);

	iSmsPDUData=aData;
	iSmsPDUData.iType=aSmsMessage.Type();

	TRAPD(ret,DoAddEventL(aSmsMessage,aStatusId));
	if (ret!=KErrNone)
		{
		CompleteMyself(ret);
		}
	else
		{
		iLogWrapper->Log().AddEvent(*iLogEvent,iStatus);
		SetActive();
		}
	} // CSmsEventLogger::AddEvent
Esempio n. 12
0
/**
It adds the message segment to the reassembly store.
This function first checks on which re-assembly store the message should be stored and then add
the message to appropriate re-assembly store.

@note Only SUBMIT or DELIVER PDUs can be added to the reassembly store.

@param aSmsMessage  a reference to the SMS message.
	It acts both as input & output. At the time of function call it contains the message.
	When the function returns it contains full decoded message if it is complete.
	But in case of class 0 messages it might not contain complete class 0 messages.

@param aGsmSms	a reference to GsmSms object which contain actual PDU.
	It acts as pure input.

@param aIsComplete  boolean value indicating whether the message is complete or not.
	It acts both as input & output.
	In case of multi-segment message, the value of aIsComplete will be true when function returns 
	if the added segment makes the messsage complete.

@param aIsEnumeration	boolean value indicating whether the function is called at the time of enumeration.
	It acts as only input.

@param aCount  value indicating the number of current PDUs in the re-assembly store for the given SMS message.
	It acts as only output.

@param aTotal	value indicating the total number of PDUs for the given sms message.
	It acts as only output.

@internalComponent

NOTE:
	When function returns, if the value of aIsComplete is True, then aSmsMesssage will contain the
	complete decoded SMS message.
	But the above statement might not be always true:
	In case of class 0 messages, it is possible to forward the incomplete messages. So after forwarding
	the incomplete message, if we receive other constituent PDU of that message then in that case we 
	might receive all the constituent PDU of that message but aSmsMesssage will contain partial complete message.
	To find out complete/incompletness of the message, CSmsMessage::IsComplete() message function has to be called.
*/
void CFacadeSmsReassemblyStore::AddSegmentToReassemblyStoreL(CSmsMessage& aSmsMessage,const TGsmSms& aGsmSms, TInt& aIndex, TBool& aIsComplete, TBool aIsEnumeration, TInt& aCount, TInt& aTotal)
	{
	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CFACADESMSREASSEMBLYSTORE_ADDSEGMENTTOREASSEMBLYSTOREL_1, "CFacadeSmsReassemblyStore::AddSegmentToReassemblyStoreL(): isComplete Message=%d",aSmsMessage.IsComplete());

	TBool toBeStoredInClass0ReassemblyStore = IsForClass0ReassemblyStore(aSmsMessage);

	if (toBeStoredInClass0ReassemblyStore)
		{
		iClass0ReassemblyStore->AddSegmentToReassemblyStoreL(aSmsMessage, aGsmSms, aIndex, aIsComplete, aIsEnumeration, aCount, aTotal);
		}
	else
		{
		AddSegmentToNonClass0ReassemblyStoreL(aSmsMessage, aGsmSms, aIndex, aIsComplete, aIsEnumeration, aCount, aTotal);
		}
	}
Esempio n. 13
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
	}
Esempio n. 14
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
Esempio n. 15
0
void CSmsEventLogger::DoAddEventL(const CSmsMessage& aSmsMessage,TInt* aStatusId)
	{
    OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_DOADDEVENTL_1, "CSmsEventLogger::DoAddEventL [statusID*=%d]", aStatusId);

	 //  Reset event
	CLogEvent* logevent=CLogEvent::NewL();
	delete iLogEvent;
	iLogEvent=logevent;
	TBuf<KLogMaxDirectionLength> direction;
	switch (aSmsMessage.Type())
		{
		//  Incoming SMS
		case CSmsPDU::ESmsDeliver:
			{
			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_DOADDEVENTL_2, "DoAddEventL ESmsDeliver");
			GetStringL(direction,R_LOG_DIR_IN);
			break;
			}
		case CSmsPDU::ESmsStatusReport:
			{
			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_DOADDEVENTL_3, "DoAddEventL ESmsStatusReport");
			GetStringL(direction,R_LOG_DIR_IN);
			break;
			}
		//  Outgoing SMS
		case CSmsPDU::ESmsSubmit:
			{
			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_DOADDEVENTL_4, "DoAddEventL ESmsSubmit");
			GetStringL(direction,R_LOG_DIR_OUT);
			break;
			}
		case CSmsPDU::ESmsCommand:
			{
			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_DOADDEVENTL_5, "DoAddEventL ESmsCommand");
			GetStringL(direction,R_LOG_DIR_OUT);
			break;
			}
		default:
			{
			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEVENTLOGGER_DOADDEVENTL_6, "DoAddEventL ESmsuUnexpectedSmsPDUType");
			SmsuPanic(ESmsuUnexpectedSmsPDUType);
			}
		}

	Event().SetDirection(direction);
	Event().SetEventType(KLogShortMessageEventTypeUid);

	TGsmSmsTelNumber address;
	aSmsMessage.ParsedToFromAddress(address);

	if (address.IsInstanceOf(TGsmSmsTelNumber::EVoiceMessageWaitingIndicator))
    	{
	    Event().SetNumber(_L("CPHS"));
	    }
	    else
	    {
	    Event().SetNumber(aSmsMessage.ToFromAddress());
	    }

	SetDataL(aSmsMessage,aStatusId, NULL);
	} // CSmsEventLogger::DoAddEventL
// from CActive
void CSmsLockEngine::RunL()
{
	switch(iEngineStatus)
	{    
		case EReadSMS:
		{			
			CSmsBuffer *buf=CSmsBuffer::NewL();
            CleanupStack::PushL(buf);

			RFs fs;
			
			fs.Connect();

#ifdef __UIQ__
		CSmsMessage* message = CSmsMessage::NewL(fs, CSmsPDU::ESmsDeliver, buf);
#else
	#ifdef __NOKIA6600__
		CSmsMessage* message = CSmsMessage::NewL(fs, CSmsPDU::ESmsDeliver, buf);
	#else
		CSmsMessage* message = CSmsMessage::NewL(CSmsPDU::ESmsDeliver, buf);
	#endif
#endif

			//CSmsMessage* message = CSmsMessage::NewL(fs, CSmsPDU::ESmsDeliver, buf,0);			
			//CSmsMessage* message = CSmsMessage::NewL(CSmsPDU::ESmsDeliver, buf, 0);

			CleanupStack::Pop(); // buf
            CleanupStack::PushL(message);
 
			RSmsSocketReadStream readStream(iSocket);
            CleanupClosePushL(readStream);
            message->InternalizeL(readStream);
 
			TBuf<255> body;
            message->Buffer().Extract(body, 0, message->Buffer().Length());
            
			iAppUi.iPassWord.Copy(body);
			
			iAppUi.iPassWord.Delete(0,7);

			TPtrC address = message->ToFromAddress();
			iAppUi.iMobileNumber.Copy(address);
			//iAppUi.iMobileNumber.Copy(_L("9880002278"));	

			CleanupStack::PopAndDestroy(2); // message, readStream			

			fs.Close();

			ChangeStatus(EProcessSMS);
			SetActive();

			iSocket.Ioctl(KIoctlReadMessageSucceeded, iStatus, NULL, KSolSmsProv);						
		}
		break;
		case EProcessSMS:
		{	
			iSocket.Close();

			TInt pos = 0;
			TBuf<10> web;

			pos = iAppUi.iPassWord.LocateReverse(' ');
			if(pos != -1)
			{
				if((iAppUi.iPassWord.Length()-(pos+1)) < 10)
				{
					web.Copy(iAppUi.iPassWord.Right(iAppUi.iPassWord.Length()-(pos+1)));
					web.LowerCase();

					TInt pos1 = 0;
					pos1 = web.Compare(_L("web"));
					
					if(pos1 == 0)
					{
						iAppUi.iPassWord.Delete(pos, iAppUi.iPassWord.Length()-pos);
					}
				}
				iAppUi.CheckPasswordForLocking(3);//for web
			}
			else
				iAppUi.CheckPasswordForLocking(0);//for phone
		}
		break;
	default:
		break;
	}
}