|
1 /* |
|
2 * Copyright (c) 2004 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: Provides methods for Utils class. |
|
15 1.Stores and restores the Navi pane. |
|
16 * 2.Reads resource files. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "CAttendeeUiUtils.h" |
|
24 #include "AttendeeViewConsts.h" |
|
25 #include <bautils.h> |
|
26 #include <stringloader.h> |
|
27 #include <AknAppUi.h> |
|
28 #include <akntitle.h> |
|
29 #include <data_caging_path_literals.hrh> |
|
30 |
|
31 // ============================ MEMBER FUNCTIONS =============================== |
|
32 // ---------------------------------------------------------------------------- |
|
33 // CAttendeeUiUtils::NewL |
|
34 // ---------------------------------------------------------------------------- |
|
35 // |
|
36 CAttendeeUiUtils* CAttendeeUiUtils::NewL() |
|
37 { |
|
38 CAttendeeUiUtils* self = new(ELeave)CAttendeeUiUtils; |
|
39 CleanupStack::PushL( self ); |
|
40 self->ConstructL(); |
|
41 CleanupStack::Pop(self); //self |
|
42 return self; |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CAttendeeUiUtils::CAttendeeUiUtils |
|
47 // C++ default constructor can NOT contain any code, that |
|
48 // might leave. |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 CAttendeeUiUtils::CAttendeeUiUtils() : iPbkResourceFile( *CEikonEnv::Static() ) |
|
52 { |
|
53 } |
|
54 |
|
55 // ---------------------------------------------------------------------------- |
|
56 // CAttendeeUiUtils::ConstructL |
|
57 // ---------------------------------------------------------------------------- |
|
58 // |
|
59 void CAttendeeUiUtils::ConstructL() |
|
60 { |
|
61 iEnv = CEikonEnv::Static(); |
|
62 iNaviPane = static_cast<CAknNavigationControlContainer*>( |
|
63 StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) ); |
|
64 |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CAttendeeUiUtils::~CAttendeeUiUtils() |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 CAttendeeUiUtils::~CAttendeeUiUtils() |
|
72 { |
|
73 if ( iNaviPane && iNaviLabel ) |
|
74 { |
|
75 iNaviPane->Pop( iNaviLabel ); |
|
76 } |
|
77 delete iNaviLabel; |
|
78 delete iStoredTitlePaneText; |
|
79 |
|
80 //If RestoreOldNaviPaneL is not called, it |
|
81 //must do atleast now |
|
82 TRAPD( error, RestoreOldNaviPaneL() ); |
|
83 if ( error != KErrNone ) |
|
84 { |
|
85 CEikonEnv::Static()->HandleError( error ); |
|
86 } |
|
87 |
|
88 delete iStoredDecorator; |
|
89 } |
|
90 |
|
91 // ---------------------------------------------------- |
|
92 // CAttendeeUiUtils::CreateNaviLabelL |
|
93 // ---------------------------------------------------- |
|
94 // |
|
95 void CAttendeeUiUtils::CreateNaviLabelL( const TDesC& aLabel ) |
|
96 { |
|
97 if ( iNaviLabel ) |
|
98 { |
|
99 iNaviPane->Pop( iNaviLabel ); |
|
100 delete iNaviLabel; |
|
101 iNaviLabel = NULL; |
|
102 } |
|
103 |
|
104 iNaviLabel = iNaviPane->CreateNavigationLabelL( aLabel ); |
|
105 iNaviPane->PushL( *iNaviLabel ); // activate navi label in navi pane |
|
106 } |
|
107 |
|
108 // ---------------------------------------------------- |
|
109 // CAttendeeUiUtils::CreateNaviLabelL |
|
110 // ---------------------------------------------------- |
|
111 // |
|
112 void CAttendeeUiUtils::CreateNaviLabelL( const TInt aResourceId ) |
|
113 { |
|
114 CEikonEnv* env = CEikonEnv::Static(); |
|
115 HBufC* label = StringLoader::LoadLC( aResourceId, env); |
|
116 CreateNaviLabelL( *label ); |
|
117 CleanupStack::PopAndDestroy(label); //label |
|
118 } |
|
119 |
|
120 // ---------------------------------------------------- |
|
121 // CAttendeeUiUtils::StoreNaviPane |
|
122 // ---------------------------------------------------- |
|
123 // |
|
124 void CAttendeeUiUtils::StoreNaviPane() |
|
125 { |
|
126 if ( iNaviPane ) |
|
127 { |
|
128 iStoredDecorator = iNaviPane->Top(); |
|
129 } |
|
130 } |
|
131 |
|
132 // ---------------------------------------------------- |
|
133 // CAttendeeUiUtils::RestoreOldNaviPaneL |
|
134 // ---------------------------------------------------- |
|
135 // |
|
136 void CAttendeeUiUtils::RestoreOldNaviPaneL() |
|
137 { |
|
138 if ( iStoredDecorator ) |
|
139 { |
|
140 iNaviPane->PushL( *iStoredDecorator ); |
|
141 iStoredDecorator = NULL; |
|
142 } |
|
143 } |
|
144 |
|
145 // ---------------------------------------------------------------------------- |
|
146 // CAttendeeUiUtils::OpenResourceFilesL |
|
147 // ---------------------------------------------------------------------------- |
|
148 // |
|
149 void CAttendeeUiUtils::OpenResourceFilesL() |
|
150 { |
|
151 FindResourceFileL(); |
|
152 |
|
153 BaflUtils::NearestLanguageFile( iEnv->FsSession(), iResourceFileName ); |
|
154 iResourceOffset = iEnv->AddResourceFileL( iResourceFileName ); |
|
155 |
|
156 //Open phonebooks resource file |
|
157 iPbkResourceFile.OpenL(); |
|
158 } |
|
159 |
|
160 // ---------------------------------------------------------------------------- |
|
161 // CAttendeeUiUtils::CloseResourceFile |
|
162 // ---------------------------------------------------------------------------- |
|
163 // |
|
164 void CAttendeeUiUtils::CloseResourceFile() |
|
165 { |
|
166 iEnv->DeleteResourceFile( iResourceOffset ); |
|
167 |
|
168 //Phonebooks resource file |
|
169 iPbkResourceFile.Close(); |
|
170 } |
|
171 |
|
172 // ---------------------------------------------------------------------------- |
|
173 // CAttendeeUiUtils::StoreTitlePaneL |
|
174 // ---------------------------------------------------------------------------- |
|
175 // |
|
176 void CAttendeeUiUtils::StoreTitlePaneL() |
|
177 { |
|
178 CEikStatusPane* statusPane = StatusPane(); |
|
179 if ( statusPane && statusPane->PaneCapabilities( |
|
180 TUid::Uid(EEikStatusPaneUidTitle) ).IsPresent() ) |
|
181 { |
|
182 iTitlePane = static_cast<CAknTitlePane*>( statusPane-> |
|
183 ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
184 |
|
185 if ( iTitlePane->Text() ) |
|
186 { |
|
187 iStoredTitlePaneText = iTitlePane->Text()->AllocL(); |
|
188 } |
|
189 } |
|
190 } |
|
191 |
|
192 // ---------------------------------------------------------------------------- |
|
193 // CAttendeeUiUtils::ChangeTitlePaneL |
|
194 // ---------------------------------------------------------------------------- |
|
195 // |
|
196 void CAttendeeUiUtils::ChangeTitlePaneL( TInt aResourceText ) |
|
197 { |
|
198 if ( aResourceText != 0 ) |
|
199 { |
|
200 HBufC* buf = StringLoader::LoadLC( aResourceText ); |
|
201 ChangeTitlePaneL( buf ); |
|
202 CleanupStack::Pop(buf); // buf, ownership transferred |
|
203 } |
|
204 } |
|
205 |
|
206 // ---------------------------------------------------------------------------- |
|
207 // CAttendeeUiUtils::ChangeTitlePaneL |
|
208 // ---------------------------------------------------------------------------- |
|
209 // |
|
210 void CAttendeeUiUtils::ChangeTitlePaneL( HBufC* aTitle ) |
|
211 { |
|
212 CEikStatusPane* statusPane = StatusPane(); |
|
213 if ( statusPane && statusPane->PaneCapabilities( |
|
214 TUid::Uid( EEikStatusPaneUidTitle ) ).IsPresent() ) |
|
215 { |
|
216 CAknTitlePane* titlePane = static_cast<CAknTitlePane*>( statusPane-> |
|
217 ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
218 titlePane->SetText( aTitle ); // Takes ownership of aTitle |
|
219 } |
|
220 } |
|
221 |
|
222 // ---------------------------------------------------------------------------- |
|
223 // CAttendeeUiUtils::RestoreOldTitlePane |
|
224 // ---------------------------------------------------------------------------- |
|
225 // |
|
226 void CAttendeeUiUtils::RestoreOldTitlePane() |
|
227 { |
|
228 if ( iTitlePane && iStoredTitlePaneText ) |
|
229 { |
|
230 // iTitlePane takes ownership of iStoredTitlePaneText |
|
231 iTitlePane->SetText( iStoredTitlePaneText ); |
|
232 iStoredTitlePaneText = NULL; |
|
233 } |
|
234 } |
|
235 |
|
236 // ---------------------------------------------------- |
|
237 // CAttendeeUiUtils::AttendeeViewIconFileL |
|
238 // ---------------------------------------------------- |
|
239 // |
|
240 TFileName CAttendeeUiUtils::AttendeeViewIconFileL() |
|
241 { |
|
242 TFileName file( KDC_APP_BITMAP_DIR ); |
|
243 file.Append( KAttendeeViewIconFileName ); //always safe |
|
244 GetFileWithCorrectDriveL( file ); |
|
245 return file; |
|
246 } |
|
247 |
|
248 // ---------------------------------------------------------------------------- |
|
249 // CAttendeeUiUtils::FindResourceFileL |
|
250 // ---------------------------------------------------------------------------- |
|
251 // |
|
252 void CAttendeeUiUtils::FindResourceFileL() |
|
253 { |
|
254 // Path and file name: |
|
255 TFileName* file = new(ELeave)TFileName; |
|
256 CleanupStack::PushL( file ); |
|
257 file->Append( KDC_RESOURCE_FILES_DIR ); // always safe |
|
258 file->Append( KAttendeeViewRscFileName ); // always safe |
|
259 |
|
260 // Drive: |
|
261 TFileName* drive = new(ELeave)TFileName; |
|
262 CleanupStack::PushL( drive ); |
|
263 Dll::FileName( *drive ); |
|
264 |
|
265 // Add drive to path & file name: |
|
266 TParse* parse = new(ELeave)TParse; |
|
267 CleanupStack::PushL( parse ); |
|
268 User::LeaveIfError( parse->Set( *file, drive, NULL ) ); |
|
269 iResourceFileName = parse->FullName(); |
|
270 |
|
271 CleanupStack::PopAndDestroy( 3 ); // parse, drive, file |
|
272 } |
|
273 |
|
274 // ---------------------------------------------------------------------------- |
|
275 // CAttendeeUiUtils::StatusPane |
|
276 // ---------------------------------------------------------------------------- |
|
277 // |
|
278 CEikStatusPane* CAttendeeUiUtils::StatusPane() |
|
279 { |
|
280 return CEikonEnv::Static()->AppUiFactory()->StatusPane(); |
|
281 } |
|
282 |
|
283 // ---------------------------------------------------------------------------- |
|
284 // CAttendeeUiUtils::GetFileWithCorrectDriveL |
|
285 // ---------------------------------------------------------------------------- |
|
286 // |
|
287 void CAttendeeUiUtils::GetFileWithCorrectDriveL( TFileName& aFileName ) |
|
288 { |
|
289 TFileName* dllDrive = new(ELeave)TFileName; |
|
290 CleanupStack::PushL( dllDrive ); |
|
291 TParse* parse = new(ELeave)TParse; |
|
292 CleanupStack::PushL( parse ); |
|
293 |
|
294 Dll::FileName( *dllDrive ); |
|
295 User::LeaveIfError( parse->Set( *dllDrive, NULL, NULL ) ); |
|
296 *dllDrive = parse->Drive(); // contains drive, e.g. "c:" |
|
297 User::LeaveIfError( parse->Set( *dllDrive, &aFileName, NULL ) ); |
|
298 aFileName = parse->FullName(); |
|
299 |
|
300 CleanupStack::PopAndDestroy( 2 ); // parse, dlldrive |
|
301 } |
|
302 |
|
303 // End of File |