|
1 /* |
|
2 * Copyright (c) 2009 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 * loads widget manager resources and icons |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <eikenv.h> |
|
21 #include <eikappui.h> |
|
22 #include <aknapp.h> |
|
23 #include <bautils.h> |
|
24 #include <gdi.h> |
|
25 #include <aknbutton.h> |
|
26 #include <AknIconUtils.h> |
|
27 #include <StringLoader.h> |
|
28 #include <aknnotewrappers.h> |
|
29 #include <widgetmanagerview.rsg> |
|
30 |
|
31 #include "wmresourceloader.h" |
|
32 |
|
33 // CONSTANTS |
|
34 _LIT( KZdrive, "Z:" ); |
|
35 _LIT( KRelativeMifPath, "\\resource\\apps\\widgetmanager.mif" ); |
|
36 _LIT( KRelativeResourcePathWithWildcard, "\\resource\\widgetmanagerview.r*" ); |
|
37 _LIT( KRelativeResourcePath, "\\resource\\widgetmanagerview.rsc" ); |
|
38 |
|
39 // --------------------------------------------------------- |
|
40 // CWmResourceLoader::NewL |
|
41 // --------------------------------------------------------- |
|
42 // |
|
43 CWmResourceLoader* CWmResourceLoader::NewL( |
|
44 CEikonEnv& aEnv ) |
|
45 { |
|
46 CWmResourceLoader* self = new (ELeave) CWmResourceLoader( aEnv ); |
|
47 CleanupStack::PushL( self ); |
|
48 self->ConstructL(); |
|
49 CleanupStack::Pop( self ); |
|
50 return self; |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------- |
|
54 // CWmResourceLoader::CWmResourceLoader |
|
55 // --------------------------------------------------------- |
|
56 // |
|
57 CWmResourceLoader::CWmResourceLoader( CEikonEnv& aEnv ) |
|
58 : iEnv( aEnv ) |
|
59 { |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------- |
|
63 // CWmResourceLoader::~CWmResourceLoader |
|
64 // --------------------------------------------------------- |
|
65 // |
|
66 CWmResourceLoader::~CWmResourceLoader() |
|
67 { |
|
68 UnloadResources(); |
|
69 delete iNote; |
|
70 delete iDescription; |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------- |
|
74 // CWmResourceLoader::ConstructL |
|
75 // --------------------------------------------------------- |
|
76 // |
|
77 void CWmResourceLoader::ConstructL() |
|
78 { |
|
79 Dll::FileName( iDllName ); |
|
80 |
|
81 LoadResourcesL(); |
|
82 DetermineIconFilePath(); |
|
83 |
|
84 iDescription = StringLoader::LoadL( |
|
85 R_QTN_WM_DETAILS_NO_DESCRIPTION, &iEnv ); |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------- |
|
89 // CWmResourceLoader::LoadResourcesL |
|
90 // --------------------------------------------------------- |
|
91 // |
|
92 void CWmResourceLoader::LoadResourcesL() |
|
93 { |
|
94 TFileName resourceFile; |
|
95 RFs& fs = iEnv.FsSession(); |
|
96 TPtrC dllDrive = iDllName.Left(2); |
|
97 resourceFile.Copy( dllDrive ); |
|
98 resourceFile.Append( KRelativeResourcePathWithWildcard ); |
|
99 BaflUtils::NearestLanguageFile( fs, resourceFile ); |
|
100 if ( !BaflUtils::FileExists( fs, resourceFile ) ) |
|
101 { |
|
102 resourceFile.Copy( dllDrive ); |
|
103 resourceFile.Append( KRelativeResourcePath ); |
|
104 BaflUtils::NearestLanguageFile( fs, resourceFile ); |
|
105 if ( !BaflUtils::FileExists( fs, resourceFile ) && |
|
106 dllDrive != KZdrive() ) |
|
107 { |
|
108 // try to load resource from ROM ( partial upgrade case ) |
|
109 resourceFile.Copy( KZdrive ); |
|
110 resourceFile.Append( KRelativeResourcePathWithWildcard ); |
|
111 BaflUtils::NearestLanguageFile( fs, resourceFile ); |
|
112 if ( !BaflUtils::FileExists( fs, resourceFile ) ) |
|
113 { |
|
114 resourceFile.Copy( KZdrive ); |
|
115 resourceFile.Append( KRelativeResourcePath ); |
|
116 BaflUtils::NearestLanguageFile( fs, resourceFile ); |
|
117 } |
|
118 } |
|
119 } |
|
120 iResourceFileOffset = iEnv.AddResourceFileL( resourceFile ); |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------- |
|
124 // CWmResourceLoader::UnloadResources |
|
125 // --------------------------------------------------------- |
|
126 // |
|
127 void CWmResourceLoader::UnloadResources() |
|
128 { |
|
129 if ( iResourceFileOffset ) |
|
130 { |
|
131 iEnv.DeleteResourceFile( iResourceFileOffset ); |
|
132 } |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------- |
|
136 // CWmResourceLoader::DetermineIconFilePath |
|
137 // --------------------------------------------------------- |
|
138 // |
|
139 void CWmResourceLoader::DetermineIconFilePath() |
|
140 { |
|
141 RFs& fs = iEnv.FsSession(); |
|
142 iMifFile.Copy( iDllName.Left(2) ); |
|
143 iMifFile.Append( KRelativeMifPath ); |
|
144 if ( !BaflUtils::FileExists( fs, iMifFile ) ) |
|
145 { |
|
146 // Load from ROM ( partial upgrade case ) |
|
147 iMifFile.Copy( KZdrive ); |
|
148 iMifFile.Append( KRelativeMifPath ); |
|
149 } |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------- |
|
153 // CWmResourceLoader::IconFilePath |
|
154 // --------------------------------------------------------- |
|
155 // |
|
156 const TDesC& CWmResourceLoader::IconFilePath() |
|
157 { |
|
158 return iMifFile; |
|
159 } |
|
160 |
|
161 // --------------------------------------------------------- |
|
162 // CWmResourceLoader::LoadButtonL |
|
163 // --------------------------------------------------------- |
|
164 void CWmResourceLoader::LoadButtonL( |
|
165 CAknButton& aResource, |
|
166 TInt aResourceId ) |
|
167 { |
|
168 TResourceReader reader; |
|
169 iEnv.CreateResourceReaderLC( reader, aResourceId ); |
|
170 aResource.ConstructFromResourceL( reader ); |
|
171 CleanupStack::PopAndDestroy(); // reader |
|
172 } |
|
173 |
|
174 // --------------------------------------------------------- |
|
175 // LoadStringLC |
|
176 // loads a string from resource. If an additional string is |
|
177 // given (the length is greater than zero) uses a different |
|
178 // StringLoader method to load. |
|
179 // --------------------------------------------------------- |
|
180 // |
|
181 HBufC* LoadStringLC( TInt aResourceId, const TDesC& aString, CEikonEnv* aEnv ) |
|
182 { |
|
183 if ( aString.Length() > 0 ) |
|
184 return StringLoader::LoadLC( aResourceId, aString, aEnv ); |
|
185 else |
|
186 return StringLoader::LoadLC( aResourceId, aEnv ); |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------- |
|
190 // CWmResourceLoader::InfoPopupL |
|
191 // --------------------------------------------------------- |
|
192 // |
|
193 void CWmResourceLoader::InfoPopupL( TInt aResourceId, const TDesC& aString ) |
|
194 { |
|
195 HBufC* infoMsg = LoadStringLC( aResourceId, aString, &iEnv ); |
|
196 iNote = new (ELeave) CAknInformationNote( &iNote ); |
|
197 iNote->SetTimeout( CAknNoteDialog::ELongTimeout ); |
|
198 iNote->ExecuteLD( *infoMsg ); |
|
199 CleanupStack::PopAndDestroy( infoMsg ); |
|
200 } |
|
201 |
|
202 // --------------------------------------------------------- |
|
203 // CWmResourceLoader::ErrorPopup |
|
204 // --------------------------------------------------------- |
|
205 // |
|
206 void CWmResourceLoader::ErrorPopup( TInt aErrorCode ) |
|
207 { |
|
208 iEnv.HandleError( aErrorCode ); |
|
209 } |
|
210 |
|
211 // --------------------------------------------------------- |
|
212 // CWmResourceLoader::NoDescriptionText |
|
213 // --------------------------------------------------------- |
|
214 // |
|
215 const TDesC& CWmResourceLoader::NoDescriptionText() |
|
216 { |
|
217 return *iDescription; |
|
218 } |
|
219 |
|
220 // end of file |
|
221 |