ipsservices/ipssossettings/src/ipssetuiitemaccesspoint.cpp
branchRCL_3
changeset 33 da5135c61bad
parent 0 8466d47a6819
equal deleted inserted replaced
32:a3a1ae9acec6 33:da5135c61bad
    24 #include <cmconnectionmethoddef.h>
    24 #include <cmconnectionmethoddef.h>
    25 #include <ipssossettings.rsg>
    25 #include <ipssossettings.rsg>
    26 
    26 
    27 #include "ipssetuiitemaccesspoint.h"
    27 #include "ipssetuiitemaccesspoint.h"
    28 
    28 
       
    29 const TInt KDefaultIapIndex = 0; 
    29 
    30 
    30 // ============================ MEMBER FUNCTIONS ===============================
    31 // ============================ MEMBER FUNCTIONS ===============================
    31 
    32 
    32 // ----------------------------------------------------------------------------
    33 // ----------------------------------------------------------------------------
    33 // CIpsSetUiItemAccessPoint::CIpsSetUiItemAccessPoint()
    34 // CIpsSetUiItemAccessPoint::CIpsSetUiItemAccessPoint()
    35 //
    36 //
    36 CIpsSetUiItemAccessPoint::CIpsSetUiItemAccessPoint()
    37 CIpsSetUiItemAccessPoint::CIpsSetUiItemAccessPoint()
    37     :
    38     :
    38     iIapType( ECuuUserDefined ),
    39     iIapType( ECuuUserDefined ),
    39     iIapPref( ECommDbDialogPrefUnknown ),
    40     iIapPref( ECommDbDialogPrefUnknown ),
    40     iIapId( 0 )
    41     iIapId( 0 ),
       
    42     iFullIapPrefs(NULL)
    41     {
    43     {
    42     FUNC_LOG;
    44     FUNC_LOG;
    43     }
    45     }
    44 
    46 
    45 // ----------------------------------------------------------------------------
    47 // ----------------------------------------------------------------------------
    49 CIpsSetUiItemAccessPoint::~CIpsSetUiItemAccessPoint()
    51 CIpsSetUiItemAccessPoint::~CIpsSetUiItemAccessPoint()
    50     {
    52     {
    51     FUNC_LOG;
    53     FUNC_LOG;
    52     iIapList.Close();
    54     iIapList.Close();
    53     iCommMethodManager.Close();
    55     iCommMethodManager.Close();
       
    56     
       
    57     if (iFullIapPrefs)
       
    58     	delete iFullIapPrefs;
    54     }
    59     }
    55 
    60 
    56 // ----------------------------------------------------------------------------
    61 // ----------------------------------------------------------------------------
    57 // CIpsSetUiItemAccessPoint::ConstructL()
    62 // CIpsSetUiItemAccessPoint::ConstructL()
    58 // ----------------------------------------------------------------------------
    63 // ----------------------------------------------------------------------------
    60 void CIpsSetUiItemAccessPoint::ConstructL()
    65 void CIpsSetUiItemAccessPoint::ConstructL()
    61     {
    66     {
    62     FUNC_LOG;
    67     FUNC_LOG;
    63     CIpsSetUiItemLink::ConstructL();
    68     CIpsSetUiItemLink::ConstructL();
    64     iCommMethodManager.OpenL();
    69     iCommMethodManager.OpenL();
       
    70     
       
    71     iIapSel.iResult = CMManager::EAlwaysAsk; 
       
    72     iIapSel.iId = 0;
    65     }
    73     }
    66 
    74 
    67 // ----------------------------------------------------------------------------
    75 // ----------------------------------------------------------------------------
    68 // CIpsSetUiItemAccessPoint::NewL()
    76 // CIpsSetUiItemAccessPoint::NewL()
    69 // ----------------------------------------------------------------------------
    77 // ----------------------------------------------------------------------------
   109     iItemSettingText->Copy( *aIapItem.iItemSettingText );
   117     iItemSettingText->Copy( *aIapItem.iItemSettingText );
   110     iItemAppereance = aIapItem.iItemAppereance;
   118     iItemAppereance = aIapItem.iItemAppereance;
   111     iIapType = aIapItem.iIapType;
   119     iIapType = aIapItem.iIapType;
   112     //iIapRadioButton = aIapItem.iIapRadioButton;
   120     //iIapRadioButton = aIapItem.iIapRadioButton;
   113     iIapPref = aIapItem.iIapPref;
   121     iIapPref = aIapItem.iIapPref;
   114     iIapId = aIapItem.iIapId;
   122     iIapId = aIapItem.iIapId;    
   115 
   123     iIapSel.iId = aIapItem.iIapSel.iId;
       
   124     iIapSel.iResult = aIapItem.iIapSel.iResult;
       
   125     
   116     return *this;
   126     return *this;
   117     }
   127     }
   118 
   128 
   119 // ----------------------------------------------------------------------------
   129 // ----------------------------------------------------------------------------
   120 // CIpsSetUiItemAccessPoint::LaunchIapPageL()
   130 // CIpsSetUiItemAccessPoint::LaunchIapPageL()
   138         // Launch the iap page
   148         // Launch the iap page
   139         if( iapType == ECuuUserDefined )
   149         if( iapType == ECuuUserDefined )
   140             {
   150             {
   141             result = LaunchIapPageL( iapId );
   151             result = LaunchIapPageL( iapId );
   142             }
   152             }
       
   153         else
       
   154         	{
       
   155 			iIapSel.iId = 0;
       
   156 			iIapSel.iResult = CMManager::EAlwaysAsk;
       
   157         	}
   143         }
   158         }
   144     
   159     
   145     // Everything is fine, finally update the setting item
   160     // Everything is fine, finally update the setting item
   146     if ( result == KErrNone )
   161     if ( result == KErrNone )
   147         {
   162         {
   178     
   193     
   179     // If a static access point is set, the name of the accesspoint can
   194     // If a static access point is set, the name of the accesspoint can
   180     // be fetched from the list.
   195     // be fetched from the list.
   181     if( iIapType == ECuuUserDefined )
   196     if( iIapType == ECuuUserDefined )
   182         {
   197         {
   183         iItemSettingText->Copy( AccessPointNameLC()->Des() );
   198 		HBufC* accPointName = AccessPointNameLC();
   184         CleanupStack::PopAndDestroy();  //AccessPointNameLC()
   199         iItemSettingText->Copy( accPointName->Des());
       
   200         CleanupStack::PopAndDestroy(accPointName);  //AccessPointNameLC()
   185         }
   201         }
   186     else
   202     else
   187         {
   203         {
   188         // Access point set to always ask, display the correct text
   204         // Access point set to always ask, display the correct text
   189         HBufC* text = StringLoader::LoadL( R_FSE_SETTINGS_IAP_ALWAYS_ASK );
   205         HBufC* text = StringLoader::LoadL( R_FSE_SETTINGS_IAP_ALWAYS_ASK );
   199 //
   215 //
   200 HBufC* CIpsSetUiItemAccessPoint::AccessPointNameLC()
   216 HBufC* CIpsSetUiItemAccessPoint::AccessPointNameLC()
   201     {
   217     {
   202     FUNC_LOG;
   218     FUNC_LOG;
   203     HBufC* bearerName( NULL );
   219     HBufC* bearerName( NULL );
   204     RCmConnectionMethod method = iCommMethodManager.ConnectionMethodL( iIapId );
   220     //check if method or destination is selected
   205     CleanupClosePushL( method );
   221     if (iIapSel.iResult == CMManager::EDestination)    
   206     bearerName = method.GetStringAttributeL( CMManager::ECmName );
   222     	{
   207     CleanupStack::PopAndDestroy();  //method
   223 		RCmDestination dest = iCommMethodManager.DestinationL(iIapSel.iId);
       
   224 		CleanupClosePushL(dest);
       
   225 		bearerName = dest.NameLC();
       
   226 		CleanupStack::Pop(bearerName);
       
   227 		CleanupStack::PopAndDestroy(&dest); //dest
       
   228     	}
       
   229     else
       
   230     	{
       
   231     	RCmConnectionMethod method = iCommMethodManager.ConnectionMethodL( iIapId );
       
   232     	CleanupClosePushL( method );
       
   233     	bearerName = method.GetStringAttributeL( CMManager::ECmName );
       
   234     	CleanupStack::PopAndDestroy(&method);  //method
       
   235         }
       
   236     
   208     CleanupStack::PushL( bearerName );
   237     CleanupStack::PushL( bearerName );
   209     return bearerName;
   238     return bearerName;
   210     }
   239     }
   211 
   240 
   212 // ----------------------------------------------------------------------------
   241 // ----------------------------------------------------------------------------
   240     TInt result = KErrNotFound;
   269     TInt result = KErrNotFound;
   241     //Show the access point list using Connection Method Manager
   270     //Show the access point list using Connection Method Manager
   242     TCmSettingSelection selection;
   271     TCmSettingSelection selection;
   243     TBearerFilterArray  filterArray;
   272     TBearerFilterArray  filterArray;
   244     //Set focus to the currently selected access point 
   273     //Set focus to the currently selected access point 
   245     selection.iId = iIapId;
   274     selection.iId = iIapSel.iId;
   246     selection.iResult = CMManager::EConnectionMethod;
   275     selection.iResult =iIapSel.iResult;
   247     CCmApplicationSettingsUi* settingsUi = CCmApplicationSettingsUi::NewLC();
   276     CCmApplicationSettingsUi* settingsUi = CCmApplicationSettingsUi::NewLC();
   248     TUint apFilter = CMManager::EShowConnectionMethods;
   277     TUint apFilter = CMManager::EShowDestinations|CMManager::EShowConnectionMethods;
       
   278     
   249     result = settingsUi->RunApplicationSettingsL( selection, apFilter, filterArray );
   279     result = settingsUi->RunApplicationSettingsL( selection, apFilter, filterArray );
   250     aIapId = result ? selection.iId : ( TUint32 )KErrNotFound;
   280     
   251     CleanupStack::PopAndDestroy( settingsUi );
   281     CleanupStack::PopAndDestroy( settingsUi );
       
   282     
       
   283     // store selection
       
   284     if (result)
       
   285     	{
       
   286 		aIapId = selection.iId;
       
   287 		iIapSel = selection;
       
   288     	}
       
   289     else
       
   290     	aIapId = ( TUint32 )KErrNotFound;
       
   291     
   252     // Return the quit method
   292     // Return the quit method
   253     return result ? KErrNone : KErrCancel;
   293     return result ? KErrNone : KErrCancel;
   254     }    
   294     }    
   255 
   295 
   256 // ----------------------------------------------------------------------------
   296 // ----------------------------------------------------------------------------
   264     CConnectionUiUtilities* dialog = CConnectionUiUtilities::NewL();
   304     CConnectionUiUtilities* dialog = CConnectionUiUtilities::NewL();
   265     CleanupStack::PushL( dialog );
   305     CleanupStack::PushL( dialog );
   266 
   306 
   267     // Open the always ask -page
   307     // Open the always ask -page
   268     TBool ok = dialog->AlwaysAskPageL( aAlwaysAsk );
   308     TBool ok = dialog->AlwaysAskPageL( aAlwaysAsk );
   269 
   309     
   270     CleanupStack::PopAndDestroy( dialog );
   310     CleanupStack::PopAndDestroy( dialog );
   271     dialog = NULL;
   311     dialog = NULL;
   272 
       
   273     // Ok or cancel pressed
   312     // Ok or cancel pressed
   274     return ok ? KErrNone : KErrCancel;
   313     return ok ? KErrNone : KErrCancel;
   275     }
   314     }
   276 
   315 
   277 // ---------------------------------------------------------------------------
   316 // ---------------------------------------------------------------------------
   293         iIapId = aIapChoice.iIAP;
   332         iIapId = aIapChoice.iIAP;
   294         iIapType = ECuuUserDefined;
   333         iIapType = ECuuUserDefined;
   295         }
   334         }
   296     UpdateL();
   335     UpdateL();
   297     }    
   336     }    
       
   337 // ---------------------------------------------------------------------------
       
   338 // CIpsSetUiItemAccessPoint::InitL()
       
   339 // ---------------------------------------------------------------------------
       
   340 //
       
   341 void CIpsSetUiItemAccessPoint::InitL( const  CImIAPPreferences* aIapPrefs )
       
   342     {
       
   343     FUNC_LOG;
       
   344     if (aIapPrefs->SNAPDefined())
       
   345     	{
       
   346         iIapSel.iResult = CMManager::EDestination;
       
   347         iIapSel.iId = aIapPrefs->SNAPPreference();
       
   348         iIapPref = ECommDbDialogPrefDoNotPrompt;
       
   349     	}
       
   350     //Iap is used
       
   351     else
       
   352     	{
       
   353 		iIapPref = aIapPrefs->IAPPreference(KDefaultIapIndex).iDialogPref;
       
   354 		if( iIapPref == ECommDbDialogPrefPrompt )
       
   355 			{
       
   356 			iIapId = 0;
       
   357 			iIapType = ECuuAlwaysAsk;
       
   358 			}
       
   359 		else
       
   360 			{
       
   361            	iIapId = aIapPrefs->IAPPreference(KDefaultIapIndex).iIAP;
       
   362 			}
       
   363 		iIapSel.iResult = CMManager::EConnectionMethod;
       
   364 		iIapSel.iId = iIapId;
       
   365         }
       
   366     UpdateL();
       
   367     }    
   298 
   368 
   299 // ----------------------------------------------------------------------------
   369 // ----------------------------------------------------------------------------
   300 // CIpsSetUiItemAccessPoint::InitializeSelection()
   370 // CIpsSetUiItemAccessPoint::InitializeSelection()
   301 // ----------------------------------------------------------------------------
   371 // ----------------------------------------------------------------------------
   302 //    
   372 //    
   315 TUint32 CIpsSetUiItemAccessPoint::GetIapIdL()
   385 TUint32 CIpsSetUiItemAccessPoint::GetIapIdL()
   316     {
   386     {
   317     FUNC_LOG;
   387     FUNC_LOG;
   318     return iIapId;
   388     return iIapId;
   319     }
   389     }
       
   390 // ----------------------------------------------------------------------------
       
   391 // CIpsSetUiItemAccessPoint::GetIapSelection()
       
   392 // ----------------------------------------------------------------------------
       
   393 //
       
   394 TCmSettingSelection CIpsSetUiItemAccessPoint::GetIapSelection()
       
   395 	{
       
   396 	FUNC_LOG;
       
   397 	return iIapSel;
       
   398 	}
       
   399 // ----------------------------------------------------------------------------
       
   400 // CIpsSetUiItemAccessPoint::GetIapChoice()
       
   401 // ----------------------------------------------------------------------------
       
   402 //
       
   403 TImIAPChoice CIpsSetUiItemAccessPoint::GetIapChoice()
       
   404 	{
       
   405 	TImIAPChoice choice;
       
   406 	
       
   407 	choice.iDialogPref = iIapPref;
       
   408 	choice.iIAP = iIapId;
       
   409 	
       
   410 	return choice;
       
   411 	}
       
   412 // ----------------------------------------------------------------------------
       
   413 // CIpsSetUiItemAccessPoint::GetExtendedIapPreferences()
       
   414 // ----------------------------------------------------------------------------
       
   415 //
       
   416 CImIAPPreferences& CIpsSetUiItemAccessPoint::GetExtendedIapPreferencesL()
       
   417 	{
       
   418 	if (iFullIapPrefs)
       
   419 		{
       
   420 		delete iFullIapPrefs;
       
   421 		iFullIapPrefs = NULL;
       
   422 		}
       
   423 		
       
   424 	
       
   425 	iFullIapPrefs = CImIAPPreferences::NewLC();
       
   426 	CleanupStack::Pop(iFullIapPrefs);
       
   427 	
       
   428 	if (iIapSel.iResult == CMManager::EDestination)
       
   429 		{
       
   430 		iFullIapPrefs->SetSNAPL(iIapSel.iId);
       
   431 		}
       
   432 	else
       
   433 		{
       
   434 		iFullIapPrefs->AddIAPL(GetIapChoice());
       
   435 		}
       
   436 	
       
   437 	return *iFullIapPrefs;
       
   438 	}
   320 
   439 
   321 // End of File
   440 // End of File
   322   
   441   
   323 
   442