telephonyserverplugins/multimodetsy/Multimode/sms/set_cmti_mode.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Sets the phoen to CMTI mode using AT+CNMI=?,1
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "NOTIFY.H"
       
    19 #include "mSMSMESS.H"
       
    20 #include "mSLOGGER.H"
       
    21 #include "ATIO.H"
       
    22 
       
    23 #include "set_cmti_mode.h"		// Header for this file
       
    24 
       
    25 //
       
    26 // Macros
       
    27 //
       
    28 // This macro is used to help keep un-intereting details outside of the main code
       
    29 // in this file. The macro uses logging functions and always prefixes writes to the 
       
    30 // log with the name of the class which is implemented in this file. This macro must
       
    31 // only be used by code in this file.
       
    32 #ifdef __LOGDEB__
       
    33 _LIT8(KLogEntry,"CATSetPhoneToCMTIMode::%S\t%S");
       
    34 #define LOCAL_LOGTEXT(function,text) {_LIT8(F,function);_LIT8(T,text);LOGTEXT3(KLogEntry,&F,&T);}
       
    35 #else
       
    36 #define LOCAL_LOGTEXT(function,text)
       
    37 #endif
       
    38 
       
    39 
       
    40 CATSetPhoneToCMTIMode* CATSetPhoneToCMTIMode::NewL (CATIO* aIo, CTelObject* aTelObject,
       
    41 												CATInit* aInit, CPhoneGlobals* aGlobals,
       
    42 												RMobileSmsMessaging::TMobileSmsReceiveMode& aCurrentRxModeVariable)
       
    43 	{
       
    44 	CATSetPhoneToCMTIMode* self = new (ELeave) CATSetPhoneToCMTIMode(aIo, aTelObject, aInit, aGlobals, aCurrentRxModeVariable);
       
    45 	CleanupStack::PushL(self);
       
    46 	self->ConstructL();
       
    47 	CleanupStack::Pop();
       
    48 	return self;
       
    49 	}
       
    50 
       
    51 CATSetPhoneToCMTIMode::CATSetPhoneToCMTIMode(CATIO* aIo, CTelObject* aTelObject,
       
    52 										 CATInit* aInit, CPhoneGlobals* aGlobals,
       
    53 										 RMobileSmsMessaging::TMobileSmsReceiveMode& aCurrentRxModeVariable)
       
    54 	:CATSmsCommands(aIo, aTelObject, aInit, aGlobals),
       
    55 	 iClientsCurrentRxMode(aCurrentRxModeVariable)
       
    56 	{}
       
    57 
       
    58 void CATSetPhoneToCMTIMode::Start(TTsyReqHandle aTsyReqHandle, TAny* /*aParam*/)
       
    59 	{
       
    60 	iReqHandle = aTsyReqHandle;
       
    61 
       
    62 	TInt ret(KErrNotSupported);
       
    63 
       
    64 	//
       
    65 	// Only request our base class set the phone to CMTI mode for us
       
    66 	// if the mode is supoprted by the phone
       
    67 	if(iPhoneGlobals->iModemSupportsCMTIMode)
       
    68 		ret=CATSmsCommands::RequestATCommand(ESetPhoneToCMTIMode);
       
    69 	
       
    70 	if(ret!=KErrNone)
       
    71 		Complete(ret);
       
    72 	}
       
    73 
       
    74 
       
    75 void CATSetPhoneToCMTIMode::EventSignal(TEventSource aSource)
       
    76 	{
       
    77 	LOCAL_LOGTEXT("EventSignal","");
       
    78 
       
    79 	//
       
    80 	// Allow base class to handle events for us
       
    81 	LOCAL_LOGTEXT("EventSignal","Giving base class a chance to handle the event");
       
    82 	CATSmsCommands::EventSignal(aSource);
       
    83 
       
    84 	//
       
    85 	// Check if base class has completed our request
       
    86 	if(CATSmsCommands::RequestATCompleted()==ESetPhoneToCMTIMode)
       
    87 		{
       
    88 		LOCAL_LOGTEXT("EventSignal","Base class has completed request to set phone to CMTI mode");
       
    89 		LOGTEXT2(_L8("completion code: %d"),iRequestError);
       
    90 
       
    91 		//
       
    92 		// If we have completed with no error then update our clients
       
    93 		// current rx mode
       
    94 		if(iRequestError==KErrNone)
       
    95 			iClientsCurrentRxMode=RMobileSmsMessaging::EReceiveStored;
       
    96 
       
    97 		Complete(iRequestError);
       
    98 		}
       
    99 	}
       
   100 
       
   101 
       
   102 void CATSetPhoneToCMTIMode::Stop(TTsyReqHandle aTsyReqHandle)
       
   103 //
       
   104 //	Attempts to halt the process
       
   105 //
       
   106 	{
       
   107 	__ASSERT_ALWAYS(aTsyReqHandle == iReqHandle,Panic(EIllegalTsyReqHandle));		
       
   108 	LOCAL_LOGTEXT("Stop","Cancelling command");
       
   109 	
       
   110 	CATSmsCommands::RequestATCommandCancel();
       
   111 	}
       
   112 
       
   113 
       
   114 void CATSetPhoneToCMTIMode::Complete(TInt aError)
       
   115 	{
       
   116 	Complete(aError,EReadCompletion);
       
   117 	}
       
   118 
       
   119 void CATSetPhoneToCMTIMode::Complete(TInt aError,TEventSource aSource)
       
   120 	{
       
   121 	LOCAL_LOGTEXT("Complete","Enter function");
       
   122 	LOGTEXT2(_L8("Error Code : %d"), aError);
       
   123 
       
   124 	CATCommands::Complete(aError,aSource);
       
   125 	if (iReqHandle != 0)
       
   126 		iTelObject->ReqCompleted(iReqHandle, aError);
       
   127 	}
       
   128 
       
   129 void CATSetPhoneToCMTIMode::CompleteWithIOError(TEventSource /*aSource*/,TInt aStatus)
       
   130 	{
       
   131 	iIo->WriteAndTimerCancel(this);
       
   132 	if (iReqHandle != 0)
       
   133 		iTelObject->ReqCompleted(iReqHandle, aStatus);
       
   134 	}