datacommsserver/networkcontroller/src/CNetworkController.h
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 /**
       
     2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21  @file CNetworkController.h
       
    22  @internalComponent
       
    23 */
       
    24 
       
    25 #if !defined (__CNETWORKCONTROLLER_H__)
       
    26 #define __CNETWORKCONTROLLER_H__
       
    27 #include <comms-infras/cnetworkcontrollerbase.h>
       
    28 #include <comms-infras/dialogprocessor.h>
       
    29 #include "CSelectionRequest.h"
       
    30 #include "CReconnectRequest.h"
       
    31 
       
    32 class MNetConDialogProcAccess;
       
    33 class MNetConEnv
       
    34 /**
       
    35 For upcalls from the requests
       
    36 
       
    37 @internalComponent
       
    38 */
       
    39 	{
       
    40 public:
       
    41 
       
    42 	/**
       
    43 	A selection request has been processed - queue another one.
       
    44 
       
    45 	@param aRequest pointer to the actual selection request
       
    46 	@param aError contains the reason for failure of processing the request or KErrNone
       
    47 	*/
       
    48 	virtual void RequestComplete(const CSelectionRequest* aRequest, TInt aError) = 0;
       
    49 
       
    50 	/**
       
    51 	A reconnect request has been processed - queue another one.
       
    52 
       
    53 	@param aRequest pointer to the actual reconnect request
       
    54 	@param aError contains the reason for failure of processing the request or KErrNone
       
    55 	*/
       
    56 	virtual void RequestComplete(const CReconnectRequest* aRequest, TInt aError) = 0;
       
    57 
       
    58 	/**
       
    59 	Retrieve the name of the Agent that is used for implicit connection
       
    60 	requests - i.e. connection startup from RSocket SendTo()/Connect() or
       
    61 	RHostResolver GetByName()
       
    62 
       
    63 	@returns an Agent name
       
    64 	*/
       
    65 	virtual const HBufC* ImplicitConnectionAgentName() const = 0;
       
    66 
       
    67 	/**
       
    68 	Retrieve the connection preferences associated with the current
       
    69 	implicit connection
       
    70 
       
    71 	@returns a TConnPref reference
       
    72 	*/
       
    73 	virtual const TConnPref& ImplicitConnectionPrefs() const = 0;
       
    74 
       
    75 	/**
       
    76 	Searches for an Agent associated with the selected IAP
       
    77 	@note that there is a one-to-one relationship between agents and IAPs
       
    78 
       
    79 	@param aAgent if found a pointer to the CNifAgentBase
       
    80 	@return TInt KErrNotFound or KErrNone
       
    81 	@pre the selected IAP setting is stored in the DbAccess object.
       
    82 	*/
       
    83 	virtual TInt FindExistingAgentForSelection(CNifAgentBase*& aAgent, CCommsDbAccess* aDatabase) const = 0;
       
    84 
       
    85 	/**
       
    86 	Check Bearer Availability
       
    87 
       
    88 	@param aIsReconnect if this is a reconnection then any asynchronous requests are skipped in order to speed things up
       
    89 	*/
       
    90 	virtual void CheckBearerAvailability(TBool aIsReconnect) = 0;
       
    91 
       
    92 	/**
       
    93 	Check Second Phase Bearer Availability - e.g. signal strength
       
    94 
       
    95 	@returns KErrNone if the bearer availability is above the threshold stored in CommDB, otherwise KErrNetConInadequateSignalStrengh
       
    96 	*/
       
    97 	virtual TInt RequestSecondPhaseAvailability() = 0;
       
    98 
       
    99 	/**
       
   100 	Create an association between an Agent and a Network ID.
       
   101 
       
   102 	@param aAgent pointer to the Agent
       
   103 	@param aNetworkId the CommDb ID of the Network
       
   104 	*/
       
   105 	virtual void AddAgentToNetworkL(CNifAgentBase* aAgent, TUint32 aNetworkId) = 0;
       
   106 
       
   107 	/**
       
   108 	CancelBearerAvailabilityCheck
       
   109 	*/
       
   110 	virtual void CancelBearerAvailabilityCheck() = 0;
       
   111 
       
   112 	/**
       
   113 	Factory function to provide a database access object.
       
   114 	*/
       
   115 	virtual CCommsDbAccess* NewDatabaseL() = 0;
       
   116 	/**
       
   117 	Factory function to proviae a dialog processor
       
   118 	*/
       
   119 	virtual CNetConDlgProcessor* NewDialogProcessorL() = 0;
       
   120 
       
   121 	};
       
   122 
       
   123 const TInt KTelBearerPosition = 0; ///< position of the telephony bearer in the array
       
   124 
       
   125 NONSHARABLE_CLASS(CNetworkController) : public CNetworkControllerBase, public MNetConEnv
       
   126 /**
       
   127 The class is responsible for Queing Selection and Reconnection requests received from NIFMAN in a FIFO queue of CNetConRequestBase objects
       
   128 
       
   129 @internalComponent
       
   130 */
       
   131 	{
       
   132 public:
       
   133 	virtual ~CNetworkController();
       
   134 	static CNetworkController* NewL();
       
   135 
       
   136 	// calls from Nifman 
       
   137 	virtual void SelectAgent(MNetworkControllerObserver* aObserver, MServiceChangeObserver* apServiceChangeObserver, TConnStartType aStartType, TInt aConnectionAttempt, TInt aLastConnectionError);
       
   138 	virtual void SelectAgent(MNetworkControllerObserver* aObserver, MServiceChangeObserver* apServiceChangeObserver, TConnStartType aStartType, TInt aConnectionAttempt, TInt aLastConnectionError, const TConnPref& aPrefs);
       
   139 	virtual void Reconnect(MNetworkControllerObserver* aObserver, CNifAgentBase* aAgent);
       
   140 	virtual void Reconnect(MNetworkControllerObserver* aObserver, CNifAgentBase* aAgent, CStoreableOverrideSettings* aOverrides);
       
   141 	virtual TInt CancelRequest(MNetworkControllerObserver* aObserver);
       
   142 	virtual void AgentConnectionFailure(CNifAgentBase* aAgent, TInt aError);
       
   143 	virtual TInt RequestImplicitConnectionNotification(MImplicitConnectionNotify* aObserver);
       
   144 	virtual void CancelImplicitConnectionNotification(MImplicitConnectionNotify* aObserver);
       
   145 
       
   146 	// implementation of MBearerObserver interface 
       
   147 	virtual void BearerStateChange(CBearerBase* aBearer);
       
   148 
       
   149 	virtual CCommsDbAccess* DbAccess();
       
   150 
       
   151 	// implementation of MNetConEnv interface
       
   152 	virtual void RequestComplete(const CSelectionRequest* aRequest, TInt aError);
       
   153 	virtual void RequestComplete(const CReconnectRequest* aRequest, TInt aError);
       
   154 	virtual const HBufC* ImplicitConnectionAgentName() const;
       
   155 	virtual const TConnPref& ImplicitConnectionPrefs() const;
       
   156 	virtual TInt FindExistingAgentForSelection(CNifAgentBase*& aAgent, CCommsDbAccess* aDatabase) const;
       
   157 	virtual void CheckBearerAvailability(TBool aIsReconnect);
       
   158 	virtual TInt RequestSecondPhaseAvailability();
       
   159 	virtual void AddAgentToNetworkL(CNifAgentBase* aAgent, TUint32 aNetworkId);
       
   160 	virtual void CancelBearerAvailabilityCheck();
       
   161 
       
   162 	virtual CCommsDbAccess* NewDatabaseL();
       
   163 	virtual CNetConDlgProcessor* NewDialogProcessorL();
       
   164 
       
   165 protected:
       
   166 	CNetworkController();
       
   167 	void ConstructL();
       
   168 
       
   169 private:
       
   170 	void SelectComplete(TInt aError, const TConnectionSettings& aSettings);
       
   171 	static TInt ProcessRequestCb(TAny* aThisPtr);
       
   172 	void ProcessRequest();
       
   173 	static TInt ImplicitNotificationCb(TAny* aThisPtr);
       
   174 	void SendImplicitConnectionNotification(const TDesC8& aConnectionInfo, MImplicitConnectionNotify::TEvent aEvent);
       
   175 	TInt GetConnectionInfo(CNifAgentBase* aAgent, TDes8& aConnectionInfo);
       
   176 
       
   177 private:
       
   178 	CNetConRequestBase* iCurrentRequest;
       
   179 	CAsyncCallBack* iProcessRequestCb;
       
   180 	TSglQue<CNetConRequestBase> iRequestQueue;
       
   181 	RPointerArray<MImplicitConnectionNotify> iImplicitNotifyList;
       
   182 	TConnPref iImplicitConnectionPrefs;
       
   183 	HBufC* iImplicitConnectionAgentName;
       
   184 	CAsyncCallBack* iImplicitNotificationCb;
       
   185 	TPckgBuf<TSoIfConnectionInfo> iImplicitNotifyInfo;
       
   186 	MImplicitConnectionNotify::TEvent iImplicitNotifyEvent;
       
   187 	};
       
   188 
       
   189 #endif
       
   190