2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FSclAddressbookManager.cpp
19 * @brief This is the implementation for AddressbookManager class.
21 * This file contains definitions of @e AddressbookManager class.
24 #include <unique_ptr.h>
26 #include <FBaseResult.h>
27 #include <FBaseString.h>
28 #include <FBaseColIList.h>
29 #include <FBaseSysLog.h>
30 #include <FSclContact.h>
31 #include <FSclCategory.h>
32 #include <FSclUserProfile.h>
33 #include <FSclAddressbookManager.h>
34 #include <FSec_AccessController.h>
35 #include <FScl_AddressbookManagerImpl.h>
37 using namespace Tizen::Base;
38 using namespace Tizen::Base::Collection;
39 using namespace Tizen::Security;
41 namespace Tizen { namespace Social
44 AddressbookManager* AddressbookManager::__pInstance = null;
46 AddressbookManager::AddressbookManager(void)
47 : __pAddressbookManagerImpl(null)
52 AddressbookManager::~AddressbookManager(void)
54 delete __pAddressbookManagerImpl;
58 AddressbookManager::Construct(void)
62 SysAssertf(__pAddressbookManagerImpl == null,
63 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
65 _AddressbookManagerImpl* pAddressbookManagerImpl = new (std::nothrow) _AddressbookManagerImpl();
66 SysTryReturnResult(NID_SCL, pAddressbookManagerImpl != null, E_OUT_OF_MEMORY, "Not enough memory.");
68 r = pAddressbookManagerImpl->Construct();
69 SysTryCatch(NID_SCL, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
71 __pAddressbookManagerImpl = pAddressbookManagerImpl;
76 delete pAddressbookManagerImpl;
82 AddressbookManager::SetEventListener(IAddressbookEventListener* pListener)
84 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
85 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
86 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
87 SysAssertf(__pAddressbookManagerImpl != null,
88 "Not yet constructed. Construct() should be called before use.");
90 r = __pAddressbookManagerImpl->SetEventListener(pListener);
91 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
97 AddressbookManager::SetAddressbookChangeEventListener(IAddressbookChangeEventListener* pListener)
99 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
100 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
101 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
102 SysAssertf(__pAddressbookManagerImpl != null,
103 "Not yet constructed. Construct() should be called before use.");
105 r = __pAddressbookManagerImpl->SetAddressbookChangeEventListener(pListener);
106 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
112 AddressbookManager::CreateAddressbookN(AccountId accountId, const String& name)
114 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
115 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
116 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
117 SysAssertf(__pAddressbookManagerImpl != null,
118 "Not yet constructed. Construct() should be called before use.");
120 Addressbook* pAddressbook = __pAddressbookManagerImpl->CreateAddressbookN(accountId, name);
121 SysTryReturn(NID_SCL, pAddressbook != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
127 AddressbookManager::DeleteAddressbook(AddressbookId addressbookId)
129 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
130 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
131 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
132 SysAssertf(__pAddressbookManagerImpl != null,
133 "Not yet constructed. Construct() should be called before use.");
135 r = __pAddressbookManagerImpl->DeleteAddressbook(addressbookId);
136 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
142 AddressbookManager::GetAddressbooksByAccountN(AccountId accountId) const
144 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
145 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
146 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
147 SysAssertf(__pAddressbookManagerImpl != null,
148 "Not yet constructed. Construct() should be called before use.");
150 IList* pList = __pAddressbookManagerImpl->GetAddressbooksByAccountN(accountId);
151 SysTryReturn(NID_SCL, pList !=null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
157 AddressbookManager::GetAllAddressbooksN(void) const
159 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
160 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
161 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
162 SysAssertf(__pAddressbookManagerImpl != null,
163 "Not yet constructed. Construct() should be called before use.");
165 IList* pList = __pAddressbookManagerImpl->GetAllAddressbooksN();
166 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
172 AddressbookManager::GetAddressbookN(AddressbookId addressbookId) const
174 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
175 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
176 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
177 SysAssertf(__pAddressbookManagerImpl != null,
178 "Not yet constructed. Construct() should be called before use.");
180 Addressbook* pAddressbook = __pAddressbookManagerImpl->GetAddressbookN(addressbookId);
181 SysTryReturn(NID_SCL, pAddressbook != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
187 AddressbookManager::AddContact(Contact& contact, AddressbookId addressbookId)
189 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
190 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
191 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
192 SysAssertf(__pAddressbookManagerImpl != null,
193 "Not yet constructed. Construct() should be called before use.");
195 r = __pAddressbookManagerImpl->AddContact(contact, addressbookId);
196 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
202 AddressbookManager::AddCategory(Category& category, AddressbookId addressbookId)
204 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
205 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
206 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
207 SysAssertf(__pAddressbookManagerImpl != null,
208 "Not yet constructed. Construct() should be called before use.");
210 r = __pAddressbookManagerImpl->AddCategory(category, addressbookId);
211 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
217 AddressbookManager::RemoveContact(RecordId contactId)
219 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
220 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
221 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
222 SysAssertf(__pAddressbookManagerImpl != null,
223 "Not yet constructed. Construct() should be called before use.");
225 r = __pAddressbookManagerImpl->RemoveContact(contactId);
226 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
232 AddressbookManager::RemoveCategory(RecordId categoryId)
234 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
235 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
236 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
237 SysAssertf(__pAddressbookManagerImpl != null,
238 "Not yet constructed. Construct() should be called before use.");
240 r = __pAddressbookManagerImpl->RemoveCategory(categoryId);
241 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
247 AddressbookManager::UpdateContact(const Contact& contact)
249 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
250 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
251 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
252 SysAssertf(__pAddressbookManagerImpl != null,
253 "Not yet constructed. Construct() should be called before use.");
255 r = __pAddressbookManagerImpl->UpdateContact(contact);
256 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
262 AddressbookManager::UpdateCategory(const Category& category)
264 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
265 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
266 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
267 SysAssertf(__pAddressbookManagerImpl != null,
268 "Not yet constructed. Construct() should be called before use.");
270 r = __pAddressbookManagerImpl->UpdateCategory(category);
271 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
277 AddressbookManager::GetAllContactsN(void) const
279 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
280 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
281 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
282 SysAssertf(__pAddressbookManagerImpl != null,
283 "Not yet constructed. Construct() should be called before use.");
285 IList* pList = __pAddressbookManagerImpl->GetAllContactsN();
286 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
292 AddressbookManager::GetContactsByCategoryN(RecordId categoryId) const
294 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
295 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
296 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
297 SysAssertf(__pAddressbookManagerImpl != null,
298 "Not yet constructed. Construct() should be called before use.");
300 IList* pList = __pAddressbookManagerImpl->GetContactsByCategoryN(categoryId);
301 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
307 AddressbookManager::GetContactsByPersonN(PersonId personId) const
309 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
310 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
311 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
312 SysAssertf(__pAddressbookManagerImpl != null,
313 "Not yet constructed. Construct() should be called before use.");
315 IList* pList = __pAddressbookManagerImpl->GetContactsByPersonN(personId);
316 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
322 AddressbookManager::AddMemberToCategory(RecordId categoryId, RecordId contactId)
324 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
325 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
326 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
327 SysAssertf(__pAddressbookManagerImpl != null,
328 "Not yet constructed. Construct() should be called before use.");
330 r = __pAddressbookManagerImpl->AddMemberToCategory(categoryId, contactId);
331 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
337 AddressbookManager::RemoveMemberFromCategory(RecordId categoryId, RecordId contactId)
339 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
340 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
341 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
342 SysAssertf(__pAddressbookManagerImpl != null,
343 "Not yet constructed. Construct() should be called before use.");
345 r = __pAddressbookManagerImpl->RemoveMemberFromCategory(categoryId, contactId);
346 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
352 AddressbookManager::GetAllCategoriesN(void) const
354 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
355 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
356 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
357 SysAssertf(__pAddressbookManagerImpl != null,
358 "Not yet constructed. Construct() should be called before use.");
360 IList* pList = __pAddressbookManagerImpl->GetAllCategoriesN();
361 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
367 AddressbookManager::GetCategoriesByContactN(RecordId contactId) const
369 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
370 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
371 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
372 SysAssertf(__pAddressbookManagerImpl != null,
373 "Not yet constructed. Construct() should be called before use.");
375 IList* pList = __pAddressbookManagerImpl->GetCategoriesByContactN(contactId);
376 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
382 AddressbookManager::GetCategoriesByPersonN(PersonId personId) const
384 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
385 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
386 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
387 SysAssertf(__pAddressbookManagerImpl != null,
388 "Not yet constructed. Construct() should be called before use.");
390 IList* pList = __pAddressbookManagerImpl->GetCategoriesByPersonN(personId);
391 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
397 AddressbookManager::SearchContactsByEmailN(const String& email) const
399 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
400 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
401 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
402 SysAssertf(__pAddressbookManagerImpl != null,
403 "Not yet constructed. Construct() should be called before use.");
405 IList* pList = __pAddressbookManagerImpl->SearchContactsByEmailN(email);
406 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
412 AddressbookManager::SearchContactsByNameN(const String& name) const
414 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
415 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
416 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
417 SysAssertf(__pAddressbookManagerImpl != null,
418 "Not yet constructed. Construct() should be called before use.");
420 IList* pList = __pAddressbookManagerImpl->SearchContactsByNameN(name);
421 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
427 AddressbookManager::SearchContactsByPhoneNumberN(const String& phoneNumber) const
429 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
430 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
431 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
432 SysAssertf(__pAddressbookManagerImpl != null,
433 "Not yet constructed. Construct() should be called before use.");
435 IList* pList = __pAddressbookManagerImpl->SearchContactsByPhoneNumberN(phoneNumber);
436 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
442 AddressbookManager::GetCategoryCount(void) const
444 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
445 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
446 SysTryReturn(NID_SCL, r == E_SUCCESS, -1, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
447 SysAssertf(__pAddressbookManagerImpl != null,
448 "Not yet constructed. Construct() should be called before use.");
450 int count = __pAddressbookManagerImpl->GetCategoryCount();
451 SysTryReturn(NID_SCL, count != -1, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
457 AddressbookManager::GetContactCount(void) const
459 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
460 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
461 SysTryReturn(NID_SCL, r == E_SUCCESS, -1, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
462 SysAssertf(__pAddressbookManagerImpl != null,
463 "Not yet constructed. Construct() should be called before use.");
465 int count = __pAddressbookManagerImpl->GetContactCount();
466 SysTryReturn(NID_SCL, count != -1, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
472 AddressbookManager::GetContactN(RecordId contactId) const
474 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
475 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
476 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
477 SysAssertf(__pAddressbookManagerImpl != null,
478 "Not yet constructed. Construct() should be called before use.");
480 Contact* pContact = __pAddressbookManagerImpl->GetContactN(contactId);
481 SysTryReturn(NID_SCL, pContact != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
487 AddressbookManager::GetPersonN(PersonId personId) const
489 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
490 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
491 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
492 SysAssertf(__pAddressbookManagerImpl != null,
493 "Not yet constructed. Construct() should be called before use.");
495 Person* pPerson = __pAddressbookManagerImpl->GetPersonN(personId);
496 SysTryReturn(NID_SCL, pPerson != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
501 AddressbookManager::GetCategoryN(RecordId categoryId) const
503 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
504 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
505 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
506 SysAssertf(__pAddressbookManagerImpl != null,
507 "Not yet constructed. Construct() should be called before use.");
509 Category* pCategory = __pAddressbookManagerImpl->GetCategoryN(categoryId);
510 SysTryReturn(NID_SCL, pCategory != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
516 AddressbookManager::GetLatestVersion(void) const
518 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
519 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
520 SysTryReturn(NID_SCL, r == E_SUCCESS, -1, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
521 SysAssertf(__pAddressbookManagerImpl != null,
522 "Not yet constructed. Construct() should be called before use.");
524 int latestVersion = __pAddressbookManagerImpl->GetLatestVersion();
525 SysTryReturn(NID_SCL, latestVersion != -1, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
527 return latestVersion;
531 AddressbookManager::GetChangedContactsAfterN(int version, int& latestVersion) const
533 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
534 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
535 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
536 SysAssertf(__pAddressbookManagerImpl != null,
537 "Not yet constructed. Construct() should be called before use.");
539 IList* pList = __pAddressbookManagerImpl->GetChangedContactsAfterN(version, latestVersion);
540 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
546 AddressbookManager::GetChangedCategoriesAfterN(int version, int& latestVersion) const
548 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
549 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
550 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
551 SysAssertf(__pAddressbookManagerImpl != null,
552 "Not yet constructed. Construct() should be called before use.");
554 IList* pList = __pAddressbookManagerImpl->GetChangedCategoriesAfterN(version, latestVersion);
555 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
561 AddressbookManager::RemovePerson(PersonId personId)
563 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
564 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
565 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
566 SysAssertf(__pAddressbookManagerImpl != null,
567 "Not yet constructed. Construct() should be called before use.");
569 return __pAddressbookManagerImpl->RemovePerson(personId);
573 AddressbookManager::SetPersonAsFavorite(PersonId personId, bool isFavorite)
575 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
576 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
577 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
578 SysAssertf(__pAddressbookManagerImpl != null,
579 "Not yet constructed. Construct() should be called before use.");
581 return __pAddressbookManagerImpl->SetPersonAsFavorite(personId, isFavorite);
585 AddressbookManager::GetAllPersonsN(void) const
587 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
588 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
589 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
590 SysAssertf(__pAddressbookManagerImpl != null,
591 "Not yet constructed. Construct() should be called before use.");
593 return __pAddressbookManagerImpl->GetAllPersonsN();
597 AddressbookManager::GetPersonsByCategoryN(RecordId categoryId) const
599 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
600 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
601 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
602 SysAssertf(__pAddressbookManagerImpl != null,
603 "Not yet constructed. Construct() should be called before use.");
605 return __pAddressbookManagerImpl->GetPersonsByCategoryN(categoryId);
609 AddressbookManager::GetFavoritePersonsN() const
611 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
612 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
613 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
614 SysAssertf(__pAddressbookManagerImpl != null,
615 "Not yet constructed. Construct() should be called before use.");
617 return __pAddressbookManagerImpl->GetFavoritePersonsN();
621 AddressbookManager::SearchPersonsN(const Tizen::Base::String& keyword) const
623 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
624 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
625 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
626 SysAssertf(__pAddressbookManagerImpl != null,
627 "Not yet constructed. Construct() should be called before use.");
629 return __pAddressbookManagerImpl->SearchPersonsN(keyword);
633 AddressbookManager::MergePersons(PersonId sourcePersonId, PersonId targetPersonId)
635 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
636 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
637 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
638 SysAssertf(__pAddressbookManagerImpl != null,
639 "Not yet constructed. Construct() should be called before use.");
641 r = __pAddressbookManagerImpl->MergePersons(sourcePersonId, targetPersonId);
642 SysTryReturn(NID_SCL, r == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
648 AddressbookManager::UnlinkContact(PersonId personId, RecordId contactId, PersonId& newPersonId)
650 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
651 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
652 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
653 SysAssertf(__pAddressbookManagerImpl != null,
654 "Not yet constructed. Construct() should be called before use.");
656 r = __pAddressbookManagerImpl->UnlinkContact(personId, contactId, newPersonId);
657 SysTryReturn(NID_SCL, r == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
663 AddressbookManager::SearchN(const AddressbookFilter& filter,
664 unsigned long propertyToSort, Tizen::Base::SortOrder sortOrder, int offset, int maxCount)
666 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
667 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
668 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
669 SysAssertf(__pAddressbookManagerImpl != null,
670 "Not yet constructed. Construct() should be called before use.");
672 return __pAddressbookManagerImpl->SearchN(filter, propertyToSort, sortOrder, offset, maxCount);
676 AddressbookManager::GetMatchedItemCount(const AddressbookFilter& filter)
678 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
679 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
680 SysTryReturn(NID_SCL, r == E_SUCCESS, -1, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
681 SysAssertf(__pAddressbookManagerImpl != null,
682 "Not yet constructed. Construct() should be called before use.");
684 return __pAddressbookManagerImpl->GetMatchedItemCount(filter);
688 AddressbookManager::ParseContactsFromVcardN(const Tizen::Base::String& vcardPath)
690 return __pAddressbookManagerImpl->ParseContactsFromVcardN(vcardPath);
694 AddressbookManager::ExportPersonToVcard(const Person& person, const Tizen::Base::String& vcardPath)
696 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
697 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
698 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
699 SysAssertf(__pAddressbookManagerImpl != null,
700 "Not yet constructed. Construct() should be called before use.");
702 return __pAddressbookManagerImpl->ExportPersonToVcard(person, vcardPath);
706 AddressbookManager::ExportPersonsToVcard(const Tizen::Base::Collection::IList& personList, const Tizen::Base::String& vcardPath)
708 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
709 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
710 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
711 SysAssertf(__pAddressbookManagerImpl != null,
712 "Not yet constructed. Construct() should be called before use.");
714 return __pAddressbookManagerImpl->ExportPersonsToVcard(personList, vcardPath);
718 AddressbookManager::ExportContactToVcard(const Contact& contact, const Tizen::Base::String& vcardPath)
720 return __pAddressbookManagerImpl->ExportContactToVcard(contact, vcardPath);
724 AddressbookManager::ExportContactsToVcard(const Tizen::Base::Collection::IList& contactList, const Tizen::Base::String& vcardPath)
726 return __pAddressbookManagerImpl->ExportContactsToVcard(contactList, vcardPath);
730 AddressbookManager::ExportContactToVcardStreamN(const Contact& contact)
732 return __pAddressbookManagerImpl->ExportContactToVcardStreamN(contact);
736 AddressbookManager::ExportContactsToVcardStreamN(const Tizen::Base::Collection::IList& contactList)
738 return __pAddressbookManagerImpl->ExportContactsToVcardStreamN(contactList);
742 AddressbookManager::ExportPersonToVcardStreamN(const Person& person)
744 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
745 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
746 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
747 SysAssertf(__pAddressbookManagerImpl != null,
748 "Not yet constructed. Construct() should be called before use.");
750 return __pAddressbookManagerImpl->ExportPersonToVcardStreamN(person);
754 AddressbookManager::ExportPersonsToVcardStreamN(const Tizen::Base::Collection::IList& personList)
756 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
757 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
758 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
759 SysAssertf(__pAddressbookManagerImpl != null,
760 "Not yet constructed. Construct() should be called before use.");
762 return __pAddressbookManagerImpl->ExportPersonsToVcardStreamN(personList);
766 AddressbookManager::ParseVcardStreamN(const Tizen::Base::ByteBuffer& vcardStream)
768 return __pAddressbookManagerImpl->ParseVcardStreamN(vcardStream);
771 Tizen::Base::ByteBuffer*
772 AddressbookManager::ExportUserProfileToVcardStreamN(const UserProfile& userProfile)
774 SysAssertf(__pAddressbookManagerImpl != null,
775 "Not yet constructed. Construct() should be called before use.");
777 return __pAddressbookManagerImpl->ExportUserProfileToVcardStreamN(userProfile);
780 Tizen::Base::ByteBuffer*
781 AddressbookManager::ExportUserProfilesToVcardStreamN(const Tizen::Base::Collection::IList& userProfileList)
783 SysAssertf(__pAddressbookManagerImpl != null,
784 "Not yet constructed. Construct() should be called before use.");
786 return __pAddressbookManagerImpl->ExportUserProfilesToVcardStreamN(userProfileList);
790 AddressbookManager::ExportUserProfileToVcard(const UserProfile& userProfile, const Tizen::Base::String& vcardPath)
792 SysAssertf(__pAddressbookManagerImpl != null,
793 "Not yet constructed. Construct() should be called before use.");
795 return __pAddressbookManagerImpl->ExportUserProfileToVcard(userProfile, vcardPath);
799 AddressbookManager::ExportUserProfilesToVcard(const Tizen::Base::Collection::IList& userProfileList, const Tizen::Base::String& vcardPath)
801 SysAssertf(__pAddressbookManagerImpl != null,
802 "Not yet constructed. Construct() should be called before use.");
804 return __pAddressbookManagerImpl->ExportUserProfilesToVcard(userProfileList, vcardPath);
807 Tizen::Base::Collection::IList*
808 AddressbookManager::GetAllUserProfilesN(void) const
810 result r = _AccessController::CheckUserPrivilege(_PRV_USERPROFILE_READ);
811 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
812 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
813 SysAssertf(__pAddressbookManagerImpl != null,
814 "Not yet constructed. Construct() should be called before use.");
816 return __pAddressbookManagerImpl->GetAllUserProfilesN();
820 AddressbookManager::GetUserProfileN(AddressbookId addressbookId) const
822 result r = _AccessController::CheckUserPrivilege(_PRV_USERPROFILE_READ);
823 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
824 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
825 SysAssertf(__pAddressbookManagerImpl != null,
826 "Not yet constructed. Construct() should be called before use.");
828 return __pAddressbookManagerImpl->GetUserProfileN(addressbookId);
832 AddressbookManager::GetInstance(void)
834 static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
836 if (__pInstance == null)
840 pthread_once(&onceBlock, InitAddressbookManager);
842 result r = GetLastResult();
846 onceBlock = PTHREAD_ONCE_INIT;
854 AddressbookManager::InitAddressbookManager(void)
856 std::unique_ptr<AddressbookManager> pInstance(new (std::nothrow) AddressbookManager());
857 SysTryReturnVoidResult(NID_SCL, pInstance, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
859 result r = pInstance->Construct();
860 SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Propagating.", GetErrorMessage(r));
862 __pInstance = pInstance.release();
864 std::atexit(DestroyAddressbookManager);
868 AddressbookManager::DestroyAddressbookManager(void)