|
1 /* |
|
2 * Copyright (c) 2006 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: |
|
15 * Simple Timer Operation. Completes observer when time expires |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #include "emailtrace.h" |
|
22 #include "ipsplgheaders.h" |
|
23 |
|
24 const TUint KIdleTimeout = 300000000;//5min |
|
25 const TInt KIpsPlgTimerPriority = CActive::EPriorityIdle; |
|
26 |
|
27 CIpsPlgTimerOperation* CIpsPlgTimerOperation::NewL( |
|
28 TFSMailMsgId aMailboxId, |
|
29 MIpsPlgTimerOperationCallBack& aObserver ) |
|
30 { |
|
31 FUNC_LOG; |
|
32 CIpsPlgTimerOperation* self = new( ELeave ) CIpsPlgTimerOperation( |
|
33 aMailboxId, aObserver ); |
|
34 CleanupStack::PushL( self ); |
|
35 self->ConstructL( ); |
|
36 CleanupStack::Pop( self ); |
|
37 return self; |
|
38 } |
|
39 |
|
40 // ---------------------------------------------------------------------------- |
|
41 // ---------------------------------------------------------------------------- |
|
42 CIpsPlgTimerOperation::CIpsPlgTimerOperation( |
|
43 TFSMailMsgId aMailboxId, |
|
44 MIpsPlgTimerOperationCallBack& aObserver ) : |
|
45 CActive( KIpsPlgTimerPriority ), |
|
46 iMailboxId( aMailboxId ), iObserver(aObserver), |
|
47 iStateReActivate( EFalse ) |
|
48 { |
|
49 FUNC_LOG; |
|
50 } |
|
51 |
|
52 // ---------------------------------------------------------------------------- |
|
53 // ---------------------------------------------------------------------------- |
|
54 CIpsPlgTimerOperation::~CIpsPlgTimerOperation() |
|
55 { |
|
56 FUNC_LOG; |
|
57 Cancel(); |
|
58 iTimer.Close(); |
|
59 } |
|
60 |
|
61 // ---------------------------------------------------------------------------- |
|
62 // ---------------------------------------------------------------------------- |
|
63 void CIpsPlgTimerOperation::ConstructL() |
|
64 { |
|
65 FUNC_LOG; |
|
66 User::LeaveIfError( iTimer.CreateLocal() ); |
|
67 CActiveScheduler::Add(this); |
|
68 } |
|
69 |
|
70 // ---------------------------------------------------------------------------- |
|
71 // ---------------------------------------------------------------------------- |
|
72 void CIpsPlgTimerOperation::After(TTimeIntervalMicroSeconds32 aInterval) |
|
73 { |
|
74 FUNC_LOG; |
|
75 Cancel(); |
|
76 iTimer.After(iStatus, aInterval); |
|
77 SetActive(); |
|
78 } |
|
79 |
|
80 |
|
81 // ---------------------------------------------------------------------------- |
|
82 // ---------------------------------------------------------------------------- |
|
83 void CIpsPlgTimerOperation::DoCancel() |
|
84 { |
|
85 FUNC_LOG; |
|
86 iTimer.Cancel(); |
|
87 iStateReActivate = EFalse; |
|
88 } |
|
89 |
|
90 // ---------------------------------------------------------------------------- |
|
91 // ---------------------------------------------------------------------------- |
|
92 void CIpsPlgTimerOperation::RunL() |
|
93 { |
|
94 FUNC_LOG; |
|
95 // cancel is normal code when re-activating timer |
|
96 if ( iStateReActivate ) |
|
97 { |
|
98 iTimer.Cancel(); |
|
99 iTimer.After(iStatus, KIdleTimeout); |
|
100 SetActive(); |
|
101 iStateReActivate = EFalse; |
|
102 } |
|
103 else |
|
104 { |
|
105 iObserver.HandleTimerFiredL( iMailboxId ); |
|
106 } |
|
107 } |
|
108 |
|
109 // ---------------------------------------------------------------------------- |
|
110 // ---------------------------------------------------------------------------- |
|
111 void CIpsPlgTimerOperation::ResetTimerOperation() |
|
112 { |
|
113 FUNC_LOG; |
|
114 if ( iStateReActivate ) |
|
115 { |
|
116 // already re-active state |
|
117 return; |
|
118 } |
|
119 else if ( IsActive() ) |
|
120 { |
|
121 iTimer.Cancel(); |
|
122 iStateReActivate = ETrue; |
|
123 } |
|
124 else |
|
125 { |
|
126 iTimer.After( iStatus, KIdleTimeout ); |
|
127 SetActive(); |
|
128 } |
|
129 } |
|
130 |
|
131 // ---------------------------------------------------------------------------- |
|
132 // ---------------------------------------------------------------------------- |
|
133 TFSMailMsgId CIpsPlgTimerOperation::FSMailboxId() const |
|
134 { |
|
135 FUNC_LOG; |
|
136 |
|
137 return iMailboxId; |
|
138 } |
|
139 |
|
140 |
|
141 |
|
142 //EOF |
|
143 |