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 <FSclAddressbookManager.h>
33 #include <FSec_AccessController.h>
34 #include <FScl_AddressbookManagerImpl.h>
36 using namespace Tizen::Base;
37 using namespace Tizen::Base::Collection;
38 using namespace Tizen::Security;
40 namespace Tizen { namespace Social
43 AddressbookManager* AddressbookManager::__pInstance = null;
45 AddressbookManager::AddressbookManager(void)
46 : __pAddressbookManagerImpl(null)
51 AddressbookManager::~AddressbookManager(void)
53 delete __pAddressbookManagerImpl;
57 AddressbookManager::Construct(void)
61 SysAssertf(__pAddressbookManagerImpl == null,
62 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
64 _AddressbookManagerImpl* pAddressbookManagerImpl = new (std::nothrow) _AddressbookManagerImpl();
65 SysTryReturnResult(NID_SCL, pAddressbookManagerImpl != null, E_OUT_OF_MEMORY, "Not enough memory.");
67 r = pAddressbookManagerImpl->Construct();
68 SysTryCatch(NID_SCL, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
70 __pAddressbookManagerImpl = pAddressbookManagerImpl;
75 delete pAddressbookManagerImpl;
81 AddressbookManager::SetEventListener(IAddressbookEventListener* pListener)
83 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED,
84 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
85 SysAssertf(__pAddressbookManagerImpl != null,
86 "Not yet constructed. Construct() should be called before use.");
88 result r = __pAddressbookManagerImpl->SetEventListener(pListener);
89 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
95 AddressbookManager::CreateAddressbookN(AccountId accountId, const String& name)
97 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE) == E_SUCCESS, null, E_PRIVILEGE_DENIED,
98 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
99 SysAssertf(__pAddressbookManagerImpl != null,
100 "Not yet constructed. Construct() should be called before use.");
102 Addressbook* pAddressbook = __pAddressbookManagerImpl->CreateAddressbookN(accountId, name);
103 SysTryReturn(NID_SCL, pAddressbook != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
109 AddressbookManager::DeleteAddressbook(AddressbookId addressbookId)
111 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE) == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED,
112 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
113 SysAssertf(__pAddressbookManagerImpl != null,
114 "Not yet constructed. Construct() should be called before use.");
116 result r = __pAddressbookManagerImpl->DeleteAddressbook(addressbookId);
117 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
123 AddressbookManager::GetAddressbooksByAccountN(AccountId accountId) const
125 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED,
126 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
127 SysAssertf(__pAddressbookManagerImpl != null,
128 "Not yet constructed. Construct() should be called before use.");
130 IList* pList = __pAddressbookManagerImpl->GetAddressbooksByAccountN(accountId);
131 SysTryReturn(NID_SCL, pList !=null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
137 AddressbookManager::GetAllAddressbooksN(void) const
139 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED,
140 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
141 SysAssertf(__pAddressbookManagerImpl != null,
142 "Not yet constructed. Construct() should be called before use.");
144 IList* pList = __pAddressbookManagerImpl->GetAllAddressbooksN();
145 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
151 AddressbookManager::GetAddressbookN(AddressbookId addressbookId) const
153 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED,
154 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
155 SysAssertf(__pAddressbookManagerImpl != null,
156 "Not yet constructed. Construct() should be called before use.");
158 Addressbook* pAddressbook = __pAddressbookManagerImpl->GetAddressbookN(addressbookId);
159 SysTryReturn(NID_SCL, pAddressbook != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
165 AddressbookManager::AddContact(Contact& contact, AddressbookId addressbookId)
167 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE) == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED,
168 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
169 SysAssertf(__pAddressbookManagerImpl != null,
170 "Not yet constructed. Construct() should be called before use.");
172 result r = __pAddressbookManagerImpl->AddContact(contact, addressbookId);
173 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
179 AddressbookManager::AddCategory(Category& category, AddressbookId addressbookId)
181 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE) == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED,
182 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
183 SysAssertf(__pAddressbookManagerImpl != null,
184 "Not yet constructed. Construct() should be called before use.");
186 result r = __pAddressbookManagerImpl->AddCategory(category, addressbookId);
187 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
193 AddressbookManager::RemoveContact(RecordId contactId)
195 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE) == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED,
196 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
197 SysAssertf(__pAddressbookManagerImpl != null,
198 "Not yet constructed. Construct() should be called before use.");
200 result r = __pAddressbookManagerImpl->RemoveContact(contactId);
201 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
207 AddressbookManager::RemoveCategory(RecordId categoryId)
209 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE) == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED,
210 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
211 SysAssertf(__pAddressbookManagerImpl != null,
212 "Not yet constructed. Construct() should be called before use.");
214 result r = __pAddressbookManagerImpl->RemoveCategory(categoryId);
215 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
221 AddressbookManager::UpdateContact(const Contact& contact)
223 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE) == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED,
224 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
225 SysAssertf(__pAddressbookManagerImpl != null,
226 "Not yet constructed. Construct() should be called before use.");
228 result r = __pAddressbookManagerImpl->UpdateContact(contact);
229 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
235 AddressbookManager::UpdateCategory(const Category& category)
237 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE) == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED,
238 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
239 SysAssertf(__pAddressbookManagerImpl != null,
240 "Not yet constructed. Construct() should be called before use.");
242 result r = __pAddressbookManagerImpl->UpdateCategory(category);
243 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
249 AddressbookManager::GetAllContactsN(void) const
251 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED,
252 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
253 SysAssertf(__pAddressbookManagerImpl != null,
254 "Not yet constructed. Construct() should be called before use.");
256 IList* pList = __pAddressbookManagerImpl->GetAllContactsN();
257 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
263 AddressbookManager::GetContactsByCategoryN(RecordId categoryId) const
265 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED,
266 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
267 SysAssertf(__pAddressbookManagerImpl != null,
268 "Not yet constructed. Construct() should be called before use.");
270 IList* pList = __pAddressbookManagerImpl->GetContactsByCategoryN(categoryId);
271 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
277 AddressbookManager::GetContactsByPersonN(PersonId personId) const
279 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED,
280 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
281 SysAssertf(__pAddressbookManagerImpl != null,
282 "Not yet constructed. Construct() should be called before use.");
284 IList* pList = __pAddressbookManagerImpl->GetContactsByPersonN(personId);
285 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
291 AddressbookManager::AddMemberToCategory(RecordId categoryId, RecordId contactId)
293 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE) == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED,
294 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
295 SysAssertf(__pAddressbookManagerImpl != null,
296 "Not yet constructed. Construct() should be called before use.");
298 result r = __pAddressbookManagerImpl->AddMemberToCategory(categoryId, contactId);
299 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
305 AddressbookManager::RemoveMemberFromCategory(RecordId categoryId, RecordId contactId)
307 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE) == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED,
308 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
309 SysAssertf(__pAddressbookManagerImpl != null,
310 "Not yet constructed. Construct() should be called before use.");
312 result r = __pAddressbookManagerImpl->RemoveMemberFromCategory(categoryId, contactId);
313 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
319 AddressbookManager::GetAllCategoriesN(void) const
321 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED,
322 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
323 SysAssertf(__pAddressbookManagerImpl != null,
324 "Not yet constructed. Construct() should be called before use.");
326 IList* pList = __pAddressbookManagerImpl->GetAllCategoriesN();
327 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
333 AddressbookManager::GetCategoriesByContactN(RecordId contactId) const
335 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED,
336 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
337 SysAssertf(__pAddressbookManagerImpl != null,
338 "Not yet constructed. Construct() should be called before use.");
340 IList* pList = __pAddressbookManagerImpl->GetCategoriesByContactN(contactId);
341 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
347 AddressbookManager::GetCategoriesByPersonN(PersonId personId) const
349 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED,
350 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
351 SysAssertf(__pAddressbookManagerImpl != null,
352 "Not yet constructed. Construct() should be called before use.");
354 IList* pList = __pAddressbookManagerImpl->GetCategoriesByPersonN(personId);
355 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
361 AddressbookManager::SearchContactsByEmailN(const String& email) const
363 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED,
364 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
365 SysAssertf(__pAddressbookManagerImpl != null,
366 "Not yet constructed. Construct() should be called before use.");
368 IList* pList = __pAddressbookManagerImpl->SearchContactsByEmailN(email);
369 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
375 AddressbookManager::SearchContactsByNameN(const String& name) const
377 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED,
378 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
379 SysAssertf(__pAddressbookManagerImpl != null,
380 "Not yet constructed. Construct() should be called before use.");
382 IList* pList = __pAddressbookManagerImpl->SearchContactsByNameN(name);
383 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
389 AddressbookManager::SearchContactsByPhoneNumberN(const String& phoneNumber) const
391 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED,
392 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
393 SysAssertf(__pAddressbookManagerImpl != null,
394 "Not yet constructed. Construct() should be called before use.");
396 IList* pList = __pAddressbookManagerImpl->SearchContactsByPhoneNumberN(phoneNumber);
397 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
403 AddressbookManager::GetCategoryCount(void) const
405 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, -1, E_PRIVILEGE_DENIED,
406 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
407 SysAssertf(__pAddressbookManagerImpl != null,
408 "Not yet constructed. Construct() should be called before use.");
410 int count = __pAddressbookManagerImpl->GetCategoryCount();
411 SysTryReturn(NID_SCL, count != -1, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
417 AddressbookManager::GetContactCount(void) const
419 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, -1, E_PRIVILEGE_DENIED,
420 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
421 SysAssertf(__pAddressbookManagerImpl != null,
422 "Not yet constructed. Construct() should be called before use.");
424 int count = __pAddressbookManagerImpl->GetContactCount();
425 SysTryReturn(NID_SCL, count != -1, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
431 AddressbookManager::GetContactN(RecordId contactId) const
433 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED,
434 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
435 SysAssertf(__pAddressbookManagerImpl != null,
436 "Not yet constructed. Construct() should be called before use.");
438 Contact* pContact = __pAddressbookManagerImpl->GetContactN(contactId);
439 SysTryReturn(NID_SCL, pContact != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
445 AddressbookManager::GetPersonN(PersonId personId) const
447 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED,
448 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
449 SysAssertf(__pAddressbookManagerImpl != null,
450 "Not yet constructed. Construct() should be called before use.");
452 Person* pPerson = __pAddressbookManagerImpl->GetPersonN(personId);
453 SysTryReturn(NID_SCL, pPerson != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
458 AddressbookManager::GetCategoryN(RecordId categoryId) const
460 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED,
461 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
462 SysAssertf(__pAddressbookManagerImpl != null,
463 "Not yet constructed. Construct() should be called before use.");
465 Category* pCategory = __pAddressbookManagerImpl->GetCategoryN(categoryId);
466 SysTryReturn(NID_SCL, pCategory != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
472 AddressbookManager::GetLatestVersion(void) const
474 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, -1, E_PRIVILEGE_DENIED,
475 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
476 SysAssertf(__pAddressbookManagerImpl != null,
477 "Not yet constructed. Construct() should be called before use.");
479 int latestVersion = __pAddressbookManagerImpl->GetLatestVersion();
480 SysTryReturn(NID_SCL, latestVersion != -1, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
482 return latestVersion;
486 AddressbookManager::GetChangedContactsAfterN(int version, int& latestVersion) const
488 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED,
489 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
490 SysAssertf(__pAddressbookManagerImpl != null,
491 "Not yet constructed. Construct() should be called before use.");
493 IList* pList = __pAddressbookManagerImpl->GetChangedContactsAfterN(version, latestVersion);
494 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
500 AddressbookManager::GetChangedCategoriesAfterN(int version, int& latestVersion) const
502 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED,
503 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
504 SysAssertf(__pAddressbookManagerImpl != null,
505 "Not yet constructed. Construct() should be called before use.");
507 IList* pList = __pAddressbookManagerImpl->GetChangedCategoriesAfterN(version, latestVersion);
508 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
514 AddressbookManager::RemovePerson(PersonId personId)
516 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE) == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED,
517 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
518 SysAssertf(__pAddressbookManagerImpl != null,
519 "Not yet constructed. Construct() should be called before use.");
521 return __pAddressbookManagerImpl->RemovePerson(personId);
525 AddressbookManager::SetPersonAsFavorite(PersonId personId, bool isFavorite)
527 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE) == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED,
528 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
529 SysAssertf(__pAddressbookManagerImpl != null,
530 "Not yet constructed. Construct() should be called before use.");
532 return __pAddressbookManagerImpl->SetPersonAsFavorite(personId, isFavorite);
536 AddressbookManager::GetAllPersonsN(void) const
538 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED,
539 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
540 SysAssertf(__pAddressbookManagerImpl != null,
541 "Not yet constructed. Construct() should be called before use.");
543 return __pAddressbookManagerImpl->GetAllPersonsN();
547 AddressbookManager::GetPersonsByCategoryN(RecordId categoryId) const
549 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED,
550 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
551 SysAssertf(__pAddressbookManagerImpl != null,
552 "Not yet constructed. Construct() should be called before use.");
554 return __pAddressbookManagerImpl->GetPersonsByCategoryN(categoryId);
558 AddressbookManager::GetFavoritePersonsN() const
560 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED,
561 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
562 SysAssertf(__pAddressbookManagerImpl != null,
563 "Not yet constructed. Construct() should be called before use.");
565 return __pAddressbookManagerImpl->GetFavoritePersonsN();
569 AddressbookManager::SearchPersonsN(const Tizen::Base::String& keyword) const
571 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED,
572 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
573 SysAssertf(__pAddressbookManagerImpl != null,
574 "Not yet constructed. Construct() should be called before use.");
576 return __pAddressbookManagerImpl->SearchPersonsN(keyword);
580 AddressbookManager::MergePersons(PersonId sourcePersonId, PersonId targetPersonId)
582 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE) == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED,
583 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
584 SysAssertf(__pAddressbookManagerImpl != null,
585 "Not yet constructed. Construct() should be called before use.");
587 result r = __pAddressbookManagerImpl->MergePersons(sourcePersonId, targetPersonId);
588 SysTryReturn(NID_SCL, r == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
594 AddressbookManager::UnlinkContact(PersonId personId, RecordId contactId, PersonId& newPersonId)
596 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE) == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED,
597 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
598 SysAssertf(__pAddressbookManagerImpl != null,
599 "Not yet constructed. Construct() should be called before use.");
601 result r = __pAddressbookManagerImpl->UnlinkContact(personId, contactId, newPersonId);
602 SysTryReturn(NID_SCL, r == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
608 AddressbookManager::SearchN(const AddressbookFilter& filter,
609 unsigned long propertyToSort, Tizen::Base::SortOrder sortOrder, int offset, int maxCount)
611 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED,
612 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
613 SysAssertf(__pAddressbookManagerImpl != null,
614 "Not yet constructed. Construct() should be called before use.");
616 return __pAddressbookManagerImpl->SearchN(filter, propertyToSort, sortOrder, offset, maxCount);
620 AddressbookManager::GetMatchedItemCount(const AddressbookFilter& filter)
622 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, -1, E_PRIVILEGE_DENIED,
623 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
624 SysAssertf(__pAddressbookManagerImpl != null,
625 "Not yet constructed. Construct() should be called before use.");
627 return __pAddressbookManagerImpl->GetMatchedItemCount(filter);
631 AddressbookManager::ParseContactsFromVcardN(const Tizen::Base::String& vcardPath)
633 return __pAddressbookManagerImpl->ParseContactsFromVcardN(vcardPath);
637 AddressbookManager::ExportPersonToVcard(const Person& person, const Tizen::Base::String& vcardPath)
639 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED,
640 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
641 SysAssertf(__pAddressbookManagerImpl != null,
642 "Not yet constructed. Construct() should be called before use.");
644 return __pAddressbookManagerImpl->ExportPersonToVcard(person, vcardPath);
648 AddressbookManager::ExportPersonsToVcard(const Tizen::Base::Collection::IList& personList, const Tizen::Base::String& vcardPath)
650 SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED,
651 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
652 SysAssertf(__pAddressbookManagerImpl != null,
653 "Not yet constructed. Construct() should be called before use.");
655 return __pAddressbookManagerImpl->ExportPersonsToVcard(personList, vcardPath);
659 AddressbookManager::ExportContactToVcard(const Contact& contact, const Tizen::Base::String& vcardPath)
661 return __pAddressbookManagerImpl->ExportContactToVcard(contact, vcardPath);
665 AddressbookManager::ExportContactsToVcard(const Tizen::Base::Collection::IList& contactList, const Tizen::Base::String& vcardPath)
667 return __pAddressbookManagerImpl->ExportContactsToVcard(contactList, vcardPath);
671 AddressbookManager::GetInstance(void)
673 static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
675 if (__pInstance == null)
679 pthread_once(&onceBlock, InitAddressbookManager);
681 result r = GetLastResult();
685 onceBlock = PTHREAD_ONCE_INIT;
693 AddressbookManager::InitAddressbookManager(void)
695 std::unique_ptr<AddressbookManager> pInstance(new (std::nothrow) AddressbookManager());
696 SysTryReturnVoidResult(NID_SCL, pInstance, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
698 result r = pInstance->Construct();
699 SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Propagating.", GetErrorMessage(r));
701 __pInstance = pInstance.release();
703 std::atexit(DestroyAddressbookManager);
707 AddressbookManager::DestroyAddressbookManager(void)