|
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 #include "IconFileProvider.h" |
|
20 |
|
21 // ============================ MEMBER FUNCTIONS =============================== |
|
22 |
|
23 // ----------------------------------------------------------------------------- |
|
24 // CIconFileProvider::CIconFileProvider() |
|
25 // C++ default constructor. |
|
26 // ----------------------------------------------------------------------------- |
|
27 // |
|
28 CIconFileProvider::CIconFileProvider(RFs aSession) : iSession(aSession) |
|
29 { |
|
30 } |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CIconFileProvider::NewL() |
|
34 // Two-phased constructor. |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 CIconFileProvider* CIconFileProvider::NewL(RFs aSession, const TDesC& aFilename) |
|
38 { |
|
39 CIconFileProvider* self = new (ELeave) CIconFileProvider(aSession); |
|
40 CleanupStack::PushL(self); |
|
41 self->ConstructL(aFilename); |
|
42 CleanupStack::Pop(); // self |
|
43 return self; |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CIconFileProvider::ConstructL() |
|
48 // 2nd phase constructor |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 void CIconFileProvider::ConstructL( const TDesC& aFilename) |
|
52 { |
|
53 iFilename = aFilename.AllocL(); |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CIconFileProvider::~CIconFileProvider() |
|
58 // Destructor |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 CIconFileProvider::~CIconFileProvider() |
|
62 { |
|
63 delete iFilename; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CIconFileProvider::RetrieveIconFileHandleL() |
|
68 // Returns an open file handle to the icon file. |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 void CIconFileProvider::RetrieveIconFileHandleL( RFile& aFile, |
|
72 const TIconFileType aType ) |
|
73 { |
|
74 // MAknIconFileProvider will by default try to open files that |
|
75 // have .mif extension first. If in case of this application, only the |
|
76 // file handle of mbm-file is passed to framework, |
|
77 // MAknIconFileProvider result will be KErrArgument. This is solved by |
|
78 // giving the correct file extension determined by function parameter |
|
79 // aType. |
|
80 // |
|
81 TFileName filename; |
|
82 |
|
83 filename = iFilename->Des().Left(iFilename->Length()-3); |
|
84 |
|
85 if (aType == EMifFile) |
|
86 { |
|
87 _LIT(KMif, "mif"); |
|
88 filename.Append(KMif); |
|
89 } |
|
90 else // mbm |
|
91 { |
|
92 _LIT(KMbm, "mbm"); |
|
93 filename.Append(KMbm); |
|
94 } |
|
95 |
|
96 User::LeaveIfError(aFile.Open(iSession, filename, EFileShareAny)); |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CIconFileProvider::Finished() |
|
101 // With this method, AknIcon framework informs that it does not use this |
|
102 // MAknIconFileProvider instance any more. |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 void CIconFileProvider::Finished() |
|
106 { |
|
107 } |
|
108 |