datacommsserver/networkcontroller/src/CReconnectRequest.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 CReconnectRequest.cpp
       
    18 */
       
    19 
       
    20 #include "CReconnectRequest.h"
       
    21 #include <comms-infras/nifagt.h>
       
    22 #include "CNetworkController.h"
       
    23 #include "NetConPanic.h"
       
    24 #include "NetConLog.h"
       
    25 
       
    26 CReconnectRequest* CReconnectRequest::NewL(MNetConEnv* aController, MNetworkControllerObserver* aObserver, CNifAgentBase* aAgent, CStoreableOverrideSettings* aOverrides)
       
    27 /**
       
    28 static newL function allocates memory to an object of class CReconnectRequest
       
    29 
       
    30 @param aController, Used to inform the CNetworkController of state changes such as a request or a bearer availability check completing.
       
    31 @param aObserver, request the selection
       
    32 @param aAgent, the agent who's connection failed
       
    33 @param aOverrides, store and retrieve override sets to and from both streams and buffers.
       
    34 @return a  pointer to class CReconnectRequest
       
    35 @exception leaves if memory allocation fails.
       
    36 */
       
    37 	{
       
    38 	CReconnectRequest* self = new(ELeave) CReconnectRequest(aController, aObserver, aAgent, aOverrides);
       
    39 	CleanupStack::PushL(self);
       
    40 	self->ConstructL();
       
    41 	CleanupStack::Pop(); // self
       
    42 	return self;
       
    43 	}
       
    44 
       
    45 CReconnectRequest::CReconnectRequest(MNetConEnv* aController, MNetworkControllerObserver* aObserver, CNifAgentBase* aAgent, CStoreableOverrideSettings* aOverrides)
       
    46 : CNetConRequestBase(aController, aObserver, aOverrides), iAgent(aAgent)
       
    47 /**
       
    48 Constructor
       
    49 */
       
    50 	{ }
       
    51 
       
    52 void CReconnectRequest::ConstructL()
       
    53 	{
       
    54 	CNetConRequestBase::ConstructL();
       
    55 	}
       
    56 
       
    57 CReconnectRequest::~CReconnectRequest()
       
    58 /**
       
    59 Destuctor
       
    60 */
       
    61 	{ }
       
    62 
       
    63 void CReconnectRequest::StartRequest()
       
    64 /**
       
    65 start processing this request
       
    66 */
       
    67 	{
       
    68 	LOG( NetConLog::Printf(_L("\tRequest type = Reconnect")); )
       
    69 
       
    70 	// set overrides for this request in the databse
       
    71 	TRAPD(err, iDatabase->SetOverridesL(iOverrides);
       
    72                iDatabase->RequestNotificationOfServiceChangeL(ipServiceChangeObserver));
       
    73 
       
    74 	if(err!=KErrNone)
       
    75 		{
       
    76 		RequestComplete(err);
       
    77 		return;
       
    78 		}
       
    79 
       
    80 	TRAP(err, StartReconnectL());
       
    81 	if(err!=KErrNone)
       
    82 		{
       
    83 		RequestComplete(err);
       
    84 		}
       
    85 	}
       
    86 
       
    87 void CReconnectRequest::RequestComplete(TInt aError)
       
    88 /**
       
    89 Force premature completion of a request with a given error
       
    90 */
       
    91 	{
       
    92 
       
    93 	LOG( NetConLog::Printf(_L("\tRequest Complete with error %d"), aError); )
       
    94 
       
    95 	iController->RequestComplete(this, aError);
       
    96 	}
       
    97 
       
    98 void CReconnectRequest::StartReconnectL()
       
    99 /**
       
   100 Read current connection preferences and settings from the database then start the reconnection process. 
       
   101 
       
   102 @exception leaves if database access leaves
       
   103 */
       
   104 	{
       
   105 
       
   106 	iController->CheckBearerAvailability(ETrue);
       
   107 	}
       
   108 
       
   109 void CReconnectRequest::SetAvailableBearers(TUint32 aBearerSet)
       
   110 /**
       
   111 Making bearer availability with a set of bearers.
       
   112 
       
   113 @param aBearerSet the set of available bearers
       
   114 */
       
   115 	{
       
   116 	LOG_DETAILED( NetConLog::Printf(_L("CReconnectRequest::SetAvailableBearers(aBearerSet)")); )
       
   117 
       
   118 	// cancel bearer availability check, since we're not
       
   119 	// going to do any second phase (i.e. signal strength)
       
   120 	// bearer availability checking
       
   121 	iController->CancelBearerAvailabilityCheck();
       
   122 
       
   123 	// retrieve connection settings from the agent
       
   124 	TRAPD(err, iSettings = iAgent->ConnectionSettingsL());
       
   125 
       
   126 	LOG (
       
   127 		NetConLog::Printf(_L("\tSelected Service Type = '%S'"), &iSettings.iServiceType);
       
   128 		NetConLog::Printf(_L("\tAvailable Bearer Set = %d"), aBearerSet);
       
   129 		)
       
   130 
       
   131 	if(err==KErrNone && SelectedServiceAvailable(aBearerSet))
       
   132 		{
       
   133 		// if service is available then display the reconnect dialog box
       
   134 		Reconnect();
       
   135 		}
       
   136 	else
       
   137 		{
       
   138 		// otherwise complete the request with KErrCancel
       
   139 		// Note that Nifman will propagate the original error
       
   140 		// code (e.g. KErrCommsLineFail) to the application
       
   141 		RequestComplete(KErrCancel);
       
   142 		}
       
   143 	}
       
   144 
       
   145 
       
   146 void CReconnectRequest::MDPOReconnectComplete(TInt aError)
       
   147 /**
       
   148 Implementation of the MDialogProcessorObserver interface:
       
   149 Callback from the dialog processor when the reconnect dialog box has completed
       
   150 
       
   151 @param aError KErrCancel if the user selected "Cancel"
       
   152 @param aReponse ETrue if the user selected "OK" otherwise EFalse
       
   153 */
       
   154 	{
       
   155 
       
   156 	RequestComplete(aError);
       
   157 	}
       
   158