|
1 /* |
|
2 * Copyright (c) 2007-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 /** |
|
22 @file |
|
23 @internalComponent |
|
24 @released |
|
25 */ |
|
26 |
|
27 #ifndef __CNTPPLVIEWMANAGER_H__ |
|
28 #define __CNTPPLVIEWMANAGER_H__ |
|
29 |
|
30 #include "cntsqlprovider.h" |
|
31 #include "persistencelayer.h" // for interface definitions. |
|
32 #include "persistencelayerimpl.h" |
|
33 #include <sqldb.h> |
|
34 |
|
35 class CViewContact; |
|
36 class CCntPplViewSession; |
|
37 class CCntSqlStatement; |
|
38 |
|
39 /** |
|
40 The CCntPplViewManager class provides the data source for the Contacts Model |
|
41 view framework. The view item manager provides support for multiple |
|
42 iterators (used for view population) as well as the random access to the |
|
43 Contacts database (used for keeping the views synchronised with the changing |
|
44 database). |
|
45 */ |
|
46 class NONSHARED CCntPplViewManager : public CBase, public MLplViewIteratorManager |
|
47 { |
|
48 public: |
|
49 static CCntPplViewManager* NewL(CPplContactsFile& aContactsFile, const CLplContactProperties& aContactProperties); |
|
50 ~CCntPplViewManager(); |
|
51 |
|
52 //Methods defined in MLplViewIteratorManager |
|
53 TInt OpenViewL(const CContactTextDef& aTextDef, const TContactViewPreferences aViewPrefs); |
|
54 void CloseView(TInt aViewId); |
|
55 void ChangeSortOrderL(TInt aViewId, const CContactTextDef& aTextDef); |
|
56 void BeginIterateL(TInt aViewId); |
|
57 void EndIterateL(TInt aViewId); |
|
58 CViewContact* NextItemL(TInt aViewId, TContactViewPreferences aViewPrefs); |
|
59 CViewContact* ItemAtL(TContactItemId aContactId, TInt aViewId); |
|
60 |
|
61 TUid ReadContactTextDefL(TContactItemId aContactId, TDes &aResult,const CContactTextDef& aTextDef); |
|
62 void TextFieldL(TInt aCntItemId,TFieldType aFieldType, TDes& aText); |
|
63 |
|
64 private: |
|
65 void ConstructL(); |
|
66 CCntPplViewManager(CPplContactsFile& aContactsFile, const CLplContactProperties& aContactProperties); |
|
67 |
|
68 TInt FindViewSessionIndexById(TInt aViewId) const; |
|
69 CCntPplViewSession* FindViewSessionByIdL(TInt aViewId) const; |
|
70 |
|
71 private: |
|
72 CPplContactsFile& iContactsFile; |
|
73 const CLplContactProperties& iContactProperties; |
|
74 |
|
75 TInt iNextViewId; |
|
76 RPointerArray<CCntPplViewSession> iViewSessions; |
|
77 |
|
78 CCntSqlStatement* iSelectFullFieldsStmt; |
|
79 }; |
|
80 |
|
81 class NONSHARED CCntPplViewSession : public CTimer |
|
82 { |
|
83 public: |
|
84 static CCntPplViewSession* NewL(CPplContactsFile& aContactsFile, const CLplContactProperties& aContactProperties, CCntSqlStatement& aSelectAllFields, TInt aViewId, const CContactTextDef& aTextDef, TContactViewPreferences aViewPrefs); |
|
85 ~CCntPplViewSession(); |
|
86 |
|
87 void ChangeSortOrderL(const CContactTextDef& aTextDef); |
|
88 |
|
89 void BeginIterateL(); |
|
90 void EndIterate(); |
|
91 CViewContact* NextItemL(TContactViewPreferences aViewPrefs); |
|
92 CViewContact* ItemAtL(TContactItemId aContactId); |
|
93 |
|
94 TInt ViewId() const; |
|
95 |
|
96 static void TextFieldL(RSqlStatement& aSqlStatement, const CCntSqlStatement& aCntSqlStmt, const CContactTemplate& aSystemTemplate, TFieldType aFieldType, TDes& aText); |
|
97 |
|
98 private: |
|
99 void ConstructL(const CContactTextDef& aTextDef); |
|
100 CCntPplViewSession(CPplContactsFile& aContactsFile, const CLplContactProperties& aContactProperties, CCntSqlStatement& aSelectAllFields, TInt aViewId, TContactViewPreferences aViewPrefs); |
|
101 |
|
102 CViewContact* CreateViewItemL(RSqlStatement& aSqlStmt, const CCntSqlStatement& aCntSqlStmt, const TContactViewPreferences& aViewPrefs); |
|
103 void FillViewItemL(CViewContact& aViewContact, RSqlStatement& aSqlStmt, const TContactViewPreferences& aViewPrefs); |
|
104 |
|
105 static CViewContact* InitialiseViewItemL(RSqlStatement& aSqlStmt, const CCntSqlStatement& aCntSqlStmt, const TContactViewPreferences& aViewPrefs); |
|
106 static TBool HasTxtFieldInFastAccessFieldsL(RSqlStatement& aSelectStmt, const CCntSqlStatement& aCntSqlStmt, TDes& aText); |
|
107 static TBool SpecificTxtFieldInFastAccessFieldsL(RSqlStatement& aSelectStmt, const CCntSqlStatement& aCntSqlStmt, const TFieldType aFieldType, TDes& aText); |
|
108 static TUid GetContactFieldMatchUid(const CViewContact& aViewContact, const TContactViewPreferences& aViewPreferences); |
|
109 static void AddFieldInViewContactL(CViewContact& aViewContact, TPtrC& aFieldPtrC, const TContactViewPreferences& aViewPreferences); |
|
110 static TBool ContactCorrectType(TUid aContactTypeUid, TContactViewPreferences aTypeToInclude); |
|
111 |
|
112 void RunL(); //interface for CTimer |
|
113 |
|
114 CViewContact* doItemAtL(TContactItemId aContactId); |
|
115 void CleanupCachedPrepareStatement(); |
|
116 private: |
|
117 const TInt iViewId; |
|
118 const CLplContactProperties& iContactProperties; |
|
119 |
|
120 CPplContactsFile& iContactsFile; |
|
121 CCntSqlStatement& iSqlSmtSelectAllFieldsById; |
|
122 |
|
123 TContactViewPreferences iViewPrefs; |
|
124 |
|
125 CContactTextDef* iTextDef; |
|
126 CCntSqlStatement* iCntSqlStatement; |
|
127 RSqlStatement* iRSqlStatement; |
|
128 RSqlStatement* iCachedSqlStatement; |
|
129 TBool iIsFastAccessFieldsOnly; |
|
130 }; |
|
131 |
|
132 |
|
133 #endif //__CNTPPLVIEWMANAGER_H__ |