voipplugins/svtmatching/src/svtsettingshandler.cpp
changeset 0 a4daefaec16c
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Settings handler class for svtmatching.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <spsettings.h>
       
    20 #include <spdefinitions.h>
       
    21 #include <spproperty.h>
       
    22 #include <crcseprofileregistry.h>
       
    23 
       
    24 #include "svtsettingshandler.h"
       
    25 #include "svtcleanup.h"
       
    26 
       
    27 
       
    28 // ======== MEMBER FUNCTIONS ========
       
    29 
       
    30 
       
    31 // ---------------------------------------------------------------------------
       
    32 // ---------------------------------------------------------------------------
       
    33 //
       
    34 CSvtSettingsHandler::CSvtSettingsHandler()
       
    35     {
       
    36     }
       
    37 
       
    38   
       
    39 // ---------------------------------------------------------------------------
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 CSvtSettingsHandler* CSvtSettingsHandler::NewL()
       
    43     {
       
    44     CSvtSettingsHandler* self = new ( ELeave ) CSvtSettingsHandler;
       
    45     return self;
       
    46     }
       
    47 
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 CSvtSettingsHandler::~CSvtSettingsHandler()
       
    53     {
       
    54 
       
    55     }
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // Initializes settings
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 void CSvtSettingsHandler::InitializeSettingsL( TUint aServiceId )
       
    62     {
       
    63     CRCSEProfileRegistry* registry = CreateRcseRegistryLC();
       
    64     
       
    65     RPointerArray<CRCSEProfileEntry> entries;
       
    66     // Cleanup for pointer array
       
    67     CleanupResetAndDestroy< 
       
    68         RPointerArray< CRCSEProfileEntry > >::PushL( entries );
       
    69     
       
    70     // Find voip settings by service id
       
    71     registry->FindByServiceIdL( aServiceId, entries );
       
    72     if ( 0 == entries.Count() )
       
    73         {
       
    74         User::Leave( KErrNotFound );
       
    75         }
       
    76     
       
    77     // Ignore domain part setting from rcse
       
    78     iIgnoreDomainPart = entries[0]->iIgnoreAddrDomainPart;
       
    79     // Meaningful digits for matching
       
    80     iMeaningfulDigits = entries[0]->iMeanCountOfVoIPDigits;
       
    81     // Service id
       
    82     iServiceId = aServiceId;
       
    83     
       
    84     CleanupStack::PopAndDestroy( &entries );
       
    85     CleanupStack::PopAndDestroy( registry );
       
    86     }
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // Returns value of meaningful digits
       
    90 // ---------------------------------------------------------------------------
       
    91 //
       
    92 TInt CSvtSettingsHandler::MeaningfulDigits() const
       
    93     {
       
    94     return iMeaningfulDigits;
       
    95     }
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // Returns value of ignore domain part setting
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 TUint CSvtSettingsHandler::IgnoreDomainPartValue() const
       
   102     {
       
   103     return iIgnoreDomainPart;
       
   104     }
       
   105 
       
   106 // ---------------------------------------------------------------------------
       
   107 // Gets contact store uris
       
   108 // ---------------------------------------------------------------------------
       
   109 //
       
   110 TInt CSvtSettingsHandler::GetContactStoreUris( CDesCArray& aStoreUris ) const
       
   111     {
       
   112     TRAPD( ret, GetContactStoreUrisL( aStoreUris ) );
       
   113     return ret;
       
   114     }
       
   115 
       
   116 // ---------------------------------------------------------------------------
       
   117 // Gets contact store uris
       
   118 // ---------------------------------------------------------------------------
       
   119 //
       
   120 void CSvtSettingsHandler::GetContactStoreUrisL( CDesCArray& aStoreUris ) const
       
   121     {
       
   122     // Get contact store id from Service Table
       
   123     //KSPMaxDesLength from spdefinitions.h
       
   124     HBufC* cntStoreId = HBufC::NewLC( KSPMaxDesLength );
       
   125     CSPSettings* spSettings = CreateSpSettingsLC(); 
       
   126     
       
   127     CSPProperty* property = CSPProperty::NewLC();
       
   128     User::LeaveIfError( spSettings->FindPropertyL( 
       
   129             TServiceId( iServiceId ), EPropertyContactStoreId, *property ) ); 
       
   130                            
       
   131                
       
   132     TPtr storeUri( cntStoreId->Des() );
       
   133     User::LeaveIfError( property->GetValue( storeUri ) );   
       
   134     
       
   135     aStoreUris.AppendL( storeUri );
       
   136     
       
   137     CleanupStack::PopAndDestroy( property ); 
       
   138     CleanupStack::PopAndDestroy( spSettings ); 
       
   139     CleanupStack::PopAndDestroy( cntStoreId ); 
       
   140     }
       
   141 
       
   142 // ---------------------------------------------------------------------------
       
   143 // Returns new instance of rcse registry
       
   144 // ---------------------------------------------------------------------------
       
   145 //
       
   146 CRCSEProfileRegistry* CSvtSettingsHandler::CreateRcseRegistryLC() const
       
   147     {
       
   148     return CRCSEProfileRegistry::NewLC();
       
   149     }
       
   150 
       
   151 // ---------------------------------------------------------------------------
       
   152 // Returns new instance of SPSettings
       
   153 // ---------------------------------------------------------------------------
       
   154 //
       
   155 CSPSettings* CSvtSettingsHandler::CreateSpSettingsLC() const
       
   156     {
       
   157     return CSPSettings::NewLC();
       
   158     }