dbcreator/commsdatcreator/src/cdcprocessorglobal.cpp
changeset 56 dd6aaa97e7b1
parent 32 5c4486441ae6
child 61 8b0c979bbe8c
equal deleted inserted replaced
52:bbe4544dfd31 56:dd6aaa97e7b1
       
     1 /*
       
     2 * Copyright (c) 2004 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:   Implementation of the class CProcessorGlobal
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include "cdclogger.h"
       
    24 #include "cdcerrors.h"
       
    25 #include "cdctagcontainer.h"
       
    26 #include "cdccommon.h"
       
    27 #include "cmgenconnsettings.h"
       
    28 #include "cdcprocessorglobal.h"
       
    29 
       
    30 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    31 #include <commsdattypesv1_1.h>
       
    32 #else
       
    33 #include <commsdattypesv1_1.h>
       
    34 #include <commsdattypesv1_1_partner.h>
       
    35 #endif
       
    36 #include <datamobilitycommsdattypes.h>
       
    37 #include <metadatabase.h>
       
    38 #include <cmmanagerext.h>
       
    39 #include <cmmanager.h>
       
    40 #include <cmdestinationext.h>
       
    41 #include <WlanCdbCols.h>
       
    42 #include <wlancontainer.h>
       
    43 #include <featmgr.h>
       
    44 
       
    45 // CONSTANTS
       
    46 
       
    47 // Global settings record name
       
    48 _LIT16( KGlobalSettingsRecordName, "DefaultRecordName-1" );
       
    49 
       
    50 // Default GPRS record name
       
    51 _LIT( KDefaultGPRSRecordName, "Dummy Default GPRS Settings" );
       
    52 
       
    53 // Modem bearer names for GPRS/WCDMA Access Points
       
    54 _LIT( KModemBearerPacketData, "GPRS Modem" );
       
    55 
       
    56 // LAN bearer names for Wlan Access Points
       
    57 _LIT( KLANBearerWlan, "WLANBearer" );
       
    58 
       
    59 
       
    60 // Structure that converts field ids to the corresponding table names
       
    61 // and parameter types
       
    62 typedef struct
       
    63     {
       
    64     TDbCreatorGlobalSettings iField;
       
    65     const TText* iBearerTableName;
       
    66     TBool iIsUIPriority;
       
    67     } TPriorityConversion;
       
    68 
       
    69 const TPriorityConversion KPriorityConversionTable[] =
       
    70     {
       
    71         { EPriorityLan, KCDTypeNameLANService, EFalse },
       
    72         { EPriorityWlan, KCDTypeNameWLANServiceExt, EFalse },
       
    73         { EPriorityPan, KCDTypeNamePANServiceExt, EFalse },
       
    74         { EPriorityGprsIn, KCDTypeNameOutgoingWCDMA, EFalse },
       
    75         { EPriorityGprsOut, KCDTypeNameIncomingWCDMA, EFalse },
       
    76         { EPriorityDialOut, KCDTypeNameDialOutISP, EFalse },
       
    77         { EPriorityDialIn, KCDTypeNameDialInISP, EFalse },
       
    78         { EPriorityVpn, KCDTypeNameVPNService, EFalse },
       
    79         { EPriorityMip, KCDTypeNameMIPServiceExt, EFalse },
       
    80         { EUIPriorityLan, KCDTypeNameLANService, ETrue },
       
    81         { EUIPriorityWlan, KCDTypeNameWLANServiceExt, ETrue },
       
    82         { EUIPriorityPan, KCDTypeNamePANServiceExt, ETrue },
       
    83         { EUIPriorityGprsIn, KCDTypeNameOutgoingWCDMA, ETrue },
       
    84         { EUIPriorityGprsOut, KCDTypeNameIncomingWCDMA, ETrue },
       
    85         { EUIPriorityDialOut, KCDTypeNameDialOutISP, ETrue },
       
    86         { EUIPriorityDialIn, KCDTypeNameDialInISP, ETrue },
       
    87         { EUIPriorityVpn, KCDTypeNameVPNService, ETrue },
       
    88         { EUIPriorityMip, KCDTypeNameMIPServiceExt, ETrue },
       
    89         { EUnused, NULL, EFalse }
       
    90     };
       
    91 
       
    92 
       
    93 // Maximum size to be allocated for table names
       
    94 const TUint KMaxTableNameSize = 50;
       
    95 
       
    96 // ================= MEMBER FUNCTIONS =======================
       
    97 
       
    98 // ---------------------------------------------------------
       
    99 // CProcessorGlobal::NewL
       
   100 // ---------------------------------------------------------
       
   101 //
       
   102 CProcessorGlobal* CProcessorGlobal::NewL( 
       
   103                           CReaderBase* aFileReader,
       
   104                           RCmManagerExt& aCmManager,
       
   105                           RPointerArray< RCmConnectionMethodExt >& aPluginArray,
       
   106                           RPointerArray< HBufC >& aPluginNames, 
       
   107                           RPointerArray< RCmDestinationExt >& aDestArray,
       
   108                           RPointerArray< HBufC >& aDestNames )
       
   109     {
       
   110     CProcessorGlobal* self = new ( ELeave ) CProcessorGlobal( aFileReader,
       
   111                                                               aCmManager,
       
   112                                                               aPluginArray,
       
   113                                                               aPluginNames,
       
   114                                                               aDestArray,
       
   115                                                               aDestNames );
       
   116     CleanupStack::PushL( self );
       
   117 
       
   118     // From base class
       
   119     self->ConstructL();
       
   120     CleanupStack::Pop( self );
       
   121     
       
   122     return self;
       
   123     }
       
   124 
       
   125 // ---------------------------------------------------------
       
   126 // CProcessorGlobal::CProcessorGlobal
       
   127 // ---------------------------------------------------------
       
   128 //
       
   129 CProcessorGlobal::CProcessorGlobal( CReaderBase* aFileReader,
       
   130                                     RCmManagerExt& aCmManager,
       
   131                                     RPointerArray< RCmConnectionMethodExt >& aPluginArray,
       
   132                                     RPointerArray< HBufC >& aPluginNames, 
       
   133                                     RPointerArray< RCmDestinationExt >& aDestArray,
       
   134                                     RPointerArray< HBufC >& aDestNames ) :
       
   135     CProcessorBase( aFileReader, aCmManager, aPluginArray, aPluginNames, aDestArray, aDestNames ),
       
   136     iAttachWhenNeeded ( EFalse )
       
   137     {
       
   138     }
       
   139     
       
   140     
       
   141 // ---------------------------------------------------------
       
   142 // CProcessorGlobal::ConstructL
       
   143 // ---------------------------------------------------------
       
   144 //
       
   145 void CProcessorGlobal::ConstructL()
       
   146     {
       
   147     iSession = CMDBSession::NewL( CMDBSession::LatestVersion() );
       
   148     
       
   149     iSession->SetAttributeMask( ECDNoWriteButDelete | ECDHidden | ECDProtectedWrite | ECDPrivate ); // Check this
       
   150     
       
   151     // Create General connection settings struct and set the default values
       
   152     iGenConnSettings = new (ELeave) TCmGenConnSettings;
       
   153     iGenConnSettings->iUsageOfWlan = ECmUsageOfWlanKnown;
       
   154     iGenConnSettings->iCellularDataUsageHome = ECmCellularDataUsageAutomatic;
       
   155     iGenConnSettings->iCellularDataUsageVisitor = ECmCellularDataUsageConfirm;
       
   156 
       
   157     CLOG_WRITE( "Initialising FeatureManager\n" )   
       
   158     //checks if Wlan feature is supported
       
   159     FeatureManager::InitializeLibL();
       
   160     iIsWlanS = FeatureManager::FeatureSupported( KFeatureIdProtocolWlan );
       
   161     FeatureManager::UnInitializeLib();
       
   162     CLOG_WRITE( "FeatureManager closed\n" ) 
       
   163     }
       
   164 
       
   165 
       
   166 // ---------------------------------------------------------
       
   167 // CProcessorGlobal::~CProcessorGlobal
       
   168 // ---------------------------------------------------------
       
   169 //
       
   170 CProcessorGlobal::~CProcessorGlobal()
       
   171     {
       
   172     if ( iSession )
       
   173         {
       
   174         iSession->Close();
       
   175         delete iSession; 
       
   176         }
       
   177     delete iGenConnSettings;    
       
   178     }
       
   179      
       
   180 // ---------------------------------------------------------
       
   181 // CProcessorGlobal::ProcessTagL
       
   182 // ---------------------------------------------------------
       
   183 //
       
   184 void CProcessorGlobal::ProcessTagL( TBool /*aFieldIDPresent*/ )
       
   185     {
       
   186     for (TInt idx(0); idx < TagContainer().Count(); idx++)
       
   187         {  
       
   188         TDbCreatorGlobalSettings fieldId;
       
   189         
       
   190         fieldId = static_cast< TDbCreatorGlobalSettings >
       
   191         ( TagContainer().FieldId( idx ) );
       
   192         
       
   193         HBufC16* ptrTag = TagContainer().Tag(idx);
       
   194         
       
   195         switch( fieldId )
       
   196             {
       
   197             case EGPRSAttachMode:
       
   198                 {
       
   199                 _LIT( KAttachWhenNeeded, "whenneeded" );
       
   200                 _LIT( KAttachWhenAvailable, "whenavailable" );
       
   201                 
       
   202                 if ( !ptrTag->CompareF( KAttachWhenNeeded ) )
       
   203                     {
       
   204                     iAttachWhenNeeded = ETrue;
       
   205                     }
       
   206                 else if ( !ptrTag->CompareF( KAttachWhenAvailable ) )
       
   207                     {
       
   208                     iAttachWhenNeeded = EFalse;
       
   209                     }
       
   210                 else 
       
   211                     {
       
   212                     iAttachWhenNeeded = EFalse;
       
   213                     CLOG_WRITE( "! Error : invalid attach mode. Default:whenavailable" );
       
   214                     }
       
   215 
       
   216                 break;
       
   217                 }
       
   218                 
       
   219             case EDefaultAP:
       
   220                 {
       
   221                 CMDBSession* db = CMDBSession::NewL( CMDBSession::LatestVersion() );
       
   222                 CleanupStack::PushL( db );
       
   223                 
       
   224                 CCDDefaultWCDMARecord* defaultGPRS = static_cast< CCDDefaultWCDMARecord* >
       
   225                         ( CCDRecordBase::RecordFactoryL( KCDTIdDefaultWCDMARecord ) );
       
   226                 
       
   227                 CleanupStack::PushL( defaultGPRS );
       
   228                 
       
   229                 defaultGPRS->iRecordName.SetL( KDefaultGPRSRecordName );
       
   230                 
       
   231                 defaultGPRS->FindL( *db );			    
       
   232                 
       
   233                 defaultGPRS->iAPN.SetL( *ptrTag );
       
   234                 
       
   235                 defaultGPRS->ModifyL( *db );				    				    				   
       
   236                 
       
   237                 CleanupStack::PopAndDestroy( defaultGPRS );
       
   238                 
       
   239                 db->Close();			    			    
       
   240                 CleanupStack::PopAndDestroy( db );
       
   241                 break;
       
   242                 }
       
   243                 
       
   244             case EDefaultDnIcon:
       
   245                 {
       
   246                 // Convert default icon to int
       
   247                 TPtrC16 iconPtr = ptrTag->Right( ptrTag->Length() );
       
   248                 TLex16 lex( iconPtr );
       
   249                 TUint32 icon( 0 );
       
   250                 if ( lex.Val( icon, EDecimal ) == KErrNone )
       
   251                     {
       
   252                     // If there was no error, write default entry to SNAP
       
   253                     // Metadata table.
       
   254                     // First load SNAP table to get table id
       
   255                     CMDBGenericRecord* snapTable = static_cast< CMDBGenericRecord* >
       
   256                             ( CCDRecordBase::RecordFactoryL( 0 ) );
       
   257                     CleanupStack::PushL( snapTable );      
       
   258                     snapTable->InitializeL( TPtrC( KCDTypeNameSNAPMetadata ),
       
   259                             NULL );
       
   260                     snapTable->LoadL( *iSession );
       
   261                     // Then add default record to table
       
   262                     CCDSNAPMetadataRecord* defaultRecord = new( ELeave )
       
   263                             CCDSNAPMetadataRecord( snapTable->TableId() );
       
   264                     CleanupStack::PushL( defaultRecord );
       
   265                     defaultRecord->SetRecordId( KCDNewRecordRequest );
       
   266                     defaultRecord->iMetadata.SetL( 0 );
       
   267                     defaultRecord->iIcon.SetL( icon );
       
   268                     defaultRecord->StoreL( *iSession );
       
   269                     
       
   270                     CleanupStack::PopAndDestroy( defaultRecord ); // defaultRecord
       
   271                     CleanupStack::PopAndDestroy( snapTable ); // snapTable
       
   272                     }
       
   273                 break;
       
   274                 }
       
   275                 
       
   276             case EPriorityLan:
       
   277             case EPriorityWlan:
       
   278             case EPriorityPan:
       
   279             case EPriorityGprsIn:
       
   280             case EPriorityGprsOut:
       
   281             case EPriorityDialOut:
       
   282             case EPriorityDialIn:
       
   283             case EPriorityVpn:
       
   284             case EPriorityMip:
       
   285             case EUIPriorityLan:
       
   286             case EUIPriorityWlan:
       
   287             case EUIPriorityPan:
       
   288             case EUIPriorityGprsIn:
       
   289             case EUIPriorityGprsOut:
       
   290             case EUIPriorityDialOut:
       
   291             case EUIPriorityDialIn:
       
   292             case EUIPriorityVpn:
       
   293             case EUIPriorityMip:
       
   294                 {
       
   295                 // Convert priority to int
       
   296                 TPtrC16 prioPtr = ptrTag->Right( ptrTag->Length() );
       
   297                 TLex16 lex( prioPtr );
       
   298                 TUint32 prio( 0 );
       
   299                 if ( lex.Val( prio, EDecimal ) == KErrNone )
       
   300                     {
       
   301                     UpdateGlobalBearerArrayL( fieldId, prio );
       
   302                     }
       
   303                 break;
       
   304                 }
       
   305                 
       
   306             case EGprsLastSocketActivityTimeout:
       
   307             case EGprsLastSessionClosedTimeout:
       
   308             case EGprsLastSocketClosedTimeout:		
       
   309                 {            				    
       
   310                 // Load modem bearer record
       
   311                 CCDModemBearerRecord* bearerRecord = static_cast< CCDModemBearerRecord * >
       
   312                 ( CCDRecordBase::RecordFactoryL( KCDTIdModemBearerRecord ) );
       
   313                 CleanupStack::PushL( bearerRecord );
       
   314                 
       
   315                 if( fieldId == EGprsLastSocketActivityTimeout
       
   316                         || fieldId == EGprsLastSessionClosedTimeout
       
   317                         || fieldId == EGprsLastSocketClosedTimeout )
       
   318                     {
       
   319                     // Open the record "Gprs Modem"
       
   320                     bearerRecord->iRecordName.SetL( KModemBearerPacketData );	
       
   321                     }				
       
   322                 
       
   323                 bearerRecord->FindL( *iSession ); // CHECK: Leaves if record not found				
       
   324                 
       
   325                 // Convert input parameter
       
   326                 TLex lex( *ptrTag );
       
   327                 
       
   328                 TInt timeout( 0 );
       
   329                 
       
   330                 // If there are parameters that cannot be handled just leave. In that case the CommsDat creation
       
   331                 // fails and default is used instead. So it is easier for the variant engineer to detect
       
   332                 // that something went wrong.
       
   333                 if ( lex.Val( timeout ) != KErrNone)
       
   334                     {
       
   335                     CLOG_WRITE( "! Error : invalid NIF parameter for GPRS (socket/session timeout)" );					
       
   336                     User::Leave( KErrArgument );
       
   337                     }
       
   338                 
       
   339                 // Set the parameter	
       
   340                 if( fieldId == EGprsLastSocketActivityTimeout )
       
   341                     {
       
   342                     bearerRecord->iLastSocketActivityTimeout.SetL( timeout );
       
   343                     }
       
   344                 else if( fieldId == EGprsLastSessionClosedTimeout )
       
   345                     {
       
   346                     bearerRecord->iLastSessionClosedTimeout.SetL( timeout );
       
   347                     }
       
   348                 else
       
   349                     {
       
   350                     bearerRecord->iLastSocketClosedTimeout.SetL( timeout );
       
   351                     }
       
   352                 
       
   353                 bearerRecord->ModifyL( *iSession );
       
   354                 
       
   355                 CleanupStack::PopAndDestroy( bearerRecord );
       
   356                 
       
   357                 break;
       
   358                 }
       
   359                 
       
   360             case EWlanLastSocketActivityTimeout:
       
   361             case EWlanLastSessionClosedTimeout:
       
   362             case EWlanLastSocketClosedTimeout:            
       
   363                 {
       
   364                 if( iIsWlanS )
       
   365                     {
       
   366                     // Load LAN bearer record
       
   367                     CCDLANBearerRecord* bearerRecord = static_cast< CCDLANBearerRecord * >
       
   368                     ( CCDRecordBase::RecordFactoryL( KCDTIdLANBearerRecord ) );
       
   369                     CleanupStack::PushL( bearerRecord );
       
   370                     
       
   371                     // Open the record "WlanBearer"
       
   372                     bearerRecord->iRecordName.SetL( KLANBearerWlan );	
       
   373                     
       
   374                     User::LeaveIfError( bearerRecord->FindL( *iSession ) );
       
   375                     
       
   376                     // Convert the input paramater to UINT
       
   377                     TLex lex( *ptrTag );
       
   378                     
       
   379                     TInt timeout( 0 );
       
   380                     
       
   381                     // If there are parameters that cannot be handled just leave. In that case the CommsDat creation
       
   382                     // fails and default is used instead. So it is easier for the variant engineer to detect
       
   383                     // that something went wrong.
       
   384                     if ( lex.Val( timeout ) != KErrNone)
       
   385                         {
       
   386                         CLOG_WRITE( "! Error : invalid NIF parameter for WLAN (socket/session timeout)" );					
       
   387                         User::Leave( KErrArgument );
       
   388                         }
       
   389                     
       
   390                     
       
   391                     // Set the paramter
       
   392                     if( fieldId == EWlanLastSocketActivityTimeout )
       
   393                         {				
       
   394                         bearerRecord->iLastSocketActivityTimeout.SetL( timeout );
       
   395                         }
       
   396                     else if( fieldId == EWlanLastSessionClosedTimeout)
       
   397                         {					
       
   398                         bearerRecord->iLastSessionClosedTimeout.SetL( timeout );
       
   399                         }
       
   400                     else
       
   401                         {					
       
   402                         bearerRecord->iLastSocketClosedTimeout.SetL( timeout );
       
   403                         }
       
   404                     
       
   405                     bearerRecord->ModifyL( *iSession );				
       
   406                     CleanupStack::PopAndDestroy( bearerRecord );
       
   407                     }
       
   408                 break;
       
   409                 }
       
   410                 
       
   411             case EWlanBGScanInterval:
       
   412             case EWlanUseDefSettings:
       
   413             case EWlanLongRetry:
       
   414             case EWlanShortRetry:
       
   415             case EWlanRTS:
       
   416             case EWlanTxPowerLevel:
       
   417             case EWlanRadioMeasurements:
       
   418             case EWlanPowerMode:
       
   419                 {
       
   420                 if( iIsWlanS )
       
   421                     {
       
   422                     // Save the same value both to default and user settings records
       
   423                     TInt err;
       
   424                     TRAP( err, SaveGlobalWlanParameterL( KWlanDefaultSettings, fieldId, ptrTag ) );
       
   425                     if( err != KErrNone )
       
   426                         {
       
   427                         CLOG_WRITE( "! Error : Could not save global WLAN parameter. Incorrect input?" );
       
   428                         User::Leave( err  );
       
   429                         }
       
   430                     TRAP( err, SaveGlobalWlanParameterL( KWlanUserSettings, fieldId, ptrTag ) );
       
   431                     if( err != KErrNone )
       
   432                         {
       
   433                         CLOG_WRITE( "! Error : Could not save global WLAN parameter. Incorrect input?" );
       
   434                         User::Leave( err );
       
   435                         }
       
   436                     }
       
   437                 break;
       
   438                 }
       
   439                 
       
   440             case EUsageOfWlan:
       
   441                 {
       
   442                 SetGenConnSettingWlanUsage( ptrTag );
       
   443                 break;
       
   444                 }
       
   445                 
       
   446             case ECellularDataUsageHome:
       
   447                 {
       
   448                 SetGenConnSettingCellularDataUsageHome( ptrTag );
       
   449                 break;
       
   450                 }
       
   451                 
       
   452             case ECellularDataUsageVisitor:
       
   453                 {
       
   454                 SetGenConnSettingCellularDataUsageVisitor( ptrTag );
       
   455                 break;
       
   456                 }
       
   457                 
       
   458             default:
       
   459                 break;
       
   460             }
       
   461         }
       
   462     
       
   463     if( iBearerArrayChanged )
       
   464         {
       
   465         
       
   466         CLOG_WRITE( "UpdateBearerPriorityArrayL\n" )
       
   467         
       
   468         iCmManager->UpdateBearerPriorityArrayL( iBearerArray );
       
   469         iCmManager->CleanupGlobalPriorityArray( iBearerArray );
       
   470         
       
   471         iBearerArray.Close();
       
   472         
       
   473         CLOG_WRITE( "UpdateBearerPriorityArrayL end\n" )
       
   474         }
       
   475     
       
   476     // General Connection settings are always set
       
   477     SetGenConnSettingsL();
       
   478     }
       
   479 
       
   480 // ---------------------------------------------------------
       
   481 // CProcessorGlobal::ProcessAPL
       
   482 // ---------------------------------------------------------
       
   483 //
       
   484 void CProcessorGlobal::ProcessAPL()
       
   485     {
       
   486     CMDBSession* db = CMDBSession::NewL( CMDBSession::LatestVersion() );
       
   487     CleanupStack::PushL( db );
       
   488                     
       
   489     CLOG_WRITE( "Global settings\n" )
       
   490     CLOG_WRITE( "---------------\n" )
       
   491         
       
   492     CCDGlobalSettingsRecord* globalSettings = static_cast< CCDGlobalSettingsRecord* >
       
   493                         ( CCDRecordBase::RecordFactoryL( KCDTIdGlobalSettingsRecord ) );
       
   494                         
       
   495 	CleanupStack::PushL( globalSettings );
       
   496                         
       
   497     globalSettings->iRecordName.SetL( KGlobalSettingsRecordName );
       
   498 
       
   499     if( globalSettings->FindL( *db ) )
       
   500         {
       
   501         //Gprs attach mode
       
   502         if ( iAttachWhenNeeded )
       
   503             {
       
   504             CLOG_WRITE( "GPRS attach mode : attach when needed\n" )
       
   505             globalSettings->iGPRSAttachMode = RPacketService::EAttachWhenNeeded;
       
   506             }
       
   507         else
       
   508             {
       
   509             CLOG_WRITE( "GPRS attach mode : attach when available\n" )
       
   510             globalSettings->iGPRSAttachMode = RPacketService::EAttachWhenPossible;
       
   511             }
       
   512         }
       
   513         
       
   514     globalSettings->ModifyL( *db );
       
   515     
       
   516     CleanupStack::PopAndDestroy( globalSettings );    
       
   517     db->Close();
       
   518     CleanupStack::PopAndDestroy( db ); // db
       
   519     }
       
   520     
       
   521 
       
   522 // ---------------------------------------------------------
       
   523 // CProcessorGlobal::UpdateGlobalBearerArrayL
       
   524 // ---------------------------------------------------------
       
   525 //
       
   526 void CProcessorGlobal::UpdateGlobalBearerArrayL
       
   527                             ( TDbCreatorGlobalSettings aField, TUint32 aPrio )
       
   528     {
       
   529     TUint itemIndex( 0 );
       
   530     
       
   531     // Look up field from conversion table
       
   532     while( EUnused != KPriorityConversionTable[ itemIndex ].iField )
       
   533         {
       
   534         if( KPriorityConversionTable[ itemIndex ].iField == aField)
       
   535             {
       
   536             break;
       
   537             }
       
   538         ++itemIndex;
       
   539         }
       
   540         
       
   541     // If found
       
   542     if( EUnused != KPriorityConversionTable[ itemIndex ].iField )
       
   543         {
       
   544         if( !iBearerArrayChanged )
       
   545             {
       
   546             iCmManager->BearerPriorityArrayL( iBearerArray );
       
   547             iBearerArrayChanged = ETrue;
       
   548             }
       
   549         
       
   550         
       
   551         HBufC* tableName = HBufC::NewLC( KMaxTableNameSize );
       
   552         *tableName = TPtrC( KPriorityConversionTable[ itemIndex ]
       
   553                                                         .iBearerTableName );
       
   554         TBool foundBearer( EFalse );
       
   555         
       
   556         // Find the appropriate bearer type
       
   557         for( TInt i( 0 ); i < iBearerArray.Count(); ++i )
       
   558             {
       
   559             if( !( ( iBearerArray )[ i ].iServiceType->Compare( *tableName ) ) )
       
   560                 {
       
   561                 if( KPriorityConversionTable[ itemIndex ].iIsUIPriority )
       
   562                     {
       
   563                     ( iBearerArray )[ i ].iUIPriority = aPrio;
       
   564                     }
       
   565                 else
       
   566                     {
       
   567                     ( iBearerArray )[ i ].iPriority = aPrio;
       
   568                     }
       
   569                 foundBearer = ETrue;
       
   570                 break;
       
   571                 }
       
   572             }
       
   573         
       
   574         // If bearer was not found, add it to the table
       
   575         if( !foundBearer )
       
   576             {
       
   577             TBearerPriority newBearer;
       
   578             newBearer.iServiceType = tableName;
       
   579             if( KPriorityConversionTable[ itemIndex ].iIsUIPriority )
       
   580                 {
       
   581                 newBearer.iUIPriority = aPrio;
       
   582                 }
       
   583             else
       
   584                 {
       
   585                 newBearer.iPriority = aPrio;
       
   586                 }
       
   587             iBearerArray.Append( newBearer );
       
   588             }
       
   589 
       
   590         CleanupStack::PopAndDestroy( tableName ); // tableName 
       
   591         }
       
   592     }
       
   593 
       
   594 // ---------------------------------------------------------
       
   595 // CProcessorGlobal::SetGenConnSettingWlanUsage
       
   596 // ---------------------------------------------------------
       
   597 //
       
   598 void CProcessorGlobal::SetGenConnSettingWlanUsage( HBufC16* aPtrTag )
       
   599     {
       
   600     // This parameter should't be set at all if WLAN isn't supported.
       
   601     // However, CMM should take care of this in WriteGenConnSettingsL().
       
   602     if ( aPtrTag->CompareF( KStrManual ) == 0 ) 
       
   603         {
       
   604         iGenConnSettings->iUsageOfWlan = ECmUsageOfWlanManual;
       
   605         }
       
   606     // else: Default value for the string is: "Known", set in ConstructL()
       
   607     }
       
   608 
       
   609 // ---------------------------------------------------------
       
   610 // CProcessorGlobal::SetGenConnSettingCellularDataUsageHome
       
   611 // ---------------------------------------------------------
       
   612 //
       
   613 void CProcessorGlobal::SetGenConnSettingCellularDataUsageHome( HBufC16* aPtrTag )
       
   614     {
       
   615     if ( aPtrTag->CompareF( KStrAutomatic ) == 0 ) 
       
   616         {
       
   617         iGenConnSettings->iCellularDataUsageHome = ECmCellularDataUsageAutomatic;
       
   618         }
       
   619     else if ( iIsWlanS && aPtrTag->CompareF( KStrWlanOnly ) == 0 ) 
       
   620         {
       
   621         // This value can't be set if WLAN isn't supported
       
   622         iGenConnSettings->iCellularDataUsageHome = ECmCellularDataUsageDisabled;
       
   623         }
       
   624     // else: Default value for the string is: "Confirm", set in ConstructL()
       
   625     }
       
   626 
       
   627 // ---------------------------------------------------------
       
   628 // CProcessorGlobal::SetGenConnSettingCellularDataUsageVisitor
       
   629 // ---------------------------------------------------------
       
   630 //
       
   631 void CProcessorGlobal::SetGenConnSettingCellularDataUsageVisitor( HBufC16* aPtrTag )
       
   632     {
       
   633     if ( aPtrTag->CompareF( KStrAutomatic ) == 0 ) 
       
   634         {
       
   635         iGenConnSettings->iCellularDataUsageVisitor = ECmCellularDataUsageAutomatic;
       
   636         }
       
   637     else if ( iIsWlanS && aPtrTag->CompareF( KStrWlanOnly ) == 0 ) 
       
   638         {
       
   639         // This value can't be set if WLAN isn't supported
       
   640         iGenConnSettings->iCellularDataUsageVisitor = ECmCellularDataUsageDisabled;
       
   641         }
       
   642     // else: Default value for the string is: "Confirm", set in ConstructL()
       
   643     }
       
   644 
       
   645 // ---------------------------------------------------------
       
   646 // CProcessorGlobal::SetGenConnSettingsL
       
   647 // ---------------------------------------------------------
       
   648 //
       
   649 void CProcessorGlobal::SetGenConnSettingsL()
       
   650     {
       
   651     RCmManager cmManager;
       
   652     cmManager.CreateTablesAndOpenL();
       
   653     CleanupClosePushL( cmManager );
       
   654     cmManager.WriteGenConnSettingsL( *iGenConnSettings );
       
   655     CleanupStack::PopAndDestroy( &cmManager );
       
   656     }
       
   657 
       
   658 //-----------------------------------------------------------------------------
       
   659 //  CProcessorGlobal::SaveGlobalWlanParameterL()
       
   660 //-----------------------------------------------------------------------------
       
   661 //
       
   662 void CProcessorGlobal::SaveGlobalWlanParameterL( const TUint32 aTableType, const TDbCreatorGlobalSettings aField, const HBufC16* const aValue )
       
   663 	{	
       
   664 		// Initialize the record
       
   665 		CMDBGenericRecord* deviceSettingsTable = static_cast< CMDBGenericRecord* >
       
   666                 ( CCDRecordBase::RecordFactoryL( 0 ) );
       
   667                 
       
   668 	    CleanupStack::PushL( deviceSettingsTable );
       
   669 	    
       
   670 	    deviceSettingsTable->InitializeL( TPtrC( WLAN_DEVICE_SETTINGS ), NULL );
       
   671 	    			   			    
       
   672 	    deviceSettingsTable->LoadL( *iSession );
       
   673 	    
       
   674 	    // Open the record that matches aTableType (either default or user settings table)
       
   675 	    
       
   676 	    CMDBField<TUint32>* settingsTypeField = (CMDBField<TUint32>*)deviceSettingsTable->GetFieldByIdL(KCDTIdWlanDeviceSettingsType);
       
   677 	    
       
   678 	   	settingsTypeField->SetL( aTableType );
       
   679 	    			   			    
       
   680 	    deviceSettingsTable->FindL( *iSession );
       
   681 	    
       
   682 	    // Convert the input parameter to integer
       
   683     	TLex lex( *aValue );
       
   684 		
       
   685     	TInt value( 0 );
       
   686         User::LeaveIfError( lex.Val( value ) );
       
   687         
       
   688 		// Set the paramter value
       
   689 	    
       
   690 	    if ( aField == EWlanBGScanInterval )
       
   691 	    	{
       
   692 	    	CMDBField< TUint32 >* field = ( CMDBField< TUint32 >* ) deviceSettingsTable->GetFieldByIdL( KCDTIdBgScanInterval );
       
   693 	    	field->SetL( value );
       
   694 	    	}
       
   695 	    else if ( aField == EWlanUseDefSettings )
       
   696 	    	{
       
   697 	    	CMDBField< TBool >* field = ( CMDBField< TBool >* ) deviceSettingsTable->GetFieldByIdL( KCDTIdUseDefaultSettings );	
       
   698 	    	field->SetL( value );
       
   699 	    	}
       
   700 	    else if ( aField == EWlanLongRetry )
       
   701 	    	{
       
   702 			CMDBField< TUint32 >* field = ( CMDBField< TUint32 >* ) deviceSettingsTable->GetFieldByIdL( KCDTIdWlanLongRetry );				    	
       
   703 			field->SetL( value );
       
   704 	    	}
       
   705 	    else if ( aField == EWlanShortRetry )
       
   706 	    	{
       
   707 	    	CMDBField< TUint32 >* field = ( CMDBField< TUint32 >* ) deviceSettingsTable->GetFieldByIdL( KCDTIdWlanShortRetry );	
       
   708 	    	field->SetL( value );
       
   709 	    	}
       
   710 	    else if ( aField == EWlanRTS )
       
   711 	    	{
       
   712 	    	CMDBField< TUint32 >* field = ( CMDBField< TUint32 >* ) deviceSettingsTable->GetFieldByIdL( KCDTIdWlanRTSThreshold );	
       
   713 	    	field->SetL( value );
       
   714 	    	}
       
   715 	    else if ( aField == EWlanTxPowerLevel )
       
   716 	    	{
       
   717 	    	CMDBField< TUint32 >* field = ( CMDBField< TUint32 >* ) deviceSettingsTable->GetFieldByIdL( KCDTIdTxPowerLevel );	
       
   718 	    	field->SetL( value );
       
   719 	    	}
       
   720 	    else if ( aField == EWlanRadioMeasurements )
       
   721 	    	{
       
   722 	    	CMDBField< TBool >* field = ( CMDBField< TBool >* ) deviceSettingsTable->GetFieldByIdL( KCDTIdAllowRadioMeasurements );	
       
   723 	    	field->SetL( value );
       
   724 	    	}
       
   725 	    else if ( aField == EWlanPowerMode )
       
   726 	    	{
       
   727 	    	CMDBField< TBool >* field = ( CMDBField< TBool >* ) deviceSettingsTable->GetFieldByIdL( KCDTIdWlanPowerMode );	
       
   728 	    	field->SetL( value );
       
   729 	    	}			    			    			      			
       
   730 
       
   731 		deviceSettingsTable->ModifyL( *iSession );
       
   732 				
       
   733 		CleanupStack::PopAndDestroy( deviceSettingsTable );				
       
   734 	}
       
   735 // End of File.