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
|
|
24 |
#include <mvpbkcontactstoreListobserver.h> //base class for vCardEng
|
|
25 |
#include <mvpbkcontactobserver.h> //base class for vCardEng
|
|
26 |
#include <mvpbksinglecontactoperationObserver.h>//base class
|
|
27 |
#include <mvpbkcontactcopyobserver.h> //base class for vCardEng
|
|
28 |
#include <CVPbkFieldTypeRefsList.h> //Used to specify search fields
|
|
29 |
#include <CVPbkContactLinkArray.h>
|
|
30 |
#include <vpbkcontactstoreuris.h>
|
|
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,
|
|
119 |
const TDesC& aStoreUri = VPbkContactStoreUris::DefaultCntDbUri());
|
|
120 |
|
|
121 |
/*
|
|
122 |
Get the list of databases currently open
|
|
123 |
*/
|
|
124 |
IMPORT_C void GetListL(CContactIter& aIter);
|
|
125 |
|
|
126 |
/*
|
|
127 |
* Called for 1) Adding a new contact/group to the contacts database.
|
|
128 |
* 2) Editing a contact/group from the contacts database.
|
|
129 |
* @return Integer indicating requestion submission.
|
|
130 |
*/
|
|
131 |
IMPORT_C void AddL( MContactCallback* aCallback,
|
|
132 |
TInt aTransId,
|
|
133 |
CSingleContact* aContact,
|
|
134 |
const TDesC8& aGroupId = KNullDesC8,
|
|
135 |
const TDesC& aGroupLabel = KNullDesC,
|
|
136 |
const TDesC& aStoreUri = VPbkContactStoreUris::DefaultCntDbUri());
|
|
137 |
/*
|
|
138 |
* Called for deleting a contact/group from the contacts database.
|
|
139 |
*
|
|
140 |
* @return Integer indicating requestion submission.
|
|
141 |
*/
|
|
142 |
IMPORT_C void DeleteL( MContactCallback* aCallback,
|
|
143 |
TInt aTransId,
|
|
144 |
RPointerArray<TDesC8>& aContactIdArray,
|
|
145 |
const TDesC& aStoreUri = VPbkContactStoreUris::DefaultCntDbUri() );
|
|
146 |
|
|
147 |
|
|
148 |
/*
|
|
149 |
* Called for Associating/Disassociating contacts to/from the group.
|
|
150 |
*
|
|
151 |
* @return Integer indicating requestion submission.
|
|
152 |
*/
|
|
153 |
IMPORT_C void OrganiseGroupsL(MContactCallback* aCallback,
|
|
154 |
TInt aTransId,
|
|
155 |
const TDesC8& aGroupId,
|
|
156 |
RPointerArray<TDesC8>& aContactIdArray,
|
|
157 |
TBool aAssociateFlag,
|
|
158 |
const TDesC& aStoreUri = VPbkContactStoreUris::DefaultCntDbUri() );
|
|
159 |
|
|
160 |
|
|
161 |
|
|
162 |
/**
|
|
163 |
* Synchronous implementation of Export api.
|
|
164 |
*Export a predefined vCard from the contact database into a file.
|
|
165 |
*
|
|
166 |
* @return Integer indicating requestion submission.
|
|
167 |
*/
|
|
168 |
IMPORT_C void ExportVCardL(const TFileName& aFileName,
|
|
169 |
const TDesC8& aContactId,
|
|
170 |
const TDesC& aStoreUri=VPbkContactStoreUris::
|
|
171 |
DefaultCntDbUri() );
|
|
172 |
|
|
173 |
/**
|
|
174 |
* Synchronous implementation of Import api.
|
|
175 |
* Import a vCard from a predefined file into the contact database.
|
|
176 |
*
|
|
177 |
* @return Integer indicating requestion submission.
|
|
178 |
*/
|
|
179 |
IMPORT_C void ImportVCardToStoreL(const TFileName& aFilename,
|
|
180 |
const TDesC& aStoreUri = VPbkContactStoreUris::
|
|
181 |
DefaultCntDbUri() );
|
|
182 |
|
|
183 |
/**
|
|
184 |
* Synchronous implementation of GetList api.
|
|
185 |
* Get the list of entries in the database satisfying the criteria in the SearchVal
|
|
186 |
*
|
|
187 |
* @return Integer indicating requestion submission.
|
|
188 |
*/
|
|
189 |
IMPORT_C CContactIter* GetListL(Ttype type,
|
|
190 |
const TDesC8& aContactId = KNullDesC8,
|
|
191 |
const TDesC& aSearchVal=KNullDesC,
|
|
192 |
CSearchFields* aSearchFields=NULL,
|
|
193 |
TOrder aSortOrder=EAsc,
|
|
194 |
const TDesC& aStoreUri=VPbkContactStoreUris::
|
|
195 |
DefaultCntDbUri());
|
|
196 |
|
|
197 |
/**
|
|
198 |
* Synchronous implementation of AddL api.
|
|
199 |
* Called for 1) Adding a new contact/group to the contacts database.
|
|
200 |
* 2) Editing a contact/group from the contacts database.
|
|
201 |
* @return Integer indicating requestion submission.
|
|
202 |
*/
|
|
203 |
IMPORT_C void AddL(CSingleContact* aContact,
|
|
204 |
const TDesC8& aGroupId = KNullDesC8,
|
|
205 |
const TDesC& aGroupLabel = KNullDesC,
|
|
206 |
const TDesC& aStoreUri = VPbkContactStoreUris::
|
|
207 |
DefaultCntDbUri());
|
|
208 |
|
|
209 |
/**
|
|
210 |
* Synchronous implementation of DeleteL api.
|
|
211 |
* Called for deleting a contact/group from the contacts database.
|
|
212 |
*
|
|
213 |
* @return Integer indicating requestion submission.
|
|
214 |
*/
|
|
215 |
IMPORT_C void DeleteL(RPointerArray<TDesC8>& aContactIdArray,
|
|
216 |
const TDesC& aStoreUri = VPbkContactStoreUris::
|
|
217 |
DefaultCntDbUri() );
|
|
218 |
|
|
219 |
|
|
220 |
/**
|
|
221 |
* Synchronous implementation of OrganiseGroupsL api.
|
|
222 |
* Called for Associating/Disassociating contacts to/from the group.
|
|
223 |
*
|
|
224 |
* @return Integer indicating requestion submission.
|
|
225 |
*/
|
|
226 |
IMPORT_C void OrganiseGroupsL(const TDesC8& aGroupId,
|
|
227 |
RPointerArray<TDesC8>& aContactIdArray,
|
|
228 |
TBool aAssociateFlag,
|
|
229 |
const TDesC& aStoreUri = VPbkContactStoreUris::
|
|
230 |
DefaultCntDbUri() );
|
|
231 |
/**
|
|
232 |
* Cancels asynchronous request
|
|
233 |
* @param aTransactionId asynchronous transaction id
|
|
234 |
* @param aResult error code
|
|
235 |
*/
|
|
236 |
IMPORT_C TInt Cancel( const TInt32 aTransactionId );
|
|
237 |
/**
|
|
238 |
* Gets the field key id which is not supported on the current data base
|
|
239 |
* It is only used for sync api's
|
|
240 |
* @return field key ID
|
|
241 |
*/
|
|
242 |
IMPORT_C TInt GetErrKey();
|
|
243 |
|
|
244 |
public :
|
|
245 |
const MVPbkFieldTypeList& GetFieldTypes();
|
|
246 |
|
|
247 |
void AddAsyncObjL( const TInt32 aTransactionId, MCancelAsync* aAsyncObj );
|
|
248 |
|
|
249 |
void RequestComplete( const TInt32 aTransactionId );
|
|
250 |
|
|
251 |
/*
|
|
252 |
* Called interanally to get the pointer to ContactManager instance.
|
|
253 |
*/
|
|
254 |
CVPbkContactManager& GetContactManager();
|
|
255 |
|
|
256 |
private:
|
|
257 |
|
|
258 |
/*
|
|
259 |
* Constructor.
|
|
260 |
*/
|
|
261 |
CContactService();
|
|
262 |
/*
|
|
263 |
* Symbian Second-phase constructor.
|
|
264 |
*/
|
|
265 |
void ConstructL();
|
|
266 |
|
|
267 |
/**
|
|
268 |
* Called for setting up the initial parameters for contacts.
|
|
269 |
*
|
|
270 |
* @return Integer.
|
|
271 |
*/
|
|
272 |
TInt BaseSetupL(const TDesC& aStoreUri);
|
|
273 |
|
|
274 |
TInt VcardStoreOpenL(const TDesC& aStoreUri,
|
|
275 |
MContactStoreListObserver* aStoreObserver);
|
|
276 |
/*
|
|
277 |
* Called for getting a contact store from the contact manager and
|
|
278 |
* opening the database
|
|
279 |
*/
|
|
280 |
TInt GetContactStoreAndOpenL(const TDesC& aDbUri,
|
|
281 |
MVPbkContactStoreObserver* aStoreObserver);
|
|
282 |
|
|
283 |
private: // Data
|
|
284 |
|
|
285 |
|
|
286 |
|
|
287 |
/**
|
|
288 |
* A pointer to the Virtual Phonebook Engine instance.
|
|
289 |
* Own.
|
|
290 |
*/
|
|
291 |
CVPbkVCardEng* iEngine;
|
|
292 |
|
|
293 |
/**
|
|
294 |
* A pointer to the Virtual Phonebook Contact Manager instance.
|
|
295 |
* Own.
|
|
296 |
*/
|
|
297 |
CVPbkContactManager* iContactManager;
|
|
298 |
|
|
299 |
/**
|
|
300 |
* A pointer to a contact store.
|
|
301 |
* Not own.
|
|
302 |
*/
|
|
303 |
MVPbkContactStore* iContactStore;
|
|
304 |
|
|
305 |
/*
|
|
306 |
* Pointer to store contact.
|
|
307 |
*/
|
|
308 |
MVPbkStoreContact* iStoreContact;
|
|
309 |
|
|
310 |
/**
|
|
311 |
* A reference to a File Server session.
|
|
312 |
*/
|
|
313 |
RFs iFs;
|
|
314 |
|
|
315 |
TInt iErrKey;
|
|
316 |
/**
|
|
317 |
* Contains handles of all asynchronous requests
|
|
318 |
*/
|
|
319 |
RArray<TAsyncRequestInfo> iAsyncObjArray;
|
|
320 |
|
|
321 |
};
|
|
322 |
|
|
323 |
|
|
324 |
#endif //// C_CONTACTSERVICE_H
|