author | Simon Howkins <simonh@symbian.org> |
Thu, 25 Nov 2010 12:13:04 +0000 | |
branch | RCL_3 |
changeset 83 | 31a5fbf5db1d |
parent 80 | 726fba06891a |
permissions | -rw-r--r-- |
64 | 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: utility class definition |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
// INCLUDE FILES |
|
21 |
#include "emailtrace.h" |
|
22 |
#include <StringLoader.h> |
|
23 |
#include <AknsUtils.h> |
|
24 |
#include <AknUtils.h> |
|
25 |
#include <AknsSkinInstance.h> |
|
26 |
#include <aknbutton.h> |
|
27 |
#include <eikedwin.h> |
|
28 |
#include <FreestyleEmailUi.rsg> |
|
29 |
#include <RPbkViewResourceFile.h> |
|
30 |
#include <CPbkContactEngine.h> |
|
31 |
#include <CPbkMultipleEntryFetchDlg.h> |
|
32 |
#include <CPbkContactItem.h> |
|
33 |
#include <AknIconUtils.h> |
|
34 |
#include <eikimage.h> |
|
35 |
#include <fbs.h> |
|
36 |
#include <flogger.h> |
|
37 |
#include <aknenv.h> // CAknEnv |
|
38 |
||
39 |
#include "cfsmailbox.h" |
|
40 |
#include "cfsmailclient.h" |
|
41 |
#include "cfsmailaddress.h" |
|
42 |
||
43 |
#include <aknlayoutscalable_apps.cdl.h> |
|
44 |
#include <layoutmetadata.cdl.h> |
|
45 |
#include <AknLayoutFont.h> |
|
46 |
||
47 |
#include "ncsutility.h" |
|
48 |
#include "ncsemailaddressobject.h" |
|
49 |
#include "ncsconstants.h" |
|
50 |
#include "FSDelayedLoader.h" |
|
51 |
#include "FreestyleEmailUiUtilities.h" |
|
52 |
#include "FreestyleEmailUiLayoutData.h" |
|
53 |
||
54 |
// CONSTANTS |
|
55 |
const TInt KFSUtilityMinColorValue = 0; |
|
56 |
const TInt KFSUtilityMaxColorValue = 255; |
|
57 |
const TInt KFSUtilityThresholdColorValue = 200; |
|
58 |
const TInt KFSUtilityThresholdColorMiddleValue = 127; |
|
59 |
||
60 |
// ========================= MEMBER FUNCTIONS ================================== |
|
61 |
||
62 |
||
63 |
// ----------------------------------------------------------------------------- |
|
64 |
// NcsUtility::CompleteRelativePathL() |
|
65 |
// ----------------------------------------------------------------------------- |
|
66 |
// |
|
67 |
void NcsUtility::CompleteRelativePathL( |
|
68 |
const TDesC& aRelativePath, TPtr& aAbsolutePath ) |
|
69 |
{ |
|
70 |
FUNC_LOG; |
|
71 |
||
72 |
// + 2 is for drive letter and ":" |
|
73 |
if( aAbsolutePath.MaxLength() < aRelativePath.Length() + 2 ) |
|
74 |
{ |
|
75 |
User::Leave( KErrArgument ); |
|
76 |
} |
|
77 |
||
78 |
TFileName path; |
|
79 |
path.Copy( aRelativePath ); |
|
80 |
TInt err = CompleteWithAppPath( path ); |
|
81 |
User::LeaveIfError( err ); |
|
82 |
||
83 |
aAbsolutePath.Copy( path ); |
|
84 |
||
85 |
} |
|
86 |
||
87 |
// ----------------------------------------------------------------------------- |
|
88 |
// NcsUtility::GenerateFromLineToMessageBodyL() |
|
89 |
// |
|
90 |
// ----------------------------------------------------------------------------- |
|
91 |
// |
|
92 |
HBufC* NcsUtility::GenerateFromLineToMessageBodyL( |
|
93 |
const RPointerArray<CNcsEmailAddressObject>& aFromArray ) |
|
94 |
{ |
|
95 |
FUNC_LOG; |
|
96 |
||
97 |
HBufC* buf = DoGenerateAddressLineToMessageBodyL( |
|
98 |
R_NCS_ENGINE_EMAIL_FROM, aFromArray ); |
|
99 |
||
100 |
return buf; |
|
101 |
} |
|
102 |
||
103 |
// ----------------------------------------------------------------------------- |
|
104 |
// NcsUtility::GenerateSentLineToMessageBodyL() |
|
105 |
// |
|
106 |
// ----------------------------------------------------------------------------- |
|
107 |
// |
|
108 |
HBufC* NcsUtility::GenerateSentLineToMessageBodyL( CFSMailMessage& aMessage ) |
|
109 |
{ |
|
110 |
FUNC_LOG; |
|
111 |
||
112 |
HBufC* dateText = TFsEmailUiUtility::DateTextFromMsgLC( &aMessage ); |
|
113 |
HBufC* timeText = TFsEmailUiUtility::TimeTextFromMsgLC( &aMessage ); |
|
114 |
HBufC* sent = StringLoader::LoadLC( R_NCS_ENGINE_EMAIL_SENT ); |
|
115 |
||
116 |
HBufC* buf = HBufC::NewL( sent->Length() + |
|
117 |
KSpace().Length() + |
|
118 |
dateText->Length() + |
|
119 |
KSentLineDateAndTimeSeparatorText().Length() + |
|
120 |
timeText->Length() ); |
|
121 |
TPtr ptr = buf->Des(); |
|
122 |
ptr.Append( *sent ); |
|
123 |
ptr.Append( KSpace ); |
|
124 |
ptr.Append( *dateText ); |
|
125 |
ptr.Append( KSentLineDateAndTimeSeparatorText ); |
|
126 |
ptr.Append( *timeText ); |
|
127 |
||
128 |
CleanupStack::PopAndDestroy( sent ); |
|
129 |
CleanupStack::PopAndDestroy( timeText ); |
|
130 |
CleanupStack::PopAndDestroy( dateText ); |
|
131 |
||
132 |
return buf; |
|
133 |
} |
|
134 |
||
135 |
// ----------------------------------------------------------------------------- |
|
136 |
// NcsUtility::GenerateAddressLineToMessageBodyL() |
|
137 |
// |
|
138 |
// ----------------------------------------------------------------------------- |
|
139 |
// |
|
140 |
HBufC* NcsUtility::GenerateAddressLineToMessageBodyL( |
|
141 |
RPointerArray<CNcsEmailAddressObject>& aToArray, TRecipientType aType ) |
|
142 |
{ |
|
143 |
FUNC_LOG; |
|
144 |
||
145 |
// figure out the recipient type dependent text |
|
146 |
TInt labelResource = R_NCS_ENGINE_EMAIL_TO; |
|
147 |
if ( aType == ERecipientTypeCc ) |
|
148 |
{ |
|
149 |
labelResource = R_NCS_ENGINE_EMAIL_CC; |
|
150 |
} |
|
151 |
||
152 |
HBufC* buf = DoGenerateAddressLineToMessageBodyL( labelResource, aToArray ); |
|
153 |
||
154 |
return buf; |
|
155 |
} |
|
156 |
||
157 |
// ----------------------------------------------------------------------------- |
|
158 |
// NcsUtility::DoGenerateAddressLineToMessageBodyL() |
|
159 |
// |
|
160 |
// ----------------------------------------------------------------------------- |
|
161 |
// |
|
162 |
HBufC* NcsUtility::DoGenerateAddressLineToMessageBodyL( TInt aLabelResourceId, |
|
163 |
const RPointerArray<CNcsEmailAddressObject>& aAddressArray ) |
|
164 |
{ |
|
165 |
FUNC_LOG; |
|
166 |
||
167 |
// load label string (e.g. "From:", "To:", "Cc:") |
|
168 |
HBufC* label = StringLoader::LoadLC( aLabelResourceId ); |
|
169 |
||
170 |
// calculate how large buffer do we need for the whole line |
|
171 |
TInt bufLength = label->Length(); |
|
172 |
TInt count = aAddressArray.Count(); |
|
173 |
for ( TInt i = 0; i < count; i++ ) |
|
174 |
{ |
|
175 |
CNcsEmailAddressObject* obj = aAddressArray[i]; |
|
176 |
const TDesC& dispName = obj->DisplayName(); |
|
177 |
// use display name if it is available, otherwise email address |
|
178 |
if ( dispName.Length() > 0 ) |
|
179 |
{ |
|
180 |
bufLength += dispName.Length(); |
|
181 |
} |
|
182 |
else |
|
183 |
{ |
|
184 |
bufLength += obj->EmailAddress().Length(); |
|
185 |
} |
|
186 |
if ( i < ( count - 1 ) ) |
|
187 |
{ |
|
188 |
bufLength += KEmailAddressSeparator().Length(); |
|
189 |
bufLength += KSpace().Length(); |
|
190 |
} |
|
191 |
} |
|
192 |
||
193 |
// allocate buffer to contain the whole text |
|
194 |
HBufC* buf = HBufC::NewL( bufLength ); |
|
195 |
TPtr ptr = buf->Des(); |
|
196 |
||
197 |
// add label |
|
198 |
ptr.Append( *label ); |
|
199 |
CleanupStack::PopAndDestroy( label ); |
|
200 |
||
201 |
// append each address into our text buffer |
|
202 |
for ( TInt i = 0; i < count; i++ ) |
|
203 |
{ |
|
204 |
CNcsEmailAddressObject* obj = aAddressArray[i]; |
|
205 |
const TDesC& dispName = obj->DisplayName(); |
|
206 |
// use display name if it is available, otherwise email address |
|
207 |
if ( dispName.Length() > 0 ) |
|
208 |
{ |
|
209 |
ptr.Append( dispName ); |
|
210 |
} |
|
211 |
else |
|
212 |
{ |
|
213 |
ptr.Append( obj->EmailAddress() ); |
|
214 |
} |
|
215 |
if ( i < ( count - 1 ) ) |
|
216 |
{ |
|
217 |
ptr.Append( KEmailAddressSeparator ); |
|
218 |
ptr.Append( KSpace ); |
|
219 |
} |
|
220 |
} |
|
221 |
||
222 |
return buf; |
|
223 |
} |
|
224 |
||
225 |
// ----------------------------------------------------------------------------- |
|
226 |
// NcsUtility::GenerateSubjectLineToMessageBodyL() |
|
227 |
// |
|
228 |
// ----------------------------------------------------------------------------- |
|
229 |
// |
|
230 |
HBufC* NcsUtility::GenerateSubjectLineToMessageBodyL( const TDesC& aSubject ) |
|
231 |
{ |
|
232 |
FUNC_LOG; |
|
233 |
||
234 |
// load "Subject:" string |
|
235 |
HBufC* subjectLabel = StringLoader::LoadLC( R_NCS_ENGINE_EMAIL_SUBJECT ); |
|
236 |
||
237 |
// allocate buffer for the text |
|
238 |
HBufC* buf = HBufC::NewL( subjectLabel->Length() + aSubject.Length() ); |
|
239 |
TPtr ptr = buf->Des(); |
|
240 |
ptr.Append( *subjectLabel ); |
|
241 |
ptr.Append( aSubject ); |
|
242 |
||
243 |
CleanupStack::PopAndDestroy( subjectLabel ); |
|
244 |
||
245 |
return buf; |
|
246 |
} |
|
247 |
||
248 |
// ----------------------------------------------------------------------------- |
|
249 |
// NcsUtility::CreateNcsAddressL() |
|
250 |
// |
|
251 |
// ----------------------------------------------------------------------------- |
|
252 |
// |
|
253 |
CNcsEmailAddressObject* NcsUtility::CreateNcsAddressL( |
|
254 |
const CFSMailAddress& aFsAddress ) |
|
255 |
{ |
|
256 |
FUNC_LOG; |
|
257 |
||
258 |
CNcsEmailAddressObject* address = CNcsEmailAddressObject::NewL( ETrue ); |
|
259 |
CleanupStack::PushL( address ); |
|
260 |
// temporary ugly code because email API can return references to null |
|
261 |
TDesC& a = aFsAddress.GetEmailAddress(); |
|
262 |
if ( &a ) |
|
263 |
{ |
|
264 |
address->SetEmailAddressL( a ); |
|
265 |
} |
|
266 |
TDesC& name = aFsAddress.GetDisplayName(); |
|
267 |
if ( &name ) |
|
268 |
{ |
|
269 |
address->SetDisplayNameL( name ); |
|
270 |
} |
|
271 |
||
272 |
CleanupStack::Pop( address ); |
|
273 |
||
274 |
return address; |
|
275 |
} |
|
276 |
||
277 |
// ----------------------------------------------------------------------------- |
|
278 |
// NcsUtility::CreateFsAddressL() |
|
279 |
// Caller takes the ownership of the returned address object |
|
280 |
// ----------------------------------------------------------------------------- |
|
281 |
// |
|
282 |
CFSMailAddress* NcsUtility::CreateFsAddressL( |
|
283 |
const CNcsEmailAddressObject& aNcsAddress ) |
|
284 |
{ |
|
285 |
FUNC_LOG; |
|
286 |
||
287 |
CFSMailAddress* address = CFSMailAddress::NewL(); |
|
288 |
address->SetEmailAddress( aNcsAddress.EmailAddress() ); |
|
289 |
address->SetDisplayName( aNcsAddress.DisplayName() ); |
|
290 |
||
291 |
return address; |
|
292 |
} |
|
293 |
||
294 |
||
295 |
// ----------------------------------------------------------------------------- |
|
296 |
// NcsUtility::FormatSubjectLineL() |
|
297 |
// |
|
298 |
// ----------------------------------------------------------------------------- |
|
299 |
// |
|
300 |
HBufC* NcsUtility::FormatSubjectLineL( |
|
301 |
const TDesC& aNewSubjectLine, const TDesC& aPrefix ) |
|
302 |
{ |
|
303 |
FUNC_LOG; |
|
304 |
||
305 |
HBufC* formattedSubjectLine = aNewSubjectLine.AllocLC(); |
|
306 |
HBufC* prefix = aPrefix.AllocLC(); |
|
307 |
TPtr formattedSubjectLinePtr = formattedSubjectLine->Des(); |
|
308 |
TPtr prefixPtr = prefix->Des(); |
|
309 |
prefixPtr.Trim(); |
|
310 |
||
311 |
HBufC* fwdPrefix = StringLoader::LoadLC( R_NCS_ENGINE_EMAIL_FORWARD_PREFIX ); |
|
70
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
312 |
HBufC* rePrefix = StringLoader::LoadLC( R_NCS_ENGINE_EMAIL_REPLY_PREFIX ); |
64 | 313 |
TPtr fwdPrt = fwdPrefix->Des(); |
70
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
314 |
TPtr rePtr = rePrefix->Des(); |
64 | 315 |
fwdPrt.Trim(); |
70
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
316 |
rePtr.Trim(); |
64 | 317 |
|
70
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
318 |
TInt indexRe; |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
319 |
TInt indexFw; |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
320 |
|
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
321 |
|
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
322 |
// Start to analyse the original subject string and remove |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
323 |
// all prefixes at the beggining. When no prefix found as |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
324 |
// first word, than loop ends |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
325 |
do |
64 | 326 |
{ |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
327 |
indexRe = formattedSubjectLinePtr.FindC( rePtr ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
328 |
if( indexRe == 0 ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
329 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
330 |
formattedSubjectLinePtr.Delete( indexRe, rePtr.Length() ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
331 |
formattedSubjectLinePtr.Trim(); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
332 |
} |
70
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
333 |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
334 |
indexFw = formattedSubjectLinePtr.FindC( fwdPrt ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
335 |
if( indexFw == 0 ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
336 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
337 |
formattedSubjectLinePtr.Delete( indexFw, rePtr.Length() ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
338 |
formattedSubjectLinePtr.Trim(); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
339 |
} |
64 | 340 |
} |
70
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
341 |
while( !( indexRe != 0 && indexFw != 0) ); |
64 | 342 |
|
343 |
HBufC* finalSubject = HBufC::NewL( formattedSubjectLinePtr.Length() + prefixPtr.Length() + KSpace().Length() ); |
|
344 |
TPtr ptr = finalSubject->Des(); |
|
345 |
if ( AknLayoutUtils::LayoutMirrored() ) |
|
346 |
{ |
|
347 |
ptr.Append( formattedSubjectLinePtr ); |
|
348 |
ptr.Append( KSpace ); |
|
349 |
ptr.Append( prefixPtr ); |
|
350 |
||
351 |
} |
|
352 |
else |
|
353 |
{ |
|
354 |
ptr.Append( prefixPtr ); |
|
355 |
ptr.Append( KSpace ); |
|
356 |
ptr.Append( formattedSubjectLinePtr ); |
|
357 |
||
358 |
} |
|
70
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
359 |
CleanupStack::PopAndDestroy( rePrefix ); |
64 | 360 |
CleanupStack::PopAndDestroy( fwdPrefix ); |
361 |
CleanupStack::PopAndDestroy( prefix ); |
|
362 |
CleanupStack::PopAndDestroy( formattedSubjectLine ); |
|
363 |
||
364 |
return finalSubject; |
|
365 |
} |
|
366 |
||
367 |
// ----------------------------------------------------------------------------- |
|
368 |
// NcsUtility::ConvertAddressArrayL() |
|
369 |
// |
|
370 |
// ----------------------------------------------------------------------------- |
|
371 |
// |
|
372 |
void NcsUtility::ConvertAddressArrayL( |
|
373 |
const RPointerArray<CFSMailAddress>& aSrc, |
|
374 |
RPointerArray<CNcsEmailAddressObject>& aDst ) |
|
375 |
{ |
|
376 |
FUNC_LOG; |
|
377 |
||
378 |
for ( TInt i=0; i<aSrc.Count(); i++ ) |
|
379 |
{ |
|
380 |
CNcsEmailAddressObject* ncsRecipient = |
|
381 |
NcsUtility::CreateNcsAddressL( *aSrc[i] ); |
|
382 |
CleanupStack::PushL( ncsRecipient ); |
|
383 |
aDst.AppendL( ncsRecipient ); |
|
384 |
CleanupStack::Pop( ncsRecipient ); |
|
385 |
} |
|
386 |
||
387 |
} |
|
388 |
||
389 |
// ----------------------------------------------------------------------------- |
|
390 |
// NcsUtility::ConvertAddressArrayL() |
|
391 |
// Caller takes the ownership of address objects pointoed in the array aDst. |
|
392 |
// ----------------------------------------------------------------------------- |
|
393 |
// |
|
394 |
void NcsUtility::ConvertAddressArrayL( |
|
395 |
const RPointerArray<CNcsEmailAddressObject>& aSrc, |
|
396 |
RPointerArray<CFSMailAddress>& aDst ) |
|
397 |
{ |
|
398 |
FUNC_LOG; |
|
399 |
||
400 |
for ( TInt i=0; i<aSrc.Count(); i++ ) |
|
401 |
{ |
|
402 |
CFSMailAddress* fsRecipient = |
|
403 |
NcsUtility::CreateFsAddressL( *aSrc[i] ); |
|
404 |
CleanupStack::PushL( fsRecipient ); |
|
405 |
aDst.AppendL( fsRecipient ); |
|
406 |
CleanupStack::Pop( fsRecipient ); |
|
407 |
} |
|
408 |
||
409 |
} |
|
410 |
||
411 |
||
412 |
||
413 |
// ----------------------------------------------------------------------------- |
|
414 |
// NcsUtility::LoadScalableIconL() |
|
415 |
// |
|
416 |
// ----------------------------------------------------------------------------- |
|
417 |
// |
|
418 |
void NcsUtility::LoadScalableIconL( |
|
419 |
const TDesC& aMifRelativeFileName, TInt aImgId, |
|
420 |
TInt aMaskId, CEikImage*& aIcon, |
|
421 |
CFbsBitmap*& aImage, CFbsBitmap*& aMask ) |
|
422 |
{ |
|
423 |
FUNC_LOG; |
|
424 |
||
425 |
HBufC* buf = HBufC::NewLC( KMaxFileName ); |
|
426 |
TPtr ptr = buf->Des(); |
|
427 |
NcsUtility::CompleteRelativePathL( aMifRelativeFileName, ptr ); |
|
428 |
||
429 |
AknIconUtils::CreateIconL( aImage, |
|
430 |
aMask, |
|
431 |
ptr, |
|
432 |
aImgId, |
|
433 |
aMaskId ); |
|
434 |
||
435 |
TSize size; |
|
436 |
AknIconUtils::GetContentDimensions( aImage, size ); |
|
437 |
AknIconUtils::SetSize( aImage, size ); |
|
438 |
||
439 |
aIcon = new ( ELeave ) CEikImage; |
|
440 |
aIcon->SetNewBitmaps( aImage, aMask ); |
|
441 |
aIcon->SetPictureOwnedExternally( ETrue ); |
|
442 |
||
443 |
CleanupStack::PopAndDestroy( buf ); |
|
444 |
||
445 |
} |
|
446 |
||
447 |
||
448 |
// ----------------------------------------------------------------------------- |
|
449 |
// NcsUtility::DebugLog |
|
450 |
// ----------------------------------------------------------------------------- |
|
451 |
// |
|
452 |
void NcsUtility::DebugLog( TRefByValue<const TDesC> aFmt, ... ) |
|
453 |
{ |
|
454 |
FUNC_LOG; |
|
455 |
_LIT( KDebugDir, "FreestyleEmailUi" ); |
|
456 |
_LIT( KDebugLog, "log.txt" ); |
|
457 |
||
458 |
VA_LIST args; |
|
459 |
VA_START( args, aFmt ); |
|
460 |
RFileLogger::WriteFormat( KDebugDir, |
|
461 |
KDebugLog, |
|
462 |
EFileLoggingModeAppend, |
|
463 |
aFmt, |
|
464 |
args ); |
|
465 |
VA_END( args ); |
|
466 |
} |
|
467 |
||
468 |
// ----------------------------------------------------------------------------- |
|
469 |
// NcsUtility::IsEqualAddressArray |
|
470 |
// ----------------------------------------------------------------------------- |
|
471 |
// |
|
472 |
TBool NcsUtility::IsEqualAddressArray( |
|
473 |
const RPointerArray<CFSMailAddress>& aAddresses1, |
|
474 |
const RPointerArray<CFSMailAddress>& aAddresses2 ) |
|
475 |
{ |
|
476 |
FUNC_LOG; |
|
477 |
||
478 |
if ( aAddresses1.Count() != aAddresses2.Count() ) |
|
479 |
{ |
|
480 |
return EFalse; |
|
481 |
} |
|
482 |
for ( TInt i=0; i<aAddresses1.Count(); i++ ) |
|
483 |
{ |
|
484 |
if ( aAddresses1[i]->GetEmailAddress().Compare( |
|
485 |
aAddresses2[i]->GetEmailAddress() ) != 0 ) |
|
486 |
{ |
|
487 |
return EFalse; |
|
488 |
} |
|
489 |
if ( aAddresses1[i]->GetDisplayName().Compare( |
|
490 |
aAddresses2[i]->GetDisplayName() ) != 0 ) |
|
491 |
{ |
|
492 |
return EFalse; |
|
493 |
} |
|
494 |
} |
|
495 |
||
496 |
return ETrue; |
|
497 |
} |
|
498 |
||
499 |
||
500 |
// ----------------------------------------------------------------------------- |
|
501 |
// NcsUtility::Measures |
|
502 |
// ----------------------------------------------------------------------------- |
|
503 |
// |
|
504 |
TNcsMeasures NcsUtility::Measures() |
|
505 |
{ |
|
506 |
FUNC_LOG; |
|
507 |
||
508 |
TNcsMeasures ms; |
|
509 |
||
510 |
TAknUiZoom zoomLevel = EAknUiZoomNormal; |
|
511 |
CAknEnv::Static()->GetCurrentGlobalUiZoom( zoomLevel ); |
|
512 |
switch ( zoomLevel ) |
|
513 |
{ |
|
514 |
case EAknUiZoomNormal: case EAknUiZoomAutomatic: |
|
515 |
{ |
|
516 |
ms.iAifHeight = KAifHeight; |
|
517 |
ms.iAifLabelMarginVertical = KAifLabelMarginVertical; |
|
518 |
ms.iAifEditorMarginVertical = KAifEditorMarginVertical; |
|
519 |
ms.iAifEditorHeight = KAifEditorHeight; |
|
520 |
ms.iSubjectExtraHeightBottom = KSubjectExtraHeightBottom; |
|
521 |
ms.iAttachmentExtraHeightBottom = KAttachmentExtraHeightBottom; |
|
522 |
ms.iIconMarginPriorityVertical = KIconMarginPriorityVertical; |
|
523 |
ms.iIconMarginFollowUpVertical = KIconMarginFollowUpVertical; |
|
524 |
ms.iIconMarginAttachmentVertical = KIconMarginAttachmentVertical; |
|
525 |
ms.iLabelFontHeightPx = KLabelFontHeightPx; |
|
526 |
ms.iEditorFontHeightPx = KEditorFontHeightPx; |
|
527 |
} |
|
528 |
break; |
|
529 |
case EAknUiZoomSmall: case EAknUiZoomVerySmall: |
|
530 |
{ |
|
531 |
ms.iAifHeight = KAifHeightSmall; |
|
532 |
ms.iAifLabelMarginVertical = KAifLabelMarginVerticalSmall; |
|
533 |
ms.iAifEditorMarginVertical = KAifEditorMarginVerticalSmall; |
|
534 |
ms.iAifEditorHeight = KAifEditorHeightSmall; |
|
535 |
ms.iSubjectExtraHeightBottom = KSubjectExtraHeightBottomSmall; |
|
536 |
ms.iAttachmentExtraHeightBottom = |
|
537 |
KAttachmentExtraHeightBottomSmall; |
|
538 |
ms.iIconMarginPriorityVertical = KIconMarginPriorityVerticalSmall; |
|
539 |
ms.iIconMarginFollowUpVertical = KIconMarginFollowUpVerticalSmall; |
|
540 |
ms.iIconMarginAttachmentVertical = |
|
541 |
KIconMarginAttachmentVerticalSmall; |
|
542 |
ms.iLabelFontHeightPx = KLabelFontHeightPxSmall; |
|
543 |
ms.iEditorFontHeightPx = KEditorFontHeightPxSmall; |
|
544 |
} |
|
545 |
break; |
|
546 |
case EAknUiZoomLarge: case EAknUiZoomVeryLarge: |
|
547 |
{ |
|
548 |
ms.iAifHeight = KAifHeightLarge; |
|
549 |
ms.iAifLabelMarginVertical = KAifLabelMarginVerticalLarge; |
|
550 |
ms.iAifEditorMarginVertical = KAifEditorMarginVerticalLarge; |
|
551 |
ms.iAifEditorHeight = KAifEditorHeightLarge; |
|
552 |
ms.iSubjectExtraHeightBottom = KSubjectExtraHeightBottomLarge; |
|
553 |
ms.iAttachmentExtraHeightBottom = |
|
554 |
KAttachmentExtraHeightBottomLarge; |
|
555 |
ms.iIconMarginPriorityVertical = KIconMarginPriorityVerticalLarge; |
|
556 |
ms.iIconMarginFollowUpVertical = KIconMarginFollowUpVerticalLarge; |
|
557 |
ms.iIconMarginAttachmentVertical = |
|
558 |
KIconMarginAttachmentVerticalLarge; |
|
559 |
ms.iLabelFontHeightPx = KLabelFontHeightPxLarge; |
|
560 |
ms.iEditorFontHeightPx = KEditorFontHeightPxLarge; |
|
561 |
} |
|
562 |
break; |
|
563 |
} |
|
564 |
||
565 |
return ms; |
|
566 |
} |
|
567 |
||
568 |
// ----------------------------------------------------------------------------- |
|
569 |
// NcsUtility::GetNearestFontL |
|
570 |
// ----------------------------------------------------------------------------- |
|
571 |
// |
|
572 |
CFont* NcsUtility::GetNearestFontL( TInt aLogicalFontId, TInt aHeightPixels ) |
|
573 |
{ |
|
574 |
FUNC_LOG; |
|
575 |
||
576 |
// Base the font on logical font passed to us |
|
577 |
const CFont* logicalFont = AknLayoutUtils::FontFromId( aLogicalFontId ); |
|
578 |
// Note: This font is owned by the application's system font array (where |
|
579 |
// it is likely already to have been created) and does not need to be |
|
580 |
// released. It can just go out of scope. |
|
581 |
||
582 |
// Extract font information |
|
583 |
TFontSpec fontSpec = logicalFont->FontSpecInTwips(); |
|
584 |
||
585 |
// Desired height, weight, and posture |
|
586 |
CWsScreenDevice& screenDev = *( CEikonEnv::Static()->ScreenDevice() ); |
|
587 |
fontSpec.iHeight = screenDev.VerticalPixelsToTwips( aHeightPixels ); |
|
588 |
fontSpec.iFontStyle.SetStrokeWeight( EStrokeWeightNormal ); |
|
589 |
fontSpec.iFontStyle.SetPosture( EPostureUpright ); |
|
590 |
||
591 |
// Obtain new font |
|
592 |
CFont* font; |
|
593 |
||
594 |
TInt err = screenDev.GetNearestFontInTwips( font, fontSpec ); |
|
595 |
User::LeaveIfError( err ); |
|
596 |
||
597 |
return font; |
|
598 |
// Font is now usable. Must be released before application |
|
599 |
// exit using CWsScreenDevice::ReleaseFont() |
|
600 |
} |
|
601 |
||
602 |
// <cmail> Platform layout change |
|
603 |
// ----------------------------------------------------------------------------- |
|
604 |
// NcsUtility::GetLayoutFont |
|
605 |
// ----------------------------------------------------------------------------- |
|
606 |
// |
|
607 |
const CFont* NcsUtility::GetLayoutFont( |
|
608 |
const TRect& aParent, TNcsLayoutFont aUsage ) |
|
609 |
{ |
|
610 |
FUNC_LOG; |
|
611 |
TAknLayoutText layoutText; |
|
612 |
switch (aUsage) |
|
613 |
{ |
|
614 |
case ENcsHeaderCaptionFont: |
|
615 |
{ |
|
616 |
layoutText.LayoutText(aParent, AknLayoutScalable_Apps::list_single_cmail_header_caption_pane_t1()); |
|
617 |
break; |
|
618 |
} |
|
619 |
case ENcsHeaderDetailFont: |
|
620 |
{ |
|
621 |
layoutText.LayoutText(aParent, AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_t1(0)); |
|
622 |
break; |
|
623 |
} |
|
624 |
case ENcsBodytextFont: |
|
625 |
{ |
|
626 |
layoutText.LayoutText(aParent, AknLayoutScalable_Apps::list_cmail_body_pane_t1()); |
|
627 |
break; |
|
628 |
} |
|
629 |
} |
|
630 |
return layoutText.Font(); |
|
631 |
} |
|
632 |
// </cmail> |
|
633 |
||
634 |
// ----------------------------------------------------------------------------- |
|
635 |
// NcsUtility::IsEditReplyForwardQuoteSupported |
|
636 |
// ----------------------------------------------------------------------------- |
|
637 |
// |
|
638 |
TBool NcsUtility::IsReplyForwardQuoteReadOnly( const CFSMailBox& aMailBox ) |
|
639 |
{ |
|
640 |
FUNC_LOG; |
|
641 |
TBool r = aMailBox.HasCapability( EFSMBoxCapaReadOnlySmartQuote ); |
|
642 |
return r; |
|
643 |
} |
|
644 |
||
645 |
// ----------------------------------------------------------------------------- |
|
646 |
// NcsUtility::FindFirstPrintableCharIndex |
|
647 |
// ----------------------------------------------------------------------------- |
|
648 |
// |
|
649 |
TInt NcsUtility::FindFirstPrintableCharIndex( const TDesC& aText ) |
|
650 |
{ |
|
651 |
FUNC_LOG; |
|
652 |
for ( TInt i=0; i<aText.Length(); i++ ) |
|
653 |
{ |
|
654 |
TChar c = aText[i]; |
|
655 |
if ( c.IsGraph() ) |
|
656 |
{ |
|
657 |
return i; |
|
658 |
} |
|
659 |
else |
|
660 |
{ |
|
661 |
continue; |
|
662 |
} |
|
663 |
} |
|
664 |
return KErrNotFound; |
|
665 |
} |
|
666 |
||
667 |
// ----------------------------------------------------------------------------- |
|
668 |
// NcsUtility::ConvertCharacters |
|
669 |
// ----------------------------------------------------------------------------- |
|
670 |
// |
|
671 |
void NcsUtility::ConvertCharacters( TDes& aBuffer, TUint16 aFrom, TUint16 aTo ) |
|
672 |
{ |
|
673 |
FUNC_LOG; |
|
674 |
for ( TInt i=0; i<aBuffer.Length(); i++ ) |
|
675 |
{ |
|
676 |
if ( aBuffer[i] == aFrom ) |
|
677 |
{ |
|
678 |
aBuffer[i] = aTo; |
|
679 |
} |
|
680 |
} |
|
681 |
} |
|
682 |
||
683 |
// ----------------------------------------------------------------------------- |
|
684 |
// NcsUtility::ConvertLineEndingsL |
|
685 |
// ----------------------------------------------------------------------------- |
|
686 |
// |
|
687 |
void NcsUtility::ConvertLineEndingsL( HBufC*& aBuffer ) |
|
688 |
{ |
|
689 |
FUNC_LOG; |
|
690 |
// find line ending positions |
|
691 |
RArray<TInt> positions; |
|
692 |
CleanupClosePushL( positions ); |
|
693 |
for ( TInt i=0; i<aBuffer->Length(); i++ ) |
|
694 |
{ |
|
695 |
if ( (*aBuffer)[i] == (TInt32)CEditableText::EParagraphDelimiter ) |
|
696 |
{ |
|
697 |
positions.Append( i ); |
|
698 |
} |
|
699 |
} |
|
700 |
||
701 |
// case when there are no line endings can be early exited |
|
702 |
if ( positions.Count() <= 0 ) |
|
703 |
{ |
|
704 |
CleanupStack::PopAndDestroy( &positions ); |
|
705 |
return; |
|
706 |
} |
|
707 |
||
708 |
// we need to do the conversion |
|
709 |
// initialize |
|
710 |
const TChar KCR = 0x0D; |
|
711 |
const TChar KLF = 0x0A; |
|
712 |
TInt startPos = 0; |
|
713 |
TInt length = 0; |
|
714 |
||
715 |
// create destination buffer |
|
716 |
HBufC* newBuffer = HBufC::NewL( aBuffer->Length() + positions.Count() * 2 ); |
|
717 |
TPtr dstPtr = newBuffer->Des(); |
|
718 |
||
719 |
// do the conversion |
|
720 |
for ( TInt i=0; i<positions.Count(); i++ ) |
|
721 |
{ |
|
722 |
// copy text, no line ending |
|
723 |
length = positions[i] - startPos; |
|
724 |
TPtrC16 srcPtr = aBuffer->Mid( startPos, length ); |
|
725 |
dstPtr.Append( srcPtr ); |
|
726 |
startPos = positions[i] + 1; |
|
727 |
// append line ending |
|
728 |
dstPtr.Append( KCR ); |
|
729 |
dstPtr.Append( KLF ); |
|
730 |
} |
|
731 |
// handle the text piece after last line ending if there is such |
|
732 |
const TInt lastPos = positions[ positions.Count() - 1 ]; |
|
733 |
const TInt high = aBuffer->Length() - 1; |
|
734 |
if ( lastPos < high ) |
|
735 |
{ |
|
736 |
const TInt start = lastPos + 1; |
|
737 |
TPtrC16 srcPtr = aBuffer->Mid( start, aBuffer->Length() - start ); |
|
738 |
dstPtr.Append( srcPtr ); |
|
739 |
} |
|
740 |
// delete old buffer and give pointer to new one |
|
741 |
delete aBuffer; |
|
742 |
aBuffer = newBuffer; |
|
743 |
CleanupStack::PopAndDestroy( &positions ); |
|
744 |
} |
|
745 |
||
746 |
// ----------------------------------------------------------------------------- |
|
747 |
// NcsUtility::DeleteMessage |
|
748 |
// ----------------------------------------------------------------------------- |
|
749 |
// |
|
750 |
TInt NcsUtility::DeleteMessage( CFSMailClient& aMailClient, |
|
751 |
const TFSMailMsgId& aMailBoxId, |
|
752 |
const TFSMailMsgId& aFolderId, |
|
753 |
const TFSMailMsgId& aMsgId ) |
|
754 |
{ |
|
755 |
FUNC_LOG; |
|
756 |
RArray<TFSMailMsgId> msgIds; |
|
757 |
TInt error = msgIds.Append( aMsgId ); |
|
758 |
if ( error == KErrNone ) |
|
759 |
{ |
|
760 |
TRAP( error, aMailClient.DeleteMessagesByUidL( aMailBoxId, aFolderId, |
|
761 |
msgIds ) ); |
|
762 |
} |
|
763 |
msgIds.Close(); |
|
764 |
return error; |
|
765 |
} |
|
766 |
||
767 |
// ----------------------------------------------------------------------------- |
|
768 |
// NcsUtility::HeaderCaptionPaneRect |
|
769 |
// ----------------------------------------------------------------------------- |
|
770 |
// |
|
771 |
TRect NcsUtility::HeaderCaptionPaneRect( const TRect& aParent ) |
|
772 |
{ |
|
773 |
FUNC_LOG; |
|
774 |
TAknLayoutRect headerCaptionPaneRect; |
|
775 |
headerCaptionPaneRect.LayoutRect( aParent, AknLayoutScalable_Apps::list_single_cmail_header_caption_pane() ); |
|
776 |
return headerCaptionPaneRect.Rect(); |
|
777 |
} |
|
778 |
||
779 |
// ----------------------------------------------------------------------------- |
|
780 |
// NcsUtility::HeaderDetailPaneRect |
|
781 |
// ----------------------------------------------------------------------------- |
|
782 |
// |
|
783 |
TRect NcsUtility::HeaderDetailPaneRect( |
|
784 |
const TRect& aParent, const TInt aRows, TBool aSameRow ) |
|
785 |
{ |
|
786 |
FUNC_LOG; |
|
787 |
const TInt variety( aRows == 1 ? 0 : 1 ); |
|
788 |
TAknLayoutRect headerDetailPaneRect; |
|
789 |
headerDetailPaneRect.LayoutRect( aParent, AknLayoutScalable_Apps::list_single_cmail_header_detail_pane( variety ) ); |
|
790 |
TRect result( headerDetailPaneRect.Rect() ); |
|
791 |
if (!aSameRow) |
|
792 |
{ |
|
793 |
result.Move( 0, HeaderCaptionPaneRect( aParent ).Height() ); |
|
794 |
} |
|
795 |
return result; |
|
796 |
} |
|
797 |
||
798 |
// ----------------------------------------------------------------------------- |
|
799 |
// NcsUtility::HeaderDetailIconRect |
|
800 |
// ----------------------------------------------------------------------------- |
|
801 |
// |
|
802 |
TRect NcsUtility::HeaderDetailIconRect( |
|
803 |
const TRect& aParent, const TInt aRows, const THeaderDetailIcon aIcon ) |
|
804 |
{ |
|
805 |
FUNC_LOG; |
|
806 |
const TInt variety( aRows == 1 ? 0 : 1 ); |
|
807 |
TAknLayoutRect headerIconRect; |
|
808 |
headerIconRect.LayoutRect( aParent, |
|
809 |
aIcon == EIconFront ? |
|
810 |
AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_g1( variety ) : |
|
811 |
AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_g2( variety ) ); |
|
812 |
// Offset detail rect by header caption pane height |
|
813 |
TRect result( headerIconRect.Rect() ); |
|
814 |
//result.Move( 0, HeaderCaptionPaneRect( aParent ).Height() ); |
|
815 |
return result; |
|
816 |
} |
|
817 |
||
818 |
// ----------------------------------------------------------------------------- |
|
819 |
// NcsUtility::ListscrollPaneRect |
|
820 |
// ----------------------------------------------------------------------------- |
|
821 |
TRect NcsUtility::ListscrollPaneRect() |
|
822 |
{ |
|
823 |
FUNC_LOG; |
|
824 |
TRect mainPaneRect; |
|
825 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); |
|
826 |
TAknLayoutRect listRect; |
|
827 |
listRect.LayoutRect( mainPaneRect, AknLayoutScalable_Apps::main_sp_fs_listscroll_pane_te() ); |
|
828 |
return listRect.Rect(); |
|
829 |
} |
|
830 |
||
831 |
// ----------------------------------------------------------------------------- |
|
832 |
// NcsUtility::ListCmailPaneRect |
|
833 |
// ----------------------------------------------------------------------------- |
|
834 |
// |
|
835 |
TRect NcsUtility::ListCmailPaneRect( const TRect& aParent ) |
|
836 |
{ |
|
837 |
FUNC_LOG; |
|
838 |
TAknLayoutRect listCmailPaneRect; |
|
839 |
listCmailPaneRect.LayoutRect( aParent, AknLayoutScalable_Apps::list_cmail_pane() ); |
|
840 |
return listCmailPaneRect.Rect(); |
|
841 |
} |
|
842 |
||
843 |
// ----------------------------------------------------------------------------- |
|
844 |
// NcsUtility::ListCmailScrollbarRect |
|
845 |
// ----------------------------------------------------------------------------- |
|
846 |
// |
|
847 |
TRect NcsUtility::ListCmailScrollbarRect( const TRect& aParent ) |
|
848 |
{ |
|
849 |
FUNC_LOG; |
|
850 |
TAknLayoutRect listCmailPaneRect; |
|
851 |
listCmailPaneRect.LayoutRect( aParent, AknLayoutScalable_Apps::sp_fs_scroll_pane_cp03() ); |
|
852 |
return listCmailPaneRect.Rect(); |
|
853 |
} |
|
854 |
||
855 |
// ----------------------------------------------------------------------------- |
|
856 |
// NcsUtility::SeparatorSizeInThisResolution |
|
857 |
// |
|
858 |
// Returns size of empty space between header and message body |
|
859 |
// ----------------------------------------------------------------------------- |
|
860 |
// |
|
861 |
TSize NcsUtility::SeparatorSizeInThisResolution() |
|
862 |
{ |
|
863 |
FUNC_LOG; |
|
864 |
||
865 |
TRect mainPaneRect; |
|
866 |
AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); |
|
867 |
||
868 |
TAknLayoutRect listRect; |
|
869 |
listRect.LayoutRect(mainPaneRect, AknLayoutScalable_Apps::list_cmail_pane()); |
|
870 |
||
871 |
TAknLayoutRect bodyRect; |
|
872 |
bodyRect.LayoutRect(listRect.Rect(), AknLayoutScalable_Apps::list_cmail_body_pane()); |
|
873 |
||
874 |
TRect rect( bodyRect.Rect() ); |
|
875 |
rect.Shrink( 0, bodyRect.Rect().Height() / 4 ); |
|
876 |
return rect.Size(); |
|
877 |
} |
|
878 |
||
879 |
||
880 |
||
881 |
// ----------------------------------------------------------------------------- |
|
882 |
// NcsUtility::SeparatorLineColor |
|
883 |
// ----------------------------------------------------------------------------- |
|
884 |
// |
|
885 |
TRgb NcsUtility::SeparatorLineColor() |
|
886 |
{ |
|
887 |
FUNC_LOG; |
|
888 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
889 |
TRgb rgb; |
|
890 |
if (AknsUtils::GetCachedColor( skin, rgb, |
|
891 |
KAknsIIDQsnLineColors, EAknsCIQsnLineColorsCG6) != KErrNone ) |
|
892 |
{ |
|
893 |
rgb = KRgbBlack; |
|
894 |
} |
|
895 |
||
896 |
return rgb; |
|
897 |
} |
|
898 |
||
899 |
// ----------------------------------------------------------------------------- |
|
900 |
// NcsUtility::ComposerLeftMarginInPixels |
|
901 |
// |
|
902 |
// Left margin value for additional graphics in composer view |
|
903 |
// ----------------------------------------------------------------------------- |
|
904 |
// |
|
905 |
TInt NcsUtility::ComposerLeftMarginInPixels( const TRect& aParent ) |
|
906 |
{ |
|
907 |
FUNC_LOG; |
|
908 |
const TRect cmailPaneRect( ListCmailPaneRect( aParent ) ); |
|
909 |
TAknLayoutRect layoutRect; |
|
910 |
layoutRect.LayoutRect( cmailPaneRect, AknLayoutScalable_Apps::list_single_cmail_header_caption_pane() ); |
|
911 |
TAknLayoutText captionTextRect; |
|
912 |
captionTextRect.LayoutText( layoutRect.Rect(), AknLayoutScalable_Apps::list_single_cmail_header_caption_pane_t1() ); |
|
913 |
return Abs( cmailPaneRect.iTl.iX - captionTextRect.TextRect().iTl.iX ); |
|
914 |
} |
|
915 |
||
916 |
// ----------------------------------------------------------------------------- |
|
917 |
// NcsUtility::ComposerRightMarginInPixels |
|
918 |
// |
|
919 |
// Right margin value for additional graphics in composer view |
|
920 |
// ----------------------------------------------------------------------------- |
|
921 |
// |
|
922 |
TInt NcsUtility::ComposerRightMarginInPixels( const TRect& aParent ) |
|
923 |
{ |
|
924 |
FUNC_LOG; |
|
925 |
const TRect cmailPaneRect( ListCmailPaneRect( aParent ) ); |
|
926 |
TAknLayoutRect layoutRect; |
|
927 |
layoutRect.LayoutRect( cmailPaneRect, AknLayoutScalable_Apps::list_single_cmail_header_caption_pane() ); |
|
928 |
TAknLayoutText captionTextRect; |
|
929 |
captionTextRect.LayoutText( layoutRect.Rect(), AknLayoutScalable_Apps::list_single_cmail_header_caption_pane_t1() ); |
|
930 |
return Abs( cmailPaneRect.iBr.iX - captionTextRect.TextRect().iBr.iX ); |
|
931 |
} |
|
932 |
||
933 |
// ----------------------------------------------------------------------------- |
|
934 |
// NcsUtility::ListCmailBodyPaneRect |
|
935 |
// ----------------------------------------------------------------------------- |
|
936 |
// |
|
937 |
TRect NcsUtility::ListCmailBodyPaneRect( const TRect& aParent ) |
|
938 |
{ |
|
939 |
FUNC_LOG; |
|
940 |
TAknLayoutRect listCmailBodyRect; |
|
941 |
listCmailBodyRect.LayoutRect( aParent, AknLayoutScalable_Apps::list_cmail_body_pane() ); |
|
942 |
return listCmailBodyRect.Rect(); |
|
943 |
} |
|
944 |
||
945 |
// ----------------------------------------------------------------------------- |
|
946 |
// NcsUtility::LayoutCaptionLabel |
|
947 |
// ----------------------------------------------------------------------------- |
|
948 |
// |
|
949 |
void NcsUtility::LayoutCaptionLabel( CEikLabel* aLabel, const TRect& aParentRect ) |
|
950 |
{ |
|
951 |
FUNC_LOG; |
|
952 |
AknLayoutUtils::LayoutLabel( |
|
953 |
aLabel, NcsUtility::HeaderCaptionPaneRect( aParentRect ), |
|
954 |
AknLayoutScalable_Apps::list_single_cmail_header_caption_pane_t1().LayoutLine() ); |
|
955 |
} |
|
956 |
||
957 |
// ----------------------------------------------------------------------------- |
|
958 |
// NcsUtility::LayoutCaptionLabel |
|
959 |
// ----------------------------------------------------------------------------- |
|
960 |
// |
|
961 |
void NcsUtility::LayoutCaptionButton( |
|
962 |
CAknButton* aButton, const TRect& aParentRect) |
|
963 |
{ |
|
964 |
FUNC_LOG; |
|
965 |
TAknLayoutText layoutText; |
|
966 |
||
967 |
const TInt labelVariety = 2; |
|
968 |
TAknTextComponentLayout textComponentLayout; |
|
969 |
TAknLayoutRect layoutRect; |
|
970 |
TRect rect; |
|
971 |
||
972 |
TInt fontId; |
|
973 |
TInt topMargin; |
|
974 |
TInt bottomMargin; |
|
975 |
||
976 |
// Getting editor's top and bottom margin from its layout |
|
977 |
textComponentLayout = |
|
978 |
AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_t1( |
|
979 |
KHeaderDetailTextPaneVariety ); |
|
980 |
fontId = textComponentLayout.LayoutLine().FontId(); |
|
981 |
||
982 |
TAknTextDecorationMetrics metrics( fontId ); |
|
983 |
metrics.GetTopAndBottomMargins( topMargin, bottomMargin ); |
|
984 |
||
985 |
layoutRect.LayoutRect( |
|
986 |
HeaderDetailPaneRect( aParentRect, 1, ETrue ), |
|
987 |
AknLayoutScalable_Apps::bg_button_pane_cp12() ); |
|
988 |
||
989 |
textComponentLayout = |
|
990 |
AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_t2( |
|
991 |
labelVariety ); |
|
992 |
layoutText.LayoutText( |
|
993 |
HeaderDetailPaneRect( aParentRect, 1, ETrue ), |
|
994 |
textComponentLayout.LayoutLine() ); |
|
995 |
||
996 |
rect = layoutRect.Rect(); |
|
997 |
rect.iTl.iY -= topMargin + bottomMargin; |
|
998 |
||
999 |
aButton->SetRect( rect ); |
|
1000 |
aButton->SetTextFont( layoutText.Font() ); |
|
1001 |
aButton->SetTextHorizontalAlignment( layoutText.Align() ); |
|
1002 |
TMargins8 margs( 0, 0, 5, 0 ); |
|
1003 |
aButton->SetMargins( margs ); |
|
1004 |
} |
|
1005 |
||
1006 |
// ----------------------------------------------------------------------------- |
|
1007 |
// NcsUtility::LayoutDetailLabel |
|
1008 |
// ----------------------------------------------------------------------------- |
|
1009 |
// |
|
1010 |
void NcsUtility::LayoutDetailLabel( |
|
1011 |
CEikLabel* aLabel, const TRect& aParentRect, TInt aRow) |
|
1012 |
{ |
|
1013 |
FUNC_LOG; |
|
1014 |
TRect rect( NcsUtility::HeaderDetailPaneRect( aParentRect, 1, ETrue ) ); |
|
1015 |
rect.Move( 0, aRow*rect.Height() ); |
|
1016 |
AknLayoutUtils::LayoutLabel( aLabel, rect, AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_t1( 0 ).LayoutLine() ); |
|
1017 |
} |
|
1018 |
||
1019 |
// ----------------------------------------------------------------------------- |
|
1020 |
// NcsUtility::LayoutDetailEdwin |
|
1021 |
// ----------------------------------------------------------------------------- |
|
1022 |
// |
|
1023 |
void NcsUtility::LayoutDetailEdwin( |
|
1024 |
CEikEdwin* aEdwin, const TRect& aParentRect, |
|
1025 |
const TInt aLineCount, const TBool aBackIcon ) |
|
1026 |
{ |
|
1027 |
FUNC_LOG; |
|
1028 |
TAknMultiLineTextLayout edwinLayout; |
|
1029 |
const TInt textPaneVariety( aBackIcon ? 1 : 3 ); |
|
1030 |
TAknTextComponentLayout textLayout( AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_t1( textPaneVariety ) ); |
|
1031 |
RArray< TAknTextComponentLayout > edwinLayoutLines; |
|
1032 |
TAknTextComponentLayout textRowLayout; |
|
1033 |
TAknWindowComponentLayout headerDetailPane( AknLayoutScalable_Apps::list_single_cmail_header_detail_pane( 0, 0, 0 ) ); |
|
1034 |
for ( TInt line = 0; line < aLineCount; line++ ) |
|
1035 |
{ |
|
1036 |
textRowLayout = TAknWindowComponentLayout::ComposeText( TAknWindowComponentLayout::MultiLineY( headerDetailPane, line, 0 ), textLayout ); |
|
1037 |
edwinLayoutLines.Append( textRowLayout ); |
|
1038 |
} |
|
1039 |
AknLayoutUtils::LayoutEdwin( aEdwin, NcsUtility::HeaderDetailPaneRect( aParentRect, aLineCount ), TAknTextComponentLayout::Multiline( edwinLayoutLines ) ); |
|
1040 |
edwinLayoutLines.Reset(); |
|
1041 |
} |
|
1042 |
||
1043 |
// ----------------------------------------------------------------------------- |
|
1044 |
// NcsUtility::LayoutDetailEdwin |
|
1045 |
// ----------------------------------------------------------------------------- |
|
1046 |
// |
|
1047 |
void NcsUtility::LayoutDetailEdwinTouch( |
|
1048 |
CEikEdwin* aEdwin, const TRect& aParentRect, |
|
1049 |
const TInt aLineCount, const TBool /*aBackIcon*/ ) |
|
1050 |
{ |
|
1051 |
FUNC_LOG; |
|
1052 |
TAknMultiLineTextLayout edwinLayout; |
|
1053 |
TAknTextComponentLayout textLayout( AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_t1( KHeaderDetailTextPaneVariety ) ); |
|
1054 |
RArray< TAknTextComponentLayout > edwinLayoutLines; |
|
1055 |
TAknTextComponentLayout textRowLayout; |
|
1056 |
TAknWindowComponentLayout headerDetailPane( AknLayoutScalable_Apps::list_single_cmail_header_detail_pane( 0, 0, 0 ) ); |
|
1057 |
for ( TInt line = 0; line < aLineCount; line++ ) |
|
1058 |
{ |
|
1059 |
textRowLayout = TAknWindowComponentLayout::ComposeText( TAknWindowComponentLayout::MultiLineY( headerDetailPane, line, 0 ), textLayout ); |
|
1060 |
edwinLayoutLines.Append( textRowLayout ); |
|
1061 |
} |
|
1062 |
AknLayoutUtils::LayoutEdwin( aEdwin, NcsUtility::HeaderDetailPaneRect( aParentRect, aLineCount, ETrue ), TAknTextComponentLayout::Multiline( edwinLayoutLines ) ); |
|
1063 |
edwinLayoutLines.Reset(); |
|
1064 |
} |
|
1065 |
||
1066 |
// ----------------------------------------------------------------------------- |
|
1067 |
// NcsUtility::HeaderControlPosition |
|
1068 |
// ----------------------------------------------------------------------------- |
|
1069 |
// |
|
1070 |
TPoint NcsUtility::HeaderControlPosition( |
|
1071 |
const TRect& aParentRect, const TInt aCurrentLine ) |
|
1072 |
{ |
|
1073 |
FUNC_LOG; |
|
1074 |
TAknLayoutRect detailPane; |
|
1075 |
TAknWindowComponentLayout headerDetailPane( AknLayoutScalable_Apps::list_single_cmail_header_detail_pane( 0, 0, 0 ) ); |
|
1076 |
detailPane.LayoutRect( aParentRect, TAknWindowComponentLayout::MultiLineY( headerDetailPane, aCurrentLine, 0 ) ); |
|
1077 |
return detailPane.Rect().iTl; |
|
1078 |
} |
|
1079 |
||
1080 |
// ----------------------------------------------------------------------------- |
|
1081 |
// NcsUtility::LayoutHeaderControl |
|
1082 |
// ----------------------------------------------------------------------------- |
|
1083 |
// |
|
1084 |
void NcsUtility::LayoutHeaderControl( |
|
1085 |
CCoeControl* aControl, const TRect& aParentRect, |
|
1086 |
const TInt aCurrentLine, const TInt aNumberOfLines ) |
|
1087 |
{ |
|
1088 |
FUNC_LOG; |
|
1089 |
TAknLayoutRect detailPane; |
|
1090 |
TAknWindowComponentLayout headerDetailPane( AknLayoutScalable_Apps::list_single_cmail_header_detail_pane( 0, 0, 0 ) ); |
|
1091 |
detailPane.LayoutRect( aParentRect, TAknWindowComponentLayout::MultiLineY( headerDetailPane, aCurrentLine, 0 ) ); |
|
1092 |
TRect rect( detailPane.Rect() ); |
|
1093 |
rect.SetHeight( rect.Height() * aNumberOfLines ); |
|
1094 |
aControl->SetRect( rect ); |
|
1095 |
} |
|
1096 |
||
1097 |
// ----------------------------------------------------------------------------- |
|
1098 |
// NcsUtility::LayoutBodyEdwin |
|
1099 |
// ----------------------------------------------------------------------------- |
|
1100 |
// |
|
1101 |
void NcsUtility::LayoutBodyEdwin( |
|
1102 |
CEikEdwin* aEdwin, const TRect& aParentRect, const TInt aCurrentLine, |
|
1103 |
const TInt aNumberOfLines, TInt& aSeparatorYPosition ) |
|
1104 |
{ |
|
1105 |
FUNC_LOG; |
|
1106 |
TAknMultiLineTextLayout edwinLayout; |
|
1107 |
TAknTextComponentLayout textLayout( AknLayoutScalable_Apps::list_cmail_body_pane_t1() ); |
|
1108 |
RArray< TAknTextComponentLayout > edwinLayoutLines; |
|
1109 |
TAknTextComponentLayout textRowLayout; |
|
1110 |
TAknWindowComponentLayout headerCaptionPane( AknLayoutScalable_Apps::list_single_cmail_header_caption_pane( 0, 0, 0 ) ); |
|
1111 |
TInt lines = Max( aNumberOfLines, 2 ); |
|
1112 |
for ( TInt line = 0; line < lines; line++ ) |
|
1113 |
{ |
|
1114 |
textRowLayout = TAknWindowComponentLayout::ComposeText( TAknWindowComponentLayout::MultiLineY( headerCaptionPane, line, 0 ), textLayout ); |
|
1115 |
edwinLayoutLines.Append( textRowLayout ); |
|
1116 |
} |
|
1117 |
TAknLayoutRect bodyPane; |
|
1118 |
bodyPane.LayoutRect( aParentRect, AknLayoutScalable_Apps::list_cmail_body_pane() ); |
|
1119 |
TRect bodyRect( bodyPane.Rect() ); |
|
1120 |
TAknLayoutRect detailPane; |
|
1121 |
TAknWindowComponentLayout headerDetailPane( AknLayoutScalable_Apps::list_single_cmail_header_detail_pane( 0, 0, 0 ) ); |
|
1122 |
detailPane.LayoutRect( aParentRect, TAknWindowComponentLayout::MultiLineY( headerDetailPane, aCurrentLine, 0 ) ); |
|
1123 |
bodyRect = TRect( detailPane.Rect().iTl, bodyRect.Size() ); |
|
1124 |
aSeparatorYPosition = bodyRect.iTl.iY; |
|
1125 |
// Since layout doesn't specify enough space between separator line |
|
1126 |
// and editor, we add some space manually |
|
1127 |
TInt deltaMove = NcsUtility::SeparatorSizeInThisResolution().iHeight; |
|
1128 |
bodyRect.Move( 0, deltaMove ); |
|
1129 |
AknLayoutUtils::LayoutEdwin( aEdwin, bodyRect, TAknTextComponentLayout::Multiline( edwinLayoutLines ), EAknsCIQsnTextColorsCG6 ); |
|
1130 |
edwinLayoutLines.Reset(); |
|
1131 |
} |
|
1132 |
||
1133 |
// ----------------------------------------------------------------------------- |
|
1134 |
// NcsUtility::CalculateSeparatorLineSecondaryColor |
|
1135 |
// |
|
1136 |
// Calculates secondary color value based on the start value. Useful for |
|
1137 |
// gradient drawing. |
|
1138 |
// @param aDegree = color change coefficient |
|
1139 |
// ----------------------------------------------------------------------------- |
|
1140 |
// |
|
1141 |
TRgb NcsUtility::CalculateSeparatorLineSecondaryColor( TInt aDegree, |
|
1142 |
TRgb /*aStartColor*/ ) |
|
1143 |
{ |
|
1144 |
TRgb secondaryColor; |
|
1145 |
TInt redValue; |
|
1146 |
TInt greenValue; |
|
1147 |
TInt blueValue; |
|
1148 |
TRgb startColor = SeparatorLineColor(); |
|
1149 |
if( startColor.Red() > KFSUtilityThresholdColorValue && |
|
1150 |
startColor.Green() > KFSUtilityThresholdColorValue && |
|
1151 |
startColor.Blue() > KFSUtilityThresholdColorValue ) |
|
1152 |
{ |
|
1153 |
//Original color is bright, so let's make secondary color darker |
|
1154 |
redValue = startColor.Red() - ( startColor.Red() / aDegree ); |
|
1155 |
greenValue = startColor.Green() - ( startColor.Green() / aDegree ); |
|
1156 |
blueValue = startColor.Blue() - ( startColor.Blue() / aDegree ); |
|
1157 |
} |
|
1158 |
else |
|
1159 |
{ |
|
1160 |
//Original color is dark, so let's make secondary color brighter |
|
1161 |
//Checking how bright original color is |
|
1162 |
if( startColor.Red() < KFSUtilityThresholdColorMiddleValue && |
|
1163 |
startColor.Green() < KFSUtilityThresholdColorMiddleValue && |
|
1164 |
startColor.Blue() < KFSUtilityThresholdColorMiddleValue ) |
|
1165 |
{ |
|
1166 |
// Calculating new values from the unoccupied color space |
|
1167 |
redValue = startColor.Red() + ( ( |
|
1168 |
KFSUtilityMaxColorValue - startColor.Red() ) / aDegree ); |
|
1169 |
greenValue = startColor.Green() + ( ( |
|
1170 |
KFSUtilityMaxColorValue - startColor.Green() ) / aDegree ); |
|
1171 |
blueValue = startColor.Blue() + ( ( |
|
1172 |
KFSUtilityMaxColorValue - startColor.Blue() ) / aDegree ); |
|
1173 |
} |
|
1174 |
else |
|
1175 |
{ |
|
1176 |
// Calculating new values from the occupied color space |
|
1177 |
redValue = startColor.Red() + ( startColor.Red() / aDegree ); |
|
1178 |
greenValue = startColor.Green() + ( startColor.Green() / aDegree ); |
|
1179 |
blueValue = startColor.Blue() + ( startColor.Blue() / aDegree ); |
|
1180 |
} |
|
1181 |
} |
|
1182 |
||
1183 |
if ( redValue > KFSUtilityMaxColorValue ) |
|
1184 |
{ |
|
1185 |
redValue = KFSUtilityMaxColorValue; |
|
1186 |
} |
|
1187 |
if ( greenValue > KFSUtilityMaxColorValue ) |
|
1188 |
{ |
|
1189 |
greenValue = KFSUtilityMaxColorValue; |
|
1190 |
} |
|
1191 |
if ( blueValue > KFSUtilityMaxColorValue ) |
|
1192 |
{ |
|
1193 |
blueValue = KFSUtilityMaxColorValue; |
|
1194 |
} |
|
1195 |
return TRgb( redValue , greenValue, blueValue ); |
|
1196 |
} |
|
1197 |
||
1198 |
// ----------------------------------------------------------------------------- |
|
1199 |
// NcsUtility::CalculateMsgBodyLineColor |
|
1200 |
// |
|
1201 |
// Calculates line color to be used in message body. Calculated color is darker than |
|
1202 |
// given base color. |
|
1203 |
// @param aDegree = color darkening coefficient |
|
1204 |
// @param aBaseColor = base color to be used in calculation |
|
1205 |
// ----------------------------------------------------------------------------- |
|
1206 |
// |
|
1207 |
TRgb NcsUtility::CalculateMsgBodyLineColor( TInt aDegree, |
|
1208 |
TRgb aBaseColor ) |
|
1209 |
{ |
|
1210 |
TInt redValue = aBaseColor.Red() - ( aBaseColor.Red() / aDegree ); |
|
1211 |
TInt greenValue = aBaseColor.Green() - ( aBaseColor.Green() / aDegree ); |
|
1212 |
TInt blueValue = aBaseColor.Blue() - ( aBaseColor.Blue() / aDegree ); |
|
1213 |
||
1214 |
if ( redValue < KFSUtilityMinColorValue ) |
|
1215 |
{ |
|
1216 |
redValue = KFSUtilityMinColorValue; |
|
1217 |
} |
|
1218 |
if ( greenValue < KFSUtilityMinColorValue ) |
|
1219 |
{ |
|
1220 |
greenValue = KFSUtilityMinColorValue; |
|
1221 |
} |
|
1222 |
if ( blueValue < KFSUtilityMinColorValue ) |
|
1223 |
{ |
|
1224 |
blueValue = KFSUtilityMinColorValue; |
|
1225 |
} |
|
1226 |
||
1227 |
return TRgb( redValue , greenValue, blueValue ); |
|
1228 |
} |
|
1229 |
||
1230 |
//End of file |
|
1231 |