author | Pat Downey <patd@symbian.org> |
Wed, 01 Sep 2010 12:28:47 +0100 | |
branch | RCL_3 |
changeset 45 | a9c0808a1095 |
parent 23 | 50974a8b132e |
permissions | -rw-r--r-- |
5 | 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 the License "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: Core class for the contact service APIs. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#ifndef C_CONTACTSERVICE_H |
|
20 |
#define C_CONTACTSERVICE_H |
|
21 |
||
22 |
//System includes |
|
23 |
#include <s32file.h> // Used for RFileReadStream and RFileWriteStream |
|
23
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
24 |
#include <MVPbkContactStoreListObserver.h> //base class for vCardEng |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
25 |
#include <MVPbkContactObserver.h> //base class for vCardEng |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
26 |
#include <MVPbkSingleContactOperationObserver.h>//base class |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
27 |
#include <MVPbkContactCopyObserver.h> //base class for vCardEng |
5 | 28 |
#include <CVPbkFieldTypeRefsList.h> //Used to specify search fields |
29 |
#include <CVPbkContactLinkArray.h> |
|
23
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
30 |
#include <VPbkContactStoreUris.h> |
5 | 31 |
|
32 |
//User Includes |
|
33 |
#include "contactcallback.h" |
|
34 |
#include "contactservice.hrh" |
|
35 |
#include "contactiter.h" |
|
36 |
#include "storelistobserver.h" |
|
37 |
#include "exportstorelistobserver.h" |
|
38 |
#include "importstorelistobserver.h" |
|
39 |
#include "searchfields.h" |
|
40 |
#include "singlecontact.h" |
|
41 |
#include "fieldkeys.hrh" |
|
42 |
||
43 |
class CVPbkVCardEng; |
|
44 |
class CVPbkContactManager; |
|
45 |
class MVPbkStoreContact; |
|
46 |
class MVPbkFieldType; |
|
47 |
class MVPbkContactLink; |
|
48 |
class CContactCopyObserver; |
|
49 |
class CSingleContactOperationObserver; |
|
50 |
class CImportStoreListObserver; |
|
51 |
class CExportStoreListObserver; |
|
52 |
class CContactViewObserver; |
|
53 |
class CGetListStoreListObserver; |
|
54 |
class CContactIter; |
|
55 |
class CContactRetrieveObserver; |
|
56 |
class CSearchFields; |
|
57 |
class CSingleContact; |
|
58 |
class MCancelAsync; |
|
59 |
class MLocalCallback; |
|
60 |
||
61 |
||
62 |
/** |
|
63 |
* Structure for storing transaction id and associated active object. |
|
64 |
*/ |
|
65 |
struct TAsyncRequestInfo |
|
66 |
{ |
|
67 |
||
68 |
/** |
|
69 |
* TransactionId |
|
70 |
*/ |
|
71 |
TInt32 iTransactionId; |
|
72 |
||
73 |
/** |
|
74 |
* Active object pointer |
|
75 |
*/ |
|
76 |
MCancelAsync* iAsyncObj; |
|
77 |
}; |
|
78 |
||
79 |
class CContactService: public CBase |
|
80 |
{ |
|
81 |
||
82 |
public: |
|
83 |
||
84 |
IMPORT_C static CContactService* NewL(); |
|
85 |
~CContactService(); |
|
86 |
/** |
|
87 |
* Export a predefined vCard from the contact database into a file. |
|
88 |
* |
|
89 |
* @return Integer indicating requestion submission. |
|
90 |
*/ |
|
91 |
IMPORT_C void ExportVCardL(MContactCallback* aCallback, |
|
92 |
TInt aTransId, |
|
93 |
const TFileName& aFileName, |
|
94 |
const TDesC8& aContactId, |
|
95 |
const TDesC& aStoreUri=VPbkContactStoreUris::DefaultCntDbUri()); |
|
96 |
||
97 |
/** |
|
98 |
* Import a vCard from a predefined file into the contact database. |
|
99 |
* |
|
100 |
* @return Integer indicating requestion submission. |
|
101 |
*/ |
|
102 |
IMPORT_C void ImportVCardToStoreL(MContactCallback* aCallback, |
|
103 |
TInt aTransId, |
|
104 |
const TFileName& aFilename, |
|
105 |
const TDesC& aStoreUri=VPbkContactStoreUris::DefaultCntDbUri()); |
|
106 |
||
107 |
/** |
|
108 |
* Get the list of entries in the database satisfying the criteria in the SearchVal |
|
109 |
* |
|
110 |
* @return Integer indicating requestion submission. |
|
111 |
*/ |
|
112 |
IMPORT_C void GetListL(MContactCallback* aCallback, |
|
113 |
TInt aTransId, |
|
114 |
Ttype type, |
|
115 |
const TDesC8& aContactId = KNullDesC8, |
|
116 |
const TDesC& aSearchVal = KNullDesC, |
|
117 |
CSearchFields* aSearchFields = NULL, |
|
118 |
TOrder aSortOrder = EAsc, |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
119 |
const TDesC& aStoreUri = VPbkContactStoreUris::DefaultCntDbUri(), |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
120 |
TCmdType val = EGetList); |
5 | 121 |
|
122 |
/* |
|
123 |
Get the list of databases currently open |
|
124 |
*/ |
|
125 |
IMPORT_C void GetListL(CContactIter& aIter); |
|
126 |
||
127 |
/* |
|
128 |
* Called for 1) Adding a new contact/group to the contacts database. |
|
129 |
* 2) Editing a contact/group from the contacts database. |
|
130 |
* @return Integer indicating requestion submission. |
|
131 |
*/ |
|
132 |
IMPORT_C void AddL( MContactCallback* aCallback, |
|
133 |
TInt aTransId, |
|
134 |
CSingleContact* aContact, |
|
135 |
const TDesC8& aGroupId = KNullDesC8, |
|
136 |
const TDesC& aGroupLabel = KNullDesC, |
|
137 |
const TDesC& aStoreUri = VPbkContactStoreUris::DefaultCntDbUri()); |
|
138 |
/* |
|
139 |
* Called for deleting a contact/group from the contacts database. |
|
140 |
* |
|
141 |
* @return Integer indicating requestion submission. |
|
142 |
*/ |
|
143 |
IMPORT_C void DeleteL( MContactCallback* aCallback, |
|
144 |
TInt aTransId, |
|
145 |
RPointerArray<TDesC8>& aContactIdArray, |
|
146 |
const TDesC& aStoreUri = VPbkContactStoreUris::DefaultCntDbUri() ); |
|
147 |
||
148 |
||
149 |
/* |
|
150 |
* Called for Associating/Disassociating contacts to/from the group. |
|
151 |
* |
|
152 |
* @return Integer indicating requestion submission. |
|
153 |
*/ |
|
154 |
IMPORT_C void OrganiseGroupsL(MContactCallback* aCallback, |
|
155 |
TInt aTransId, |
|
156 |
const TDesC8& aGroupId, |
|
157 |
RPointerArray<TDesC8>& aContactIdArray, |
|
158 |
TBool aAssociateFlag, |
|
159 |
const TDesC& aStoreUri = VPbkContactStoreUris::DefaultCntDbUri() ); |
|
160 |
||
161 |
||
162 |
||
163 |
/** |
|
164 |
* Synchronous implementation of Export api. |
|
165 |
*Export a predefined vCard from the contact database into a file. |
|
166 |
* |
|
167 |
* @return Integer indicating requestion submission. |
|
168 |
*/ |
|
169 |
IMPORT_C void ExportVCardL(const TFileName& aFileName, |
|
170 |
const TDesC8& aContactId, |
|
171 |
const TDesC& aStoreUri=VPbkContactStoreUris:: |
|
172 |
DefaultCntDbUri() ); |
|
173 |
||
174 |
/** |
|
175 |
* Synchronous implementation of Import api. |
|
176 |
* Import a vCard from a predefined file into the contact database. |
|
177 |
* |
|
178 |
* @return Integer indicating requestion submission. |
|
179 |
*/ |
|
180 |
IMPORT_C void ImportVCardToStoreL(const TFileName& aFilename, |
|
181 |
const TDesC& aStoreUri = VPbkContactStoreUris:: |
|
182 |
DefaultCntDbUri() ); |
|
183 |
||
184 |
/** |
|
185 |
* Synchronous implementation of GetList api. |
|
186 |
* Get the list of entries in the database satisfying the criteria in the SearchVal |
|
187 |
* |
|
188 |
* @return Integer indicating requestion submission. |
|
189 |
*/ |
|
190 |
IMPORT_C CContactIter* GetListL(Ttype type, |
|
191 |
const TDesC8& aContactId = KNullDesC8, |
|
192 |
const TDesC& aSearchVal=KNullDesC, |
|
193 |
CSearchFields* aSearchFields=NULL, |
|
194 |
TOrder aSortOrder=EAsc, |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
195 |
const TDesC& aStoreUri=VPbkContactStoreUris::DefaultCntDbUri(), |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
196 |
TCmdType val=EGetList); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
197 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
198 |
/** |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
199 |
* Synchronous implementation of GetIds api. |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
200 |
* Get the list of ids of contacts/groups in the database satisfying the criteria in the SearchVal |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
201 |
* |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
202 |
* @return Integer indicating requestion submission. |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
203 |
*/ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
204 |
IMPORT_C |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
205 |
RPointerArray<HBufC8>& GetIdsL(Ttype atype, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
206 |
const TDesC& aSearchVal=KNullDesC, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
207 |
CSearchFields* aSearchFields=NULL, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
208 |
TOrder aSortOrder = EAsc, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
209 |
const TDesC& aStoreUri=VPbkContactStoreUris::DefaultCntDbUri(), |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
210 |
TCmdType aval=EGetIds); |
5 | 211 |
|
212 |
/** |
|
213 |
* Synchronous implementation of AddL api. |
|
214 |
* Called for 1) Adding a new contact/group to the contacts database. |
|
215 |
* 2) Editing a contact/group from the contacts database. |
|
216 |
* @return Integer indicating requestion submission. |
|
217 |
*/ |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
218 |
IMPORT_C HBufC8* AddL(CSingleContact* aContact, |
5 | 219 |
const TDesC8& aGroupId = KNullDesC8, |
220 |
const TDesC& aGroupLabel = KNullDesC, |
|
221 |
const TDesC& aStoreUri = VPbkContactStoreUris:: |
|
222 |
DefaultCntDbUri()); |
|
223 |
||
224 |
/** |
|
225 |
* Synchronous implementation of DeleteL api. |
|
226 |
* Called for deleting a contact/group from the contacts database. |
|
227 |
* |
|
228 |
* @return Integer indicating requestion submission. |
|
229 |
*/ |
|
230 |
IMPORT_C void DeleteL(RPointerArray<TDesC8>& aContactIdArray, |
|
231 |
const TDesC& aStoreUri = VPbkContactStoreUris:: |
|
232 |
DefaultCntDbUri() ); |
|
233 |
||
234 |
||
235 |
/** |
|
236 |
* Synchronous implementation of OrganiseGroupsL api. |
|
237 |
* Called for Associating/Disassociating contacts to/from the group. |
|
238 |
* |
|
239 |
* @return Integer indicating requestion submission. |
|
240 |
*/ |
|
241 |
IMPORT_C void OrganiseGroupsL(const TDesC8& aGroupId, |
|
242 |
RPointerArray<TDesC8>& aContactIdArray, |
|
243 |
TBool aAssociateFlag, |
|
244 |
const TDesC& aStoreUri = VPbkContactStoreUris:: |
|
245 |
DefaultCntDbUri() ); |
|
246 |
/** |
|
247 |
* Cancels asynchronous request |
|
248 |
* @param aTransactionId asynchronous transaction id |
|
249 |
* @param aResult error code |
|
250 |
*/ |
|
251 |
IMPORT_C TInt Cancel( const TInt32 aTransactionId ); |
|
252 |
/** |
|
253 |
* Gets the field key id which is not supported on the current data base |
|
254 |
* It is only used for sync api's |
|
255 |
* @return field key ID |
|
256 |
*/ |
|
257 |
IMPORT_C TInt GetErrKey(); |
|
258 |
||
259 |
public : |
|
260 |
const MVPbkFieldTypeList& GetFieldTypes(); |
|
261 |
||
262 |
void AddAsyncObjL( const TInt32 aTransactionId, MCancelAsync* aAsyncObj ); |
|
263 |
||
264 |
void RequestComplete( const TInt32 aTransactionId ); |
|
265 |
||
266 |
/* |
|
267 |
* Called interanally to get the pointer to ContactManager instance. |
|
268 |
*/ |
|
269 |
CVPbkContactManager& GetContactManager(); |
|
270 |
||
271 |
private: |
|
272 |
||
273 |
/* |
|
274 |
* Constructor. |
|
275 |
*/ |
|
276 |
CContactService(); |
|
277 |
/* |
|
278 |
* Symbian Second-phase constructor. |
|
279 |
*/ |
|
280 |
void ConstructL(); |
|
281 |
||
282 |
/** |
|
283 |
* Called for setting up the initial parameters for contacts. |
|
284 |
* |
|
285 |
* @return Integer. |
|
286 |
*/ |
|
287 |
TInt BaseSetupL(const TDesC& aStoreUri); |
|
288 |
||
289 |
TInt VcardStoreOpenL(const TDesC& aStoreUri, |
|
290 |
MContactStoreListObserver* aStoreObserver); |
|
291 |
/* |
|
292 |
* Called for getting a contact store from the contact manager and |
|
293 |
* opening the database |
|
294 |
*/ |
|
295 |
TInt GetContactStoreAndOpenL(const TDesC& aDbUri, |
|
296 |
MVPbkContactStoreObserver* aStoreObserver); |
|
297 |
||
298 |
private: // Data |
|
299 |
||
300 |
||
301 |
||
302 |
/** |
|
303 |
* A pointer to the Virtual Phonebook Engine instance. |
|
304 |
* Own. |
|
305 |
*/ |
|
306 |
CVPbkVCardEng* iEngine; |
|
307 |
||
308 |
/** |
|
309 |
* A pointer to the Virtual Phonebook Contact Manager instance. |
|
310 |
* Own. |
|
311 |
*/ |
|
312 |
CVPbkContactManager* iContactManager; |
|
313 |
||
314 |
/** |
|
315 |
* A pointer to a contact store. |
|
316 |
* Not own. |
|
317 |
*/ |
|
318 |
MVPbkContactStore* iContactStore; |
|
319 |
||
320 |
/* |
|
321 |
* Pointer to store contact. |
|
322 |
*/ |
|
323 |
MVPbkStoreContact* iStoreContact; |
|
324 |
||
325 |
/** |
|
326 |
* A reference to a File Server session. |
|
327 |
*/ |
|
328 |
RFs iFs; |
|
329 |
||
330 |
TInt iErrKey; |
|
331 |
/** |
|
332 |
* Contains handles of all asynchronous requests |
|
333 |
*/ |
|
334 |
RArray<TAsyncRequestInfo> iAsyncObjArray; |
|
335 |
||
336 |
}; |
|
337 |
||
338 |
||
339 |
#endif //// C_CONTACTSERVICE_H |