bearermanagement/mpm/inc/mpmiapselection.h
changeset 0 5a93021fdf25
child 12 ea6e024ea6f9
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     1 /*
       
     2 * Copyright (c) 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: Handles IAP selection logic
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef MPMIAPSELECTION_H
       
    19 #define MPMIAPSELECTION_H
       
    20 
       
    21 #include <e32base.h>
       
    22 
       
    23 #include "mpmserversession.h"
       
    24 #include "mpmcommsdataccess.h"
       
    25 #include "mpmwlanavailability.h"
       
    26 
       
    27 class CMPMDialog;
       
    28 class CMPMWlanQueryDialog;
       
    29 class CMPMConfirmDlgStarting;
       
    30 class MWlanAvailability;
       
    31 class TMpmConnPref;
       
    32 
       
    33 enum TOfflineNoteResponse
       
    34     {
       
    35     EOfflineResponseUndefined,
       
    36     EOfflineResponseYes,
       
    37     EOfflineResponseNo
       
    38     };
       
    39 
       
    40 /**
       
    41  * Handles IAP selection. MPM Server session
       
    42  * uses the class to select the best available 
       
    43  * IAP.
       
    44  *
       
    45  *  @lib mpmserver.exe
       
    46  *  @since S60 v3.2
       
    47  */
       
    48 class CMPMIapSelection : public CBase,
       
    49                          public MWlanAvailability
       
    50     {
       
    51 
       
    52 public:
       
    53     // Enumeration describes session state at choosing best IAP.
       
    54     // Choosing best IAP may use asyncrous services and once 
       
    55     // and these states define at which point the choosing iap is
       
    56     // proceeding.
       
    57     // 
       
    58     enum TChooseIapState
       
    59         {
       
    60         ENoConnection,
       
    61         EExplicitConnection,
       
    62         EImplicitConnection
       
    63         };
       
    64 
       
    65     enum TImplicitConnectionState
       
    66         {
       
    67         EImplicitStart,
       
    68         EImplicitWlanScan,
       
    69         EImplicitUserSelection,
       
    70         EImplicitWlanQuery
       
    71         };
       
    72 
       
    73 
       
    74 public: // CMPMServerSession interface    
       
    75     /**
       
    76      * Two-phased constructor.
       
    77      */
       
    78     static CMPMIapSelection* NewL( CMPMCommsDatAccess*  aCommsDatAccess,
       
    79                                    CMPMServerSession*   aSession );
       
    80     
       
    81     /**
       
    82      * Destructor.
       
    83      */
       
    84     virtual ~CMPMIapSelection();
       
    85 
       
    86     /**
       
    87      * Chooses best available IAP when connection is starting.
       
    88      * @param aChooseIapPref Connection preferences.
       
    89      *
       
    90      * @since S60 v3.2
       
    91      */
       
    92     void ChooseIapL( const TMpmConnPref& aChooseIapPref );
       
    93 
       
    94     /**
       
    95      * Handles IAP selection for explicit connection.
       
    96      * If necessary performs Wlan scan. 
       
    97      *
       
    98      * @since S60 v3.2
       
    99      */
       
   100     void ExplicitConnectionL();
       
   101 
       
   102     /**
       
   103      * Updates connection dialog contents if 
       
   104      * the dilog is shown
       
   105      *
       
   106      * @since S60 v3.2
       
   107      */
       
   108     void UpdateConnectionDialogL();
       
   109 
       
   110 public:
       
   111     /**
       
   112      * Starts Wlan query if Iap is wlan iap.
       
   113      *
       
   114      * @param aIapId Id of Iap
       
   115      * @param aIsRoaming True if wlan query is for roaming
       
   116      * @return ETrue if wlan query was started
       
   117      * @since S60 v3.2
       
   118      */
       
   119     TBool StartWlanQueryIfNeededL(
       
   120         TUint32 aIapId,
       
   121         TBool aIsRoaming = EFalse );
       
   122 
       
   123     /**
       
   124      * Part of selecting best IAP at connection start. Called when WLAN scan
       
   125      * is completed. Continues IAP selection according to the iChooseIapState.
       
   126      *
       
   127      * @since 3.1
       
   128      * @param aStatus Error code of completing the request.
       
   129      */
       
   130     void ChooseIapWLANScanCompletedL( TInt aStatus );
       
   131 
       
   132     /**
       
   133      * Completing choose iap request. Uses corresponding function
       
   134      * of CMPMServerSession
       
   135      *
       
   136      * @since 3.2
       
   137      * @param aError Message status
       
   138      * @param aPolicyPref Policy preference to be returned, NULL if no 
       
   139      * preference should be passed
       
   140      */
       
   141     void ChooseIapComplete( TInt aError, const TMpmConnPref* aPolicyPref );
       
   142 
       
   143     /**
       
   144      * Callback function used after Wlan network has been selected. 
       
   145      * Uses HandleUserIapSelectionL to complete IAP selection.
       
   146      *
       
   147      * @since 3.2
       
   148      * @param aError Error code from selection
       
   149      * @param aIapId Element id of IAP record if different than reported before. 
       
   150      * May be 0, when error occurred in selection or when no new Iap id is set.
       
   151      *
       
   152      */
       
   153     void UserWlanSelectionDoneL( TInt aError, TUint32 aIapId );
       
   154 
       
   155     /**
       
   156      * Stops displaying the starting dialog.
       
   157      *
       
   158      * @since 3.2
       
   159      */
       
   160     void StopDisplayingStartingDlg();
       
   161 
       
   162     /**
       
   163      * Selects the best IAP for the connection.
       
   164      *
       
   165      * @since 3.0
       
   166      * @param aMpmConnPref Connection preferences
       
   167      * @param aAvailableIAPs Array of available IAPs
       
   168      * @return KErrNone if successful, otherwise one of the
       
   169      * system-wide error codes
       
   170      */
       
   171     void ChooseBestIAPL( TMpmConnPref&          aMpmConnPref,
       
   172                          const RArray<TUint32>& aAvailableIAPs);
       
   173 
       
   174     /**
       
   175      * Selects the best IAP for the connection.
       
   176      * @since 3.2
       
   177      * @param aMpmConnPref Connection preferences.
       
   178      * @param aAvailableIAPs Array of available IAPs.
       
   179      * @param aNextBestExists ETrue if there is another available 
       
   180      * IAP inside the destination that could be used.
       
   181      * @return KErrNone if successful, otherwise one of the
       
   182      * system-wide error codes.
       
   183      */
       
   184     void ChooseBestIAPL( TMpmConnPref&           aMpmConnPref,
       
   185                          const RArray<TUint32>&  aAvailableIAPs, 
       
   186                          TBool&                  aNextBestExists );
       
   187 
       
   188     /**
       
   189      * Sets confirmation dialog ponter to NULL.
       
   190      *
       
   191      * @since 3.0
       
   192      */
       
   193     void SetConfirmDlgStartingPtrNull();
       
   194 
       
   195     /**
       
   196      * Returns reference to CMPMServerSession
       
   197      *
       
   198      * @since S60 3.2
       
   199      */
       
   200     CMPMServerSession* Session();
       
   201 
       
   202     /**
       
   203      * Handles user IAP/SNAP selection error and completes the request.
       
   204      *
       
   205      * @since 3.2
       
   206      * @param aError Error value 
       
   207      *
       
   208      */
       
   209     void HandleUserSelectionError( TInt aError );
       
   210 
       
   211     /**
       
   212      * Handles user IAP/SNAP selection and completes the request.
       
   213      *
       
   214      * @since 3.2
       
   215      * @param aIsIap ETrue if selection is iap
       
   216      * @param aId Id of IAP or SNAP record. May be 0, when error
       
   217      * occurred in selection
       
   218      * @param aError Error value 
       
   219      *
       
   220      */
       
   221     void HandleUserSelectionL( TBool aIsIap, TUint32 aId, TInt aError  );
       
   222 
       
   223     /**
       
   224      * Returns the stored user response to the offline note
       
   225      * @since 3.2
       
   226      */
       
   227     TOfflineNoteResponse OfflineNoteResponse();
       
   228 
       
   229     /**
       
   230      * Stores the user response to the offline note
       
   231      * @since 3.2
       
   232      * @param aResponse Offline note response
       
   233      */
       
   234     void SetOfflineNoteResponse( TOfflineNoteResponse aResponse );
       
   235 
       
   236     /**
       
   237      * Iap selection is notified that conenction is started. 
       
   238      * Offline note response is reseted.
       
   239      *
       
   240      * @since 3.2
       
   241      */
       
   242     void ConnectionStarted();
       
   243     
       
   244     /**
       
   245      * Triggers an information note. Note disappears automatically. 
       
   246      *
       
   247      * @since 5.2
       
   248      */
       
   249     void TriggerInformationNoteL();
       
   250 
       
   251     /**
       
   252      * Get original MPM connection preferences
       
   253      * @since 5.2
       
   254      */
       
   255      TMpmConnPref MpmConnPref();
       
   256      
       
   257      /**
       
   258       * Completing implicit connection.
       
   259       * @since 3.2
       
   260       */
       
   261      void CompleteImplicitConnectionL();
       
   262          
       
   263 
       
   264     // internal functions
       
   265 private:
       
   266     /**
       
   267      * Handles IAP selection for implicit connection.
       
   268      * If necessary performs Wlan scan. 
       
   269      *
       
   270      * @since 3.2
       
   271      *
       
   272      */
       
   273     void ImplicitConnectionCheckWlanScanNeededL();
       
   274 
       
   275     /**
       
   276      * Completes IAP selection with explicit 
       
   277      * SNAP connection. If necessary, displays 
       
   278      * confirmation query.
       
   279      *
       
   280      * @since S60 v3.2
       
   281      */
       
   282     void CompleteExplicitSnapConnectionL();
       
   283 
       
   284     /**
       
   285      * Check whether GPRS services are allowed or not.
       
   286      * @since 3.2
       
   287      * @param aIapLanOrWlan IAP service type is either LANService or not 
       
   288      * @return ETrue if GPRS services are allowed
       
   289      */
       
   290     TBool CheckGprsServicesAllowedL( TBool aIapLanOrWlan );
       
   291 
       
   292     /**
       
   293      * Handles implicit connection IAP selection
       
   294      * @since 3.2
       
   295      */
       
   296     void ImplicitConnectionIapSelectionL();
       
   297 
       
   298     /**
       
   299      * Handles implicit connection start
       
   300      * @since 3.2
       
   301      */
       
   302     void ImplicitConnectionL();
       
   303 
       
   304     /**
       
   305      * Handles implicit connection wlan note displaying
       
   306      * @since 3.2
       
   307      */
       
   308     void ImplicitConnectionWlanNoteL();
       
   309     
       
   310 private: // from MWlanAvailability
       
   311 
       
   312        /**
       
   313        * WLAN availability check response
       
   314        * @since 3.2
       
   315        * @param aError generic Symbian error response code
       
   316        * @param aResult Result of WLAN availability check
       
   317        * @return void
       
   318        */
       
   319        void WlanAvailabilityResponse( const TInt  aError, 
       
   320                                       const TBool aResult );
       
   321 
       
   322 private:
       
   323 
       
   324     /**
       
   325      * C++ default constructor.
       
   326      */
       
   327     CMPMIapSelection( CMPMCommsDatAccess*   aCommsDatAccess,
       
   328                       CMPMServerSession*    aSession );
       
   329 
       
   330     /**
       
   331      * ConstructL
       
   332      */
       
   333     void ConstructL();
       
   334 
       
   335 private:
       
   336 
       
   337     // Connection preferences used for connection selection.
       
   338     // This is stored when ChooseIapL() is called and is used by methods 
       
   339     // selecting the best iap. This member variable is also used 
       
   340     // to store selection before writing it back to client message.
       
   341     TMpmConnPref iChooseIapPref;
       
   342 
       
   343     // Keeps state of choosing iap
       
   344     TChooseIapState iChooseIapState;
       
   345 
       
   346     // Used for commsdat related functionalities
       
   347     CMPMCommsDatAccess* iCommsDatAccess;
       
   348 
       
   349     // Contains state info whether PrefIapnotifs can be sent 
       
   350     // and saved IAP info structure.
       
   351     TStoredIapInfo iStoredIapInfo;
       
   352 
       
   353     // Stored available Iaps
       
   354     RAvailableIAPList iStoredAvailableIaps;
       
   355 
       
   356     // pointer to Session
       
   357     CMPMServerSession* iSession;
       
   358 
       
   359     // Pointer to Confirmation dialog.
       
   360     CMPMConfirmDlgStarting* iConfirmDlgStarting;
       
   361 
       
   362     // Pointer to the dialog active object.
       
   363     CMPMDialog* iDialog;
       
   364 
       
   365     // Pointer to Wlan query dialog.
       
   366     CMPMWlanQueryDialog* iWlanDialog;
       
   367 
       
   368     // Stores the boolean value whether next best iaps 
       
   369     // exists in explicit connection start.
       
   370     TBool iNextBestExists;
       
   371 
       
   372     // Iap selected by user.
       
   373     TUint32 iUserSelectionIapId;
       
   374 
       
   375     // Snap selected by user.
       
   376     TUint32 iUserSelectionSnapId;
       
   377 
       
   378     // State of impilict connection start
       
   379     TImplicitConnectionState iImplicitState;
       
   380 
       
   381     // Offline note response for the connection. 
       
   382     // Offline note must be displayed only once 
       
   383     // during the connection (not for each wlan iap of a snap).
       
   384     TOfflineNoteResponse iOfflineNoteResponse;
       
   385 
       
   386     // True if connection is roaming (set when displaying offline note)
       
   387     TBool iIsRoaming;
       
   388 
       
   389     // True if user has selected "Known and new" for join wlan networks
       
   390 	// setting in Connectivity settings plugin.
       
   391     TBool iNewWlansAllowed;
       
   392     };
       
   393 
       
   394 #endif // MPMIAPSELECTION_H