javaextensions/centralrepository/src/cjavacentralrepository.cpp
branchRCL_3
changeset 83 26b2b12093af
parent 77 7cee158cb8cd
child 84 0553e2305d00
equal deleted inserted replaced
77:7cee158cb8cd 83:26b2b12093af
     1 /*
       
     2 * Copyright (c) 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:
       
    15 *
       
    16 */
       
    17 
       
    18 #include <centralrepository.h>  // CRepository
       
    19 
       
    20 #include "cjavacentralrepository.h" // CJavaCentralRepository
       
    21 #include "logger.h"
       
    22 // ======== MEMBER FUNCTIONS ========
       
    23 
       
    24 // ---------------------------------------------------------------------------
       
    25 // CJavaCentralRepository::NewL
       
    26 // ---------------------------------------------------------------------------
       
    27 CJavaCentralRepository* CJavaCentralRepository::NewL(TUid aRepositoryUid)
       
    28 {
       
    29     CJavaCentralRepository* self = CJavaCentralRepository::NewLC(aRepositoryUid);
       
    30     CleanupStack::Pop(self);
       
    31     return self;
       
    32 }
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // CJavaCentralRepository::NewLC
       
    36 // ---------------------------------------------------------------------------
       
    37 CJavaCentralRepository* CJavaCentralRepository::NewLC(TUid aRepositoryUid)
       
    38 {
       
    39     CJavaCentralRepository* self =
       
    40         new(ELeave) CJavaCentralRepository(aRepositoryUid);
       
    41     CleanupStack::PushL(self);
       
    42     self->ConstructL();
       
    43     return self;
       
    44 }
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // CJavaCentralRepository::~CJavaCentralRepository
       
    48 // ---------------------------------------------------------------------------
       
    49 CJavaCentralRepository::~CJavaCentralRepository()
       
    50 {
       
    51     Close();
       
    52 }
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // CJavaCentralRepository::Close
       
    56 // ---------------------------------------------------------------------------
       
    57 void CJavaCentralRepository::Close()
       
    58 {
       
    59     iRepositoryUid = TUid::Null();
       
    60     delete iRepository;
       
    61     iRepository = NULL;
       
    62 }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // CJavaCentralRepository::CJavaCentralRepository
       
    66 // ---------------------------------------------------------------------------
       
    67 CJavaCentralRepository::CJavaCentralRepository(TUid aRepositoryUid)
       
    68 {
       
    69     iRepositoryUid = aRepositoryUid;
       
    70 }
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // CJavaCentralRepository::ConstructL
       
    74 // ---------------------------------------------------------------------------
       
    75 void CJavaCentralRepository::ConstructL()
       
    76 {
       
    77     iRepository = CRepository::NewL(iRepositoryUid);
       
    78 }
       
    79 
       
    80 /**
       
    81  * GetStringL
       
    82  */
       
    83 HBufC* CJavaCentralRepository::GetStringL(TUint32 aKey)
       
    84 {
       
    85     HBufC* value = HBufC::NewLC(NCentralRepositoryConstants::KMaxUnicodeStringLength);
       
    86     TPtr ptr(value->Des());
       
    87     GetL(aKey, ptr);
       
    88 
       
    89     //aValue = value;
       
    90     CleanupStack::Pop(value);
       
    91     return value;
       
    92 }
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // CJavaCentralRepository::Get
       
    96 // ---------------------------------------------------------------------------
       
    97 void CJavaCentralRepository::GetL(TUint32 aKey, TDes& aValue)
       
    98 {
       
    99     User::LeaveIfError(iRepository->Get(aKey, aValue));
       
   100 }
       
   101 
       
   102 /**
       
   103  * GetIntL
       
   104  */
       
   105 TInt CJavaCentralRepository::GetIntL(TUint32 aKey/*, TInt& aValue*/)
       
   106 {
       
   107     TInt value(0);
       
   108     GetL(aKey, value);
       
   109     return value;
       
   110 }
       
   111 
       
   112 // ---------------------------------------------------------------------------
       
   113 // CJavaCentralRepository::Get
       
   114 // ---------------------------------------------------------------------------
       
   115 void CJavaCentralRepository::GetL(TUint32 aKey, TInt& aValue)
       
   116 {
       
   117     User::LeaveIfError(iRepository->Get(aKey, aValue));
       
   118 }
       
   119 
       
   120 // ---------------------------------------------------------------------------
       
   121 // CJavaCentralRepository::Set
       
   122 // ---------------------------------------------------------------------------
       
   123 void CJavaCentralRepository::SetL(TUint32 aKey, TDesC& aValue)
       
   124 {
       
   125     User::LeaveIfError(iRepository->Set(aKey, aValue));
       
   126 }
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 // CJavaCentralRepository::Set
       
   130 // ---------------------------------------------------------------------------
       
   131 void CJavaCentralRepository::SetL(TUint32 aKey, TInt aValue)
       
   132 {
       
   133     User::LeaveIfError(iRepository->Set(aKey, aValue));
       
   134 }