|
1 /* |
|
2 * Copyright (c) 2004 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: SAP Settings Store proxy. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <E32Std.h> |
|
20 #include <CIMPSSAPSettingsStore.h> |
|
21 #include "CCnUiSapStoreProxy.h" |
|
22 |
|
23 |
|
24 // ================= LOCAL FUNCTIONS ======================= |
|
25 // ----------------------------------------------------------------------------- |
|
26 // ReleaseSapStoreIfOwned() |
|
27 // ----------------------------------------------------------------------------- |
|
28 // |
|
29 void ReleaseSapStoreIfOwned( TAny* aSapStoreProxy ) |
|
30 { |
|
31 CCnUiSapStoreProxy* p = static_cast< CCnUiSapStoreProxy* >( aSapStoreProxy ); |
|
32 p->ReleaseOwnedSapStore(); |
|
33 } |
|
34 |
|
35 |
|
36 |
|
37 // ================= MEMBER FUNCTIONS ======================= |
|
38 // C++ default constructor can NOT contain any code, that |
|
39 // might leave. |
|
40 // |
|
41 CCnUiSapStoreProxy::CCnUiSapStoreProxy( CIMPSSAPSettingsStore* aSapStore ) |
|
42 : iSapStore( aSapStore ) |
|
43 { |
|
44 } |
|
45 |
|
46 |
|
47 // Destructor |
|
48 CCnUiSapStoreProxy::~CCnUiSapStoreProxy() |
|
49 { |
|
50 ReleaseOwnedSapStore(); |
|
51 } |
|
52 |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CCnUiSapStoreProxy::SapStoreL() |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CIMPSSAPSettingsStore& CCnUiSapStoreProxy::SapStoreL() |
|
59 { |
|
60 //lazy initialize the SAP store if yet not having one. |
|
61 if ( !iSapStore ) |
|
62 { |
|
63 iSapStore = CIMPSSAPSettingsStore::NewL(); |
|
64 iOwnsSapStore = ETrue; |
|
65 } |
|
66 return *iSapStore; |
|
67 } |
|
68 |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CCnUiSapStoreProxy::PushOwnedSapStoreReleaseLC() |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 void CCnUiSapStoreProxy::PushOwnedSapStoreReleaseLC() |
|
75 { |
|
76 CleanupStack::PushL( TCleanupItem( ReleaseSapStoreIfOwned, this ) ); |
|
77 } |
|
78 |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CCnUiSapStoreProxy::ReleaseOwnedSapStore() |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 void CCnUiSapStoreProxy::ReleaseOwnedSapStore() |
|
85 { |
|
86 //if owning SAP store, destroy it and clear holding flags. |
|
87 if ( iOwnsSapStore ) |
|
88 { |
|
89 delete iSapStore; |
|
90 iSapStore = NULL; |
|
91 iOwnsSapStore = EFalse; |
|
92 } |
|
93 } |
|
94 |
|
95 // End of File |