engine/src/ConnectionEngine.cpp
branchRCL_3
changeset 285 4d42a5e09930
parent 163 f94dbd678dda
child 310 2e0299e13cbf
equal deleted inserted replaced
283:08a3356e8364 285:4d42a5e09930
    53 	User::LeaveIfError(iSocketServer.Connect());
    53 	User::LeaveIfError(iSocketServer.Connect());
    54 	User::LeaveIfError( iConnection.Open( iSocketServer ) );
    54 	User::LeaveIfError( iConnection.Open( iSocketServer ) );
    55 	}
    55 	}
    56 
    56 
    57 void CConnectionEngine::RunL()
    57 void CConnectionEngine::RunL()
    58 	{		
    58 	{
    59 	if ( iStatus.Int() == KErrNone )
    59 	DP1("CConnectionEngine::RunL BEGIN, iStatus.Int()=%d", iStatus.Int());
    60 		{		
    60 	if ( iStatus.Int() == KErrNone && iMobility == NULL)
    61 		delete iMobility;
    61 		{
    62 		iMobility = NULL;
    62 		TRAPD(err, iMobility = CActiveCommsMobilityApiExt::NewL( iConnection, *this ));
    63 		iMobility = CActiveCommsMobilityApiExt::NewL( iConnection, *this );
    63 		
       
    64 		if (err != KErrNone)
       
    65 			{
       
    66 			DP1("Leave in CActiveCommsMobilityApiExt::NewL, err=%d", err);
       
    67 			}
    64 		}
    68 		}
    65 	
    69 	
    66 	iConnectionState = iStatus.Int() == KErrNone?CConnectionEngine::EConnected:CConnectionEngine::ENotConnected;
    70 	iConnectionState = iStatus.Int() == KErrNone?CConnectionEngine::EConnected:CConnectionEngine::ENotConnected;
    67 	ReportConnectionL( iStatus.Int() );
    71 	ReportConnectionL( iStatus.Int() );
       
    72 	DP("CConnectionEngine::RunL END");
    68 	}
    73 	}
    69 
    74 
    70 void CConnectionEngine::DoCancel()
    75 void CConnectionEngine::DoCancel()
    71 	{
    76 	{
    72 	}
    77 	}
    78 
    83 
    79 void CConnectionEngine::PreferredCarrierAvailable( TAccessPointInfo /*aOldAPInfo*/,
    84 void CConnectionEngine::PreferredCarrierAvailable( TAccessPointInfo /*aOldAPInfo*/,
    80 		TAccessPointInfo /*aNewAPInfo*/,
    85 		TAccessPointInfo /*aNewAPInfo*/,
    81 		TBool aIsUpgrade,
    86 		TBool aIsUpgrade,
    82 		TBool aIsSeamless )
    87 		TBool aIsSeamless )
    83 	{   
    88 	{
       
    89 	DP("CConnectionEngine::PreferredCarrierAvailable");
    84 	if ( aIsUpgrade )
    90 	if ( aIsUpgrade )
    85 		{        
    91 		{        
    86 		}
    92 		}
    87 	else
    93 	else
    88 		{       
    94 		{       
   101 
   107 
   102 	}
   108 	}
   103 
   109 
   104 void CConnectionEngine::NewCarrierActive( TAccessPointInfo /*aNewAPInfo*/, TBool aIsSeamless )
   110 void CConnectionEngine::NewCarrierActive( TAccessPointInfo /*aNewAPInfo*/, TBool aIsSeamless )
   105 	{    
   111 	{    
       
   112 	DP("CConnectionEngine::NewCarrierActive");
   106 	if ( aIsSeamless )
   113 	if ( aIsSeamless )
   107 		{
   114 		{
   108 		// in S60 3.2, this situation cannot occur.
   115 		// in S60 3.2, this situation cannot occur.
   109 
   116 
   110 		}
   117 		}
   122 
   129 
   123 	}
   130 	}
   124 
   131 
   125 TBool CConnectionEngine::ConnectionSettingL()
   132 TBool CConnectionEngine::ConnectionSettingL()
   126 	{
   133 	{
       
   134 	DP("CConnectionEngine::ConnectionSettingL");
   127 	TBool selected( EFalse );
   135 	TBool selected( EFalse );
   128 
   136 
   129 	CCmApplicationSettingsUi* settings = CCmApplicationSettingsUi::NewL();
   137 	CCmApplicationSettingsUi* settings = CCmApplicationSettingsUi::NewL();
   130 	CleanupStack::PushL( settings );
   138 	CleanupStack::PushL( settings );
   131 
   139 
   145 	}
   153 	}
   146 
   154 
   147 
   155 
   148 void CConnectionEngine::StartL(TConnectionType aConnectionType)
   156 void CConnectionEngine::StartL(TConnectionType aConnectionType)
   149 	{
   157 	{
   150 	DP1("CConnectionEngine::StartL, aConnectionType=%d", aConnectionType);
   158 	DP1("CConnectionEngine::StartL BEGIN, aConnectionType=%d", aConnectionType);
   151 	
   159 	
   152 	iConnection.Close();
   160 	iConnection.Close();
   153 	User::LeaveIfError( iConnection.Open( iSocketServer ) );
   161 	User::LeaveIfError( iConnection.Open( iSocketServer ) );
   154 	// Connect using UI Setting
   162 	// Connect using UI Setting
   155 	if(aConnectionType == EDefaultConnection)
   163 	if(aConnectionType == EDefaultConnection)
   204 		SetActive();	
   212 		SetActive();	
   205 		}		
   213 		}		
   206 	
   214 	
   207 	iConnectionType = aConnectionType;
   215 	iConnectionType = aConnectionType;
   208 	iConnectionState = CConnectionEngine::EConnecting;
   216 	iConnectionState = CConnectionEngine::EConnecting;
       
   217 	DP1("CConnectionEngine::StartL END, iConnectionState=%d", iConnectionState);	
   209 	}
   218 	}
   210 
   219 
   211 void CConnectionEngine::Stop()
   220 void CConnectionEngine::Stop()
   212 	{
   221 	{
   213 	DP("CConnectionEngine::Stop");
   222 	DP("CConnectionEngine::Stop");
   221 	return iConnection;	
   230 	return iConnection;	
   222 	}
   231 	}
   223 
   232 
   224 CConnectionEngine::TConnectionState CConnectionEngine::ConnectionState()
   233 CConnectionEngine::TConnectionState CConnectionEngine::ConnectionState()
   225 	{
   234 	{
       
   235 	DP("CConnectionEngine::ConnectionState BEGIN");
   226 	TInt selectedConn = (TInt) iSnapPreference.Snap();
   236 	TInt selectedConn = (TInt) iSnapPreference.Snap();
   227 	TInt specIAPSNAP = iPodcastModel.SettingsEngine().SpecificIAP();
   237 	TInt specIAPSNAP = iPodcastModel.SettingsEngine().SpecificIAP();
   228 	// If we have IAP preference then get that from our current connection and mask out the selected iap
   238 	// If we have IAP preference then get that from our current connection and mask out the selected iap
   229 	if((specIAPSNAP&KUseIAPFlag))
   239 	if((specIAPSNAP&KUseIAPFlag))
   230 		{
   240 		{
   264 			{
   274 			{
   265 			iConnectionState = CConnectionEngine::ENotConnected;
   275 			iConnectionState = CConnectionEngine::ENotConnected;
   266 			}
   276 			}
   267 		}
   277 		}
   268 	
   278 	
       
   279 	DP("CConnectionEngine::ConnectionState END");
   269 	return iConnectionState;
   280 	return iConnectionState;
   270 	}
   281 	}
   271 
   282 
   272 EXPORT_C void CConnectionEngine::AddObserver(MConnectionObserver* aObserver)
   283 EXPORT_C void CConnectionEngine::AddObserver(MConnectionObserver* aObserver)
   273 	{
   284 	{
       
   285 	DP("CConnectionEngine::AddObserver");
   274 	iObserverArray.Append(aObserver);
   286 	iObserverArray.Append(aObserver);
   275 	}
   287 	}
   276 
   288 
       
   289 EXPORT_C void CConnectionEngine::RemoveObserver(MConnectionObserver* aObserver)
       
   290 	{
       
   291 	DP("CConnectionEngine::RemoveObserver");
       
   292 	for (int i=0;i<iObserverArray.Count();i++)
       
   293 		{
       
   294 		if (iObserverArray[i] == aObserver)
       
   295 			{
       
   296 			iObserverArray.Remove(i);
       
   297 			}
       
   298 			
       
   299 		}
       
   300 	}
       
   301 
   277 RSocketServ& CConnectionEngine::SockServ()
   302 RSocketServ& CConnectionEngine::SockServ()
   278 	{
   303 	{
   279 	return iSocketServer;
   304 	return iSocketServer;
   280 	}
   305 	}
   281 
   306 
   282 
   307 
   283 void CConnectionEngine::ReportConnectionL(TInt aError)
   308 void CConnectionEngine::ReportConnectionL(TInt aError)
       
   309 	{
       
   310 	DP1("CConnectionEngine::ReportConnectionL, aError=%d", aError);
       
   311 	TInt noObservers = iObserverArray.Count();
       
   312 	DP1("    noObservers=%d", noObservers);
       
   313 	while(noObservers)
       
   314 		{
       
   315 		noObservers--;
       
   316 		DP("    calling callback");
       
   317 		iObserverArray[noObservers]->ConnectCompleteL(aError);
       
   318 		}
       
   319 	}
       
   320 
       
   321 
       
   322 void CConnectionEngine::ReportConnectionSelectionStart()
   284 	{
   323 	{
   285 	TInt noObservers = iObserverArray.Count();
   324 	TInt noObservers = iObserverArray.Count();
   286 	while(noObservers)
   325 	while(noObservers)
   287 		{
   326 		{
   288 		noObservers--;
   327 		noObservers--;
   289 		iObserverArray[noObservers]->ConnectCompleteL(aError);
   328 		iObserverArray[noObservers]->ConnectionSelectionStart();
   290 		}
   329 		}
   291 	}
   330 	}
   292 
   331 
   293 
   332 
   294 void CConnectionEngine::ReportConnectionSelectionStart()
   333 void CConnectionEngine::ReportConnectionSelectionEnd()
   295 	{
   334 	{
   296 	TInt noObservers = iObserverArray.Count();
   335 	TInt noObservers = iObserverArray.Count();
   297 	while(noObservers)
   336 	while(noObservers)
   298 		{
   337 		{
   299 		noObservers--;
   338 		noObservers--;
   300 		iObserverArray[noObservers]->ConnectionSelectionStart();
       
   301 		}
       
   302 	}
       
   303 
       
   304 
       
   305 void CConnectionEngine::ReportConnectionSelectionEnd()
       
   306 	{
       
   307 	TInt noObservers = iObserverArray.Count();
       
   308 	while(noObservers)
       
   309 		{
       
   310 		noObservers--;
       
   311 		iObserverArray[noObservers]->ConnectionSelectionEnd();
   339 		iObserverArray[noObservers]->ConnectionSelectionEnd();
   312 		}
   340 		}
   313 	}
   341 	}