datacommsserver/networkcontroller/src/CNetConRequestBase.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     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 /**
       
    17  @file CNetConRequestBase.cpp
       
    18 */
       
    19 
       
    20 #include "CNetworkController.h"
       
    21 #include "CNetConRequestBase.h"
       
    22 #include "NetConPanic.h"
       
    23 #include "NetConLog.h"
       
    24 
       
    25 #include "CNetConDlgProcessor.h"
       
    26 
       
    27 CNetConRequestBase::~CNetConRequestBase()
       
    28 /**
       
    29 Destructor
       
    30 */
       
    31 	{
       
    32 	if (iDatabase)
       
    33 		{
       
    34 		iDatabase->CancelRequestNotificationOfServiceChange(ipServiceChangeObserver);
       
    35 		delete iDatabase;
       
    36 		}
       
    37 	delete iDialogPrc;
       
    38 	}
       
    39 
       
    40 CNetConRequestBase::CNetConRequestBase(MNetConEnv* aController, MNetworkControllerObserver* aObserver, CStoreableOverrideSettings* aOverrides)
       
    41 : iController(aController), iObserver(aObserver), iOverrides(aOverrides)
       
    42 /**
       
    43 Constructor
       
    44 
       
    45 @param aDatabase, allow the requests and bearers access to the database.
       
    46 @param aDialogPrc, allow the requests access to the dialog processor.
       
    47 @param aController, For upcalls from the requests.
       
    48 @param aObserver, define the reverse API - from a Network Controller towards NIFMAN
       
    49 @param aOverrides, store and retrieve override sets to and from both streams and buffers.
       
    50 */
       
    51 	{ }
       
    52 
       
    53 void CNetConRequestBase::ConstructL()
       
    54 	{
       
    55 	iDatabase = iController->NewDatabaseL();
       
    56 	__ASSERT_DEBUG(iDatabase, NetConPanic(NetworkController::ETelBearerBadState));
       
    57 	}
       
    58 
       
    59 void CNetConRequestBase::CancelRequest()
       
    60 /**
       
    61 Cancel this request
       
    62 */
       
    63 	{
       
    64 	// cancel any outstanding dialog processor activity
       
    65 	if (iDialogPrc)
       
    66 		{
       
    67 		iDialogPrc->CancelEverything();
       
    68 		}
       
    69 
       
    70 	// cancel any outstanding bearer availability check
       
    71 	iController->CancelBearerAvailabilityCheck();
       
    72 
       
    73 	// Cancel Service Change Notification
       
    74 	iDatabase->CancelRequestNotificationOfServiceChange(ipServiceChangeObserver);
       
    75 	}
       
    76 
       
    77 /**
       
    78 accessors
       
    79 send for customer input
       
    80 
       
    81 @return iObserver, a reverse API - from a Network Controller towards NIFMAN
       
    82 */
       
    83 MNetworkControllerObserver* CNetConRequestBase::Observer() const
       
    84 	{
       
    85 	return iObserver;
       
    86 	}
       
    87 
       
    88 /**
       
    89 accessors
       
    90 Network controller connection overrides.
       
    91 send for customer input
       
    92 
       
    93 @return iOverrides, override sets to and from both streams and buffers.
       
    94 */
       
    95 CStoreableOverrideSettings* CNetConRequestBase::Overrides() const
       
    96 	{
       
    97 	return iOverrides;
       
    98 	}
       
    99 
       
   100 TBool CNetConRequestBase::SelectedServiceAvailable(TUint32 aAvailableBearerSet) const
       
   101 /**
       
   102 The function checks whether the Selected Service is Available
       
   103 
       
   104 @param aAvailableBearerSet the set of available bearers
       
   105 @return ETrue if the selected service is available otherwise EFalse
       
   106 */
       
   107 	{
       
   108 
       
   109 	TBool available(EFalse);
       
   110 
       
   111 	if (iSettings.iServiceType == TPtrC(DIAL_OUT_ISP) || iSettings.iServiceType == TPtrC(DIAL_IN_ISP))
       
   112 		{
       
   113 		// user requested a CSD type connection but is the bearer available?
       
   114 		available = (aAvailableBearerSet & KCommDbBearerCSD);
       
   115 		}
       
   116 	if (iSettings.iServiceType == TPtrC(LAN_SERVICE))
       
   117 		{
       
   118 		// user requested a CDMA type connection but is the bearer available?
       
   119 		available = (aAvailableBearerSet & KCommDbBearerLAN);
       
   120 		}
       
   121 	if (iSettings.iServiceType == TPtrC(VPN_SERVICE))
       
   122 		{
       
   123 		// user requested a Vpn service...
       
   124 		available = (aAvailableBearerSet & KCommDbBearerVirtual );
       
   125 		}
       
   126 
       
   127 	if (available)
       
   128 		{
       
   129 		LOG( NetConLog::Printf(_L("\tSelected service is available")); )
       
   130 		}
       
   131 	else
       
   132 		{
       
   133 		LOG( NetConLog::Printf(_L("\tSelected service is not available")); )
       
   134 		}
       
   135 
       
   136 	return available;
       
   137 	}
       
   138 
       
   139 void CNetConRequestBase::SelectConnection(const TConnectionPrefs& aPrefs)
       
   140 /**
       
   141 Display a dialog to the user asking them to select an IAP to connect to
       
   142 
       
   143 MNetConDialogProcAccess Interface
       
   144 
       
   145 @param aObserver the object to receive notification when the dialog box completes
       
   146 @param aPrefs the connection preferences used to select this IAP
       
   147 */
       
   148 	{
       
   149 	const TInt err = ConstructDialogProcessor();
       
   150 	if( KErrNone != err )
       
   151 		{
       
   152 		TConnectionSettings settings;
       
   153 		MDPOSelectComplete(err, settings);
       
   154 		return;
       
   155 		}
       
   156 
       
   157 	iDialogPrc->SelectConnection(*this, aPrefs);
       
   158 	}
       
   159 
       
   160 void CNetConRequestBase::SelectConnection(const TConnectionPrefs& aPrefs, TInt aLastError)
       
   161 /**
       
   162 Display a dialog to the user asking them to select an IAP to connect to
       
   163 
       
   164 @param aObserver the object to receive notification when the dialog box completes
       
   165 @param aPrefs the connection preferences used to select this IAP
       
   166 @param aLastError if this is not the 1st connection attempt this is the error of the last attempt
       
   167 */
       
   168 	{
       
   169 	const TInt err = ConstructDialogProcessor();
       
   170 	if( KErrNone != err )
       
   171 		{
       
   172 		TConnectionSettings settings;
       
   173 		MDPOSelectComplete(err, settings);
       
   174 		return;
       
   175 		}
       
   176 
       
   177 	iDialogPrc->SelectConnection(*this, aPrefs, aLastError);
       
   178 	}
       
   179 
       
   180 void CNetConRequestBase::SelectModemAndLocation()
       
   181 /**
       
   182 Display a dialog to the user asking the user to select a modem and location entry from CommDb
       
   183 
       
   184 @param aObserver the object to receive notification when the dialog box completes
       
   185 */
       
   186 	{
       
   187 	const TInt err = ConstructDialogProcessor();
       
   188 	if( KErrNone != err )
       
   189 		{
       
   190 		TConnectionSettings settings;
       
   191 		MDPOSelectModemAndLocationComplete(err, settings);
       
   192 		return;
       
   193 		}
       
   194 
       
   195 	iDialogPrc->SelectModemAndLocation(*this);
       
   196 	}
       
   197 
       
   198 void CNetConRequestBase::WarnNewConnection(const TConnectionPrefs& aPrefs, const TDesC* aNewIapName, const TIspConnectionNames* aNewConnectionNames, TInt aLastError)
       
   199 /**
       
   200 Display a dialog to the user warning that a new connection is about to be attempted to the specified IAP
       
   201 
       
   202 @param aObserver the object to receive notification when the dialog box completes
       
   203 @param aPrefs the connection preferences used to select this IAP
       
   204 @param aNewIapName the name of the IAP used for the connection.
       
   205 @param aNewConnectionNames this parameter is no-longer used.
       
   206 @param aLastError if this is not the 1st connection attempt this is the error of the last attempt
       
   207 */
       
   208 	{
       
   209 	const TInt err = ConstructDialogProcessor();
       
   210 	if( KErrNone != err )
       
   211 		{
       
   212 		MDPOWarnComplete(err, EFalse);
       
   213 		return;
       
   214 		}
       
   215 
       
   216 	iDialogPrc->WarnNewConnection(*this, aPrefs, aNewIapName, aNewConnectionNames, aLastError);
       
   217 	}
       
   218 
       
   219 void CNetConRequestBase::Reconnect()
       
   220 /**
       
   221 Display a dialog to the user asking whether to reconnect a failed connection
       
   222 
       
   223 @param aObserver the object to receive notification when the dialog box completes
       
   224 */
       
   225 	{
       
   226 	const TInt err = ConstructDialogProcessor();
       
   227 	if( KErrNone != err )
       
   228 		{
       
   229 		MDPOReconnectComplete(err);
       
   230 		return;
       
   231 		}
       
   232 
       
   233 	iDialogPrc->Reconnect(*this);
       
   234 	}
       
   235 
       
   236 
       
   237 /**
       
   238 Ensure the request dialog processor is correctly constructed. Construct it if not.
       
   239 
       
   240 @return KErrNone on success, and error code otherwise
       
   241 */
       
   242 TInt CNetConRequestBase::ConstructDialogProcessor()
       
   243 	{
       
   244 	if (!iDialogPrc)
       
   245 		{
       
   246 		// construct dialog processor
       
   247 		TRAPD( err, iDialogPrc = iController->NewDialogProcessorL() );
       
   248 		return err;
       
   249 		}
       
   250 	__ASSERT_DEBUG(iDialogPrc, NetConPanic(NetworkController::ETelBearerBadState));
       
   251 	return KErrNone;
       
   252 	}
       
   253 
       
   254 /**
       
   255 Return the Request's internal database access pointer
       
   256 */
       
   257 CCommsDbAccess* CNetConRequestBase::DbAccess()
       
   258     {
       
   259 	__ASSERT_DEBUG(iDatabase, NetConPanic(NetworkController::ETelBearerBadState));
       
   260     return iDatabase;
       
   261     }
       
   262