|
1 /* |
|
2 * Copyright (c) 2005-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: Freestyle Email source file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "emailtrace.h" |
|
21 #include <centralrepository.h> |
|
22 #include <e32svr.h> |
|
23 #include <aknnotewrappers.h> // for note |
|
24 |
|
25 #include "FreestyleEmailCenRepHandler.h" |
|
26 #include "FreestyleEmailCenRepKeys.h" |
|
27 |
|
28 // CONSTANTS |
|
29 //_LIT( KFsCrHandlerDelimiter, "," ); |
|
30 //_LIT( KFsCrHandlerEmpty, "" ); |
|
31 //const TInt KFsEmailFileTypesStringLenght = 256; |
|
32 |
|
33 |
|
34 // ============================ MEMBER FUNCTIONS =============================== |
|
35 |
|
36 // ---------------------------------------------------- |
|
37 // CFSEmailCRHandler::CFSEmailCRHandler |
|
38 |
|
39 // Default class constructor. |
|
40 // ---------------------------------------------------- |
|
41 // |
|
42 CFSEmailCRHandler::CFSEmailCRHandler() |
|
43 { |
|
44 FUNC_LOG; |
|
45 } |
|
46 |
|
47 // ---------------------------------------------------- |
|
48 // CFSEmailCRHandler::ConstructL |
|
49 // Second phase class constructor. |
|
50 // ---------------------------------------------------- |
|
51 // |
|
52 void CFSEmailCRHandler::ConstructL() |
|
53 { |
|
54 FUNC_LOG; |
|
55 |
|
56 TRAP_IGNORE( iCentralRepository = CRepository::NewL( KFreestyleEmailCenRep ) ); |
|
57 |
|
58 // has to be trapped because setup wizard is not included in S60 3.1 SDK, |
|
59 // and thus the NewL() would leave with KErrNotFound. |
|
60 TRAP_IGNORE( iSetupWizCentRep = CRepository::NewL( KSetupWizardCenRep ) ); |
|
61 } |
|
62 |
|
63 // ---------------------------------------------------- |
|
64 // CFSEmailCRHandler::NewL |
|
65 // Two-phased class constructor. |
|
66 // Singleton |
|
67 // ---------------------------------------------------- |
|
68 // |
|
69 CFSEmailCRHandler* CFSEmailCRHandler::InstanceL() |
|
70 { |
|
71 FUNC_LOG; |
|
72 CFSEmailCRHandler* singleton = NULL; |
|
73 |
|
74 // Check Thread Local Storage for instance pointer |
|
75 singleton = static_cast<CFSEmailCRHandler*>( UserSvr::DllTls( KTlsHandleCRHandler ) ); |
|
76 if ( !singleton ) |
|
77 { |
|
78 singleton = new ( ELeave ) CFSEmailCRHandler(); |
|
79 CleanupStack::PushL( singleton ); |
|
80 singleton->ConstructL(); |
|
81 CleanupStack::Pop( singleton ); |
|
82 |
|
83 // Store a pointer of a new instance in Thread Local Storage |
|
84 TInt err = UserSvr::DllSetTls( KTlsHandleCRHandler, singleton ); |
|
85 if ( err ) |
|
86 { |
|
87 delete singleton; |
|
88 singleton = NULL; |
|
89 User::Leave( err ); |
|
90 } |
|
91 } |
|
92 return singleton; |
|
93 } |
|
94 |
|
95 // ---------------------------------------------------- |
|
96 // CFSEmailCRHandler::~CFSEmailCRHandler |
|
97 // Destructor of CFSEmailCRHandler class. |
|
98 // ---------------------------------------------------- |
|
99 // |
|
100 CFSEmailCRHandler::~CFSEmailCRHandler() |
|
101 { |
|
102 FUNC_LOG; |
|
103 if( iCentralRepository ) |
|
104 { |
|
105 delete iCentralRepository; |
|
106 iCentralRepository = NULL; |
|
107 } |
|
108 if( iSetupWizCentRep ) |
|
109 { |
|
110 delete iSetupWizCentRep; |
|
111 iSetupWizCentRep = NULL; |
|
112 } |
|
113 UserSvr::DllFreeTls( KTlsHandleCRHandler ); |
|
114 } |
|
115 |
|
116 |
|
117 // ---------------------------------------------------- |
|
118 // CFSEmailCRHandler::WarnBeforeDelete |
|
119 // Returns setting warn before delete from CR |
|
120 // ---------------------------------------------------- |
|
121 // |
|
122 |
|
123 TInt CFSEmailCRHandler::WarnBeforeDelete() |
|
124 { |
|
125 FUNC_LOG; |
|
126 TInt buf; |
|
127 TInt err=KErrNotFound; |
|
128 if ( iCentralRepository ) |
|
129 { |
|
130 err = iCentralRepository->Get( KFreestyleEmailWarnBeforeDelete, buf ); |
|
131 } |
|
132 if ( err != KErrNone ) |
|
133 { |
|
134 buf = KFreestyleEmailWarnBeforeDeleteDefault; |
|
135 } |
|
136 return buf; |
|
137 } |
|
138 |
|
139 // ---------------------------------------------------- |
|
140 // CFSEmailCRHandler::SetMessageHeader |
|
141 // ---------------------------------------------------- |
|
142 // |
|
143 void CFSEmailCRHandler::SetWarnBeforeDelete( TInt aValue ) |
|
144 { |
|
145 FUNC_LOG; |
|
146 if ( iCentralRepository ) |
|
147 { |
|
148 iCentralRepository->Set( KFreestyleEmailWarnBeforeDelete, aValue ); |
|
149 } |
|
150 } |
|
151 |
|
152 /* |
|
153 // ---------------------------------------------------- |
|
154 // CFSEmailCRHandler::SetMessageHeader |
|
155 // ---------------------------------------------------- |
|
156 // |
|
157 void CFSEmailCRHandler::SetMessageHeader( TInt aValue ) |
|
158 { |
|
159 iCentralRepository->Set( KFreestyleEmailMessageHeader, aValue ); |
|
160 } |
|
161 |
|
162 // ---------------------------------------------------- |
|
163 // CFSEmailCRHandler::MessageHeader |
|
164 // ---------------------------------------------------- |
|
165 // |
|
166 TInt CFSEmailCRHandler::MessageHeader() |
|
167 { |
|
168 TInt buf; |
|
169 iCentralRepository->Get( KFreestyleEmailMessageHeader, buf ); |
|
170 return buf; |
|
171 } |
|
172 */ |
|
173 // ---------------------------------------------------- |
|
174 // CFSEmailCRHandler::SetMessageListLayout |
|
175 // ---------------------------------------------------- |
|
176 // |
|
177 void CFSEmailCRHandler::SetMessageListLayout( TInt aValue ) |
|
178 { |
|
179 FUNC_LOG; |
|
180 if ( iCentralRepository ) |
|
181 { |
|
182 iCentralRepository->Set( KFreestyleEmailMessageListLayout, aValue ); |
|
183 } |
|
184 } |
|
185 |
|
186 // ---------------------------------------------------- |
|
187 // CFSEmailCRHandler::MessageListLayout |
|
188 // ---------------------------------------------------- |
|
189 // |
|
190 TInt CFSEmailCRHandler::MessageListLayout() |
|
191 { |
|
192 FUNC_LOG; |
|
193 TInt buf; |
|
194 TInt err=KErrNotFound; |
|
195 |
|
196 if ( iCentralRepository ) |
|
197 { |
|
198 err = iCentralRepository->Get( KFreestyleEmailMessageListLayout, buf ); |
|
199 } |
|
200 if ( err != KErrNone ) |
|
201 { |
|
202 buf = KFreestyleEmailMessageListLayoutDefault; |
|
203 } |
|
204 return buf; |
|
205 } |
|
206 |
|
207 // ---------------------------------------------------- |
|
208 // CFSEmailCRHandler::SetBodyPreview |
|
209 // ---------------------------------------------------- |
|
210 // |
|
211 void CFSEmailCRHandler::SetBodyPreview( TInt aValue ) |
|
212 { |
|
213 FUNC_LOG; |
|
214 if ( iCentralRepository ) |
|
215 { |
|
216 iCentralRepository->Set( KFreestyleEmailBodyPreview, aValue ); |
|
217 } |
|
218 } |
|
219 |
|
220 // ---------------------------------------------------- |
|
221 // CFSEmailCRHandler::BodyPreview |
|
222 // ---------------------------------------------------- |
|
223 // |
|
224 TInt CFSEmailCRHandler::BodyPreview() |
|
225 { |
|
226 FUNC_LOG; |
|
227 TInt buf; |
|
228 TInt err=KErrNotFound; |
|
229 |
|
230 if ( iCentralRepository ) |
|
231 { |
|
232 err = iCentralRepository->Get( KFreestyleEmailBodyPreview, buf ); |
|
233 } |
|
234 if ( err != KErrNone ) |
|
235 { |
|
236 buf = KFreestyleEmailBodyPreviewDefault; |
|
237 } |
|
238 return buf; |
|
239 } |
|
240 |
|
241 // ---------------------------------------------------- |
|
242 // CFSEmailCRHandler::SetTitleDividers |
|
243 // ---------------------------------------------------- |
|
244 // |
|
245 void CFSEmailCRHandler::SetTitleDividers( TInt aValue ) |
|
246 { |
|
247 FUNC_LOG; |
|
248 if ( iCentralRepository ) |
|
249 { |
|
250 iCentralRepository->Set( KFreestyleEmailTitleDividers, aValue ); |
|
251 } |
|
252 } |
|
253 |
|
254 // ---------------------------------------------------- |
|
255 // CFSEmailCRHandler::TitleDividers |
|
256 // ---------------------------------------------------- |
|
257 // |
|
258 TInt CFSEmailCRHandler::TitleDividers() |
|
259 { |
|
260 FUNC_LOG; |
|
261 TInt buf; |
|
262 |
|
263 TInt err=KErrNotFound; |
|
264 |
|
265 if ( iCentralRepository ) |
|
266 { |
|
267 err = iCentralRepository->Get( KFreestyleEmailTitleDividers, buf ); |
|
268 } |
|
269 if ( err != KErrNone ) |
|
270 { |
|
271 buf = KFreestyleEmailTitleDividersDefault; |
|
272 } |
|
273 return buf; |
|
274 } |
|
275 |
|
276 |
|
277 // ---------------------------------------------------- |
|
278 // CFSEmailCRHandler::SetDownloadNotifications |
|
279 // ---------------------------------------------------- |
|
280 // |
|
281 void CFSEmailCRHandler::SetDownloadNotifications( TInt aValue ) |
|
282 { |
|
283 FUNC_LOG; |
|
284 if ( iCentralRepository ) |
|
285 { |
|
286 iCentralRepository->Set( KFreestyleEmailDownloadNotification, aValue ); |
|
287 } |
|
288 } |
|
289 |
|
290 // ---------------------------------------------------- |
|
291 // CFSEmailCRHandler::DownloadNotifications |
|
292 // ---------------------------------------------------- |
|
293 // |
|
294 TInt CFSEmailCRHandler::DownloadNotifications() |
|
295 { |
|
296 FUNC_LOG; |
|
297 TInt buf; |
|
298 |
|
299 TInt err=KErrNotFound; |
|
300 |
|
301 if ( iCentralRepository ) |
|
302 { |
|
303 err = iCentralRepository->Get( KFreestyleEmailDownloadNotification, buf ); |
|
304 } |
|
305 if ( err != KErrNone ) |
|
306 { |
|
307 buf = KFreestyleEmailDownloadNotificationDefault; |
|
308 } |
|
309 return buf; |
|
310 } |
|
311 |
|
312 // ---------------------------------------------------- |
|
313 // CFSEmailCRHandler::SetActiveIdle |
|
314 // ---------------------------------------------------- |
|
315 // |
|
316 void CFSEmailCRHandler::SetActiveIdle( TInt aValue ) |
|
317 { |
|
318 FUNC_LOG; |
|
319 if ( iCentralRepository ) |
|
320 { |
|
321 iCentralRepository->Set( KFreestyleEmailActiveIdle, aValue ); |
|
322 } |
|
323 } |
|
324 |
|
325 // ---------------------------------------------------- |
|
326 // CFSEmailCRHandler::ActiveIdle |
|
327 // ---------------------------------------------------- |
|
328 // |
|
329 TInt CFSEmailCRHandler::ActiveIdle() |
|
330 { |
|
331 FUNC_LOG; |
|
332 TInt buf; |
|
333 |
|
334 TInt err=KErrNotFound; |
|
335 |
|
336 if ( iCentralRepository ) |
|
337 { |
|
338 err = iCentralRepository->Get( KFreestyleEmailActiveIdle, buf ); |
|
339 } |
|
340 if ( err != KErrNone ) |
|
341 { |
|
342 buf = KFreestyleEmailActiveIdleDefault; |
|
343 } |
|
344 return buf; |
|
345 } |
|
346 /* |
|
347 // ---------------------------------------------------- |
|
348 // CFSEmailCRHandler::SetDownloadHTMLImages |
|
349 // ---------------------------------------------------- |
|
350 // |
|
351 void CFSEmailCRHandler::SetDownloadHTMLImages( TInt aValue ) |
|
352 { |
|
353 FUNC_LOG; |
|
354 if ( iCentralRepository ) |
|
355 { |
|
356 iCentralRepository->Set( KFreestyleEmailDownloadHTMLImages, aValue ); |
|
357 } |
|
358 } |
|
359 |
|
360 |
|
361 // ---------------------------------------------------- |
|
362 // CFSEmailCRHandler::DownloadHTMLImages |
|
363 // ---------------------------------------------------- |
|
364 // |
|
365 TInt CFSEmailCRHandler::DownloadHTMLImages() |
|
366 { |
|
367 FUNC_LOG; |
|
368 TInt buf; |
|
369 |
|
370 TInt err=KErrNotFound; |
|
371 |
|
372 if ( iCentralRepository ) |
|
373 { |
|
374 err = iCentralRepository->Get( KFreestyleEmailDownloadHTMLImages, buf ); |
|
375 } |
|
376 if ( err != KErrNone ) |
|
377 { |
|
378 buf = KFreestyleEmailDownloadHTMLImagesDefault; |
|
379 } |
|
380 return buf; |
|
381 } |
|
382 */ |
|
383 /* |
|
384 // ---------------------------------------------------- |
|
385 // CFSEmailCRHandler::AttachmentFileTypes |
|
386 // ---------------------------------------------------- |
|
387 // |
|
388 TInt CFSEmailCRHandler::AttachmentFileTypes() |
|
389 { |
|
390 TInt buf; |
|
391 iCentralRepository->Get( KFreestyleEmailAttachmentFileTypes, buf ); |
|
392 return buf; |
|
393 } |
|
394 |
|
395 // ---------------------------------------------------- |
|
396 // CFSEmailCRHandler::SetAttachmentFileTypes |
|
397 // ---------------------------------------------------- |
|
398 // |
|
399 void CFSEmailCRHandler::SetAttachmentFileTypes( TInt aValue ) |
|
400 { |
|
401 iCentralRepository->Set( KFreestyleEmailAttachmentFileTypes, aValue ); |
|
402 } |
|
403 */ |
|
404 |
|
405 // ---------------------------------------------------- |
|
406 // CFSEmailCRHandler::AttachmentFileTypesArrayL |
|
407 // Array of user defined file types for attachment download |
|
408 // ---------------------------------------------------- |
|
409 // |
|
410 /* |
|
411 void CFSEmailCRHandler::AttachmentFileTypesArray( CDesCArray& aArray ) |
|
412 { |
|
413 TInt position = 0; |
|
414 TPtrC fileType; |
|
415 TBuf<KFsEmailFileTypesStringLenght> buffer; |
|
416 iCentralRepository->Get( KFreestyleEmailAttachmentFileTypesDes, buffer ); |
|
417 |
|
418 while ( (position = buffer.Find( KFsCrHandlerDelimiter )) != KErrNotFound ) |
|
419 { |
|
420 fileType.Set( buffer.Left( position ) ); |
|
421 aArray.AppendL( fileType ); |
|
422 buffer.Replace( 0, position+1, KFsCrHandlerEmpty ); |
|
423 } |
|
424 aArray.AppendL( buffer ); |
|
425 } |
|
426 */ |
|
427 |
|
428 // ---------------------------------------------------- |
|
429 // CFSEmailCRHandler::AttachmentFileTypesDes |
|
430 // String of user defined file types for attachment download |
|
431 // ---------------------------------------------------- |
|
432 // |
|
433 /* |
|
434 void CFSEmailCRHandler::AttachmentFileTypesDes( TDes16& aValue ) |
|
435 { |
|
436 iCentralRepository->Get( KFreestyleEmailAttachmentFileTypesDes, aValue ); |
|
437 } |
|
438 */ |
|
439 |
|
440 // ---------------------------------------------------- |
|
441 // CFSEmailCRHandler::SetAttachmentFileTypesDes |
|
442 // ---------------------------------------------------- |
|
443 // |
|
444 /* |
|
445 void CFSEmailCRHandler::SetAttachmentFileTypesDes( TDesC& aValue ) |
|
446 { |
|
447 iCentralRepository->Set( KFreestyleEmailAttachmentFileTypesDes, aValue ); |
|
448 } |
|
449 */ |
|
450 |
|
451 // ---------------------------------------------------- |
|
452 // CFSEmailCRHandler::EditorCCVisible |
|
453 // ---------------------------------------------------- |
|
454 // |
|
455 TInt CFSEmailCRHandler::EditorCCVisible() |
|
456 { |
|
457 FUNC_LOG; |
|
458 TInt buf; |
|
459 |
|
460 TInt err=KErrNotFound; |
|
461 |
|
462 if ( iCentralRepository ) |
|
463 { |
|
464 err = iCentralRepository->Get( KFreestyleEmailEditorCCVisible, buf ); |
|
465 } |
|
466 if ( err != KErrNone ) |
|
467 { |
|
468 buf = KFreestyleEmailEditorCCVisibleDefault; |
|
469 } |
|
470 return buf; |
|
471 } |
|
472 |
|
473 // ---------------------------------------------------- |
|
474 // CFSEmailCRHandler::SetEditorCCVisible |
|
475 // ---------------------------------------------------- |
|
476 // |
|
477 void CFSEmailCRHandler::SetEditorCCVisible( TInt aValue ) |
|
478 { |
|
479 FUNC_LOG; |
|
480 if ( iCentralRepository ) |
|
481 { |
|
482 iCentralRepository->Set( KFreestyleEmailEditorCCVisible, aValue ); |
|
483 } |
|
484 } |
|
485 |
|
486 // ---------------------------------------------------- |
|
487 // CFSEmailCRHandler::EditorBCVisible |
|
488 // ---------------------------------------------------- |
|
489 // |
|
490 TInt CFSEmailCRHandler::EditorBCVisible() |
|
491 { |
|
492 FUNC_LOG; |
|
493 TInt buf; |
|
494 |
|
495 TInt err=KErrNotFound; |
|
496 |
|
497 if ( iCentralRepository ) |
|
498 { |
|
499 err = iCentralRepository->Get( KFreestyleEmailEditorBCVisible, buf ); |
|
500 } |
|
501 if ( err != KErrNone ) |
|
502 { |
|
503 buf = KFreestyleEmailEditorBCVisibleDefault; |
|
504 } |
|
505 return buf; |
|
506 } |
|
507 |
|
508 // ---------------------------------------------------- |
|
509 // CFSEmailCRHandler::SetEditorBCVisible |
|
510 // ---------------------------------------------------- |
|
511 // |
|
512 void CFSEmailCRHandler::SetEditorBCVisible( TInt aValue ) |
|
513 { |
|
514 FUNC_LOG; |
|
515 if ( iCentralRepository ) |
|
516 { |
|
517 iCentralRepository->Set( KFreestyleEmailEditorBCVisible, aValue ); |
|
518 } |
|
519 } |
|
520 |
|
521 // ---------------------------------------------------- |
|
522 // CFSEmailCRHandler::SetupWizAccountType |
|
523 // ---------------------------------------------------- |
|
524 // |
|
525 TInt CFSEmailCRHandler::SetupWizAccountType( TDes16& aValue ) |
|
526 { |
|
527 FUNC_LOG; |
|
528 if ( iSetupWizCentRep ) |
|
529 { |
|
530 return iSetupWizCentRep->Get( KSetupWizardAccountType, aValue ); |
|
531 } |
|
532 return KErrNotFound; |
|
533 } |
|
534 |
|
535 // ---------------------------------------------------- |
|
536 // CFSEmailCRHandler::SetSetupWizAccountType |
|
537 // ---------------------------------------------------- |
|
538 // |
|
539 /*void CFSEmailCRHandler::SetSetupWizAccountType( const TDesC16& aValue ) |
|
540 { |
|
541 if ( iSetupWizCentRep ) |
|
542 { |
|
543 iSetupWizCentRep->Set( KSetupWizardAccountType, aValue ); |
|
544 } |
|
545 }*/ |
|
546 |
|
547 // ---------------------------------------------------- |
|
548 // CFSEmailCRHandler::SetupWizCentrepStartKey |
|
549 // ---------------------------------------------------- |
|
550 // |
|
551 TInt CFSEmailCRHandler::SetupWizCentrepStartKey( TDes16& aValue ) |
|
552 { |
|
553 FUNC_LOG; |
|
554 if ( iSetupWizCentRep ) |
|
555 { |
|
556 return iSetupWizCentRep->Get( KSetupWizardCentrepStartKey, aValue ); |
|
557 } |
|
558 return KErrNotFound; |
|
559 } |
|
560 |
|
561 // ---------------------------------------------------- |
|
562 // CFSEmailCRHandler::SetSetupWizCentrepStartKey |
|
563 // ---------------------------------------------------- |
|
564 // |
|
565 /*void CFSEmailCRHandler::SetSetupWizCentrepStartKey( const TDesC16& aValue ) |
|
566 { |
|
567 if ( iSetupWizCentRep ) |
|
568 { |
|
569 iSetupWizCentRep->Set( KSetupWizardCentrepStartKey, aValue ); |
|
570 } |
|
571 }*/ |
|
572 |
|
573 /*TUint32*/void CFSEmailCRHandler::ClearWizardParams() |
|
574 { |
|
575 //TUint32 errorKey = 0; |
|
576 //TInt error = iSetupWizCentRep->Delete(KSetupWizardAccountType, 0xFFFFFFFF, errorKey); |
|
577 if( iSetupWizCentRep ) |
|
578 { |
|
579 iSetupWizCentRep->Delete( KSetupWizardAccountType ); |
|
580 } |
|
581 //TInt error = iSetupWizCentRep->Delete(KSetupWizardCentrepStartKey, 0xFFFFFFFF, errorKey); |
|
582 if( iSetupWizCentRep ) |
|
583 { |
|
584 iSetupWizCentRep->Delete( KSetupWizardCentrepStartKey ); |
|
585 } |
|
586 //return errorkey; |
|
587 } |
|
588 |
|
589 // end of file |
|
590 |