33
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-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: Header file for CNSmlDMDbNotifier
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef NSMLDMDBNOTIFIER_H
|
|
20 |
#define NSMLDMDBNOTIFIER_H
|
|
21 |
|
|
22 |
#include <e32std.h>
|
|
23 |
#include <SyncMLObservers.h>
|
|
24 |
#include <SyncMLClient.h>
|
36
|
25 |
#include "nsmldmsyncutil.h"
|
33
|
26 |
|
|
27 |
// CLASS DECLARATION
|
|
28 |
|
|
29 |
/**
|
|
30 |
* DB events
|
|
31 |
*
|
|
32 |
*/
|
|
33 |
NONSHARABLE_CLASS (TNSmlDMDbEvent)
|
|
34 |
{
|
|
35 |
public:
|
|
36 |
TInt iType;
|
|
37 |
TInt iProfileId;
|
|
38 |
TInt iError;
|
|
39 |
};
|
|
40 |
|
|
41 |
/**
|
|
42 |
* Interface class to handle database events
|
|
43 |
*
|
|
44 |
*/
|
|
45 |
class MNSmlDMDbEventHandler
|
|
46 |
{
|
|
47 |
|
|
48 |
public:
|
|
49 |
/**
|
|
50 |
* CNSmlDMDbNotifier calls this to inform that database has changed.
|
|
51 |
* @param aStatus EClose, EUnlock, ECommit, ERollback, or ERecover (d32dbms.h).
|
|
52 |
* @param aMoreEvents ETrue issue new request, EFalse no requests.
|
|
53 |
* @return None.
|
|
54 |
*/
|
|
55 |
virtual void HandleDbEventL( TNSmlDMDbEvent aEvent ) = 0;
|
|
56 |
};
|
|
57 |
|
|
58 |
/**
|
|
59 |
* DB notifier
|
|
60 |
*
|
|
61 |
*/
|
|
62 |
NONSHARABLE_CLASS (CNSmlDMDbNotifier) : public CBase,
|
|
63 |
public MNSmlDMActiveCallerObserver,
|
|
64 |
public MSyncMLEventObserver
|
|
65 |
{
|
|
66 |
public:
|
|
67 |
enum TEventType
|
|
68 |
{
|
|
69 |
EUpdate,
|
|
70 |
EUpdateAll,
|
|
71 |
EDelete,
|
|
72 |
EClose
|
|
73 |
};
|
|
74 |
|
|
75 |
public:
|
|
76 |
/**
|
|
77 |
* Two-phased constructor
|
|
78 |
* @param aDatabase Reference to RDbDatabase instance.
|
|
79 |
* @param aHandler Pointer to MNSmlDMDbEventHandler instance.
|
|
80 |
* @return None.
|
|
81 |
*/
|
|
82 |
static CNSmlDMDbNotifier* NewL( RSyncMLSession* aSyncSession,
|
|
83 |
MNSmlDMDbEventHandler* aHandler );
|
|
84 |
|
|
85 |
/**
|
|
86 |
* Destructor.
|
|
87 |
*/
|
|
88 |
virtual ~CNSmlDMDbNotifier();
|
|
89 |
|
|
90 |
// Functions from base classes
|
|
91 |
|
|
92 |
private:
|
|
93 |
|
|
94 |
/**
|
|
95 |
* Constructor
|
|
96 |
* @param aDatabase Reference to RDbDatabase instance.
|
|
97 |
* @param aHandler Pointer to event handler.
|
|
98 |
* @return None.
|
|
99 |
*/
|
|
100 |
CNSmlDMDbNotifier( RSyncMLSession* aSyncSession,
|
|
101 |
MNSmlDMDbEventHandler* aHandler);
|
|
102 |
|
|
103 |
/**
|
|
104 |
* By default Symbian OS constructor is private.
|
|
105 |
*/
|
|
106 |
void ConstructL();
|
|
107 |
|
|
108 |
public:
|
|
109 |
/**
|
|
110 |
* Start requesting events from db.
|
|
111 |
* @param None.
|
|
112 |
* @return None.
|
|
113 |
*/
|
|
114 |
void RequestL();
|
|
115 |
|
|
116 |
|
|
117 |
private: // from MNSmlDMActiveCallerObserver
|
|
118 |
|
|
119 |
/**
|
|
120 |
* From MNSmlDMActiveCallerObserver
|
|
121 |
* Called when CNSmlDMActiveCaller completes.
|
|
122 |
* @param None
|
|
123 |
* @return None.
|
|
124 |
*/
|
|
125 |
void HandleActiveCallL();
|
|
126 |
|
|
127 |
private: // from MSyncMLEventObserver
|
|
128 |
|
|
129 |
/**
|
|
130 |
* From MSyncMLEventObserver
|
|
131 |
* Called when SyncML session events oocur.
|
|
132 |
* @param aEvent.
|
|
133 |
* @param aIdentifier.
|
|
134 |
* @param aError.
|
|
135 |
* @param aAdditionalData.
|
|
136 |
* @return None.
|
|
137 |
*/
|
|
138 |
void OnSyncMLSessionEvent( TEvent aEvent,
|
|
139 |
TInt aIdentifier,
|
|
140 |
TInt aError,
|
|
141 |
TInt aAdditionalData);
|
|
142 |
|
|
143 |
public:
|
|
144 |
/**
|
|
145 |
* Call observer with delay
|
|
146 |
* @param None
|
|
147 |
* @return None
|
|
148 |
*/
|
|
149 |
void CallObserverWithDelay();
|
|
150 |
|
|
151 |
/**
|
|
152 |
* Call observer
|
|
153 |
* @param None
|
|
154 |
* @return None
|
|
155 |
*/
|
|
156 |
void CallObserver();
|
|
157 |
|
|
158 |
/**
|
|
159 |
* Set as disabled
|
|
160 |
* @param aDisable
|
|
161 |
* @return None
|
|
162 |
*/
|
|
163 |
void SetDisabled( TBool aDisable );
|
|
164 |
|
|
165 |
/**
|
|
166 |
* Change profile count
|
|
167 |
* @param None
|
|
168 |
* @return TInt
|
|
169 |
*/
|
|
170 |
TInt ChangedProfileCount();
|
|
171 |
|
|
172 |
/**
|
|
173 |
* DB event
|
|
174 |
* @param aIndex
|
|
175 |
* @return db event
|
|
176 |
*/
|
|
177 |
TNSmlDMDbEvent Event(TInt aIndex);
|
|
178 |
|
|
179 |
/**
|
|
180 |
* Event count
|
|
181 |
* @param None
|
|
182 |
* @return TInt
|
|
183 |
*/
|
|
184 |
TInt EventCount();
|
|
185 |
|
|
186 |
/**
|
|
187 |
* Reset
|
|
188 |
* @param None
|
|
189 |
* @return None
|
|
190 |
*/
|
|
191 |
void Reset();
|
|
192 |
|
|
193 |
/**
|
|
194 |
* Find event
|
|
195 |
* @param None
|
|
196 |
* @return TInt
|
|
197 |
*/
|
|
198 |
TInt FindCloseEvent();
|
|
199 |
|
|
200 |
/**
|
|
201 |
* Find event
|
|
202 |
* @param None
|
|
203 |
* @return TInt
|
|
204 |
*/
|
|
205 |
TInt FindSingleProfileEvent();
|
|
206 |
|
|
207 |
/**
|
|
208 |
* Find event
|
|
209 |
* @param None
|
|
210 |
* @return TInt
|
|
211 |
*/
|
|
212 |
TInt FindProfileEvent();
|
|
213 |
|
|
214 |
/**
|
|
215 |
* Check if profile id is unique
|
|
216 |
* @param aId Profile id
|
|
217 |
* @return ETrue if unique
|
|
218 |
*/
|
|
219 |
TBool IsUniqueProfileId(TInt aId);
|
|
220 |
|
|
221 |
/**
|
|
222 |
* Utility function.
|
|
223 |
* @return Sync session.
|
|
224 |
*/
|
|
225 |
RSyncMLSession& Session();
|
|
226 |
|
|
227 |
private:
|
|
228 |
// sync session
|
|
229 |
RSyncMLSession* iSyncSession;
|
|
230 |
// Pointer to event handler
|
|
231 |
MNSmlDMDbEventHandler* iHandler;
|
|
232 |
// for making function call via active scheduler
|
|
233 |
CNSmlDMActiveCaller* iActiveCaller;
|
|
234 |
// for storing ids of changed profiles
|
|
235 |
RArray<TNSmlDMDbEvent> iList;
|
|
236 |
// can observer be called
|
|
237 |
TBool iDisabled;
|
|
238 |
// is synchronizing going on
|
|
239 |
TBool iSyncRunning;
|
|
240 |
};
|
|
241 |
|
|
242 |
#endif // NSMLDMDBNOTIFIER_H
|
|
243 |
|
|
244 |
// End of File
|