|
1 /* |
|
2 * Copyright (c) 2009 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: This file implements class CFsAutoSaver. |
|
15 * |
|
16 */ |
|
17 // <cmail> |
|
18 #include "emailtrace.h" |
|
19 #include <alf/alfenv.h> |
|
20 // </cmail> |
|
21 #include"FSAutoSaver.h" |
|
22 #include"FreestyleEmailUiConstants.h" |
|
23 |
|
24 |
|
25 // ----------------------------------------------------------------------------- |
|
26 // CFsAutoSaver::NewL |
|
27 // |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 CFsAutoSaver* CFsAutoSaver::NewL( CAlfEnv& aEnv, TInt aTimeDelayMs ) |
|
31 { |
|
32 FUNC_LOG; |
|
33 CFsAutoSaver* self = new (ELeave) CFsAutoSaver( aEnv, aTimeDelayMs ); |
|
34 CleanupStack::PushL( self ); |
|
35 self->ConstructL(); |
|
36 CleanupStack::Pop( self ); |
|
37 return self; |
|
38 } |
|
39 |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CFsAutoSaver::CFsAutoSaver |
|
43 // |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CFsAutoSaver::CFsAutoSaver( CAlfEnv& aEnv, TInt aTimeDelayMs ): iEnv( aEnv ), |
|
47 iTimeDelayMs( aTimeDelayMs ), iEnabled( ETrue ) |
|
48 { |
|
49 FUNC_LOG; |
|
50 } |
|
51 |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CFsAutoSaver::ConstructL |
|
55 // |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 void CFsAutoSaver::ConstructL() |
|
59 { |
|
60 FUNC_LOG; |
|
61 iTimer = CFSEmailUiGenericTimer::NewL( this ); |
|
62 } |
|
63 |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CFsAutoSaver::~CFsAutoSaver |
|
67 // |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CFsAutoSaver::~CFsAutoSaver() |
|
71 { |
|
72 FUNC_LOG; |
|
73 delete iTimer; |
|
74 } |
|
75 |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CFsAutoSaver::ReportActivity |
|
79 // |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 void CFsAutoSaver::ReportActivity() |
|
83 { |
|
84 FUNC_LOG; |
|
85 iTimer->Stop(); |
|
86 iTimer->Start( iTimeDelayMs ); |
|
87 } |
|
88 |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // CFsAutoSaver::TimerEventL |
|
92 // |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 void CFsAutoSaver::TimerEventL( CFSEmailUiGenericTimer* /*aTriggeredTimer*/ ) |
|
96 { |
|
97 FUNC_LOG; |
|
98 if ( iEnabled ) |
|
99 { |
|
100 iEnv.Send( TAlfActionCommand( KCmdEditorAutoSave ) ); |
|
101 } |
|
102 } |
|
103 |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CFsAutoSaver::Enable |
|
107 // |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 void CFsAutoSaver::Enable( TBool aEnable ) |
|
111 { |
|
112 FUNC_LOG; |
|
113 iEnabled = aEnable; |
|
114 if ( !iEnabled ) |
|
115 { |
|
116 iTimer->Stop(); |
|
117 } |
|
118 } |
|
119 |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // CFsAutoSaver::IsEnabled |
|
123 // |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 TBool CFsAutoSaver::IsEnabled() |
|
127 { |
|
128 FUNC_LOG; |
|
129 return iEnabled; |
|
130 } |
|
131 |