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 FScl_AddressbookManagerImpl.cpp
18 * @brief This is the implementation for _AddressbookManagerImpl class.
20 * This file contains definitions of @e _AddressbookManagerImpl class.
23 #include <unique_ptr.h>
24 #include <FBaseColIListT.h>
25 #include <FBaseColArrayListT.h>
26 #include <FBaseColHashMapT.h>
27 #include <FBaseResult.h>
28 #include <FBaseLongLong.h>
29 #include <FBaseInteger.h>
31 #include <FSclAddressbook.h>
32 #include <FSclAddressbookManager.h>
33 #include <FSclIAddressbookChangeEventListener.h>
34 #include <FSclContact.h>
35 #include <FSclCategory.h>
36 #include <FSclUserProfile.h>
37 #include <FSclContactChangeInfo.h>
38 #include <FSclCategoryChangeInfo.h>
39 #include <FSclPerson.h>
40 #include <FSclPhoneNumberContact.h>
41 #include <FScl_PhoneNumberContactImpl.h>
42 #include <FSclEmailContact.h>
43 #include <FScl_EmailContactImpl.h>
44 #include <FSclAddressbookFilter.h>
45 #include <FSclIAddressbookEventListener.h>
46 #include <FSclIRecordEventListener.h>
47 #include <FBaseSysLog.h>
48 #include <FApp_AppInfo.h>
49 #include <FBase_StringConverter.h>
50 #include "FScl_AddressbookImpl.h"
51 #include "FScl_AddressbookFilterImpl.h"
52 #include "FScl_AddressbookManagerImpl.h"
53 #include "FScl_AddressbookUtil.h"
54 #include "FScl_RecordImpl.h"
55 #include "FScl_ContactImpl.h"
56 #include "FScl_CategoryImpl.h"
57 #include "FScl_PersonImpl.h"
58 #include "FScl_AddressbookUtil.h"
59 #include "FScl_ContactChangeInfoImpl.h"
60 #include "FScl_CategoryChangeInfoImpl.h"
61 #include "FScl_ContactDbMonitor.h"
62 #include "FScl_ContactDbConnector.h"
63 #include "FScl_UserProfileImpl.h"
66 using namespace Tizen::App;
67 using namespace Tizen::Base;
68 using namespace Tizen::Base::Collection;
69 using namespace Tizen::Io;
70 using namespace Tizen::Graphics;
72 namespace Tizen { namespace Social
75 _AddressbookManagerImpl::_AddressbookManagerImpl(void)
76 : __pIAddressbookEventListener(null)
77 , __pIAddressbookChangeEventListener(null)
78 , __dbVersionForContact(0)
79 , __dbVersionForGroup(0)
80 , __dbVersionForRelation(0)
85 _AddressbookManagerImpl::~_AddressbookManagerImpl(void)
87 if (__pIAddressbookEventListener != null || __pIAddressbookChangeEventListener != null)
89 _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance();
90 if (pContactDbMonitor != null)
92 pContactDbMonitor->RemoveListener(*this);
98 _AddressbookManagerImpl::Construct(void)
100 result r = _ContactDbConnector::EnsureDbConnection();
101 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
107 _AddressbookManagerImpl::SetEventListener(IAddressbookEventListener* pListener)
109 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
111 result r = E_SUCCESS;
113 if (pListener != null)
115 if (__pIAddressbookEventListener == null && __pIAddressbookChangeEventListener == null)
117 _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance();
118 SysTryReturn(NID_SCL, pContactDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
120 r = pContactDbMonitor->AddListener(*this);
121 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
124 __dbVersionForContact = GetLatestVersion();
125 SysTryReturn(NID_SCL, __dbVersionForContact != -1, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
127 __dbVersionForGroup = __dbVersionForContact;
128 __dbVersionForRelation = __dbVersionForContact;
130 __pIAddressbookChangeEventListener = null;
131 __pIAddressbookEventListener = pListener;
135 if (__pIAddressbookEventListener != null || __pIAddressbookChangeEventListener != null)
138 _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance();
139 SysTryReturn(NID_SCL, pContactDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
141 pContactDbMonitor->RemoveListener(*this);
144 __pIAddressbookEventListener = null;
145 __pIAddressbookChangeEventListener = null;
152 _AddressbookManagerImpl::SetAddressbookChangeEventListener(IAddressbookChangeEventListener* pListener)
154 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
156 result r = E_SUCCESS;
158 if (pListener != null)
160 if (__pIAddressbookChangeEventListener == null && __pIAddressbookEventListener == null)
162 _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance();
163 SysTryReturn(NID_SCL, pContactDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
165 r = pContactDbMonitor->AddListener(*this);
166 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
169 __dbVersionForContact = GetLatestVersion();
170 SysTryReturn(NID_SCL, __dbVersionForContact != -1, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
172 __dbVersionForGroup = __dbVersionForContact;
173 __dbVersionForRelation = __dbVersionForContact;
175 __pIAddressbookEventListener = null;
176 __pIAddressbookChangeEventListener = pListener;
180 if (__pIAddressbookChangeEventListener != null || __pIAddressbookEventListener != null)
183 _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance();
184 SysTryReturn(NID_SCL, pContactDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
186 pContactDbMonitor->RemoveListener(*this);
189 __pIAddressbookChangeEventListener = null;
190 __pIAddressbookEventListener = null;
197 _AddressbookManagerImpl::CreateAddressbookN(AccountId accountId, const String& name)
199 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
200 SysTryReturn(NID_SCL, accountId >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. account id is invalid.", GetErrorMessage(E_INVALID_ARG));
201 SysTryReturn(NID_SCL, !name.IsEmpty(), null, E_INVALID_ARG, "[%s] Invalid argument is used. The name is empty.", GetErrorMessage(E_INVALID_ARG));
205 result r = E_SUCCESS;
208 unique_ptr<char[]> pNameString(_StringConverter::CopyToCharArrayN(name));
209 SysTryReturn(NID_SCL, pNameString !=null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
211 __Filter<__ContactsAddressbook> filter;
213 filter.AddString(_contacts_address_book.name, CONTACTS_MATCH_EXACTLY, pNameString.get());
216 filter.AddOperator(CONTACTS_FILTER_OPERATOR_OR);
217 filter.AddInt(_contacts_address_book.account_id, CONTACTS_MATCH_EQUAL, accountId);
220 __Query<__ContactsAddressbook> query;
222 query.SetFilter(filter);
224 int count = _AddressbookUtil::GetCountWithQuery(query);
225 SysTryReturn(NID_SCL, count == 0, null, E_OBJ_ALREADY_EXIST, "[%s] The name is already being used by other addressbook.", GetErrorMessage(E_OBJ_ALREADY_EXIST));
227 unique_ptr<Addressbook> pAddressbook(new (std::nothrow) Addressbook());
228 SysTryReturn(NID_SCL, pAddressbook != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
230 r = pAddressbook->Construct();
231 SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
233 unique_ptr<ContactRecord, ContactRecordDeleter> pAbRecord(_AddressbookUtil::CreateContactRecordN(_contacts_address_book._uri));
234 SysTryReturn(NID_SCL, pAbRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
236 contacts_record_set_str(pAbRecord.get(), _contacts_address_book.name, pNameString.get());
237 contacts_record_set_int(pAbRecord.get(), _contacts_address_book.account_id, accountId);
239 r = _AddressbookUtil::InsertContactRecordN(pAbRecord.get(), recordId);
240 SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
242 _AddressbookImpl::GetInstance(*pAddressbook)->SetAccountId(accountId);
243 _AddressbookImpl::GetInstance(*pAddressbook)->SetName(name);
244 _AddressbookImpl::GetInstance(*pAddressbook)->SetId(recordId);
246 return pAddressbook.release();
250 _AddressbookManagerImpl::DeleteAddressbook(AddressbookId addressbookId)
252 SysTryReturn(NID_SCL, addressbookId > 0, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument used.The addressbook ID is invalid or the default addressbook ID.", GetErrorMessage(E_INVALID_ARG));
253 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
254 result r = _AddressbookUtil::DeleteContactRecord(_contacts_address_book._uri, addressbookId);
255 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
261 _AddressbookManagerImpl::GetAddressbooksByAccountN(AccountId accountId) const
263 SysTryReturn(NID_SCL, accountId >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. account id is invalid.", GetErrorMessage(E_INVALID_ARG));
264 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
268 IList* pAddressbooks = null;
270 __Filter<__ContactsAddressbook> accountFilter;
271 accountFilter.Construct();
272 accountFilter.AddInt(_contacts_address_book.account_id, CONTACTS_MATCH_EQUAL, accountId);
274 unique_ptr< __Filter<__ContactsAddressbook> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsAddressbook>());
275 if (pRwAbFilter->Get() == null)
277 __Query<__ContactsAddressbook> query;
279 query.SetFilter(accountFilter);
281 pAddressbooks = _AddressbookUtil::SearchWithQueryN<__ContactsAddressbook, Addressbook>(query);
282 SysTryReturn(NID_SCL, pAddressbooks != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
286 __Filter<__ContactsAddressbook> mainFilter;
287 mainFilter.Construct();
289 mainFilter.AddFilter(*pRwAbFilter);
290 mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
291 mainFilter.AddFilter(accountFilter);
293 __Query<__ContactsAddressbook> query;
295 query.SetFilter(mainFilter);
297 pAddressbooks = _AddressbookUtil::SearchWithQueryN<__ContactsAddressbook, Addressbook>(query);
298 SysTryReturn(NID_SCL, pAddressbooks != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
301 return pAddressbooks;
305 _AddressbookManagerImpl::GetAllAddressbooksN(void) const
307 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
311 __Filter<__ContactsAddressbook> abFilter;
312 abFilter.Construct();
313 abFilter.AddInt(_contacts_address_book.mode, CONTACTS_MATCH_EQUAL, 0);
315 __Query<__ContactsAddressbook> query;
317 query.SetFilter(abFilter);
318 query.SetSort(_contacts_address_book.name, true);
320 IList* pAddressbooks = _AddressbookUtil::SearchWithQueryN<__ContactsAddressbook, Addressbook>(query);
321 SysTryReturn(NID_SCL, pAddressbooks != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
323 return pAddressbooks;
327 _AddressbookManagerImpl::GetAddressbookN(AddressbookId addressbookId) const
329 SysTryReturn(NID_SCL, addressbookId >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. addressbookId.", GetErrorMessage(E_INVALID_ARG), addressbookId);
330 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
334 result r = E_SUCCESS;
336 char* pCharValue = null;
338 unique_ptr<ContactRecord, ContactRecordDeleter> pAbRecord(_AddressbookUtil::GetContactRecordN(_contacts_address_book._uri, addressbookId));
339 SysTryReturn(NID_SCL, pAbRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
341 contacts_record_get_int(pAbRecord.get(), _contacts_address_book.mode, &intValue);
342 SysTryReturn(NID_SCL, intValue == 0, null, E_OBJ_NOT_FOUND, "[%s] Addressbook does not exist.", GetErrorMessage(E_OBJ_NOT_FOUND));
344 unique_ptr<Addressbook> pAddressbook(new (std::nothrow) Addressbook());
345 SysTryReturn(NID_SCL, pAddressbook !=null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
347 r = pAddressbook->Construct();
348 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
350 _AddressbookImpl::GetInstance(*pAddressbook)->SetId(addressbookId);
352 contacts_record_get_int(pAbRecord.get(), _contacts_address_book.account_id, &intValue);
353 _AddressbookImpl::GetInstance(*pAddressbook)->SetAccountId(intValue);
355 contacts_record_get_str_p(pAbRecord.get(), _contacts_address_book.name, &pCharValue);
356 _AddressbookImpl::GetInstance(*pAddressbook)->SetName(pCharValue);
358 return pAddressbook.release();
362 _AddressbookManagerImpl::AddContact(Contact& contact, AddressbookId addressbookId)
364 if (_ContactImpl::GetInstance(contact)->IsRemoved())
366 result r = _ContactImpl::GetInstance(contact)->Invalidate();
367 SysTryReturn(NID_SCL, r == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
370 SysTryReturn(NID_SCL, contact.GetRecordId() == INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The ID of specified contact is not INVALID_RECORD_ID.", GetErrorMessage(E_INVALID_ARG));
371 SysTryReturn(NID_SCL, !_ContactImpl::GetInstance(contact)->IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified contact does not have any property.", GetErrorMessage(E_INVALID_ARG));
372 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
374 unique_ptr<ContactRecord, ContactRecordDeleter> pAbRecord(_AddressbookUtil::GetContactRecordN(_contacts_address_book._uri, addressbookId));
375 SysTryReturn(NID_SCL, pAbRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
378 contacts_record_get_int(pAbRecord.get(), _contacts_address_book.mode, &intValue);
379 SysTryReturn(NID_SCL, intValue == 0, null, E_OBJ_NOT_FOUND, "[%s] Addressbook does not exist.", GetErrorMessage(E_OBJ_NOT_FOUND));
381 contacts_record_h recordHandle = _ContactImpl::GetInstance(contact)->GetContactRecordHandle();
382 contacts_record_set_int(recordHandle, _contacts_contact.address_book_id, addressbookId);
385 result r = _AddressbookUtil::InsertContactRecordN(recordHandle, recordId);
386 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
388 unique_ptr<ContactRecord, ContactRecordDeleter> pContactRecord(_AddressbookUtil::GetContactRecordN(_contacts_contact._uri, recordId));
389 SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
391 _ContactImpl::GetInstance(contact)->SetContactRecordHandle(pContactRecord.release());
392 _RecordImpl::GetInstance(contact)->SetRecordId(recordId);
398 _AddressbookManagerImpl::AddCategory(Category& category, AddressbookId addressbookId)
400 SysTryReturn(NID_SCL, category.GetRecordId() == INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified categoryId is not INVALID_RECORD_ID.", GetErrorMessage(E_INVALID_ARG));
401 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
403 unique_ptr<ContactRecord, ContactRecordDeleter> pAbRecord(_AddressbookUtil::GetContactRecordN(_contacts_address_book._uri, addressbookId));
404 SysTryReturn(NID_SCL, pAbRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
407 contacts_record_get_int(pAbRecord.get(), _contacts_address_book.mode, &intValue);
408 SysTryReturn(NID_SCL, intValue == 0, null, E_OBJ_NOT_FOUND, "[%s] Addressbook does not exist.", GetErrorMessage(E_OBJ_NOT_FOUND));
410 contacts_record_h recordHandle = _CategoryImpl::GetInstance(category)->GetRecordHandle();
411 contacts_record_set_int(recordHandle, _contacts_group.address_book_id, addressbookId);
414 result r = _AddressbookUtil::InsertContactRecordN(recordHandle, recordId);
415 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
417 unique_ptr<ContactRecord, ContactRecordDeleter> pCategoryRecord(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, recordId));
418 SysTryReturn(NID_SCL, pCategoryRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
420 _CategoryImpl::GetInstance(category)->SetRecordHandle(pCategoryRecord.release());
421 _RecordImpl::GetInstance(category)->SetRecordId(recordId);
423 unique_ptr<IListT<int> > pList(_CategoryImpl::GetInstance(category)->GetAddedMembersN());
424 if (pList != null && pList->GetCount() > 0)
426 unique_ptr<IEnumeratorT<int> > pEnum(pList->GetEnumeratorN());
428 while (pEnum->MoveNext() == E_SUCCESS)
431 pEnum->GetCurrent(tableId);
433 AddMemberToCategory(category.GetRecordId(), tableId);
436 _CategoryImpl::GetInstance(category)->ClearAddedMemberList();
443 _AddressbookManagerImpl::RemoveContact(RecordId contactId)
445 SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified contactId is invalid.", GetErrorMessage(E_INVALID_ARG));
446 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
447 result r = _AddressbookUtil::DeleteContactRecord(_contacts_contact._uri, contactId);
448 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
454 _AddressbookManagerImpl::RemoveCategory(RecordId categoryId)
456 SysTryReturn(NID_SCL, categoryId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified categoryId is invalid", GetErrorMessage(E_INVALID_ARG));
457 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
459 unique_ptr<ContactRecord, ContactRecordDeleter> pCategoryRecord(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, categoryId));
460 SysTryReturn(NID_SCL, pCategoryRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
462 bool isReadOnly = false;
463 contacts_record_get_bool(pCategoryRecord.get(), _contacts_group.is_read_only, &isReadOnly);
464 SysTryReturn(NID_SCL, !isReadOnly, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified category is a default category.", GetErrorMessage(E_INVALID_ARG));
466 result r = _AddressbookUtil::DeleteContactRecord(_contacts_group._uri, categoryId);
467 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
473 _AddressbookManagerImpl::UpdateContact(const Contact& contact)
475 RecordId contactId = contact.GetRecordId();
476 SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified contactId is not INVALID_RECORD_ID.", GetErrorMessage(E_INVALID_ARG));
477 SysTryReturn(NID_SCL, !_ContactImpl::GetInstance(contact)->IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified contact does not have any property.", GetErrorMessage(E_INVALID_ARG));
478 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
480 unique_ptr<ContactRecord, ContactRecordDeleter> pContactRecord(_AddressbookUtil::GetContactRecordN(_contacts_simple_contact._uri, contactId));
481 SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
484 contacts_record_get_int(pContactRecord.get(), _contacts_simple_contact.id, &intValue);
485 SysTryReturn(NID_SCL, intValue == contactId, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The contact is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
487 contacts_record_h recordHandle = _ContactImpl::GetInstance(contact)->GetContactRecordHandle();
488 SysTryReturn(NID_SCL, recordHandle != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
490 int ret = contacts_db_update_record(recordHandle);
491 if (ret == CONTACTS_ERROR_NO_DATA)
493 unsigned int count = 0;
494 unsigned int count2 = 0;
496 contacts_record_h newRecordHandle = null;
497 ret = contacts_db_get_record(_contacts_contact._uri, contactId, &newRecordHandle);
498 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
499 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
501 contacts_record_get_child_record_count(newRecordHandle, _contacts_contact.image, &count);
502 contacts_record_get_child_record_count(recordHandle, _contacts_contact.image, &count2);
504 contacts_record_h imageHandle = null;
505 contacts_record_h imageHandle2 = null;
510 for (int i = count2 - 1; i >= 0; i--)
512 contacts_record_get_child_record_at_p(recordHandle, _contacts_contact.image, i, &imageHandle);
513 contacts_record_get_int(imageHandle, _contacts_image.id, &imageId);
519 bool matchFound = false;
521 for (int j = 0; j < count; j++)
523 contacts_record_get_child_record_at_p(newRecordHandle, _contacts_contact.image, i, &imageHandle2);
524 contacts_record_get_int(imageHandle2, _contacts_image.id, &imageId2);
525 if (imageId == imageId2)
534 contacts_record_remove_child_record(recordHandle, _contacts_contact.image, imageHandle);
538 contacts_record_destroy(newRecordHandle, true);
540 contacts_record_h copyRecordHandle = CopyContactRecordHandle(recordHandle);
541 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
543 ret = contacts_db_replace_record(copyRecordHandle, contactId);
544 contacts_record_destroy(copyRecordHandle, true);
547 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
548 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is insufficient.", GetErrorMessage(E_STORAGE_FULL));
549 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred. Failed to update a contact.", GetErrorMessage(E_SYSTEM));
551 pContactRecord.reset(_AddressbookUtil::GetContactRecordN(_contacts_contact._uri, contact.GetRecordId()));
552 SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
554 _ContactImpl::GetInstance(*const_cast<Contact*>(&contact))->SetContactRecordHandle(pContactRecord.release());
560 _AddressbookManagerImpl::UpdateCategory(const Category& category)
562 RecordId categoryId = category.GetRecordId();
563 SysTryReturn(NID_SCL, categoryId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified category is invalid.", GetErrorMessage(E_INVALID_ARG));
564 SysTryReturn(NID_SCL, !category.GetName().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified category does not have name.", GetErrorMessage(E_INVALID_ARG));
565 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
567 unique_ptr<ContactRecord, ContactRecordDeleter> pCategoryRecord(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, category.GetRecordId()));
568 SysTryReturn(NID_SCL, pCategoryRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
571 contacts_record_get_int(pCategoryRecord.get(), _contacts_group.id, &intValue);
572 SysTryReturn(NID_SCL, intValue == categoryId, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The category is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
574 contacts_record_h recordHandle = _CategoryImpl::GetInstance(category)->GetRecordHandle();
576 int ret = contacts_db_update_record(recordHandle);
577 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
578 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is insufficient.", GetErrorMessage(E_STORAGE_FULL));
579 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
581 pCategoryRecord.reset(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, category.GetRecordId()));
582 SysTryReturn(NID_SCL, pCategoryRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
584 _CategoryImpl::GetInstance(*const_cast<Category*>(&category))->SetRecordHandle(pCategoryRecord.release());
586 unique_ptr<IListT<int> > pList(_CategoryImpl::GetInstance(category)->GetAddedMembersN());
587 if (pList != null && pList->GetCount() > 0)
590 unique_ptr<IEnumeratorT<int> > pEnum(pList->GetEnumeratorN());
591 while (pEnum->MoveNext() == E_SUCCESS)
593 pEnum->GetCurrent(tableId);
595 AddMemberToCategory(category.GetRecordId(), tableId);
598 const_cast<_CategoryImpl*>(_CategoryImpl::GetInstance(category))->ClearAddedMemberList();
601 pList.reset(_CategoryImpl::GetInstance(category)->GetRemovedMembersN());
602 if (pList != null && pList->GetCount() > 0)
605 unique_ptr<IEnumeratorT<int> > pEnum(pList->GetEnumeratorN());
606 while (pEnum->MoveNext() == E_SUCCESS)
608 pEnum->GetCurrent(tableId);
610 RemoveMemberFromCategory(category.GetRecordId(), tableId);
613 const_cast<_CategoryImpl*>(_CategoryImpl::GetInstance(category))->ClearRemovedMemberList();
620 _AddressbookManagerImpl::AddMemberToCategory(RecordId categoryId, RecordId contactId)
622 SysTryReturn(NID_SCL, categoryId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. categoryId = %d.", GetErrorMessage(E_INVALID_ARG), categoryId);
623 SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. contactId = %d.", GetErrorMessage(E_INVALID_ARG), contactId);
624 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
626 int ret = contacts_group_add_contact(categoryId, contactId);
627 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
628 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
629 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
635 _AddressbookManagerImpl::RemoveMemberFromCategory(RecordId categoryId, RecordId contactId)
637 SysTryReturn(NID_SCL, categoryId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. categoryId = %d.", GetErrorMessage(E_INVALID_ARG), categoryId);
638 SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. contactId = %d.", GetErrorMessage(E_INVALID_ARG), contactId);
639 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
641 int ret = contacts_group_remove_contact(categoryId, contactId);
642 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
643 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
644 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
650 _AddressbookManagerImpl::GetAllCategoriesN(void) const
652 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
656 unique_ptr< __Filter<__ContactsGroup> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsGroup>());
658 __Query<__ContactsGroup> query;
660 query.SetSort(_contacts_group.name, true);
662 if (pRwAbFilter->Get() != null)
664 query.SetFilter(*pRwAbFilter);
667 IList* pCategories = _AddressbookUtil::SearchWithQueryN<__ContactsGroup, Category>(query);
668 SysTryReturn(NID_SCL, pCategories != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
674 _AddressbookManagerImpl::GetCategoriesByContactN(RecordId contactId) const
676 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
677 SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, null, E_INVALID_ARG, "[%s] Invalid argument is used. The specified contact is invalid.", GetErrorMessage(E_INVALID_ARG));
680 IList* pCategories = null;
682 unique_ptr< __Filter<__ContactsContactGroupRel> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContactGroupRel>());
684 __Filter<__ContactsContactGroupRel> relFilter;
685 relFilter.Construct();
686 relFilter.AddInt(_contacts_contact_grouprel.contact_id, CONTACTS_MATCH_EQUAL, contactId);
688 if (pRwAbFilter->Get() != null)
690 __Filter<__ContactsContactGroupRel> mainFilter;
691 mainFilter.Construct();
692 mainFilter.AddFilter(*pRwAbFilter);
693 mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
694 mainFilter.AddFilter(relFilter);
696 __Query<__ContactsContactGroupRel> query;
698 query.SetFilter(mainFilter);
700 pCategories = _AddressbookUtil::SearchWithQueryN<__ContactsContactGroupRel, Category>(query);
701 SysTryReturn(NID_SCL, pCategories != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
705 __Query<__ContactsContactGroupRel> query;
707 query.SetFilter(relFilter);
709 pCategories = _AddressbookUtil::SearchWithQueryN<__ContactsContactGroupRel, Category>(query);
710 SysTryReturn(NID_SCL, pCategories != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
717 _AddressbookManagerImpl::GetCategoriesByPersonN(PersonId personId) const
719 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
723 IList* pCategories = null;
725 unique_ptr< __Filter<__ContactsContactGroupRel> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContactGroupRel>());
727 __Filter<__ContactsContactGroupRel> relFilter;
728 relFilter.Construct();
729 relFilter.AddInt(_contacts_contact_grouprel.person_id, CONTACTS_MATCH_EQUAL, personId);
730 relFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
731 relFilter.AddInt(_contacts_contact_grouprel.group_id, CONTACTS_MATCH_GREATER_THAN, 0);
733 unsigned int propertyIds[] =
735 _contacts_contact_grouprel.group_id,
738 if (pRwAbFilter->Get() != null)
741 __Filter<__ContactsContactGroupRel> mainFilter;
742 mainFilter.Construct();
743 mainFilter.AddFilter(*pRwAbFilter);
744 mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
745 mainFilter.AddFilter(relFilter);
748 __Query<__ContactsContactGroupRel> query;
750 query.SetProjection(propertyIds, sizeof(propertyIds)/sizeof(unsigned int));
751 query.SetFilter(mainFilter);
752 query.SetSort(_contacts_contact_grouprel.group_name, true);
753 query.SetDistinct(true);
755 pCategories = _AddressbookUtil::SearchWithQueryN<__ContactsContactGroupRel, Category>(query);
756 SysTryReturn(NID_SCL, pCategories != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
760 __Query<__ContactsContactGroupRel> query;
762 query.SetProjection(propertyIds, sizeof(propertyIds)/sizeof(unsigned int));
763 query.SetFilter(relFilter);
764 query.SetSort(_contacts_contact_grouprel.group_name, true);
765 query.SetDistinct(true);
767 pCategories = _AddressbookUtil::SearchWithQueryN<__ContactsContactGroupRel, Category>(query);
768 SysTryReturn(NID_SCL, pCategories != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
776 _AddressbookManagerImpl::GetAllContactsN(void) const
778 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
782 unique_ptr< __Filter<__ContactsContact> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContact>());
784 __Query<__ContactsContact> query;
786 query.SetSort(_contacts_contact.display_name, true);
788 if (pRwAbFilter->Get() != null)
790 query.SetFilter(*pRwAbFilter);
793 IList* pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContact, Contact>(query);
794 SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
800 _AddressbookManagerImpl::GetContactsByCategoryN(RecordId categoryId) const
802 SysTryReturn(NID_SCL, categoryId >= INVALID_RECORD_ID, null, E_INVALID_ARG, "[%s] Invalid argument is used. The category ID must be greater than or equal to INVALID_RECORD_ID.", GetErrorMessage(E_INVALID_ARG));
803 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
807 IList* pContacts = null;
809 unique_ptr< __Filter<__ContactsContactGroupRel> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContactGroupRel>());
811 __Filter<__ContactsContactGroupRel> relFilter;
812 relFilter.Construct();
814 if (categoryId != INVALID_RECORD_ID)
816 relFilter.AddInt(_contacts_contact_grouprel.group_id, CONTACTS_MATCH_EQUAL, categoryId);
820 relFilter.AddInt(_contacts_contact_grouprel.group_id, CONTACTS_MATCH_NONE, 0);
823 if (pRwAbFilter->Get() != null)
825 __Filter<__ContactsContactGroupRel> mainFilter;
826 mainFilter.Construct();
828 mainFilter.AddFilter(*pRwAbFilter);
829 mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
830 mainFilter.AddFilter(relFilter);
832 __Query<__ContactsContactGroupRel> query;
834 query.SetFilter(mainFilter);
836 pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContactGroupRel, Contact>(query);
837 SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
841 __Query<__ContactsContactGroupRel> query;
843 query.SetFilter(relFilter);
845 pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContactGroupRel, Contact>(query);
846 SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
853 _AddressbookManagerImpl::GetContactsByPersonN(PersonId personId) const
855 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
859 IList* pContacts = null;
861 unique_ptr< __Filter<__ContactsContact> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContact>());
863 __Filter<__ContactsContact> contactFilter;
864 contactFilter.Construct();
865 contactFilter.AddInt(_contacts_contact.person_id, CONTACTS_MATCH_EQUAL, personId);
867 if (pRwAbFilter->Get() != null)
869 __Filter<__ContactsContact> mainFilter;
870 mainFilter.Construct();
872 mainFilter.AddFilter(*pRwAbFilter);
873 mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
874 mainFilter.AddFilter(contactFilter);
876 __Query<__ContactsContact> query;
878 query.SetFilter(mainFilter);
879 query.SetSort(_contacts_contact.display_name, true);
881 pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContact, Contact>(query);
882 SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
886 __Query<__ContactsContact> query;
888 query.SetFilter(contactFilter);
889 query.SetSort(_contacts_contact.display_name, true);
891 pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContact, Contact>(query);
892 SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
899 _AddressbookManagerImpl::SearchContactsByEmailN(const String& email) const
901 SysTryReturn(NID_SCL, !email.IsEmpty(), null, E_INVALID_ARG, "[%s] Invalid argument is used. The specified email is an empty string.", GetErrorMessage(E_INVALID_ARG));
902 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
906 IList* pContacts = null;
908 unique_ptr< __Filter<__ContactsContactEmail> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContactEmail>());
910 unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(email));
911 SysTryReturn(NID_SCL, pCharArray != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
913 __Filter<__ContactsContactEmail> emailFilter;
914 emailFilter.Construct();
915 emailFilter.AddString(_contacts_contact_email.email, CONTACTS_MATCH_CONTAINS, pCharArray.get());
917 if (pRwAbFilter->Get() != null)
919 __Filter<__ContactsContactEmail> mainFilter;
920 mainFilter.Construct();
922 mainFilter.AddFilter(*pRwAbFilter);
923 mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
924 mainFilter.AddFilter(emailFilter);
926 __Query<__ContactsContactEmail> query;
928 query.SetFilter(mainFilter);
929 query.SetSort(_contacts_contact_email.display_name, true);
931 pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContactEmail, Contact>(query);
932 SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
936 __Query<__ContactsContactEmail> query;
938 query.SetFilter(emailFilter);
939 query.SetSort(_contacts_contact_email.display_name, true);
941 pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContactEmail, Contact>(query);
942 SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
950 _AddressbookManagerImpl::SearchContactsByNameN(const String& name) const
952 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
956 IList* pContacts = null;
958 unique_ptr< __Filter<__ContactsContact> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContact>());
960 SysTryReturn(NID_SCL, !name.IsEmpty(), null, E_INVALID_ARG, "[%s] Invalid argument is used. The specified email is an name string.", GetErrorMessage(E_INVALID_ARG));
962 unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(name));
963 SysTryReturn(NID_SCL, pCharArray != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
965 __Filter<__ContactsContact> nameFilter;
966 nameFilter.Construct();
967 nameFilter.AddString(_contacts_contact.display_name, CONTACTS_MATCH_CONTAINS, pCharArray.get());
969 if (pRwAbFilter->Get() != null)
971 __Filter<__ContactsContact> mainFilter;
972 mainFilter.Construct();
974 mainFilter.AddFilter(*pRwAbFilter);
975 mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
976 mainFilter.AddFilter(nameFilter);
978 __Query<__ContactsContact> query;
980 query.SetFilter(mainFilter);
981 query.SetSort(_contacts_contact.display_name, true);
983 pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContact, Contact>(query);
984 SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
988 __Query<__ContactsContact> query;
990 query.SetFilter(nameFilter);
991 query.SetSort(_contacts_contact.display_name, true);
993 pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContact, Contact>(query);
994 SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1001 _AddressbookManagerImpl::SearchContactsByPhoneNumberN(const String& phoneNumber) const
1003 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1007 IList* pContacts = null;
1009 SysTryReturn(NID_SCL, !phoneNumber.IsEmpty(), null, E_INVALID_ARG, "[%s] Invalid argument is used. The specified phoneNumber is an empty string.", GetErrorMessage(E_INVALID_ARG));
1011 unique_ptr< __Filter<__ContactsContactNumber> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContactNumber>());
1013 unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(phoneNumber));
1014 SysTryReturn(NID_SCL, pCharArray != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1016 __Filter<__ContactsContactNumber> numberFilter;
1017 numberFilter.Construct();
1018 numberFilter.AddString(_contacts_contact_number.normalized_number, CONTACTS_MATCH_CONTAINS, pCharArray.get());
1020 if (pRwAbFilter->Get() != null)
1022 __Filter<__ContactsContactNumber> mainFilter;
1023 mainFilter.Construct();
1025 mainFilter.AddFilter(*pRwAbFilter);
1026 mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
1027 mainFilter.AddFilter(numberFilter);
1029 __Query<__ContactsContactNumber> query;
1031 query.SetFilter(mainFilter);
1032 query.SetDistinct(true);
1033 query.SetSort(_contacts_contact_number.display_name, true);
1035 pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContactNumber, Contact>(query);
1036 SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1040 __Query<__ContactsContactNumber> query;
1042 query.SetFilter(numberFilter);
1043 query.SetDistinct(true);
1044 query.SetSort(_contacts_contact_number.display_name, true);
1046 pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContactNumber, Contact>(query);
1047 SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1055 _AddressbookManagerImpl::GetCategoryCount(void) const
1057 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1061 unique_ptr< __Filter<__ContactsGroup> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsGroup>());
1063 int count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsGroup>(pRwAbFilter->Get());
1064 SysTryReturn(NID_SCL, count >= 0, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1070 _AddressbookManagerImpl::GetContactCount(void) const
1072 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1076 unique_ptr< __Filter<__ContactsContact> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContact>());
1078 int count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsContact>(pRwAbFilter->Get());
1079 SysTryReturn(NID_SCL, count >= 0, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1085 _AddressbookManagerImpl::GetContactN(RecordId contactId) const
1087 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1088 SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, null, E_INVALID_ARG, "[%s] Invalid argument is used. contactId = %d.", GetErrorMessage(E_INVALID_ARG), contactId);
1092 unique_ptr<ContactRecord, ContactRecordDeleter> pContactRecord(_AddressbookUtil::GetContactRecordN(_contacts_contact._uri, contactId));
1093 SysTryReturn(NID_SCL, pContactRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1096 contacts_record_get_int(pContactRecord.get(), _contacts_contact.address_book_id, &intValue);
1098 unique_ptr<ContactRecord, ContactRecordDeleter> pAbRecord(_AddressbookUtil::GetContactRecordN(_contacts_address_book._uri, intValue));
1099 SysTryReturn(NID_SCL, pAbRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1101 contacts_record_get_int(pAbRecord.get(), _contacts_address_book.mode, &intValue);
1102 SysTryReturn(NID_SCL, intValue == 0, null, E_OBJ_NOT_FOUND, "[%s] Contact does not exist.", GetErrorMessage(E_OBJ_NOT_FOUND));
1104 contacts_record_get_int(pContactRecord.get(), _contacts_contact.id, &intValue);
1105 SysTryReturn(NID_SCL, intValue == contactId, null, E_OBJ_NOT_FOUND, "[%s] The contact is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
1107 unique_ptr<Contact> pContact(new (std::nothrow) Contact());
1108 SysTryReturn(NID_SCL, pContact, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1110 _ContactImpl::GetInstance(*pContact)->SetContactRecordHandle(pContactRecord.release());
1111 _RecordImpl::GetInstance(*pContact)->SetRecordId(intValue);
1113 return pContact.release();
1117 _AddressbookManagerImpl::GetPersonN(PersonId personId) const
1119 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1120 SysTryReturn(NID_SCL, personId >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. personId = %d.", GetErrorMessage(E_INVALID_ARG), personId);
1124 unique_ptr<ContactRecord, ContactRecordDeleter> pPersonRecord(_AddressbookUtil::GetContactRecordN(_contacts_person._uri, personId));
1127 contacts_record_get_int(pPersonRecord.get(), _contacts_person.id, &intValue);
1128 SysTryReturn(NID_SCL, intValue == personId, null, E_OBJ_NOT_FOUND, "[%s] The person is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
1130 Person* pPerson = __ContactsPerson::ConvertHandleTo<Person>(pPersonRecord.get());
1131 SysTryReturn(NID_SCL, pPerson != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1137 _AddressbookManagerImpl::GetCategoryN(RecordId categoryId) const
1139 SysTryReturn(NID_SCL, categoryId != INVALID_RECORD_ID, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. categoryId = %d.", categoryId);
1140 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1144 unique_ptr<ContactRecord, ContactRecordDeleter> pCategoryRecord(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, categoryId));
1145 SysTryReturn(NID_SCL, pCategoryRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1149 contacts_record_get_int(pCategoryRecord.get(), _contacts_group.id, &intValue);
1150 SysTryReturn(NID_SCL, categoryId == intValue, null, E_OBJ_NOT_FOUND, "[%s] The category is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
1152 contacts_record_get_int(pCategoryRecord.get(), _contacts_group.address_book_id, &intValue);
1154 unique_ptr<ContactRecord, ContactRecordDeleter> pAbRecord(_AddressbookUtil::GetContactRecordN(_contacts_address_book._uri, intValue));
1155 SysTryReturn(NID_SCL, pAbRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1157 contacts_record_get_int(pAbRecord.get(), _contacts_address_book.mode, &intValue);
1158 SysTryReturn(NID_SCL, intValue == 0, null, E_OBJ_NOT_FOUND, "[%s] Category does not exist.", GetErrorMessage(E_OBJ_NOT_FOUND));
1160 unique_ptr<Category> pCategory(new (std::nothrow) Category());
1161 SysTryReturn(NID_SCL, pCategory != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1163 __Filter<__ContactsGroupRelation> filter;
1165 filter.AddInt(_contacts_group_relation.group_id, CONTACTS_MATCH_EQUAL, categoryId);
1167 __Query<__ContactsGroupRelation> query;
1169 query.SetFilter(filter);
1171 int count = _AddressbookUtil::GetCountWithQuery(query);
1172 SysTryReturn(NID_SCL, count >= 0, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1174 _CategoryImpl::GetInstance(*pCategory)->SetRecordHandle(pCategoryRecord.release());
1175 _CategoryImpl::GetInstance(*pCategory)->SetMemberCount(count);
1176 _RecordImpl::GetInstance(*pCategory)->SetRecordId(categoryId);
1178 return pCategory.release();
1182 _AddressbookManagerImpl::GetLatestVersion(void) const
1184 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1186 int latestVersion = -1;
1190 int ret = contacts_db_get_current_version(&latestVersion);
1191 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, -1, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
1193 return latestVersion;
1197 _AddressbookManagerImpl::GetChangedContactsAfterN(int version, int& latestVersion) const
1199 SysTryReturn(NID_SCL, version >= 0, null, E_INVALID_ARG, "[%s] Invalid arguent is used. version %d must be greater that or equal 0.", GetErrorMessage(E_INVALID_ARG), version);
1200 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1204 unique_ptr< IListT<AddressbookId> > pRwAbIdList(_AddressbookUtil::GetRwAbIdListN());
1206 IList* pChangedContacts = _AddressbookUtil::SearchWithVersionN<__ContactsContactUpdatedInfo, ContactChangeInfo>(-1, version, latestVersion, pRwAbIdList.get());
1207 SysTryReturn(NID_SCL, pChangedContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1209 return pChangedContacts;
1213 _AddressbookManagerImpl::GetChangedCategoriesAfterN(int version, int& latestVersion) const
1215 SysTryReturn(NID_SCL, version >= 0, null, E_INVALID_ARG, "[%s] Invalid arguemnt is used. version %d must be greater that or equal 0.", GetErrorMessage(E_INVALID_ARG), version);
1216 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1220 int latestVersion1 = 0;
1221 int latestVersion2 = 0;
1223 unique_ptr< IListT<AddressbookId> > pRwAbIdList(_AddressbookUtil::GetRwAbIdListN());
1225 unique_ptr<IList, AllElementsDeleter> pChangedGroups(_AddressbookUtil::SearchWithVersionN<__ContactsGroupUpdatedInfo, CategoryChangeInfo>(-1, version, latestVersion1, pRwAbIdList.get()));
1226 SysTryReturn(NID_SCL, pChangedGroups != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1228 unique_ptr<IList, AllElementsDeleter> pChangedRelations(_AddressbookUtil::SearchWithVersionN<__ContactsGroupRelUpdatedInfo, CategoryChangeInfo>(-1, version, latestVersion2, pRwAbIdList.get()));
1229 SysTryReturn(NID_SCL, pChangedRelations != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1231 unique_ptr<ArrayList, AllElementsDeleter> pChangeList(new (std::nothrow) Tizen::Base::Collection::ArrayList());
1232 SysTryReturn(NID_SCL, pChangeList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1234 result r = pChangeList->AddItems(*pChangedGroups);
1235 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1237 r = pChangeList->AddItems(*pChangedRelations);
1238 SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1240 pChangedGroups->RemoveAll(false);
1241 pChangedRelations->RemoveAll(false);
1243 latestVersion = latestVersion2 > latestVersion1 ? latestVersion2 : latestVersion1;
1245 return pChangeList.release();
1249 _AddressbookManagerImpl::GetChangedGroupsAfterN(int version, int& latestVersion) const
1251 SysTryReturn(NID_SCL, version >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. version %d must be greater that or equal 0.", GetErrorMessage(E_INVALID_ARG), version);
1252 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1256 unique_ptr< IListT<AddressbookId> > pRwAbIdList(_AddressbookUtil::GetRwAbIdListN());
1258 IList* pChangedRelations = _AddressbookUtil::SearchWithVersionN<__ContactsGroupUpdatedInfo, CategoryChangeInfo>(-1, version, latestVersion, pRwAbIdList.get());
1259 SysTryReturn(NID_SCL, pChangedRelations != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1261 return pChangedRelations;
1265 _AddressbookManagerImpl::GetChangedRelationsAfterN(int version, int& latestVersion) const
1267 SysTryReturn(NID_SCL, version >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. version %d must be greater that or equal 0.", GetErrorMessage(E_INVALID_ARG), version);
1268 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1272 unique_ptr< IListT<AddressbookId> > pRwAbIdList(_AddressbookUtil::GetRwAbIdListN());
1274 IList* pChangedRelations = _AddressbookUtil::SearchWithVersionN<__ContactsGroupRelUpdatedInfo, CategoryChangeInfo>(-1, version, latestVersion, pRwAbIdList.get());
1275 SysTryReturn(NID_SCL, pChangedRelations != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1277 return pChangedRelations;
1281 _AddressbookManagerImpl::OnContactChanged(void)
1283 if (__pIAddressbookChangeEventListener == null && __pIAddressbookEventListener == null)
1288 IList* pChangedContactList = GetChangedContactsAfterN(__dbVersionForContact, __dbVersionForContact);
1289 SysTryReturnVoidResult(NID_SCL, pChangedContactList != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1291 if (pChangedContactList->GetCount() > 0)
1293 if (__pIAddressbookChangeEventListener != null)
1295 __pIAddressbookChangeEventListener->OnContactsChanged(*pChangedContactList);
1299 __pIAddressbookEventListener->OnContactsChanged(*pChangedContactList);
1303 pChangedContactList->RemoveAll(true);
1304 delete pChangedContactList;
1308 _AddressbookManagerImpl::OnCategoryChanged(void)
1310 if (__pIAddressbookChangeEventListener == null && __pIAddressbookEventListener == null)
1315 IList* pChangedCategoryList = GetChangedGroupsAfterN(__dbVersionForGroup, __dbVersionForGroup);
1316 SysTryReturnVoidResult(NID_SCL, pChangedCategoryList != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1318 if (pChangedCategoryList->GetCount() > 0)
1320 if (__pIAddressbookChangeEventListener != null)
1322 __pIAddressbookChangeEventListener->OnCategoriesChanged(*pChangedCategoryList);
1326 __pIAddressbookEventListener->OnCategoriesChanged(*pChangedCategoryList);
1330 pChangedCategoryList->RemoveAll(true);
1331 delete pChangedCategoryList;
1335 _AddressbookManagerImpl::OnRelationChanged(void)
1337 if (__pIAddressbookEventListener == null)
1342 IList* pChangedCategoryList = GetChangedRelationsAfterN(__dbVersionForRelation, __dbVersionForRelation);
1343 SysTryReturnVoidResult(NID_SCL, pChangedCategoryList != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1345 if (pChangedCategoryList->GetCount() > 0)
1347 if (__pIAddressbookEventListener != null)
1349 __pIAddressbookEventListener->OnCategoriesChanged(*pChangedCategoryList);
1353 pChangedCategoryList->RemoveAll(true);
1354 delete pChangedCategoryList;
1358 _AddressbookManagerImpl::RemovePerson(PersonId personId)
1360 SysTryReturnResult(NID_SCL, personId > 0, E_INVALID_ARG, "[%s] Invalid argument is used. ", GetErrorMessage(E_INVALID_ARG));
1361 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1363 result r = _AddressbookUtil::DeleteContactRecord(_contacts_person._uri, personId);
1364 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
1370 _AddressbookManagerImpl::GetAllPersonsN(void) const
1372 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1376 unique_ptr< __Filter<__ContactsPersonGroupRel> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsPersonGroupRel>());
1378 unsigned int propertyIds[] =
1380 _contacts_person_grouprel.person_id,
1381 _contacts_person_grouprel.display_name,
1382 _contacts_person_grouprel.image_thumbnail_path,
1383 _contacts_person_grouprel.ringtone_path,
1384 _contacts_person_grouprel.is_favorite,
1385 _contacts_person_grouprel.has_phonenumber,
1386 _contacts_person_grouprel.has_email,
1387 _contacts_person_grouprel.addressbook_ids,
1391 __Query<__ContactsPersonGroupRel> query;
1393 query.SetSort(_contacts_person.display_name, true);
1394 query.SetProjection(propertyIds, sizeof(propertyIds)/sizeof(unsigned int));
1395 query.SetDistinct(true);
1397 if (pRwAbFilter->Get() != null)
1399 query.SetFilter(*pRwAbFilter);
1402 IList* pPersons = _AddressbookUtil::SearchWithQueryN<__ContactsPersonGroupRel, Person>(query);
1403 SysTryReturn(NID_SCL, pPersons != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1409 _AddressbookManagerImpl::GetPersonsByCategoryN(RecordId categoryId) const
1411 SysTryReturn(NID_SCL, categoryId >= INVALID_RECORD_ID, null, E_INVALID_ARG, "[%s] Invalid argument is used. The specified categoryId is less than INVALID_RECORD_ID.", GetErrorMessage(E_INVALID_ARG));
1412 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1416 IList* pPersons = null;
1418 unique_ptr< __Filter<__ContactsPersonGroupRel> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsPersonGroupRel>());
1420 __Filter<__ContactsPersonGroupRel> groupFilter;
1421 groupFilter.Construct();
1422 if (categoryId != INVALID_RECORD_ID)
1424 groupFilter.AddInt(_contacts_person_grouprel.group_id, CONTACTS_MATCH_EQUAL, categoryId);
1428 groupFilter.AddInt(_contacts_person_grouprel.group_id, CONTACTS_MATCH_NONE, 0);
1431 unsigned int propertyIds[] =
1433 _contacts_person_grouprel.person_id,
1434 _contacts_person_grouprel.display_name,
1435 _contacts_person_grouprel.image_thumbnail_path,
1436 _contacts_person_grouprel.ringtone_path,
1437 _contacts_person_grouprel.is_favorite,
1438 _contacts_person_grouprel.has_phonenumber,
1439 _contacts_person_grouprel.has_email,
1440 _contacts_person_grouprel.addressbook_ids,
1443 if (pRwAbFilter->Get() != null)
1445 __Filter<__ContactsPersonGroupRel> mainFilter;
1446 mainFilter.Construct();
1448 mainFilter.AddFilter(*pRwAbFilter);
1449 mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
1450 mainFilter.AddFilter(groupFilter);
1452 __Query<__ContactsPersonGroupRel> query;
1454 query.SetProjection(propertyIds, sizeof(propertyIds)/sizeof(unsigned int));
1455 query.SetFilter(mainFilter);
1456 query.SetSort(_contacts_person_grouprel.display_name, true);
1457 query.SetDistinct(true);
1459 pPersons = _AddressbookUtil::SearchWithQueryN<__ContactsPersonGroupRel, Person>(query);
1460 SysTryReturn(NID_SCL, pPersons != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1464 __Query<__ContactsPersonGroupRel> query;
1466 query.SetProjection(propertyIds, sizeof(propertyIds)/sizeof(unsigned int));
1467 query.SetFilter(groupFilter);
1468 query.SetSort(_contacts_person_grouprel.display_name, true);
1469 query.SetDistinct(true);
1471 pPersons = _AddressbookUtil::SearchWithQueryN<__ContactsPersonGroupRel, Person>(query);
1472 SysTryReturn(NID_SCL, pPersons != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1480 _AddressbookManagerImpl::GetFavoritePersonsN() const
1482 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1486 __Filter<__ContactsPerson> filter;
1488 filter.AddBool(_contacts_person.is_favorite, true);
1490 __Query<__ContactsPerson> query;
1492 query.SetFilter(filter);
1493 query.SetSort(_contacts_person.display_name, true);
1495 IList* pPersons = _AddressbookUtil::SearchWithQueryN<__ContactsPerson, Person>(query);
1496 SysTryReturn(NID_SCL, pPersons != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1502 _AddressbookManagerImpl::SearchPersonsN(const Tizen::Base::String& keyword) const
1504 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1505 SysTryReturn(NID_SCL, !keyword.IsEmpty(), null, E_INVALID_ARG, "Invalid argument is used. keyword is empty string.", GetErrorMessage(E_INVALID_ARG));
1509 contacts_record_h currentRecord = null;
1510 unique_ptr<Person> pPerson(null);
1512 unique_ptr<ArrayList, AllElementsDeleter> pPersonList(new (std::nothrow) ArrayList());
1513 SysTryReturn(NID_SCL, pPersonList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1515 result r = pPersonList->Construct();
1516 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1518 unique_ptr<__SearchResult<__ContactsPerson> > pSearchResult(_AddressbookUtil::Search<__ContactsPerson>(keyword));
1519 SysTryReturn(NID_SCL, pSearchResult != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1521 while (pSearchResult->MoveNext() == E_SUCCESS)
1523 currentRecord = pSearchResult->GetCurrentRecord();
1524 SysTryReturn(NID_SCL, currentRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1526 pPerson.reset(__ContactsPerson::ConvertHandleTo<Person>(currentRecord));
1527 SysTryReturn(NID_SCL, pPerson != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1529 r = pPersonList->Add(*pPerson);
1530 SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
1535 return pPersonList.release();
1539 _AddressbookManagerImpl::SetPersonAsFavorite(PersonId personId, bool isFavorite)
1541 SysTryReturn(NID_SCL, personId > 0, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. personId = %d.", GetErrorMessage(E_INVALID_ARG), personId);
1542 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1544 unique_ptr<ContactRecord, ContactRecordDeleter> pPersonRecord(_AddressbookUtil::GetContactRecordN(_contacts_person._uri, personId));
1545 SysTryReturn(NID_SCL, pPersonRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1547 bool boolValue = false;
1548 contacts_record_get_bool(pPersonRecord.get(), _contacts_person.is_favorite, &boolValue);
1550 if (boolValue != isFavorite)
1552 contacts_record_set_bool(pPersonRecord.get(), _contacts_person.is_favorite, isFavorite);
1554 int ret = contacts_db_update_record(pPersonRecord.get());
1555 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1556 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
1563 _AddressbookManagerImpl::MergePersons(PersonId sourcePersonId, PersonId targetPersonId)
1565 SysTryReturn(NID_SCL, sourcePersonId > 0 && targetPersonId > 0, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. sourcePersonId %d and targetPersonId must be greater than 0.", GetErrorMessage(E_INVALID_ARG), sourcePersonId, targetPersonId);
1566 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1568 int ret = contacts_person_link_person(targetPersonId, sourcePersonId);
1569 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1570 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
1576 _AddressbookManagerImpl::UnlinkContact(PersonId personId, RecordId contactId, PersonId& newPersonId)
1578 SysTryReturn(NID_SCL, personId > 0 && contactId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. personId %d must be greater thant 0 and contactId %d must not be INVALID_RECORD_ID.", GetErrorMessage(E_INVALID_ARG), personId, contactId);
1579 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1581 int ret = contacts_person_unlink_contact(personId, contactId, &newPersonId);
1582 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1583 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
1589 _AddressbookManagerImpl::SearchN(const AddressbookFilter& filter, unsigned long propertySortedBy, SortOrder sortOrder, int offset, int maxCount)
1591 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1595 IList* pList = null;
1596 bool ascending = false;
1597 unsigned int viewSortPropertyId = 0;
1599 AddressbookFilterType type = _AddressbookFilterImpl::GetInstance(filter)->GetType();
1600 contacts_filter_h filterHandle = _AddressbookFilterImpl::GetInstance(filter)->GetFilterHandle();
1602 SysTryReturn(NID_SCL, propertySortedBy == 0 || _AddressbookFilterImpl::IsValidProperty(type, propertySortedBy), null, E_INVALID_ARG, "[%s] Invalid argument is used. The protertyToSort %d can not be used for property for sorting.", GetErrorMessage(E_INVALID_ARG), propertySortedBy);
1604 if (propertySortedBy != 0 && sortOrder != SORT_ORDER_NONE)
1606 viewSortPropertyId = _AddressbookFilterImpl::GetViewPropertyId(type, propertySortedBy);
1607 ascending = (sortOrder == SORT_ORDER_ASCENDING) ? true : false;
1612 case AB_FI_TYPE_ADDRESSBOOK:
1614 unique_ptr< __Filter<__ContactsAddressbook> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsAddressbook>());
1616 __Filter<__ContactsAddressbook> abFilter;
1617 abFilter.Construct(filterHandle);
1619 if (pRwAbFilter->Get() != null)
1621 __Filter<__ContactsAddressbook> mainFilter;
1622 mainFilter.Construct();
1623 mainFilter.AddFilter(*pRwAbFilter);
1624 if (abFilter.Get() != null)
1626 mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
1627 mainFilter.AddFilter(abFilter);
1630 __Query<__ContactsAddressbook> query;
1632 query.SetFilter(mainFilter);
1634 if (viewSortPropertyId != 0)
1636 query.SetSort(viewSortPropertyId, ascending);
1639 pList = _AddressbookUtil::SearchWithQueryN<__ContactsAddressbook, Addressbook>(query, offset, maxCount);
1643 __Query<__ContactsAddressbook> query;
1645 query.SetFilter(abFilter);
1647 if (viewSortPropertyId != 0)
1649 query.SetSort(viewSortPropertyId, ascending);
1652 pList = _AddressbookUtil::SearchWithQueryN<__ContactsAddressbook, Addressbook>(query, offset, maxCount);
1657 case AB_FI_TYPE_PERSON:
1659 unique_ptr< __Filter<__ContactsPersonGroupRel> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsPersonGroupRel>());
1661 __Filter<__ContactsPersonGroupRel> personFilter;
1662 personFilter.Construct(filterHandle);
1664 unsigned int propertyIds[] =
1665 { _contacts_person_grouprel.person_id,
1666 _contacts_person_grouprel.addressbook_ids,
1667 _contacts_person_grouprel.is_favorite,
1668 _contacts_person_grouprel.has_phonenumber,
1669 _contacts_person_grouprel.has_email,
1670 _contacts_person_grouprel.image_thumbnail_path,
1671 _contacts_person_grouprel.ringtone_path,
1672 _contacts_person_grouprel.display_name
1675 if (pRwAbFilter->Get() != null)
1677 __Filter<__ContactsPersonGroupRel> mainFilter;
1678 mainFilter.Construct();
1679 mainFilter.AddFilter(*pRwAbFilter);
1680 if (personFilter.Get() != null)
1682 mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
1683 mainFilter.AddFilter(personFilter);
1686 __Query<__ContactsPersonGroupRel> query;
1688 query.SetFilter(mainFilter);
1689 query.SetProjection(propertyIds, sizeof(propertyIds)/sizeof(unsigned int));
1690 query.SetDistinct(true);
1692 if (viewSortPropertyId != 0)
1694 query.SetSort(viewSortPropertyId, ascending);
1697 pList = _AddressbookUtil::SearchWithQueryN<__ContactsPersonGroupRel, Person>(query, offset, maxCount);
1701 __Query<__ContactsPersonGroupRel> query;
1703 query.SetFilter(personFilter);
1704 query.SetProjection(propertyIds, sizeof(propertyIds)/sizeof(unsigned int));
1705 query.SetDistinct(true);
1707 if (viewSortPropertyId != 0)
1709 query.SetSort(viewSortPropertyId, ascending);
1712 pList = _AddressbookUtil::SearchWithQueryN<__ContactsPersonGroupRel, Person>(query, offset, maxCount);
1716 case AB_FI_TYPE_CONTACT:
1718 unique_ptr< __Filter<__ContactsContact> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContact>());
1720 __Filter<__ContactsContact> contactFilter;
1721 contactFilter.Construct(filterHandle);
1723 if (pRwAbFilter->Get() != null)
1725 __Filter<__ContactsContact> mainFilter;
1726 mainFilter.Construct();
1727 mainFilter.AddFilter(*pRwAbFilter);
1728 if (contactFilter.Get() != null)
1730 mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
1731 mainFilter.AddFilter(contactFilter);
1734 __Query<__ContactsContact> query;
1736 query.SetFilter(mainFilter);
1738 if (viewSortPropertyId != 0)
1740 query.SetSort(viewSortPropertyId, ascending);
1743 pList = _AddressbookUtil::SearchWithQueryN<__ContactsContact, Contact>(query, offset, maxCount);
1747 __Query<__ContactsContact> query;
1749 query.SetFilter(contactFilter);
1751 if (viewSortPropertyId != 0)
1753 query.SetSort(viewSortPropertyId, ascending);
1756 pList = _AddressbookUtil::SearchWithQueryN<__ContactsContact, Contact>(query, offset, maxCount);
1761 case AB_FI_TYPE_CATEGORY:
1763 unique_ptr< __Filter<__ContactsGroup> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsGroup>());
1765 __Filter<__ContactsGroup> groupFilter;
1766 groupFilter.Construct(filterHandle);
1768 if (pRwAbFilter->Get() != null)
1770 __Filter<__ContactsGroup> mainFilter;
1771 mainFilter.Construct();
1772 mainFilter.AddFilter(*pRwAbFilter);
1773 if (groupFilter.Get() != null)
1775 mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
1776 mainFilter.AddFilter(groupFilter);
1779 __Query<__ContactsGroup> query;
1781 query.SetFilter(mainFilter);
1783 if (viewSortPropertyId != 0)
1785 query.SetSort(viewSortPropertyId, ascending);
1788 pList = _AddressbookUtil::SearchWithQueryN<__ContactsGroup, Category>(query, offset, maxCount);
1792 __Query<__ContactsGroup> query;
1794 query.SetFilter(groupFilter);
1796 if (viewSortPropertyId != 0)
1798 query.SetSort(viewSortPropertyId, ascending);
1801 pList = _AddressbookUtil::SearchWithQueryN<__ContactsGroup, Category>(query, offset, maxCount);
1805 case AB_FI_TYPE_PHONE_CONTACT:
1807 unique_ptr< __Filter<__ContactsContactNumber> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContactNumber>());
1809 __Filter<__ContactsContactNumber> numberFilter;
1810 numberFilter.Construct(filterHandle);
1812 if (pRwAbFilter->Get() != null)
1814 __Filter<__ContactsContactNumber> mainFilter;
1815 mainFilter.Construct();
1816 mainFilter.AddFilter(*pRwAbFilter);
1817 if (numberFilter.Get() != null)
1819 mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
1820 mainFilter.AddFilter(numberFilter);
1823 __Query<__ContactsContactNumber> query;
1825 query.SetFilter(mainFilter);
1827 if (viewSortPropertyId != 0)
1829 query.SetSort(viewSortPropertyId, ascending);
1832 pList = _AddressbookUtil::SearchWithQueryN<__ContactsContactNumber, PhoneNumberContact>(query, offset, maxCount);
1836 __Query<__ContactsContactNumber> query;
1838 query.SetFilter(numberFilter);
1840 if (viewSortPropertyId != 0)
1842 query.SetSort(viewSortPropertyId, ascending);
1845 pList = _AddressbookUtil::SearchWithQueryN<__ContactsContactNumber, PhoneNumberContact>(query, offset, maxCount);
1849 case AB_FI_TYPE_EMAIL_CONTACT:
1851 unique_ptr< __Filter<__ContactsContactEmail> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContactEmail>());
1853 __Filter<__ContactsContactEmail> emailFilter;
1854 emailFilter.Construct(filterHandle);
1856 if (pRwAbFilter->Get() != null)
1858 __Filter<__ContactsContactEmail> mainFilter;
1859 mainFilter.Construct();
1860 mainFilter.AddFilter(*pRwAbFilter);
1861 if (emailFilter.Get() != null)
1863 mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
1864 mainFilter.AddFilter(emailFilter);
1867 __Query<__ContactsContactEmail> query;
1869 query.SetFilter(mainFilter);
1871 if (viewSortPropertyId != 0)
1873 query.SetSort(viewSortPropertyId, ascending);
1876 pList = _AddressbookUtil::SearchWithQueryN<__ContactsContactEmail, EmailContact>(query, offset, maxCount);
1880 __Query<__ContactsContactEmail> query;
1882 query.SetFilter(emailFilter);
1884 if (viewSortPropertyId != 0)
1886 query.SetSort(viewSortPropertyId, ascending);
1889 pList = _AddressbookUtil::SearchWithQueryN<__ContactsContactEmail, EmailContact>(query, offset, maxCount);
1894 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. The filter type is invalid", GetErrorMessage(E_INVALID_ARG));
1902 _AddressbookManagerImpl::GetMatchedItemCount(const AddressbookFilter& filter)
1904 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1909 AddressbookFilterType type = _AddressbookFilterImpl::GetInstance(filter)->GetType();
1910 contacts_filter_h filterHandle = _AddressbookFilterImpl::GetInstance(filter)->GetFilterHandle();
1914 case AB_FI_TYPE_ADDRESSBOOK:
1916 unique_ptr< __Filter<__ContactsAddressbook> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsAddressbook>());
1918 __Filter<__ContactsAddressbook> abFilter;
1919 abFilter.Construct(filterHandle);
1921 if (pRwAbFilter->Get() != null)
1923 __Filter<__ContactsAddressbook> mainFilter;
1924 mainFilter.Construct();
1925 mainFilter.AddFilter(*pRwAbFilter);
1926 if (abFilter.Get() != null)
1928 mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
1929 mainFilter.AddFilter(abFilter);
1932 count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsAddressbook>(mainFilter.Get());
1936 count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsAddressbook>(abFilter.Get());
1940 case AB_FI_TYPE_PERSON:
1942 unique_ptr< __Filter<__ContactsPersonGroupRel> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsPersonGroupRel>());
1944 __Filter<__ContactsPersonGroupRel> personFilter;
1945 personFilter.Construct(filterHandle);
1947 if (pRwAbFilter->Get() != null)
1949 __Filter<__ContactsPersonGroupRel> mainFilter;
1950 mainFilter.Construct();
1951 mainFilter.AddFilter(*pRwAbFilter);
1952 if (personFilter.Get() != null)
1954 mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
1955 mainFilter.AddFilter(personFilter);
1958 unsigned int propertyIds[] = { _contacts_person_grouprel.person_id };
1960 __Query<__ContactsPersonGroupRel> query;
1962 query.SetFilter(mainFilter);
1963 query.SetProjection(propertyIds, sizeof(propertyIds)/sizeof(unsigned int));
1964 query.SetDistinct(true);
1966 count = _AddressbookUtil::GetCountWithQuery(query);
1970 unsigned int propertyIds[] = { _contacts_person_grouprel.person_id };
1972 __Query<__ContactsPersonGroupRel> query;
1974 query.SetFilter(personFilter);
1975 query.SetProjection(propertyIds, sizeof(propertyIds)/sizeof(unsigned int));
1976 query.SetDistinct(true);
1978 count = _AddressbookUtil::GetCountWithQuery(query);
1984 case AB_FI_TYPE_CONTACT:
1986 unique_ptr< __Filter<__ContactsContact> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContact>());
1988 __Filter<__ContactsContact> contactFilter;
1989 contactFilter.Construct(filterHandle);
1991 if (pRwAbFilter->Get() != null)
1993 __Filter<__ContactsContact> mainFilter;
1994 mainFilter.Construct();
1995 mainFilter.AddFilter(*pRwAbFilter);
1996 if (contactFilter.Get() != null)
1998 mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
1999 mainFilter.AddFilter(contactFilter);
2002 count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsContact>(mainFilter.Get());
2006 count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsContact>(contactFilter.Get());
2010 case AB_FI_TYPE_CATEGORY:
2012 unique_ptr< __Filter<__ContactsGroup> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsGroup>());
2014 __Filter<__ContactsGroup> groupFilter;
2015 groupFilter.Construct(filterHandle);
2017 if (pRwAbFilter->Get() != null)
2019 __Filter<__ContactsGroup> mainFilter;
2020 mainFilter.Construct();
2021 mainFilter.AddFilter(*pRwAbFilter);
2022 if (groupFilter.Get() != null)
2024 mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
2025 mainFilter.AddFilter(groupFilter);
2028 count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsGroup>(mainFilter.Get());
2032 count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsGroup>(groupFilter.Get());
2036 case AB_FI_TYPE_PHONE_CONTACT:
2038 unique_ptr< __Filter<__ContactsContactNumber> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContactNumber>());
2040 __Filter<__ContactsContactNumber> numberFilter;
2041 numberFilter.Construct(filterHandle);
2043 if (pRwAbFilter->Get() != null)
2045 __Filter<__ContactsContactNumber> mainFilter;
2046 mainFilter.Construct();
2047 mainFilter.AddFilter(*pRwAbFilter);
2048 if (numberFilter.Get() != null)
2050 mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
2051 mainFilter.AddFilter(numberFilter);
2054 count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsContactNumber>(mainFilter.Get());
2058 count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsContactNumber>(numberFilter.Get());
2062 case AB_FI_TYPE_EMAIL_CONTACT:
2064 unique_ptr< __Filter<__ContactsContactEmail> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContactEmail>());
2066 __Filter<__ContactsContactEmail> emailFilter;
2067 emailFilter.Construct(filterHandle);
2069 if (pRwAbFilter->Get() != null)
2071 __Filter<__ContactsContactEmail> mainFilter;
2072 mainFilter.Construct();
2073 mainFilter.AddFilter(*pRwAbFilter);
2074 if (emailFilter.Get() != null)
2076 mainFilter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
2077 mainFilter.AddFilter(emailFilter);
2080 count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsContactEmail>(mainFilter.Get());
2084 count = _AddressbookUtil::GetMatchedItemCountWithFilter<__ContactsContactEmail>(emailFilter.Get());
2089 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. The type of the filter is invalid", GetErrorMessage(GetLastResult()));
2097 _AddressbookManagerImpl::OnEachContact(contacts_record_h recordHandle, void* pUserData)
2099 IList* pList = static_cast<IList*>(pUserData);
2103 unique_ptr<Contact> pContact(new (std::nothrow) Contact());
2104 SysTryReturn(NID_SCL, pContact != null, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2106 contacts_record_h newRecordHandle = null;
2108 contacts_record_clone(recordHandle, &newRecordHandle);
2109 SysTryReturn(NID_SCL, newRecordHandle != null, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2111 _ContactImpl::GetInstance(*pContact)->SetContactRecordHandle(newRecordHandle);
2113 result r = pList->Add(*pContact);
2114 SysTryReturn(NID_SCL, !IsFailed(r), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2122 _AddressbookManagerImpl::ParseContactsFromVcardN(const Tizen::Base::String& vcardPath)
2124 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2129 result r = file.Construct(vcardPath, "r");
2130 SysTryReturn(NID_SCL, r != E_INVALID_ARG, null, E_INVALID_ARG, "[%s] Invalid argument is used..", GetErrorMessage(E_INVALID_ARG));
2131 SysTryReturn(NID_SCL, r != E_ILLEGAL_ACCESS, null, E_ILLEGAL_ACCESS, "[%s] Access to the vcard file is denied due to insufficient permission.", GetErrorMessage(E_ILLEGAL_ACCESS));
2132 SysTryReturn(NID_SCL, r != E_FILE_NOT_FOUND, null, E_FILE_NOT_FOUND, "[%s] The specified file does not exist.", GetErrorMessage(E_FILE_NOT_FOUND));
2133 SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2135 unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2137 unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(vcardPath));
2139 int ret = contacts_vcard_parse_to_contact_foreach(pCharArray.get(), OnEachContact, pList.get());
2140 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2141 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2142 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2144 return pList.release();
2148 _AddressbookManagerImpl::ExportPersonToVcard(const Person& person, const Tizen::Base::String& vcardPath)
2150 bool exist = File::IsFileExist(vcardPath);
2151 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating..", GetErrorMessage(GetLastResult()));
2152 SysTryReturn(NID_SCL, !exist, E_FILE_ALREADY_EXIST, E_FILE_ALREADY_EXIST, "[%s] The specified vcard file already exist.", GetErrorMessage(E_FILE_ALREADY_EXIST));
2153 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2156 result r = file.Construct(vcardPath, "w");
2157 SysTryReturn(NID_SCL, r != E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, "[%s] Access to the vcard file is denied due to insufficient permission.", GetErrorMessage(E_ILLEGAL_ACCESS));
2158 SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
2159 SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2161 unique_ptr<ContactRecord, ContactRecordDeleter> pPersonRecord(_AddressbookUtil::GetContactRecordN(_contacts_person._uri, person.GetId()));
2162 SysTryReturn(NID_SCL, pPersonRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2164 char* pVcardStream = null;
2165 int ret = contacts_vcard_make_from_person(pPersonRecord.get(), &pVcardStream);
2166 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2167 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2169 r = file.Write(pVcardStream, strlen(pVcardStream));
2171 SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
2172 SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2178 _AddressbookManagerImpl::ExportPersonsToVcard(const Tizen::Base::Collection::IList& personList, const Tizen::Base::String& vcardPath)
2180 bool exist = File::IsFileExist(vcardPath);
2181 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating..", GetErrorMessage(GetLastResult()));
2182 SysTryReturn(NID_SCL, !exist, E_FILE_ALREADY_EXIST, E_FILE_ALREADY_EXIST, "[%s] The specified vcard file already exist.", GetErrorMessage(E_FILE_ALREADY_EXIST));
2183 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2185 int ret = CONTACTS_ERROR_NONE;
2186 char* pVcardStream = null;
2189 result r = file.Construct(vcardPath, "w");
2190 SysTryReturn(NID_SCL, r != E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, "[%s] Access to the vcard file is denied due to insufficient permission.", GetErrorMessage(E_ILLEGAL_ACCESS));
2191 SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
2192 SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2195 unique_ptr<ContactRecord, ContactRecordDeleter> pPersonRecord(null);
2197 unique_ptr<IEnumerator> pEnum(personList.GetEnumeratorN());
2198 SysTryReturnResult(NID_SCL, pEnum != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2200 while (pEnum->MoveNext() == E_SUCCESS)
2202 Person* pPerson = static_cast<Person*>(pEnum->GetCurrent());
2204 pPersonRecord.reset(_AddressbookUtil::GetContactRecordN(_contacts_person._uri, pPerson->GetId()));
2205 SysTryReturn(NID_SCL, pPersonRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2207 ret = contacts_vcard_make_from_person(pPersonRecord.get(), &pVcardStream);
2208 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2209 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2211 r = file.Write(pVcardStream, strlen(pVcardStream));
2213 SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
2214 SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2221 _AddressbookManagerImpl::ExportContactToVcard(const Contact& contact, const Tizen::Base::String& vcardPath)
2223 bool exist = File::IsFileExist(vcardPath);
2224 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating..", GetErrorMessage(GetLastResult()));
2225 SysTryReturn(NID_SCL, !exist, E_FILE_ALREADY_EXIST, E_FILE_ALREADY_EXIST, "[%s] The specified vcard file already exist.", GetErrorMessage(E_FILE_ALREADY_EXIST));
2226 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2229 result r = file.Construct(vcardPath, "w");
2230 SysTryReturn(NID_SCL, r != E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, "[%s] Access to the vcard file is denied due to insufficient permission.", GetErrorMessage(E_ILLEGAL_ACCESS));
2231 SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
2232 SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2234 contacts_record_h recordHandle = _ContactImpl::GetInstance(contact)->GetContactRecordHandle();
2236 char* pVcardStream = null;
2238 int ret = contacts_vcard_make_from_contact(recordHandle, &pVcardStream);
2239 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2240 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2242 r = file.Write(pVcardStream, strlen(pVcardStream));
2244 SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
2245 SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2251 _AddressbookManagerImpl::ExportContactsToVcard(const Tizen::Base::Collection::IList& contactList, const Tizen::Base::String& vcardPath)
2253 bool exist = File::IsFileExist(vcardPath);
2254 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating..", GetErrorMessage(GetLastResult()));
2255 SysTryReturn(NID_SCL, !exist, E_FILE_ALREADY_EXIST, E_FILE_ALREADY_EXIST, "[%s] The specified vcard file already exist.", GetErrorMessage(E_FILE_ALREADY_EXIST));
2256 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2258 int ret = CONTACTS_ERROR_NONE;
2259 char* pVcardStream = null;
2261 Contact* pContact = null;
2263 result r = file.Construct(vcardPath, "w");
2264 SysTryReturn(NID_SCL, r != E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, "[%s] Access to the vcard file is denied due to insufficient permission.", GetErrorMessage(E_ILLEGAL_ACCESS));
2265 SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
2266 SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2268 contacts_record_h recordHandle = null;
2270 unique_ptr<IEnumerator> pEnum(contactList.GetEnumeratorN());
2271 SysTryReturnResult(NID_SCL, pEnum != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2273 while (pEnum->MoveNext() == E_SUCCESS)
2275 pContact = static_cast<Contact*>(pEnum->GetCurrent());
2277 recordHandle = _ContactImpl::GetInstance(*pContact)->GetContactRecordHandle();
2279 ret = contacts_vcard_make_from_contact(recordHandle, &pVcardStream);
2280 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2281 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2283 r = file.Write(pVcardStream, strlen(pVcardStream));
2285 SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
2286 SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2293 _AddressbookManagerImpl::ExportContactToVcardStreamN(const Contact& contact)
2295 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2299 contacts_record_h recordHandle = _ContactImpl::GetInstance(contact)->GetContactRecordHandle();
2301 char* pVcardStream = null;
2302 int ret = CONTACTS_ERROR_NONE;
2304 ret = contacts_vcard_make_from_contact(recordHandle, &pVcardStream);
2305 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, null, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
2306 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_SYSTEM, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2307 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2309 unique_ptr<ByteBuffer> pByteBuffer(new (std::nothrow) ByteBuffer);
2310 if (pByteBuffer == null)
2313 SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2318 result r = pByteBuffer->Construct(strlen(pVcardStream));
2322 SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2327 r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
2329 SysTryReturn(NID_SCL, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2330 SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2332 return pByteBuffer.release();
2336 _AddressbookManagerImpl::ExportContactsToVcardStreamN(const Tizen::Base::Collection::IList& contactList)
2338 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2342 char* pVcardStream = null;
2343 int ret = CONTACTS_ERROR_NONE;
2344 Contact* pContact = null;
2345 result r = E_SUCCESS;
2348 contacts_record_h recordHandle = null;
2350 unique_ptr<IEnumerator> pEnum(contactList.GetEnumeratorN());
2351 SysTryReturn(NID_SCL, pEnum != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2353 unique_ptr<ByteBuffer> pByteBuffer(new (std::nothrow) ByteBuffer);
2354 SysTryReturn(NID_SCL, pByteBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2356 r = pByteBuffer->Construct(capacity);
2357 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2359 if (contactList.GetCount() == 0)
2361 return pByteBuffer.release();
2364 while (pEnum->MoveNext() == E_SUCCESS)
2366 pContact = static_cast<Contact*>(pEnum->GetCurrent());
2368 recordHandle = _ContactImpl::GetInstance(*pContact)->GetContactRecordHandle();
2370 ret = contacts_vcard_make_from_contact(recordHandle, &pVcardStream);
2371 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, null, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
2372 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_SYSTEM, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2373 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2375 capacity += strlen(pVcardStream);
2376 r = pByteBuffer->ExpandCapacity(capacity);
2380 SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2385 r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
2387 pVcardStream = null;
2388 SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.: capacity(%d), size(%d)", GetErrorMessage(E_SYSTEM));
2391 return pByteBuffer.release();
2395 _AddressbookManagerImpl::ExportPersonToVcardStreamN(const Person& person)
2397 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2401 unique_ptr<ContactRecord, ContactRecordDeleter> pPersonRecord(_AddressbookUtil::GetContactRecordN(_contacts_person._uri, person.GetId()));
2402 SysTryReturn(NID_SCL, GetLastResult() != E_OBJ_NOT_FOUND, null, E_INVALID_ARG, "[%s] Person does not exist.", GetErrorMessage(E_INVALID_ARG));
2403 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, null, E_INVALID_ARG, "[%s] Person does not exist.", GetErrorMessage(E_INVALID_ARG));
2405 char* pVcardStream = null;
2406 int ret = contacts_vcard_make_from_person(pPersonRecord.get(), &pVcardStream);
2407 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2408 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, null, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
2409 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2411 unique_ptr<ByteBuffer> pByteBuffer(new (std::nothrow) ByteBuffer);
2412 if (pByteBuffer == null)
2415 SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2420 result r = pByteBuffer->Construct(strlen(pVcardStream));
2424 SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2429 r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
2431 SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2433 return pByteBuffer.release();
2437 _AddressbookManagerImpl::ExportPersonsToVcardStreamN(const Tizen::Base::Collection::IList& personList)
2439 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2443 int ret = CONTACTS_ERROR_NONE;
2444 Person* pPerson = null;
2445 char* pVcardStream = null;
2449 unique_ptr<ContactRecord, ContactRecordDeleter> pPersonRecord(null);
2451 unique_ptr<IEnumerator> pEnum(personList.GetEnumeratorN());
2452 SysTryReturn(NID_SCL, pEnum != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2454 unique_ptr<ByteBuffer> pByteBuffer(new (std::nothrow) ByteBuffer);
2455 SysTryReturn(NID_SCL, pByteBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2457 result r = pByteBuffer->Construct(capacity);
2458 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2460 if (personList.GetCount() == 0)
2462 return pByteBuffer.release();
2465 while (pEnum->MoveNext() == E_SUCCESS)
2467 pPerson = static_cast<Person*>(pEnum->GetCurrent());
2469 pPersonRecord.reset(_AddressbookUtil::GetContactRecordN(_contacts_person._uri, pPerson->GetId()));
2470 SysTryReturn(NID_SCL, GetLastResult() != E_OBJ_NOT_FOUND, null, E_INVALID_ARG, "[%s] Person does not exist.", GetErrorMessage(E_INVALID_ARG));
2471 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, null, E_INVALID_ARG, "[%s] Person does not exist.", GetErrorMessage(E_INVALID_ARG));
2473 ret = contacts_vcard_make_from_person(pPersonRecord.get(), &pVcardStream);
2474 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2475 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, null, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
2476 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2478 capacity += strlen(pVcardStream);
2479 r = pByteBuffer->ExpandCapacity(capacity);
2483 SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2488 r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
2490 pVcardStream = null;
2491 SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2494 return pByteBuffer.release();
2498 _AddressbookManagerImpl::ParseVcardStreamN(const Tizen::Base::ByteBuffer& vcardStream)
2500 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2504 contacts_list_h listHandle = null;
2505 result r = E_SUCCESS;
2507 int ret = contacts_vcard_parse_to_contacts(reinterpret_cast<char*>(const_cast<byte*>(vcardStream.GetPointer())), &listHandle);
2508 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, null, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
2509 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2511 unsigned int count = 0;
2512 contacts_record_h recordHandle = null;
2513 contacts_list_get_count(listHandle, &count);
2515 unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2518 contacts_list_destroy(listHandle, true);
2519 SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2524 r = pList->Construct(count);
2527 contacts_list_destroy(listHandle, true);
2528 SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2533 for (unsigned int i = 0; i < count; i++)
2535 unique_ptr<Contact> pContact(new (std::nothrow) Contact());
2536 if (pContact == null)
2538 contacts_list_destroy(listHandle, true);
2539 SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2544 r = pList->Add(pContact.get());
2547 contacts_list_destroy(listHandle, true);
2548 SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2556 unique_ptr<IEnumerator> pEnum(pList->GetEnumeratorN());
2558 while (pEnum->MoveNext() == E_SUCCESS)
2560 Contact* pContact = static_cast <Contact*> (pEnum->GetCurrent());
2562 contacts_list_get_current_record_p(listHandle, &recordHandle);
2563 _ContactImpl::GetInstance(*pContact)->SetContactRecordHandle(recordHandle);
2565 ret = contacts_list_next(listHandle);
2568 contacts_list_destroy(listHandle, false);
2570 return pList.release();
2574 _AddressbookManagerImpl::ExportUserProfileToVcardStreamN(const UserProfile& userProfile)
2576 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2580 char* pVcardStream = null;
2581 int ret = CONTACTS_ERROR_NONE;
2582 contacts_record_h recordHandle = null;
2584 recordHandle = _UserProfileImpl::GetInstance(userProfile)->GetUserProfileHandle();
2586 ret = contacts_vcard_make_from_my_profile(recordHandle, &pVcardStream);
2587 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, null, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
2588 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_SYSTEM, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2589 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2591 unique_ptr<ByteBuffer> pByteBuffer(new (std::nothrow) ByteBuffer);
2592 if (pByteBuffer == null)
2595 SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2599 SysTryReturn(NID_SCL, pByteBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2601 result r = pByteBuffer->Construct(strlen(pVcardStream));
2605 SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2610 r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
2612 SysTryReturn(NID_SCL, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2613 SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2615 return pByteBuffer.release();
2619 _AddressbookManagerImpl::ExportUserProfilesToVcardStreamN(const Tizen::Base::Collection::IList& userProfileList)
2621 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2625 char* pVcardStream = null;
2626 int ret = CONTACTS_ERROR_NONE;
2627 UserProfile* pProfile = null;
2628 result r = E_SUCCESS;
2631 unique_ptr<IEnumerator> pEnum(userProfileList.GetEnumeratorN());
2632 SysTryReturn(NID_SCL, pEnum != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2634 unique_ptr<ByteBuffer> pByteBuffer(new (std::nothrow) ByteBuffer);
2635 SysTryReturn(NID_SCL, pByteBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2637 r = pByteBuffer->Construct(capacity);
2638 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2640 if (userProfileList.GetCount() == 0)
2642 return pByteBuffer.release();
2645 while (pEnum->MoveNext() == E_SUCCESS)
2647 contacts_record_h recordHandle = null;
2649 pProfile = static_cast<UserProfile*>(pEnum->GetCurrent());
2651 recordHandle = _UserProfileImpl::GetInstance(*pProfile)->GetUserProfileHandle();
2653 ret = contacts_vcard_make_from_my_profile(recordHandle, &pVcardStream);
2654 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, null, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
2655 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_SYSTEM, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2656 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2658 capacity += strlen(pVcardStream);
2659 r = pByteBuffer->ExpandCapacity(capacity);
2663 SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2668 r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
2670 SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.: capacity(%d), size(%d)", GetErrorMessage(E_SYSTEM));
2673 return pByteBuffer.release();
2677 _AddressbookManagerImpl::ExportUserProfileToVcard(const UserProfile& userProfile, const Tizen::Base::String& vcardPath)
2679 bool exist = File::IsFileExist(vcardPath);
2680 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating..", GetErrorMessage(GetLastResult()));
2681 SysTryReturn(NID_SCL, !exist, E_FILE_ALREADY_EXIST, E_FILE_ALREADY_EXIST, "[%s] The specified vcard file already exist.", GetErrorMessage(E_FILE_ALREADY_EXIST));
2682 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2685 result r = file.Construct(vcardPath, "w");
2686 SysTryReturn(NID_SCL, r != E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, "[%s] Access to the vcard file is denied due to insufficient permission.", GetErrorMessage(E_ILLEGAL_ACCESS));
2687 SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
2688 SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2690 char* pVcardStream = null;
2691 contacts_record_h recordHandle = null;
2693 recordHandle = _UserProfileImpl::GetInstance(userProfile)->GetUserProfileHandle();
2695 int ret = contacts_vcard_make_from_my_profile(recordHandle, &pVcardStream);
2696 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2697 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2699 r = file.Write(pVcardStream, strlen(pVcardStream));
2701 SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
2702 SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2708 _AddressbookManagerImpl::ExportUserProfilesToVcard(const Tizen::Base::Collection::IList& userProfileList, const Tizen::Base::String& vcardPath)
2710 bool exist = File::IsFileExist(vcardPath);
2711 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating..", GetErrorMessage(GetLastResult()));
2712 SysTryReturn(NID_SCL, !exist, E_FILE_ALREADY_EXIST, E_FILE_ALREADY_EXIST, "[%s] The specified vcard file already exist.", GetErrorMessage(E_FILE_ALREADY_EXIST));
2713 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2715 int ret = CONTACTS_ERROR_NONE;
2716 char* pVcardStream = null;
2718 UserProfile* pProfile = null;
2720 result r = file.Construct(vcardPath, "w");
2721 SysTryReturn(NID_SCL, r != E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS, "[%s] Access to the vcard file is denied due to insufficient permission.", GetErrorMessage(E_ILLEGAL_ACCESS));
2722 SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
2723 SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2725 unique_ptr<IEnumerator> pEnum(userProfileList.GetEnumeratorN());
2726 SysTryReturnResult(NID_SCL, pEnum != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2728 while (pEnum->MoveNext() == E_SUCCESS)
2730 contacts_record_h recordHandle = null;
2732 pProfile = static_cast<UserProfile*>(pEnum->GetCurrent());
2734 recordHandle = _UserProfileImpl::GetInstance(*pProfile)->GetUserProfileHandle();
2736 ret = contacts_vcard_make_from_my_profile(recordHandle, &pVcardStream);
2737 SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2738 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2740 r = file.Write(pVcardStream, strlen(pVcardStream));
2742 SysTryReturn(NID_SCL, r != E_STORAGE_FULL, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is full.", GetErrorMessage(E_STORAGE_FULL));
2743 SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2750 _AddressbookManagerImpl::GetAllUserProfilesN(void) const
2752 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2756 unique_ptr< __Filter<__ContactsUserProfile> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsUserProfile>());
2757 SysTryReturn(NID_SCL, pRwAbFilter != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2759 __Query<__ContactsUserProfile> query;
2761 query.SetSort(_contacts_my_profile.display_name, true);
2763 if (pRwAbFilter->Get() != null)
2765 query.SetFilter(*pRwAbFilter);
2768 IList* pUserProfilesList = _AddressbookUtil::SearchWithQueryN<__ContactsUserProfile, UserProfile>(query);
2769 SysTryReturn(NID_SCL, pUserProfilesList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2771 return pUserProfilesList;
2775 _AddressbookManagerImpl::GetUserProfileN(AddressbookId addressbookId) const
2777 SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2778 SysTryReturn(NID_SCL, addressbookId >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. Addressbook Id(%d).", GetErrorMessage(E_INVALID_ARG), addressbookId);
2783 unique_ptr<ContactRecord, ContactRecordDeleter> pAbRecord(_AddressbookUtil::GetContactRecordN(_contacts_address_book._uri, addressbookId));
2784 SysTryReturn(NID_SCL, pAbRecord != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2786 contacts_record_get_int(pAbRecord.get(), _contacts_address_book.mode, &mode);
2787 SysTryReturn(NID_SCL, mode == 0, null, E_OBJ_NOT_FOUND, "[%s] The addressbook does not exist.", GetErrorMessage(E_OBJ_NOT_FOUND));
2789 __Filter<__ContactsUserProfile> filter;
2791 filter.AddInt(_contacts_my_profile.address_book_id, CONTACTS_MATCH_EQUAL, addressbookId);
2793 __Query<__ContactsUserProfile> query;
2795 query.SetFilter(filter);
2797 unique_ptr<IList, AllElementsDeleter> pUserProfilesList(_AddressbookUtil::SearchWithQueryN<__ContactsUserProfile, UserProfile>(query));
2798 SysTryReturn(NID_SCL, pUserProfilesList.get() != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2799 SysTryReturn(NID_SCL, pUserProfilesList->GetCount() != 0, null, E_SUCCESS, "No UserProfile Set for this Addressbook.");
2800 SysTryReturn(NID_SCL, pUserProfilesList->GetCount() == 1, null, E_SYSTEM, "[%s] Propagating. More than one UserProfile not allowed.", GetErrorMessage(E_SYSTEM));
2802 UserProfile* pProfile = new (std::nothrow) UserProfile(*(static_cast<UserProfile*>(pUserProfilesList->GetAt(0))));
2803 SysTryReturn(NID_SCL, pProfile != null, null, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(E_OUT_OF_MEMORY));
2809 _AddressbookManagerImpl::CopyContactRecordHandle(contacts_record_h srcHandle)
2813 int ret = CONTACTS_ERROR_NONE;
2815 unsigned int count = 0;
2816 char* pCharValue = null;
2818 bool boolValue = false;
2820 contacts_record_h contactHandle = null;
2821 contacts_record_h sourceRecordHandle = null;
2822 contacts_record_h destRecordHandle = null;
2824 ret = contacts_record_create(_contacts_contact._uri, &contactHandle);
2825 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2828 contacts_record_get_bool(sourceRecordHandle, _contacts_contact.is_favorite, &boolValue);
2829 contacts_record_set_bool(destRecordHandle, _contacts_contact.is_favorite, boolValue);
2832 contacts_record_get_str_p(sourceRecordHandle, _contacts_contact.uid, &pCharValue);
2833 contacts_record_set_str(destRecordHandle, _contacts_contact.uid, pCharValue);
2835 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
2837 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
2838 contacts_record_get_child_record_count(srcHandle, _contacts_contact.name, &count);
2841 contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.name, 0, &sourceRecordHandle);
2843 ret = contacts_record_create(_contacts_name._uri, &destRecordHandle);
2844 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2846 __ContactsRecordHandle nameHandle(destRecordHandle);
2849 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.first, &pCharValue);
2850 contacts_record_set_str(destRecordHandle, _contacts_name.first, pCharValue);
2853 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.last, &pCharValue);
2854 contacts_record_set_str(destRecordHandle, _contacts_name.last, pCharValue);
2857 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.addition, &pCharValue);
2858 contacts_record_set_str(destRecordHandle, _contacts_name.addition, pCharValue);
2861 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.suffix, &pCharValue);
2862 contacts_record_set_str(destRecordHandle, _contacts_name.suffix, pCharValue);
2865 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.prefix, &pCharValue);
2866 contacts_record_set_str(destRecordHandle, _contacts_name.prefix, pCharValue);
2868 // 6. phonetic_first
2869 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_first, &pCharValue);
2870 contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_first, pCharValue);
2873 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_last, &pCharValue);
2874 contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_last, pCharValue);
2876 // 8. phonetic_middle
2877 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_middle, &pCharValue);
2878 contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_middle, pCharValue);
2880 contacts_record_add_child_record(contactHandle, _contacts_contact.name, destRecordHandle);
2882 nameHandle.Release();
2885 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
2887 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
2888 contacts_record_get_child_record_count(srcHandle, _contacts_contact.image, &count);
2889 for (i = 0; i < count; i++)
2891 contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.image, i, &sourceRecordHandle);
2893 ret = contacts_record_create(_contacts_image._uri, &destRecordHandle);
2894 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2896 __ContactsRecordHandle imageHandle(destRecordHandle);
2898 contacts_record_get_int(sourceRecordHandle, _contacts_image.type, &intValue);
2899 contacts_record_set_int(destRecordHandle, _contacts_image.type, intValue);
2901 contacts_record_get_str_p(sourceRecordHandle, _contacts_image.label, &pCharValue);
2902 contacts_record_set_str(destRecordHandle, _contacts_image.label, pCharValue);
2904 contacts_record_get_str_p(sourceRecordHandle, _contacts_image.path, &pCharValue);
2905 contacts_record_set_str(destRecordHandle, _contacts_image.path, pCharValue);
2907 contacts_record_add_child_record(contactHandle, _contacts_contact.image, destRecordHandle);
2909 imageHandle.Release();
2912 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
2914 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
2915 contacts_record_get_child_record_count(srcHandle, _contacts_contact.company, &count);
2916 for (i = 0; i < count; i++)
2918 contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.company, i, &sourceRecordHandle);
2920 ret = contacts_record_create(_contacts_company._uri, &destRecordHandle);
2921 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2923 __ContactsRecordHandle companyHandle(destRecordHandle);
2925 contacts_record_get_int(sourceRecordHandle, _contacts_company.type, &intValue);
2926 contacts_record_set_int(destRecordHandle, _contacts_company.type, intValue);
2928 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.name, &pCharValue);
2929 contacts_record_set_str(destRecordHandle, _contacts_company.name, pCharValue);
2931 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.department, &pCharValue);
2932 contacts_record_set_str(destRecordHandle, _contacts_company.department, pCharValue);
2934 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.job_title, &pCharValue);
2935 contacts_record_set_str(destRecordHandle, _contacts_company.job_title, pCharValue);
2937 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.assistant_name, &pCharValue);
2938 contacts_record_set_str(destRecordHandle, _contacts_company.assistant_name, pCharValue);
2940 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.role, &pCharValue);
2941 contacts_record_set_str(destRecordHandle, _contacts_company.role, pCharValue);
2943 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.logo, &pCharValue);
2944 contacts_record_set_str(destRecordHandle, _contacts_company.logo, pCharValue);
2946 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.location, &pCharValue);
2947 contacts_record_set_str(destRecordHandle, _contacts_company.location, pCharValue);
2949 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.description, &pCharValue);
2950 contacts_record_set_str(destRecordHandle, _contacts_company.description, pCharValue);
2952 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.phonetic_name, &pCharValue);
2953 contacts_record_set_str(destRecordHandle, _contacts_company.phonetic_name, pCharValue);
2955 contacts_record_add_child_record(contactHandle, _contacts_contact.company, destRecordHandle);
2957 companyHandle.Release();
2960 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
2962 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
2963 contacts_record_get_child_record_count(srcHandle, _contacts_contact.note, &count);
2964 for (i = 0; i < count; i++)
2966 contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.note, i, &sourceRecordHandle);
2968 ret = contacts_record_create(_contacts_note._uri, &destRecordHandle);
2969 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2971 __ContactsRecordHandle noteHandle(destRecordHandle);
2973 contacts_record_get_str_p(sourceRecordHandle, _contacts_note.note, &pCharValue);
2974 contacts_record_set_str(destRecordHandle, _contacts_note.note, pCharValue);
2976 contacts_record_add_child_record(contactHandle, _contacts_contact.note, destRecordHandle);
2978 noteHandle.Release();
2981 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
2983 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
2984 contacts_record_get_child_record_count(srcHandle, _contacts_contact.number, &count);
2985 for (i = 0; i < count; i++)
2987 contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.number, i, &sourceRecordHandle);
2989 ret = contacts_record_create(_contacts_number._uri, &destRecordHandle);
2990 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2992 __ContactsRecordHandle numberHandle(destRecordHandle);
2994 contacts_record_get_int(sourceRecordHandle, _contacts_number.type, &intValue);
2995 contacts_record_set_int(destRecordHandle, _contacts_number.type, intValue);
2997 contacts_record_get_str_p(sourceRecordHandle, _contacts_number.label, &pCharValue);
2998 contacts_record_set_str(destRecordHandle, _contacts_number.label, pCharValue);
3000 contacts_record_get_str_p(sourceRecordHandle, _contacts_number.number, &pCharValue);
3001 contacts_record_set_str(destRecordHandle, _contacts_number.number, pCharValue);
3003 contacts_record_add_child_record(contactHandle, _contacts_contact.number, destRecordHandle);
3005 numberHandle.Release();
3008 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
3010 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
3011 contacts_record_get_child_record_count(srcHandle, _contacts_contact.email, &count);
3012 for (i = 0; i < count; i++)
3014 contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.email, i, &sourceRecordHandle);
3016 ret = contacts_record_create(_contacts_email._uri, &destRecordHandle);
3017 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3019 __ContactsRecordHandle emailHandle(destRecordHandle);
3021 contacts_record_get_int(sourceRecordHandle, _contacts_email.type, &intValue);
3022 contacts_record_set_int(destRecordHandle, _contacts_email.type, intValue);
3024 contacts_record_get_str_p(sourceRecordHandle, _contacts_email.label, &pCharValue);
3025 contacts_record_set_str(destRecordHandle, _contacts_email.label, pCharValue);
3027 contacts_record_get_str_p(sourceRecordHandle, _contacts_email.email, &pCharValue);
3028 contacts_record_set_str(destRecordHandle, _contacts_email.email, pCharValue);
3030 contacts_record_add_child_record(contactHandle, _contacts_contact.email, destRecordHandle);
3032 emailHandle.Release();
3036 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
3038 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
3039 contacts_record_get_child_record_count(srcHandle, _contacts_contact.event, &count);
3040 for (i = 0; i < count; i++)
3042 contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.event, i, &sourceRecordHandle);
3044 ret = contacts_record_create(_contacts_event._uri, &destRecordHandle);
3045 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3047 __ContactsRecordHandle eventHandle(destRecordHandle);
3049 contacts_record_get_int(sourceRecordHandle, _contacts_event.type, &intValue);
3050 contacts_record_set_int(destRecordHandle, _contacts_event.type, intValue);
3052 contacts_record_get_str_p(sourceRecordHandle, _contacts_event.label, &pCharValue);
3053 contacts_record_set_str(destRecordHandle, _contacts_event.label, pCharValue);
3055 contacts_record_get_int(sourceRecordHandle, _contacts_event.date, &intValue);
3056 contacts_record_set_int(destRecordHandle, _contacts_event.date, intValue);
3058 contacts_record_add_child_record(contactHandle, _contacts_contact.event, destRecordHandle);
3060 eventHandle.Release();
3063 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
3065 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
3066 contacts_record_get_child_record_count(srcHandle, _contacts_contact.messenger, &count);
3067 for (i = 0; i < count; i++)
3069 contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.messenger, i, &sourceRecordHandle);
3071 ret = contacts_record_create(_contacts_messenger._uri, &destRecordHandle);
3072 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3074 __ContactsRecordHandle imAddressHandle(destRecordHandle);
3076 contacts_record_get_int(sourceRecordHandle, _contacts_messenger.type, &intValue);
3077 contacts_record_set_int(destRecordHandle, _contacts_messenger.type, intValue);
3079 contacts_record_get_str_p(sourceRecordHandle, _contacts_messenger.label, &pCharValue);
3080 contacts_record_set_str(destRecordHandle, _contacts_messenger.label, pCharValue);
3082 contacts_record_get_str_p(sourceRecordHandle, _contacts_messenger.im_id, &pCharValue);
3083 contacts_record_set_str(destRecordHandle, _contacts_messenger.im_id, pCharValue);
3085 contacts_record_add_child_record(contactHandle, _contacts_contact.messenger, destRecordHandle);
3087 imAddressHandle.Release();
3090 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
3092 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
3093 contacts_record_get_child_record_count(srcHandle, _contacts_contact.address, &count);
3094 for (i = 0; i < count; i++)
3096 contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.address, i, &sourceRecordHandle);
3098 ret = contacts_record_create(_contacts_address._uri, &destRecordHandle);
3099 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3101 __ContactsRecordHandle addressHandle(destRecordHandle);
3103 contacts_record_get_int(sourceRecordHandle, _contacts_address.type, &intValue);
3104 contacts_record_set_int(destRecordHandle, _contacts_address.type, intValue);
3106 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.label, &pCharValue);
3107 contacts_record_set_str(destRecordHandle, _contacts_address.label, pCharValue);
3109 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.postbox, &pCharValue);
3110 contacts_record_set_str(destRecordHandle, _contacts_address.postbox, pCharValue);
3112 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.extended, &pCharValue);
3113 contacts_record_set_str(destRecordHandle, _contacts_address.extended, pCharValue);
3115 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.street, &pCharValue);
3116 contacts_record_set_str(destRecordHandle, _contacts_address.street, pCharValue);
3118 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.locality, &pCharValue);
3119 contacts_record_set_str(destRecordHandle, _contacts_address.locality, pCharValue);
3121 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.region, &pCharValue);
3122 contacts_record_set_str(destRecordHandle, _contacts_address.region, pCharValue);
3124 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.postal_code, &pCharValue);
3125 contacts_record_set_str(destRecordHandle, _contacts_address.postal_code, pCharValue);
3127 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.country, &pCharValue);
3128 contacts_record_set_str(destRecordHandle, _contacts_address.country, pCharValue);
3130 contacts_record_add_child_record(contactHandle, _contacts_contact.address, destRecordHandle);
3132 addressHandle.Release();
3135 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
3137 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
3138 contacts_record_get_child_record_count(srcHandle, _contacts_contact.url, &count);
3139 for (i = 0; i < count; i++)
3141 contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.url, i, &sourceRecordHandle);
3143 ret = contacts_record_create(_contacts_url._uri, &destRecordHandle);
3144 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3146 __ContactsRecordHandle urlHandle(destRecordHandle);
3148 contacts_record_get_int(sourceRecordHandle, _contacts_url.type, &intValue);
3149 contacts_record_set_int(destRecordHandle, _contacts_url.type, intValue);
3151 contacts_record_get_str_p(sourceRecordHandle, _contacts_url.label, &pCharValue);
3152 contacts_record_set_str(destRecordHandle, _contacts_url.label, pCharValue);
3154 contacts_record_get_str_p(sourceRecordHandle, _contacts_url.url, &pCharValue);
3155 contacts_record_set_str(destRecordHandle, _contacts_url.url, pCharValue);
3157 contacts_record_add_child_record(contactHandle, _contacts_contact.url, destRecordHandle);
3159 urlHandle.Release();
3162 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
3164 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
3165 contacts_record_get_child_record_count(srcHandle, _contacts_contact.nickname, &count);
3166 for (i = 0; i < count; i++)
3168 contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.nickname, i, &sourceRecordHandle);
3170 ret = contacts_record_create(_contacts_nickname._uri, &destRecordHandle);
3171 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3173 __ContactsRecordHandle nicknameHandle(destRecordHandle);
3175 contacts_record_get_str_p(sourceRecordHandle, _contacts_nickname.name, &pCharValue);
3176 contacts_record_set_str(destRecordHandle, _contacts_nickname.name, pCharValue);
3178 contacts_record_add_child_record(contactHandle, _contacts_contact.nickname, destRecordHandle);
3180 nicknameHandle.Release();
3183 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
3185 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
3186 contacts_record_get_child_record_count(srcHandle, _contacts_contact.relationship, &count);
3187 for (i = 0; i < count; i++)
3189 contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.relationship, i, &sourceRecordHandle);
3191 ret = contacts_record_create(_contacts_relationship._uri, &destRecordHandle);
3192 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3194 __ContactsRecordHandle relationshipHandle(destRecordHandle);
3196 contacts_record_get_str_p(sourceRecordHandle, _contacts_relationship.name, &pCharValue);
3197 contacts_record_set_str(destRecordHandle, _contacts_relationship.name, pCharValue);
3199 contacts_record_add_child_record(contactHandle, _contacts_contact.relationship, destRecordHandle);
3201 relationshipHandle.Release();
3204 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
3206 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
3207 contacts_record_get_child_record_count(srcHandle, _contacts_contact.profile, &count);
3208 for (i = 0; i < count; i++)
3210 contacts_record_get_child_record_at_p(srcHandle, _contacts_contact.profile, i, &sourceRecordHandle);
3212 ret = contacts_record_create(_contacts_profile._uri, &destRecordHandle);
3213 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3215 __ContactsRecordHandle profileHandle(destRecordHandle);
3217 contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.text, &pCharValue);
3218 contacts_record_set_str(destRecordHandle, _contacts_profile.text, pCharValue);
3220 contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.uid, &pCharValue);
3221 contacts_record_set_str(destRecordHandle, _contacts_profile.uid, pCharValue);
3223 contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.app_id, &pCharValue);
3224 contacts_record_set_str(destRecordHandle, _contacts_profile.app_id, pCharValue);
3226 contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.service_operation, &pCharValue);
3227 contacts_record_set_str(destRecordHandle, _contacts_profile.service_operation, pCharValue);
3229 contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.uri, &pCharValue);
3230 contacts_record_set_str(destRecordHandle, _contacts_profile.uri, pCharValue);
3232 contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.category, &pCharValue);
3233 contacts_record_set_str(destRecordHandle, _contacts_profile.category, pCharValue);
3235 contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.mime, &pCharValue);
3236 contacts_record_set_str(destRecordHandle, _contacts_profile.mime, pCharValue);
3238 contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.extra_data, &pCharValue);
3239 contacts_record_set_str(destRecordHandle, _contacts_profile.extra_data, pCharValue);
3241 contacts_record_add_child_record(contactHandle, _contacts_contact.profile, destRecordHandle);
3243 profileHandle.Release();
3246 return contactHandle;
3249 _AddressbookManagerImpl*
3250 _AddressbookManagerImpl::GetInstance(AddressbookManager& addressbookManager)
3252 return addressbookManager.__pAddressbookManagerImpl;
3255 const _AddressbookManagerImpl*
3256 _AddressbookManagerImpl::GetInstance(const AddressbookManager& addressbookManager)
3258 return addressbookManager.__pAddressbookManagerImpl;