natfw/natfwstunplugin/tsrc/ut_cnatfwstunplugin/stubs/settings.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2007 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:    
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "settings.h"
       
    21 
       
    22 #include <unsafprotocolscrkeys.h>
       
    23 
       
    24 #include "datadepository.h"
       
    25 
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // CSettings
       
    29 // -----------------------------------------------------------------------------
       
    30 // 
       
    31 CSettings::CSettings()
       
    32     {
       
    33     }
       
    34  
       
    35  
       
    36 // -----------------------------------------------------------------------------
       
    37 // ~CSettings
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CSettings::~CSettings( )
       
    41     {
       
    42     delete iDepository;
       
    43     delete iRepository;
       
    44     }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CSettings::ConstructBaseL
       
    48 // -----------------------------------------------------------------------------
       
    49 //  
       
    50 void CSettings::ConstructBaseL()
       
    51     {
       
    52     iRepository = CRepository::NewL( KCRUidUNSAFProtocols );
       
    53     iDepository = CDataDepository::NewL( iRepository );
       
    54     }
       
    55 
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CSettings::CreateNewTableKeyL
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 TUint32 CSettings::CreateNewTableKeyL( TUint aTableMask, TUint32 aFieldMask ) const
       
    62     {
       
    63     return iDepository->CreateNewTableKeyL( aTableMask, aFieldMask );
       
    64     }
       
    65 
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CSettings::StoreL
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 void CSettings::StoreL( const TUint32 aKey, const TInt aData )
       
    72     {
       
    73     iDepository->StoreL( aKey, aData );
       
    74     }
       
    75 
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CSettings::StoreL
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 void CSettings::StoreL( const TUint32 aKey, const TDesC8& aData )
       
    82     {
       
    83     iDepository->StoreL( aKey, aData );
       
    84     }
       
    85     
       
    86     
       
    87 // -----------------------------------------------------------------------------
       
    88 // CSettings::Read(
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 TInt CSettings::Read( const TUint32 aKey, TInt& aData )
       
    92     {
       
    93     return iDepository->Read( aKey, aData );
       
    94     }
       
    95 
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CSettings::ReadL
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 TInt CSettings::ReadL( const TUint32 aKey, HBufC8** aData )
       
   102     {
       
   103     return iDepository->ReadL( aKey, aData );
       
   104     }
       
   105     
       
   106 // -----------------------------------------------------------------------------
       
   107 // CSettings::ReadDomainSettingsKeyL
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 TInt CSettings::ReadDomainSettingsKeyL( const TDesC8& aDomain, 
       
   111     TUint32& aDomainKey ) const
       
   112     {
       
   113     RArray<TUint32> keys;
       
   114     CleanupClosePushL( keys );
       
   115     
       
   116     TInt err = iRepository->FindEqL( KUNSAFProtocolsDomainMask,
       
   117         KUNSAFProtocolsFieldTypeMask, aDomain, keys );
       
   118     TInt count = keys.Count();
       
   119     
       
   120     if ( KErrNone == err && 1 == count )
       
   121         {
       
   122         aDomainKey = KUNSAFProtocolsDomainMask ^ keys[0];
       
   123         }
       
   124     if ( count > 1 )
       
   125         {
       
   126         err = KErrCorrupt;
       
   127         }
       
   128     CleanupStack::PopAndDestroy( &keys );
       
   129     return err;
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CSettings::EraseL
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 TInt CSettings::EraseL( TUint32 aTableMask, TUint32 aFieldTypeMask )
       
   137     {
       
   138     return iDepository->EraseL( aTableMask, aFieldTypeMask );
       
   139     }
       
   140 
       
   141 
       
   142 
       
   143