2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 * @file FSclAddressbook.cpp
18 * @brief This is the implementation for Addressbook class.
20 * This file contains definitions of @e Addressbook class.
24 #include <FBaseColIList.h>
25 #include <FBaseResult.h>
26 #include <FBaseString.h>
27 #include <FBaseSysLog.h>
28 #include <FSclAddressbook.h>
29 #include <FSclCategory.h>
30 #include <FSclContact.h>
31 #include <FSclUserProfile.h>
32 #include <FSec_AccessController.h>
33 #include "FScl_AddressbookImpl.h"
34 #include "FScl_CategoryImpl.h"
35 #include "FScl_ContactImpl.h"
36 #include "FScl_RecordImpl.h"
38 using namespace Tizen::Base;
39 using namespace Tizen::Base::Collection;
40 using namespace Tizen::Security;
42 namespace Tizen { namespace Social
45 Addressbook::Addressbook(void)
46 : __pAddressbookImpl(null)
51 Addressbook::~Addressbook(void)
53 delete __pAddressbookImpl;
57 Addressbook::Construct(IRecordEventListener* pListener)
61 SysAssertf(__pAddressbookImpl == null,
62 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
64 __pAddressbookImpl = new (std::nothrow) _AddressbookImpl();
65 SysTryReturn(NID_SCL, __pAddressbookImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
67 r = __pAddressbookImpl->Construct();
68 SysTryCatch(NID_SCL, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
70 if (pListener != null)
72 r = __pAddressbookImpl->SetRecordEventListener(pListener);
73 SysTryCatch(NID_SCL, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
79 delete __pAddressbookImpl;
80 __pAddressbookImpl = null;
86 Addressbook::SetEventListener(IAddressbookEventListener* pListener)
88 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
89 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
90 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
91 SysAssertf(__pAddressbookImpl != null,
92 "Not yet constructed. Construct() should be called before use.");
94 r = __pAddressbookImpl->SetAddressbookEventListener(pListener);
95 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
101 Addressbook::SetAddressbookChangeEventListener(IAddressbookChangeEventListener* pListener)
103 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
104 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
105 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
106 SysAssertf(__pAddressbookImpl != null,
107 "Not yet constructed. Construct() should be called before use.");
109 r = __pAddressbookImpl->SetAddressbookChangeEventListener(pListener);
110 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
116 Addressbook::GetName(void) const
118 SysAssertf(__pAddressbookImpl != null,
119 "Not yet constructed. Construct() should be called before use.");
121 return __pAddressbookImpl->GetName();
125 Addressbook::GetId(void) const
127 SysAssertf(__pAddressbookImpl != null,
128 "Not yet constructed. Construct() should be called before use.");
130 return __pAddressbookImpl->GetId();
134 Addressbook::GetAccountId(void) const
136 SysAssertf(__pAddressbookImpl != null,
137 "Not yet constructed. Construct() should be called before use.");
139 return __pAddressbookImpl->GetAccountId();
143 Addressbook::AddContact(Contact& contact)
145 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
146 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
147 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
148 SysAssertf(__pAddressbookImpl != null,
149 "Not yet constructed. Construct() should be called before use.");
151 r = __pAddressbookImpl->AddContact(contact);
152 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
158 Addressbook::AddCategory(Category& category)
160 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
161 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
162 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
163 SysAssertf(__pAddressbookImpl != null,
164 "Not yet constructed. Construct() should be called before use.");
166 r = __pAddressbookImpl->AddCategory(category);
167 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
173 Addressbook::RemoveContact(Contact& contact)
175 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
176 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
177 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
178 SysAssertf(__pAddressbookImpl != null,
179 "Not yet constructed. Construct() should be called before use.");
181 r = __pAddressbookImpl->RemoveContact(contact);
182 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
188 Addressbook::RemoveContact(RecordId contactId)
190 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
191 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
192 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
193 SysAssertf(__pAddressbookImpl != null,
194 "Not yet constructed. Construct() should be called before use.");
196 r = __pAddressbookImpl->RemoveContact(contactId);
197 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
203 Addressbook::RemoveCategory(Category& category)
205 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
206 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
207 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
208 SysAssertf(__pAddressbookImpl != null,
209 "Not yet constructed. Construct() should be called before use.");
211 r = __pAddressbookImpl->RemoveCategory(category.GetRecordId());
212 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
214 _CategoryImpl::GetInstance(category)->Invalidate();
215 _RecordImpl::GetInstance(category)->SetRecordId(INVALID_RECORD_ID);
221 Addressbook::RemoveCategory(RecordId categoryId)
223 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
224 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
225 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
226 SysAssertf(__pAddressbookImpl != null,
227 "Not yet constructed. Construct() should be called before use.");
229 r = __pAddressbookImpl->RemoveCategory(categoryId);
230 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
236 Addressbook::UpdateContact(const Contact& contact)
238 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
239 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
240 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
241 SysAssertf(__pAddressbookImpl != null,
242 "Not yet constructed. Construct() should be called before use.");
244 r = __pAddressbookImpl->UpdateContact(contact);
245 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
251 Addressbook::UpdateCategory(const Category& category)
253 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
254 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
255 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
256 SysAssertf(__pAddressbookImpl != null,
257 "Not yet constructed. Construct() should be called before use.");
259 r = __pAddressbookImpl->UpdateCategory(category);
260 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
266 Addressbook::GetAllContactsN(void) const
268 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
269 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
270 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
271 SysAssertf(__pAddressbookImpl != null,
272 "Not yet constructed. Construct() should be called before use.");
274 IList* pList = __pAddressbookImpl->GetAllContactsN();
275 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
281 Addressbook::GetContactsByCategoryN(RecordId categoryId) const
283 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
284 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
285 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
286 SysAssertf(__pAddressbookImpl != null,
287 "Not yet constructed. Construct() should be called before use.");
289 IList* pList = __pAddressbookImpl->GetContactsByCategoryN(categoryId);
290 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
296 Addressbook::AddMemberToCategory(RecordId categoryId, RecordId contactId)
298 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
299 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
300 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
301 SysAssertf(__pAddressbookImpl != null,
302 "Not yet constructed. Construct() should be called before use.");
304 r = __pAddressbookImpl->AddMemberToCategory(categoryId, contactId);
305 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
311 Addressbook::RemoveMemberFromCategory(RecordId categoryId, RecordId contactId)
313 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
314 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
315 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
316 SysAssertf(__pAddressbookImpl != null,
317 "Not yet constructed. Construct() should be called before use.");
319 r = __pAddressbookImpl->RemoveMemberFromCategory(categoryId, contactId);
320 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
326 Addressbook::GetAllCategoriesN(void) const
328 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
329 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
330 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
331 SysAssertf(__pAddressbookImpl != null,
332 "Not yet constructed. Construct() should be called before use.");
334 IList* pList = __pAddressbookImpl->GetAllCategoriesN();
335 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
341 Addressbook::GetCategoriesByContactN(RecordId contactId) const
343 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
344 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
345 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
346 SysAssertf(__pAddressbookImpl != null,
347 "Not yet constructed. Construct() should be called before use.");
349 IList* pList = __pAddressbookImpl->GetCategoriesByContactN(contactId);
350 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
356 Addressbook::GetContactsN(int pageNo, int countPerPage) const
358 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
359 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
360 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
361 SysAssertf(__pAddressbookImpl != null,
362 "Not yet constructed. Construct() should be called before use.");
364 IList* pList = __pAddressbookImpl->GetContactsN(pageNo, countPerPage);
365 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
371 Addressbook::GetContactsInN(const Category& category, int pageNo, int countPerPage) const
373 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
374 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
375 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
376 SysAssertf(__pAddressbookImpl != null,
377 "Not yet constructed. Construct() should be called before use.");
379 IList* pList = __pAddressbookImpl->GetContactsInN(category, pageNo, countPerPage);
380 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
386 Addressbook::SearchContactsByEmailN(const String& email) const
388 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
389 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
390 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
391 SysAssertf(__pAddressbookImpl != null,
392 "Not yet constructed. Construct() should be called before use.");
394 IList* pList = __pAddressbookImpl->SearchContactsByEmailN(email);
395 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
401 Addressbook::SearchContactsByNameN(const String& name) const
403 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
404 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
405 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
406 SysAssertf(__pAddressbookImpl != null,
407 "Not yet constructed. Construct() should be called before use.");
409 IList* pList = __pAddressbookImpl->SearchContactsByNameN(name);
410 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
416 Addressbook::SearchContactsByPhoneNumberN(const String& phoneNumber) const
418 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
419 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
420 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
421 SysAssertf(__pAddressbookImpl != null,
422 "Not yet constructed. Construct() should be called before use.");
424 IList* pList = __pAddressbookImpl->SearchContactsByPhoneNumberN(phoneNumber);
425 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
431 Addressbook::GetCategoryCount(void) const
433 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
434 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
435 SysTryReturn(NID_SCL, r == E_SUCCESS, -1, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
436 SysAssertf(__pAddressbookImpl != null,
437 "Not yet constructed. Construct() should be called before use.");
439 int count = __pAddressbookImpl->GetCategoryCount();
440 SysTryReturn(NID_SCL, count != -1, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
446 Addressbook::GetContactCount(void) const
448 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
449 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
450 SysTryReturn(NID_SCL, r == E_SUCCESS, -1, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
451 SysAssertf(__pAddressbookImpl != null,
452 "Not yet constructed. Construct() should be called before use.");
454 int count = __pAddressbookImpl->GetContactCount();
455 SysTryReturn(NID_SCL, count != -1, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
461 Addressbook::GetContactN(RecordId contactId) const
463 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
464 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
465 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
466 SysAssertf(__pAddressbookImpl != null,
467 "Not yet constructed. Construct() should be called before use.");
469 Contact* pContact = __pAddressbookImpl->GetContactN(contactId);
470 SysTryReturn(NID_SCL, pContact != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
476 Addressbook::GetCategoryN(RecordId categoryId) const
478 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
479 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
480 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
481 SysAssertf(__pAddressbookImpl != null,
482 "Not yet constructed. Construct() should be called before use.");
484 Category* pCategory = __pAddressbookImpl->GetCategoryN(categoryId);
485 SysTryReturn(NID_SCL, pCategory != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
491 Addressbook::GetLatestVersion(void) const
493 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
494 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
495 SysTryReturn(NID_SCL, r == E_SUCCESS, -1, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
496 SysAssertf(__pAddressbookImpl != null,
497 "Not yet constructed. Construct() should be called before use.");
499 int latestVersion = __pAddressbookImpl->GetLatestVersion();
500 SysTryReturn(NID_SCL, latestVersion != -1, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
502 return latestVersion;
506 Addressbook::GetChangedContactsAfterN(int version, int& latestVersion) const
508 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
509 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
510 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
511 SysAssertf(__pAddressbookImpl != null,
512 "Not yet constructed. Construct() should be called before use.");
514 IList* pList = __pAddressbookImpl->GetChangedContactsAfterN(version, latestVersion);
515 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
521 Addressbook::GetChangedCategoriesAfterN(int version, int& latestVersion) const
523 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
524 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
525 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
526 SysAssertf(__pAddressbookImpl != null,
527 "Not yet constructed. Construct() should be called before use.");
529 IList* pList = __pAddressbookImpl->GetChangedCategoriesAfterN(version, latestVersion);
530 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
536 Addressbook::GetChangedContactInfoListN(int version, int& latestVersion) const
538 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
539 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
540 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
541 SysAssertf(__pAddressbookImpl != null,
542 "Not yet constructed. Construct() should be called before use.");
544 IList* pList = __pAddressbookImpl->GetChangedContactInfoListN(version, latestVersion);
545 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
551 Addressbook::GetChangedCategoryInfoListN(int version, int& latestVersion) const
553 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
554 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
555 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
556 SysAssertf(__pAddressbookImpl != null,
557 "Not yet constructed. Construct() should be called before use.");
559 IList* pList = __pAddressbookImpl->GetChangedCategoryInfoListN(version, latestVersion);
560 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
566 Addressbook::AddContacts(const IList& contactList, IListT<RecordId>* pContactIdList)
568 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
569 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
570 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
571 SysAssertf(__pAddressbookImpl != null,
572 "Not yet constructed. Construct() should be called before use.");
574 r = __pAddressbookImpl->AddContacts(contactList, pContactIdList);
580 Addressbook::UpdateContacts(const IList& contactList)
582 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
583 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
584 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
585 SysAssertf(__pAddressbookImpl != null,
586 "Not yet constructed. Construct() should be called before use.");
588 r = __pAddressbookImpl->UpdateContacts(contactList);
594 Addressbook::RemoveContacts(const IListT<RecordId>& contactIdList)
596 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
597 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
598 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
599 SysAssertf(__pAddressbookImpl != null,
600 "Not yet constructed. Construct() should be called before use.");
602 r = __pAddressbookImpl->RemoveContacts(contactIdList);
608 Addressbook::SetUserProfile(const UserProfile* pUserProfile)
610 result r = _AccessController::CheckUserPrivilege(_PRV_USERPROFILE_WRITE);
611 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
612 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
613 SysAssertf(__pAddressbookImpl != null,
614 "Not yet constructed. Construct() should be called before use.");
616 r = __pAddressbookImpl->SetUserProfile(pUserProfile);
617 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
623 Addressbook::GetUserProfileN(void) const
625 result r = _AccessController::CheckUserPrivilege(_PRV_USERPROFILE_READ);
626 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
627 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
628 SysAssertf(__pAddressbookImpl != null,
629 "Not yet constructed. Construct() should be called before use.");
631 UserProfile* pProfile = __pAddressbookImpl->GetUserProfileN();
632 SysTryReturn(NID_SCL, pProfile != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
638 Addressbook::IsUserProfileChangedAfter(int version) const
640 result r = _AccessController::CheckUserPrivilege(_PRV_USERPROFILE_READ);
641 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
642 SysTryReturn(NID_SCL, r == E_SUCCESS, false, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
643 SysAssertf(__pAddressbookImpl != null,
644 "Not yet constructed. Construct() should be called before use.");
646 bool isChanged = __pAddressbookImpl->IsUserProfileChangedAfter(version);
647 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));