|
1 /* |
|
2 * Copyright (c) 2005 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: CVASDBMonitor class is an active object that is a wrapper around |
|
15 * the RDBNotifier class. Events from RDBNotifier are handled by |
|
16 * encapsulating them in a CNssVASDBEvent object and passing it to all |
|
17 * its observers. In addition to the events provided by RDBNotifier, |
|
18 * CVASDBMonitor also provides additional events when a entry is added, |
|
19 * changed or deleted from the VAS DB. CVASDBMonitor owns the list of |
|
20 * observers of the VAS DB. |
|
21 * |
|
22 */ |
|
23 |
|
24 |
|
25 #ifndef CNSSVASDBEVENTMONITOR_H |
|
26 #define CNSSVASDBEVENTMONITOR_H |
|
27 |
|
28 // INCLUDES |
|
29 #include <d32dbms.h> |
|
30 |
|
31 #include "nssvascoreconstant.h" |
|
32 #include "nssvascvasdbevent.h" |
|
33 #include "nssvasmvasdatabaseobserver.h" |
|
34 #include "nssvasctag.h" |
|
35 |
|
36 |
|
37 // CLASS DECLARATION |
|
38 |
|
39 /** |
|
40 * CNssVASDBEventMonitor is an active object responsible for observing VAS database changes |
|
41 * and notifying all registerted observers of the change. |
|
42 * @lib NssVASApi.lib |
|
43 * @since 2.8 |
|
44 */ |
|
45 class CNssVASDBEventMonitor :public CActive |
|
46 { |
|
47 public: // Constructors and destructor |
|
48 |
|
49 /** |
|
50 * Two-phased constructor. |
|
51 */ |
|
52 static CNssVASDBEventMonitor* NewL(); |
|
53 |
|
54 /** |
|
55 * Destructor. |
|
56 */ |
|
57 virtual ~CNssVASDBEventMonitor(); |
|
58 |
|
59 public: // New functions |
|
60 |
|
61 /** |
|
62 * Request to start monitoring the VAS DB |
|
63 * @since 2.0 |
|
64 * @param void |
|
65 * @return void |
|
66 */ |
|
67 void StartMonitoring(); |
|
68 |
|
69 /** |
|
70 * Method that adds an observer to the observer list |
|
71 * @since 2.0 |
|
72 * @param aObserver to be added |
|
73 * @return none |
|
74 */ |
|
75 void AddObserverL(MNssVASDatabaseObserver* aObserver); |
|
76 |
|
77 /** |
|
78 * Method that removes an observer from the observer list. |
|
79 * @since 2.0 |
|
80 * @param aObserver to be removed |
|
81 * @return error code |
|
82 */ |
|
83 TInt RemoveObserver(MNssVASDatabaseObserver* aObserver); |
|
84 |
|
85 |
|
86 public: // Functions from base classes |
|
87 |
|
88 /** |
|
89 * From CActive, called by RunL of RDBNotifier |
|
90 * @since 2.0 |
|
91 * @param void |
|
92 * @return void |
|
93 */ |
|
94 void RunL(); |
|
95 |
|
96 /** |
|
97 * From CActive, cancel outstanding requests |
|
98 * @since 2.0 |
|
99 * @param void |
|
100 * @return void |
|
101 */ |
|
102 void DoCancel(); |
|
103 |
|
104 /** |
|
105 * handling of addional events ( tag added, tag deleted, tag changed) |
|
106 * These events can be reported only when the events occur on the same |
|
107 * thread as that of the observer (client monitoring the event). |
|
108 * @since 2.0 |
|
109 * @param aEvent - VAS DB event type |
|
110 * @param aTag - tag on which the event occured |
|
111 * @return void |
|
112 */ |
|
113 void HandleDatabaseEventL(CNssVASDBEvent::TVASDBEventType aEvent, CNssTag *aTag); |
|
114 |
|
115 private: |
|
116 |
|
117 /** |
|
118 * C++ constructor. |
|
119 */ |
|
120 CNssVASDBEventMonitor(); |
|
121 |
|
122 /** |
|
123 * EPOC constructor |
|
124 */ |
|
125 void ConstructL(); |
|
126 |
|
127 /** |
|
128 * Called by RunL() to create an event object and |
|
129 * call HandleDatabaseEvent() for all observers |
|
130 * Handles Standard Symbian DBMS events |
|
131 * @since 2.0 |
|
132 * @param aEvent - Symbian DBMS event |
|
133 * @return void |
|
134 */ |
|
135 void HandleDatabaseEventL(RDbNotifier::TEvent aEvent); |
|
136 |
|
137 |
|
138 private: // Data |
|
139 |
|
140 RDbs iDbSession; |
|
141 RDbNamedDatabase iDatabase; |
|
142 RDbNotifier iNotifier; |
|
143 CArrayPtrFlat<MNssVASDatabaseObserver>* iObservers; |
|
144 |
|
145 }; |
|
146 |
|
147 #endif // CVASDBEVENTMONITOR_H |
|
148 |
|
149 // End of File |