author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 23 | 50974a8b132e |
parent 10 | fc9cf246af83 |
permissions | -rw-r--r-- |
5 | 1 |
/* |
2 |
* Copyright (c) 2007 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: Implementation of the sync api's of the contact sapi's. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
//user includes |
|
21 |
#include "contactservice.h" |
|
22 |
#include "contactsynccallback.h" |
|
23 |
||
24 |
||
25 |
/* |
|
26 |
----------------------------------------------------------------------------- |
|
27 |
CContactService :: GetListL |
|
28 |
Description : synchronous implementation of GetList api. |
|
29 |
Return values : CContactIter* |
|
30 |
----------------------------------------------------------------------------- |
|
31 |
*/ |
|
32 |
EXPORT_C |
|
33 |
CContactIter* CContactService::GetListL(Ttype atype, |
|
34 |
const TDesC8& aContactId, |
|
35 |
const TDesC& aSearchVal, |
|
36 |
CSearchFields* aSearchFields, |
|
37 |
TOrder aSortOrder, |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
38 |
const TDesC& aStoreUri, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
39 |
TCmdType aval) |
5 | 40 |
{ |
41 |
//create the callback object internally |
|
42 |
CContactSyncCallback* callback = new(ELeave) CContactSyncCallback(); |
|
43 |
CleanupStack::PushL(callback); |
|
44 |
//create the wait scheduler instance |
|
45 |
CActiveSchedulerWait* waitScheduler = new(ELeave) CActiveSchedulerWait(); |
|
46 |
CleanupStack::PushL(waitScheduler); |
|
47 |
//needed to stop the scheduler by the callback instance |
|
48 |
callback->SetWaitScheduler(waitScheduler); |
|
49 |
//call the asynch sapi with all the params |
|
50 |
TRAPD(err,GetListL(callback, |
|
51 |
0, |
|
52 |
atype, |
|
53 |
aContactId, |
|
54 |
aSearchVal, |
|
55 |
aSearchFields, |
|
56 |
aSortOrder, |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
57 |
aStoreUri, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
58 |
aval)); |
5 | 59 |
//TRAP harness is used to unset the sync flag in leaving condition |
60 |
//since we r using the same async apis for sync implementation |
|
61 |
if(KErrNone != err) |
|
62 |
{ |
|
63 |
User::Leave(err); |
|
64 |
} |
|
65 |
//start the wait scheduler and wait untill the operation finishes |
|
66 |
waitScheduler->Start(); |
|
67 |
//Unset the callbak pointer |
|
68 |
callback->SetWaitScheduler(NULL); |
|
69 |
//check for any errors |
|
70 |
TInt error = callback->GetErrorCode(); |
|
71 |
if(KErrNone != error) |
|
72 |
{ |
|
73 |
User::Leave(error); |
|
74 |
} |
|
75 |
CContactIter* tempIter = callback->GetIter(); |
|
76 |
CleanupStack::PopAndDestroy(waitScheduler); |
|
77 |
CleanupStack::PopAndDestroy(callback); |
|
78 |
return tempIter; |
|
79 |
} |
|
80 |
||
81 |
||
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
82 |
/* |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
83 |
----------------------------------------------------------------------------- |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
84 |
CContactService :: GetIdsL |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
85 |
Description : synchronous implementation of GetIds api. |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
86 |
Return values : RPointerArray<HBufC8>& |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
87 |
----------------------------------------------------------------------------- |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
88 |
*/ |
5 | 89 |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
90 |
EXPORT_C |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
91 |
RPointerArray<HBufC8>& CContactService::GetIdsL(Ttype atype, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
92 |
const TDesC& aSearchVal, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
93 |
CSearchFields* aSearchFields, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
94 |
TOrder aSortOrder, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
95 |
const TDesC& aStoreUri, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
96 |
TCmdType aval) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
97 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
98 |
//create the callback object internally |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
99 |
CContactSyncCallback* callback = new(ELeave) CContactSyncCallback(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
100 |
CleanupStack::PushL(callback); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
101 |
//create the wait scheduler instance |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
102 |
CActiveSchedulerWait* waitScheduler = new(ELeave) CActiveSchedulerWait(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
103 |
CleanupStack::PushL(waitScheduler); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
104 |
//needed to stop the scheduler by the callback instance |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
105 |
callback->SetWaitScheduler(waitScheduler); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
106 |
//call the asynch sapi with all the params |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
107 |
TRAPD(err,GetListL(callback, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
108 |
0, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
109 |
atype, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
110 |
KNullDesC8, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
111 |
aSearchVal, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
112 |
aSearchFields, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
113 |
aSortOrder, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
114 |
aStoreUri, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
115 |
aval)); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
116 |
//TRAP harness is used to unset the sync flag in leaving condition |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
117 |
//since we r using the same async apis for sync implementation |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
118 |
if(KErrNone != err) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
119 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
120 |
User::Leave(err); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
121 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
122 |
//start the wait scheduler and wait untill the operation finishes |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
123 |
waitScheduler->Start(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
124 |
//Unset the callbak pointer |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
125 |
callback->SetWaitScheduler(NULL); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
126 |
//check for any errors |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
127 |
TInt error = callback->GetErrorCode(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
128 |
if(KErrNone != error) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
129 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
130 |
User::Leave(error); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
131 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
132 |
RPointerArray<HBufC8>* tempArray = new (ELeave) RPointerArray<HBufC8>; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
133 |
//get the array of ids of contacts/groups |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
134 |
callback->GetArray(tempArray); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
135 |
CleanupStack::PopAndDestroy(waitScheduler); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
136 |
CleanupStack::PopAndDestroy(callback); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
137 |
return *tempArray; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
138 |
} |
5 | 139 |
/* |
140 |
----------------------------------------------------------------------------- |
|
141 |
CContactService :: AddL |
|
142 |
Description : synchronous implementation of AddL api. |
|
143 |
Return values : CContactIter* |
|
144 |
----------------------------------------------------------------------------- |
|
145 |
*/ |
|
146 |
||
147 |
EXPORT_C |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
148 |
HBufC8* CContactService:: AddL( CSingleContact* aContact, |
5 | 149 |
const TDesC8& aGroupId, |
150 |
const TDesC& aGroupLabel, |
|
151 |
const TDesC& aStoreUri) |
|
152 |
{ |
|
153 |
iErrKey = 0; |
|
154 |
//create the callback object internally |
|
155 |
CContactSyncCallback* callback = new(ELeave) CContactSyncCallback(); |
|
156 |
CleanupStack::PushL(callback); |
|
157 |
//create the wait scheduler instance |
|
158 |
CActiveSchedulerWait* waitScheduler = new(ELeave) CActiveSchedulerWait(); |
|
159 |
CleanupStack::PushL(waitScheduler); |
|
160 |
//needed to stop the scheduler by the callback instance |
|
161 |
callback->SetWaitScheduler(waitScheduler); |
|
162 |
//call the asynch sapi with all the params |
|
163 |
TRAPD(err,AddL(callback, |
|
164 |
0, |
|
165 |
aContact, |
|
166 |
aGroupId, |
|
167 |
aGroupLabel, |
|
168 |
aStoreUri)); |
|
169 |
//TRAP harness is used to unset the sync flag in leaving condition |
|
170 |
//since we are using the same async apis for sync implementation |
|
171 |
if(err!= KErrNone) |
|
172 |
{ |
|
173 |
User::Leave(err); |
|
174 |
} |
|
175 |
//start the wait scheduler and wait untill the operation finishes |
|
176 |
waitScheduler->Start(); |
|
177 |
//Unset the callbak pointer |
|
178 |
callback->SetWaitScheduler(NULL); |
|
179 |
//check for any errors |
|
180 |
TInt error = callback->GetErrorCode(); |
|
181 |
if( error!= KErrNone ) |
|
182 |
{ |
|
183 |
if(error == KErrNotSupported && callback->iErrKey != 0) |
|
184 |
{ |
|
185 |
iErrKey = callback->iErrKey; |
|
186 |
} |
|
187 |
User::Leave(error); |
|
188 |
} |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
189 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
190 |
HBufC8* cntIdVal = callback->GetId(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
191 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
192 |
CleanupStack::PopAndDestroy(waitScheduler); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
193 |
CleanupStack::PopAndDestroy(callback); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
194 |
return cntIdVal; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
195 |
|
5 | 196 |
} |
197 |
||
198 |
||
199 |
/* |
|
200 |
----------------------------------------------------------------------------- |
|
201 |
CContactService :: DeleteL |
|
202 |
Description : synchronous implementation of DeleteL api. |
|
203 |
Return values : CContactIter* |
|
204 |
----------------------------------------------------------------------------- |
|
205 |
*/ |
|
206 |
||
207 |
||
208 |
EXPORT_C void CContactService:: DeleteL(RPointerArray<TDesC8>& aContactIdArray, |
|
209 |
const TDesC& aStoreUri) |
|
210 |
{ |
|
211 |
//create the callback object internally |
|
212 |
CContactSyncCallback* callback = new(ELeave) CContactSyncCallback(); |
|
213 |
CleanupStack::PushL(callback); |
|
214 |
//create the wait scheduler instance |
|
215 |
CActiveSchedulerWait* waitScheduler = new(ELeave) CActiveSchedulerWait(); |
|
216 |
CleanupStack::PushL(waitScheduler); |
|
217 |
//needed to stop the scheduler by the callback instance |
|
218 |
callback->SetWaitScheduler(waitScheduler); |
|
219 |
//call the asynch sapi with all the params |
|
220 |
TRAPD(err,DeleteL(callback, |
|
221 |
0, |
|
222 |
aContactIdArray, |
|
223 |
aStoreUri)); |
|
224 |
//TRAP harness is used to unset the sync flag in leaving condition |
|
225 |
//since we r using the same async apis for sync implementation |
|
226 |
if(err!= KErrNone) |
|
227 |
{ |
|
228 |
User::Leave(err); |
|
229 |
} |
|
230 |
//start the wait scheduler and wait untill the operation finishes |
|
231 |
waitScheduler->Start(); |
|
232 |
//Unset the callbak pointer |
|
233 |
callback->SetWaitScheduler(NULL); |
|
234 |
//check for any errors |
|
235 |
TInt error = callback->GetErrorCode(); |
|
236 |
if( error!= KErrNone ) |
|
237 |
{ |
|
238 |
User::Leave(error); |
|
239 |
} |
|
240 |
CleanupStack::PopAndDestroy(waitScheduler); |
|
241 |
CleanupStack::PopAndDestroy(callback); |
|
242 |
} |
|
243 |
||
244 |
||
245 |
||
246 |
/* |
|
247 |
----------------------------------------------------------------------------- |
|
248 |
CContactService :: OrganiseGroupsL |
|
249 |
Description : synchronous implementation of OrganiseGroupsL api. |
|
250 |
Return values : CContactIter* |
|
251 |
----------------------------------------------------------------------------- |
|
252 |
*/ |
|
253 |
||
254 |
||
255 |
EXPORT_C void CContactService:: OrganiseGroupsL( const TDesC8& aGroupId, |
|
256 |
RPointerArray<TDesC8>& aContactIdArray, |
|
257 |
TBool aAssociateFlag, |
|
258 |
const TDesC& aStoreUri) |
|
259 |
{ |
|
260 |
//create the callback object internally |
|
261 |
CContactSyncCallback* callback = new(ELeave) CContactSyncCallback(); |
|
262 |
CleanupStack::PushL(callback); |
|
263 |
//create the wait scheduler instance |
|
264 |
CActiveSchedulerWait* waitScheduler = new(ELeave) CActiveSchedulerWait(); |
|
265 |
CleanupStack::PushL(waitScheduler); |
|
266 |
//needed to stop the scheduler by the callback instance |
|
267 |
callback->SetWaitScheduler(waitScheduler); |
|
268 |
//call the asynch sapi with all the params |
|
269 |
//TInt err = KErrNone; |
|
270 |
TRAPD(err,OrganiseGroupsL(callback, |
|
271 |
0, |
|
272 |
aGroupId, |
|
273 |
aContactIdArray, |
|
274 |
aAssociateFlag, |
|
275 |
aStoreUri)); |
|
276 |
//TRAP harness is used to unset the sync flag in leaving condition |
|
277 |
//since we r using the same async apis for sync implementation |
|
278 |
if(err!= KErrNone) |
|
279 |
{ |
|
280 |
User::Leave(err); |
|
281 |
} |
|
282 |
//start the wait scheduler and wait untill the operation finishes |
|
283 |
waitScheduler->Start(); |
|
284 |
//Unset the callbak pointer |
|
285 |
callback->SetWaitScheduler(NULL); |
|
286 |
//check for any errors |
|
287 |
TInt error = callback->GetErrorCode(); |
|
288 |
if(error!= KErrNone) |
|
289 |
{ |
|
290 |
User::Leave(error); |
|
291 |
} |
|
292 |
CleanupStack::PopAndDestroy(waitScheduler); |
|
293 |
CleanupStack::PopAndDestroy(callback); |
|
294 |
} |
|
295 |
||
296 |
||
297 |
/* |
|
298 |
----------------------------------------------------------------------------- |
|
299 |
CContactService :: ExportVCardL |
|
300 |
Description : synchronous implementation of ExportVCardL api. |
|
301 |
Return values : CContactIter* |
|
302 |
----------------------------------------------------------------------------- |
|
303 |
*/ |
|
304 |
||
305 |
||
306 |
EXPORT_C void CContactService::ExportVCardL(const TFileName& aFileName, |
|
307 |
const TDesC8& aContactId, |
|
308 |
const TDesC& aStoreUri) |
|
309 |
||
310 |
{ |
|
311 |
//create the callback object internally |
|
312 |
CContactSyncCallback* callback = new(ELeave) CContactSyncCallback(); |
|
313 |
CleanupStack::PushL(callback); |
|
314 |
//create the wait scheduler instance |
|
315 |
CActiveSchedulerWait* waitScheduler = new(ELeave) CActiveSchedulerWait(); |
|
316 |
CleanupStack::PushL(waitScheduler); |
|
317 |
//needed to stop the scheduler by the callback instance |
|
318 |
callback->SetWaitScheduler(waitScheduler); |
|
319 |
//call the asynch sapi with all the params |
|
320 |
TRAPD(err,ExportVCardL(callback, |
|
321 |
0, |
|
322 |
aFileName, |
|
323 |
aContactId, |
|
324 |
aStoreUri)); |
|
325 |
//TRAP harness is used to unset the sync flag in leaving condition |
|
326 |
//since we r using the same async apis for sync implementation |
|
327 |
if(err!= KErrNone) |
|
328 |
{ |
|
329 |
User::Leave(err); |
|
330 |
} |
|
331 |
//start the wait scheduler and wait untill the operation finishes |
|
332 |
waitScheduler->Start(); |
|
333 |
//Unset the callbak pointer |
|
334 |
callback->SetWaitScheduler(NULL); |
|
335 |
//check for any errors |
|
336 |
TInt error = callback->GetErrorCode(); |
|
337 |
if( error!= KErrNone ) |
|
338 |
{ |
|
339 |
User::Leave(error); |
|
340 |
} |
|
341 |
CleanupStack::PopAndDestroy(waitScheduler); |
|
342 |
CleanupStack::PopAndDestroy(callback); |
|
343 |
} |
|
344 |
||
345 |
/* |
|
346 |
----------------------------------------------------------------------------- |
|
347 |
CContactService :: ImportVCardToStoreL |
|
348 |
Description : synchronous implementation of ImportVCardToStoreL api. |
|
349 |
Return values : CContactIter* |
|
350 |
----------------------------------------------------------------------------- |
|
351 |
*/ |
|
352 |
||
353 |
EXPORT_C void CContactService::ImportVCardToStoreL(const TFileName& aFilename, |
|
354 |
const TDesC& aStoreUri) |
|
355 |
{ |
|
356 |
//create the callback object internally |
|
357 |
CContactSyncCallback* callback = new(ELeave) CContactSyncCallback(); |
|
358 |
CleanupStack::PushL(callback); |
|
359 |
//create the wait scheduler instance |
|
360 |
CActiveSchedulerWait* waitScheduler = new(ELeave) CActiveSchedulerWait(); |
|
361 |
CleanupStack::PushL(waitScheduler); |
|
362 |
//needed to stop the scheduler by the callback instance |
|
363 |
callback->SetWaitScheduler(waitScheduler); |
|
364 |
//call the asynch sapi with all the params |
|
365 |
TRAPD(err,ImportVCardToStoreL(callback, |
|
366 |
0, |
|
367 |
aFilename, |
|
368 |
aStoreUri)); |
|
369 |
//TRAP harness is used to unset the sync flag in leaving condition |
|
370 |
//since we r using the same async apis for sync implementation |
|
371 |
if(err!= KErrNone) |
|
372 |
{ |
|
373 |
User::Leave(err); |
|
374 |
} |
|
375 |
//start the wait scheduler and wait untill the operation finishes |
|
376 |
waitScheduler->Start(); |
|
377 |
//Unset the callbak pointer |
|
378 |
callback->SetWaitScheduler(NULL); |
|
379 |
//check for any errors |
|
380 |
TInt error = callback->GetErrorCode(); |
|
381 |
if( error!= KErrNone ) |
|
382 |
{ |
|
383 |
User::Leave(error); |
|
384 |
} |
|
385 |
CleanupStack::PopAndDestroy(waitScheduler); |
|
386 |
CleanupStack::PopAndDestroy(callback); |
|
387 |
} |
|
388 |