smsprotocols/smsstack/smsprot/Inc/smspcdb.h
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 1997-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 // Declares the CSmsCommDBEvent class.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalAll
       
    21 */
       
    22 
       
    23 #if !defined (SMSPCDB_H__)
       
    24 #define SMSPCDB_H__
       
    25 
       
    26 #include <e32base.h>
       
    27 #include <e32property.h>
       
    28 #include "smspcomm.h"
       
    29 #include "smsstacklog.h"
       
    30 #include "smsuact.h"
       
    31 
       
    32 
       
    33 class TSmsSettings;
       
    34 
       
    35 
       
    36 
       
    37 /**
       
    38  *  Requests notification of changes in CommDB and in turn notifies an observer,
       
    39  *  the CSmsProtocol object.
       
    40  *  
       
    41  *  Currently this class only waits on changes in the current SMS bearer setting,
       
    42  *  though it should be extendable for changes in other CommDB settings in the future.
       
    43  *  
       
    44  *  The class is a simple active object derived state machine with two states
       
    45  *  defined by CSmsCommDBEvent::TSmsCommDBEventState.
       
    46  *  
       
    47  *  @internalComponent
       
    48  */
       
    49 class CSmspCommDbEvent : public CSmsuActiveBase
       
    50 	{
       
    51 protected:
       
    52 	~CSmspCommDbEvent();
       
    53 	virtual void ConstructL();
       
    54 	virtual void NotifyOnEvent();
       
    55 	CSmspCommDbEvent(const TSmsSettings& aSmsSettings, RMobileSmsMessaging& aSmsMessaging, TInt aPriority);
       
    56 	void Complete(TInt aError);
       
    57 
       
    58 protected:
       
    59 	// Private members
       
    60 	RProperty iProperty; // Property describing the event we require notification of
       
    61 	const TSmsSettings& iSmsSettings;
       
    62 	RMobileSmsMessaging& iSmsMessaging;
       
    63 	};
       
    64 
       
    65 
       
    66 /**
       
    67  *  Queries CommDB for the current sms bearer and attempts to change the
       
    68  *  bearer of the phone.
       
    69  *  
       
    70  *  This class works with the classes CSmsCommDBEvent and CSmsProtocol to change
       
    71  *  the sms bearer when the corresponding setting changes in CommDB.
       
    72  *  
       
    73  *  The class is a simple active object derived state machine with these states
       
    74  *  defined by CSmspSetBearer::TSmsSetBearerState.
       
    75  *  
       
    76  *  @internalComponent
       
    77  */
       
    78 class CSmspSetBearer : public CSmspCommDbEvent
       
    79 	{
       
    80 public:
       
    81 	static CSmspSetBearer* NewL(const TSmsSettings& aSmsSettings, RMobileSmsMessaging& aSmsMessaging, TInt aPriority);
       
    82 	~CSmspSetBearer();
       
    83 	void Start();
       
    84 	void NotifyBearerSet(TRequestStatus& aStatus);
       
    85 
       
    86 protected:
       
    87 	virtual void ConstructL();
       
    88 
       
    89 private:
       
    90 	void DoRunL();
       
    91 	void DoCancel();
       
    92 private:
       
    93 	CSmspSetBearer(const TSmsSettings& aSmsSettings,RMobileSmsMessaging& aSmsMessaging, TInt aPriority);
       
    94 	void SetSmsBearer();
       
    95 	void GetSmsBearerL(RMobileSmsMessaging::TMobileSmsBearer& aBearer);
       
    96 	void NotifyOnEvent();
       
    97 private:
       
    98 	enum TSmsSetBearerState
       
    99 		{
       
   100 		ESmsSetBearerStateInit, 			//< Intial State
       
   101 		ESmsSetBearerNotifyOnEvent, 		//< Wait for notification from property when Bearer changes
       
   102 		ESmsSetBearerStateSettingBearer 	//< Setting the bearer on the current GPRS session
       
   103 		};
       
   104 private:
       
   105 	TSmsSetBearerState iState;				//< The current state of the state machine
       
   106 	RMobileSmsMessaging::TMobileSmsBearer iBearer;	//< The currently used SMS bearer
       
   107 	TBool iBearerSet;						//< Boolean tell is bearer set
       
   108 	RMobileSmsMessaging::TMobileSmsBearer iPreviousBearer; //< The previously used SMS bearer
       
   109 	};
       
   110 
       
   111 /**
       
   112  *  @internalComponent
       
   113  */
       
   114 const TInt KSmspReceiveModeCommDbRetryLimit = 5;
       
   115 const TInt KSmspReceiveModeCommDbRetryDelay = 1000000;
       
   116 
       
   117 /**
       
   118  *  CSmspReceiveMode reads the CommDB global setting SMS_RECEIVE_MODE, compares this to the TSY's SMS capabilities then sets the Receive Mode on the TSY.
       
   119  *  After setting the Receive Mode, CSmspReceiveMode waits for notification from CommDB for changes in global setting SMS_RECEIVE_MODE.
       
   120  *  When the global setting has changed, CSmspReceiveMode sets the Receive Mode on the TSY again.
       
   121  *  @internalComponent
       
   122  */
       
   123 class CSmspReceiveMode : public CSmspCommDbEvent
       
   124 	{
       
   125 public:
       
   126 
       
   127 	static CSmspReceiveMode* NewL(const TSmsSettings& aSmsSettings, RMobileSmsMessaging& aSmsMessaging, const RMobileSmsMessaging::TMobileSmsCapsV1& aSmsCaps, TInt aPriority);
       
   128 	virtual ~CSmspReceiveMode();
       
   129 	void Start(TRequestStatus& aStatus);
       
   130 
       
   131 protected:
       
   132 	virtual void ConstructL();
       
   133 
       
   134 private:
       
   135 
       
   136 	CSmspReceiveMode(const TSmsSettings& aSmsSettings, RMobileSmsMessaging& aSmsMessaging, const RMobileSmsMessaging::TMobileSmsCapsV1& aSmsCaps, TInt aPriority);
       
   137 	void DoRunL();
       
   138 	void DoCancel();
       
   139 
       
   140 	RMobileSmsMessaging::TMobileSmsReceiveMode SelectReceiveMode(RMobileSmsMessaging::TMobileSmsReceiveMode aPreferredMode) const;
       
   141 	RMobileSmsMessaging::TMobileSmsReceiveMode SelectReceiveMode() const;
       
   142 
       
   143 	void GetCommDbReceiveModeL(RMobileSmsMessaging::TMobileSmsReceiveMode& aReceiveMode);
       
   144 	void NotifyOnEvent();
       
   145 	void SetReceiveMode(RMobileSmsMessaging::TMobileSmsReceiveMode aReceiveMode);
       
   146 
       
   147 private:
       
   148 
       
   149 	enum TSmspReceiveMode
       
   150 		{
       
   151 		ESmspReceiveModeInit,					//< Initial state
       
   152 		ESmspReceiveModeRetryCommDb,			//< Transitory state while waiting for CommDb access
       
   153 		ESmspReceiveModeNotifyOnEvent,			//< Wait for notification from property when Bearer changes
       
   154 		ESmspReceiveModeSet 					//< Setting the Receive Mode on the TSY
       
   155 		} iState;
       
   156 
       
   157 	// When notified that the CommDB has been changed we must re-read SMS_RECEIVE_MODE. Possibly this can transitorily
       
   158 	// fail due to power-up race condition, etc. Hence this suppoer for retrying briefly
       
   159 	TInt	iCommDbRetryCount;					//< Count of retry attempts before giving up
       
   160 	RTimer	iCommDbRetryTimer;
       
   161 	RMobileSmsMessaging::TMobileSmsReceiveMode	iSmsReceiveModeLastSet;	//< Used in the event that CommDb can't be read (rather than simply applying default)
       
   162 
       
   163 	const RMobileSmsMessaging::TMobileSmsCapsV1& iSmsCaps;		//< TSY SMS Capabilities
       
   164 	};
       
   165 
       
   166 #endif // !defined SMSPCDB_H__