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