richcallsettingsengine/rcse2/src/crcseprofileregistry.cpp
branchRCL_3
changeset 22 d38647835c2e
equal deleted inserted replaced
21:f742655b05bf 22:d38647835c2e
       
     1 /*
       
     2 * Copyright (c) 2002-2010 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:  Stores and loads CRCSEProfileEntry to/from data storage.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <sipmanagedprofileregistry.h>
       
    22 #include <sipprofile.h>
       
    23 
       
    24 #include <spsettings.h>
       
    25 #include <spentry.h>
       
    26 #include <spproperty.h>
       
    27 #include <spdefinitions.h>
       
    28 #include <featmgr.h>
       
    29 
       
    30 #include <cenrepdatabaseutil.h>
       
    31 #include <cenrepdatabaseproperty.h>
       
    32 
       
    33 #include <mmf/common/mmfcontrollerpluginresolver.h>
       
    34 
       
    35 #include "crcseprofileregistry.h"
       
    36 #include "crcseprofileentry.h"
       
    37 #include "crcseaudiocodecregistry.h"
       
    38 #include "rcsepanic.h"
       
    39 #include "rcseconstants.h"
       
    40 #include "rcsedefaults.h"
       
    41 #include "rcseprivatecrkeys.h"
       
    42 #include "rcselogger.h"
       
    43 
       
    44 
       
    45 const TInt KArrayInitSize = 2;
       
    46 
       
    47 // ============================ MEMBER FUNCTIONS ===============================
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CRCSEProfileRegistry::CRCSEProfileRegistry
       
    51 // C++ default constructor can NOT contain any code, that
       
    52 // might leave.
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 CRCSEProfileRegistry::CRCSEProfileRegistry()
       
    56     : CRCSERegistryBase( EVoIPProfile ),
       
    57       iSIPRegistry( NULL )
       
    58     {
       
    59     }
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CRCSEProfileRegistry::ConstructL
       
    63 // Symbian 2nd phase constructor can leave.
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 void CRCSEProfileRegistry::ConstructL()
       
    67     {
       
    68     // Check VoIP support from feature manager
       
    69     FeatureManager::InitializeLibL();
       
    70     TBool support = FeatureManager::FeatureSupported( KFeatureIdCommonVoip );
       
    71     FeatureManager::UnInitializeLib();
       
    72     if ( !support )
       
    73         {
       
    74         User::Leave( KErrNotSupported );
       
    75         }
       
    76 
       
    77     BaseConstructL();
       
    78     iSIPRegistry = CSIPManagedProfileRegistry::NewL( *this );
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CRCSEProfileRegistry::NewL
       
    83 // Two-phased constructor.
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 EXPORT_C CRCSEProfileRegistry* CRCSEProfileRegistry::NewL()
       
    87     {
       
    88     CRCSEProfileRegistry* self = CRCSEProfileRegistry::NewLC();
       
    89     CleanupStack::Pop( self );
       
    90     return self;
       
    91     }
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CRCSEProfileRegistry::NewLC
       
    95 // Two-phased constructor.
       
    96 // -----------------------------------------------------------------------------
       
    97 //
       
    98 EXPORT_C CRCSEProfileRegistry* CRCSEProfileRegistry::NewLC()
       
    99     {
       
   100     CRCSEProfileRegistry* self = new( ELeave ) CRCSEProfileRegistry;
       
   101     CleanupStack::PushL( self );
       
   102     self->ConstructL();
       
   103     return self;
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // Destructor
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 EXPORT_C CRCSEProfileRegistry::~CRCSEProfileRegistry()
       
   111     {
       
   112     RCSELOGSTRING( "CRCSEProfileRegistry::~CRCSEProfileRegistry() - IN" );
       
   113 
       
   114     delete iSIPRegistry;
       
   115     iSIPProfiles.ResetAndDestroy();
       
   116 
       
   117     RCSELOGSTRING( "CRCSEProfileRegistry::~CRCSEProfileRegistry() - OUT" );
       
   118     }
       
   119     
       
   120 // -----------------------------------------------------------------------------
       
   121 // CRCSEProfileRegistry::FindL
       
   122 // Start search of profile entry by provider name.
       
   123 // -----------------------------------------------------------------------------
       
   124 //
       
   125 EXPORT_C void CRCSEProfileRegistry::FindL( 
       
   126     const TDesC& aProviderName,
       
   127     CRCSEProfileEntry& aFoundEntry )
       
   128     {
       
   129     RCSELOGSTRING2( "CRCSEProfileRegistry::FindL(%S) - IN", &aProviderName );
       
   130 
       
   131     BeginL();
       
   132 
       
   133     RArray<TUint32> entryIds;
       
   134     CleanupClosePushL( entryIds );
       
   135 
       
   136     // Search IDs of entries that have this service ID
       
   137     FindIdsByValueL( KColProviderName,
       
   138                      aProviderName, 
       
   139                      entryIds );
       
   140 
       
   141     // Search whole entry if ID was found
       
   142     if ( 0 < entryIds.Count() )
       
   143         {
       
   144         FindEntryL( entryIds[ 0 ], aFoundEntry );
       
   145         }
       
   146     else
       
   147         {
       
   148         User::Leave( KErrNotFound );
       
   149         }
       
   150 
       
   151     // Check that SIP Ids are valid
       
   152     UpdateSIPProfileLinksL( aFoundEntry );
       
   153     
       
   154     CleanupStack::PopAndDestroy( &entryIds );
       
   155 
       
   156     EndL();
       
   157 
       
   158     RCSELOGSTRING2( "CRCSEProfileRegistry::FindL(%S) - OUT", &aProviderName );
       
   159     }
       
   160 
       
   161 // -----------------------------------------------------------------------------
       
   162 // CRCSEProfileRegistry::FindL
       
   163 // Start search of profile entry by ID.
       
   164 // -----------------------------------------------------------------------------
       
   165 //
       
   166 EXPORT_C void CRCSEProfileRegistry::FindL( 
       
   167     TUint32 aProfileId, 
       
   168     CRCSEProfileEntry& aFoundEntry )
       
   169     {
       
   170     RCSELOGSTRING2( "CRCSEProfileRegistry::FindL(id=%d) - IN", aProfileId );
       
   171 
       
   172     BeginL();
       
   173 
       
   174     FindEntryL( aProfileId, aFoundEntry );
       
   175 
       
   176     // Check that SIP Ids are valid
       
   177     UpdateSIPProfileLinksL( aFoundEntry );
       
   178 
       
   179     EndL();
       
   180 
       
   181     RCSELOGSTRING2( "CRCSEProfileRegistry::FindL(id=%d) - OUT", aProfileId );
       
   182     }
       
   183     
       
   184 // -----------------------------------------------------------------------------
       
   185 // CRCSEProfileRegistry::AddL
       
   186 // Start addition of profile entry.
       
   187 // -----------------------------------------------------------------------------
       
   188 //
       
   189 EXPORT_C TUint32 CRCSEProfileRegistry::AddL( 
       
   190     const CRCSEProfileEntry& aNewEntry )
       
   191     {
       
   192     RCSELOGSTRING( "CRCSEProfileRegistry::AddL() - IN" );
       
   193 
       
   194     BeginL();
       
   195 
       
   196     TUint32 id( KNoEntryId );
       
   197 
       
   198     // Add entry to storage
       
   199     AddOrUpdateEntryL( id, aNewEntry );
       
   200 
       
   201     __ASSERT_ALWAYS( KNoEntryId < id, User::Leave( KErrCorrupt ) );
       
   202 
       
   203     // Create service settings or use existing
       
   204     CRCSEProfileEntry& modifyEntry 
       
   205         = const_cast<CRCSEProfileEntry&>( aNewEntry );
       
   206 
       
   207     // New service settings entry...
       
   208     if( ( CRCSEProfileEntry::EOONotSet == modifyEntry.iNewServiceTableEntry ||
       
   209           CRCSEProfileEntry::EOn == modifyEntry.iNewServiceTableEntry ) )
       
   210         {
       
   211         CreateDefaultServiceSettingsL( modifyEntry );
       
   212         if ( modifyEntry.iServiceProviderId != KRCSEDefServiceProviderId )
       
   213             {
       
   214             UpdateServiceIdL( id, modifyEntry.iServiceProviderId );
       
   215             }
       
   216         }
       
   217 
       
   218     // Use existing service settings entry if
       
   219     // - given service id is valid
       
   220     // - service id is not used by another profile
       
   221     // - provider name is valid
       
   222     else if( CRCSEProfileEntry::EOff == modifyEntry.iNewServiceTableEntry &&
       
   223              KSPNoId < modifyEntry.iServiceProviderId )
       
   224         {
       
   225         // Check that provide name is valid
       
   226         TBool providerExist( 
       
   227             NameExistsInServiceTableL( modifyEntry.iProviderName ) );
       
   228 
       
   229         if( !providerExist )
       
   230             {
       
   231             User::Leave( KErrNotFound );
       
   232             }
       
   233 
       
   234         // Check that service id is not used by another profile
       
   235         LeaveIfServiceIdInUseL( modifyEntry );
       
   236         }
       
   237 
       
   238     // Fail all other cases
       
   239     else
       
   240         {
       
   241         User::Leave( KErrArgument );
       
   242         }
       
   243 
       
   244     EndL();
       
   245 
       
   246     RCSELOGSTRING( "CRCSEProfileRegistry::AddL() - OUT" );
       
   247 
       
   248     return id;
       
   249     }
       
   250 
       
   251 // -----------------------------------------------------------------------------
       
   252 // CRCSEProfileRegistry::DeleteL
       
   253 // Deletes a profile entry which profile id is aProfileId.
       
   254 // -----------------------------------------------------------------------------
       
   255 //
       
   256 EXPORT_C void CRCSEProfileRegistry::DeleteL( 
       
   257     TUint32 aProfileId )
       
   258     {
       
   259     RCSELOGSTRING( "CRCSEProfileRegistry::DeleteL() - IN" );
       
   260 
       
   261     // Delete referenced settings first
       
   262     DeleteReferenceSettingsL( aProfileId );
       
   263 
       
   264     // Start transaction here since referenced settings are
       
   265     // deleted in own separate transaction
       
   266     BeginL();
       
   267 
       
   268     // Delete actual profile
       
   269     iCenRepDb->DeleteEntryL( aProfileId );
       
   270 
       
   271     EndL();
       
   272 
       
   273     RCSELOGSTRING( "CRCSEProfileRegistry::DeleteL() - OUT" );
       
   274     }
       
   275 
       
   276 // -----------------------------------------------------------------------------
       
   277 // CRCSEProfileRegistry::UpdateL
       
   278 // Updates profile entry, which profile identifier is aId.
       
   279 // -----------------------------------------------------------------------------
       
   280 //
       
   281 EXPORT_C void CRCSEProfileRegistry::UpdateL(
       
   282     TUint32 aId, const CRCSEProfileEntry& aUpdateData )
       
   283     {
       
   284     RCSELOGSTRING2( "CRCSEProfileRegistry::UpdateL(%d) - IN", aId );
       
   285 
       
   286     __ASSERT_ALWAYS( KNoEntryId < aId, User::Leave( KErrArgument ) );
       
   287 
       
   288     BeginL();
       
   289 
       
   290     AddOrUpdateEntryL( aId, aUpdateData );
       
   291 
       
   292     // Update also service settings if needed
       
   293     if ( aUpdateData.iIds.Count() && 
       
   294         aUpdateData.iIds[0].iProfileType == CRCSEProfileEntry::EProtocolSIP )
       
   295         {
       
   296         if ( aUpdateData.iServiceProviderId == KRCSEDefServiceProviderId )
       
   297             {
       
   298             CRCSEProfileEntry* entry = CRCSEProfileEntry::NewLC();
       
   299             CopyEntryValues( aUpdateData, *entry );
       
   300             CreateDefaultServiceSettingsL( *entry );
       
   301             UpdateServiceSettingsL( *entry );
       
   302             AddOrUpdateEntryL( aId, *entry );
       
   303             CleanupStack::PopAndDestroy( entry );
       
   304             }
       
   305         else
       
   306             {
       
   307             UpdateServiceSettingsL( aUpdateData );
       
   308             }
       
   309         }
       
   310 
       
   311     EndL();
       
   312 
       
   313     RCSELOGSTRING2( "CRCSEProfileRegistry::UpdateL(%d) - OUT", aId );
       
   314     }
       
   315 
       
   316 // -----------------------------------------------------------------------------
       
   317 // CRCSEProfileRegistry::GetDefaultProfile
       
   318 // Resets a default profile values.
       
   319 // -----------------------------------------------------------------------------
       
   320 //
       
   321 EXPORT_C void CRCSEProfileRegistry::GetDefaultProfile( 
       
   322     CRCSEProfileEntry& aDefaultProfile ) const
       
   323     {
       
   324     aDefaultProfile.ResetDefaultValues();
       
   325     }
       
   326 
       
   327 // -----------------------------------------------------------------------------
       
   328 // CRCSEProfileRegistry::GetAllIdsL
       
   329 // Gets all profile identifiers.
       
   330 // -----------------------------------------------------------------------------
       
   331 //
       
   332 EXPORT_C void CRCSEProfileRegistry::GetAllIdsL( RArray<TUint32>& aAllIds )
       
   333     {
       
   334     RCSELOGSTRING( "CRCSEProfileRegistry::GetAllIdsL() - IN" );
       
   335 
       
   336     BeginL();
       
   337 
       
   338     FindAllIdsL( aAllIds );
       
   339     
       
   340     EndL();
       
   341 
       
   342     RCSELOGSTRING( "CRCSEProfileRegistry::GetAllIdsL() - OUT" );
       
   343     }
       
   344 
       
   345 
       
   346 // -----------------------------------------------------------------------------
       
   347 // CRCSEProfileRegistry::FindByServiceIdL
       
   348 // Gets all profiles matching to service ID.
       
   349 // -----------------------------------------------------------------------------
       
   350 //
       
   351 EXPORT_C void CRCSEProfileRegistry::FindByServiceIdL( TUint32 aServiceId, 
       
   352     RPointerArray<CRCSEProfileEntry>& aFoundEntries )
       
   353     {
       
   354     RCSELOGSTRING( "CRCSEProfileRegistry::FindByServiceIdL() - IN" );
       
   355 
       
   356     CleanupResetAndDestroyPushL( aFoundEntries );
       
   357     
       
   358     BeginL();
       
   359 
       
   360     TBuf<KDesLength128> des;
       
   361 
       
   362     RArray<TUint32> entryIds;
       
   363     CleanupClosePushL( entryIds );
       
   364 
       
   365     // Search IDs of entries that have this service ID
       
   366     FindIdsByValueL( KColServiceProviderId,
       
   367                      ToDes( aServiceId, des ), 
       
   368                      entryIds );
       
   369 
       
   370     const TInt count( entryIds.Count() );
       
   371     RCSELOGSTRING2( " - Entries found: %d", count );
       
   372 
       
   373     // Search entries using found IDs
       
   374     for ( TInt i( 0 ); i < count; i++ )
       
   375         {
       
   376         CRCSEProfileEntry* entry = CRCSEProfileEntry::NewLC();
       
   377         TRAPD( e, FindEntryL( entryIds[ i ], *entry ) );
       
   378 
       
   379         if ( KErrNone == e )
       
   380             {
       
   381             aFoundEntries.AppendL( entry );
       
   382             CleanupStack::Pop( entry );
       
   383             }
       
   384         else
       
   385             {
       
   386             CleanupStack::PopAndDestroy( entry );
       
   387             }
       
   388         }
       
   389 
       
   390     CleanupStack::PopAndDestroy( &entryIds );
       
   391 
       
   392     // Update SIP profile links
       
   393     const TInt entryCount( aFoundEntries.Count() );
       
   394     for ( TInt k( 0 ); k < entryCount; ++k )
       
   395         {
       
   396         UpdateSIPProfileLinksL( *aFoundEntries[k] );
       
   397         }
       
   398 
       
   399     EndL();
       
   400     
       
   401     CleanupStack::Pop( &aFoundEntries );
       
   402 
       
   403     RCSELOGSTRING( "CRCSEProfileRegistry::FindByServiceIdL() - OUT" );
       
   404     }
       
   405 
       
   406 
       
   407 // -----------------------------------------------------------------------------
       
   408 // CRCSEProfileRegistry::FindBySIPSprofileIdL
       
   409 // Gets all profiles based on SIP profile ID.
       
   410 // -----------------------------------------------------------------------------
       
   411 //
       
   412 EXPORT_C void CRCSEProfileRegistry::FindBySIPProfileIdL( TUint32 aSipProfileId, 
       
   413     RPointerArray<CRCSEProfileEntry>& aFoundEntries )
       
   414     {
       
   415     RCSELOGSTRING( "CRCSEProfileRegistry::FindBySIPProfileIdL() - IN" );
       
   416     
       
   417     CleanupResetAndDestroyPushL( aFoundEntries );
       
   418 
       
   419     BeginL();
       
   420 
       
   421     // Find all profile IDs
       
   422     RArray<TUint32> voipIds;
       
   423     CleanupClosePushL( voipIds );
       
   424     FindAllIdsL( voipIds );
       
   425 
       
   426     // Check protocol ids (iIds) from each found profile ID.
       
   427     // Leave only those profile IDs where match found.
       
   428     CCenRepDatabaseProperty* property = CCenRepDatabaseProperty::NewLC();
       
   429     TInt count( voipIds.Count() );
       
   430 
       
   431     RArray<TSettingIds> prIds;
       
   432     CleanupClosePushL( prIds );
       
   433 
       
   434     for ( TInt i( 0 ); i < count; i++ )
       
   435         {
       
   436         iCenRepDb->FindPropertyL( voipIds[ i ], KColProtocolIds, *property );
       
   437         
       
   438         const TDesC& value = property->GetDesValue();
       
   439 
       
   440         ExtractProtocoIdsL( value, prIds );
       
   441 
       
   442         TBool found( EFalse );
       
   443         TInt prIdCount( prIds.Count() );
       
   444         for ( TInt j( 0 ); j < prIdCount && !found; j++ )
       
   445             {
       
   446             if ( prIds[ j ].iProfileType == CRCSEProfileEntry::EProtocolSIP && 
       
   447                  prIds[ j ].iProfileId == aSipProfileId )
       
   448                 {
       
   449                 found = ETrue;
       
   450                 }
       
   451             }
       
   452 
       
   453         // Search profile if match found
       
   454         if ( found )
       
   455             {
       
   456             CRCSEProfileEntry* entry = CRCSEProfileEntry::NewLC();
       
   457             TRAPD( e, FindEntryL( voipIds[ i ], *entry ) );
       
   458 
       
   459             if ( KErrNone == e )
       
   460                 {
       
   461                 aFoundEntries.AppendL( entry );
       
   462                 CleanupStack::Pop( entry );
       
   463                 }
       
   464             else
       
   465                 {
       
   466                 CleanupStack::PopAndDestroy( entry );
       
   467                 }
       
   468             }
       
   469         }
       
   470 
       
   471 
       
   472     CleanupStack::PopAndDestroy( &prIds );
       
   473     CleanupStack::PopAndDestroy( property );
       
   474 
       
   475 
       
   476     // Update SIP profile links
       
   477     TInt entryCount( aFoundEntries.Count() );
       
   478     for ( TInt k( 0 ); k < entryCount; ++k )
       
   479         {
       
   480         UpdateSIPProfileLinksL( *aFoundEntries[k] );
       
   481         }
       
   482 
       
   483     CleanupStack::PopAndDestroy( &voipIds );
       
   484     EndL();
       
   485     
       
   486     CleanupStack::Pop( &aFoundEntries );
       
   487 
       
   488     RCSELOGSTRING( "CRCSEProfileRegistry::FindBySIPProfileIdL() - OUT" );
       
   489     }
       
   490 
       
   491 // ---------------------------------------------------------------------------
       
   492 // CRCSEProfileRegistry::AddL
       
   493 // Add bunch of entries to store
       
   494 // ---------------------------------------------------------------------------
       
   495 //
       
   496 void CRCSEProfileRegistry::AddL( 
       
   497     RPointerArray<CRCSEProfileEntry>& aEntries )
       
   498     {
       
   499     RCSELOGSTRING2( 
       
   500         "CRCSEProfileRegistry::AddL( %d entries) - IN", aEntries.Count() );
       
   501 
       
   502     BeginL();
       
   503 
       
   504     TInt count( aEntries.Count() );
       
   505 
       
   506     for ( TInt i( 0 ); i < count; ++i )
       
   507         {
       
   508         // Create service settings if service ID is not available for entry
       
   509         if (  KRCSEDefServiceProviderId == aEntries[ i ]->iServiceProviderId )
       
   510             {
       
   511             CreateDefaultServiceSettingsL( *aEntries[ i ] );
       
   512             }
       
   513 
       
   514         TUint32 id( KNoEntryId );
       
   515         AddOrUpdateEntryL( id, *aEntries[ i ] );
       
   516         aEntries[ i ]->iId = id;
       
   517         }
       
   518         
       
   519 
       
   520     EndL();
       
   521 
       
   522     RCSELOGSTRING( "CRCSEProfileRegistry::AddL(entries) - OUT" );
       
   523     }
       
   524 
       
   525 // -----------------------------------------------------------------------------
       
   526 // CRCSEProfileRegistry::FindEntryL
       
   527 // Do actual search of profile entry
       
   528 // -----------------------------------------------------------------------------
       
   529 //
       
   530 void CRCSEProfileRegistry::FindEntryL( 
       
   531     TUint32 aProfileId, 
       
   532     CRCSEProfileEntry& aFoundEntry )
       
   533     {
       
   534     RCSELOGSTRING2( "CRCSEProfileRegistry::FindEntryL(id=%d) - IN", aProfileId );
       
   535 
       
   536     RIpAppPropArray properties;
       
   537 	TCleanupItem cleanup( CRCSERegistryBase::CleanupDbPropArray, &properties );
       
   538 	CleanupStack::PushL( cleanup );
       
   539 
       
   540     User::LeaveIfError( iCenRepDb->FindEntryL( aProfileId, properties ) );
       
   541     ConvertPropertiesToEntryL( aFoundEntry, properties );
       
   542     aFoundEntry.iId = aProfileId;
       
   543     
       
   544     CleanupStack::PopAndDestroy( &properties );
       
   545 
       
   546     RCSELOGSTRING2( "CRCSEProfileRegistry::FindEntryL(id=%d) - OUT", aProfileId );
       
   547     }
       
   548 
       
   549 // -----------------------------------------------------------------------------
       
   550 // CRCSEProfileRegistry::AddOrUpdateEntryL
       
   551 // Adds new entry or updates values of existing enry
       
   552 // -----------------------------------------------------------------------------
       
   553 //
       
   554 void CRCSEProfileRegistry::AddOrUpdateEntryL( 
       
   555     TUint32& aId, 
       
   556     const CRCSEProfileEntry& aEntry )
       
   557     {
       
   558     RCSELOGSTRING( "CRCSEProfileRegistry::AddOrUpdateEntryL() - IN" );
       
   559 
       
   560     TInt id( aId );
       
   561 
       
   562     RIpAppPropArray properties;
       
   563 	TCleanupItem cleanup( CRCSERegistryBase::CleanupDbPropArray, &properties );
       
   564 	CleanupStack::PushL( cleanup );
       
   565 
       
   566     ConvertEntryToPropertiesL( aEntry, properties );
       
   567 
       
   568     if ( KNoEntryId == id ) // Add new one
       
   569         {
       
   570         RCSELOGSTRING( "-- Add --" );
       
   571         iCenRepDb->AddEntryL( id, properties );
       
   572         }
       
   573     else                    // Update existing entry
       
   574         {
       
   575         RCSELOGSTRING( "-- Update --" );
       
   576         User::LeaveIfError( iCenRepDb->UpdateEntryL( id, properties ) );
       
   577         }
       
   578 
       
   579     aId = id;
       
   580 
       
   581     CleanupStack::PopAndDestroy( &properties );
       
   582 
       
   583     RCSELOGSTRING( "CRCSEProfileRegistry::AddOrUpdateEntryL() - OUT" );
       
   584     }
       
   585 
       
   586 // -----------------------------------------------------------------------------
       
   587 // 
       
   588 // -----------------------------------------------------------------------------
       
   589 //
       
   590 void CRCSEProfileRegistry::ConvertPropertiesToEntryL( 
       
   591     CRCSEProfileEntry& aEntry,
       
   592     RIpAppPropArray& aProperties )
       
   593     {
       
   594     RCSELOGSTRING( "CRCSEProfileRegistry::ConvertPropertiesToEntryL() - IN" );
       
   595 
       
   596     aEntry.ResetDefaultValues();
       
   597 
       
   598     TBuf<KDesLength256> value;
       
   599 
       
   600     GetPropertyValueL( KColProviderName, aEntry.iProviderName, aProperties );
       
   601 
       
   602     GetPropertyValueL( KColSettingsName, aEntry.iSettingsName, aProperties );
       
   603 
       
   604     GetPropertyValueL( KColPreferredCodecs, value, aProperties );
       
   605 
       
   606     TLex lex2( value );
       
   607     while( !lex2.Eos() )
       
   608         {
       
   609         // Extract the number as unsigned int 32, which can be 
       
   610         // converted to value wanted (template)
       
   611         TUint32 num;
       
   612         lex2.Val( num, EDecimal );
       
   613         aEntry.iPreferredCodecs.AppendL( static_cast<TUint32>( num ) );
       
   614         // Skip characters to space char.
       
   615         lex2.SkipCharacters();
       
   616         if ( !lex2.Eos() ) // Check that End of string is not next char.
       
   617             {
       
   618             // Go over the space character.
       
   619             lex2.Inc( 1 );
       
   620             }
       
   621         }
       
   622 
       
   623     GetPropertyValueL( KColStartMediaPort, value, aProperties );
       
   624     aEntry.iStartMediaPort = ToTInt32L( value );
       
   625 
       
   626     GetPropertyValueL( KColEndMediaPort, value, aProperties );
       
   627     aEntry.iEndMediaPort = ToTInt32L( value );
       
   628 
       
   629     GetPropertyValueL( KColSiqnalingQOS, value, aProperties );
       
   630     aEntry.iSiqnalingQOS = ToTInt32L( value );
       
   631 
       
   632     GetPropertyValueL( KColMediaQOS, value, aProperties );
       
   633     aEntry.iMediaQOS = ToTInt32L( value );
       
   634 
       
   635     GetPropertyValueL( KColInbandDtmf, value, aProperties );
       
   636     aEntry.iInbandDTMF = static_cast<CRCSEProfileEntry::TOnOff>( ToTInt32L( value ) );
       
   637 
       
   638     GetPropertyValueL( KColOutbandDtmf, value, aProperties );
       
   639     aEntry.iOutbandDTMF = static_cast<CRCSEProfileEntry::TOnOff>( ToTInt32L( value ) );
       
   640 
       
   641     GetPropertyValueL( KColHoldRingBack, value, aProperties );
       
   642     aEntry.iHoldRingBack = ToTInt32L( value );
       
   643 
       
   644     GetPropertyValueL( KColAutoComplete, value, aProperties );
       
   645     aEntry.iAutoComplete = static_cast<CRCSEProfileEntry::TOnOff>( ToTInt32L( value ) );
       
   646 
       
   647     GetPropertyValueL( KColCFNoAnswer, value, aProperties );
       
   648     aEntry.iCFNoAnswer = static_cast<CRCSEProfileEntry::TOnOff>( ToTInt32L( value ) );
       
   649 
       
   650     GetPropertyValueL( KColCFBusy, value, aProperties );
       
   651     aEntry.iCFBusy = static_cast<CRCSEProfileEntry::TOnOff>( ToTInt32L( value ) );
       
   652 
       
   653     GetPropertyValueL( KColCFUnconditional, value, aProperties );
       
   654     aEntry.iCFUnconditional = static_cast<CRCSEProfileEntry::TOnOff>( ToTInt32L( value ) );
       
   655 
       
   656     GetPropertyValueL( KColRedundancy, value, aProperties );
       
   657     aEntry.iRedundancy = static_cast<CRCSEProfileEntry::TOnOff>( ToTInt32L( value ) );
       
   658 
       
   659     GetPropertyValueL( KColProtocolIds, value, aProperties );
       
   660     ExtractProtocoIdsL( value, aEntry.iIds );
       
   661 
       
   662     GetPropertyValueL( KColSecureCallPreference, value, aProperties );
       
   663     aEntry.iSecureCallPreference = ToTUint32L( value );
       
   664 
       
   665     GetPropertyValueL( KColVoIPProfileLock, value, aProperties );
       
   666     aEntry.iVoIPProfileLock = ToTUint32L( value );
       
   667 
       
   668     GetPropertyValueL( KColAdhocAllowed, value, aProperties );
       
   669     aEntry.iAdhocAllowed = ToTUint32L( value );
       
   670 
       
   671     GetPropertyValueL( KColSIPServerType, value, aProperties );
       
   672     aEntry.iSIPServerType.Copy( value );
       
   673 
       
   674     GetPropertyValueL( KColSBCType, value, aProperties );
       
   675     aEntry.iSBCType.Copy( value );;
       
   676 
       
   677     GetPropertyValueL( KColSTUNServerType, value, aProperties );
       
   678     aEntry.iSTUNServerType.Copy( value );
       
   679 
       
   680     GetPropertyValueL( KColWLANAPType, value, aProperties );
       
   681     aEntry.iWLANAPType.Copy( value );
       
   682 
       
   683     GetPropertyValueL( KColPSTNGatewayType, value, aProperties );
       
   684     aEntry.iPSTNGatewayType.Copy( value );
       
   685 
       
   686     GetPropertyValueL( KColSecurityGatewayType, value, aProperties );
       
   687     aEntry.iSecurityGatewayType.Copy( value );
       
   688 
       
   689     GetPropertyValueL( KColRTCP, value, aProperties );
       
   690     aEntry.iRTCP = ToTUint32L( value );
       
   691 
       
   692     GetPropertyValueL( KColSIPVoIPUAHTerminalType, value, aProperties );
       
   693     aEntry.iSIPVoIPUAHTerminalType = ToTUint32L( value );
       
   694 
       
   695     GetPropertyValueL( KColSIPVoIPUAHeaderWLANMAC, value, aProperties );
       
   696     aEntry.iSIPVoIPUAHeaderWLANMAC = ToTUint32L( value );
       
   697 
       
   698     GetPropertyValueL( KColSIPVoIPUAHeaderString, value, aProperties );
       
   699     aEntry.iSIPVoIPUAHeaderString.Copy( value );
       
   700 
       
   701     GetPropertyValueL( KColProfileLockedToIAP, value, aProperties );
       
   702     aEntry.iProfileLockedToIAP = static_cast<CRCSEProfileEntry::TOnOff>( ToTInt32L( value ) );
       
   703 
       
   704     GetPropertyValueL( KColVoIPPluginUID, value, aProperties );
       
   705     aEntry.iVoIPPluginUID = ToTInt32L( value );
       
   706 
       
   707     GetPropertyValueL( KColAllowVoIPoverWCDMA, value, aProperties );
       
   708     aEntry.iAllowVoIPoverWCDMA = static_cast<CRCSEProfileEntry::TOnOff>( ToTInt32L( value ) );
       
   709 
       
   710     GetPropertyValueL( KColAllowVoIPoverBT, value, aProperties );
       
   711     aEntry.iAllowVoIPoverBT = static_cast<CRCSEProfileEntry::TOnOff>( ToTInt32L( value ) );
       
   712 
       
   713     GetPropertyValueL( KColMeanCountOfVoIPDigits, value, aProperties );
       
   714     aEntry.iMeanCountOfVoIPDigits = ToTInt32L( value );
       
   715 
       
   716     GetPropertyValueL( KColIgnoreAddrDomainPart, value, aProperties );
       
   717     aEntry.iIgnoreAddrDomainPart = ToTInt32L( value );
       
   718 
       
   719     GetPropertyValueL( KColHandoverDialect, value, aProperties );
       
   720     aEntry.iHandoverDialect = ToTInt32L( value );
       
   721 
       
   722     GetPropertyValueL( KColPSTelephonyHOPreference, value, aProperties );
       
   723     aEntry.iPSTelephonyHOPreference = ToTInt32L( value );
       
   724 
       
   725     GetPropertyValueL( KColHOThresholdValueLL, value, aProperties );
       
   726     aEntry.iHOThresholdValueLL = ToTInt32L( value );
       
   727 
       
   728     GetPropertyValueL( KColHOThresholdValueHL, value, aProperties );
       
   729     aEntry.iHOThresholdValueHL = ToTInt32L( value );
       
   730 
       
   731     GetPropertyValueL( KColNumberOfMeasurementsAbove, value, aProperties );
       
   732     aEntry.iNumberOfMeasurementsAbove = ToTInt32L( value );
       
   733 
       
   734     GetPropertyValueL( KColNumberOfMeasurementsBelow, value, aProperties );
       
   735     aEntry.iNumberOfMeasurementsBelow = ToTInt32L( value );
       
   736 
       
   737     GetPropertyValueL( KColSmartScannInterParaHigh, value, aProperties );
       
   738     aEntry.iSmartScannInterParaHigh = ToTInt32L( value );
       
   739 
       
   740     GetPropertyValueL( KColSmartScannInterParaMedium, value, aProperties );
       
   741     aEntry.iSmartScannInterParaMedium = ToTInt32L( value );
       
   742 
       
   743     GetPropertyValueL( KColSmartScannInterParaLow, value, aProperties );
       
   744     aEntry.iSmartScannInterParaLow = ToTInt32L( value );
       
   745 
       
   746     GetPropertyValueL( KColSmartScannInterParaStatic, value, aProperties );
       
   747     aEntry.iSmartScannInterParaStatic = ToTInt32L( value );
       
   748 
       
   749     GetPropertyValueL( KColSmartScannDurationHighMode, value, aProperties );
       
   750     aEntry.iSmartScannDurationHighMode = ToTInt32L( value );
       
   751 
       
   752     GetPropertyValueL( KColSmartScannDurationMediumMode, value, aProperties );
       
   753     aEntry.iSmartScannDurationMediumMode = ToTInt32L( value );
       
   754 
       
   755     GetPropertyValueL( KColSmartScannDurationLowMode, value, aProperties );
       
   756     aEntry.iSmartScannDurationLowMode = ToTInt32L( value );
       
   757 
       
   758     GetPropertyValueL( KColHandoffNumber, value, aProperties );
       
   759     aEntry.iHandoffNumber = ToTInt32L( value );
       
   760 
       
   761     GetPropertyValueL( KColHandbackNumber, value, aProperties );
       
   762     aEntry.iHandbackNumber = ToTInt32L( value );
       
   763 
       
   764     GetPropertyValueL( KColHysterisisTimer, value, aProperties );
       
   765     aEntry.iHysterisisTimer = ToTInt32L( value );
       
   766 
       
   767     GetPropertyValueL( KColHandOffProcessTimer, value, aProperties );
       
   768     aEntry.iHandOffProcessTimer = ToTInt32L( value );
       
   769 
       
   770     GetPropertyValueL( KColDisconnectProcessTimer, value, aProperties );
       
   771     aEntry.iDisconnectProcessTimer = ToTInt32L( value );
       
   772 
       
   773     GetPropertyValueL( KColHandoffPrefix, value, aProperties );
       
   774     aEntry.iHandoffPrefix.Copy( value );
       
   775 
       
   776     GetPropertyValueL( KColHandbackPrefix, value, aProperties );
       
   777     aEntry.iHandbackPrefix.Copy( value );
       
   778 
       
   779     GetPropertyValueL( KColHandoverTones, value, aProperties );
       
   780     aEntry.iHandoverTones = ToTInt32L( value );
       
   781 
       
   782     GetPropertyValueL( KColSupportSMSoverWLAN, value, aProperties );
       
   783     aEntry.iSupportSMSoverWLAN = ToTInt32L( value );
       
   784 
       
   785     GetPropertyValueL( KColServiceProviderId, value, aProperties );
       
   786     aEntry.iServiceProviderId = ToTUint32L( value );
       
   787 
       
   788     GetPropertyValueL( KColUserPhoneUriParam, value, aProperties );
       
   789     aEntry.iUserPhoneUriParameter = static_cast<CRCSEProfileEntry::TOnOff>( ToTInt32L( value ) );
       
   790 
       
   791     GetPropertyValueL( KColSIPConnTestAddress, value, aProperties );
       
   792     aEntry.iSIPConnTestAddress.Copy( value );
       
   793 
       
   794     GetPropertyValueL( KColNATSettingsStorageId, value, aProperties );
       
   795     aEntry.iNATSettingsStorageId = ToTUint32L( value );
       
   796 
       
   797     GetPropertyValueL( KColSIPMinSE, value, aProperties );
       
   798     aEntry.iSIPMinSE = ToTInt32L( value );
       
   799 
       
   800     GetPropertyValueL( KColSIPSessionExpires, value, aProperties );
       
   801     aEntry.iSIPSessionExpires = ToTInt32L( value );
       
   802 
       
   803     GetPropertyValueL( KColNATProtocol, value, aProperties );
       
   804     aEntry.iNATProtocol = ToTInt32L( value );
       
   805 
       
   806     GetPropertyValueL( KColNewServiceTable, value, aProperties );
       
   807     aEntry.iNewServiceTableEntry = static_cast<CRCSEProfileEntry::TOnOff>( ToTInt32L( value ) );
       
   808 
       
   809     GetPropertyValueL( KColSNAPId, value, aProperties );
       
   810     aEntry.iSNAPId = ToTUint32L( value );
       
   811     
       
   812     GetPropertyValueL( KColCreationUrl, value, aProperties );
       
   813     aEntry.iAccountCreationUrl.Copy( value );
       
   814 
       
   815     RCSELOGSTRING( "CRCSEProfileRegistry::ConvertPropertiesToEntryL() - OUT" );
       
   816     }
       
   817 
       
   818 
       
   819 // -----------------------------------------------------------------------------
       
   820 // 
       
   821 // -----------------------------------------------------------------------------
       
   822 //
       
   823 void CRCSEProfileRegistry::ConvertEntryToPropertiesL( 
       
   824     const CRCSEProfileEntry& aEntry,
       
   825     RIpAppPropArray& aProperties )
       
   826     {
       
   827     RCSELOGSTRING( "CRCSEProfileRegistry::ConvertEntryToPropertiesL() - IN" );
       
   828 
       
   829     // Descriptor for value conversion
       
   830     TBuf<KDesLength128> des;
       
   831 
       
   832     CreatePropertyL( KColProviderName,
       
   833                      aEntry.iProviderName,
       
   834                      aProperties );
       
   835 
       
   836     CreatePropertyL( KColSettingsName, 
       
   837                      aEntry.iSettingsName,
       
   838                      aProperties );
       
   839 
       
   840     TInt count = aEntry.iPreferredCodecs.Count();
       
   841     des.Zero();
       
   842     for ( TInt j( 0 ); j < count; j++ )
       
   843         {
       
   844         des.AppendNum( static_cast<TUint32>( aEntry.iPreferredCodecs[j] ) );
       
   845         if ( j < count - 1 )
       
   846             {
       
   847             des.Append( KSpace );
       
   848             }
       
   849         }
       
   850 
       
   851     CreatePropertyL( KColPreferredCodecs, 
       
   852                      des,
       
   853                      aProperties );
       
   854 
       
   855     CreatePropertyL( KColStartMediaPort, 
       
   856                      ToDes( aEntry.iStartMediaPort, des ),
       
   857                      aProperties );
       
   858 
       
   859     CreatePropertyL( KColEndMediaPort, 
       
   860                      ToDes( aEntry.iEndMediaPort, des ),
       
   861                      aProperties );
       
   862 
       
   863     CreatePropertyL( KColSiqnalingQOS, 
       
   864                      ToDes( aEntry.iSiqnalingQOS, des ),
       
   865                      aProperties );
       
   866 
       
   867     CreatePropertyL(  KColMediaQOS, 
       
   868                      ToDes( aEntry.iMediaQOS, des ),
       
   869                      aProperties );
       
   870 
       
   871     TInt32 inbandDTMF( aEntry.iInbandDTMF ); // TOnOff
       
   872     CreatePropertyL( KColInbandDtmf, 
       
   873                      ToDes( inbandDTMF, des ),
       
   874                      aProperties );
       
   875 
       
   876     TInt32 outbandDTMF( aEntry.iOutbandDTMF ); // TOnOff
       
   877     CreatePropertyL( KColOutbandDtmf, 
       
   878                      ToDes( outbandDTMF, des ),
       
   879                      aProperties );
       
   880 
       
   881     TInt32 holdRingBack( aEntry.iHoldRingBack ); // TOnOff
       
   882     CreatePropertyL( KColHoldRingBack, 
       
   883                      ToDes( holdRingBack, des ),
       
   884                      aProperties );
       
   885 
       
   886     TInt32 autoComplete = aEntry.iAutoComplete; // TOnOff
       
   887     CreatePropertyL( KColAutoComplete, 
       
   888                      ToDes( autoComplete, des ),
       
   889                      aProperties );
       
   890 
       
   891     TInt32 cfNoAnswer( aEntry.iCFNoAnswer ); // TOnOff
       
   892     CreatePropertyL( KColCFNoAnswer, 
       
   893                      ToDes( cfNoAnswer,  des ),
       
   894                      aProperties );
       
   895 
       
   896     TInt32 cfBusy( aEntry.iCFBusy ); // TOnOff
       
   897     CreatePropertyL( KColCFBusy, 
       
   898                      ToDes( cfBusy, des ),
       
   899                      aProperties );
       
   900 
       
   901     TInt32 cfUnconditional( aEntry.iCFUnconditional ); // TOnOff
       
   902     CreatePropertyL( KColCFUnconditional, 
       
   903                      ToDes( cfUnconditional, des ),
       
   904                      aProperties );
       
   905 
       
   906     TInt32 redundancy( aEntry.iRedundancy ); // TOnOff
       
   907     CreatePropertyL( KColRedundancy, 
       
   908                      ToDes( redundancy, des ),
       
   909                      aProperties );
       
   910 
       
   911     des.Zero();
       
   912     TBuf<KDesLength15> intDes; // for SIP profile ID
       
   913     count = aEntry.iIds.Count();
       
   914 
       
   915     if ( count )
       
   916         {
       
   917         for( TInt i = 0; i < count; i++ )
       
   918             {
       
   919             intDes.Zero();
       
   920 
       
   921             TInt profileType = aEntry.iIds[i].iProfileType;
       
   922             intDes.Num( profileType );
       
   923             des.Append( intDes );
       
   924             des.Append( KSpace );
       
   925 
       
   926             TInt profileId = aEntry.iIds[i].iProfileId;
       
   927             intDes.Num( profileId );
       
   928             des.Append( intDes );
       
   929             des.Append( KSpace );
       
   930 
       
   931             TInt profileSpecificId = aEntry.iIds[i].iProfileSpecificSettingId;
       
   932             intDes.Num( profileSpecificId );
       
   933             des.Append( intDes );
       
   934             des.Append( KSpace );
       
   935             }
       
   936         }
       
   937 
       
   938     CreatePropertyL( KColProtocolIds, 
       
   939                      des,
       
   940                      aProperties );
       
   941 
       
   942     CreatePropertyL( KColSecureCallPreference, 
       
   943                      ToDes( aEntry.iSecureCallPreference, des ),
       
   944                      aProperties );
       
   945 
       
   946     CreatePropertyL( KColVoIPProfileLock, 
       
   947                      ToDes( aEntry.iVoIPProfileLock, des ),
       
   948                      aProperties );
       
   949 
       
   950     CreatePropertyL( KColAdhocAllowed, 
       
   951                      ToDes( aEntry.iAdhocAllowed, des ),
       
   952                      aProperties );
       
   953 
       
   954     CreatePropertyL( KColSIPServerType, 
       
   955                      aEntry.iSIPServerType,
       
   956                      aProperties );
       
   957 
       
   958     CreatePropertyL( KColSBCType, 
       
   959                      aEntry.iSBCType,
       
   960                      aProperties );
       
   961 
       
   962     CreatePropertyL( KColSTUNServerType, 
       
   963                      aEntry.iSTUNServerType,
       
   964                      aProperties );
       
   965 
       
   966     CreatePropertyL( KColWLANAPType, 
       
   967                      aEntry.iWLANAPType,
       
   968                      aProperties );
       
   969 
       
   970     CreatePropertyL( KColPSTNGatewayType, 
       
   971                      aEntry.iPSTNGatewayType,
       
   972                      aProperties );
       
   973 
       
   974     CreatePropertyL( KColSecurityGatewayType, 
       
   975                      aEntry.iSecurityGatewayType,
       
   976                      aProperties );
       
   977   
       
   978     CreatePropertyL( KColRTCP, 
       
   979                      ToDes( aEntry.iRTCP, des ),
       
   980                      aProperties );
       
   981 
       
   982     CreatePropertyL( KColSIPVoIPUAHTerminalType, 
       
   983                      ToDes( aEntry.iSIPVoIPUAHTerminalType, des ),
       
   984                      aProperties );
       
   985 
       
   986     CreatePropertyL( KColSIPVoIPUAHeaderWLANMAC, 
       
   987                      ToDes( aEntry.iSIPVoIPUAHeaderWLANMAC, des ),
       
   988                      aProperties );
       
   989 
       
   990     CreatePropertyL( KColSIPVoIPUAHeaderString, 
       
   991                      aEntry.iSIPVoIPUAHeaderString,
       
   992                      aProperties );
       
   993 
       
   994     TInt32 profileLockedToIAP( aEntry.iProfileLockedToIAP ); // TOnOff
       
   995     CreatePropertyL( KColProfileLockedToIAP, 
       
   996                      ToDes( profileLockedToIAP, des ),
       
   997                      aProperties );
       
   998 
       
   999     CreatePropertyL( KColVoIPPluginUID, 
       
  1000                      ToDes( aEntry.iVoIPPluginUID, des ),
       
  1001                      aProperties );
       
  1002 
       
  1003     TInt32 allowVoIPoverWCDMA( aEntry.iAllowVoIPoverWCDMA ); // TOnOff
       
  1004     CreatePropertyL( KColAllowVoIPoverWCDMA, 
       
  1005                      ToDes( allowVoIPoverWCDMA, des ),
       
  1006                      aProperties );
       
  1007 
       
  1008     TInt32 allowVoIPoverBT( aEntry.iAllowVoIPoverBT ); // TOnOff
       
  1009     CreatePropertyL( KColAllowVoIPoverBT, 
       
  1010                      ToDes( allowVoIPoverBT, des ),
       
  1011                      aProperties );
       
  1012 
       
  1013     CreatePropertyL( KColMeanCountOfVoIPDigits,
       
  1014                      ToDes( aEntry.iMeanCountOfVoIPDigits, des ),
       
  1015                      aProperties );
       
  1016 
       
  1017     CreatePropertyL( KColIgnoreAddrDomainPart, 
       
  1018                      ToDes( aEntry.iIgnoreAddrDomainPart, des ),
       
  1019                      aProperties );
       
  1020 
       
  1021     CreatePropertyL( KColHandoverDialect, 
       
  1022                      ToDes( aEntry.iHandoverDialect, des ),
       
  1023                      aProperties );
       
  1024 
       
  1025     CreatePropertyL( KColPSTelephonyHOPreference, 
       
  1026                      ToDes( aEntry.iPSTelephonyHOPreference, des ),
       
  1027                      aProperties );
       
  1028 
       
  1029     CreatePropertyL( KColHOThresholdValueLL, 
       
  1030                      ToDes( aEntry.iHOThresholdValueLL, des ),
       
  1031                      aProperties );
       
  1032 
       
  1033     CreatePropertyL( KColHOThresholdValueHL, 
       
  1034                      ToDes( aEntry.iHOThresholdValueHL, des ),
       
  1035                      aProperties );
       
  1036 
       
  1037     CreatePropertyL( KColNumberOfMeasurementsAbove, 
       
  1038                      ToDes( aEntry.iNumberOfMeasurementsAbove, des ),
       
  1039                      aProperties );
       
  1040 
       
  1041     CreatePropertyL( KColNumberOfMeasurementsBelow, 
       
  1042                      ToDes( aEntry.iNumberOfMeasurementsBelow, des ),
       
  1043                      aProperties );
       
  1044 
       
  1045     CreatePropertyL( KColSmartScannInterParaHigh, 
       
  1046                      ToDes( aEntry.iSmartScannInterParaHigh, des ),
       
  1047                      aProperties );
       
  1048 
       
  1049     CreatePropertyL( KColSmartScannInterParaMedium, 
       
  1050                      ToDes(  aEntry.iSmartScannInterParaMedium, des ),
       
  1051                      aProperties );
       
  1052 
       
  1053     CreatePropertyL( KColSmartScannInterParaLow, 
       
  1054                      ToDes( aEntry.iSmartScannInterParaLow, des ),
       
  1055                      aProperties );
       
  1056 
       
  1057     CreatePropertyL( KColSmartScannInterParaStatic, 
       
  1058                      ToDes( aEntry.iSmartScannInterParaStatic, des ),
       
  1059                      aProperties );
       
  1060 
       
  1061     CreatePropertyL( KColSmartScannDurationHighMode, 
       
  1062                      ToDes( aEntry.iSmartScannDurationHighMode, des ),
       
  1063                      aProperties );
       
  1064 
       
  1065     CreatePropertyL( KColSmartScannDurationMediumMode, 
       
  1066                      ToDes( aEntry.iSmartScannDurationMediumMode, des ),
       
  1067                      aProperties );
       
  1068 
       
  1069     CreatePropertyL( KColSmartScannDurationLowMode, 
       
  1070                      ToDes( aEntry.iSmartScannDurationLowMode, des ),
       
  1071                      aProperties );
       
  1072 
       
  1073     CreatePropertyL( KColHandoffNumber, 
       
  1074                      ToDes( aEntry.iHandoffNumber, des ),
       
  1075                      aProperties );
       
  1076 
       
  1077     CreatePropertyL( KColHandbackNumber, 
       
  1078                      ToDes( aEntry.iHandbackNumber, des ),
       
  1079                      aProperties );
       
  1080 
       
  1081     CreatePropertyL( KColHysterisisTimer, 
       
  1082                      ToDes( aEntry.iHysterisisTimer, des ),
       
  1083                      aProperties );
       
  1084 
       
  1085     CreatePropertyL( KColHandOffProcessTimer, 
       
  1086                      ToDes( aEntry.iHandOffProcessTimer, des ),
       
  1087                      aProperties );
       
  1088 
       
  1089     CreatePropertyL( KColDisconnectProcessTimer, 
       
  1090                      ToDes( aEntry.iDisconnectProcessTimer, des ),
       
  1091                      aProperties );
       
  1092 
       
  1093     CreatePropertyL( KColHandoffPrefix, 
       
  1094                      aEntry.iHandoffPrefix,
       
  1095                      aProperties );
       
  1096 
       
  1097     CreatePropertyL( KColHandbackPrefix, 
       
  1098                      aEntry.iHandbackPrefix,
       
  1099                      aProperties );
       
  1100 
       
  1101     CreatePropertyL( KColHandoverTones, 
       
  1102                      ToDes( aEntry.iHandoverTones, des ),
       
  1103                      aProperties );
       
  1104 
       
  1105     CreatePropertyL( KColSupportSMSoverWLAN, 
       
  1106                      ToDes( aEntry.iSupportSMSoverWLAN, des ),
       
  1107                      aProperties );
       
  1108 
       
  1109     CreatePropertyL( KColServiceProviderId, 
       
  1110                      ToDes( aEntry.iServiceProviderId, des ),
       
  1111                      aProperties );
       
  1112 
       
  1113     TInt32 userPhoneUriParameter( aEntry.iUserPhoneUriParameter ); // TOnOff
       
  1114     CreatePropertyL( KColUserPhoneUriParam, 
       
  1115                      ToDes( userPhoneUriParameter, des ),
       
  1116                      aProperties );
       
  1117 
       
  1118     CreatePropertyL( KColSIPConnTestAddress, 
       
  1119                      aEntry.iSIPConnTestAddress,
       
  1120                      aProperties );
       
  1121 
       
  1122     CreatePropertyL( KColNATSettingsStorageId, 
       
  1123                      ToDes( aEntry.iNATSettingsStorageId, des ),
       
  1124                      aProperties );
       
  1125 
       
  1126     CreatePropertyL( KColSIPMinSE, 
       
  1127                      ToDes( aEntry.iSIPMinSE, des ),
       
  1128                      aProperties );
       
  1129 
       
  1130     CreatePropertyL( KColSIPSessionExpires, 
       
  1131                      ToDes( aEntry.iSIPSessionExpires, des ),
       
  1132                      aProperties );
       
  1133 
       
  1134     CreatePropertyL( KColNATProtocol, 
       
  1135                      ToDes( aEntry.iNATProtocol, des ),
       
  1136                      aProperties );
       
  1137 
       
  1138     TInt32 newServiceTable( aEntry.iNewServiceTableEntry ); // TOnOff
       
  1139     CreatePropertyL( KColNewServiceTable, 
       
  1140                      ToDes( newServiceTable, des ),
       
  1141                      aProperties );
       
  1142 
       
  1143     CreatePropertyL( KColSNAPId, 
       
  1144                      ToDes( aEntry.iSNAPId, des ),
       
  1145                      aProperties );
       
  1146 
       
  1147     CreatePropertyL( KColCreationUrl, 
       
  1148                      aEntry.iAccountCreationUrl,
       
  1149                      aProperties );
       
  1150     
       
  1151     RCSELOGSTRING( "CRCSEProfileRegistry::ConvertEntryToPropertiesL() - OUT" );
       
  1152     }
       
  1153 
       
  1154 // -----------------------------------------------------------------------------
       
  1155 // CRCSEProfileRegistry::
       
  1156 // -----------------------------------------------------------------------------
       
  1157 //
       
  1158 void CRCSEProfileRegistry::ExtractProtocoIdsL( 
       
  1159     const TDesC& aDes, RArray<TSettingIds>& aArray )
       
  1160     {
       
  1161     CleanupClosePushL( aArray );
       
  1162     
       
  1163     TLex lex( aDes );
       
  1164     
       
  1165     TSettingIds value;
       
  1166     
       
  1167     // Reset original array
       
  1168     aArray.Reset();
       
  1169     
       
  1170     while( !lex.Eos() )
       
  1171         {
       
  1172         lex.Val( value.iProfileType );
       
  1173         // Skip characters to space char.
       
  1174         lex.SkipCharacters();
       
  1175         lex.Inc( 1 );
       
  1176         lex.Val( value.iProfileId );
       
  1177         lex.SkipCharacters();
       
  1178         lex.Inc( 1 );
       
  1179         lex.Val( value.iProfileSpecificSettingId );
       
  1180         
       
  1181         aArray.AppendL( value );
       
  1182         if ( !lex.Eos() ) // Check that End of string is not next char.
       
  1183             {
       
  1184             // Go over the space character.
       
  1185             lex.Inc( 1 );
       
  1186             }
       
  1187         }
       
  1188     
       
  1189     CleanupStack::Pop( &aArray );
       
  1190     }
       
  1191 
       
  1192 // -----------------------------------------------------------------------------
       
  1193 // CRCSEProfileRegistry::UpdateSIPProfileLinksL
       
  1194 // Validates profile's SIP profile IDs and updates if necessary
       
  1195 // -----------------------------------------------------------------------------
       
  1196 //
       
  1197 void CRCSEProfileRegistry::UpdateSIPProfileLinksL( CRCSEProfileEntry& aEntry )
       
  1198     {
       
  1199     RCSELOGSTRING( "CRCSEProfileRegistry::UpdateSIPProfileLinksL - IN" );
       
  1200     const TInt count( aEntry.iIds.Count() );
       
  1201     TSettingIds value;
       
  1202     RCSELOGSTRING2( "Protocol link count=%d", count );
       
  1203 
       
  1204     if ( 0 < count )
       
  1205         {
       
  1206         iSIPProfiles.ResetAndDestroy();
       
  1207 
       
  1208         TInt err(0);
       
  1209         // Check the existence of linked SIP profiles
       
  1210         for ( TInt i( count-1 ); 0 <= i ; i-- )
       
  1211             {
       
  1212             value = aEntry.iIds[i];
       
  1213 
       
  1214             if ( CRCSEProfileEntry::EProtocolSIP == value.iProfileType )
       
  1215                 {
       
  1216                 CSIPProfile* profile = NULL;
       
  1217                 TRAP( err, profile = iSIPRegistry->ProfileL( value.iProfileId ) );
       
  1218                 if ( KErrNotFound == err )
       
  1219                     {
       
  1220                     aEntry.iIds.Remove( i );
       
  1221                     delete profile;
       
  1222                     profile = NULL;
       
  1223                     RCSELOGSTRING2( "SIP link removed, id=%d", value.iProfileId );
       
  1224                     }
       
  1225                 else if ( KErrNone == err )
       
  1226                     {
       
  1227                     err = iSIPProfiles.Append( profile );
       
  1228                     }
       
  1229                 else
       
  1230                     {
       
  1231                     delete profile;
       
  1232                     profile = NULL;
       
  1233                     }
       
  1234                 }
       
  1235             }
       
  1236 
       
  1237         // Check that all profiles have same AOR.
       
  1238         // If some AOR differs leave only the first link
       
  1239         TInt profCount( iSIPProfiles.Count() );
       
  1240         RCSELOGSTRING2( "SIP link count=%d", profCount );
       
  1241         TBool ok( ETrue );
       
  1242         if ( 1 < profCount )
       
  1243             {
       
  1244             const TDesC8* aor1;
       
  1245             HBufC8* empty = KNullDesC8().AllocLC();
       
  1246             err = iSIPProfiles[0]->GetParameter( KSIPUserAor, aor1 );
       
  1247 
       
  1248             if ( KErrNotFound == err )
       
  1249                 {
       
  1250                 aor1 = empty;
       
  1251                 }
       
  1252 
       
  1253             for ( TInt j( 1 ); j < profCount; j++ )
       
  1254                 {
       
  1255                 const TDesC8* aor2;
       
  1256                 err = iSIPProfiles[j]->GetParameter( KSIPUserAor, aor2 );
       
  1257 
       
  1258                 if ( KErrNotFound == err )
       
  1259                     {
       
  1260                     if ( aor1->Compare( KNullDesC8() ) != 0 )
       
  1261                         {
       
  1262                         ok = EFalse;
       
  1263                         }
       
  1264                     }
       
  1265                 else
       
  1266                     { 
       
  1267                     if ( aor1->Compare( *aor2 ) != 0 )
       
  1268                         {
       
  1269                         ok = EFalse;
       
  1270                         }
       
  1271                     }
       
  1272                 }
       
  1273             CleanupStack::PopAndDestroy( empty );
       
  1274 
       
  1275             if ( !ok )
       
  1276                 {
       
  1277                 RCSELOGSTRING( "AOR changed" );
       
  1278                 TInt newCount = aEntry.iIds.Count();
       
  1279                 TBool first( ETrue );
       
  1280                 for ( TInt k( 0 ); k < newCount; k++ )
       
  1281                     {
       
  1282                     value = aEntry.iIds[k];
       
  1283                     if ( CRCSEProfileEntry::EProtocolSIP == value.iProfileType )
       
  1284                         {
       
  1285                         if ( first )
       
  1286                             {
       
  1287                             first = EFalse;
       
  1288                             RCSELOGSTRING2( "Leave SIP link, index=%d", k );
       
  1289                             }
       
  1290                         else
       
  1291                             {
       
  1292                             aEntry.iIds.Remove( k );
       
  1293                             newCount--;
       
  1294                             k--;
       
  1295                             RCSELOGSTRING2( "Remove SIP link, index=%d", k );
       
  1296                             }
       
  1297                         }
       
  1298                     }
       
  1299                 }
       
  1300             }
       
  1301 
       
  1302         iSIPProfiles.ResetAndDestroy();
       
  1303 
       
  1304         // Update entry if count of ids have changed
       
  1305         if ( count != aEntry.iIds.Count() )
       
  1306             {
       
  1307             RCSELOGSTRING3( "Link ID count: initial=%d, final=%d",
       
  1308                              count, aEntry.iIds.Count() );
       
  1309 
       
  1310             AddOrUpdateEntryL( aEntry.iId, aEntry );
       
  1311 
       
  1312             RCSELOGSTRING( "Entry updated" );
       
  1313             }
       
  1314         }
       
  1315 
       
  1316     RCSELOGSTRING( "CRCSEProfileRegistry::UpdateSIPProfileLinksL - OUT" );
       
  1317     }
       
  1318 
       
  1319 // -----------------------------------------------------------------------------
       
  1320 // Local helper method for searching default values of properties from service
       
  1321 // table and adding them to given service entry.
       
  1322 // -----------------------------------------------------------------------------
       
  1323 //
       
  1324 void FindAndAddDefaultPropertyL( 
       
  1325     CSPSettings& aTable, 
       
  1326     CSPEntry& aEntry, 
       
  1327     CSPProperty& aProperty, 
       
  1328     TServicePropertyName aName  )
       
  1329     {
       
  1330     TInt err = aTable.FindPropertyL( KDefaultVoIPService, aName, aProperty );
       
  1331 
       
  1332     if ( KErrNone == err )
       
  1333         {
       
  1334         err = aEntry.AddPropertyL( aProperty );
       
  1335         if ( KErrNone != err )
       
  1336             {
       
  1337             RCSELOGSTRING2(
       
  1338                 "CRCSEProfileRegistry::FindAndAddDefaultPropertyL - add property err: %d",
       
  1339                 err );
       
  1340             }
       
  1341         }
       
  1342     }
       
  1343 
       
  1344 // -----------------------------------------------------------------------------
       
  1345 // CRCSEProfileRegistry::CreateDefaultServiceSettingsL
       
  1346 // Creates a voip-sip service entry with default content and return
       
  1347 // service ID for new profile
       
  1348 // -----------------------------------------------------------------------------
       
  1349 //
       
  1350 void CRCSEProfileRegistry::CreateDefaultServiceSettingsL( 
       
  1351     CRCSEProfileEntry& aNewEntry )
       
  1352     {
       
  1353     RCSELOGSTRING( 
       
  1354         "CRCSEProfileRegistry::CreateDefaultServiceSettingsL - IN" );
       
  1355 
       
  1356     // Do not create service if there is no SIP linkage.
       
  1357     if ( !aNewEntry.iIds.Count() )
       
  1358         {
       
  1359         return;
       
  1360         }
       
  1361     else if ( aNewEntry.iIds[0].iProfileType != 
       
  1362         CRCSEProfileEntry::EProtocolSIP )
       
  1363         {
       
  1364         return;
       
  1365         }
       
  1366     
       
  1367     TInt err( KErrNone );
       
  1368 
       
  1369     // Service table API
       
  1370     CSPSettings* table = CSPSettings::NewLC();
       
  1371 
       
  1372     // New service entry for this provider name
       
  1373     CSPEntry* entry = CSPEntry::NewLC();
       
  1374     entry->SetServiceName( aNewEntry.iProviderName );
       
  1375 
       
  1376     CSPProperty* property = CSPProperty::NewLC();
       
  1377 
       
  1378     // Service Setup plug-in UID ( if VoIP plugin UID set )
       
  1379     if ( KRCSEDefaultVoIPPluginUID != aNewEntry.iVoIPPluginUID )
       
  1380         {
       
  1381         property->SetName( EPropertyServiceSetupPluginId );
       
  1382         property->SetValue( aNewEntry.iVoIPPluginUID );
       
  1383         err = entry->AddPropertyL( *property );
       
  1384         if ( KErrAlreadyExists == err )
       
  1385             {
       
  1386             User::LeaveIfError(
       
  1387                     entry->UpdateProperty( EPropertyServiceSetupPluginId,
       
  1388                                            aNewEntry.iVoIPPluginUID ) );
       
  1389             }
       
  1390         else
       
  1391             {
       
  1392             User::LeaveIfError( err );
       
  1393             }
       
  1394         }
       
  1395 
       
  1396     // This property is needed by clients to check if VoIP service is used
       
  1397     property->SetName( ESubPropertyVoIPSettingsId );
       
  1398     property->SetValue( KVoIPSettingsID );
       
  1399     err = entry->AddPropertyL( *property );
       
  1400     if ( KErrAlreadyExists == err )
       
  1401         {
       
  1402         User::LeaveIfError( entry->UpdateProperty( ESubPropertyVoIPSettingsId,
       
  1403                                                    KVoIPSettingsID ) );
       
  1404         }
       
  1405     else
       
  1406         {
       
  1407         User::LeaveIfError( err );
       
  1408         }
       
  1409     
       
  1410     // Service Attribute Mask
       
  1411     FindAndAddDefaultPropertyL( 
       
  1412         *table, *entry, *property, EPropertyServiceAttributeMask );
       
  1413 
       
  1414     // Phone Application CLI plug-in UID
       
  1415     FindAndAddDefaultPropertyL( 
       
  1416         *table, *entry, *property, EPropertyCLIPluginId );
       
  1417 
       
  1418     // Phone Application Call Logging plug-in UID.
       
  1419     FindAndAddDefaultPropertyL( 
       
  1420         *table, *entry, *property, EPropertyCallLoggingPluginId );
       
  1421 
       
  1422     // Phone Application Call State Indicator plug-in UID.
       
  1423     FindAndAddDefaultPropertyL( 
       
  1424         *table, *entry, *property, EPropertyCallStateIndicatorPluginId );
       
  1425 
       
  1426     // Phone Application Call Menu Handler plug-in UID.
       
  1427     FindAndAddDefaultPropertyL( 
       
  1428         *table, *entry, *property, EPropertyCallMenuHandlerPluginId );
       
  1429 
       
  1430     // Converged Call Engine Call Provider plug-in UID.
       
  1431     FindAndAddDefaultPropertyL( 
       
  1432         *table, *entry, *property, EPropertyCallProviderPluginId );
       
  1433 
       
  1434     // Virtual Phonebook Contact Store ID.
       
  1435     FindAndAddDefaultPropertyL( 
       
  1436         *table, *entry, *property, EPropertyContactStoreId );
       
  1437 
       
  1438     // Contact View plug-in UID
       
  1439     FindAndAddDefaultPropertyL( 
       
  1440         *table, *entry, *property, EPropertyContactViewPluginId );
       
  1441 
       
  1442     // Converged Connection Handler (CCH) VoIP Subservice plug-in UID
       
  1443     FindAndAddDefaultPropertyL( 
       
  1444         *table, *entry, *property, EPropertyVoIPSubServicePluginId );
       
  1445 
       
  1446     // Converged Connection Handler (CCH) VMBX Subservice plug-in UID
       
  1447     FindAndAddDefaultPropertyL( 
       
  1448         *table, *entry, *property, EPropertyVMBXSubServicePluginId );
       
  1449 
       
  1450     // Brand ID for VoIP
       
  1451     FindAndAddDefaultPropertyL( 
       
  1452         *table, *entry, *property, EPropertyBrandId );
       
  1453 
       
  1454     // Presence Service Connectivity plugin UID
       
  1455     FindAndAddDefaultPropertyL( 
       
  1456         *table, *entry, *property, EPropertyPCSPluginId );
       
  1457 
       
  1458     // Maximum Lenght of Log Contact Link
       
  1459     FindAndAddDefaultPropertyL( 
       
  1460         *table, *entry, *property, EPropertyLogCntLinkMaxLength );
       
  1461 
       
  1462     // Field Type of Presence Presentity ID
       
  1463     FindAndAddDefaultPropertyL( 
       
  1464         *table, *entry, *property, ESubPropertyPresencePresentityIDFieldType );
       
  1465 
       
  1466     // Add entry to store and set service ID
       
  1467     User::LeaveIfError( table->AddEntryL( *entry ) );
       
  1468     aNewEntry.iServiceProviderId 
       
  1469         = static_cast<TUint32>( entry->GetServiceId() );
       
  1470 
       
  1471     CleanupStack::PopAndDestroy( property );
       
  1472     CleanupStack::PopAndDestroy( entry );
       
  1473     CleanupStack::PopAndDestroy( table );
       
  1474 
       
  1475     RCSELOGSTRING( 
       
  1476         "CRCSEProfileRegistry::CreateDefaultServiceSettingsL - OUT" );
       
  1477     }
       
  1478 
       
  1479 // ---------------------------------------------------------------------------
       
  1480 // CRCSEProfileRegistry::DeleteReferenceSettingsL
       
  1481 // ---------------------------------------------------------------------------
       
  1482 //
       
  1483 void CRCSEProfileRegistry::DeleteReferenceSettingsL( TUint32 aProfileId )
       
  1484     {
       
  1485     RCSELOGSTRING( "CRCSEProfileRegistry::DeleteReferenceSettingsL - IN" );
       
  1486 
       
  1487     CRCSEProfileEntry* profileInfo = CRCSEProfileEntry::NewLC();
       
  1488 
       
  1489     TRAPD( e, FindL( aProfileId, *profileInfo ) );
       
  1490 
       
  1491     __ASSERT_ALWAYS( KErrNone == e || KErrNotFound == e, User::Leave( e ) );
       
  1492 
       
  1493     // Delete related audio codecs
       
  1494     CRCSEAudioCodecRegistry* codecReg = CRCSEAudioCodecRegistry::NewLC();
       
  1495     codecReg->DeleteL( profileInfo->iPreferredCodecs );
       
  1496     CleanupStack::PopAndDestroy( codecReg );
       
  1497 
       
  1498     // Delete related service settings
       
  1499     if( CRCSEProfileEntry::EOONotSet == profileInfo->iNewServiceTableEntry ||
       
  1500         CRCSEProfileEntry::EOn == profileInfo->iNewServiceTableEntry )
       
  1501         {
       
  1502         RCSELOGSTRING( "Delete related service settings" );
       
  1503         CSPSettings* serviceSettings = CSPSettings::NewLC();
       
  1504         serviceSettings->DeleteEntryL( profileInfo->iServiceProviderId );
       
  1505         CleanupStack::PopAndDestroy( serviceSettings );
       
  1506         }
       
  1507 
       
  1508     CleanupStack::PopAndDestroy( profileInfo );
       
  1509 
       
  1510     RCSELOGSTRING( "CRCSEProfileRegistry::DeleteReferenceSettingsL - OUT" );
       
  1511     }
       
  1512 // -----------------------------------------------------------------------------
       
  1513 // CRCSEProfileRegistry::NameExistsInServiceTableL
       
  1514 // -----------------------------------------------------------------------------
       
  1515 //
       
  1516 TBool CRCSEProfileRegistry::NameExistsInServiceTableL(
       
  1517     const TDesC& aProviderName ) const
       
  1518     {
       
  1519     RCSELOGSTRING( "CRCSEProfileRegistry::NameExistsInServiceTableL- IN" );
       
  1520     TBool result( EFalse );
       
  1521     
       
  1522     RIdArray serviceIds;
       
  1523     CleanupClosePushL( serviceIds );
       
  1524     CDesCArray* serviceNames = 
       
  1525         new ( ELeave ) CDesCArrayFlat( KArrayInitSize );
       
  1526     CleanupStack::PushL( serviceNames );
       
  1527     CSPSettings* serviceSettings = CSPSettings::NewLC();
       
  1528     TInt err(KErrNone);
       
  1529     err = serviceSettings->FindServiceIdsL( serviceIds );
       
  1530     if ( KErrNotFound == err )
       
  1531         {
       
  1532         CleanupStack::PopAndDestroy( serviceSettings );
       
  1533         CleanupStack::PopAndDestroy( serviceNames );
       
  1534         CleanupStack::PopAndDestroy( &serviceIds );
       
  1535         return EFalse; 
       
  1536         }
       
  1537     User::LeaveIfError( err );
       
  1538     User::LeaveIfError( 
       
  1539         serviceSettings->FindServiceNamesL( serviceIds, *serviceNames ) );
       
  1540     CleanupStack::PopAndDestroy( serviceSettings );
       
  1541     TBool serviceFound( EFalse );
       
  1542     for ( TInt i( 0 ) ; i < serviceNames->MdcaCount() && !serviceFound ; i++ )
       
  1543         {
       
  1544         if ( !aProviderName.Compare( serviceNames->MdcaPoint( i) ) )
       
  1545             {
       
  1546             result = ETrue;
       
  1547             serviceFound = ETrue;
       
  1548             }
       
  1549         }
       
  1550     CleanupStack::PopAndDestroy( serviceNames );	
       
  1551     CleanupStack::PopAndDestroy( &serviceIds );
       
  1552     
       
  1553     RCSELOGSTRING( "CRCSEProfileRegistry::NameExistsInServiceTableL- OUT" );
       
  1554     return result;
       
  1555     }
       
  1556     
       
  1557 // -----------------------------------------------------------------------------
       
  1558 // CRCSEProfileRegistry::LeaveIfServiceIdInUseL
       
  1559 // -----------------------------------------------------------------------------
       
  1560 //
       
  1561 void CRCSEProfileRegistry::LeaveIfServiceIdInUseL(
       
  1562     const CRCSEProfileEntry& aEntry ) 
       
  1563     {    
       
  1564     RCSELOGSTRING( "CRCSEProfileRegistry::LeaveIfServiceIdInUseL - IN" );
       
  1565 
       
  1566     // Find all profile IDs
       
  1567     RArray<TUint32> voipIds;
       
  1568     CleanupClosePushL( voipIds );
       
  1569     FindAllIdsL( voipIds );
       
  1570 
       
  1571 
       
  1572     // Check service id from each profile
       
  1573     CCenRepDatabaseProperty* property = CCenRepDatabaseProperty::NewLC();
       
  1574     TBuf<KDesLength256> value;
       
  1575     TInt count( voipIds.Count() );
       
  1576 
       
  1577     for ( TInt i( 0 ); i < count; i++ )
       
  1578         {
       
  1579         iCenRepDb->FindPropertyL( voipIds[ i ], KColProtocolIds, *property );
       
  1580 
       
  1581         __ASSERT_ALWAYS( 
       
  1582             aEntry.iServiceProviderId != ToTUint32L( property->GetDesValue() ),
       
  1583                 User::Leave( KErrAlreadyExists ) );
       
  1584         }
       
  1585 
       
  1586     CleanupStack::PopAndDestroy( property );
       
  1587     CleanupStack::PopAndDestroy( &voipIds );
       
  1588 
       
  1589     RCSELOGSTRING( "CRCSEProfileRegistry::LeaveIfServiceIdInUseL - OUT" );
       
  1590     }
       
  1591 
       
  1592 // -----------------------------------------------------------------------------
       
  1593 // CRCSEProfileRegistry::UpdateServiceSettingsL
       
  1594 // -----------------------------------------------------------------------------
       
  1595 //
       
  1596 void CRCSEProfileRegistry::UpdateServiceSettingsL(
       
  1597     const CRCSEProfileEntry& aEntry ) 
       
  1598     {    
       
  1599     RCSELOGSTRING( "CRCSEProfileRegistry::UpdateServiceSettingsL - IN" );
       
  1600 
       
  1601     // Do not update service if there is no SIP linkage.
       
  1602     if ( !aEntry.iIds.Count() )
       
  1603         {
       
  1604         return;
       
  1605         }
       
  1606     else if ( aEntry.iIds[0].iProfileType != 
       
  1607         CRCSEProfileEntry::EProtocolSIP )
       
  1608         {
       
  1609         return;
       
  1610         }
       
  1611 
       
  1612     CSPSettings* serviceSettings = CSPSettings::NewLC();
       
  1613     CSPEntry* serviceEntry = CSPEntry::NewLC();
       
  1614 
       
  1615     User::LeaveIfError( 
       
  1616         serviceSettings->FindEntryL( 
       
  1617             aEntry.iServiceProviderId, *serviceEntry ) );
       
  1618 
       
  1619     // Update service settings if service name has been changed
       
  1620     if ( aEntry.iProviderName != serviceEntry->GetServiceName() )
       
  1621         {
       
  1622         serviceEntry->SetServiceName( aEntry.iProviderName );
       
  1623         User::LeaveIfError( serviceSettings->UpdateEntryL( *serviceEntry ) );
       
  1624         }
       
  1625 
       
  1626     CleanupStack::PopAndDestroy( serviceEntry );
       
  1627     CleanupStack::PopAndDestroy( serviceSettings );
       
  1628 
       
  1629     RCSELOGSTRING( "CRCSEProfileRegistry::UpdateServiceSettingsL - OUT" );
       
  1630     }
       
  1631 
       
  1632 // -----------------------------------------------------------------------------
       
  1633 // CRCSEProfileRegistry::UpdateServiceIdL
       
  1634 // -----------------------------------------------------------------------------
       
  1635 //
       
  1636 void CRCSEProfileRegistry::UpdateServiceIdL( TUint32 aId, TUint32 aServiceId )
       
  1637     {    
       
  1638     RCSELOGSTRING( "CRCSEProfileRegistry::UpdateServiceIdL - IN" );
       
  1639 
       
  1640     TBuf<KDesLength128> des;
       
  1641 
       
  1642     RIpAppPropArray properties;
       
  1643 
       
  1644     CreatePropertyL( KColServiceProviderId,
       
  1645                      ToDes( aServiceId, des ),
       
  1646                      properties );
       
  1647 
       
  1648     iCenRepDb->AddOrUpdatePropertiesL( aId, properties );
       
  1649 
       
  1650     properties.ResetAndDestroy();
       
  1651 
       
  1652     RCSELOGSTRING( "CRCSEProfileRegistry::UpdateServiceIdL - OUT" );
       
  1653     }
       
  1654 
       
  1655 // ---------------------------------------------------------------------------
       
  1656 // From MSIPProfileRegistryObserver
       
  1657 // CRCSEProfileRegistry::ProfileRegistryEventOccurred
       
  1658 // SIP profile event
       
  1659 // ---------------------------------------------------------------------------
       
  1660 //
       
  1661 void CRCSEProfileRegistry::ProfileRegistryEventOccurred( 
       
  1662     TUint32 /*aSIPProfileId*/,
       
  1663     TEvent /*aEvent*/ )
       
  1664     {
       
  1665     RCSELOGSTRING( "CRCSEProfileRegistry::ProfileRegistryEventOccurred" );
       
  1666     // Have to be implemented because MSIPProfileRegistryObserver
       
  1667     // is passed to CSIPManagedProfileRegistry.
       
  1668     }
       
  1669 
       
  1670 // ---------------------------------------------------------------------------
       
  1671 // From MSIPProfileRegistryObserver
       
  1672 // CRCSEProfileRegistry::ProfileRegistryErrorOccured
       
  1673 // An asynchronous error has occurred related to SIP profile
       
  1674 // ---------------------------------------------------------------------------
       
  1675 //
       
  1676 void CRCSEProfileRegistry::ProfileRegistryErrorOccurred( 
       
  1677     TUint32  /*aProfileId*/,
       
  1678     TInt /*aError*/ )
       
  1679     {
       
  1680     RCSELOGSTRING( "CRCSEProfileRegistry::ProfileRegistryErrorOccurred" );
       
  1681     // Have to be implemented because MSIPProfileRegistryObserver
       
  1682     // is passed to CSIPManagedProfileRegistry.
       
  1683     }
       
  1684 
       
  1685 // -----------------------------------------------------------------------------
       
  1686 // CRCSEProfileRegistry::ResetAndDestroyEntries
       
  1687 // -----------------------------------------------------------------------------
       
  1688 //
       
  1689 void CRCSEProfileRegistry::ResetAndDestroyEntries( TAny* anArray )
       
  1690 	{
       
  1691 	RCSELOGSTRING( "CRCSEProfileRegistry::ResetAndDestroyEntries - IN" );
       
  1692 	
       
  1693     RPointerArray<CRCSEProfileEntry>* array = 
       
  1694         reinterpret_cast<RPointerArray<CRCSEProfileEntry>*>( anArray );
       
  1695     if (array)
       
  1696         {
       
  1697         array->ResetAndDestroy();
       
  1698         array->Close();
       
  1699         }
       
  1700     RCSELOGSTRING( "CRCSEProfileRegistry::ResetAndDestroyEntries - OUT" );
       
  1701 	}
       
  1702 
       
  1703 // -----------------------------------------------------------------------------
       
  1704 // CRCSEProfileRegistry::CopyEntryValues
       
  1705 // -----------------------------------------------------------------------------
       
  1706 //
       
  1707 void CRCSEProfileRegistry::CopyEntryValues( 
       
  1708     const CRCSEProfileEntry& aSourceEntry, 
       
  1709     CRCSEProfileEntry& aDestinationEntry )
       
  1710     {
       
  1711     aDestinationEntry.ResetDefaultValues();
       
  1712     aDestinationEntry.iIds.Reset();
       
  1713     for ( TInt i = 0; i < aSourceEntry.iIds.Count(); i++ )
       
  1714         {
       
  1715         aDestinationEntry.iIds.Append( aSourceEntry.iIds[i] );
       
  1716         }
       
  1717     aDestinationEntry.iId = aSourceEntry.iId;
       
  1718     aDestinationEntry.iProviderName = aSourceEntry.iProviderName;
       
  1719     aDestinationEntry.iSettingsName = aSourceEntry.iSettingsName;
       
  1720     aDestinationEntry.iPreferredCodecs.Reset();
       
  1721     for ( TInt i = 0; i < aSourceEntry.iPreferredCodecs.Count(); i++ )
       
  1722         {
       
  1723         aDestinationEntry.iPreferredCodecs.Append( 
       
  1724             aSourceEntry.iPreferredCodecs[i] );
       
  1725         }
       
  1726     aDestinationEntry.iStartMediaPort = aSourceEntry.iStartMediaPort;
       
  1727     aDestinationEntry.iEndMediaPort = aSourceEntry.iEndMediaPort;
       
  1728     aDestinationEntry.iMediaQOS = aSourceEntry.iMediaQOS;
       
  1729     aDestinationEntry.iInbandDTMF = aSourceEntry.iInbandDTMF;
       
  1730     aDestinationEntry.iOutbandDTMF = aSourceEntry.iOutbandDTMF;
       
  1731     aDestinationEntry.iSecureCallPreference = 
       
  1732         aSourceEntry.iSecureCallPreference;
       
  1733     aDestinationEntry.iRTCP = aSourceEntry.iRTCP;
       
  1734     aDestinationEntry.iSIPVoIPUAHTerminalType = 
       
  1735         aSourceEntry.iSIPVoIPUAHTerminalType;
       
  1736     aDestinationEntry.iSIPVoIPUAHeaderWLANMAC = 
       
  1737         aSourceEntry.iSIPVoIPUAHeaderWLANMAC;
       
  1738     aDestinationEntry.iSIPVoIPUAHeaderString = 
       
  1739         aSourceEntry.iSIPVoIPUAHeaderString;
       
  1740     aDestinationEntry.iProfileLockedToIAP = aSourceEntry.iProfileLockedToIAP;
       
  1741     aDestinationEntry.iVoIPPluginUID = aSourceEntry.iVoIPPluginUID;
       
  1742     aDestinationEntry.iAllowVoIPoverWCDMA = aSourceEntry.iAllowVoIPoverWCDMA;
       
  1743     aDestinationEntry.iMeanCountOfVoIPDigits = 
       
  1744         aSourceEntry.iMeanCountOfVoIPDigits;
       
  1745     aDestinationEntry.iIgnoreAddrDomainPart = 
       
  1746         aSourceEntry.iIgnoreAddrDomainPart;
       
  1747     aDestinationEntry.iServiceProviderId = aSourceEntry.iServiceProviderId;
       
  1748     aDestinationEntry.iUserPhoneUriParameter = 
       
  1749         aSourceEntry.iUserPhoneUriParameter;
       
  1750     aDestinationEntry.iSIPConnTestAddress = aSourceEntry.iSIPConnTestAddress;
       
  1751     aDestinationEntry.iNATSettingsStorageId = 
       
  1752         aSourceEntry.iNATSettingsStorageId;
       
  1753     aDestinationEntry.iSIPMinSE = aSourceEntry.iSIPMinSE;
       
  1754     aDestinationEntry.iSIPSessionExpires = aSourceEntry.iSIPSessionExpires;
       
  1755     aDestinationEntry.iNATProtocol = aSourceEntry.iNATProtocol;
       
  1756     aDestinationEntry.iNewServiceTableEntry = 
       
  1757         aSourceEntry.iNewServiceTableEntry;
       
  1758     aDestinationEntry.iSNAPId = aSourceEntry.iSNAPId;
       
  1759     aDestinationEntry.iAccountCreationUrl = aSourceEntry.iAccountCreationUrl;
       
  1760     }
       
  1761 
       
  1762 //  End of File  
       
  1763 
       
  1764