telephonyserverplugins/simtsy/inc/CSimLine.h
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2003-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 //
       
    15 
       
    16 #ifndef __CSIMLINE_H__
       
    17 #define __CSIMLINE_H__
       
    18 
       
    19 
       
    20 #include <et_phone.h>
       
    21 #include "utils.h"
       
    22 #include <etelmm.h>
       
    23 #include "CSimPubSub.h"
       
    24 #include "csimtimer.h"
       
    25 
       
    26 /**
       
    27  * @file
       
    28  * Declares the base class for voice and data lines - CSimLine
       
    29  * @internalAll
       
    30  */
       
    31 
       
    32 const RMobileCall::TMobileCallStatus KStateTableTerminator=(RMobileCall::TMobileCallStatus)999;
       
    33 
       
    34 struct TStateChangeValidity
       
    35 	{
       
    36 	RMobileCall::TMobileCallStatus iOldState;
       
    37 	RMobileCall::TMobileCallStatus iNewState;
       
    38 	TInt iError;
       
    39 	};
       
    40 
       
    41 /**
       
    42  * This table is used to test the validity of potential line state changes.
       
    43  * If the state change is not included in the table, the error KErrGeneral will be generated.
       
    44  * A potential error value is included as the third item in each entry to enable errors
       
    45  * other than KErrGeneral to be generated for specific erroneous state changes.
       
    46  */
       
    47 const struct TStateChangeValidity KLineStateChangeValidity[]= {
       
    48 	{ RMobileCall::EStatusIdle,			RMobileCall::EStatusDialling,	KErrNone },
       
    49 	{ RMobileCall::EStatusDialling,		RMobileCall::EStatusConnecting,	KErrNone },
       
    50 	{ RMobileCall::EStatusConnecting,	RMobileCall::EStatusConnected,	KErrNone },
       
    51 
       
    52 	{ RMobileCall::EStatusIdle,			RMobileCall::EStatusAnswering,	KErrNone },
       
    53 	{ RMobileCall::EStatusIdle,			RMobileCall::EStatusRinging,	KErrNone },
       
    54 	{ RMobileCall::EStatusRinging,		RMobileCall::EStatusAnswering,	KErrNone },
       
    55 	{ RMobileCall::EStatusRinging,		RMobileCall::EStatusRinging,	KErrNone },
       
    56 	{ RMobileCall::EStatusRinging,		RMobileCall::EStatusHold,	KErrNone },
       
    57 	{ RMobileCall::EStatusAnswering,	RMobileCall::EStatusConnected,	KErrNone },
       
    58 
       
    59 	{ RMobileCall::EStatusConnected,	RMobileCall::EStatusHold,		KErrNone },
       
    60 	{ RMobileCall::EStatusHold,			RMobileCall::EStatusConnected,	KErrNone },
       
    61 	{ RMobileCall::EStatusHold,			RMobileCall::EStatusDialling,	KErrNone },
       
    62 	{ RMobileCall::EStatusHold,			RMobileCall::EStatusAnswering,	KErrNone },
       
    63 	{ RMobileCall::EStatusHold,			RMobileCall::EStatusDisconnecting,	KErrNone },
       
    64 
       
    65 	{ RMobileCall::EStatusConnected,	RMobileCall::EStatusDisconnecting,	KErrNone },
       
    66 	{ RMobileCall::EStatusConnected,	RMobileCall::EStatusRinging,	KErrNone }, // new AA
       
    67 	{ RMobileCall::EStatusHold,	RMobileCall::EStatusRinging,	KErrNone }, 
       
    68 	{ RMobileCall::EStatusDisconnecting,	RMobileCall::EStatusIdle,		KErrNone },
       
    69 	
       
    70 	{ RMobileCall::EStatusDisconnecting,	RMobileCall::EStatusConnected,		KErrNone },//HangUp Cancel
       
    71 
       
    72 	{ KStateTableTerminator,			KStateTableTerminator,			KStateTableTerminator}
       
    73 	};
       
    74 
       
    75 //
       
    76 // CSimLine - General Line Functionality
       
    77 //
       
    78 /**
       
    79 * This class 'CSimLine' is the Line class for the Simulator TSY.
       
    80 * It is the base class for Voice (CSimVoiceLine) and Data (CSimDataLine) lines. 
       
    81 * It is an abstract class and is therefore not going to be instantiated. 
       
    82 * It will handle all functionality common to voice and data lines.
       
    83 */
       
    84 class CSimPhone;
       
    85 class CSimCall;
       
    86 class CTestConfigSection;
       
    87 
       
    88 class CSimLine : public CLineBase, public MPSSimObserver, public MTimerCallBack
       
    89 	{
       
    90 	friend class CSimVoiceCall;
       
    91 public:
       
    92 	CSimLine(CSimPhone* aPhone);
       
    93 	~CSimLine();
       
    94 	virtual TInt RegisterNotification(const TInt aIpc);
       
    95 	virtual TInt DeregisterNotification(const TInt aIpc);
       
    96 	static void CloseLine(TAny* aObj);
       
    97 	virtual CTelObject::TReqMode ReqModeL(const TInt aIpc);
       
    98 	// MTelObjectTSY pure virtuals
       
    99 	virtual void Init();
       
   100 	
       
   101 	// Functionality associated with the ETel Core API
       
   102 	virtual TInt GetInfo(const TTsyReqHandle aTsyReqHandle,RLine::TLineInfo* aLineInfo);
       
   103 
       
   104 	virtual TInt GetCaps(const TTsyReqHandle aTsyReqHandle,RLine::TCaps* aCaps);
       
   105 	virtual TInt NotifyCapsChange(const TTsyReqHandle aTsyReqHandle, RLine::TCaps* aCaps);
       
   106 	virtual TInt NotifyCapsChangeCancel(const TTsyReqHandle aTsyReqHandle);
       
   107 
       
   108 	virtual TInt NotifyIncomingCall(const TTsyReqHandle aTsyReqHandle, TName* aName);
       
   109 	virtual TInt NotifyIncomingCallCancel(const TTsyReqHandle aTsyReqHandle);
       
   110 
       
   111 	virtual TInt NotifyHookChange(const TTsyReqHandle aTsyReqHandle, RCall::THookStatus* aHookStatus);
       
   112 	virtual TInt NotifyHookChangeCancel(const TTsyReqHandle aTsyReqHandle);
       
   113 
       
   114 	virtual TInt GetStatus(const TTsyReqHandle aTsyReqHandle,RCall::TStatus* aStatus);
       
   115 	virtual TInt GetHookStatus(const TTsyReqHandle aTsyReqHandle,RMobileCall::THookStatus* aHookStatus);
       
   116 	virtual TInt NotifyStatusChange(const TTsyReqHandle aTsyReqHandle,RCall::TStatus* aLineStatus);
       
   117 	virtual TInt NotifyStatusChangeCancel(const TTsyReqHandle aTsyReqHandle);
       
   118 
       
   119 	// Functionality associated with the ETel Multimode API
       
   120 	virtual TInt NotifyMobileLineStatusChange(const TTsyReqHandle aTsyReqHandle,RMobileCall::TMobileCallStatus* aLineStatus);
       
   121 	virtual TInt NotifyMobileLineStatusChangeCancel(const TTsyReqHandle aTsyReqHandle);
       
   122 	virtual TInt NotifyCallAdded(const TTsyReqHandle aTsyReqHandle,TName* aName);
       
   123 	virtual TInt NotifyCallAddedCancel(const TTsyReqHandle aTsyReqHandle);
       
   124 	virtual TInt GetMobileLineStatus(const TTsyReqHandle aTsyReqHandle,RMobileCall::TMobileCallStatus* aStatus);
       
   125 	virtual TInt NumberOfSlotsL(const TInt aIpc);
       
   126 
       
   127 	const CTestConfigSection* CfgFile();					// < Accessor function for the configuration file.
       
   128 	TInt ChangeStateL(RMobileCall::TMobileCallStatus aNewState,TBool aSwap,CSimCall* aOriginatingCall);	// < Attempt to change the line state.
       
   129 	virtual void SimPSEvent(const CSimPubSub::TPubSubProperty aProperty, TInt aStatus);		// < MPSSimObserver  pure virtual
       
   130 	TInt SetAutoAnswerCallObject(CSimCall* aCallObject);			// < Set the call object that will be used to answer the next incoming call.
       
   131 	void ResetAutoAnswerCallObject(CSimCall* aCallObject);			// < Reset the call object that would have been used to answer the next incoming call.
       
   132 	TInt SetRemoteHangupCallObject(CSimCall* aCallObject);			// < Set the call object that will be remotely hung up.
       
   133 	void ResetRemoteHangupCallObject(CSimCall* aCallObject);		// < Reset the call object that would have been remotely hung up.
       
   134 	void CallDestructor(CSimCall* aCall);
       
   135 	TBool IsAnswerCallObjectSpare();
       
   136 	virtual TUint Caps()=0;
       
   137 	enum TCallType
       
   138 		{
       
   139 		ECallTypeSpareCall,
       
   140 		ECallTypeNormalCall
       
   141 		};
       
   142 	virtual CSimCall* CreateNewCallL(TDes& aNewName,TCallType aCallType)=0;
       
   143 	virtual TInt FindActiveCall(CSimCall*& aCall)=0;
       
   144 
       
   145 
       
   146 	// Implement the MTimerCallBack interface
       
   147 	void TimerCallBack(TInt /*aId*/);
       
   148 
       
   149 protected:
       
   150 	void ConstructL(const TName& aName);
       
   151 	void HandleNewCallAddedNotification(const TDesC& aNewName);
       
   152 
       
   153 private:
       
   154 	void ProcessIncomingCallEvent();
       
   155 	void ProcessNotifyIncomingCallEvent();
       
   156 	void ProcessRemoteHangupEvent();
       
   157 	RCall::TStatus GetCoreLineStatus();	//< Converts Multimode Line status to Core line status
       
   158 
       
   159 public:
       
   160 	CSimPhone* iPhone;							//< Pointer to the phone object
       
   161 	TName iLineName;							//< Current Line name
       
   162 	RMobileCall::TMobileCallStatus iState;		//< Holds the current line status
       
   163 	void UpdatePhoneNotifiers(CSimCall*,TUint);
       
   164 
       
   165 protected:
       
   166 	CArrayFixFlat<CSimCall*>* iCalls;			//< Array of all the call objects created
       
   167 	TInt iCallCnt;
       
   168 	TInt iNameIndex;							//< Call index in the pool of calls created
       
   169 	TName iNameOfLastCallAdded;					//< Name of last call added
       
   170 	CSimCall* iAnswerNextIncomingCall;			//< Pointer for handling AnswerIncomingCall request
       
   171 	CSimCall* iSpareCall;						//< Pointer to the spare call, used for incoming calls if none is allocated.
       
   172 	CSimCall* iRemoteHangupCall;				//< Pointer for handling RemoteHangupCall request
       
   173 
       
   174 	CSimPubSub::TPubSubProperty iICProperty;
       
   175 	CSimPubSub::TPubSubProperty iRHProperty;
       
   176 	
       
   177 	TBool iAnswerIncomingCallReqPending;		//< There is an answer incoming call request pending on a call on this line.
       
   178 	TBool iRemoteHangupCallReqPending;			//< There is a remote hangup call request pending on a call on this line.
       
   179 
       
   180 	TNotifyData		iNotifyMobileStatusChange;	//< Holds the notification data (a flag, TsyReqHandle and any raw data) for the mobile line status
       
   181 	TNotifyData		iNotifyStatusChange;		//< Holds the notification data (a flag, TsyReqHandle and any raw data) for the line status
       
   182 	RCall::THookStatus	iHookState;				//< The current line hook state.
       
   183 	TNotifyData		iNotifyHookChange;			//< Holds the notification data (a flag, TsyReqHandle and any raw data) for the line hook status
       
   184 	TNotifyData		iNotifyCallAdded;			//< Holds the notification data (a flag, TsyReqHandle and any raw data) for the newly added call
       
   185 	TNotifyData		iNotifyIncomingCall;		//< Holds the notification data (a flag, TsyReqHandle and any raw data) for IncomingCall Notification
       
   186 	TNotifyData		iNotifyCapsChange;			//< Holds the notification data (a flag, TsyReqHandle and any raw data) for Line Capability Notifications
       
   187 	TUint			iCaps;						//< Current line capability information
       
   188 private:
       
   189 	CSimPubSub*		iSimPubSubIC;				//< Pointer to the Publish & Subscribe object for the incoming call
       
   190 	CSimPubSub*		iSimPubSubRH;				//< Pointer to the Publish & Subscribe object for the incoming call
       
   191 	
       
   192 	/** 
       
   193 	Duration between receiving an incoming call and sending the 
       
   194 	incoming call notification.
       
   195 	*/
       
   196 	TInt iNotifyIncomingCallPause;
       
   197 	/**
       
   198 	Timer to delay sending the notification of the incoming call.
       
   199 	*/
       
   200 	CSimTimer* iTimer;
       
   201 	};
       
   202 
       
   203 #endif // __CSIMLINE_H__