|
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: Main settings view class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 //debug |
|
20 #include "calendarui_debug.h" |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "calengsplugin.h" |
|
24 |
|
25 #include "calengsplugincontainer.h" |
|
26 #include "CalenUid.h" |
|
27 #include "calendar.hrh" |
|
28 #include <Calendar.rsg> |
|
29 #include <calendarsettings.mbg> |
|
30 |
|
31 #include <featmgr.h> |
|
32 #include <StringLoader.h> // for StringLoader |
|
33 #include <hlplch.h> // for HlpLauncher |
|
34 #include <bautils.h> // for BaflUtils |
|
35 #include <pathinfo.h> |
|
36 |
|
37 _LIT( KCalenIconDirAndFile,"calendarsettings.mif" ); |
|
38 _LIT( KCalenAppResourceFile, "calendar.rsc" ); |
|
39 _LIT( KResourceFile, "calencommonui.rsc" ); |
|
40 |
|
41 // ========================= MEMBER FUNCTIONS ================================= |
|
42 |
|
43 // ---------------------------------------------------------------------------- |
|
44 // CCalenGSPlugin::CCalenGSPlugin |
|
45 // C++ constructor. |
|
46 // ---------------------------------------------------------------------------- |
|
47 // |
|
48 CCalenGSPlugin::CCalenGSPlugin() |
|
49 : iResourceLoader( *iCoeEnv ) |
|
50 { |
|
51 TRACE_ENTRY_POINT; |
|
52 TRACE_EXIT_POINT; |
|
53 } |
|
54 |
|
55 // ---------------------------------------------------------------------------- |
|
56 // CCalenGSPlugin::NewL |
|
57 // Two-phased constructor. |
|
58 // ---------------------------------------------------------------------------- |
|
59 // |
|
60 CCalenGSPlugin* CCalenGSPlugin::NewL( TAny* /*aInitParams*/ ) |
|
61 { |
|
62 TRACE_ENTRY_POINT; |
|
63 |
|
64 CCalenGSPlugin* self = new(ELeave) CCalenGSPlugin(); |
|
65 CleanupStack::PushL(self); |
|
66 self->ConstructL(); |
|
67 CleanupStack::Pop(self); |
|
68 |
|
69 TRACE_EXIT_POINT; |
|
70 return self; |
|
71 } |
|
72 |
|
73 // ---------------------------------------------------------------------------- |
|
74 // CCalenGSPlugin::ConstructL |
|
75 // Second phase of construction. |
|
76 // ---------------------------------------------------------------------------- |
|
77 // |
|
78 void CCalenGSPlugin::ConstructL() |
|
79 { |
|
80 TRACE_ENTRY_POINT; |
|
81 // Find the resource file |
|
82 TFileName fileName; |
|
83 // Get the complate path of the DLL from where it is currently loaded |
|
84 Dll::FileName( fileName ); |
|
85 |
|
86 TFileName resourcePath; |
|
87 resourcePath.Append(fileName.Mid(0,2)); |
|
88 resourcePath.Append(KDC_APP_RESOURCE_DIR); |
|
89 // Find the resource file |
|
90 TParse parse; |
|
91 parse.Set( KCalenAppResourceFile, |
|
92 &resourcePath, |
|
93 NULL ); |
|
94 TFileName resourceFileName( parse.FullName() ); |
|
95 |
|
96 // Get language of resource file |
|
97 BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), resourceFileName ); |
|
98 |
|
99 // Add the the commonUI resource file to the environment |
|
100 TFileName resFile; |
|
101 resFile.Append(fileName.Mid(0,2)); |
|
102 resFile.Append( KDC_RESOURCE_FILES_DIR ); |
|
103 resFile.Append( KResourceFile ); |
|
104 |
|
105 CEikonEnv* eikonEnv = CEikonEnv::Static(); |
|
106 BaflUtils::NearestLanguageFile( eikonEnv->FsSession(), resFile ); |
|
107 iResourceFileOffset = eikonEnv->AddResourceFileL( resFile ); |
|
108 |
|
109 // Open the resource file |
|
110 iResourceLoader.OpenL( resourceFileName ); |
|
111 FeatureManager::InitializeLibL(); |
|
112 |
|
113 BaseConstructL( R_CALENDAR_GS_SETTING_LIST_VIEW ); |
|
114 |
|
115 iCaption = StringLoader::LoadL( R_CALENDAR_GS_VIEW_TITLE ); |
|
116 TRACE_EXIT_POINT; |
|
117 } |
|
118 |
|
119 |
|
120 // ---------------------------------------------------------------------------- |
|
121 // CCalenGSPlugin::~CCalenGSPlugin |
|
122 // Destructor. |
|
123 // ---------------------------------------------------------------------------- |
|
124 // |
|
125 CCalenGSPlugin::~CCalenGSPlugin() |
|
126 { |
|
127 TRACE_ENTRY_POINT; |
|
128 FeatureManager::UnInitializeLib(); |
|
129 |
|
130 if( iContainer ) |
|
131 { |
|
132 if( iAppUi ) |
|
133 { |
|
134 iAppUi->RemoveFromViewStack( *this, iContainer ); |
|
135 } |
|
136 delete iContainer; |
|
137 } |
|
138 |
|
139 if( iResourceFileOffset ) |
|
140 { |
|
141 CCoeEnv::Static()->DeleteResourceFile( iResourceFileOffset ); |
|
142 } |
|
143 |
|
144 iResourceLoader.Close(); |
|
145 |
|
146 delete iCaption; |
|
147 |
|
148 TRACE_EXIT_POINT; |
|
149 } |
|
150 |
|
151 // ---------------------------------------------------------------------------- |
|
152 // CCalenGSPlugin::Id |
|
153 // Returns the UID of this view. |
|
154 // ---------------------------------------------------------------------------- |
|
155 // |
|
156 TUid CCalenGSPlugin::Id() const |
|
157 { |
|
158 TRACE_ENTRY_POINT; |
|
159 TRACE_EXIT_POINT; |
|
160 return KUidCalenGSPlugin; |
|
161 } |
|
162 |
|
163 // ---------------------------------------------------------------------------- |
|
164 // CCalenGSPlugin::HandleCommandL |
|
165 // Handles commands. |
|
166 // ---------------------------------------------------------------------------- |
|
167 // |
|
168 void CCalenGSPlugin::HandleCommandL( TInt aCommand ) |
|
169 { |
|
170 TRACE_ENTRY_POINT; |
|
171 switch ( aCommand ) |
|
172 { |
|
173 case ECalenCmdChange: /* fall through... */ |
|
174 case EAknSoftkeyChange: /* fall through... */ |
|
175 case EAknCmdOpen: |
|
176 // Delegate to container |
|
177 Container()->HandleListBoxSelectionL( EAknCmdOpen ); |
|
178 break; |
|
179 |
|
180 case EAknSoftkeyBack: |
|
181 // Activate previous view |
|
182 #ifdef _DEBUG |
|
183 RDebug::Print(_L("CalenGS: activating view 0x%x"), iPrevViewId.iViewUid.iUid); |
|
184 #endif |
|
185 iAppUi->ActivateLocalViewL( iPrevViewId.iViewUid ); |
|
186 break; |
|
187 |
|
188 case EAknCmdHelp: |
|
189 if( FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
190 { |
|
191 HlpLauncher::LaunchHelpApplicationL( |
|
192 iEikonEnv->WsSession(), iAppUi->AppHelpContextL() ); |
|
193 } |
|
194 break; |
|
195 |
|
196 default: |
|
197 iAppUi->HandleCommandL( aCommand ); |
|
198 break; |
|
199 } |
|
200 TRACE_EXIT_POINT; |
|
201 } |
|
202 |
|
203 // ---------------------------------------------------------------------------- |
|
204 // CCalenGSPlugin::HandleClientRectChange |
|
205 // Handles screen size change. |
|
206 // ---------------------------------------------------------------------------- |
|
207 // |
|
208 void CCalenGSPlugin::HandleClientRectChange() |
|
209 { |
|
210 TRACE_ENTRY_POINT; |
|
211 |
|
212 if ( iContainer ) |
|
213 { |
|
214 Container()->SetRect( ClientRect() ); |
|
215 } |
|
216 |
|
217 TRACE_EXIT_POINT; |
|
218 } |
|
219 |
|
220 // ---------------------------------------------------------------------------- |
|
221 // CCalenGSPlugin::Container |
|
222 // Returns a handle to the container class. |
|
223 // ---------------------------------------------------------------------------- |
|
224 // |
|
225 CCalenGSPluginContainer* CCalenGSPlugin::Container() |
|
226 { |
|
227 TRACE_ENTRY_POINT; |
|
228 TRACE_EXIT_POINT; |
|
229 return static_cast<CCalenGSPluginContainer*>( iContainer ); |
|
230 } |
|
231 |
|
232 // ---------------------------------------------------------------------------- |
|
233 // CCalenGSPlugin::HandleListBoxSelectionL |
|
234 // Handles any user actions while in the list view. |
|
235 // ---------------------------------------------------------------------------- |
|
236 // |
|
237 void CCalenGSPlugin::HandleListBoxSelectionL() |
|
238 { |
|
239 TRACE_ENTRY_POINT; |
|
240 |
|
241 // Delegate to container |
|
242 Container()->HandleListBoxSelectionL( ECalenCmdChange ); |
|
243 |
|
244 TRACE_EXIT_POINT; |
|
245 } |
|
246 |
|
247 // ---------------------------------------------------------------------------- |
|
248 // CCalenGSPlugin::GetCaptionL |
|
249 // Populates aCaption with the caption text to be displayed in the navi pane. |
|
250 // ---------------------------------------------------------------------------- |
|
251 // |
|
252 void CCalenGSPlugin::GetCaptionL( TDes& aCaption ) const |
|
253 { |
|
254 TRACE_ENTRY_POINT; |
|
255 |
|
256 aCaption.Copy( *iCaption ); |
|
257 |
|
258 TRACE_EXIT_POINT; |
|
259 } |
|
260 |
|
261 // ---------------------------------------------------------------------------- |
|
262 // CCalenGSPlugin::NewContainerL |
|
263 // Creates new iContainer. |
|
264 // ---------------------------------------------------------------------------- |
|
265 // |
|
266 void CCalenGSPlugin::NewContainerL() |
|
267 { |
|
268 TRACE_ENTRY_POINT; |
|
269 |
|
270 iContainer = new( ELeave ) CCalenGSPluginContainer; |
|
271 |
|
272 TRACE_EXIT_POINT; |
|
273 } |
|
274 |
|
275 // ---------------------------------------------------------------------------- |
|
276 // CCalenGSPlugin::CreateIconL |
|
277 // Returns a new icon. |
|
278 // ---------------------------------------------------------------------------- |
|
279 // |
|
280 CGulIcon* CCalenGSPlugin::CreateIconL( const TUid /*aIconType*/ ) |
|
281 { |
|
282 TRACE_ENTRY_POINT; |
|
283 TParse* fp = new( ELeave ) TParse(); |
|
284 CleanupStack::PushL( fp ); |
|
285 |
|
286 TFileName dllName; |
|
287 // Get the complate path of the DLL from where it is currently loaded |
|
288 Dll::FileName( dllName ); |
|
289 |
|
290 TFileName resourcePath; |
|
291 resourcePath.Append(dllName.Mid(0,2)); |
|
292 resourcePath.Append(KDC_APP_BITMAP_DIR); |
|
293 User::LeaveIfError( fp->Set( KCalenIconDirAndFile, &resourcePath, NULL ) ); |
|
294 |
|
295 TBuf< KMaxFileName > fileName = fp->FullName(); |
|
296 CleanupStack::PopAndDestroy( fp ); |
|
297 |
|
298 CGulIcon* icon = AknsUtils::CreateGulIconL( AknsUtils::SkinInstance(), |
|
299 KAknsIIDQgnPropSetAppsCale, |
|
300 fileName, |
|
301 EMbmCalendarsettingsQgn_prop_set_apps_cale, |
|
302 EMbmCalendarsettingsQgn_prop_set_apps_cale ); |
|
303 TRACE_EXIT_POINT; |
|
304 return icon; |
|
305 } |
|
306 |
|
307 // End of file |