engine/src/ConnectionEngine.cpp
branch3rded
changeset 176 1c8b56cb6409
parent 164 000f9fc147b2
child 177 269e3f3e544a
equal deleted inserted replaced
175:cd124c4eb6b9 176:1c8b56cb6409
    29 	return self;
    29 	return self;
    30 	}
    30 	}
    31 
    31 
    32 CConnectionEngine::~CConnectionEngine()
    32 CConnectionEngine::~CConnectionEngine()
    33 	{
    33 	{
    34 	delete iMobility;
       
    35 
       
    36 	Cancel();
    34 	Cancel();
    37 	
    35 	
    38 	iConnection.Close();
    36 	iConnection.Close();
    39 
    37 
    40 	iSocketServer.Close();
    38 	iSocketServer.Close();
    54 	User::LeaveIfError( iConnection.Open( iSocketServer ) );
    52 	User::LeaveIfError( iConnection.Open( iSocketServer ) );
    55 	}
    53 	}
    56 
    54 
    57 void CConnectionEngine::RunL()
    55 void CConnectionEngine::RunL()
    58 	{		
    56 	{		
    59 	if ( iStatus.Int() == KErrNone )
    57 //	if ( iStatus.Int() == KErrNone )
    60 		{		
    58 //		{		
    61 		delete iMobility;
    59 //		delete iMobility;
    62 		iMobility = NULL;
    60 //		iMobility = NULL;
    63 		iMobility = CActiveCommsMobilityApiExt::NewL( iConnection, *this );
    61 //		iMobility = CActiveCommsMobilityApiExt::NewL( iConnection, *this );
    64 		}
    62 //		}
    65 	
    63 //	
    66 	iConnectionState = iStatus.Int() == KErrNone?CConnectionEngine::EConnected:CConnectionEngine::ENotConnected;
    64 //	iConnectionState = iStatus.Int() == KErrNone?CConnectionEngine::EConnected:CConnectionEngine::ENotConnected;
    67 	ReportConnectionL( iStatus.Int() );
    65 //	ReportConnectionL( iStatus.Int() );
    68 	}
    66 	}
    69 
    67 
    70 void CConnectionEngine::DoCancel()
    68 void CConnectionEngine::DoCancel()
    71 	{
    69 	{
    72 	}
    70 	}
    94 		}
    92 		}
    95 	else
    93 	else
    96 		{       
    94 		{       
    97 		// Sockets have to be closed at this point.        
    95 		// Sockets have to be closed at this point.        
    98 
    96 
    99 		iMobility->MigrateToPreferredCarrier();
    97 //		iMobility->MigrateToPreferredCarrier();
   100 		}
    98 		}
   101 
    99 
   102 	}
   100 	}
   103 
   101 
   104 void CConnectionEngine::NewCarrierActive( TAccessPointInfo /*aNewAPInfo*/, TBool aIsSeamless )
   102 void CConnectionEngine::NewCarrierActive( TAccessPointInfo /*aNewAPInfo*/, TBool aIsSeamless )
   111 	else
   109 	else
   112 		{        
   110 		{        
   113 		// Sockets have to be re-opened and check they can connect
   111 		// Sockets have to be re-opened and check they can connect
   114 		// to their server at this point.        
   112 		// to their server at this point.        
   115 
   113 
   116 		iMobility->NewCarrierAccepted();
   114 //		iMobility->NewCarrierAccepted();
   117 		}
   115 		}
   118 	}
   116 	}
   119 
   117 
   120 void CConnectionEngine::Error( TInt /*aError*/ )
   118 void CConnectionEngine::Error( TInt /*aError*/ )
   121 	{
   119 	{
   123 	}
   121 	}
   124 
   122 
   125 TBool CConnectionEngine::ConnectionSettingL()
   123 TBool CConnectionEngine::ConnectionSettingL()
   126 	{
   124 	{
   127 	TBool selected( EFalse );
   125 	TBool selected( EFalse );
   128 
   126 //
   129 	CCmApplicationSettingsUi* settings = CCmApplicationSettingsUi::NewL();
   127 //	CCmApplicationSettingsUi* settings = CCmApplicationSettingsUi::NewL();
   130 	CleanupStack::PushL( settings );
   128 //	CleanupStack::PushL( settings );
   131 
   129 //
   132 	TUint listedItems = 
   130 //	TUint listedItems = 
   133 	CMManager::EShowDefaultConnection |
   131 //	CMManager::EShowDefaultConnection |
   134 	CMManager::EShowDestinations;
   132 //	CMManager::EShowDestinations;
   135 
   133 //
   136 	TBearerFilterArray filter;
   134 //	TBearerFilterArray filter;
   137 	ReportConnectionSelectionStart();
   135 //	ReportConnectionSelectionStart();
   138 	selected = settings->RunApplicationSettingsL( iUserSelection,
   136 //	selected = settings->RunApplicationSettingsL( iUserSelection,
   139 			listedItems,
   137 //			listedItems,
   140 			filter );
   138 //			filter );
   141 
   139 //
   142 	CleanupStack::PopAndDestroy( settings );
   140 //	CleanupStack::PopAndDestroy( settings );
   143 	ReportConnectionSelectionEnd();
   141 //	ReportConnectionSelectionEnd();
   144 	return selected;
   142 	return selected;
   145 	}
   143 	}
   146 
   144 
   147 
   145 
   148 void CConnectionEngine::StartL(TConnectionType aConnectionType)
   146 void CConnectionEngine::StartL(TConnectionType aConnectionType)
   149 	{
   147 	{
   150 	DP1("CConnectionEngine::StartL, aConnectionType=%d", aConnectionType);
   148 	DP1("CConnectionEngine::StartL, aConnectionType=%d", aConnectionType);
   151 	
   149 	
   152 	iConnection.Close();
   150 	iConnection.Close();
   153 	User::LeaveIfError( iConnection.Open( iSocketServer ) );
   151 	User::LeaveIfError( iConnection.Open( iSocketServer ) );
   154 	// Connect using UI Setting
   152 //	// Connect using UI Setting
   155 	if(aConnectionType == EDefaultConnection)
   153 //	if(aConnectionType == EDefaultConnection)
   156 		{
   154 //		{
   157 		iConnection.Start( iStatus );
   155 //		iConnection.Start( iStatus );
   158 		SetActive();
   156 //		SetActive();
   159 		}
   157 //		}
   160 	else if(aConnectionType == EUserSelectConnection)
   158 //	else if(aConnectionType == EUserSelectConnection)
   161 		{				
   159 //		{				
   162 		TBool selected = ConnectionSettingL();
   160 //		TBool selected = ConnectionSettingL();
   163 
   161 //
   164 		if ( selected )
   162 //		if ( selected )
   165 			{
   163 //			{
   166 			switch ( iUserSelection.iResult )
   164 //			switch ( iUserSelection.iResult )
   167 				{
   165 //				{
   168 				case CMManager::EDestination:
   166 //				case CMManager::EDestination:
   169 					{					
   167 //					{					
   170 					iSnapPreference.SetSnap( iUserSelection.iId );
   168 //					iSnapPreference.SetSnap( iUserSelection.iId );
   171 					iConnection.Start( iSnapPreference, iStatus );
   169 //					iConnection.Start( iSnapPreference, iStatus );
   172 					aConnectionType = ESNAPConnection;
   170 //					aConnectionType = ESNAPConnection;
   173 					break;
   171 //					break;
   174 					}				
   172 //					}				
   175 				default: // CMManager::EAlwaysAsk
   173 //				default: // CMManager::EAlwaysAsk
   176 				case CMManager::EDefaultConnection:
   174 //				case CMManager::EDefaultConnection:
   177 					{					
   175 //					{					
   178 					iConnection.Start( iStatus );
   176 //					iConnection.Start( iStatus );
   179 					break;
   177 //					break;
   180 					}									
   178 //					}									
   181 				}						
   179 //				}						
   182 			}
   180 //			}
   183 		else
   181 //		else
   184 			{
   182 //			{
   185 			TRequestStatus* status = &iStatus;
   183 //			TRequestStatus* status = &iStatus;
   186 			User::RequestComplete(status, KErrCancel);
   184 //			User::RequestComplete(status, KErrCancel);
   187 			}
   185 //			}
   188 		
   186 //		
   189 			SetActive();
   187 //			SetActive();
   190 		}	
   188 //		}	
   191 	else if (aConnectionType == EIAPConnection)
   189 //	else if (aConnectionType == EIAPConnection)
   192 		{
   190 //		{
   193 		iCommdbPreference.SetIapId((iPodcastModel.SettingsEngine().SpecificIAP()& KUseIAPMask));
   191 //		iCommdbPreference.SetIapId((iPodcastModel.SettingsEngine().SpecificIAP()& KUseIAPMask));
   194 		iCommdbPreference.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
   192 //		iCommdbPreference.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
   195 		iCommdbPreference.SetDirection(ECommDbConnectionDirectionOutgoing);
   193 //		iCommdbPreference.SetDirection(ECommDbConnectionDirectionOutgoing);
   196 		iConnection.Start( iCommdbPreference, iStatus );
   194 //		iConnection.Start( iCommdbPreference, iStatus );
   197 		SetActive();
   195 //		SetActive();
   198 		}
   196 //		}
   199 	// Connect using SNAP 
   197 //	// Connect using SNAP 
   200 	else
   198 //	else
   201 		{
   199 //		{
   202 		iSnapPreference.SetSnap(iPodcastModel.SettingsEngine().SpecificIAP());
   200 //		iSnapPreference.SetSnap(iPodcastModel.SettingsEngine().SpecificIAP());
   203 		iConnection.Start( iSnapPreference, iStatus );
   201 //		iConnection.Start( iSnapPreference, iStatus );
   204 		SetActive();	
   202 //		SetActive();	
   205 		}		
   203 //		}		
   206 	
   204 //	
   207 	iConnectionType = aConnectionType;
   205 	iConnectionType = aConnectionType;
   208 	iConnectionState = CConnectionEngine::EConnecting;
   206 	iConnectionState = CConnectionEngine::EConnecting;
   209 	}
   207 	}
   210 
   208 
   211 void CConnectionEngine::Stop()
   209 void CConnectionEngine::Stop()