|
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 // CFSEmailCRHandler::DownloadHTMLImages |
|
362 // ---------------------------------------------------- |
|
363 // |
|
364 TInt CFSEmailCRHandler::DownloadHTMLImages() |
|
365 { |
|
366 FUNC_LOG; |
|
367 TInt buf; |
|
368 |
|
369 TInt err=KErrNotFound; |
|
370 |
|
371 if ( iCentralRepository ) |
|
372 { |
|
373 err = iCentralRepository->Get( KFreestyleEmailDownloadHTMLImages, buf ); |
|
374 } |
|
375 if ( err != KErrNone ) |
|
376 { |
|
377 buf = KFreestyleEmailDownloadHTMLImagesDefault; |
|
378 } |
|
379 return buf; |
|
380 } |
|
381 |
|
382 /* |
|
383 // ---------------------------------------------------- |
|
384 // CFSEmailCRHandler::AttachmentFileTypes |
|
385 // ---------------------------------------------------- |
|
386 // |
|
387 TInt CFSEmailCRHandler::AttachmentFileTypes() |
|
388 { |
|
389 TInt buf; |
|
390 iCentralRepository->Get( KFreestyleEmailAttachmentFileTypes, buf ); |
|
391 return buf; |
|
392 } |
|
393 |
|
394 // ---------------------------------------------------- |
|
395 // CFSEmailCRHandler::SetAttachmentFileTypes |
|
396 // ---------------------------------------------------- |
|
397 // |
|
398 void CFSEmailCRHandler::SetAttachmentFileTypes( TInt aValue ) |
|
399 { |
|
400 iCentralRepository->Set( KFreestyleEmailAttachmentFileTypes, aValue ); |
|
401 } |
|
402 */ |
|
403 |
|
404 // ---------------------------------------------------- |
|
405 // CFSEmailCRHandler::AttachmentFileTypesArrayL |
|
406 // Array of user defined file types for attachment download |
|
407 // ---------------------------------------------------- |
|
408 // |
|
409 /* |
|
410 void CFSEmailCRHandler::AttachmentFileTypesArray( CDesCArray& aArray ) |
|
411 { |
|
412 TInt position = 0; |
|
413 TPtrC fileType; |
|
414 TBuf<KFsEmailFileTypesStringLenght> buffer; |
|
415 iCentralRepository->Get( KFreestyleEmailAttachmentFileTypesDes, buffer ); |
|
416 |
|
417 while ( (position = buffer.Find( KFsCrHandlerDelimiter )) != KErrNotFound ) |
|
418 { |
|
419 fileType.Set( buffer.Left( position ) ); |
|
420 aArray.AppendL( fileType ); |
|
421 buffer.Replace( 0, position+1, KFsCrHandlerEmpty ); |
|
422 } |
|
423 aArray.AppendL( buffer ); |
|
424 } |
|
425 */ |
|
426 |
|
427 // ---------------------------------------------------- |
|
428 // CFSEmailCRHandler::AttachmentFileTypesDes |
|
429 // String of user defined file types for attachment download |
|
430 // ---------------------------------------------------- |
|
431 // |
|
432 /* |
|
433 void CFSEmailCRHandler::AttachmentFileTypesDes( TDes16& aValue ) |
|
434 { |
|
435 iCentralRepository->Get( KFreestyleEmailAttachmentFileTypesDes, aValue ); |
|
436 } |
|
437 */ |
|
438 |
|
439 // ---------------------------------------------------- |
|
440 // CFSEmailCRHandler::SetAttachmentFileTypesDes |
|
441 // ---------------------------------------------------- |
|
442 // |
|
443 /* |
|
444 void CFSEmailCRHandler::SetAttachmentFileTypesDes( TDesC& aValue ) |
|
445 { |
|
446 iCentralRepository->Set( KFreestyleEmailAttachmentFileTypesDes, aValue ); |
|
447 } |
|
448 */ |
|
449 |
|
450 // ---------------------------------------------------- |
|
451 // CFSEmailCRHandler::EditorCCVisible |
|
452 // ---------------------------------------------------- |
|
453 // |
|
454 TInt CFSEmailCRHandler::EditorCCVisible() |
|
455 { |
|
456 FUNC_LOG; |
|
457 TInt buf; |
|
458 |
|
459 TInt err=KErrNotFound; |
|
460 |
|
461 if ( iCentralRepository ) |
|
462 { |
|
463 err = iCentralRepository->Get( KFreestyleEmailEditorCCVisible, buf ); |
|
464 } |
|
465 if ( err != KErrNone ) |
|
466 { |
|
467 buf = KFreestyleEmailEditorCCVisibleDefault; |
|
468 } |
|
469 return buf; |
|
470 } |
|
471 |
|
472 // ---------------------------------------------------- |
|
473 // CFSEmailCRHandler::SetEditorCCVisible |
|
474 // ---------------------------------------------------- |
|
475 // |
|
476 void CFSEmailCRHandler::SetEditorCCVisible( TInt aValue ) |
|
477 { |
|
478 FUNC_LOG; |
|
479 if ( iCentralRepository ) |
|
480 { |
|
481 iCentralRepository->Set( KFreestyleEmailEditorCCVisible, aValue ); |
|
482 } |
|
483 } |
|
484 |
|
485 // ---------------------------------------------------- |
|
486 // CFSEmailCRHandler::EditorBCVisible |
|
487 // ---------------------------------------------------- |
|
488 // |
|
489 TInt CFSEmailCRHandler::EditorBCVisible() |
|
490 { |
|
491 FUNC_LOG; |
|
492 TInt buf; |
|
493 |
|
494 TInt err=KErrNotFound; |
|
495 |
|
496 if ( iCentralRepository ) |
|
497 { |
|
498 err = iCentralRepository->Get( KFreestyleEmailEditorBCVisible, buf ); |
|
499 } |
|
500 if ( err != KErrNone ) |
|
501 { |
|
502 buf = KFreestyleEmailEditorBCVisibleDefault; |
|
503 } |
|
504 return buf; |
|
505 } |
|
506 |
|
507 // ---------------------------------------------------- |
|
508 // CFSEmailCRHandler::SetEditorBCVisible |
|
509 // ---------------------------------------------------- |
|
510 // |
|
511 void CFSEmailCRHandler::SetEditorBCVisible( TInt aValue ) |
|
512 { |
|
513 FUNC_LOG; |
|
514 if ( iCentralRepository ) |
|
515 { |
|
516 iCentralRepository->Set( KFreestyleEmailEditorBCVisible, aValue ); |
|
517 } |
|
518 } |
|
519 |
|
520 // ---------------------------------------------------- |
|
521 // CFSEmailCRHandler::SetupWizAccountType |
|
522 // ---------------------------------------------------- |
|
523 // |
|
524 TInt CFSEmailCRHandler::SetupWizAccountType( TDes16& aValue ) |
|
525 { |
|
526 FUNC_LOG; |
|
527 if ( iSetupWizCentRep ) |
|
528 { |
|
529 return iSetupWizCentRep->Get( KSetupWizardAccountType, aValue ); |
|
530 } |
|
531 return KErrNotFound; |
|
532 } |
|
533 |
|
534 // ---------------------------------------------------- |
|
535 // CFSEmailCRHandler::SetSetupWizAccountType |
|
536 // ---------------------------------------------------- |
|
537 // |
|
538 /*void CFSEmailCRHandler::SetSetupWizAccountType( const TDesC16& aValue ) |
|
539 { |
|
540 if ( iSetupWizCentRep ) |
|
541 { |
|
542 iSetupWizCentRep->Set( KSetupWizardAccountType, aValue ); |
|
543 } |
|
544 }*/ |
|
545 |
|
546 // ---------------------------------------------------- |
|
547 // CFSEmailCRHandler::SetupWizCentrepStartKey |
|
548 // ---------------------------------------------------- |
|
549 // |
|
550 TInt CFSEmailCRHandler::SetupWizCentrepStartKey( TDes16& aValue ) |
|
551 { |
|
552 FUNC_LOG; |
|
553 if ( iSetupWizCentRep ) |
|
554 { |
|
555 return iSetupWizCentRep->Get( KSetupWizardCentrepStartKey, aValue ); |
|
556 } |
|
557 return KErrNotFound; |
|
558 } |
|
559 |
|
560 // ---------------------------------------------------- |
|
561 // CFSEmailCRHandler::SetSetupWizCentrepStartKey |
|
562 // ---------------------------------------------------- |
|
563 // |
|
564 /*void CFSEmailCRHandler::SetSetupWizCentrepStartKey( const TDesC16& aValue ) |
|
565 { |
|
566 if ( iSetupWizCentRep ) |
|
567 { |
|
568 iSetupWizCentRep->Set( KSetupWizardCentrepStartKey, aValue ); |
|
569 } |
|
570 }*/ |
|
571 |
|
572 /*TUint32*/void CFSEmailCRHandler::ClearWizardParams() |
|
573 { |
|
574 //TUint32 errorKey = 0; |
|
575 //TInt error = iSetupWizCentRep->Delete(KSetupWizardAccountType, 0xFFFFFFFF, errorKey); |
|
576 if( iSetupWizCentRep ) |
|
577 { |
|
578 iSetupWizCentRep->Delete( KSetupWizardAccountType ); |
|
579 } |
|
580 //TInt error = iSetupWizCentRep->Delete(KSetupWizardCentrepStartKey, 0xFFFFFFFF, errorKey); |
|
581 if( iSetupWizCentRep ) |
|
582 { |
|
583 iSetupWizCentRep->Delete( KSetupWizardCentrepStartKey ); |
|
584 } |
|
585 //return errorkey; |
|
586 } |
|
587 |
|
588 // end of file |
|
589 |