|
1 /* |
|
2 * Copyright (c) 2004-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: Static interface class for arbitrary data storage |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <coemain.h> |
|
21 |
|
22 #include "AknsCppPreface.h" |
|
23 #include <AknsPointerStore.h> |
|
24 #include "AknsAppSkinInstance.h" |
|
25 |
|
26 AKNS_UNDEFINED_METHOD(AknsPointerStore::AknsPointerStore) |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // AknsPointerStore::StorePointerL |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 AKNS_EXPORTED_METHOD(AknsPointerStore::StorePointerL) |
|
35 EXPORT_C void AknsPointerStore::StorePointerL( const TAny* aKey, TAny* aValue ) |
|
36 { |
|
37 CAknsAppSkinInstance* skin = static_cast<CAknsAppSkinInstance*> |
|
38 (CCoeEnv::Static( KAknsSkinInstanceTls )); |
|
39 |
|
40 if( !aValue ) |
|
41 { |
|
42 // No need to store NULL value |
|
43 return; |
|
44 } |
|
45 |
|
46 if( !skin ) |
|
47 { |
|
48 User::Leave( KErrNotReady ); |
|
49 } |
|
50 |
|
51 TAknsPointerStoreEntry entry; |
|
52 TInt index; |
|
53 |
|
54 entry.iKey = reinterpret_cast<TUint>(aKey); |
|
55 if( skin->iPointerStoreList.FindInUnsignedKeyOrder( |
|
56 entry, index ) == KErrNone ) |
|
57 { |
|
58 skin->iPointerStoreList[index].iValue = aValue; |
|
59 } |
|
60 else |
|
61 { |
|
62 entry.iValue = aValue; |
|
63 User::LeaveIfError( |
|
64 skin->iPointerStoreList.InsertInUnsignedKeyOrder( entry ) ); |
|
65 } |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // AknsPointerStore::RetrievePointer |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 AKNS_EXPORTED_METHOD(AknsPointerStore::RetrievePointer) |
|
73 EXPORT_C TAny* AknsPointerStore::RetrievePointer( const TAny* aKey ) |
|
74 { |
|
75 CAknsAppSkinInstance* skin = static_cast<CAknsAppSkinInstance*> |
|
76 (CCoeEnv::Static( KAknsSkinInstanceTls )); |
|
77 |
|
78 if( !skin ) |
|
79 { |
|
80 return NULL; |
|
81 } |
|
82 |
|
83 TAknsPointerStoreEntry entry; |
|
84 TInt index; |
|
85 |
|
86 entry.iKey = reinterpret_cast<TUint>(aKey); |
|
87 if( skin->iPointerStoreList.FindInUnsignedKeyOrder( |
|
88 entry, index ) == KErrNone ) |
|
89 { |
|
90 return skin->iPointerStoreList[index].iValue; |
|
91 } |
|
92 |
|
93 return NULL; |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // AknsPointerStore::RemovePointer |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 AKNS_EXPORTED_METHOD(AknsPointerStore::RemovePointer) |
|
101 EXPORT_C void AknsPointerStore::RemovePointer( const TAny* aKey ) |
|
102 { |
|
103 CAknsAppSkinInstance* skin = static_cast<CAknsAppSkinInstance*> |
|
104 (CCoeEnv::Static( KAknsSkinInstanceTls )); |
|
105 |
|
106 if( !skin ) |
|
107 { |
|
108 return; |
|
109 } |
|
110 |
|
111 TAknsPointerStoreEntry entry; |
|
112 TInt index; |
|
113 |
|
114 entry.iKey = reinterpret_cast<TUint>(aKey); |
|
115 if( skin->iPointerStoreList.FindInUnsignedKeyOrder( |
|
116 entry, index ) == KErrNone ) |
|
117 { |
|
118 skin->iPointerStoreList.Remove( index ); |
|
119 } |
|
120 } |
|
121 |
|
122 // End of File |