|
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: Notifies observers of external changes to the calendar database |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __CALENDBCHANGENOTIFIER_H |
|
20 #define __CALENDBCHANGENOTIFIER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 |
|
25 #include <calchangecallback.h> //MCalChangeCallBack |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CCalSession; //Calendar session |
|
29 class CCalenGlobalData; //Calendar global data |
|
30 class CMissedAlarm; |
|
31 |
|
32 // CLASS DECLARATION |
|
33 |
|
34 /** |
|
35 * Observer class for database changes. Forwards callback from |
|
36 * MCalChangeCallBack2 |
|
37 */ |
|
38 class MCalenDBChangeObserver |
|
39 { |
|
40 public: |
|
41 virtual void HandleDBChangeL() = 0; |
|
42 }; |
|
43 |
|
44 /** |
|
45 * CCalenDbChangeNotifier buffers notifications from MCalChangeCallBack2 and |
|
46 * only notifies its observers after a set period has elapsed. This prevents |
|
47 * Calendar views refreshing more often than necessary during a sync operation |
|
48 */ |
|
49 NONSHARABLE_CLASS(CCalenDbChangeNotifier) : public CActive, |
|
50 public MCalChangeCallBack2 |
|
51 { |
|
52 public: // Constructors and destructor |
|
53 /** |
|
54 * Constructor. |
|
55 * @param aGlobalData global data reference |
|
56 * @return a pointer to the new CCalenDbChangeNotifier instance |
|
57 */ |
|
58 static CCalenDbChangeNotifier* NewL( CCalSession& aSession ); |
|
59 |
|
60 /** |
|
61 * Destructor. |
|
62 */ |
|
63 ~CCalenDbChangeNotifier(); |
|
64 |
|
65 public: |
|
66 /** |
|
67 * Allow CCalenViews to register for database change notifications |
|
68 * @param aDBObserver Observer to register |
|
69 */ |
|
70 void RegisterObserverL( MCalenDBChangeObserver& aDBObserver ); |
|
71 |
|
72 /** |
|
73 * Allow CCalenViews to deregister for database change notifications |
|
74 * @param aDBObserver Observer to deregister |
|
75 */ |
|
76 void DeRegisterObserverL( MCalenDBChangeObserver& aDBObserver ); |
|
77 |
|
78 /** |
|
79 * Returns the time of the last call to MCalChangeCallBack2::CalChangeNotification |
|
80 * This is not necessarily the same time as the last notification issued by |
|
81 * this class |
|
82 * @return Time of the last database modification as TTime |
|
83 */ |
|
84 TTime LastDBModificationTime() const; |
|
85 |
|
86 public: |
|
87 /** |
|
88 * From MCalChangeCallBack2 |
|
89 * Called when the calendar database is changed through another |
|
90 * CCalSession |
|
91 * @param aChangeItems array of database items changed |
|
92 */ |
|
93 void CalChangeNotification( RArray<TCalChangeEntry>& aChangeItems ); |
|
94 |
|
95 private: |
|
96 /** |
|
97 * C++ default constructor. |
|
98 * @param aGlobalData global data reference |
|
99 */ |
|
100 CCalenDbChangeNotifier( CCalSession& aSession ); |
|
101 |
|
102 /** |
|
103 * By default Symbian 2nd phase constructor is private. |
|
104 * Performs any construction which may leave |
|
105 */ |
|
106 void ConstructL(); |
|
107 |
|
108 /** |
|
109 * From CActive |
|
110 * Called when outstanding asynchronous request completes |
|
111 * This will be called when iNotificationTimer either completes |
|
112 * or is cancelled |
|
113 */ |
|
114 void RunL(); |
|
115 |
|
116 /** |
|
117 * From CActive |
|
118 * Called by the active scheduler if RunL leaves |
|
119 * Ensures we are ready to receive the next database event |
|
120 * @param aError System wide error code |
|
121 */ |
|
122 TInt RunError( TInt aError ); |
|
123 |
|
124 /** |
|
125 * From CActive |
|
126 * Implements cancellation of outstanding asynchronous requests |
|
127 * Cancels iNotificationTimer if started |
|
128 */ |
|
129 void DoCancel(); |
|
130 void HandleMissedAlarmsL(const RArray<TCalChangeEntry>& aChangeItems); |
|
131 class TCalLuidFilename |
|
132 { |
|
133 public: |
|
134 TCalLocalUid iLuid; |
|
135 TFileName iFilename; |
|
136 }; |
|
137 static TBool DoFindEntryByLuid(const TCalLuidFilename* aLuidFilename,const CMissedAlarm& aCalendarInfo); |
|
138 |
|
139 private: // Data |
|
140 |
|
141 //Database change observer filter |
|
142 CCalChangeNotificationFilter* iCalChangeFilter; |
|
143 |
|
144 //Observer array |
|
145 RPointerArray<MCalenDBChangeObserver> iDBObservers; |
|
146 |
|
147 //Timer to limit the amount of notifications issued by this class |
|
148 RTimer iNotificationTimer; |
|
149 |
|
150 //The time of the last received notification |
|
151 TTime iLastDbChangeNotification; |
|
152 |
|
153 //Flag to restart the timer after cancelling last tiemr request |
|
154 TBool iRestartTimer; |
|
155 |
|
156 CCalSession& iSession; |
|
157 }; |
|
158 |
|
159 #endif // __CALENDBCHANGENOTIFIER_H |
|
160 |
|
161 // End of File |