voipplugins/voipadapters/cpgenvoipsettings/src/cwpgeneralvoipsettingsadapter.cpp
branchRCL_3
changeset 22 d38647835c2e
equal deleted inserted replaced
21:f742655b05bf 22:d38647835c2e
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Receives and stores general VoIP settings.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <CWPAdapter.h>
       
    21 #include <CWPCharacteristic.h>
       
    22 #include <CWPParameter.h>
       
    23 #include <wpgeneralvoipsettingsadapter.rsg>
       
    24 #include <bldvariant.hrh>
       
    25 #include <commdb.h>
       
    26 #include <e32des8.h>
       
    27 #include <WPAdapterUtil.h> // Adapter utils
       
    28 #include <utf.h> // Unicode conversion
       
    29 #include <crcseprofileentry.h>
       
    30 #include <crcseprofileregistry.h>
       
    31 #include <settingsinternalcrkeys.h>
       
    32 #include <centralrepository.h>
       
    33 #include <featmgr.h>
       
    34 
       
    35 #include "cwpgeneralvoipsettingsadapter.h"
       
    36 
       
    37 // Application related constants.
       
    38 _LIT( KGeneralVoIPSettingsAdapterName, "WPGeneralVoIPSettingsAdapter");
       
    39 _LIT( KGeneralVoIPSettingsAppID, "w9033" ); // OMA CP registration document.
       
    40 const TInt KMaxCharsInTUint32 = 10;
       
    41 _LIT8( KVoIPAppID8,       "w9013" );
       
    42 
       
    43 // RESOURCE parameters.
       
    44 // OMA CP registration document for general VoIP settings.
       
    45 _LIT( KParmCLIR,           "CLIR" );
       
    46 _LIT( KParmACBRULE,        "ACBRULE" );
       
    47 _LIT( KParmPREFTEL,        "PREFTEL" );
       
    48 _LIT( KParmDND,            "DND" );
       
    49 _LIT( KParmPSCALLWAITING,  "PSCALLWAITING" );
       
    50 // GOANNA:
       
    51 _LIT( KParmPREFTELLOCK,    "PREFTELLOCK" );
       
    52 _LIT( KParmCSRADIOWIFIOFF, "CSRADIOWIFIOFF" );
       
    53 
       
    54 
       
    55 // ======== MEMBER FUNCTIONS ========
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // CWPGeneralVoIPSettingsAdapter::CWPGeneralVoIPSettingsAdapter
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 CWPGeneralVoIPSettingsAdapter::CWPGeneralVoIPSettingsAdapter() : CWPAdapter()
       
    62     {
       
    63     }
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // CWPGeneralVoIPSettingsAdapter::ConstructL
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 void CWPGeneralVoIPSettingsAdapter::ConstructL()
       
    70     {
       
    71     TFileName fileName;
       
    72     Dll::FileName( fileName );
       
    73     
       
    74     iTitle = WPAdapterUtil::ReadHBufCL( fileName,
       
    75         KGeneralVoIPSettingsAdapterName,
       
    76         R_QTN_SM_HEAD_GENERAL_VOIP_SETTINGS );
       
    77     
       
    78     iDefaultName = WPAdapterUtil::ReadHBufCL( fileName,
       
    79         KGeneralVoIPSettingsAdapterName,
       
    80         R_QTN_SM_DEFAULT_NAME_GENERAL_VOIP_SETTINGS );
       
    81     
       
    82     iName = HBufC::NewL( 0 );
       
    83     iToAppref = HBufC8::NewL( 0 );
       
    84 
       
    85     _LIT8( KFormatTxt,"%u" );
       
    86     iSavedDataId    = HBufC8::NewL( KMaxCharsInTUint32 );
       
    87     iSavedDataId->Des().Format( KFormatTxt, KCRUidRichCallSettings );
       
    88 
       
    89     iIsAppIdOk      = EFalse;
       
    90     iIsNameOk       = EFalse;
       
    91     iClir           = KNotSet;
       
    92     iACBRule        = KNotSet;
       
    93     iPrefTel        = KNotSet;
       
    94     iDnd            = KNotSet;
       
    95     iPSCallWaiting  = KNotSet;
       
    96     iPrefTelLock    = KNotSet;
       
    97     iCsRadioWifiOff = KNotSet;
       
    98     iVoipId         = (TUint32)KNotSet;
       
    99 
       
   100     FeatureManager::InitializeLibL();
       
   101     iFeatMgrInitialized = ETrue;
       
   102     
       
   103     if ( !FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) )
       
   104         {
       
   105         User::Leave( KErrNotSupported );
       
   106         }
       
   107     }
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // CWPGeneralVoIPSettingsAdapter::NewL
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 CWPGeneralVoIPSettingsAdapter* CWPGeneralVoIPSettingsAdapter::NewL()
       
   114     {
       
   115     CWPGeneralVoIPSettingsAdapter* self = new (ELeave) 
       
   116         CWPGeneralVoIPSettingsAdapter;
       
   117     CleanupStack::PushL( self );
       
   118     self->ConstructL();
       
   119     CleanupStack::Pop();
       
   120     return self;
       
   121     }
       
   122 
       
   123 // ---------------------------------------------------------------------------
       
   124 // CWPGeneralVoIPSettingsAdapter::~CWPGeneralVoIPSettingsAdapter
       
   125 // ---------------------------------------------------------------------------
       
   126 //
       
   127 CWPGeneralVoIPSettingsAdapter::~CWPGeneralVoIPSettingsAdapter()
       
   128     {
       
   129     delete iTitle;
       
   130     delete iDefaultName;
       
   131     delete iName;
       
   132     delete iSavedDataId;
       
   133     delete iToAppref;
       
   134 
       
   135     if ( iFeatMgrInitialized )
       
   136         {
       
   137         FeatureManager::UnInitializeLib();
       
   138         }
       
   139     }
       
   140 
       
   141 // ---------------------------------------------------------------------------
       
   142 // CWPGeneralVoIPSettingsAdapter::SetNameL
       
   143 // Set iName, the user viewable name of general VoIP settings.
       
   144 // ---------------------------------------------------------------------------
       
   145 //
       
   146 void CWPGeneralVoIPSettingsAdapter::SetNameL( const TDesC& aName )
       
   147     {
       
   148     if ( !iIsNameOk )
       
   149         {
       
   150         delete iName;
       
   151         iName = NULL;
       
   152         iName = aName.AllocL();
       
   153         }
       
   154     }
       
   155 
       
   156 // ---------------------------------------------------------------------------
       
   157 // CWPGeneralVoIPSettingsAdapter::SetClir
       
   158 // Sets CLIR in enabled or disabled mode.
       
   159 // ---------------------------------------------------------------------------
       
   160 //
       
   161 void CWPGeneralVoIPSettingsAdapter::SetClir( const TInt aClir )
       
   162     {
       
   163     iClir = aClir;
       
   164     }
       
   165 
       
   166 // ---------------------------------------------------------------------------
       
   167 // CWPGeneralVoIPSettingsAdapter::SetACBRule
       
   168 // Sets a rule for Anonymous Call Blocking feature.
       
   169 // ---------------------------------------------------------------------------
       
   170 //
       
   171 void CWPGeneralVoIPSettingsAdapter::SetACBRule( const TInt aACBRule )
       
   172     {
       
   173     iACBRule = aACBRule;
       
   174     }
       
   175 
       
   176 // ---------------------------------------------------------------------------
       
   177 // CWPGeneralVoIPSettingsAdapter::SetPrefTel
       
   178 // Sets the preferred telephony mode.
       
   179 // ---------------------------------------------------------------------------
       
   180 //
       
   181 void CWPGeneralVoIPSettingsAdapter::SetPrefTel( const TInt aPrefTel )
       
   182     {
       
   183     iPrefTel = aPrefTel;
       
   184     }
       
   185 
       
   186 // ---------------------------------------------------------------------------
       
   187 // CWPGeneralVoIPSettingsAdapter::SetDnd
       
   188 // Enables or disables the Do Not Disturb setting.
       
   189 // ---------------------------------------------------------------------------
       
   190 //
       
   191 void CWPGeneralVoIPSettingsAdapter::SetDnd( const TInt aDnd )
       
   192     {
       
   193     iDnd = aDnd;
       
   194     }
       
   195 
       
   196 // ---------------------------------------------------------------------------
       
   197 // CWPGeneralVoIPSettingsAdapter::SetPSCallWaiting
       
   198 // Sets call waiting in enabled or disabled mode.
       
   199 // ---------------------------------------------------------------------------
       
   200 //
       
   201 void CWPGeneralVoIPSettingsAdapter::SetPSCallWaiting( 
       
   202     const TInt aPSCallWaiting )
       
   203     {
       
   204     iPSCallWaiting = aPSCallWaiting;
       
   205     }
       
   206 
       
   207 // ---------------------------------------------------------------------------
       
   208 // CWPGeneralVoIPSettingsAdapter::SetPrefTelLock
       
   209 // Enables or disables preferred telephony mode to be edited from UI.
       
   210 // ---------------------------------------------------------------------------
       
   211 //
       
   212 void CWPGeneralVoIPSettingsAdapter::SetPrefTelLock( const TInt aPrefTelLock )
       
   213     {
       
   214     iPrefTelLock = aPrefTelLock;
       
   215     }
       
   216 
       
   217 
       
   218 // ---------------------------------------------------------------------------
       
   219 // CWPGeneralVoIPSettingsAdapter::SetCsRadioWifiOff
       
   220 // Sets CS radio in WiFi mode in turned on or off mode.
       
   221 // ---------------------------------------------------------------------------
       
   222 //
       
   223 void CWPGeneralVoIPSettingsAdapter::SetCsRadioWifiOff( 
       
   224     const TInt aCsRadioWifiOff )
       
   225     {
       
   226     iCsRadioWifiOff = aCsRadioWifiOff;
       
   227     }
       
   228 
       
   229 // ---------------------------------------------------------------------------
       
   230 // CWPGeneralVoIPSettingsAdapter::SetToApprefL
       
   231 // Sets TO-APPREF if it hasn't been set before.
       
   232 // ---------------------------------------------------------------------------
       
   233 //
       
   234 void CWPGeneralVoIPSettingsAdapter::SetToApprefL( const TDesC8& aToAppRef )
       
   235     {
       
   236     if ( !iToApprefSet )
       
   237         {        
       
   238         delete iToAppref;
       
   239         iToAppref = NULL;
       
   240         iToAppref = aToAppRef.AllocL(); 
       
   241         }
       
   242     }
       
   243 
       
   244 // ---------------------------------------------------------------------------
       
   245 // CWPGeneralVoIPSettingsAdapter::Name
       
   246 // Returns the user viewable name of general VoIP settings.
       
   247 // ---------------------------------------------------------------------------
       
   248 //
       
   249 TDesC& CWPGeneralVoIPSettingsAdapter::Name()
       
   250     {
       
   251     return *iName;
       
   252     }
       
   253 
       
   254 // ---------------------------------------------------------------------------
       
   255 // CWPGeneralVoIPSettingsAdapter::Clir
       
   256 // Tells whether CLIR is enabled or disabled.
       
   257 // ---------------------------------------------------------------------------
       
   258 //
       
   259 TInt CWPGeneralVoIPSettingsAdapter::Clir()
       
   260     {
       
   261     return iClir;
       
   262     }
       
   263 
       
   264 // ---------------------------------------------------------------------------
       
   265 // CWPGeneralVoIPSettingsAdapter::ACBRule
       
   266 // Returns the rule of Anonymous Call Blocking feature.
       
   267 // ---------------------------------------------------------------------------
       
   268 //
       
   269 TInt CWPGeneralVoIPSettingsAdapter::ACBRule()
       
   270     {
       
   271     return iACBRule;
       
   272     }
       
   273 
       
   274 // ---------------------------------------------------------------------------
       
   275 // CWPGeneralVoIPSettingsAdapter::PrefTel
       
   276 // Returns the preferred telephony mode.
       
   277 // ---------------------------------------------------------------------------
       
   278 //
       
   279 TInt CWPGeneralVoIPSettingsAdapter::PrefTel()
       
   280     {
       
   281     return iPrefTel;
       
   282     }
       
   283 
       
   284 // ---------------------------------------------------------------------------
       
   285 // CWPGeneralVoIPSettingsAdapter::Dnd
       
   286 // Returns the state of the Do Not Disturb setting.
       
   287 // ---------------------------------------------------------------------------
       
   288 //
       
   289 TInt CWPGeneralVoIPSettingsAdapter::Dnd()
       
   290     {
       
   291     return iDnd;
       
   292     }
       
   293 
       
   294 // ---------------------------------------------------------------------------
       
   295 // CWPGeneralVoIPSettingsAdapter::PSCallWaiting
       
   296 // Returns the state of VoIP call waiting feature.
       
   297 // ---------------------------------------------------------------------------
       
   298 //
       
   299 TInt CWPGeneralVoIPSettingsAdapter::PSCallWaiting()
       
   300     {
       
   301     return iPSCallWaiting;
       
   302     }
       
   303 
       
   304 // ---------------------------------------------------------------------------
       
   305 // CWPGeneralVoIPSettingsAdapter::PrefTelLock
       
   306 // Returns preferred telephony lock, i.e. tells whether preferred telephony
       
   307 // can be edited from UI.
       
   308 // ---------------------------------------------------------------------------
       
   309 //
       
   310 TInt CWPGeneralVoIPSettingsAdapter::PrefTelLock()
       
   311     {
       
   312     return iPrefTelLock;
       
   313     }
       
   314 
       
   315 // ---------------------------------------------------------------------------
       
   316 // CWPGeneralVoIPSettingsAdapter::CsRadioWifiOff
       
   317 // Tells whether CS radio is turned off in WiFi mode.
       
   318 // ---------------------------------------------------------------------------
       
   319 //
       
   320 TInt CWPGeneralVoIPSettingsAdapter::CsRadioWifiOff()
       
   321     {
       
   322     return iCsRadioWifiOff;
       
   323     }
       
   324 
       
   325 // ---------------------------------------------------------------------------
       
   326 // CWPGeneralVoIPSettingsAdapter::ItemCount
       
   327 // From class CWPAdapter.
       
   328 // Checks the number of settings items. Since there can only be one set of
       
   329 // general VoIP settings, always return 1.
       
   330 // ---------------------------------------------------------------------------
       
   331 //
       
   332 TInt CWPGeneralVoIPSettingsAdapter::ItemCount() const
       
   333     {
       
   334     return iIsAppIdOk ? 1 : 0;
       
   335     }
       
   336 
       
   337 // ---------------------------------------------------------------------------
       
   338 // From class CWPAdapter.
       
   339 // CWPGeneralVoIPSettingsAdapter::SummaryTitle
       
   340 // Returns the summary title of general VoIP settings item.
       
   341 // ---------------------------------------------------------------------------
       
   342 //
       
   343 const TDesC16& CWPGeneralVoIPSettingsAdapter::SummaryTitle( 
       
   344     TInt /*aIndex*/ ) const
       
   345     {
       
   346     if ( iIsAppIdOk )
       
   347         {
       
   348         return *iTitle;
       
   349         }
       
   350     return KNullDesC16;
       
   351     }
       
   352 
       
   353 // ---------------------------------------------------------------------------
       
   354 // CWPGeneralVoIPSettingsAdapter::SummaryText
       
   355 // From class CWPAdapter.
       
   356 // Returns the summary text of general VoIP settings.
       
   357 // ---------------------------------------------------------------------------
       
   358 //
       
   359 const TDesC16& CWPGeneralVoIPSettingsAdapter::SummaryText( 
       
   360     TInt /*aIndex*/ ) const
       
   361     {
       
   362     if ( iIsAppIdOk )
       
   363         {
       
   364         if ( 0 == iName->Length() )
       
   365             {
       
   366             return *iDefaultName;
       
   367             }
       
   368         return *iName;
       
   369         }
       
   370     return KNullDesC16;
       
   371     }
       
   372 
       
   373 // ---------------------------------------------------------------------------
       
   374 // CWPGeneralVoIPSettingsAdapter::SaveL
       
   375 // From class CWPAdapter.
       
   376 // Saves the general VoIP settings via Central Repository.
       
   377 // ---------------------------------------------------------------------------
       
   378 //
       
   379 void CWPGeneralVoIPSettingsAdapter::SaveL( TInt /*aIndex*/ )
       
   380     {
       
   381     // Settings will not be saved if the APPID parameter is not w9033, i.e. 
       
   382     // OMA APPID for general VoIP settings.
       
   383     if ( iIsAppIdOk )
       
   384         {
       
   385         CRepository* cRepository = CRepository::NewLC( 
       
   386             KCRUidRichCallSettings );
       
   387         if( KNotSet != Clir() )
       
   388             {
       
   389             User::LeaveIfError( cRepository->Set( KRCSEClir, Clir() ) );
       
   390             }
       
   391         if ( KNotSet != ACBRule() )
       
   392             {
       
   393             User::LeaveIfError( cRepository->Set( KRCSEAnonymousCallBlockRule,
       
   394                 ACBRule() ) );
       
   395             }
       
   396         if ( KNotSet != PrefTel() )
       
   397             {
       
   398             User::LeaveIfError( cRepository->Set( KRCSEPreferredTelephony,
       
   399                 PrefTel() ) );
       
   400             }
       
   401         if ( KNotSet != Dnd() )
       
   402             {
       
   403             User::LeaveIfError( cRepository->Set( KRCSEDoNotDisturb,
       
   404                 Dnd() ) );
       
   405             }
       
   406         if ( KNotSet != PSCallWaiting() )
       
   407             {
       
   408             User::LeaveIfError( cRepository->Set( KRCSPSCallWaiting,
       
   409                 PSCallWaiting() ) );
       
   410             }
       
   411         CleanupStack::PopAndDestroy( cRepository );
       
   412         }
       
   413     }
       
   414 
       
   415 // ---------------------------------------------------------------------------
       
   416 // CWPGeneralVoIPSettingsAdapter::CanSetAsDefault
       
   417 // From class CWPAdapter.
       
   418 // Return EFalse since there can only be one set of general VoIP settings.
       
   419 // ---------------------------------------------------------------------------
       
   420 //
       
   421 TBool CWPGeneralVoIPSettingsAdapter::CanSetAsDefault( TInt /*aIndex*/ ) const
       
   422     {
       
   423     return EFalse;
       
   424     }
       
   425 
       
   426 // ---------------------------------------------------------------------------
       
   427 // CWPGeneralVoIPSettingsAdapter::DetailsL
       
   428 // From class CWPAdapter.
       
   429 // Not supported.
       
   430 // ---------------------------------------------------------------------------
       
   431 //
       
   432 TInt CWPGeneralVoIPSettingsAdapter::DetailsL( TInt /*aItem*/, 
       
   433     MWPPairVisitor& /*aVisitor */ )
       
   434     {
       
   435     return KErrNotSupported;
       
   436     }  
       
   437 
       
   438 // ---------------------------------------------------------------------------
       
   439 // CWPGeneralVoIPSettingsAdapter::VisitL
       
   440 // From class CWPAdapter.
       
   441 // ---------------------------------------------------------------------------
       
   442 //
       
   443 void CWPGeneralVoIPSettingsAdapter::VisitL( 
       
   444     CWPCharacteristic& aCharacteristic )
       
   445     {
       
   446     switch( aCharacteristic.Type() )
       
   447         {
       
   448         // Core general VoIP settings.
       
   449         case KWPApplication:
       
   450             {
       
   451             aCharacteristic.AcceptL( *this );
       
   452             if ( 0 == iAppID.Compare( KGeneralVoIPSettingsAppID() ) )
       
   453                 {
       
   454                 iIsAppIdOk = ETrue;
       
   455                 iIsNameOk = ETrue;
       
   456                 iToApprefSet = ETrue; // TO-APPREF can't be modified anymore.
       
   457                 }
       
   458             if ( !iIsAppIdOk )
       
   459                 {
       
   460                 iName->Des().Zero(); // Otherwise iName may have wrong value.
       
   461                 }
       
   462             break;
       
   463             }
       
   464         default:
       
   465             break;
       
   466         }
       
   467     }
       
   468 
       
   469 
       
   470 // ---------------------------------------------------------------------------
       
   471 // CWPGeneralVoIPSettingsAdapter::SettingsSavedL
       
   472 // From class CWPAdapter.
       
   473 // ---------------------------------------------------------------------------
       
   474 // 
       
   475 void CWPGeneralVoIPSettingsAdapter::SettingsSavedL( const TDesC8& aAppIdOfSavingItem,
       
   476     const TDesC8& aAppRef, const TDesC8& aStorageIdValue )
       
   477     {
       
   478     if ( PrefTel() && KVoIPAppID8().CompareF( aAppIdOfSavingItem ) == 0 &&
       
   479          0 == iToAppref->Compare( aAppRef ) )
       
   480         {
       
   481         TInt voipId;
       
   482         TLex8 lex( aStorageIdValue );
       
   483         User::LeaveIfError( lex.Val( voipId ) );
       
   484         iVoipId = voipId;
       
   485         }
       
   486     }
       
   487 
       
   488 // ---------------------------------------------------------------------------
       
   489 // CWPGeneralVoIPSettingsAdapter::VisitL
       
   490 // From class CWPAdapter.
       
   491 // General VoIP settings parameters are handled in this method.
       
   492 // ---------------------------------------------------------------------------
       
   493 //
       
   494 void CWPGeneralVoIPSettingsAdapter::VisitL( CWPParameter& aParameter )
       
   495     {
       
   496     // tmpValue holds the value converted from Unicode to UTF8.
       
   497     HBufC8* tmpValue = HBufC8::NewLC( aParameter.Value().Length() ); // CS:1
       
   498     TPtr8 ptrTmpValue( tmpValue->Des() );
       
   499     CnvUtfConverter::ConvertFromUnicodeToUtf8( ptrTmpValue,
       
   500         aParameter.Value() );
       
   501     
       
   502     switch ( aParameter.ID() )
       
   503         {
       
   504         case EWPParameterToAppRef:
       
   505             {
       
   506             SetToApprefL( tmpValue->Des() );
       
   507             }
       
   508             break;
       
   509             
       
   510         case EWPParameterAppID:
       
   511             {
       
   512 	        iAppID.Set( aParameter.Value() );
       
   513             break;
       
   514             }
       
   515         
       
   516         // Case 0 handles the general VoIP parameters that are extensions to
       
   517         // OMA Client Provisioning parameter set.
       
   518         case 0:
       
   519             if ( 0 == aParameter.Name().Compare( KParmCLIR ) )
       
   520                 {
       
   521                 TInt tIntParameterValue;
       
   522                 TLex8 lex( tmpValue->Des() );
       
   523                 TInt err( KErrNone );            
       
   524                 err = lex.Val( tIntParameterValue );
       
   525                 if ( KErrNone != err )
       
   526                     {
       
   527                     break;
       
   528                     }
       
   529                 SetClir( tIntParameterValue );    
       
   530                 }
       
   531             else if ( 0 == aParameter.Name().Compare( KParmACBRULE ) )
       
   532                 {
       
   533                 TInt tIntParameterValue;
       
   534                 TLex8 lex( tmpValue->Des() );
       
   535                 TInt err( KErrNone );            
       
   536                 err = lex.Val( tIntParameterValue );
       
   537                 if ( KErrNone != err )
       
   538                     {
       
   539                     break;
       
   540                     }
       
   541                 SetACBRule( tIntParameterValue );    
       
   542                 }
       
   543             else if ( 0 == aParameter.Name().Compare( KParmPREFTEL ) )
       
   544                 {
       
   545                 TInt tIntParameterValue;
       
   546                 TLex8 lex( tmpValue->Des() );
       
   547                 TInt err( KErrNone );            
       
   548                 err = lex.Val( tIntParameterValue );
       
   549                 if ( KErrNone != err )
       
   550                     {
       
   551                     break;
       
   552                     }
       
   553                 SetPrefTel( tIntParameterValue );
       
   554                 }
       
   555             else if ( 0 == aParameter.Name().Compare( KParmDND ) )
       
   556                 {
       
   557                 TInt tIntParameterValue;
       
   558                 TLex8 lex( tmpValue->Des() );
       
   559                 TInt err( KErrNone );            
       
   560                 err = lex.Val( tIntParameterValue );
       
   561                 if ( KErrNone != err )
       
   562                     {
       
   563                     break;
       
   564                     }
       
   565                 SetDnd( tIntParameterValue );    
       
   566                 }
       
   567             else if ( 0 == aParameter.Name().Compare( KParmPSCALLWAITING ) )
       
   568                 {
       
   569                 TInt tIntParameterValue;
       
   570                 TLex8 lex( tmpValue->Des() );
       
   571                 TInt err( KErrNone );            
       
   572                 err = lex.Val( tIntParameterValue );
       
   573                 if ( KErrNone != err )
       
   574                     {
       
   575                     break;
       
   576                     }
       
   577                 SetPSCallWaiting( tIntParameterValue );    
       
   578                 }
       
   579             else if ( 0 == aParameter.Name().Compare( KParmPREFTELLOCK ) )
       
   580                 {
       
   581                 TInt tIntParameterValue;
       
   582                 TLex8 lex( tmpValue->Des() );
       
   583                 TInt err( KErrNone );            
       
   584                 err = lex.Val( tIntParameterValue );
       
   585                 if ( KErrNone != err )
       
   586                     {
       
   587                     break;
       
   588                     }
       
   589                 SetPrefTelLock( tIntParameterValue );    
       
   590                 }
       
   591             else if ( 0 == aParameter.Name().Compare( KParmCSRADIOWIFIOFF ) )
       
   592                 {
       
   593                 TInt tIntParameterValue;
       
   594                 TLex8 lex( tmpValue->Des() );
       
   595                 TInt err( KErrNone );            
       
   596                 err = lex.Val( tIntParameterValue );
       
   597                 if ( KErrNone != err )
       
   598                     {
       
   599                     break;
       
   600                     }
       
   601                 SetCsRadioWifiOff( tIntParameterValue );    
       
   602                 }
       
   603             break;
       
   604             
       
   605         case EWPParameterName: // APPLICATION/NAME
       
   606             SetNameL( aParameter.Value() );
       
   607             break;
       
   608 
       
   609 		default:
       
   610 			break;
       
   611         }// switch
       
   612     CleanupStack::PopAndDestroy( tmpValue ); // CS:0				
       
   613     }
       
   614 
       
   615 // ---------------------------------------------------------------------------
       
   616 // CWPGeneralVoIPSettingsAdapter::SavingFinalizedL
       
   617 // From class CWPAdapter.
       
   618 // ---------------------------------------------------------------------------
       
   619 //
       
   620 void CWPGeneralVoIPSettingsAdapter::SavingFinalizedL()
       
   621     {
       
   622     if ( (TUint32)KNotSet == iVoipId )
       
   623         {
       
   624         return;
       
   625         }
       
   626 
       
   627     // Get service ID from RCSE.
       
   628     CRCSEProfileRegistry* registry = CRCSEProfileRegistry::NewLC();
       
   629     CRCSEProfileEntry* entry = CRCSEProfileEntry::NewLC();        
       
   630 
       
   631     registry->FindL( iVoipId, *entry );        
       
   632     TUint serviceId = entry->iServiceProviderId;
       
   633 
       
   634     CleanupStack::PopAndDestroy( 2, registry ); // entry, registry
       
   635 
       
   636     // Set the preferred service ID.
       
   637     CRepository* repository = CRepository::NewL( KCRUidRichCallSettings );
       
   638     repository->Set( KRCSPSPreferredService, (TInt)serviceId );
       
   639     delete repository;
       
   640     }
       
   641 
       
   642 // ---------------------------------------------------------------------------
       
   643 // CWPGeneralVoIPSettingsAdapter::ContextExtension
       
   644 // From class MWPContextExtension.
       
   645 // Returns a pointer to context extension.
       
   646 // ---------------------------------------------------------------------------
       
   647 //
       
   648 TInt CWPGeneralVoIPSettingsAdapter::ContextExtension( 
       
   649     MWPContextExtension*& aExtension )
       
   650     {
       
   651     aExtension = this;
       
   652     return KErrNone;
       
   653     }
       
   654 
       
   655 // ---------------------------------------------------------------------------
       
   656 // CWPGeneralVoIPSettingsAdapter::SaveDataL
       
   657 // From class MWPContextExtension.
       
   658 // Returns ID of saved data.
       
   659 // ---------------------------------------------------------------------------
       
   660 //
       
   661 const TDesC8& CWPGeneralVoIPSettingsAdapter::SaveDataL( TInt /*aIndex*/ ) const
       
   662     {
       
   663     return *iSavedDataId;
       
   664     }
       
   665 
       
   666 // ---------------------------------------------------------------------------
       
   667 // CWPGeneralVoIPSettingsAdapter::DeleteL
       
   668 // From class MWPContextExtension.
       
   669 // Deletes general VoIP settings from Central Repository.
       
   670 // ---------------------------------------------------------------------------
       
   671 //
       
   672 void CWPGeneralVoIPSettingsAdapter::DeleteL( const TDesC8& aSaveData )
       
   673     {
       
   674     TInt tInt( 0 );
       
   675     TLex8 lex( aSaveData );
       
   676     TInt err( KErrNone );            
       
   677     err = lex.Val( tInt );
       
   678     TUid cenRepUid = { tInt };
       
   679     if ( KErrNone == err && KCRUidRichCallSettings == cenRepUid )
       
   680         {
       
   681         CRepository* cRepository = CRepository::NewLC( cenRepUid );
       
   682         User::LeaveIfError( cRepository->Reset( KRCSEClir ) );
       
   683         User::LeaveIfError( cRepository->Reset(
       
   684             KRCSEAnonymousCallBlockRule ) );
       
   685         User::LeaveIfError( cRepository->Reset( KRCSEPreferredTelephony ) );
       
   686         User::LeaveIfError( cRepository->Reset( KRCSEDoNotDisturb ) );
       
   687         User::LeaveIfError( cRepository->Reset( KRCSPSCallWaiting ) );
       
   688         User::LeaveIfError( cRepository->Reset( KRCSPSPreferredService ) );
       
   689         
       
   690         CleanupStack::PopAndDestroy( cRepository );
       
   691         cRepository = NULL;
       
   692         }
       
   693     }
       
   694 
       
   695 // ---------------------------------------------------------------------------
       
   696 // CWPGeneralVoIPSettingsAdapter::Uid
       
   697 // From class MWPContextExtension.
       
   698 // Returns the UID of this adapter.
       
   699 // ---------------------------------------------------------------------------
       
   700 //
       
   701 TUint32 CWPGeneralVoIPSettingsAdapter::Uid() const
       
   702     {
       
   703     return iDtor_ID_Key.iUid;
       
   704     }
       
   705 
       
   706 //  End of File