63
|
1 |
/**
|
|
2 |
* Copyright (c) 2005-2009 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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
/**
|
|
21 |
@file
|
|
22 |
@internalComponent
|
|
23 |
@released
|
|
24 |
*/
|
|
25 |
|
|
26 |
|
|
27 |
#ifndef __PERSISTENCELAYER_H__
|
|
28 |
#define __PERSISTENCELAYER_H__
|
|
29 |
|
|
30 |
#include <cntdef.h>
|
|
31 |
#include <cntitem.h>
|
|
32 |
#include <cntviewbase.h>
|
|
33 |
|
|
34 |
|
|
35 |
#ifdef __EABI__
|
|
36 |
#define NONSHARED __declspec(notshared)
|
|
37 |
#else
|
|
38 |
#define NONSHARED
|
|
39 |
#endif
|
|
40 |
|
|
41 |
|
|
42 |
enum TPlReadMode
|
|
43 |
{
|
|
44 |
EPlBlobOnly = 0,
|
|
45 |
EPlIdentityInfo = 1,
|
|
46 |
EPlEmailInfo = 2,
|
|
47 |
EPlGroupMembershipInfo = 4,
|
|
48 |
EPlAllInfo = EPlIdentityInfo | EPlEmailInfo | EPlGroupMembershipInfo
|
|
49 |
};
|
|
50 |
|
|
51 |
|
|
52 |
enum TOpenStates
|
|
53 |
{
|
|
54 |
EPlClosed = 0,
|
|
55 |
EPlFileOpen,
|
|
56 |
EPlRecover,
|
|
57 |
EPlUpgrade,
|
|
58 |
EPlOpened
|
|
59 |
};
|
|
60 |
|
|
61 |
|
|
62 |
/**
|
|
63 |
This interface defines five basic operations on CContactItem objects in the
|
|
64 |
Persistence Layer:
|
|
65 |
|
|
66 |
- Create
|
|
67 |
- Read
|
|
68 |
- Update
|
|
69 |
- Delete
|
|
70 |
- Change type
|
|
71 |
|
|
72 |
The methods in this interface provide the only mechanism to change data in the
|
|
73 |
Contacts database.
|
|
74 |
|
|
75 |
The SetConnectionId() method is a helper function and it is used in the event
|
|
76 |
notification mechanism.
|
|
77 |
*/
|
|
78 |
class MLplPersistenceBroker
|
|
79 |
{
|
|
80 |
public:
|
|
81 |
/** Store a new contact. */
|
|
82 |
virtual TContactItemId CreateL(CContactItem& aItem, TUint aSessionId)=0;
|
|
83 |
|
|
84 |
/** Read an existing contact (or parts of it as specified by the view definition). */
|
|
85 |
virtual CContactItem* ReadLC(TContactItemId aItemId, const CContactItemViewDef& aView, TInt aInfoToRead, TUint aSessionId, TBool aIccOpenCheck = EFalse) const =0;
|
|
86 |
|
|
87 |
/** Update an existing contact (or parts of it as specified by the view definition). */
|
|
88 |
virtual void UpdateL(CContactItem& aItem, TUint aSessionId, TBool aSpeeDailUpdate = EFalse) = 0;
|
|
89 |
|
|
90 |
/** Delete a contact. The deleted contact is read first before the deletion
|
|
91 |
and the object is returned. This is useful for the analysis of the deleted contact. */
|
|
92 |
virtual CContactItem* DeleteLC(TContactItemId aItemId, TUint aSessionId, TCntSendEventAction aEventType) = 0;
|
|
93 |
|
|
94 |
/** Change type for the current contact item. */
|
|
95 |
virtual void ChangeTypeL(TContactItemId aItemId, TUid aNewType) = 0;
|
|
96 |
|
|
97 |
/** Set connection ID for the notification mechanism. */
|
|
98 |
virtual void SetConnectionId(TInt aConnectionId) = 0;
|
|
99 |
};
|
|
100 |
|
|
101 |
|
|
102 |
/**
|
|
103 |
The MLplTransactionManager class is part of the Logical sub-layer of the
|
|
104 |
Persistence Layer.
|
|
105 |
|
|
106 |
The interface offers Logical transactions and it ensures that the write and read
|
|
107 |
operations are atomic, consistent, isolated and durable.
|
|
108 |
|
|
109 |
The MLplTransactionManager class only provides support for a single transaction.
|
|
110 |
*/
|
|
111 |
class MLplTransactionManager
|
|
112 |
{
|
|
113 |
public:
|
|
114 |
/** Start a new transaction. */
|
|
115 |
virtual void StartTransactionL() = 0;
|
|
116 |
/** Commit the current transaction. */
|
|
117 |
virtual void CommitCurrentTransactionL(TUint aSessionId) = 0;
|
|
118 |
/** Rollback the current transaction. */
|
|
119 |
virtual void RollbackCurrentTransactionL(TUint aSessionId) = 0;
|
|
120 |
/** Returns if a transaction is currently in progress. */
|
|
121 |
virtual TBool IsTransactionActive() const = 0;
|
|
122 |
};
|
|
123 |
|
|
124 |
|
|
125 |
/**
|
|
126 |
The MLplContactsFile interface defines a set of operation on the Contacts
|
|
127 |
database file, such as opening and closing, compression, recovery, deletion
|
|
128 |
and Contacts Model private directory listing.
|
|
129 |
|
|
130 |
Note that some operations do not require the Contacts database file to be
|
|
131 |
opened.
|
|
132 |
*/
|
|
133 |
class MLplContactsFile
|
|
134 |
{
|
|
135 |
public:
|
|
136 |
enum TPlCreateMode {EPlLeaveIfExist, EPlOverwrite};
|
|
137 |
|
|
138 |
virtual void CreateL(const TDesC& aFileName, TPlCreateMode aMode = EPlLeaveIfExist)=0;
|
|
139 |
virtual void Close(TBool aNotify = ETrue)=0;
|
|
140 |
virtual void DeleteL(const TDesC& aFileName)=0;
|
|
141 |
virtual CDesCArray* ListL(TDriveUnit* aDriveUnit = NULL)=0;
|
|
142 |
virtual TBool DatabaseExistsL(const TDesC& aFileName) = 0;
|
|
143 |
virtual void DatabaseDrive(TDriveUnit& aDriveUnit) = 0;
|
|
144 |
virtual TInt FileSize() const = 0;
|
|
145 |
virtual void CloseTablesL(TBool aNotify) = 0;
|
|
146 |
virtual void OpenTablesL(TBool aNotify = EFalse) = 0;
|
|
147 |
|
|
148 |
virtual void OpenL(const TDesC& aFileName, TBool aNotify = EFalse)=0;
|
|
149 |
};
|
|
150 |
|
|
151 |
|
|
152 |
// Forward class references.
|
|
153 |
class CContactTemplate;
|
|
154 |
class CContactPhoneParser;
|
|
155 |
|
|
156 |
|
|
157 |
/**
|
|
158 |
Originally MLplContactProperties was split into two classes.
|
|
159 |
|
|
160 |
One was concerned with looking up contact item attributes (type, hint and text)
|
|
161 |
by ID and the other was solely concerned with looking after the Preferences
|
|
162 |
table.
|
|
163 |
|
|
164 |
The latter was considered to be data that was 'static' to the whole model.
|
|
165 |
|
|
166 |
Both were merged into MLplContactProperties.
|
|
167 |
*/
|
|
168 |
class MLplContactProperties
|
|
169 |
{
|
|
170 |
public:
|
|
171 |
virtual TInt CardTemplatePrefIdL() const = 0;
|
|
172 |
virtual void SetCardTemplatePrefIdL(TInt aCardTemplatePrefId) = 0;
|
|
173 |
virtual TInt64 MachineIdL() const = 0;
|
|
174 |
virtual CContactIdArray& CardTemplateIdsL() = 0;
|
|
175 |
virtual CContactIdArray& GroupIdListL() = 0;
|
|
176 |
virtual void SetMachineIdL(TInt64 aMachineId) = 0;
|
|
177 |
virtual TPtrC UniqueIdL() = 0;
|
|
178 |
|
|
179 |
// System template methods.
|
|
180 |
virtual const CContactTemplate& SystemTemplateL() const =0;
|
|
181 |
virtual void RecreateSystemTemplateL() = 0;
|
|
182 |
|
|
183 |
virtual TContactItemId OwnCardIdL() = 0;
|
|
184 |
virtual void SetOwnCardIdL(TContactItemId aId) = 0;
|
|
185 |
|
|
186 |
virtual const CArrayFix<CContactDatabase::TSortPref>& SortPrefsL() =0;
|
|
187 |
virtual void SetSortPrefsL(CArrayFix<CContactDatabase::TSortPref>* aPrefs) =0;
|
|
188 |
|
|
189 |
virtual void SetDbViewContactType(TUid aDbViewContactType) =0;
|
|
190 |
virtual TUid GetDbViewContactType() const =0;
|
|
191 |
|
|
192 |
virtual TContactItemId ICCTemplateIdL(TUid aPhonebookUid, TUint aSessionId) =0;
|
|
193 |
virtual TContactItemId PhonebookGroupIdL(TUint aSessionId) =0;
|
|
194 |
virtual void DisableSynchroniser(TUint aSessionId) =0;
|
|
195 |
|
|
196 |
virtual void SessionDeleted(TUint aSessionId) =0;
|
|
197 |
};
|
|
198 |
|
|
199 |
class CViewContact;
|
|
200 |
|
|
201 |
#define KPLViewSessionIdNull 0
|
|
202 |
|
|
203 |
/**
|
|
204 |
This interface defines a set of functions for retrieving view contacts from the
|
|
205 |
contacts database.The view item manager have read-only access to the database
|
|
206 |
and supply all the required data for the contact view framework.
|
|
207 |
*/
|
|
208 |
class MLplViewIteratorManager
|
|
209 |
{
|
|
210 |
public:
|
|
211 |
//View session create and close methods
|
|
212 |
virtual TInt OpenViewL(const CContactTextDef& aTextDef, TContactViewPreferences aViewPrefs) =0;
|
|
213 |
virtual void CloseView(TInt aViewId) =0;
|
|
214 |
|
|
215 |
//Change sort order should be always called when there is not an iteration
|
|
216 |
//started in persistence layer.
|
|
217 |
virtual void ChangeSortOrderL(TInt aViewId, const CContactTextDef& aTextDef) =0;
|
|
218 |
|
|
219 |
//Iterator Methods
|
|
220 |
virtual void BeginIterateL(TInt aViewId) =0;
|
|
221 |
virtual void EndIterateL(TInt aViewId) =0;
|
|
222 |
virtual CViewContact* NextItemL(TInt aViewId, TContactViewPreferences aViewPrefs) =0;
|
|
223 |
virtual CViewContact* ItemAtL(TContactItemId aContactId, TInt aViewId) =0;
|
|
224 |
|
|
225 |
//Read content of a contact into descriptor
|
|
226 |
virtual TUid ReadContactTextDefL(TContactItemId aContactId, TDes &aResult,const CContactTextDef& aTextDef) =0;
|
|
227 |
|
|
228 |
//Get a sortable text field based on field type.
|
|
229 |
virtual void TextFieldL(TInt aCntItemId,TFieldType aFieldType, TDes& aText) =0;
|
|
230 |
};
|
|
231 |
|
|
232 |
|
|
233 |
/**
|
|
234 |
This interface defines a function to Match Phone Numbers in the
|
|
235 |
contacts database.
|
|
236 |
*/
|
|
237 |
class MLplFieldMatcher
|
|
238 |
{
|
|
239 |
public:
|
|
240 |
virtual CContactIdArray* MatchPhoneNumberL(const TDesC& aNumber, TInt aMatchLengthFromRight) = 0;
|
|
241 |
};
|
|
242 |
|
|
243 |
|
|
244 |
/**
|
|
245 |
* This interface defines a function to close the resource
|
|
246 |
* which is running and depends on RSqlDatabase.
|
|
247 |
*/
|
|
248 |
class MLplSqlDatabaseObserver
|
|
249 |
{
|
|
250 |
public:
|
|
251 |
virtual void OnCloseL() = 0;
|
|
252 |
};
|
|
253 |
|
|
254 |
|
|
255 |
/**
|
|
256 |
This interface provides a simplified way of querying the database. The result
|
|
257 |
of the query is typically an array of the contact IDs satisfying the given
|
|
258 |
criteria. For example, IDs of all the contacts changed since the given date.
|
|
259 |
*/
|
|
260 |
class MLplCollection
|
|
261 |
{
|
|
262 |
public:
|
|
263 |
enum TLplViewType
|
|
264 |
{
|
|
265 |
EFilter,
|
|
266 |
EChangedSince,
|
|
267 |
EFindInIdFields,
|
|
268 |
EFindInEmail,
|
|
269 |
EFindInAll,
|
|
270 |
EFindType,
|
|
271 |
EFindGuid,
|
|
272 |
EPhoneMatch,
|
|
273 |
EViewData,
|
|
274 |
EUnfiled,
|
|
275 |
EDeleted,
|
|
276 |
ESortNoText,
|
|
277 |
ESortWithText,
|
|
278 |
EMatchPhoneNos
|
|
279 |
};
|
|
280 |
public:
|
|
281 |
virtual TBool ContactMatchesHintFieldL (TInt aBitWiseFilter, TContactItemId aContactId) = 0;
|
|
282 |
virtual CContactIdArray* CollectionL(TLplViewType aViewType,TTime aTime = 0, const TDesC& aGuid = KNullDesC)=0;
|
|
283 |
virtual TInt ContactCountL () = 0;
|
|
284 |
virtual CContactIdArray* MatchPhoneNumberL(const TDesC& aNumber, const TInt aMatchLengthFromRight) = 0;
|
|
285 |
virtual CContactIdArray* FindL(const TDesC& aText, const CContactItemFieldDef* aFieldDef, TUint aSessionId) = 0;
|
|
286 |
virtual CContactIdArray* FilterDatabaseL(CCntFilter& aFilter)=0;
|
|
287 |
virtual void Reset()=0;
|
|
288 |
virtual void FindAsyncInitL(const TDesC& aText,CContactItemFieldDef* aFieldDef)=0;
|
|
289 |
virtual void FindAsyncTextDefInitL(const CDesCArray& aWords,CContactTextDef* aTextDef) =0;
|
|
290 |
virtual CContactIdArray* FindAsyncL(TBool& aMoreToGo, TUint aSessionId)=0;
|
|
291 |
virtual TBool UsesIdentityFieldsOnly(TInt aFindFlags) = 0;
|
|
292 |
virtual void ConstructBitwiseFlagsFromTextDef(TInt& aFindFlags,TInt& aIdentityColumnsCount,const CContactTextDef* aTextDef) = 0;
|
|
293 |
|
|
294 |
virtual TBool SeekContactL(TContactItemId aReqId,TContactItemId& aId,TUid& aContactType, TBool& aDeleted) = 0;
|
|
295 |
};
|
|
296 |
|
|
297 |
|
|
298 |
/**
|
|
299 |
This interface provides a single point of access to the three other interfaces:
|
|
300 |
|
|
301 |
- View Iterator Manager
|
|
302 |
- Phone Book Synchroniser Plugin
|
|
303 |
- Collection Iterator.
|
|
304 |
|
|
305 |
This interface is implemented in the Contacts Model twice: once on the client
|
|
306 |
and the once on the server. This allows us to reuse the same code for Local
|
|
307 |
View on both sides of the Contacts Model.
|
|
308 |
*/
|
|
309 |
class MLplPersistenceLayerFactory
|
|
310 |
{
|
|
311 |
public:
|
|
312 |
virtual MLplViewIteratorManager& GetViewIteratorManagerL() = 0;
|
|
313 |
virtual MContactSynchroniser& GetContactSynchroniserL(TUint aSessionId) = 0;
|
|
314 |
virtual MLplCollection& GetCollectorL() = 0;
|
|
315 |
};
|
|
316 |
|
|
317 |
|
|
318 |
class MLplPersistenceLayerTest
|
|
319 |
{
|
|
320 |
public:
|
|
321 |
virtual void MergeContactWithTemplateL(CContactItem& aContact, const CContactItem& aTempl, const CContactItemViewDef& aView) const =0;
|
|
322 |
};
|
|
323 |
|
|
324 |
|
|
325 |
class MIniFileManager
|
|
326 |
{
|
|
327 |
public:
|
|
328 |
virtual void DeleteNotifyL(TContactItemId aContactId) = 0;
|
|
329 |
virtual TContactItemId SetSpeedDialIdForPositionL(const TInt aSpeedDialIndex, const TContactItemId aContactId, const TSpeedDialPhoneNumber& aPhoneNumber, TUint aConnectionId, TBool aSendNotification) = 0;
|
|
330 |
virtual CArrayFix<TInt>* SpeedDialIndicesForContactIdLC(TContactItemId aContactId) = 0;
|
|
331 |
};
|
|
332 |
|
|
333 |
|
|
334 |
// Forward class references.
|
|
335 |
class CPplContactsFile;
|
|
336 |
class CLplContactProperties;
|
|
337 |
class CLplTester;
|
|
338 |
class CLplPersistenceLayerFactory;
|
|
339 |
class CLplAnalyserProxy;
|
|
340 |
|
|
341 |
|
|
342 |
class NONSHARED CPersistenceLayer : public CBase
|
|
343 |
{
|
|
344 |
public:
|
|
345 |
IMPORT_C static CPersistenceLayer* NewLC(RFs& aFs, MIniFileManager* aIniFileManager = NULL, MContactDbObserver* aObserver = NULL);
|
|
346 |
|
|
347 |
virtual ~CPersistenceLayer();
|
|
348 |
|
|
349 |
IMPORT_C MLplContactsFile& ContactsFileL();
|
|
350 |
IMPORT_C MLplPersistenceBroker& PersistenceBroker();
|
|
351 |
IMPORT_C MLplTransactionManager& TransactionManager();
|
|
352 |
IMPORT_C MLplContactProperties& ContactProperties();
|
|
353 |
IMPORT_C MLplPersistenceLayerFactory& FactoryL();
|
|
354 |
IMPORT_C void RegisterDbObserver(MContactDbObserver& aDbObserver);
|
|
355 |
IMPORT_C MLplPersistenceLayerTest& PersistenceLayerTestL();
|
|
356 |
|
|
357 |
private:
|
|
358 |
CPersistenceLayer(RFs& aFs, MIniFileManager* aIniFileManager, MContactDbObserver* aObserver);
|
|
359 |
static void CleanupOperation(TAny* aObject);
|
|
360 |
|
|
361 |
private:
|
|
362 |
RFs& iFs;
|
|
363 |
CPplContactsFile* iContactsFile;
|
|
364 |
CLplContactProperties* iContactProperties;
|
|
365 |
CLplTester* iTester;
|
|
366 |
CLplAnalyserProxy* iAnalyserProxy;
|
|
367 |
CLplPersistenceLayerFactory* iFactory;
|
|
368 |
MContactDbObserver* iCntDbObserver; //optional
|
|
369 |
MIniFileManager* iIniManager; //optional
|
|
370 |
};
|
|
371 |
|
|
372 |
#endif //__PERSISTENCELAYER_H__
|