64 // NcsUtility::CompleteRelativePathL() |
64 // NcsUtility::CompleteRelativePathL() |
65 // ----------------------------------------------------------------------------- |
65 // ----------------------------------------------------------------------------- |
66 // |
66 // |
67 void NcsUtility::CompleteRelativePathL( |
67 void NcsUtility::CompleteRelativePathL( |
68 const TDesC& aRelativePath, TPtr& aAbsolutePath ) |
68 const TDesC& aRelativePath, TPtr& aAbsolutePath ) |
69 { |
69 { |
70 FUNC_LOG; |
70 FUNC_LOG; |
71 |
71 |
72 // + 2 is for drive letter and ":" |
72 // + 2 is for drive letter and ":" |
73 if( aAbsolutePath.MaxLength() < aRelativePath.Length() + 2 ) |
73 if( aAbsolutePath.MaxLength() < aRelativePath.Length() + 2 ) |
74 { |
74 { |
75 User::Leave( KErrArgument ); |
75 User::Leave( KErrArgument ); |
76 } |
76 } |
77 |
77 |
78 TFileName path; |
78 TFileName path; |
79 path.Copy( aRelativePath ); |
79 path.Copy( aRelativePath ); |
80 TInt err = CompleteWithAppPath( path ); |
80 TInt err = CompleteWithAppPath( path ); |
81 User::LeaveIfError( err ); |
81 User::LeaveIfError( err ); |
82 |
82 |
83 aAbsolutePath.Copy( path ); |
83 aAbsolutePath.Copy( path ); |
84 |
84 |
85 } |
85 } |
86 |
86 |
87 // ----------------------------------------------------------------------------- |
87 // ----------------------------------------------------------------------------- |
88 // NcsUtility::GenerateFromLineToMessageBodyL() |
88 // NcsUtility::GenerateFromLineToMessageBodyL() |
89 // |
89 // |
90 // ----------------------------------------------------------------------------- |
90 // ----------------------------------------------------------------------------- |
91 // |
91 // |
92 HBufC* NcsUtility::GenerateFromLineToMessageBodyL( |
92 HBufC* NcsUtility::GenerateFromLineToMessageBodyL( |
93 const RPointerArray<CNcsEmailAddressObject>& aFromArray ) |
93 const RPointerArray<CNcsEmailAddressObject>& aFromArray ) |
94 { |
94 { |
95 FUNC_LOG; |
95 FUNC_LOG; |
96 |
96 |
97 HBufC* buf = DoGenerateAddressLineToMessageBodyL( |
97 HBufC* buf = DoGenerateAddressLineToMessageBodyL( |
98 R_NCS_ENGINE_EMAIL_FROM, aFromArray ); |
98 R_NCS_ENGINE_EMAIL_FROM, aFromArray ); |
99 |
99 |
100 return buf; |
100 return buf; |
101 } |
101 } |
102 |
102 |
103 // ----------------------------------------------------------------------------- |
103 // ----------------------------------------------------------------------------- |
104 // NcsUtility::GenerateSentLineToMessageBodyL() |
104 // NcsUtility::GenerateSentLineToMessageBodyL() |
105 // |
105 // |
106 // ----------------------------------------------------------------------------- |
106 // ----------------------------------------------------------------------------- |
107 // |
107 // |
108 HBufC* NcsUtility::GenerateSentLineToMessageBodyL( CFSMailMessage& aMessage ) |
108 HBufC* NcsUtility::GenerateSentLineToMessageBodyL( CFSMailMessage& aMessage ) |
109 { |
109 { |
110 FUNC_LOG; |
110 FUNC_LOG; |
111 |
111 |
112 HBufC* dateText = TFsEmailUiUtility::DateTextFromMsgLC( &aMessage ); |
112 HBufC* dateText = TFsEmailUiUtility::DateTextFromMsgLC( &aMessage ); |
113 HBufC* timeText = TFsEmailUiUtility::TimeTextFromMsgLC( &aMessage ); |
113 HBufC* timeText = TFsEmailUiUtility::TimeTextFromMsgLC( &aMessage ); |
114 HBufC* sent = StringLoader::LoadLC( R_NCS_ENGINE_EMAIL_SENT ); |
114 HBufC* sent = StringLoader::LoadLC( R_NCS_ENGINE_EMAIL_SENT ); |
115 |
115 |
116 HBufC* buf = HBufC::NewL( sent->Length() + |
116 HBufC* buf = HBufC::NewL( sent->Length() + |
117 KSpace().Length() + |
117 KSpace().Length() + |
118 dateText->Length() + |
118 dateText->Length() + |
119 KSentLineDateAndTimeSeparatorText().Length() + |
119 KSentLineDateAndTimeSeparatorText().Length() + |
120 timeText->Length() ); |
120 timeText->Length() ); |
121 TPtr ptr = buf->Des(); |
121 TPtr ptr = buf->Des(); |
122 ptr.Append( *sent ); |
122 ptr.Append( *sent ); |
123 ptr.Append( KSpace ); |
123 ptr.Append( KSpace ); |
124 ptr.Append( *dateText ); |
124 ptr.Append( *dateText ); |
125 ptr.Append( KSentLineDateAndTimeSeparatorText ); |
125 ptr.Append( KSentLineDateAndTimeSeparatorText ); |
126 ptr.Append( *timeText ); |
126 ptr.Append( *timeText ); |
127 |
127 |
128 CleanupStack::PopAndDestroy( sent ); |
128 CleanupStack::PopAndDestroy( sent ); |
129 CleanupStack::PopAndDestroy( timeText ); |
129 CleanupStack::PopAndDestroy( timeText ); |
130 CleanupStack::PopAndDestroy( dateText ); |
130 CleanupStack::PopAndDestroy( dateText ); |
131 |
131 |
132 return buf; |
132 return buf; |
133 } |
133 } |
134 |
134 |
135 // ----------------------------------------------------------------------------- |
135 // ----------------------------------------------------------------------------- |
136 // NcsUtility::GenerateAddressLineToMessageBodyL() |
136 // NcsUtility::GenerateAddressLineToMessageBodyL() |
137 // |
137 // |
138 // ----------------------------------------------------------------------------- |
138 // ----------------------------------------------------------------------------- |
139 // |
139 // |
140 HBufC* NcsUtility::GenerateAddressLineToMessageBodyL( |
140 HBufC* NcsUtility::GenerateAddressLineToMessageBodyL( |
141 RPointerArray<CNcsEmailAddressObject>& aToArray, TRecipientType aType ) |
141 RPointerArray<CNcsEmailAddressObject>& aToArray, TRecipientType aType ) |
142 { |
142 { |
143 FUNC_LOG; |
143 FUNC_LOG; |
144 |
144 |
145 // figure out the recipient type dependent text |
145 // figure out the recipient type dependent text |
146 TInt labelResource = R_NCS_ENGINE_EMAIL_TO; |
146 TInt labelResource = R_NCS_ENGINE_EMAIL_TO; |
147 if ( aType == ERecipientTypeCc ) |
147 if ( aType == ERecipientTypeCc ) |
148 { |
148 { |
149 labelResource = R_NCS_ENGINE_EMAIL_CC; |
149 labelResource = R_NCS_ENGINE_EMAIL_CC; |
150 } |
150 } |
151 |
151 |
152 HBufC* buf = DoGenerateAddressLineToMessageBodyL( labelResource, aToArray ); |
152 HBufC* buf = DoGenerateAddressLineToMessageBodyL( labelResource, aToArray ); |
153 |
153 |
154 return buf; |
154 return buf; |
155 } |
155 } |
156 |
156 |
157 // ----------------------------------------------------------------------------- |
157 // ----------------------------------------------------------------------------- |
158 // NcsUtility::DoGenerateAddressLineToMessageBodyL() |
158 // NcsUtility::DoGenerateAddressLineToMessageBodyL() |
159 // |
159 // |
160 // ----------------------------------------------------------------------------- |
160 // ----------------------------------------------------------------------------- |
226 // NcsUtility::GenerateSubjectLineToMessageBodyL() |
226 // NcsUtility::GenerateSubjectLineToMessageBodyL() |
227 // |
227 // |
228 // ----------------------------------------------------------------------------- |
228 // ----------------------------------------------------------------------------- |
229 // |
229 // |
230 HBufC* NcsUtility::GenerateSubjectLineToMessageBodyL( const TDesC& aSubject ) |
230 HBufC* NcsUtility::GenerateSubjectLineToMessageBodyL( const TDesC& aSubject ) |
231 { |
231 { |
232 FUNC_LOG; |
232 FUNC_LOG; |
233 |
233 |
234 // load "Subject:" string |
234 // load "Subject:" string |
235 HBufC* subjectLabel = StringLoader::LoadLC( R_NCS_ENGINE_EMAIL_SUBJECT ); |
235 HBufC* subjectLabel = StringLoader::LoadLC( R_NCS_ENGINE_EMAIL_SUBJECT ); |
236 |
236 |
237 // allocate buffer for the text |
237 // allocate buffer for the text |
238 HBufC* buf = HBufC::NewL( subjectLabel->Length() + aSubject.Length() ); |
238 HBufC* buf = HBufC::NewL( subjectLabel->Length() + aSubject.Length() ); |
239 TPtr ptr = buf->Des(); |
239 TPtr ptr = buf->Des(); |
240 ptr.Append( *subjectLabel ); |
240 ptr.Append( *subjectLabel ); |
241 ptr.Append( aSubject ); |
241 ptr.Append( aSubject ); |
242 |
242 |
243 CleanupStack::PopAndDestroy( subjectLabel ); |
243 CleanupStack::PopAndDestroy( subjectLabel ); |
244 |
244 |
245 return buf; |
245 return buf; |
246 } |
246 } |
247 |
247 |
248 // ----------------------------------------------------------------------------- |
248 // ----------------------------------------------------------------------------- |
249 // NcsUtility::CreateNcsAddressL() |
249 // NcsUtility::CreateNcsAddressL() |
250 // |
250 // |
251 // ----------------------------------------------------------------------------- |
251 // ----------------------------------------------------------------------------- |
252 // |
252 // |
253 CNcsEmailAddressObject* NcsUtility::CreateNcsAddressL( |
253 CNcsEmailAddressObject* NcsUtility::CreateNcsAddressL( |
254 const CFSMailAddress& aFsAddress ) |
254 const CFSMailAddress& aFsAddress ) |
255 { |
255 { |
256 FUNC_LOG; |
256 FUNC_LOG; |
257 |
257 |
258 CNcsEmailAddressObject* address = CNcsEmailAddressObject::NewL( ETrue ); |
258 CNcsEmailAddressObject* address = CNcsEmailAddressObject::NewL( ETrue ); |
259 CleanupStack::PushL( address ); |
259 CleanupStack::PushL( address ); |
260 // temporary ugly code because email API can return references to null |
260 // temporary ugly code because email API can return references to null |
261 TDesC& a = aFsAddress.GetEmailAddress(); |
261 TDesC& a = aFsAddress.GetEmailAddress(); |
262 if ( &a ) |
262 if ( &a ) |
263 { |
263 { |
264 address->SetEmailAddressL( a ); |
264 address->SetEmailAddressL( a ); |
265 } |
265 } |
266 TDesC& name = aFsAddress.GetDisplayName(); |
266 TDesC& name = aFsAddress.GetDisplayName(); |
267 if ( &name ) |
267 if ( &name ) |
268 { |
268 { |
269 address->SetDisplayNameL( name ); |
269 address->SetDisplayNameL( name ); |
270 } |
270 } |
271 |
271 |
272 CleanupStack::Pop( address ); |
272 CleanupStack::Pop( address ); |
273 |
273 |
274 return address; |
274 return address; |
275 } |
275 } |
276 |
276 |
277 // ----------------------------------------------------------------------------- |
277 // ----------------------------------------------------------------------------- |
278 // NcsUtility::CreateFsAddressL() |
278 // NcsUtility::CreateFsAddressL() |
279 // Caller takes the ownership of the returned address object |
279 // Caller takes the ownership of the returned address object |
280 // ----------------------------------------------------------------------------- |
280 // ----------------------------------------------------------------------------- |
281 // |
281 // |
282 CFSMailAddress* NcsUtility::CreateFsAddressL( |
282 CFSMailAddress* NcsUtility::CreateFsAddressL( |
283 const CNcsEmailAddressObject& aNcsAddress ) |
283 const CNcsEmailAddressObject& aNcsAddress ) |
284 { |
284 { |
285 FUNC_LOG; |
285 FUNC_LOG; |
286 |
286 |
287 CFSMailAddress* address = CFSMailAddress::NewL(); |
287 CFSMailAddress* address = CFSMailAddress::NewL(); |
288 address->SetEmailAddress( aNcsAddress.EmailAddress() ); |
288 address->SetEmailAddress( aNcsAddress.EmailAddress() ); |
289 address->SetDisplayName( aNcsAddress.DisplayName() ); |
289 address->SetDisplayName( aNcsAddress.DisplayName() ); |
290 |
290 |
291 return address; |
291 return address; |
292 } |
292 } |
293 |
293 |
294 |
294 |
295 // ----------------------------------------------------------------------------- |
295 // ----------------------------------------------------------------------------- |
296 // NcsUtility::FormatSubjectLineL() |
296 // NcsUtility::FormatSubjectLineL() |
297 // |
297 // |
298 // ----------------------------------------------------------------------------- |
298 // ----------------------------------------------------------------------------- |
299 // |
299 // |
300 HBufC* NcsUtility::FormatSubjectLineL( |
300 HBufC* NcsUtility::FormatSubjectLineL( |
301 const TDesC& aNewSubjectLine, const TDesC& aPrefix ) |
301 const TDesC& aNewSubjectLine, const TDesC& aPrefix ) |
302 { |
302 { |
303 FUNC_LOG; |
303 FUNC_LOG; |
304 |
304 |
305 HBufC* formattedSubjectLine = aNewSubjectLine.AllocLC(); |
305 HBufC* formattedSubjectLine = aNewSubjectLine.AllocLC(); |
306 HBufC* prefix = aPrefix.AllocLC(); |
306 HBufC* prefix = aPrefix.AllocLC(); |
307 TPtr formattedSubjectLinePtr = formattedSubjectLine->Des(); |
307 TPtr formattedSubjectLinePtr = formattedSubjectLine->Des(); |
308 TPtr prefixPtr = prefix->Des(); |
308 TPtr prefixPtr = prefix->Des(); |
309 prefixPtr.Trim(); |
309 prefixPtr.Trim(); |
310 |
310 |
311 TInt subjectLineLength = formattedSubjectLinePtr.Length(); |
311 TInt subjectLineLength = formattedSubjectLinePtr.Length(); |
312 TInt length = subjectLineLength; |
312 TInt length = subjectLineLength; |
313 TInt prefixLength = prefixPtr.Length(); |
313 TInt prefixLength = prefixPtr.Length(); |
314 HBufC* fwdPrefix = StringLoader::LoadLC( R_NCS_ENGINE_EMAIL_FORWARD_PREFIX ); |
314 HBufC* fwdPrefix = StringLoader::LoadLC( R_NCS_ENGINE_EMAIL_FORWARD_PREFIX ); |
315 TPtr fwdPrt = fwdPrefix->Des(); |
315 TPtr fwdPrt = fwdPrefix->Des(); |
316 TInt fwdLength = fwdPrt.Length(); |
316 TInt fwdLength = fwdPrt.Length(); |
317 fwdPrt.Trim(); |
317 fwdPrt.Trim(); |
318 |
318 |
319 for(TInt index = formattedSubjectLinePtr.FindC( prefixPtr ); index != KErrNotFound ; index = formattedSubjectLinePtr.FindC( prefixPtr )) |
319 for(TInt index = formattedSubjectLinePtr.FindC( prefixPtr ); index != KErrNotFound ; index = formattedSubjectLinePtr.FindC( prefixPtr )) |
320 { |
320 { |
321 formattedSubjectLinePtr = formattedSubjectLinePtr.RightTPtr( length ); |
321 formattedSubjectLinePtr = formattedSubjectLinePtr.RightTPtr( length ); |
322 length = formattedSubjectLinePtr.Length() - index - prefixLength; |
322 length = formattedSubjectLinePtr.Length() - index - prefixLength; |
323 } |
323 } |
324 formattedSubjectLinePtr.Trim(); |
324 formattedSubjectLinePtr.Trim(); |
325 |
325 |
326 for(TInt index = formattedSubjectLinePtr.FindC( fwdPrt) ; index != KErrNotFound ; index = formattedSubjectLinePtr.FindC( fwdPrt )) |
326 for(TInt index = formattedSubjectLinePtr.FindC( fwdPrt) ; index != KErrNotFound ; index = formattedSubjectLinePtr.FindC( fwdPrt )) |
327 { |
327 { |
328 formattedSubjectLinePtr = formattedSubjectLinePtr.RightTPtr( length ); |
328 formattedSubjectLinePtr = formattedSubjectLinePtr.RightTPtr( length ); |
329 length = formattedSubjectLinePtr.Length() - index - fwdLength; |
329 length = formattedSubjectLinePtr.Length() - index - fwdLength; |
330 } |
330 } |
331 |
331 |
332 formattedSubjectLinePtr.Trim(); |
332 formattedSubjectLinePtr.Trim(); |
333 |
333 |
334 |
334 |
335 HBufC* finalSubject = HBufC::NewL( formattedSubjectLinePtr.Length() + prefixPtr.Length() + KSpace().Length() ); |
335 HBufC* finalSubject = HBufC::NewL( formattedSubjectLinePtr.Length() + prefixPtr.Length() + KSpace().Length() ); |
336 TPtr ptr = finalSubject->Des(); |
336 TPtr ptr = finalSubject->Des(); |
337 if ( AknLayoutUtils::LayoutMirrored() ) |
337 if ( AknLayoutUtils::LayoutMirrored() ) |
338 { |
338 { |
339 ptr.Append( formattedSubjectLinePtr ); |
339 ptr.Append( formattedSubjectLinePtr ); |
340 ptr.Append( KSpace ); |
340 ptr.Append( KSpace ); |
341 ptr.Append( prefixPtr ); |
341 ptr.Append( prefixPtr ); |
342 |
342 |
343 } |
343 } |
344 else |
344 else |
345 { |
345 { |
346 ptr.Append( prefixPtr ); |
346 ptr.Append( prefixPtr ); |
347 ptr.Append( KSpace ); |
347 ptr.Append( KSpace ); |
348 ptr.Append( formattedSubjectLinePtr ); |
348 ptr.Append( formattedSubjectLinePtr ); |
349 |
349 |
350 } |
350 } |
351 CleanupStack::PopAndDestroy( fwdPrefix ); |
351 CleanupStack::PopAndDestroy( fwdPrefix ); |
352 CleanupStack::PopAndDestroy( prefix ); |
352 CleanupStack::PopAndDestroy( prefix ); |
353 CleanupStack::PopAndDestroy( formattedSubjectLine ); |
353 CleanupStack::PopAndDestroy( formattedSubjectLine ); |
354 |
354 |
355 return finalSubject; |
355 return finalSubject; |
356 } |
356 } |
357 |
357 |
358 // ----------------------------------------------------------------------------- |
358 // ----------------------------------------------------------------------------- |
359 // NcsUtility::ConvertAddressArrayL() |
359 // NcsUtility::ConvertAddressArrayL() |
360 // |
360 // |
361 // ----------------------------------------------------------------------------- |
361 // ----------------------------------------------------------------------------- |
362 // |
362 // |
363 void NcsUtility::ConvertAddressArrayL( |
363 void NcsUtility::ConvertAddressArrayL( |
364 const RPointerArray<CFSMailAddress>& aSrc, |
364 const RPointerArray<CFSMailAddress>& aSrc, |
365 RPointerArray<CNcsEmailAddressObject>& aDst ) |
365 RPointerArray<CNcsEmailAddressObject>& aDst ) |
366 { |
366 { |
367 FUNC_LOG; |
367 FUNC_LOG; |
368 |
368 |
369 for ( TInt i=0; i<aSrc.Count(); i++ ) |
369 for ( TInt i=0; i<aSrc.Count(); i++ ) |
370 { |
370 { |
371 CNcsEmailAddressObject* ncsRecipient = |
371 CNcsEmailAddressObject* ncsRecipient = |
372 NcsUtility::CreateNcsAddressL( *aSrc[i] ); |
372 NcsUtility::CreateNcsAddressL( *aSrc[i] ); |
373 CleanupStack::PushL( ncsRecipient ); |
373 CleanupStack::PushL( ncsRecipient ); |
374 aDst.AppendL( ncsRecipient ); |
374 aDst.AppendL( ncsRecipient ); |
375 CleanupStack::Pop( ncsRecipient ); |
375 CleanupStack::Pop( ncsRecipient ); |
376 } |
376 } |
377 |
377 |
378 } |
378 } |
379 |
379 |
380 // ----------------------------------------------------------------------------- |
380 // ----------------------------------------------------------------------------- |
381 // NcsUtility::ConvertAddressArrayL() |
381 // NcsUtility::ConvertAddressArrayL() |
382 // Caller takes the ownership of address objects pointoed in the array aDst. |
382 // Caller takes the ownership of address objects pointoed in the array aDst. |
383 // ----------------------------------------------------------------------------- |
383 // ----------------------------------------------------------------------------- |
384 // |
384 // |
385 void NcsUtility::ConvertAddressArrayL( |
385 void NcsUtility::ConvertAddressArrayL( |
386 const RPointerArray<CNcsEmailAddressObject>& aSrc, |
386 const RPointerArray<CNcsEmailAddressObject>& aSrc, |
387 RPointerArray<CFSMailAddress>& aDst ) |
387 RPointerArray<CFSMailAddress>& aDst ) |
388 { |
388 { |
389 FUNC_LOG; |
389 FUNC_LOG; |
390 |
390 |
391 for ( TInt i=0; i<aSrc.Count(); i++ ) |
391 for ( TInt i=0; i<aSrc.Count(); i++ ) |
392 { |
392 { |
393 CFSMailAddress* fsRecipient = |
393 CFSMailAddress* fsRecipient = |
394 NcsUtility::CreateFsAddressL( *aSrc[i] ); |
394 NcsUtility::CreateFsAddressL( *aSrc[i] ); |
395 CleanupStack::PushL( fsRecipient ); |
395 CleanupStack::PushL( fsRecipient ); |
396 aDst.AppendL( fsRecipient ); |
396 aDst.AppendL( fsRecipient ); |
397 CleanupStack::Pop( fsRecipient ); |
397 CleanupStack::Pop( fsRecipient ); |
398 } |
398 } |
399 |
399 |
400 } |
400 } |
401 |
401 |
402 |
402 |
403 |
403 |
404 // ----------------------------------------------------------------------------- |
404 // ----------------------------------------------------------------------------- |
405 // NcsUtility::LoadScalableIconL() |
405 // NcsUtility::LoadScalableIconL() |
461 // ----------------------------------------------------------------------------- |
461 // ----------------------------------------------------------------------------- |
462 // |
462 // |
463 TBool NcsUtility::IsEqualAddressArray( |
463 TBool NcsUtility::IsEqualAddressArray( |
464 const RPointerArray<CFSMailAddress>& aAddresses1, |
464 const RPointerArray<CFSMailAddress>& aAddresses1, |
465 const RPointerArray<CFSMailAddress>& aAddresses2 ) |
465 const RPointerArray<CFSMailAddress>& aAddresses2 ) |
466 { |
466 { |
467 FUNC_LOG; |
467 FUNC_LOG; |
468 |
468 |
469 if ( aAddresses1.Count() != aAddresses2.Count() ) |
469 if ( aAddresses1.Count() != aAddresses2.Count() ) |
470 { |
470 { |
471 return EFalse; |
471 return EFalse; |
472 } |
472 } |
473 for ( TInt i=0; i<aAddresses1.Count(); i++ ) |
473 for ( TInt i=0; i<aAddresses1.Count(); i++ ) |
474 { |
474 { |
475 if ( aAddresses1[i]->GetEmailAddress().Compare( |
475 if ( aAddresses1[i]->GetEmailAddress().Compare( |
476 aAddresses2[i]->GetEmailAddress() ) != 0 ) |
476 aAddresses2[i]->GetEmailAddress() ) != 0 ) |
477 { |
477 { |
478 return EFalse; |
478 return EFalse; |
479 } |
479 } |
480 if ( aAddresses1[i]->GetDisplayName().Compare( |
480 if ( aAddresses1[i]->GetDisplayName().Compare( |
481 aAddresses2[i]->GetDisplayName() ) != 0 ) |
481 aAddresses2[i]->GetDisplayName() ) != 0 ) |
482 { |
482 { |
483 return EFalse; |
483 return EFalse; |
484 } |
484 } |
485 } |
485 } |
486 |
486 |
487 return ETrue; |
487 return ETrue; |
488 } |
488 } |
489 |
489 |
490 |
490 |
491 // ----------------------------------------------------------------------------- |
491 // ----------------------------------------------------------------------------- |
492 // NcsUtility::Measures |
492 // NcsUtility::Measures |
493 // ----------------------------------------------------------------------------- |
493 // ----------------------------------------------------------------------------- |
494 // |
494 // |
495 TNcsMeasures NcsUtility::Measures() |
495 TNcsMeasures NcsUtility::Measures() |
496 { |
496 { |
497 FUNC_LOG; |
497 FUNC_LOG; |
498 |
498 |
499 TNcsMeasures ms; |
499 TNcsMeasures ms; |
500 |
500 |
501 TAknUiZoom zoomLevel = EAknUiZoomNormal; |
501 TAknUiZoom zoomLevel = EAknUiZoomNormal; |
502 CAknEnv::Static()->GetCurrentGlobalUiZoom( zoomLevel ); |
502 CAknEnv::Static()->GetCurrentGlobalUiZoom( zoomLevel ); |
503 switch ( zoomLevel ) |
503 switch ( zoomLevel ) |
504 { |
504 { |
505 case EAknUiZoomNormal: case EAknUiZoomAutomatic: |
505 case EAknUiZoomNormal: case EAknUiZoomAutomatic: |
506 { |
506 { |
507 ms.iAifHeight = KAifHeight; |
507 ms.iAifHeight = KAifHeight; |
508 ms.iAifLabelMarginVertical = KAifLabelMarginVertical; |
508 ms.iAifLabelMarginVertical = KAifLabelMarginVertical; |
509 ms.iAifEditorMarginVertical = KAifEditorMarginVertical; |
509 ms.iAifEditorMarginVertical = KAifEditorMarginVertical; |
510 ms.iAifEditorHeight = KAifEditorHeight; |
510 ms.iAifEditorHeight = KAifEditorHeight; |
511 ms.iSubjectExtraHeightBottom = KSubjectExtraHeightBottom; |
511 ms.iSubjectExtraHeightBottom = KSubjectExtraHeightBottom; |
512 ms.iAttachmentExtraHeightBottom = KAttachmentExtraHeightBottom; |
512 ms.iAttachmentExtraHeightBottom = KAttachmentExtraHeightBottom; |
513 ms.iIconMarginPriorityVertical = KIconMarginPriorityVertical; |
513 ms.iIconMarginPriorityVertical = KIconMarginPriorityVertical; |
514 ms.iIconMarginFollowUpVertical = KIconMarginFollowUpVertical; |
514 ms.iIconMarginFollowUpVertical = KIconMarginFollowUpVertical; |
515 ms.iIconMarginAttachmentVertical = KIconMarginAttachmentVertical; |
515 ms.iIconMarginAttachmentVertical = KIconMarginAttachmentVertical; |
516 ms.iLabelFontHeightPx = KLabelFontHeightPx; |
516 ms.iLabelFontHeightPx = KLabelFontHeightPx; |
517 ms.iEditorFontHeightPx = KEditorFontHeightPx; |
517 ms.iEditorFontHeightPx = KEditorFontHeightPx; |
518 } |
518 } |
519 break; |
519 break; |
520 case EAknUiZoomSmall: case EAknUiZoomVerySmall: |
520 case EAknUiZoomSmall: case EAknUiZoomVerySmall: |
521 { |
521 { |
522 ms.iAifHeight = KAifHeightSmall; |
522 ms.iAifHeight = KAifHeightSmall; |
523 ms.iAifLabelMarginVertical = KAifLabelMarginVerticalSmall; |
523 ms.iAifLabelMarginVertical = KAifLabelMarginVerticalSmall; |
524 ms.iAifEditorMarginVertical = KAifEditorMarginVerticalSmall; |
524 ms.iAifEditorMarginVertical = KAifEditorMarginVerticalSmall; |
525 ms.iAifEditorHeight = KAifEditorHeightSmall; |
525 ms.iAifEditorHeight = KAifEditorHeightSmall; |
526 ms.iSubjectExtraHeightBottom = KSubjectExtraHeightBottomSmall; |
526 ms.iSubjectExtraHeightBottom = KSubjectExtraHeightBottomSmall; |
527 ms.iAttachmentExtraHeightBottom = |
527 ms.iAttachmentExtraHeightBottom = |
528 KAttachmentExtraHeightBottomSmall; |
528 KAttachmentExtraHeightBottomSmall; |
529 ms.iIconMarginPriorityVertical = KIconMarginPriorityVerticalSmall; |
529 ms.iIconMarginPriorityVertical = KIconMarginPriorityVerticalSmall; |
530 ms.iIconMarginFollowUpVertical = KIconMarginFollowUpVerticalSmall; |
530 ms.iIconMarginFollowUpVertical = KIconMarginFollowUpVerticalSmall; |
531 ms.iIconMarginAttachmentVertical = |
531 ms.iIconMarginAttachmentVertical = |
532 KIconMarginAttachmentVerticalSmall; |
532 KIconMarginAttachmentVerticalSmall; |
533 ms.iLabelFontHeightPx = KLabelFontHeightPxSmall; |
533 ms.iLabelFontHeightPx = KLabelFontHeightPxSmall; |
534 ms.iEditorFontHeightPx = KEditorFontHeightPxSmall; |
534 ms.iEditorFontHeightPx = KEditorFontHeightPxSmall; |
535 } |
535 } |
536 break; |
536 break; |
537 case EAknUiZoomLarge: case EAknUiZoomVeryLarge: |
537 case EAknUiZoomLarge: case EAknUiZoomVeryLarge: |
538 { |
538 { |
539 ms.iAifHeight = KAifHeightLarge; |
539 ms.iAifHeight = KAifHeightLarge; |
540 ms.iAifLabelMarginVertical = KAifLabelMarginVerticalLarge; |
540 ms.iAifLabelMarginVertical = KAifLabelMarginVerticalLarge; |
541 ms.iAifEditorMarginVertical = KAifEditorMarginVerticalLarge; |
541 ms.iAifEditorMarginVertical = KAifEditorMarginVerticalLarge; |
542 ms.iAifEditorHeight = KAifEditorHeightLarge; |
542 ms.iAifEditorHeight = KAifEditorHeightLarge; |
543 ms.iSubjectExtraHeightBottom = KSubjectExtraHeightBottomLarge; |
543 ms.iSubjectExtraHeightBottom = KSubjectExtraHeightBottomLarge; |
544 ms.iAttachmentExtraHeightBottom = |
544 ms.iAttachmentExtraHeightBottom = |
545 KAttachmentExtraHeightBottomLarge; |
545 KAttachmentExtraHeightBottomLarge; |
546 ms.iIconMarginPriorityVertical = KIconMarginPriorityVerticalLarge; |
546 ms.iIconMarginPriorityVertical = KIconMarginPriorityVerticalLarge; |
547 ms.iIconMarginFollowUpVertical = KIconMarginFollowUpVerticalLarge; |
547 ms.iIconMarginFollowUpVertical = KIconMarginFollowUpVerticalLarge; |
548 ms.iIconMarginAttachmentVertical = |
548 ms.iIconMarginAttachmentVertical = |
549 KIconMarginAttachmentVerticalLarge; |
549 KIconMarginAttachmentVerticalLarge; |
550 ms.iLabelFontHeightPx = KLabelFontHeightPxLarge; |
550 ms.iLabelFontHeightPx = KLabelFontHeightPxLarge; |
551 ms.iEditorFontHeightPx = KEditorFontHeightPxLarge; |
551 ms.iEditorFontHeightPx = KEditorFontHeightPxLarge; |
552 } |
552 } |
553 break; |
553 break; |
554 } |
554 } |
555 |
555 |
556 return ms; |
556 return ms; |
557 } |
557 } |
558 |
558 |
559 // ----------------------------------------------------------------------------- |
559 // ----------------------------------------------------------------------------- |
560 // NcsUtility::GetNearestFontL |
560 // NcsUtility::GetNearestFontL |
561 // ----------------------------------------------------------------------------- |
561 // ----------------------------------------------------------------------------- |
562 // |
562 // |
563 CFont* NcsUtility::GetNearestFontL( TInt aLogicalFontId, TInt aHeightPixels ) |
563 CFont* NcsUtility::GetNearestFontL( TInt aLogicalFontId, TInt aHeightPixels ) |
564 { |
564 { |
565 FUNC_LOG; |
565 FUNC_LOG; |
566 |
566 |
567 // Base the font on logical font passed to us |
567 // Base the font on logical font passed to us |
568 const CFont* logicalFont = AknLayoutUtils::FontFromId( aLogicalFontId ); |
568 const CFont* logicalFont = AknLayoutUtils::FontFromId( aLogicalFontId ); |
569 // Note: This font is owned by the application's system font array (where |
569 // Note: This font is owned by the application's system font array (where |
570 // it is likely already to have been created) and does not need to be |
570 // it is likely already to have been created) and does not need to be |
571 // released. It can just go out of scope. |
571 // released. It can just go out of scope. |
572 |
572 |
573 // Extract font information |
573 // Extract font information |
574 TFontSpec fontSpec = logicalFont->FontSpecInTwips(); |
574 TFontSpec fontSpec = logicalFont->FontSpecInTwips(); |
575 |
575 |
576 // Desired height, weight, and posture |
576 // Desired height, weight, and posture |
577 CWsScreenDevice& screenDev = *( CEikonEnv::Static()->ScreenDevice() ); |
577 CWsScreenDevice& screenDev = *( CEikonEnv::Static()->ScreenDevice() ); |
578 fontSpec.iHeight = screenDev.VerticalPixelsToTwips( aHeightPixels ); |
578 fontSpec.iHeight = screenDev.VerticalPixelsToTwips( aHeightPixels ); |
579 fontSpec.iFontStyle.SetStrokeWeight( EStrokeWeightNormal ); |
579 fontSpec.iFontStyle.SetStrokeWeight( EStrokeWeightNormal ); |
580 fontSpec.iFontStyle.SetPosture( EPostureUpright ); |
580 fontSpec.iFontStyle.SetPosture( EPostureUpright ); |
581 |
581 |
582 // Obtain new font |
582 // Obtain new font |
583 CFont* font; |
583 CFont* font; |
584 |
584 |
585 TInt err = screenDev.GetNearestFontInTwips( font, fontSpec ); |
585 TInt err = screenDev.GetNearestFontInTwips( font, fontSpec ); |
586 User::LeaveIfError( err ); |
586 User::LeaveIfError( err ); |
587 |
587 |
588 return font; |
588 return font; |
589 // Font is now usable. Must be released before application |
589 // Font is now usable. Must be released before application |
590 // exit using CWsScreenDevice::ReleaseFont() |
590 // exit using CWsScreenDevice::ReleaseFont() |
591 } |
591 } |
592 |
592 |
593 // <cmail> Platform layout change |
593 // <cmail> Platform layout change |
594 // ----------------------------------------------------------------------------- |
594 // ----------------------------------------------------------------------------- |
595 // NcsUtility::GetLayoutFont |
595 // NcsUtility::GetLayoutFont |
596 // ----------------------------------------------------------------------------- |
596 // ----------------------------------------------------------------------------- |