internetradio2.0/networkcontrollerinc/irnetworkcontroller.h
changeset 0 09774dfdd46b
child 11 f683e24efca3
equal deleted inserted replaced
-1:000000000000 0:09774dfdd46b
       
     1 /*
       
     2 * Copyright (c) 2006-2008 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:  Controls the network interface(s) for Internet Radio.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CIRNETWORKCONTROLLER_H
       
    20 #define CIRNETWORKCONTROLLER_H
       
    21 
       
    22 #include <badesca.h>
       
    23 #include <es_sock.h>
       
    24 #include <rhttpsession.h>
       
    25 
       
    26 //Added for ALR/SNAP
       
    27 #include <cmmanager.h>
       
    28 #include <connpref.h>
       
    29 #include <commdbconnpref.h>
       
    30 #include <comms-infras/cs_mobility_apiext.h>
       
    31 #include "iractivenetworkobserver.h"
       
    32 
       
    33 
       
    34 #include "irnetworkcontrollerobserver.h"
       
    35 #include "irdatatransfertracker.h"
       
    36 
       
    37 class CIRNetworkObserver;
       
    38 class CIRSettings;
       
    39 class MIRActiveNetworkObserver;
       
    40 
       
    41 typedef RArray<TUint32> RDestinationArray;
       
    42 
       
    43 //Added for ALR/SNAP
       
    44 enum TUserDefinedSelection
       
    45    {
       
    46     EUserDefinedSelectionAlwaysAsk = 0,
       
    47     EUserDefinedSelectionDefaultConnection,
       
    48     EUserDefinedSelectionDestination,
       
    49     EUserDefinedSelectionConnectionMethod
       
    50     };
       
    51     
       
    52     
       
    53 namespace CommsDat
       
    54     {
       
    55     class CMDBSession;
       
    56     }
       
    57 
       
    58 using namespace CommsDat;
       
    59 
       
    60 /**
       
    61  * This class provides the interface to IRNetworkController component
       
    62  *
       
    63  * @code
       
    64  * // CIRNetworkController follows a singleton pattern
       
    65  * // hence the destructor is private and to destroy it we need to use an API
       
    66  * // For creating a network controller which has provision for network monitoring
       
    67  * // we need to pass the reference of the observer which should derive from
       
    68  * // MIRNetworkControllerObserver class the network even observed will be
       
    69  * // indicated to the observer with the call back IRNetworkEvent() function
       
    70  * CIRNetworkController* iNetworkController = CIRNetworkController::NewL(iObserver)
       
    71  *
       
    72  * // For creating a network controller which does not have provision for network monitoring
       
    73  * // we use the overloaded NewL() of CIRNetworkController
       
    74  * CIRNetworkController* iNetworkController = CIRNetworkController::NewL()
       
    75  *
       
    76  * // This API is used to destroy the network controller handle
       
    77  * iNetworkController->DestroyNetworkController();
       
    78  *
       
    79  * // This API returns the instance of RConnection
       
    80  * // The same RConnection object is used across the entire iRAPP components to
       
    81  * // provide central arbiter and monitoring of Network Connection
       
    82  * iNetworkController->GetIRConnection();
       
    83  *
       
    84  * // This API returns the instance of RSocketServ
       
    85  * // The same RSocketServ object is used across the entire iRAPP components to
       
    86  * // provide central arbiter and monitoring of Network Connection
       
    87  * iNetworkController->GetIRSocketServer();
       
    88  *
       
    89  * // This API returns a pointer to the x-wap-profile string.
       
    90  * // The ownership of the object is passed onto the caller
       
    91  * iNetworkController->GetWapProfString();
       
    92  *
       
    93  * // This API returns a pointer to the UAProf string.
       
    94  * // The ownership of the object is passed onto the caller
       
    95  * iNetworkController->GetUAProfString();
       
    96  *
       
    97  * // This API returns ETrue of network connection is up and running EFalse
       
    98  * // otherwise
       
    99  * iNetworkController->GetNetworkStatus();
       
   100  *
       
   101  * // This API returns the IAP id of the connected connection
       
   102  * // this is used by download manager for choosing the access point
       
   103  * iNetworkController->GetIAPId();
       
   104  *
       
   105  * // This API returns the list of available access points
       
   106  * iNetworkController->GetAccessPointList();
       
   107  *
       
   108  * // This API returns the list of bearer ids for available access points
       
   109  * iNetworkController->GetBearerList();
       
   110  *
       
   111  * // This API returns the list of network ids for available access points
       
   112  * iNetworkController->GetNetworkList();
       
   113  *
       
   114  * // This API returns the list of iap ids for available access points
       
   115  * iNetworkController->GetApList();
       
   116  *
       
   117  * // This API is called to initiate access point selection
       
   118  * iNetworkController->ChooseAccessPointL();
       
   119  *
       
   120  * // This API returns ETrue if the phone is in offline mode, EFalse
       
   121  * // otherwise
       
   122  * iNetworkController->IsOfflineMode();
       
   123  *
       
   124  * // This API returns ETrue if WLan is supported on the device, EFalse
       
   125  * // otherwise
       
   126  * iNetworkController->IsWlanSupported();
       
   127  *
       
   128  * // This API allows the caller to reset the network connection status
       
   129  * iNetworkController->ResetConnectionStatus();
       
   130  *
       
   131  * // This API returns the type of connection open
       
   132  * iNetworkController->IdentifyConnectionType();
       
   133  *
       
   134  * @endcode
       
   135  *
       
   136  */
       
   137 
       
   138 NONSHARABLE_CLASS(CIRNetworkController): public CActive, 
       
   139 										 public MIRDataTransferObserver,
       
   140 									     public MMobilityProtocolResp
       
   141 	{
       
   142 
       
   143 public:
       
   144 
       
   145 	/**
       
   146 	 *  Creates an Instance of CIRNetworkController
       
   147 	 *  @return CIRNetworkController*
       
   148 	 */
       
   149 	IMPORT_C static CIRNetworkController* OpenL(MIRNetworkController* aObserver = NULL);
       
   150 
       
   151 	/**
       
   152 	 *  Conditionally destroys the IRNetworkController object
       
   153 	 */
       
   154 	IMPORT_C void Close();
       
   155 
       
   156 	/**
       
   157 	 *  Default C++ Destructor
       
   158 	 */
       
   159 	~CIRNetworkController();
       
   160 
       
   161 	/**
       
   162 	 *  Returns the instance of RConnection
       
   163 	 *  The same RConnection object is used across the entire iRAPP components to
       
   164 	 *  provide central arbiter and monitoring of Network Connection
       
   165 	 *  @return RConnection&
       
   166 	 */
       
   167 	IMPORT_C RConnection& GetIRConnection();
       
   168 
       
   169 	/**
       
   170 	 *  Returns the instance of RSocketServ
       
   171 	 *  The same RSocketServ object is used across the entire iRAPP components to
       
   172 	 *  provide central arbiter and monitoring of Network Connection
       
   173 	 *  @return RSocketServ&
       
   174 	 */
       
   175 	IMPORT_C RSocketServ& GetIRSocketServer();
       
   176 
       
   177 	/**
       
   178 	 *  Returns a HBufC pointer to the x-wap-profile string
       
   179 	 *  Transfers the ownership of the returned HBufC8 object
       
   180 	 *  The caller must takecare of deleting the returned object
       
   181 	 *  @return HBufC8*
       
   182 	 */
       
   183 	IMPORT_C HBufC8* GetWapProfString();
       
   184 
       
   185 	/**
       
   186 	 *  Returns a HBufC pointer to the UAProf string
       
   187 	 *  Transfers the ownership of the returned HBufC8 object
       
   188 	 *  The caller must takecare of deleting the returned object
       
   189 	 *  @return HBufC8*
       
   190 	 */
       
   191 	IMPORT_C HBufC8* GetUAProfString();
       
   192 
       
   193 	/**
       
   194 	 *  Returns the variable which indicates if connection is active or not
       
   195 	 *  @return TBool iIsConnectedToNetwork
       
   196 	 */
       
   197 	IMPORT_C TBool GetNetworkStatus() const;
       
   198 
       
   199 	/**
       
   200 	 *  Gets the IAP Id of the chosen IAP
       
   201 	 *  @return TInt Error code.
       
   202 	 */
       
   203 	IMPORT_C TInt GetIAPId(TUint32& aIapId) const;
       
   204 
       
   205 	/**
       
   206 	 *  Returns the list of available access points
       
   207 	 *  @return CDesCArray* array specifying the access point names
       
   208 	 */
       
   209 	IMPORT_C const CDesCArray* GetAccessPointList() const;
       
   210 
       
   211 	/**
       
   212 	 *  Returns the list of bearer ids for available access points
       
   213 	 *  @return const RArray<TUint32> array specifying the bearer ids
       
   214 	 */
       
   215 	IMPORT_C const RArray<TUint32> GetBearerList() const;
       
   216 
       
   217 	/**
       
   218 	 *  Returns the list of network ids for available access points
       
   219 	 *  @return const RArray<TUint32> array specifying the network ids
       
   220 	 */
       
   221 	IMPORT_C const RArray<TUint32> GetNetworkList() const;
       
   222 
       
   223 	/**
       
   224 	 *  Returns the list of iap ids for available access points
       
   225 	 *  @return const RArray<TUint32> array specifying the iap ids
       
   226 	 */
       
   227 	IMPORT_C const RArray<TUint32> GetApList() const;
       
   228 
       
   229 	/**
       
   230 	 *  Configures the Access Point which is used by all the components for network connectivity
       
   231 	 */
       
   232 	IMPORT_C void ChooseAccessPointL(TBool aDefaultConnection = ETrue);
       
   233 
       
   234 	/*
       
   235 	 * cancel configuring access point
       
   236 	 */
       
   237 	IMPORT_C void CancelConnecting();
       
   238 	
       
   239 	/**
       
   240 	 *  This api is used to determine if the phone is in offline mode
       
   241 	 *  @return ETrue if the phone is in offline mode else EFalse
       
   242 	 */
       
   243 	IMPORT_C TBool IsOfflineMode();
       
   244 
       
   245 	/**
       
   246 	 *  This api is used to determine if the phone supports WLan usage
       
   247 	 *  @return ETrue if the phone supports else EFalse
       
   248 	 */
       
   249 	IMPORT_C TBool IsWlanSupported() const;
       
   250 
       
   251 	/**
       
   252 	 *  Reset the connection status to Disconnected state
       
   253 	 */
       
   254 	IMPORT_C  void ResetConnectionStatus();
       
   255 
       
   256 	/**
       
   257 	 *  Used to determine the type of connection
       
   258 	 *  @return enum describing the type of connection ( GPRS/3G/WiFi )
       
   259 	 */
       
   260 	IMPORT_C TIRConnectionType IdentifyConnectionType() const;
       
   261 
       
   262 	/**
       
   263 	 *  Binds DataTranseferTracker instance to HTTPSession (Byte Counter Impl)
       
   264 	 */
       
   265 	IMPORT_C  void InitializeHttpSessionL(const RHTTPSession& aHTTPSession, 
       
   266 						MIRDataTransferTracker::TIRTransferCategory aCategory );
       
   267 
       
   268 	/**
       
   269 	 *  Binds LogoDataTranseferTracker instance to Logo HTTPSession (Byte Counter Impl)
       
   270 	 */
       
   271 	IMPORT_C  void RegisterLogoDataTransferTrackerL( RHTTPSession& aHTTPSession );
       
   272 
       
   273 	/**
       
   274 	 *  DataTranseferTracker instance for observers and Raw sockets (Byte Counter Impl)
       
   275 	 */
       
   276 	IMPORT_C  MIRDataTransferTracker& DataTransferTracker();
       
   277 
       
   278 	/**
       
   279 	 *  LogoDataTranseferTracker instance for observers and Raw sockets (Byte Counter Impl)
       
   280 	 */
       
   281 	IMPORT_C  MIRDataTransferTracker& LogoDataTransferTracker();
       
   282 
       
   283 	/**
       
   284 	 *  Method to receive notification when logo is downloaded
       
   285 	 */
       
   286 	void HandleDataTransferEventL( const MIRDataTransferTracker::TIRDataTransferPckg& aData );
       
   287 
       
   288 	/*
       
   289 	 * Registers the observer that will be notified for 
       
   290 	 * a network connection.
       
   291 	 * Observer requires notification to reissue pending request
       
   292 	 */ 
       
   293 	IMPORT_C  void RegisterActiveNetworkObserverL(MIRActiveNetworkObserver& aActiveNetworkObserver);
       
   294 
       
   295 	/**
       
   296 	 * DeleteRoamingObserver()
       
   297 	 * Used to remove an observer for roaming events from the observer array
       
   298 	 */
       
   299 	IMPORT_C void DeleteActiveNetworkObserver(MIRActiveNetworkObserver& aActiveNetworkObserver);
       
   300 		
       
   301 	/**
       
   302 	 * Notifies all observers whose network request is active
       
   303 	 * to reissue the request  
       
   304 	 * NotifyActiveNetworkObserversL()
       
   305 	 */	
       
   306 	IMPORT_C  void NotifyActiveNetworkObserversL(TIRNetworkEvent aEvent);
       
   307 	 
       
   308 	 
       
   309 	 /**
       
   310 	 * Notifies all observers whose network request is active
       
   311 	 * to reset the pending request status  
       
   312 	 * ResetPendingRequests()
       
   313 	 */	
       
   314 	 void ResetPendingRequests(TBool aValue);
       
   315 
       
   316 protected:
       
   317 
       
   318 	/**
       
   319 	 *  Derived from CActive
       
   320 	 */
       
   321 
       
   322 	/**
       
   323 	 * The function is called by the active scheduler when a request completion event occurs,
       
   324 	 */
       
   325 	virtual void RunL();
       
   326 
       
   327 	/**
       
   328 	 *  Cancels the pending requests on the CIRNetworkController Active object
       
   329 	 */
       
   330 	virtual void DoCancel();
       
   331 	
       
   332 	
       
   333 public: // From MMobilityProtocolResp		//to be changed to private after demo
       
   334 
       
   335 			//Added for ALR/SNAP
       
   336 		void PreferredCarrierAvailable( TAccessPointInfo aOldAPInfo,
       
   337 			TAccessPointInfo aNewAPInfo,
       
   338 			TBool aIsUpgrade,
       
   339 			TBool aIsSeamless );
       
   340 		void NewCarrierActive( TAccessPointInfo aNewAPInfo, TBool aIsSeamless );
       
   341 		void Error( TInt aError );	
       
   342 		
       
   343 public:
       
   344 		/**
       
   345 		 * IsHandingOverConnection()
       
   346 		 * Indicates if the Hand over of Network connection has happened
       
   347 		 */
       
   348 		IMPORT_C TBool IsHandingOverConnection();
       
   349 		
       
   350 		void ResetHandingOverConnection();
       
   351 		
       
   352 private:
       
   353 
       
   354 	/**
       
   355 	 *  Used to determine the current profile
       
   356 	 *  @return TInt describing the profile value
       
   357 	 */
       
   358 	TInt DetermineCurrentProfile() const;
       
   359 
       
   360 	/**
       
   361 	 *  Pops up the access point list.
       
   362 	 *  @return TBool ETrue feature is supported EFalse otherwise
       
   363 	 */
       
   364 	TBool CheckFeatureL(TInt aFeatureId) const;
       
   365 
       
   366 	/**
       
   367 	 *  Default C++ Constructor
       
   368 	 */
       
   369 	CIRNetworkController();
       
   370 
       
   371 	/**
       
   372 	 *  Second Phase construction.
       
   373 	 */
       
   374 	void ConstructL();
       
   375 
       
   376 	/**
       
   377 	 *  Second Phase construction.
       
   378 	 *	@param aObserver pointer to the observer class if an observer is needed
       
   379 	 */
       
   380 	void ConstructL( MIRNetworkController* aObserver );
       
   381 
       
   382 	/**
       
   383 	 *  Determines the available access points using CommsDat Api
       
   384 	 */
       
   385 	void QueryCommsForIAPL();
       
   386 
       
   387 	/**
       
   388 	 *  Queries the system and extracts the UAProf information
       
   389 	 *  Used by IRDataProvider and IRStreamSource
       
   390 	 */
       
   391 	void BuildUAProfStringL();
       
   392 
       
   393 	/**
       
   394 	 *  Retrievs the string from Central Repository for the specified key and cen rep uid
       
   395 	 *  Transfers the ownership of the returned HBufC object
       
   396 	 *  The caller must takecare of deleting the returned object*
       
   397 	 *	@param aRepositoryUid specifies the Uid of the repository to be used
       
   398 	 *	@param aKey specifies the key to be used
       
   399 	 *	@return HufC* pointer to the retrieved string
       
   400 	 */
       
   401 	HBufC* CentralRepositoryStringValueL(const TUid& aRepositoryUid,
       
   402 		TUint32 aKey ) const;
       
   403 
       
   404 	/**
       
   405 	 *  Pops up the access point list.
       
   406 	 *  @return TBool ETrue is we need to proceed with access point selection EFalse otherwise
       
   407 	 */
       
   408 	TBool DisplayAccessPointListL();
       
   409 
       
   410 	/**
       
   411 	 *  Validates the access point availablity etc.
       
   412 	 */
       
   413 	TBool ValidateAccessPointsL();
       
   414 
       
   415 	/**
       
   416 	 *  Handles the success case of Network connection in RunL
       
   417 	 */
       
   418 	void HandleRunLSuccessL();
       
   419 	
       
   420 	/**
       
   421 	 *  Handles the error case of Network connection in RunL
       
   422 	 */
       
   423 	void HandleRunLErrorL(TInt aStatusCode);
       
   424 	
       
   425 public:
       
   426 	/**
       
   427 	 * Indicates if ChooseAccessPointL is called
       
   428 	 */
       
   429 	TBool iIsConnectRequestIssued;
       
   430 
       
   431 private:
       
   432     /**
       
   433      * This is the physical connection we are putting up
       
   434      */
       
   435 	RConnection* iIRNetworkConnection;
       
   436 
       
   437 	/**
       
   438      * Actual RSocketServ instance
       
   439      */
       
   440    	RSocketServ iIRSocketServer;
       
   441 
       
   442 	/**
       
   443      * Number of objects currently referring to the singleton object CIRNetworkController
       
   444      */
       
   445 	TInt iSingletonInstances;
       
   446 
       
   447 	/**
       
   448      * Used to access Settings object
       
   449      */
       
   450 	CIRSettings* iIRSettings;
       
   451 
       
   452 	/**
       
   453      * IR Network component observer
       
   454      */
       
   455 	MIRNetworkController* iObserver;
       
   456 
       
   457 	/**
       
   458 	 * Enum declaration which indicate the network status
       
   459 	 */
       
   460 	enum TIRNetworkConnectionStatus
       
   461 		{
       
   462 		EIRNetworkConnectionActive = 1,
       
   463 		EIRNetworkConnectionInActive
       
   464 		};
       
   465 
       
   466 	/**
       
   467 	 * Variable to keep track of the RConnection connection status
       
   468 	 */
       
   469 	TIRNetworkConnectionStatus iNetworkConnectionState;
       
   470 
       
   471 	/**
       
   472 	 * Enum declaration which indicate the connection to RSocketServ status
       
   473 	 */
       
   474 	enum TIRSocketServerConnectionStatus
       
   475 		{
       
   476 		EIRSocketServerActive = 1,
       
   477 		EIRSocketServerInActive
       
   478 		};
       
   479 
       
   480 	/**
       
   481 	 * Variable to keep track of the RSocketServ connection status
       
   482 	 */
       
   483 	TIRSocketServerConnectionStatus iSocketServerConnectionState;
       
   484 
       
   485 	/**
       
   486 	 * Enum declaration to indicate the NetworkController state
       
   487 	 */
       
   488 	enum TIRNetworkControllerState
       
   489 		{
       
   490 		EInActive = 1,
       
   491 		EConnectingToNetwork
       
   492 		};
       
   493 
       
   494 	/**
       
   495 	 * Specifies the Network controller state
       
   496 	 */
       
   497 	TIRNetworkControllerState iNetworkControllerState;
       
   498 
       
   499 	/**
       
   500 	 * Indicates the current network connection status
       
   501 	 */
       
   502 	TBool iIsConnectedToNetwork;
       
   503 
       
   504 	/**
       
   505 	 * Network observer
       
   506 	 */
       
   507 	CIRNetworkObserver* iIRNetworkObserver;
       
   508 
       
   509 	/**
       
   510 	 * Pointer to UAProf string
       
   511 	 */
       
   512 	HBufC8* iIRUAProf;
       
   513 
       
   514 	/**
       
   515 	 * Pointer to x-wap-profile string
       
   516 	 */
       
   517 	HBufC8* iIRWapProf;
       
   518 
       
   519 	/**
       
   520 	 * Access point list for settings view
       
   521 	 */
       
   522 	CDesCArrayFlat* iIapList;
       
   523 
       
   524 	/**
       
   525 	 * Array of bearer ids for access points
       
   526 	 */
       
   527 	RArray<TUint32> iBearerList;
       
   528 
       
   529 	/**
       
   530 	 * Array of network ids for access points
       
   531 	 */
       
   532 	RArray<TUint32> iNetworkList;
       
   533 
       
   534 	/**
       
   535 	 * Array of iap ids for access points
       
   536 	 */
       
   537 	RArray<TUint32> iIapIdList;
       
   538 
       
   539 	/**
       
   540 	 * Indicates if WiFi is supported or not
       
   541 	 */
       
   542 	TBool iIsWlanSupported;
       
   543 
       
   544 	/**
       
   545 	 * Used to determine if connection is open or not
       
   546 	 */
       
   547 
       
   548 	TBool iConnectionPresent;
       
   549 
       
   550 	/**
       
   551 	 * Tracks data transferred over the network for the connection.
       
   552 	 * Owned.
       
   553 	 */
       
   554 
       
   555 	CIRDataTransferTracker* iDataTransferTracker;
       
   556 
       
   557 	/**
       
   558 	 * Tracks data transferred over the network for the Logo session.
       
   559 	 * Owned.
       
   560 	 */
       
   561 
       
   562 	CIRDataTransferTracker* iLogoDataTransferTracker;
       
   563 	
       
   564 	
       
   565 	//Added for ALR/SNAP
       
   566 	
       
   567 	/**
       
   568     * Observes the preferred network within defined destination
       
   569     */
       
   570 	CActiveCommsMobilityApiExt* iMobility;
       
   571 	
       
   572 
       
   573 	/**
       
   574      * ETrue if the ALR handover is ongoing
       
   575      */
       
   576     TBool iHandingOver;
       
   577     
       
   578     
       
   579     /**
       
   580 	 * Array of observers for change in roaming events
       
   581 	 */
       
   582 	RPointerArray<MIRActiveNetworkObserver> iActiveNetworkObserverArray;
       
   583 	
       
   584 	TBool iDefaultConnection;
       
   585 	};
       
   586 
       
   587 #endif //CIRNETWORKCONTROLLER_H