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( KRelativeMifPath, "\\resource\\apps\\widgetmanager.mif" ); |
|
35 _LIT( KRelativeResourcePathWithWildcard, "\\resource\\widgetmanagerview.r*" ); |
|
36 _LIT( KRelativeResourcePath, "\\resource\\widgetmanagerview.rsc" ); |
|
37 |
|
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 resourceFile.Copy( iDllName.Left(2) ); |
|
97 resourceFile.Append( KRelativeResourcePathWithWildcard ); |
|
98 BaflUtils::NearestLanguageFile( fs, resourceFile ); |
|
99 if ( !BaflUtils::FileExists( fs, resourceFile ) ) |
|
100 { |
|
101 resourceFile.Copy( iDllName.Left(2) ); |
|
102 resourceFile.Append( KRelativeResourcePath ); |
|
103 BaflUtils::NearestLanguageFile( fs, resourceFile ); |
|
104 } |
|
105 iResourceFileOffset = iEnv.AddResourceFileL( resourceFile ); |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------- |
|
109 // CWmResourceLoader::UnloadResources |
|
110 // --------------------------------------------------------- |
|
111 // |
|
112 void CWmResourceLoader::UnloadResources() |
|
113 { |
|
114 if ( iResourceFileOffset ) |
|
115 { |
|
116 iEnv.DeleteResourceFile( iResourceFileOffset ); |
|
117 } |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------- |
|
121 // CWmResourceLoader::DetermineIconFilePath |
|
122 // --------------------------------------------------------- |
|
123 // |
|
124 void CWmResourceLoader::DetermineIconFilePath() |
|
125 { |
|
126 iMifFile.Copy( iDllName.Left(2) ); |
|
127 iMifFile.Append( KRelativeMifPath ); |
|
128 } |
|
129 |
|
130 // --------------------------------------------------------- |
|
131 // CWmResourceLoader::IconFilePath |
|
132 // --------------------------------------------------------- |
|
133 // |
|
134 const TDesC& CWmResourceLoader::IconFilePath() |
|
135 { |
|
136 return iMifFile; |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------- |
|
140 // CWmResourceLoader::LoadButtonL |
|
141 // --------------------------------------------------------- |
|
142 void CWmResourceLoader::LoadButtonL( |
|
143 CAknButton& aResource, |
|
144 TInt aResourceId ) |
|
145 { |
|
146 TResourceReader reader; |
|
147 iEnv.CreateResourceReaderLC( reader, aResourceId ); |
|
148 aResource.ConstructFromResourceL( reader ); |
|
149 CleanupStack::PopAndDestroy(); // reader |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------- |
|
153 // LoadStringLC |
|
154 // loads a string from resource. If an additional string is |
|
155 // given (the length is greater than zero) uses a different |
|
156 // StringLoader method to load. |
|
157 // --------------------------------------------------------- |
|
158 // |
|
159 HBufC* LoadStringLC( TInt aResourceId, const TDesC& aString, CEikonEnv* aEnv ) |
|
160 { |
|
161 if ( aString.Length() > 0 ) |
|
162 return StringLoader::LoadLC( aResourceId, aString, aEnv ); |
|
163 else |
|
164 return StringLoader::LoadLC( aResourceId, aEnv ); |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------- |
|
168 // CWmResourceLoader::InfoPopupL |
|
169 // --------------------------------------------------------- |
|
170 // |
|
171 void CWmResourceLoader::InfoPopupL( TInt aResourceId, const TDesC& aString ) |
|
172 { |
|
173 HBufC* infoMsg = LoadStringLC( aResourceId, aString, &iEnv ); |
|
174 iNote = new (ELeave) CAknInformationNote( &iNote ); |
|
175 iNote->SetTimeout( CAknNoteDialog::ELongTimeout ); |
|
176 iNote->ExecuteLD( *infoMsg ); |
|
177 CleanupStack::PopAndDestroy( infoMsg ); |
|
178 } |
|
179 |
|
180 // --------------------------------------------------------- |
|
181 // CWmResourceLoader::ErrorPopup |
|
182 // --------------------------------------------------------- |
|
183 // |
|
184 void CWmResourceLoader::ErrorPopup( TInt aErrorCode ) |
|
185 { |
|
186 iEnv.HandleError( aErrorCode ); |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------- |
|
190 // CWmResourceLoader::NoDescriptionText |
|
191 // --------------------------------------------------------- |
|
192 // |
|
193 const TDesC& CWmResourceLoader::NoDescriptionText() |
|
194 { |
|
195 return *iDescription; |
|
196 } |
|
197 |
|
198 // end of file |
|
199 |
|