|
1 /* |
|
2 * Copyright (c) 2006 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: DS contacts datastore. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __NSMLCONTACTSMODSFETCHER_H__ |
|
20 #define __NSMLCONTACTSMODSFETCHER_H__ |
|
21 |
|
22 // INCLUDES |
|
23 #include <SmlDataProvider.h> |
|
24 #include <SmlDataFormat.h> |
|
25 #include <f32file.h> |
|
26 #include <cntdb.h> |
|
27 #include <cntitem.h> |
|
28 #include <MContactsModsFetcher.h> |
|
29 |
|
30 #include <CVPbkContactManager.h> |
|
31 #include <MVPbkContactStore.h> |
|
32 #include <MVPbkContactViewObserver.h> |
|
33 #include <CVPbkSortOrder.h> |
|
34 #include <MVPbkContactViewBase.h> |
|
35 #include <MVPbkSingleContactOperationObserver.h> |
|
36 #include <MVPbkContactOperationBase.h> |
|
37 |
|
38 // CONSTANTS |
|
39 const TInt KNSmlSnapshotSize = 56; |
|
40 const TInt KNSmlSnapshotSmallSize = 8; |
|
41 _LIT( KNSmlContactSyncNoSync, "none" ); // Taken from phonebook |
|
42 |
|
43 // CLASS DECLARATION |
|
44 class CNSmlChangeFinder; |
|
45 class TNSmlSnapshotItem; |
|
46 |
|
47 // ------------------------------------------------------------------------------------------------ |
|
48 // CNSmlContactsModsFetcher |
|
49 // |
|
50 // @lib nsmlcontactsdataprovider.lib |
|
51 // ------------------------------------------------------------------------------------------------ |
|
52 class CNSmlContactsModsFetcher : public CActive, public MContactsModsFetcher, |
|
53 MVPbkContactViewObserver, |
|
54 MVPbkSingleContactOperationObserver, |
|
55 MVPbkContactOperationBase |
|
56 |
|
57 { |
|
58 public: |
|
59 /** |
|
60 * C++ constructor. |
|
61 * @param aSnapshotRegistered Is snapshot registered. |
|
62 * @param aCntDb Pointer to opened database. |
|
63 * @param aKey Key array. |
|
64 * @param aChangeFinder Pointer to Changefinder. |
|
65 */ |
|
66 CNSmlContactsModsFetcher( TBool& aSnapshotRegistered,CVPbkContactManager& aContactManager,MVPbkContactStore& aStore,TKeyArrayFix& aKey, CNSmlChangeFinder& aChangeFinder ); |
|
67 /** |
|
68 * Second phase constructor. |
|
69 */ |
|
70 void ConstructL(); |
|
71 |
|
72 /** |
|
73 * ~CNSmlContactsModsFetcher() desctructor. |
|
74 */ |
|
75 virtual ~CNSmlContactsModsFetcher(); |
|
76 |
|
77 private: |
|
78 |
|
79 /** |
|
80 * From MVPbkContactViewObserver |
|
81 * Called when a view is ready for use. |
|
82 */ |
|
83 |
|
84 void ContactViewReady( |
|
85 MVPbkContactViewBase& aView ) ; |
|
86 /** |
|
87 * From MVPbkContactViewObserver |
|
88 * Called when a view is unavailable for a while. |
|
89 */ |
|
90 void ContactViewUnavailable( |
|
91 MVPbkContactViewBase& aView ) ; |
|
92 /** |
|
93 * From MVPbkContactViewObserver |
|
94 * Called when a contact has been added to the view. |
|
95 */ |
|
96 void ContactAddedToView( |
|
97 MVPbkContactViewBase& aView, |
|
98 TInt aIndex, |
|
99 const MVPbkContactLink& aContactLink ); |
|
100 /** |
|
101 * From MVPbkContactViewObserver |
|
102 * Called when a contact has been removed from a view. |
|
103 */ |
|
104 void ContactRemovedFromView( |
|
105 MVPbkContactViewBase& aView, |
|
106 TInt aIndex, |
|
107 const MVPbkContactLink& aContactLink ) ; |
|
108 /** |
|
109 * From MVPbkContactViewObserver |
|
110 * Called when an error occurs in the view. |
|
111 */ |
|
112 void ContactViewError( |
|
113 MVPbkContactViewBase& aView, |
|
114 TInt aError, |
|
115 TBool aErrorNotified ) ; |
|
116 /** |
|
117 * From MVPbkSingleContactOperationObserver |
|
118 * Called when the operation is completed. |
|
119 */ |
|
120 void VPbkSingleContactOperationComplete(MVPbkContactOperationBase& aOperation,MVPbkStoreContact* aContact ); |
|
121 |
|
122 /** |
|
123 * From MVPbkSingleContactOperationObserver |
|
124 * Called if the operation fails. |
|
125 */ |
|
126 void VPbkSingleContactOperationFailed( |
|
127 MVPbkContactOperationBase& aOperation, |
|
128 TInt aError ); |
|
129 |
|
130 private: |
|
131 /** |
|
132 * Fetches next chunk of data (client contacts data changes). |
|
133 */ |
|
134 void FetchNextContactL(); |
|
135 |
|
136 /** |
|
137 * From CActive. Called when asynchronous operation completes. |
|
138 */ |
|
139 void RunL(); |
|
140 |
|
141 /** |
|
142 * From CActive. Called when RunL leaves. |
|
143 */ |
|
144 TInt RunError( TInt aError ); |
|
145 |
|
146 /** |
|
147 * From CActive. Cancels operation. |
|
148 */ |
|
149 void DoCancel(); |
|
150 |
|
151 /** |
|
152 * Checks if aItem is confidential or not. |
|
153 * @param aItem Item that is checked. |
|
154 * @return TBool ETrue if item is confidential. |
|
155 * Otherwise EFalse is returned. |
|
156 */ |
|
157 TBool IsConfidentialL( MVPbkStoreContact& aItem ); |
|
158 /** |
|
159 * Create a contact view of the store which is opened |
|
160 */ |
|
161 void CreateViewL(); |
|
162 /** |
|
163 * Add the fetched contacts id and timestamp |
|
164 * to the snapshot. |
|
165 * @param aContact Fetched contact to be |
|
166 * added to snapshot |
|
167 */ |
|
168 void UpdateSnapshotL( MVPbkStoreContact* aContact ); |
|
169 |
|
170 private: // from MContactsModsFetcher |
|
171 |
|
172 /** |
|
173 * Cancels the current asynchronous request |
|
174 */ |
|
175 void CancelRequest( ); |
|
176 |
|
177 /** |
|
178 * Reads all modifications from clients contacts databse. |
|
179 * @param aStatus On completion of the operation, contains the result code. |
|
180 */ |
|
181 void FetchModificationsL( TRequestStatus& aStatus ); |
|
182 |
|
183 private: // data |
|
184 TRequestStatus* iCallerStatus; |
|
185 TTime iFromTime; |
|
186 |
|
187 |
|
188 CArrayFixSeg<TNSmlSnapshotItem>* iSnapshot; |
|
189 |
|
190 TBool& iSnapshotRegistered; |
|
191 |
|
192 |
|
193 TKeyArrayFix& iKey; |
|
194 |
|
195 CNSmlChangeFinder& iChangeFinder; |
|
196 TInt iCurrentSnapshotCounter; |
|
197 |
|
198 CVPbkContactManager& iContactManager; |
|
199 MVPbkContactStore& iStore; |
|
200 MVPbkContactViewBase* iContactViewBase; |
|
201 TInt iContactCount; |
|
202 |
|
203 }; |
|
204 |
|
205 #endif // __NSMLCONTACTSMODSFETCHER_H__ |
|
206 |
|
207 // End of File |