|
1 /* |
|
2 * Copyright (c) 2008 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: Handler for Snoozing of Event |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef EVTSNOOZEHANDLER_H |
|
21 #define EVTSNOOZEHANDLER_H |
|
22 |
|
23 // INCLUDES |
|
24 |
|
25 #include <e32base.h> |
|
26 #include <e32std.h> |
|
27 #include <cenrepnotifyhandler.h> |
|
28 |
|
29 #include "evtdefs.h" |
|
30 |
|
31 // CONSTANTS |
|
32 |
|
33 // MACROS |
|
34 |
|
35 // DATA TYPES |
|
36 |
|
37 // FUNCTION PROTOTYPES |
|
38 |
|
39 // FORWARD DECLARATIONS |
|
40 |
|
41 // CLASS DECLARATION |
|
42 |
|
43 /** |
|
44 * Event Strucutre for Snooze. |
|
45 * |
|
46 * @since Series 60 9.2 |
|
47 */ |
|
48 class TEvtSnoozeItem |
|
49 { |
|
50 public : |
|
51 /** |
|
52 * Copy constructor |
|
53 */ |
|
54 TEvtSnoozeItem(TEvtEventId aId, TEvtFireAccuracy aAcc, TTime aTime, TUint8 aCount = 1) |
|
55 { |
|
56 iEventId = aId; |
|
57 iAccuracy = aAcc; |
|
58 iTime = aTime; |
|
59 iCount = aCount; |
|
60 }; |
|
61 |
|
62 /** |
|
63 * inline function used for comparision |
|
64 */ |
|
65 static inline TInt Match(const TEvtSnoozeItem& aFirst, const TEvtSnoozeItem& aSecond) |
|
66 { |
|
67 if (aFirst.iEventId == aSecond.iEventId) |
|
68 return 1; |
|
69 return 0; |
|
70 }; |
|
71 |
|
72 /** |
|
73 * inline function used for comparision |
|
74 */ |
|
75 static inline TInt Compare(const TEvtSnoozeItem& aFirst, const TEvtSnoozeItem& aSecond) |
|
76 { |
|
77 if (aFirst.iTime < aSecond.iTime) |
|
78 return -1; |
|
79 if (aFirst.iTime > aSecond.iTime) |
|
80 return 1; |
|
81 return 0; |
|
82 }; |
|
83 public : |
|
84 // Event's Information like Event Id, Accuracy, Time and Count |
|
85 TEvtEventId iEventId; |
|
86 TEvtFireAccuracy iAccuracy; |
|
87 TTime iTime; |
|
88 TUint8 iCount; |
|
89 }; |
|
90 |
|
91 /** |
|
92 * Observer class for snooze handlers. Observer will get the call back when |
|
93 * Snooze for a particular event is complete. |
|
94 * |
|
95 * @since Series 60 9.1 |
|
96 */ |
|
97 class MEvtSnoozeObserver |
|
98 { |
|
99 public: |
|
100 /** |
|
101 * Call back function when the Snooze is complete. |
|
102 * @param aSnoozeItem Snooze Item |
|
103 * @param aSnoozeAgain Snooze again flag which indicates if the event |
|
104 * has to be snnozed again. |
|
105 */ |
|
106 virtual void SnoozeCompleteL( |
|
107 TEvtSnoozeItem& aSnoozeItem, TBool aSnoozeAgain ) = 0; |
|
108 }; |
|
109 |
|
110 |
|
111 /** |
|
112 * Handler for Snoozing the Event. |
|
113 * |
|
114 * @since Series 60 9.1 |
|
115 */ |
|
116 class CEvtSnoozeHandler: public CTimer, public MCenRepNotifyHandlerCallback |
|
117 { |
|
118 public: |
|
119 /** |
|
120 * Two-phase construction. |
|
121 */ |
|
122 static CEvtSnoozeHandler * NewL( |
|
123 MEvtSnoozeObserver& aSnoozeObserver ); |
|
124 |
|
125 /** |
|
126 * Destructor |
|
127 */ |
|
128 virtual ~CEvtSnoozeHandler(); |
|
129 |
|
130 /** |
|
131 * Remove the Event from the Snooze Que |
|
132 * @param[in] aSnoozeItem Snooze Item |
|
133 */ |
|
134 void RemoveIfPresent(const TEvtSnoozeItem& aSnoozeItem); |
|
135 |
|
136 /** |
|
137 * Add the Event to Snooze |
|
138 * @param[in] aSnoozeItem Snooze Item |
|
139 */ |
|
140 void Snooze(TEvtSnoozeItem aSnoozeItem); |
|
141 |
|
142 /** |
|
143 * Check if the Snooze Que is empty. |
|
144 * @ret Return ETrue if the Snooze Que is empty. |
|
145 */ |
|
146 TBool IsSnoozeQueEmpty(); |
|
147 |
|
148 private: // Methods derived from MCenRepNotifyHandlerCallback |
|
149 void HandleNotifyInt(TUint32 aId, TInt aNewValue); |
|
150 |
|
151 private: |
|
152 /** |
|
153 * From CActive |
|
154 */ |
|
155 void RunL(); |
|
156 |
|
157 private: |
|
158 |
|
159 /** |
|
160 * Second phase of the construction |
|
161 */ |
|
162 void ConstructL( ); |
|
163 |
|
164 /** |
|
165 * Private constructor |
|
166 */ |
|
167 CEvtSnoozeHandler( |
|
168 MEvtSnoozeObserver& aSnoozeObserver ); |
|
169 |
|
170 private: |
|
171 /** |
|
172 * Snoozer Observer |
|
173 */ |
|
174 MEvtSnoozeObserver& iSnoozeObserver; |
|
175 |
|
176 /** |
|
177 * events id queue for snooze |
|
178 * Owns |
|
179 */ |
|
180 RArray<TEvtSnoozeItem> iSnoozeQueue; |
|
181 |
|
182 /** |
|
183 * events id queue for snooze |
|
184 * Owns |
|
185 */ |
|
186 RArray<TEvtSnoozeItem> iSnoozeCompleteQueue; |
|
187 |
|
188 /** |
|
189 * Cenrep Session to Snooze Settings. |
|
190 * Own |
|
191 */ |
|
192 CRepository* iSettingSession; |
|
193 |
|
194 /** |
|
195 * Handler to Cenrep Interval key Notifier |
|
196 * Own |
|
197 */ |
|
198 CCenRepNotifyHandler* iIntervalNotifyHandler; |
|
199 |
|
200 /** |
|
201 * Handler to Cenrep Period key Notifier |
|
202 * Own |
|
203 */ |
|
204 CCenRepNotifyHandler* iPeriodNotifyHandler; |
|
205 |
|
206 /** |
|
207 * Snooze Interval in minutes |
|
208 */ |
|
209 TInt iSnoozeInterval; |
|
210 |
|
211 /** |
|
212 * Snooze Count |
|
213 */ |
|
214 TInt iSnoozeCount; |
|
215 }; |
|
216 |
|
217 #endif //EVTSNOOZEHANDLER_H |
|
218 |
|
219 // End of File |