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