iaupdate/IAD/ui/src/iaupdateaccesspointhandler.cpp
branchRCL_3
changeset 26 8b7f4e561641
parent 0 ba25891c3a9e
equal deleted inserted replaced
25:7333d7932ef7 26:8b7f4e561641
       
     1 /*
       
     2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 
       
    22 #include "iaupdateaccesspointhandler.h"
       
    23 #include "iaupdatedebug.h"
       
    24 #include <iaupdate.rsg>
       
    25 
       
    26 #include <featmgr.h>
       
    27 #include <StringLoader.h>
       
    28 // access point selection
       
    29 #include <cmapplicationsettingsui.h>
       
    30 #include <cmconnectionmethoddef.h>
       
    31 #include <cmdestination.h>
       
    32 
       
    33 
       
    34 
       
    35  
       
    36 
       
    37 /******************************************************************************
       
    38  * class CIAUpdateAccessPointHandler
       
    39  ******************************************************************************/
       
    40  
       
    41 // -----------------------------------------------------------------------------
       
    42 // CIAUpdateAccessPointHandler::NewLC
       
    43 //
       
    44 // Two-phased constructor.
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 CIAUpdateAccessPointHandler* CIAUpdateAccessPointHandler::NewL()
       
    48     {
       
    49     CIAUpdateAccessPointHandler* self = new( ELeave ) CIAUpdateAccessPointHandler();
       
    50 	CleanupStack::PushL(self);
       
    51 	self->ConstructL();
       
    52 	CleanupStack::Pop(self);
       
    53 
       
    54 	return self;
       
    55     }
       
    56 
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // Destructor
       
    60 //
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 CIAUpdateAccessPointHandler::~CIAUpdateAccessPointHandler()
       
    64 	{
       
    65 	delete iCmUi;
       
    66 	iCmManager.Close();
       
    67 	}
       
    68 
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CIAUpdateAccessPointHandler::CIAUpdateAccessPointHandler
       
    72 //
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 CIAUpdateAccessPointHandler::CIAUpdateAccessPointHandler()
       
    76 	{
       
    77 	}
       
    78 
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // CIAUpdateAccessPointHandler::ConstructL
       
    82 //
       
    83 // Symbian 2nd phase constructor can leave.
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 void CIAUpdateAccessPointHandler::ConstructL()
       
    87     {
       
    88     iCmManager.OpenL();
       
    89     iCmUi = CCmApplicationSettingsUi::NewL();
       
    90 
       
    91 	iIdAppCsdSupport = EFalse;
       
    92 	FeatureManager::InitializeLibL();
       
    93 	if ( FeatureManager::FeatureSupported( KFeatureIdAppCsdSupport ) )
       
    94 	    {
       
    95 	    iIdAppCsdSupport = ETrue;
       
    96 	    }
       
    97 	FeatureManager::UnInitializeLib();
       
    98     }
       
    99 
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CIAUpdateAccessPointHandler::ShowApSelectDialogL
       
   103 //
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 TInt CIAUpdateAccessPointHandler::ShowApSelectDialogL( TInt& aItemUid, HBufC*& aItemName )
       
   107 	{
       
   108     TBearerFilterArray filterArray;
       
   109     TCmSettingSelection selection;
       
   110     selection.iId = aItemUid;
       
   111     selection.iResult = CMManager::EDestination;
       
   112     
       
   113     TBool ret = iCmUi->RunApplicationSettingsL( 
       
   114         selection,
       
   115         CMManager::EShowDestinations | CMManager::EShowDefaultConnection, 
       
   116         filterArray );
       
   117     filterArray.Close();
       
   118 	
       
   119 	if ( ret )
       
   120 		{
       
   121 		aItemUid = selection.iId;
       
   122 		if ( selection.iResult == CMManager::EDefaultConnection )
       
   123 		    {
       
   124 			GetDefaultConnectionLabelL( aItemName );
       
   125 			}
       
   126 	    else
       
   127 	        {
       
   128 	        GetApNameL( aItemUid, aItemName );	
       
   129 	        }
       
   130 		return EDialogSelect;
       
   131 		}
       
   132     else
       
   133     	{
       
   134     	return EDialogCancel;
       
   135     	}
       
   136 	}
       
   137 
       
   138 	
       
   139 // -----------------------------------------------------------------------------
       
   140 // CIAUpdateAccessPointHandler::GetApNameL
       
   141 //
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 TInt CIAUpdateAccessPointHandler::GetApNameL( TInt aItemUid, HBufC*& aItemName )
       
   145 	{
       
   146 	if ( aItemUid == KErrNotFound || aItemUid == 0 )
       
   147 		{
       
   148 		aItemName = KNullDesC().AllocL();
       
   149 		return KErrNotFound;
       
   150 		}
       
   151 
       
   152     RCmDestination dest = iCmManager.DestinationL( aItemUid );
       
   153     CleanupClosePushL( dest );
       
   154     HBufC* temp = dest.NameLC();    
       
   155     CleanupStack::Pop( temp );
       
   156 	CleanupStack::PopAndDestroy( &dest ); 
       
   157 	aItemName = temp;
       
   158 
       
   159 	TInt ret = KErrNone;
       
   160 	if ( aItemName->Length() == 0 ) 
       
   161 		{
       
   162 		ret = KErrNotFound;
       
   163 		}
       
   164     
       
   165 	return ret;
       
   166 	}
       
   167 
       
   168 
       
   169 // -----------------------------------------------------------------------------
       
   170 // CIAUpdateAccessPointHandler::GetDefaultConnectionLabelL
       
   171 //
       
   172 // -----------------------------------------------------------------------------
       
   173 //
       
   174 void CIAUpdateAccessPointHandler::GetDefaultConnectionLabelL( HBufC*& aLabelText )
       
   175     {
       
   176     aLabelText = StringLoader::LoadLC( R_IAUPDATE_DEFAULT_CONNECTION );    
       
   177     CleanupStack::Pop( aLabelText );
       
   178     }
       
   179 
       
   180     
       
   181 //  End of File