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