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 FSclAddressbookManager.cpp
18 * @brief This is the implementation for AddressbookManager class.
20 * This file contains definitions of @e AddressbookManager class.
23 #include <unique_ptr.h>
25 #include <FBaseResult.h>
26 #include <FBaseString.h>
27 #include <FBaseColIList.h>
28 #include <FBaseSysLog.h>
29 #include <FSclContact.h>
30 #include <FSclCategory.h>
31 #include <FSclUserProfile.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 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
84 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
85 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
86 SysAssertf(__pAddressbookManagerImpl != null,
87 "Not yet constructed. Construct() should be called before use.");
89 r = __pAddressbookManagerImpl->SetEventListener(pListener);
90 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
96 AddressbookManager::SetAddressbookChangeEventListener(IAddressbookChangeEventListener* pListener)
98 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
99 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
100 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
101 SysAssertf(__pAddressbookManagerImpl != null,
102 "Not yet constructed. Construct() should be called before use.");
104 r = __pAddressbookManagerImpl->SetAddressbookChangeEventListener(pListener);
105 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
111 AddressbookManager::CreateAddressbookN(AccountId accountId, const String& name)
113 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
114 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
115 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
116 SysAssertf(__pAddressbookManagerImpl != null,
117 "Not yet constructed. Construct() should be called before use.");
119 Addressbook* pAddressbook = __pAddressbookManagerImpl->CreateAddressbookN(accountId, name);
120 SysTryReturn(NID_SCL, pAddressbook != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
126 AddressbookManager::DeleteAddressbook(AddressbookId addressbookId)
128 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
129 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
130 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
131 SysAssertf(__pAddressbookManagerImpl != null,
132 "Not yet constructed. Construct() should be called before use.");
134 r = __pAddressbookManagerImpl->DeleteAddressbook(addressbookId);
135 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
141 AddressbookManager::GetAddressbooksByAccountN(AccountId accountId) const
143 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
144 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
145 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
146 SysAssertf(__pAddressbookManagerImpl != null,
147 "Not yet constructed. Construct() should be called before use.");
149 IList* pList = __pAddressbookManagerImpl->GetAddressbooksByAccountN(accountId);
150 SysTryReturn(NID_SCL, pList !=null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
156 AddressbookManager::GetAllAddressbooksN(void) const
158 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
159 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
160 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
161 SysAssertf(__pAddressbookManagerImpl != null,
162 "Not yet constructed. Construct() should be called before use.");
164 IList* pList = __pAddressbookManagerImpl->GetAllAddressbooksN();
165 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
171 AddressbookManager::GetAddressbookN(AddressbookId addressbookId) const
173 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
174 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
175 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
176 SysAssertf(__pAddressbookManagerImpl != null,
177 "Not yet constructed. Construct() should be called before use.");
179 Addressbook* pAddressbook = __pAddressbookManagerImpl->GetAddressbookN(addressbookId);
180 SysTryReturn(NID_SCL, pAddressbook != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
186 AddressbookManager::AddContact(Contact& contact, AddressbookId addressbookId)
188 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
189 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
190 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
191 SysAssertf(__pAddressbookManagerImpl != null,
192 "Not yet constructed. Construct() should be called before use.");
194 r = __pAddressbookManagerImpl->AddContact(contact, addressbookId);
195 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
201 AddressbookManager::AddCategory(Category& category, AddressbookId addressbookId)
203 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
204 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
205 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
206 SysAssertf(__pAddressbookManagerImpl != null,
207 "Not yet constructed. Construct() should be called before use.");
209 r = __pAddressbookManagerImpl->AddCategory(category, addressbookId);
210 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
216 AddressbookManager::RemoveContact(RecordId contactId)
218 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
219 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
220 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
221 SysAssertf(__pAddressbookManagerImpl != null,
222 "Not yet constructed. Construct() should be called before use.");
224 r = __pAddressbookManagerImpl->RemoveContact(contactId);
225 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
231 AddressbookManager::RemoveCategory(RecordId categoryId)
233 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
234 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
235 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
236 SysAssertf(__pAddressbookManagerImpl != null,
237 "Not yet constructed. Construct() should be called before use.");
239 r = __pAddressbookManagerImpl->RemoveCategory(categoryId);
240 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
246 AddressbookManager::UpdateContact(const Contact& contact)
248 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
249 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
250 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
251 SysAssertf(__pAddressbookManagerImpl != null,
252 "Not yet constructed. Construct() should be called before use.");
254 r = __pAddressbookManagerImpl->UpdateContact(contact);
255 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
261 AddressbookManager::UpdateCategory(const Category& category)
263 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
264 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
265 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
266 SysAssertf(__pAddressbookManagerImpl != null,
267 "Not yet constructed. Construct() should be called before use.");
269 r = __pAddressbookManagerImpl->UpdateCategory(category);
270 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
276 AddressbookManager::GetAllContactsN(void) const
278 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
279 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
280 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
281 SysAssertf(__pAddressbookManagerImpl != null,
282 "Not yet constructed. Construct() should be called before use.");
284 IList* pList = __pAddressbookManagerImpl->GetAllContactsN();
285 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
291 AddressbookManager::GetContactsByCategoryN(RecordId categoryId) const
293 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
294 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
295 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
296 SysAssertf(__pAddressbookManagerImpl != null,
297 "Not yet constructed. Construct() should be called before use.");
299 IList* pList = __pAddressbookManagerImpl->GetContactsByCategoryN(categoryId);
300 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
306 AddressbookManager::GetContactsByPersonN(PersonId personId) const
308 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
309 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
310 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
311 SysAssertf(__pAddressbookManagerImpl != null,
312 "Not yet constructed. Construct() should be called before use.");
314 IList* pList = __pAddressbookManagerImpl->GetContactsByPersonN(personId);
315 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
321 AddressbookManager::AddMemberToCategory(RecordId categoryId, RecordId contactId)
323 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
324 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
325 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
326 SysAssertf(__pAddressbookManagerImpl != null,
327 "Not yet constructed. Construct() should be called before use.");
329 r = __pAddressbookManagerImpl->AddMemberToCategory(categoryId, contactId);
330 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
336 AddressbookManager::RemoveMemberFromCategory(RecordId categoryId, RecordId contactId)
338 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
339 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
340 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
341 SysAssertf(__pAddressbookManagerImpl != null,
342 "Not yet constructed. Construct() should be called before use.");
344 r = __pAddressbookManagerImpl->RemoveMemberFromCategory(categoryId, contactId);
345 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
351 AddressbookManager::GetAllCategoriesN(void) const
353 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
354 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
355 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
356 SysAssertf(__pAddressbookManagerImpl != null,
357 "Not yet constructed. Construct() should be called before use.");
359 IList* pList = __pAddressbookManagerImpl->GetAllCategoriesN();
360 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
366 AddressbookManager::GetCategoriesByContactN(RecordId contactId) const
368 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
369 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
370 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
371 SysAssertf(__pAddressbookManagerImpl != null,
372 "Not yet constructed. Construct() should be called before use.");
374 IList* pList = __pAddressbookManagerImpl->GetCategoriesByContactN(contactId);
375 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
381 AddressbookManager::GetCategoriesByPersonN(PersonId personId) const
383 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
384 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
385 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
386 SysAssertf(__pAddressbookManagerImpl != null,
387 "Not yet constructed. Construct() should be called before use.");
389 IList* pList = __pAddressbookManagerImpl->GetCategoriesByPersonN(personId);
390 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
396 AddressbookManager::SearchContactsByEmailN(const String& email) const
398 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
399 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
400 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
401 SysAssertf(__pAddressbookManagerImpl != null,
402 "Not yet constructed. Construct() should be called before use.");
404 IList* pList = __pAddressbookManagerImpl->SearchContactsByEmailN(email);
405 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
411 AddressbookManager::SearchContactsByNameN(const String& name) const
413 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
414 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
415 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
416 SysAssertf(__pAddressbookManagerImpl != null,
417 "Not yet constructed. Construct() should be called before use.");
419 IList* pList = __pAddressbookManagerImpl->SearchContactsByNameN(name);
420 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
426 AddressbookManager::SearchContactsByPhoneNumberN(const String& phoneNumber) const
428 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
429 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
430 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
431 SysAssertf(__pAddressbookManagerImpl != null,
432 "Not yet constructed. Construct() should be called before use.");
434 IList* pList = __pAddressbookManagerImpl->SearchContactsByPhoneNumberN(phoneNumber);
435 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
441 AddressbookManager::GetCategoryCount(void) const
443 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
444 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
445 SysTryReturn(NID_SCL, r == E_SUCCESS, -1, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
446 SysAssertf(__pAddressbookManagerImpl != null,
447 "Not yet constructed. Construct() should be called before use.");
449 int count = __pAddressbookManagerImpl->GetCategoryCount();
450 SysTryReturn(NID_SCL, count != -1, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
456 AddressbookManager::GetContactCount(void) const
458 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
459 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
460 SysTryReturn(NID_SCL, r == E_SUCCESS, -1, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
461 SysAssertf(__pAddressbookManagerImpl != null,
462 "Not yet constructed. Construct() should be called before use.");
464 int count = __pAddressbookManagerImpl->GetContactCount();
465 SysTryReturn(NID_SCL, count != -1, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
471 AddressbookManager::GetContactN(RecordId contactId) const
473 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
474 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
475 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
476 SysAssertf(__pAddressbookManagerImpl != null,
477 "Not yet constructed. Construct() should be called before use.");
479 Contact* pContact = __pAddressbookManagerImpl->GetContactN(contactId);
480 SysTryReturn(NID_SCL, pContact != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
486 AddressbookManager::GetPersonN(PersonId personId) const
488 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
489 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
490 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
491 SysAssertf(__pAddressbookManagerImpl != null,
492 "Not yet constructed. Construct() should be called before use.");
494 Person* pPerson = __pAddressbookManagerImpl->GetPersonN(personId);
495 SysTryReturn(NID_SCL, pPerson != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
500 AddressbookManager::GetCategoryN(RecordId categoryId) const
502 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
503 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
504 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
505 SysAssertf(__pAddressbookManagerImpl != null,
506 "Not yet constructed. Construct() should be called before use.");
508 Category* pCategory = __pAddressbookManagerImpl->GetCategoryN(categoryId);
509 SysTryReturn(NID_SCL, pCategory != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
515 AddressbookManager::GetLatestVersion(void) const
517 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
518 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
519 SysTryReturn(NID_SCL, r == E_SUCCESS, -1, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
520 SysAssertf(__pAddressbookManagerImpl != null,
521 "Not yet constructed. Construct() should be called before use.");
523 int latestVersion = __pAddressbookManagerImpl->GetLatestVersion();
524 SysTryReturn(NID_SCL, latestVersion != -1, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
526 return latestVersion;
530 AddressbookManager::GetChangedContactsAfterN(int version, int& latestVersion) const
532 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
533 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
534 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
535 SysAssertf(__pAddressbookManagerImpl != null,
536 "Not yet constructed. Construct() should be called before use.");
538 IList* pList = __pAddressbookManagerImpl->GetChangedContactsAfterN(version, latestVersion);
539 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
545 AddressbookManager::GetChangedCategoriesAfterN(int version, int& latestVersion) const
547 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
548 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
549 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
550 SysAssertf(__pAddressbookManagerImpl != null,
551 "Not yet constructed. Construct() should be called before use.");
553 IList* pList = __pAddressbookManagerImpl->GetChangedCategoriesAfterN(version, latestVersion);
554 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
560 AddressbookManager::RemovePerson(PersonId personId)
562 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
563 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
564 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
565 SysAssertf(__pAddressbookManagerImpl != null,
566 "Not yet constructed. Construct() should be called before use.");
568 return __pAddressbookManagerImpl->RemovePerson(personId);
572 AddressbookManager::SetPersonAsFavorite(PersonId personId, bool isFavorite)
574 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
575 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
576 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
577 SysAssertf(__pAddressbookManagerImpl != null,
578 "Not yet constructed. Construct() should be called before use.");
580 return __pAddressbookManagerImpl->SetPersonAsFavorite(personId, isFavorite);
584 AddressbookManager::GetAllPersonsN(void) const
586 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
587 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
588 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
589 SysAssertf(__pAddressbookManagerImpl != null,
590 "Not yet constructed. Construct() should be called before use.");
592 return __pAddressbookManagerImpl->GetAllPersonsN();
596 AddressbookManager::GetPersonsByCategoryN(RecordId categoryId) const
598 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
599 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
600 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
601 SysAssertf(__pAddressbookManagerImpl != null,
602 "Not yet constructed. Construct() should be called before use.");
604 return __pAddressbookManagerImpl->GetPersonsByCategoryN(categoryId);
608 AddressbookManager::GetFavoritePersonsN() const
610 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
611 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
612 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
613 SysAssertf(__pAddressbookManagerImpl != null,
614 "Not yet constructed. Construct() should be called before use.");
616 return __pAddressbookManagerImpl->GetFavoritePersonsN();
620 AddressbookManager::SearchPersonsN(const Tizen::Base::String& keyword) const
622 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
623 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
624 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
625 SysAssertf(__pAddressbookManagerImpl != null,
626 "Not yet constructed. Construct() should be called before use.");
628 return __pAddressbookManagerImpl->SearchPersonsN(keyword);
632 AddressbookManager::MergePersons(PersonId sourcePersonId, PersonId targetPersonId)
634 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
635 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
636 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
637 SysAssertf(__pAddressbookManagerImpl != null,
638 "Not yet constructed. Construct() should be called before use.");
640 r = __pAddressbookManagerImpl->MergePersons(sourcePersonId, targetPersonId);
641 SysTryReturn(NID_SCL, r == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
647 AddressbookManager::UnlinkContact(PersonId personId, RecordId contactId, PersonId& newPersonId)
649 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
650 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
651 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
652 SysAssertf(__pAddressbookManagerImpl != null,
653 "Not yet constructed. Construct() should be called before use.");
655 r = __pAddressbookManagerImpl->UnlinkContact(personId, contactId, newPersonId);
656 SysTryReturn(NID_SCL, r == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
662 AddressbookManager::SearchN(const AddressbookFilter& filter,
663 unsigned long propertyToSort, Tizen::Base::SortOrder sortOrder, int offset, int maxCount)
665 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
666 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
667 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
668 SysAssertf(__pAddressbookManagerImpl != null,
669 "Not yet constructed. Construct() should be called before use.");
671 return __pAddressbookManagerImpl->SearchN(filter, propertyToSort, sortOrder, offset, maxCount);
675 AddressbookManager::GetMatchedItemCount(const AddressbookFilter& filter)
677 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
678 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
679 SysTryReturn(NID_SCL, r == E_SUCCESS, -1, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
680 SysAssertf(__pAddressbookManagerImpl != null,
681 "Not yet constructed. Construct() should be called before use.");
683 return __pAddressbookManagerImpl->GetMatchedItemCount(filter);
687 AddressbookManager::ParseContactsFromVcardN(const Tizen::Base::String& vcardPath)
689 return __pAddressbookManagerImpl->ParseContactsFromVcardN(vcardPath);
693 AddressbookManager::ExportPersonToVcard(const Person& person, const Tizen::Base::String& vcardPath)
695 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
696 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
697 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
698 SysAssertf(__pAddressbookManagerImpl != null,
699 "Not yet constructed. Construct() should be called before use.");
701 return __pAddressbookManagerImpl->ExportPersonToVcard(person, vcardPath);
705 AddressbookManager::ExportPersonsToVcard(const Tizen::Base::Collection::IList& personList, const Tizen::Base::String& vcardPath)
707 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
708 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
709 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
710 SysAssertf(__pAddressbookManagerImpl != null,
711 "Not yet constructed. Construct() should be called before use.");
713 return __pAddressbookManagerImpl->ExportPersonsToVcard(personList, vcardPath);
717 AddressbookManager::ExportContactToVcard(const Contact& contact, const Tizen::Base::String& vcardPath)
719 return __pAddressbookManagerImpl->ExportContactToVcard(contact, vcardPath);
723 AddressbookManager::ExportContactsToVcard(const Tizen::Base::Collection::IList& contactList, const Tizen::Base::String& vcardPath)
725 return __pAddressbookManagerImpl->ExportContactsToVcard(contactList, vcardPath);
729 AddressbookManager::ExportContactToVcardStreamN(const Contact& contact)
731 return __pAddressbookManagerImpl->ExportContactToVcardStreamN(contact);
735 AddressbookManager::ExportContactsToVcardStreamN(const Tizen::Base::Collection::IList& contactList)
737 return __pAddressbookManagerImpl->ExportContactsToVcardStreamN(contactList);
741 AddressbookManager::ExportPersonToVcardStreamN(const Person& person)
743 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
744 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
745 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
746 SysAssertf(__pAddressbookManagerImpl != null,
747 "Not yet constructed. Construct() should be called before use.");
749 return __pAddressbookManagerImpl->ExportPersonToVcardStreamN(person);
753 AddressbookManager::ExportPersonsToVcardStreamN(const Tizen::Base::Collection::IList& personList)
755 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
756 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
757 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
758 SysAssertf(__pAddressbookManagerImpl != null,
759 "Not yet constructed. Construct() should be called before use.");
761 return __pAddressbookManagerImpl->ExportPersonsToVcardStreamN(personList);
765 AddressbookManager::ParseVcardStreamN(const Tizen::Base::ByteBuffer& vcardStream)
767 return __pAddressbookManagerImpl->ParseVcardStreamN(vcardStream);
770 Tizen::Base::ByteBuffer*
771 AddressbookManager::ExportUserProfileToVcardStreamN(const UserProfile& userProfile)
773 SysAssertf(__pAddressbookManagerImpl != null,
774 "Not yet constructed. Construct() should be called before use.");
776 return __pAddressbookManagerImpl->ExportUserProfileToVcardStreamN(userProfile);
779 Tizen::Base::ByteBuffer*
780 AddressbookManager::ExportUserProfilesToVcardStreamN(const Tizen::Base::Collection::IList& userProfileList)
782 SysAssertf(__pAddressbookManagerImpl != null,
783 "Not yet constructed. Construct() should be called before use.");
785 return __pAddressbookManagerImpl->ExportUserProfilesToVcardStreamN(userProfileList);
789 AddressbookManager::ExportUserProfileToVcard(const UserProfile& userProfile, const Tizen::Base::String& vcardPath)
791 SysAssertf(__pAddressbookManagerImpl != null,
792 "Not yet constructed. Construct() should be called before use.");
794 return __pAddressbookManagerImpl->ExportUserProfileToVcard(userProfile, vcardPath);
798 AddressbookManager::ExportUserProfilesToVcard(const Tizen::Base::Collection::IList& userProfileList, const Tizen::Base::String& vcardPath)
800 SysAssertf(__pAddressbookManagerImpl != null,
801 "Not yet constructed. Construct() should be called before use.");
803 return __pAddressbookManagerImpl->ExportUserProfilesToVcard(userProfileList, vcardPath);
806 Tizen::Base::Collection::IList*
807 AddressbookManager::GetAllUserProfilesN(void) const
809 result r = _AccessController::CheckUserPrivilege(_PRV_USERPROFILE_READ);
810 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
811 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
812 SysAssertf(__pAddressbookManagerImpl != null,
813 "Not yet constructed. Construct() should be called before use.");
815 return __pAddressbookManagerImpl->GetAllUserProfilesN();
819 AddressbookManager::GetUserProfileN(AddressbookId addressbookId) const
821 result r = _AccessController::CheckUserPrivilege(_PRV_USERPROFILE_READ);
822 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
823 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
824 SysAssertf(__pAddressbookManagerImpl != null,
825 "Not yet constructed. Construct() should be called before use.");
827 return __pAddressbookManagerImpl->GetUserProfileN(addressbookId);
831 AddressbookManager::GetInstance(void)
833 static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
835 if (__pInstance == null)
839 pthread_once(&onceBlock, InitAddressbookManager);
841 result r = GetLastResult();
845 onceBlock = PTHREAD_ONCE_INIT;
853 AddressbookManager::InitAddressbookManager(void)
855 std::unique_ptr<AddressbookManager> pInstance(new (std::nothrow) AddressbookManager());
856 SysTryReturnVoidResult(NID_SCL, pInstance, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
858 result r = pInstance->Construct();
859 SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Propagating.", GetErrorMessage(r));
861 __pInstance = pInstance.release();
863 std::atexit(DestroyAddressbookManager);
867 AddressbookManager::DestroyAddressbookManager(void)