|
1 /* |
|
2 * Copyright (c) 2002 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 FILES |
|
21 #include "AknIconFileNameCache.h" |
|
22 #include "AknIconFileNameItem.h" |
|
23 |
|
24 // CONSTANTS |
|
25 |
|
26 // ================= MEMBER FUNCTIONS ========================================== |
|
27 |
|
28 CAknIconFileNameCache::CAknIconFileNameCache() |
|
29 { |
|
30 } |
|
31 |
|
32 CAknIconFileNameCache::~CAknIconFileNameCache() |
|
33 { |
|
34 iFileNameItems.ResetAndDestroy(); |
|
35 } |
|
36 |
|
37 CAknIconFileNameCache* CAknIconFileNameCache::NewL() |
|
38 { |
|
39 return new( ELeave ) CAknIconFileNameCache; |
|
40 } |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CAknIconFileNameCache::CacheIconFileNameL |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 HBufC* CAknIconFileNameCache::CacheIconFileNameL( const TDesC& aFileName ) |
|
47 { |
|
48 HBufC* retFileName = GetIconFileName(aFileName); |
|
49 if (!retFileName) |
|
50 { |
|
51 retFileName = StoreIconFileNameL(aFileName); |
|
52 } |
|
53 return retFileName; |
|
54 } |
|
55 |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CAknIconFileNameCache::GetIconFileName |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 HBufC* CAknIconFileNameCache::GetIconFileName( const TDesC& aFileName ) const |
|
62 { |
|
63 HBufC* retFileName = NULL; |
|
64 // Compare item. Can be instantiated in stack with this constructor. |
|
65 CAknIconFileNameItem compareItem( aFileName ); |
|
66 |
|
67 TInt index = iFileNameItems.FindInOrder( |
|
68 &compareItem, CAknIconFileNameItem::LinearOrder ); |
|
69 |
|
70 if ( index >= 0 ) |
|
71 { |
|
72 retFileName = iFileNameItems[index]->iFileName; |
|
73 } |
|
74 return retFileName; |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CAknIconFileNameCache::StoreIconFileNameL |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 HBufC* CAknIconFileNameCache::StoreIconFileNameL( const TDesC& aFileName ) |
|
82 { |
|
83 CAknIconFileNameItem* fileNameItem = CAknIconFileNameItem::NewL(aFileName); |
|
84 CleanupStack::PushL( fileNameItem ); |
|
85 User::LeaveIfError( iFileNameItems.InsertInOrder( |
|
86 fileNameItem, CAknIconFileNameItem::LinearOrder ) ); |
|
87 CleanupStack::Pop(fileNameItem); |
|
88 return fileNameItem->iFileName; |
|
89 } |
|
90 |
|
91 // End of File |