2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FScl_ContactImpl.cpp
19 * @brief This is the implementation for _ContactImpl class.
21 * This file contains definitions of _ContactImpl class.
23 #include <FBaseString.h>
24 #include <FBaseColArrayList.h>
25 #include <FBaseSysLog.h>
27 #include <FMediaImage.h>
28 #include <FSclAddress.h>
29 #include <FSclPhoneNumber.h>
30 #include <FSclEmail.h>
32 #include <FSclImAddress.h>
33 #include <FSclOrganization.h>
34 #include <FSclContactEvent.h>
35 #include <FSclRelationship.h>
36 #include <FSclContact.h>
37 #include <FApp_AppInfo.h>
38 #include <FBase_StringConverter.h>
39 #include "FScl_ContactDbConnector.h"
40 #include "FScl_PhoneNumberImpl.h"
41 #include "FScl_ContactImpl.h"
42 #include "FScl_AddressbookUtil.h"
43 #include "FScl_UrlImpl.h"
44 #include "FScl_EmailImpl.h"
45 #include "FScl_AddressImpl.h"
46 #include "FScl_ImAddressImpl.h"
47 #include "FScl_OrganizationImpl.h"
49 using namespace Tizen::App;
50 using namespace Tizen::Base;
51 using namespace Tizen::Base::Collection;
52 using namespace Tizen::Graphics;
53 using namespace Tizen::Media;
54 using namespace Tizen::Io;
56 namespace Tizen { namespace Social
59 extern const wchar_t OTHER_LABEL[] = L"Other";
61 const int __CONTACT_CHANGED_TIME_YEAR_OFFSET = 1900;
62 const int __CONTACT_CHANGED_TIME_MONTH_OFFSET = 1;
64 const int __CONTACT_MOD_YEAR = 10000;
65 const int __CONTACT_MOD_MONTH = 100;
67 #define __PARSE_DATE(date, year, month, day) \
71 year = temp/__CONTACT_MOD_YEAR; \
72 temp -= year*__CONTACT_MOD_YEAR; \
73 month = temp/__CONTACT_MOD_MONTH; \
74 day = temp - month*__CONTACT_MOD_MONTH; \
77 #define __CONVERT_DATE_TO_DATETIME(date, dateTime) \
84 year = temp/__CONTACT_MOD_YEAR; \
85 temp -= year*__CONTACT_MOD_YEAR; \
86 month = temp/__CONTACT_MOD_MONTH; \
87 day = temp - month*__CONTACT_MOD_MONTH; \
88 dateTime.SetValue(year, month, day, 0, 0, 0); \
92 #define __CONVERT_DATETIME_TO_DATE(dateTime, date) \
95 date = dateTime.GetYear()*__CONTACT_MOD_YEAR + dateTime.GetMonth()*__CONTACT_MOD_MONTH + dateTime.GetDay(); \
98 _ContactImpl::_ContactImpl(void)
99 : __contactHandle(null)
102 contacts_record_h contactHandle = null;
104 SysTryReturnVoidResult(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
106 int ret = contacts_record_create(_contacts_contact._uri, &contactHandle);
107 SysTryReturnVoidResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
109 __contactHandle = contactHandle;
112 _ContactImpl::_ContactImpl(const _ContactImpl& rhs)
113 : __contactHandle(null)
115 contacts_record_h contactHandle = null;
117 SysTryReturnVoidResult(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
119 int ret = contacts_record_clone(rhs.__contactHandle, &contactHandle);
120 SysTryReturnVoidResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
122 __contactHandle = contactHandle;
123 __isRemoved = rhs.__isRemoved;
126 _ContactImpl::~_ContactImpl(void)
128 if (__contactHandle != null)
130 contacts_record_destroy(__contactHandle, true);
135 _ContactImpl::operator =(const _ContactImpl& rhs)
142 contacts_record_h contactHandle = null;
144 int ret = contacts_record_clone(rhs.__contactHandle, &contactHandle);
145 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
147 contacts_record_destroy(__contactHandle, true);
148 __contactHandle = contactHandle;
150 __isRemoved = rhs.__isRemoved;
156 _ContactImpl::SetContactRecordHandle(contacts_record_h contactHandle)
158 contacts_record_destroy(__contactHandle, true);
160 __contactHandle = contactHandle;
164 _ContactImpl::GetContactRecordHandle(void) const
166 return __contactHandle;
170 _ContactImpl::SetThumbnailPath(const Tizen::Base::String& filePath)
172 SysTryReturn(NID_SCL, filePath.IsEmpty() || File::IsFileExist(filePath), E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[%s] The specified file is not found.", GetErrorMessage(E_FILE_NOT_FOUND));
174 unsigned int count = 0;
175 contacts_record_h imageHandle = null;
177 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
180 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, 0, &imageHandle);
182 if (!filePath.IsEmpty())
184 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(filePath));
185 SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
187 contacts_record_set_str(imageHandle, _contacts_image.path, pCharArray.get());
191 contacts_record_remove_child_record(__contactHandle, _contacts_contact.image, imageHandle);
196 if (!filePath.IsEmpty())
198 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(filePath));
199 SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
201 int ret = contacts_record_create(_contacts_image._uri, &imageHandle);
202 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
204 contacts_record_set_str(imageHandle, _contacts_image.path, pCharArray.get());
206 contacts_record_add_child_record(__contactHandle, _contacts_contact.image, imageHandle);
214 _ContactImpl::GetThumbnailPath(void) const
216 unsigned int count = 0;
218 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
224 char* pCharValue = null;
225 contacts_record_h imageHandle = null;
227 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, 0, &imageHandle);
228 contacts_record_get_str_p(imageHandle, _contacts_image.path, &pCharValue);
230 return String(pCharValue);
234 _ContactImpl::GetThumbnailN(void) const
236 unsigned int count = 0;
237 char* pCharValue = null;
238 contacts_record_h imageHandle = null;
242 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
248 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, 0, &imageHandle);
249 contacts_record_get_str_p(imageHandle, _contacts_image.path, &pCharValue);
251 String thumbnailPath(pCharValue);
254 result r = image.Construct();
255 SysTryReturn(NID_SCL, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
256 SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Failed to construct Image.", GetErrorMessage(E_SYSTEM));
258 ImageFormat imageFormat = image.GetImageFormat(thumbnailPath);
259 SysTryReturn(NID_SCL, GetLastResult() != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
260 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, null, E_SYSTEM, "[%s] Failed to get the format of the thumbnail image.", GetErrorMessage(E_SYSTEM));
262 BitmapPixelFormat bitmapPixelFormat = BITMAP_PIXEL_FORMAT_RGB565;
271 bitmapPixelFormat = BITMAP_PIXEL_FORMAT_RGB565;
274 bitmapPixelFormat = BITMAP_PIXEL_FORMAT_ARGB8888;
277 SysLogException(NID_SCL, E_SYSTEM, "[%s] Unsupported image format.", GetErrorMessage(E_SYSTEM));
281 Bitmap* pBitmap = image.DecodeN(thumbnailPath, bitmapPixelFormat);
282 SysTryReturn(NID_SCL, GetLastResult() != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. ", GetErrorMessage(E_OUT_OF_MEMORY));
283 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred. ", GetErrorMessage(E_SYSTEM));
289 _ContactImpl::GetValue(const ContactPropertyId id, String& value) const
291 unsigned int count = 0;
292 char* pCharValue = null;
296 case CONTACT_PROPERTY_ID_FIRST_NAME:
298 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
301 contacts_record_h nameHandle = null;
303 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
304 contacts_record_get_str_p(nameHandle, _contacts_name.first, &pCharValue);
310 case CONTACT_PROPERTY_ID_LAST_NAME:
312 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
315 contacts_record_h nameHandle = null;
317 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
318 contacts_record_get_str_p(nameHandle, _contacts_name.last, &pCharValue);
324 case CONTACT_PROPERTY_ID_DISPLAY_NAME:
325 contacts_record_get_str_p(__contactHandle, _contacts_contact.display_name, &pCharValue);
328 case CONTACT_PROPERTY_ID_NICK_NAME:
330 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
333 contacts_record_h nicknameHandle = null;
335 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, 0, &nicknameHandle);
336 contacts_record_get_str_p(nicknameHandle, _contacts_nickname.name, &pCharValue);
342 case CONTACT_PROPERTY_ID_MIDDLE_NAME:
344 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
347 contacts_record_h nameHandle = null;
349 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
350 contacts_record_get_str_p(nameHandle, _contacts_name.addition, &pCharValue);
356 case CONTACT_PROPERTY_ID_NAME_PREFIX:
358 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
361 contacts_record_h nameHandle = null;
363 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
364 contacts_record_get_str_p(nameHandle, _contacts_name.prefix, &pCharValue);
370 case CONTACT_PROPERTY_ID_NAME_SUFFIX:
372 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
375 contacts_record_h nameHandle = null;
377 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
378 contacts_record_get_str_p(nameHandle, _contacts_name.suffix, &pCharValue);
384 case CONTACT_PROPERTY_ID_JOB_TITLE:
386 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
389 contacts_record_h companyHandle = null;
391 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
392 contacts_record_get_str_p(companyHandle, _contacts_company.job_title, &pCharValue);
398 case CONTACT_PROPERTY_ID_COMPANY:
400 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
403 contacts_record_h companyHandle = null;
405 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
406 contacts_record_get_str_p(companyHandle, _contacts_company.name, &pCharValue);
412 case CONTACT_PROPERTY_ID_NOTE:
414 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
417 contacts_record_h noteHandle = null;
419 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, 0, ¬eHandle);
420 contacts_record_get_str_p(noteHandle, _contacts_note.note, &pCharValue);
426 case CONTACT_PROPERTY_ID_RINGTONE:
427 contacts_record_get_str_p(__contactHandle, _contacts_contact.ringtone_path, &pCharValue);
430 case CONTACT_PROPERTY_ID_THUMBNAIL:
432 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
435 contacts_record_h imageHandle = null;
437 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, 0, &imageHandle);
438 contacts_record_get_str_p(imageHandle, _contacts_image.path, &pCharValue);
443 case CONTACT_PROPERTY_ID_PHONETIC_FIRST_NAME:
445 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
448 contacts_record_h phoneticNameHandle = null;
450 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
451 contacts_record_get_str_p(phoneticNameHandle, _contacts_name.phonetic_first, &pCharValue);
457 case CONTACT_PROPERTY_ID_PHONETIC_LAST_NAME:
459 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
462 contacts_record_h phoneticNameHandle = null;
464 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
465 contacts_record_get_str_p(phoneticNameHandle, _contacts_name.phonetic_last, &pCharValue);
471 case CONTACT_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
473 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
476 contacts_record_h phoneticNameHandle = null;
478 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
479 contacts_record_get_str_p(phoneticNameHandle, _contacts_name.phonetic_middle, &pCharValue);
485 case CONTACT_PROPERTY_ID_UID:
487 contacts_record_get_str_p(__contactHandle, _contacts_contact.uid, &pCharValue);
494 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d", GetErrorMessage(E_INVALID_ARG), id);
495 return E_INVALID_ARG;
502 _ContactImpl::GetValue(const ContactPropertyId id, DateTime& value) const
506 unsigned int count = 0;
508 value = DateTime::GetMinValue();
512 case CONTACT_PROPERTY_ID_BIRTHDAY:
514 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
521 contacts_record_h eventHandle = null;
522 for (unsigned int i = 0; i < count; i++)
524 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
525 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
526 if (intValue == CONTACTS_EVENT_TYPE_BIRTH)
528 contacts_record_get_int(eventHandle, _contacts_event.date, &intValue);
530 __PARSE_DATE(intValue, year, month, day);
532 value.SetValue(year, month, day, 0, 0, 0);
540 case CONTACT_PROPERTY_ID_ANNIVERSARY:
542 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
549 contacts_record_h eventHandle = null;
550 for (unsigned int i = 0; i < count; i++)
552 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
553 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
554 if (intValue == CONTACTS_EVENT_TYPE_ANNIVERSARY)
556 contacts_record_get_int(eventHandle, _contacts_event.date, &intValue);
558 __PARSE_DATE(intValue, year, month, day);
560 value.SetValue(year, month, day, 0, 0, 0);
568 case CONTACT_PROPERTY_ID_LAST_REVISION:
573 contacts_record_get_int(__contactHandle, _contacts_contact.changed_time, &intValue);
574 gmtime_r((time_t *)intValue, &ts);
576 value.SetValue(ts.tm_year + __CONTACT_CHANGED_TIME_YEAR_OFFSET, ts.tm_mon + __CONTACT_CHANGED_TIME_MONTH_OFFSET, ts.tm_mday, ts.tm_hour, ts.tm_min, ts.tm_sec);
581 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
582 return E_INVALID_ARG;
589 _ContactImpl::IsEmptyCompany(contacts_record_h companyHandle)
591 char* pCharValue = null;
593 contacts_record_get_str_p(companyHandle, _contacts_company.name, &pCharValue);
594 if (pCharValue != null)
599 contacts_record_get_str_p(companyHandle, _contacts_company.job_title, &pCharValue);
600 if (pCharValue != null)
605 contacts_record_get_str_p(companyHandle, _contacts_company.department, &pCharValue);
606 if (pCharValue != null)
611 contacts_record_get_str_p(companyHandle, _contacts_company.role, &pCharValue);
612 if (pCharValue != null)
617 contacts_record_get_str_p(companyHandle, _contacts_company.assistant_name, &pCharValue);
618 if (pCharValue != null)
623 contacts_record_get_str_p(companyHandle, _contacts_company.description, &pCharValue);
624 if (pCharValue != null)
629 contacts_record_get_str_p(companyHandle, _contacts_company.location, &pCharValue);
630 if (pCharValue != null)
635 contacts_record_get_str_p(companyHandle, _contacts_company.phonetic_name, &pCharValue);
636 if (pCharValue != null)
641 contacts_record_get_str_p(companyHandle, _contacts_company.logo, &pCharValue);
642 if (pCharValue != null)
651 _ContactImpl::IsEmptyName(contacts_record_h nameHandle)
653 char* pCharValue = null;
655 contacts_record_get_str_p(nameHandle, _contacts_name.first, &pCharValue);
656 if (pCharValue != null)
661 contacts_record_get_str_p(nameHandle, _contacts_name.last, &pCharValue);
662 if (pCharValue != null)
667 contacts_record_get_str_p(nameHandle, _contacts_name.addition, &pCharValue);
668 if (pCharValue != null)
673 contacts_record_get_str_p(nameHandle, _contacts_name.prefix, &pCharValue);
674 if (pCharValue != null)
679 contacts_record_get_str_p(nameHandle, _contacts_name.suffix, &pCharValue);
680 if (pCharValue != null)
685 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_first, &pCharValue);
686 if (pCharValue != null)
691 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_last, &pCharValue);
692 if (pCharValue != null)
697 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_middle, &pCharValue);
698 if (pCharValue != null)
707 _ContactImpl::SetValue(ContactPropertyId id, const String& value)
709 SysTryReturn(NID_SCL, id != CONTACT_PROPERTY_ID_THUMBNAIL, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. Thumbnail cannot be set using this.", GetErrorMessage(E_INVALID_ARG));
710 SysTryReturn(NID_SCL, id != CONTACT_PROPERTY_ID_DISPLAY_NAME, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. Display cannot be set using this.", GetErrorMessage(E_INVALID_ARG));
712 int ret = CONTACTS_ERROR_NONE;
713 unsigned int count = 0;
715 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
717 int maxLength = GetMaxLength(id);
718 SysTryReturn(NID_SCL, value.GetLength() <= maxLength || maxLength == -1 , E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The length of the value=%ls exceeds the maximum length.", GetErrorMessage(E_INVALID_ARG), value.GetPointer());
723 case CONTACT_PROPERTY_ID_FIRST_NAME:
725 contacts_record_h nameHandle = null;
726 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
729 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
731 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
732 contacts_record_set_str(nameHandle, _contacts_name.first, pCharArray.get());
734 if (value.IsEmpty() && IsEmptyName(nameHandle))
736 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
741 if (!value.IsEmpty())
743 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
744 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
746 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
747 contacts_record_set_str(nameHandle, _contacts_name.first, pCharArray.get());
749 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
755 case CONTACT_PROPERTY_ID_MIDDLE_NAME:
757 contacts_record_h nameHandle = null;
758 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
761 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
763 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
764 contacts_record_set_str(nameHandle, _contacts_name.addition, pCharArray.get());
766 if (value.IsEmpty() && IsEmptyName(nameHandle))
768 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
773 if (!value.IsEmpty())
775 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
776 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
778 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
779 contacts_record_set_str(nameHandle, _contacts_name.addition, pCharArray.get());
781 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
789 case CONTACT_PROPERTY_ID_LAST_NAME:
791 contacts_record_h nameHandle = null;
792 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
795 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
797 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
798 contacts_record_set_str(nameHandle, _contacts_name.last, pCharArray.get());
800 if (value.IsEmpty() && IsEmptyName(nameHandle))
802 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
807 if (!value.IsEmpty())
809 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
810 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
812 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
813 contacts_record_set_str(nameHandle, _contacts_name.last, pCharArray.get());
815 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
822 case CONTACT_PROPERTY_ID_NAME_SUFFIX:
824 contacts_record_h nameHandle = null;
825 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
828 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
830 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
831 contacts_record_set_str(nameHandle, _contacts_name.suffix, pCharArray.get());
833 if (value.IsEmpty() && IsEmptyName(nameHandle))
835 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
841 if (!value.IsEmpty())
843 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
845 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
847 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
848 contacts_record_set_str(nameHandle, _contacts_name.suffix, pCharArray.get());
850 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
858 case CONTACT_PROPERTY_ID_NAME_PREFIX:
860 contacts_record_h nameHandle = null;
861 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
864 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
866 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
867 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
869 if (value.IsEmpty() && IsEmptyName(nameHandle))
871 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
876 if (!value.IsEmpty())
878 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
879 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
881 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
882 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
884 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
892 case CONTACT_PROPERTY_ID_NICK_NAME:
894 contacts_record_h nicknameHandle = null;
895 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
898 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, 0, &nicknameHandle);
899 if (!value.IsEmpty())
901 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
902 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
908 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, 0, &nicknameHandle);
909 if (ret != CONTACTS_ERROR_NONE)
914 contacts_record_remove_child_record(__contactHandle, _contacts_contact.nickname, nicknameHandle);
920 if (!value.IsEmpty())
922 ret = contacts_record_create(_contacts_nickname._uri, &nicknameHandle);
923 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
925 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
926 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
928 contacts_record_add_child_record(__contactHandle, _contacts_contact.nickname, nicknameHandle);
936 case CONTACT_PROPERTY_ID_JOB_TITLE:
938 contacts_record_h companyHandle = null;
939 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
942 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
944 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
945 contacts_record_set_str(companyHandle, _contacts_company.job_title, pCharArray.get());
947 if (value.IsEmpty() && IsEmptyCompany(companyHandle))
951 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
952 if (ret != CONTACTS_ERROR_NONE)
957 contacts_record_remove_child_record(__contactHandle, _contacts_contact.company, companyHandle);
963 if (!value.IsEmpty())
965 ret = contacts_record_create(_contacts_company._uri, &companyHandle);
966 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
968 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
969 contacts_record_set_str(companyHandle, _contacts_company.job_title, pCharArray.get());
971 contacts_record_add_child_record(__contactHandle, _contacts_contact.company, companyHandle);
978 case CONTACT_PROPERTY_ID_COMPANY:
980 contacts_record_h companyHandle = null;
981 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
984 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
986 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(value));
987 contacts_record_set_str(companyHandle, _contacts_company.name, pCharArray.get());
989 if (value.IsEmpty() && IsEmptyCompany(companyHandle))
993 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
994 if (ret != CONTACTS_ERROR_NONE)
999 contacts_record_remove_child_record(__contactHandle, _contacts_contact.company, companyHandle);
1006 if (!value.IsEmpty())
1008 ret = contacts_record_create(_contacts_company._uri, &companyHandle);
1009 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1011 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(value));
1012 contacts_record_set_str(companyHandle, _contacts_company.name, pCharArray.get());
1014 contacts_record_add_child_record(__contactHandle, _contacts_contact.company, companyHandle);
1021 case CONTACT_PROPERTY_ID_NOTE:
1023 contacts_record_h noteHandle = null;
1024 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
1027 if (!value.IsEmpty())
1029 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, 0, ¬eHandle);
1031 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(value));
1032 contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
1038 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, 0, ¬eHandle);
1039 if (ret != CONTACTS_ERROR_NONE)
1044 contacts_record_remove_child_record(__contactHandle, _contacts_contact.note, noteHandle);
1050 if (!value.IsEmpty())
1052 ret = contacts_record_create(_contacts_note._uri, ¬eHandle);
1053 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1055 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(value));
1056 contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
1058 contacts_record_add_child_record(__contactHandle, _contacts_contact.note, noteHandle);
1064 case CONTACT_PROPERTY_ID_RINGTONE:
1066 if (!value.IsEmpty() && !File::IsFileExist(value))
1068 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. The specified ringtone file does not exist.", GetErrorMessage(E_INVALID_ARG));
1069 return E_INVALID_ARG;
1072 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1074 contacts_record_set_str(__contactHandle, _contacts_contact.ringtone_path, pCharArray.get());
1078 case CONTACT_PROPERTY_ID_PHONETIC_FIRST_NAME:
1080 contacts_record_h phoneticNameHandle = null;
1081 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
1084 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
1086 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1087 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_first, pCharArray.get());
1089 if (value.IsEmpty() && IsEmptyName(phoneticNameHandle))
1091 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1096 if (!value.IsEmpty())
1098 ret = contacts_record_create(_contacts_name._uri, &phoneticNameHandle);
1099 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1101 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1102 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_first, pCharArray.get());
1104 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1109 case CONTACT_PROPERTY_ID_PHONETIC_LAST_NAME:
1111 contacts_record_h phoneticNameHandle = null;
1112 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
1115 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
1117 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1118 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_last, pCharArray.get());
1120 if (value.IsEmpty() && IsEmptyName(phoneticNameHandle))
1122 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1127 if (!value.IsEmpty())
1129 ret = contacts_record_create(_contacts_name._uri, &phoneticNameHandle);
1130 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1132 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1133 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_last, pCharArray.get());
1135 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1140 case CONTACT_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
1142 contacts_record_h phoneticNameHandle = null;
1143 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
1146 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
1148 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1149 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_middle, pCharArray.get());
1151 if (value.IsEmpty() && IsEmptyName(phoneticNameHandle))
1153 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1158 if (!value.IsEmpty())
1160 ret = contacts_record_create(_contacts_name._uri, &phoneticNameHandle);
1161 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1163 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1164 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_middle, pCharArray.get());
1166 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1171 case CONTACT_PROPERTY_ID_UID:
1173 if (!value.IsEmpty())
1175 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1176 contacts_record_set_str(__contactHandle, _contacts_contact.uid, pCharArray.get());
1180 contacts_record_set_str(__contactHandle, _contacts_contact.uid, null);
1185 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
1186 return E_INVALID_ARG;
1193 _ContactImpl::SetValue(ContactPropertyId id, const DateTime& value)
1195 SysTryReturn(NID_SCL, id != CONTACT_PROPERTY_ID_LAST_REVISION, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. Thumbnail cannot be set using this.", GetErrorMessage(E_INVALID_ARG));
1197 unsigned int count = 0;
1199 int ret = CONTACTS_ERROR_NONE;
1203 case CONTACT_PROPERTY_ID_BIRTHDAY:
1207 contacts_record_h eventHandle = null;
1209 __CONVERT_DATETIME_TO_DATE(value, date);
1211 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
1214 for (unsigned int i = 0; i < count; i++)
1216 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
1217 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
1218 if (intValue == CONTACTS_EVENT_TYPE_BIRTH)
1220 contacts_record_set_int(eventHandle, _contacts_event.date, date);
1229 ret = contacts_record_create(_contacts_event._uri, &eventHandle);
1230 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1232 contacts_record_set_int(eventHandle, _contacts_event.type, CONTACTS_EVENT_TYPE_BIRTH);
1233 contacts_record_set_int(eventHandle, _contacts_event.date, date);
1235 contacts_record_add_child_record(__contactHandle, _contacts_contact.event, eventHandle);
1241 case CONTACT_PROPERTY_ID_ANNIVERSARY:
1245 contacts_record_h eventHandle = null;
1247 __CONVERT_DATETIME_TO_DATE(value, date);
1249 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
1252 for (unsigned int i = 0; i < count; i++)
1254 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
1255 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
1256 if (intValue == CONTACTS_EVENT_TYPE_ANNIVERSARY)
1258 contacts_record_set_int(eventHandle, _contacts_event.date, date);
1267 ret = contacts_record_create(_contacts_event._uri, &eventHandle);
1268 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1270 contacts_record_set_int(eventHandle, _contacts_event.type, CONTACTS_EVENT_TYPE_ANNIVERSARY);
1271 contacts_record_set_int(eventHandle, _contacts_event.date, date);
1273 contacts_record_add_child_record(__contactHandle, _contacts_contact.event, eventHandle);
1280 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
1281 return E_INVALID_ARG;
1288 _ContactImpl::AddPhoneNumber(const PhoneNumber& phoneNumber)
1290 SysTryReturn(NID_SCL, !phoneNumber.GetPhoneNumber().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The phoneNumber is empty.", GetErrorMessage(E_INVALID_ARG));
1291 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1295 contacts_record_h numberHandle = null;
1297 int ret = contacts_record_create(_contacts_number._uri, &numberHandle);
1298 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1300 __ContactsRecordHandle recordHandle(numberHandle);
1302 switch (_PhoneNumberImpl::GetInstance(phoneNumber)->GetType())
1304 case PHONENUMBER_TYPE_HOME:
1305 type = CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE;
1307 case PHONENUMBER_TYPE_WORK:
1308 type = CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE;
1310 case PHONENUMBER_TYPE_MOBILE:
1311 type = CONTACTS_NUMBER_TYPE_CELL;
1313 case PHONENUMBER_TYPE_HOME_FAX:
1314 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME;
1316 case PHONENUMBER_TYPE_WORK_FAX:
1317 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK;
1319 case PHONENUMBER_TYPE_PAGER:
1320 type = CONTACTS_NUMBER_TYPE_PAGER;
1322 case PHONENUMBER_TYPE_CUSTOM:
1323 type = CONTACTS_NUMBER_TYPE_CUSTOM;
1325 case PHONENUMBER_TYPE_ASSISTANT:
1326 type = CONTACTS_NUMBER_TYPE_ASSISTANT;
1328 case PHONENUMBER_TYPE_OTHER:
1330 type = CONTACTS_NUMBER_TYPE_OTHER;
1334 contacts_record_set_int(numberHandle, _contacts_number.type, type);
1336 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetLabel();
1338 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1339 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1341 contacts_record_set_str(numberHandle, _contacts_number.label, pCharArray.get());
1343 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetPhoneNumber();
1344 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1345 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1347 contacts_record_set_str(numberHandle, _contacts_number.number, pCharArray.get());
1349 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.number, numberHandle);
1350 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1352 recordHandle.Release();
1358 _ContactImpl::AddNickname(const String& nickname)
1360 SysTryReturn(NID_SCL, !nickname.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The nickname is an empty string.", GetErrorMessage(E_INVALID_ARG));
1361 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1362 contacts_record_h nicknameHandle = null;
1364 int ret = contacts_record_create(_contacts_nickname._uri, &nicknameHandle);
1365 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1367 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(nickname));
1368 SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1370 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
1372 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.nickname, nicknameHandle);
1373 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1379 _ContactImpl::AddNote(const String& note)
1381 SysTryReturn(NID_SCL, !note.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The note is an empty string.", GetErrorMessage(E_INVALID_ARG));
1382 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1383 contacts_record_h noteHandle = null;
1385 int ret = contacts_record_create(_contacts_note._uri, ¬eHandle);
1386 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1388 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(note));
1389 SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1391 contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
1393 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.note, noteHandle);
1394 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1400 _ContactImpl::AddEmail(const Email& email)
1402 SysTryReturn(NID_SCL, !email.GetEmail().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The email is empty.", GetErrorMessage(E_INVALID_ARG));
1403 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1407 contacts_record_h emailHandle = null;
1409 int ret = contacts_record_create(_contacts_email._uri, &emailHandle);
1410 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1412 __ContactsRecordHandle recordHandle(emailHandle);
1414 switch (_EmailImpl::GetInstance(email)->GetType())
1416 case EMAIL_TYPE_PERSONAL:
1417 type = CONTACTS_EMAIL_TYPE_HOME;
1419 case EMAIL_TYPE_WORK:
1420 type = CONTACTS_EMAIL_TYPE_WORK;
1422 case EMAIL_TYPE_CUSTOM:
1423 type = CONTACTS_EMAIL_TYPE_CUSTOM;
1425 case EMAIL_TYPE_MOBILE:
1426 type = CONTACTS_EMAIL_TYPE_MOBILE;
1428 case EMAIL_TYPE_OTHER:
1431 type = CONTACTS_EMAIL_TYPE_OTHER;
1435 contacts_record_set_int(emailHandle, _contacts_email.type, type);
1437 stringValue = _EmailImpl::GetInstance(email)->GetLabel();
1438 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1439 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1441 contacts_record_set_str(emailHandle, _contacts_email.label, pCharArray.get());
1443 stringValue = _EmailImpl::GetInstance(email)->GetEmail();
1444 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1445 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1447 contacts_record_set_str(emailHandle, _contacts_email.email, pCharArray.get());
1449 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.email, emailHandle);
1450 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1452 recordHandle.Release();
1458 _ContactImpl::AddUrl(const Url& url)
1460 SysTryReturn(NID_SCL, !url.GetUrl().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The url is empty.", GetErrorMessage(E_INVALID_ARG));
1461 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1465 contacts_record_h urlHandle = null;
1467 int ret = contacts_record_create(_contacts_url._uri, &urlHandle);
1468 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1470 __ContactsRecordHandle recordHandle(urlHandle);
1472 switch (_UrlImpl::GetInstance(url)->GetType())
1474 case URL_TYPE_PERSONAL:
1475 type = CONTACTS_URL_TYPE_HOME;
1478 type = CONTACTS_URL_TYPE_WORK;
1480 case URL_TYPE_CUSTOM:
1481 type = CONTACTS_URL_TYPE_CUSTOM;
1483 case URL_TYPE_OTHER:
1486 type = CONTACTS_URL_TYPE_OTHER;
1491 contacts_record_set_int(urlHandle, _contacts_url.type, type);
1494 stringValue = _UrlImpl::GetInstance(url)->GetLabel();
1495 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1496 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1498 contacts_record_set_str(urlHandle, _contacts_url.label, pCharArray.get());
1501 stringValue = _UrlImpl::GetInstance(url)->GetUrl();
1502 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1503 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1505 contacts_record_set_str(urlHandle, _contacts_url.url, pCharArray.get());
1507 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.url, urlHandle);
1508 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1510 recordHandle.Release();
1516 _ContactImpl::AddAddress(const Address& address)
1518 SysTryReturn(NID_SCL, !_AddressImpl::GetInstance(address)->IsEmpty() ,E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The address is empty.", GetErrorMessage(E_INVALID_ARG));
1519 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1523 contacts_record_h addressHandle = null;
1525 int ret = contacts_record_create(_contacts_address._uri, &addressHandle);
1526 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1528 __ContactsRecordHandle recordHandle(addressHandle);
1530 switch (_AddressImpl::GetInstance(address)->GetType())
1532 case ADDRESS_TYPE_HOME:
1533 type = CONTACTS_ADDRESS_TYPE_HOME;
1535 case ADDRESS_TYPE_WORK:
1536 type = CONTACTS_ADDRESS_TYPE_WORK;
1538 case ADDRESS_TYPE_CUSTOM:
1539 type = CONTACTS_ADDRESS_TYPE_CUSTOM;
1541 case ADDRESS_TYPE_OTHER:
1544 type = CONTACTS_ADDRESS_TYPE_OTHER;
1548 contacts_record_set_int(addressHandle, _contacts_address.type, type);
1550 stringValue = _AddressImpl::GetInstance(address)->GetLabel();
1551 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1552 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1554 contacts_record_set_str(addressHandle, _contacts_address.label, pCharArray.get());
1556 stringValue = _AddressImpl::GetInstance(address)->GetCity();
1557 if (!stringValue.IsEmpty())
1559 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1560 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1562 contacts_record_set_str(addressHandle, _contacts_address.locality, pCharArray.get());
1566 stringValue = _AddressImpl::GetInstance(address)->GetCountry();
1567 if (!stringValue.IsEmpty())
1569 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1570 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1572 contacts_record_set_str(addressHandle, _contacts_address.country, pCharArray.get());
1575 stringValue = _AddressImpl::GetInstance(address)->GetExtended();
1576 if (!stringValue.IsEmpty())
1578 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1579 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1581 contacts_record_set_str(addressHandle, _contacts_address.extended, pCharArray.get());
1584 stringValue = _AddressImpl::GetInstance(address)->GetPostalCode();
1585 if (!stringValue.IsEmpty())
1587 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1588 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1590 contacts_record_set_str(addressHandle, _contacts_address.postal_code, pCharArray.get());
1593 stringValue = _AddressImpl::GetInstance(address)->GetPostOfficeBoxNumber();
1594 if (!stringValue.IsEmpty())
1596 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1597 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1599 contacts_record_set_str(addressHandle, _contacts_address.postbox, pCharArray.get());
1602 stringValue = _AddressImpl::GetInstance(address)->GetState();
1603 if (!stringValue.IsEmpty())
1605 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1606 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1608 contacts_record_set_str(addressHandle, _contacts_address.region, pCharArray.get());
1611 stringValue = _AddressImpl::GetInstance(address)->GetStreet();
1612 if (!stringValue.IsEmpty())
1614 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1615 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1617 contacts_record_set_str(addressHandle, _contacts_address.street, pCharArray.get());
1620 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.address, addressHandle);
1621 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1623 recordHandle.Release();
1629 _ContactImpl::AddImAddress(const ImAddress& imAddress)
1631 SysTryReturn(NID_SCL, !imAddress.GetImAddress().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%] Invalid argument is used. The imAddress is empty.", GetErrorMessage(E_INVALID_ARG));
1632 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1636 contacts_record_h messengerHandle = null;
1638 std::unique_ptr<char[]> pCharArray(null);
1640 int ret = contacts_record_create(_contacts_messenger._uri, &messengerHandle);
1641 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1643 __ContactsRecordHandle recordHandle(messengerHandle);
1645 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetServiceProviderName();
1647 if (stringValue == IM_ADDRESS_GOOGLE_TALK)
1649 type = CONTACTS_MESSENGER_TYPE_GOOGLE;
1651 else if (stringValue == IM_ADDRESS_MSN)
1653 type = CONTACTS_MESSENGER_TYPE_WLM;
1655 else if (stringValue == IM_ADDRESS_ICQ)
1657 type = CONTACTS_MESSENGER_TYPE_ICQ;
1659 else if (stringValue == IM_ADDRESS_AIM)
1661 type = CONTACTS_MESSENGER_TYPE_AIM;
1663 else if (stringValue == IM_ADDRESS_YAHOO)
1665 type = CONTACTS_MESSENGER_TYPE_YAHOO;
1667 else if (stringValue == IM_ADDRESS_QQ)
1669 type = CONTACTS_MESSENGER_TYPE_QQ;
1671 else if (stringValue == IM_ADDRESS_SKYPE)
1673 type = CONTACTS_MESSENGER_TYPE_SKYPE;
1675 else if (stringValue == IM_ADDRESS_JABBER)
1677 type = CONTACTS_MESSENGER_TYPE_JABBER;
1681 type = CONTACTS_MESSENGER_TYPE_CUSTOM;
1684 contacts_record_set_int(messengerHandle, _contacts_messenger.type, type);
1685 if (type == CONTACTS_MESSENGER_TYPE_CUSTOM)
1687 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1688 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1690 contacts_record_set_str(messengerHandle, _contacts_messenger.label, pCharArray.get());
1693 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetImAddress();
1694 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1695 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1697 contacts_record_set_str(messengerHandle, _contacts_messenger.im_id, pCharArray.get());
1699 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.messenger, messengerHandle);
1700 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1702 recordHandle.Release();
1707 _ContactImpl::AddRelationship(const Relationship& relationship)
1709 SysTryReturn(NID_SCL, !relationship.GetRelativeName().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%] Invalid argument is used. The relationship is empty.", GetErrorMessage(E_INVALID_ARG));
1710 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1713 contacts_record_h relationshipHandle = null;
1715 int ret = contacts_record_create(_contacts_relationship._uri, &relationshipHandle);
1716 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1718 __ContactsRecordHandle recordHandle(relationshipHandle);
1720 switch (relationship.GetType())
1722 case CONTACT_RELATIONSHIP_TYPE_ASSISTANT:
1723 intValue = CONTACTS_RELATIONSHIP_TYPE_ASSISTANT;
1725 case CONTACT_RELATIONSHIP_TYPE_BROTHER:
1726 intValue = CONTACTS_RELATIONSHIP_TYPE_BROTHER;
1728 case CONTACT_RELATIONSHIP_TYPE_CHILD:
1729 intValue = CONTACTS_RELATIONSHIP_TYPE_CHILD;
1731 case CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
1732 intValue = CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER;
1734 case CONTACT_RELATIONSHIP_TYPE_FATHER:
1735 intValue = CONTACTS_RELATIONSHIP_TYPE_FATHER;
1737 case CONTACT_RELATIONSHIP_TYPE_FRIEND:
1738 intValue = CONTACTS_RELATIONSHIP_TYPE_FRIEND;
1740 case CONTACT_RELATIONSHIP_TYPE_MANAGER:
1741 intValue = CONTACTS_RELATIONSHIP_TYPE_MANAGER;
1743 case CONTACT_RELATIONSHIP_TYPE_MOTHER:
1744 intValue = CONTACTS_RELATIONSHIP_TYPE_MOTHER;
1746 case CONTACT_RELATIONSHIP_TYPE_PARENT:
1747 intValue = CONTACTS_RELATIONSHIP_TYPE_PARENT;
1749 case CONTACT_RELATIONSHIP_TYPE_PARTNER:
1750 intValue = CONTACTS_RELATIONSHIP_TYPE_PARTNER;
1752 case CONTACT_RELATIONSHIP_TYPE_REFERRED_BY:
1753 intValue = CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY;
1755 case CONTACT_RELATIONSHIP_TYPE_RELATIVE:
1756 intValue = CONTACTS_RELATIONSHIP_TYPE_RELATIVE;
1758 case CONTACT_RELATIONSHIP_TYPE_SISTER:
1759 intValue = CONTACTS_RELATIONSHIP_TYPE_SISTER;
1761 case CONTACT_RELATIONSHIP_TYPE_SPOUSE:
1762 intValue = CONTACTS_RELATIONSHIP_TYPE_SPOUSE;
1764 case CONTACT_RELATIONSHIP_TYPE_CUSTOM:
1765 intValue = CONTACTS_RELATIONSHIP_TYPE_CUSTOM;
1768 intValue = CONTACTS_RELATIONSHIP_TYPE_OTHER;
1773 contacts_record_set_int(relationshipHandle, _contacts_relationship.type, intValue);
1776 String stringValue = relationship.GetLabel();
1777 if (!stringValue.IsEmpty())
1779 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1780 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1782 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, pCharArray.get());
1786 stringValue = relationship.GetRelativeName();
1787 if (!stringValue.IsEmpty())
1789 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1790 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1792 contacts_record_set_str(relationshipHandle, _contacts_relationship.name, pCharArray.get());
1795 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.relationship, relationshipHandle);
1796 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1798 recordHandle.Release();
1805 _ContactImpl::AddEvent(const ContactEvent& event)
1807 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1812 contacts_record_h eventHandle = null;
1814 int ret = contacts_record_create(_contacts_event._uri, &eventHandle);
1815 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1817 __ContactsRecordHandle recordHandle(eventHandle);
1819 switch (event.GetType())
1821 case CONTACT_EVENT_TYPE_ANNIVERSARY:
1822 type = CONTACTS_EVENT_TYPE_ANNIVERSARY;
1824 case CONTACT_EVENT_TYPE_BIRTHDAY:
1825 type = CONTACTS_EVENT_TYPE_BIRTH;
1827 case CONTACT_EVENT_TYPE_CUSTOM:
1828 type = CONTACTS_EVENT_TYPE_CUSTOM;
1830 case CONTACT_EVENT_TYPE_OTHER:
1833 type = CONTACTS_EVENT_TYPE_OTHER;
1838 contacts_record_set_int(eventHandle, _contacts_event.type, type);
1841 stringValue = event.GetLabel();
1842 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1843 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1845 contacts_record_set_str(eventHandle, _contacts_event.label, pCharArray.get());
1848 DateTime dateValue = event.GetDate();
1849 intValue = dateValue.GetYear()*10000 + dateValue.GetMonth()*100 + dateValue.GetDay();
1850 contacts_record_set_int(eventHandle, _contacts_event.date, intValue);
1852 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.event, eventHandle);
1853 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1855 recordHandle.Release();
1861 _ContactImpl::AddOrganization(const Organization& organization)
1863 SysTryReturn(NID_SCL
1864 , !organization.GetName().IsEmpty() ||
1865 !organization.GetJobTitle().IsEmpty() ||
1866 !organization.GetDepartment().IsEmpty() ||
1867 !organization.GetRole().IsEmpty() ||
1868 !organization.GetAgent().IsEmpty() ||
1869 !organization.GetDescription().IsEmpty() ||
1870 !organization.GetLocation().IsEmpty() ||
1871 !organization.GetPhoneticName().IsEmpty() ||
1872 !organization.GetLogoPath().IsEmpty()
1873 ,E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The organization is empty.", GetErrorMessage(E_INVALID_ARG));
1874 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1876 contacts_record_h organizationHandle = null;
1878 int ret = contacts_record_create(_contacts_company._uri, &organizationHandle);
1879 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1881 __ContactsRecordHandle recordHandle(organizationHandle);
1884 String stringValue = organization.GetName();
1885 if (!stringValue.IsEmpty())
1887 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1888 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1890 contacts_record_set_str(organizationHandle, _contacts_company.name, pCharArray.get());
1894 stringValue = organization.GetJobTitle();
1895 if (!stringValue.IsEmpty())
1897 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1898 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1900 contacts_record_set_str(organizationHandle, _contacts_company.job_title, pCharArray.get());
1904 stringValue = organization.GetDepartment();
1905 if (!stringValue.IsEmpty())
1907 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1908 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1910 contacts_record_set_str(organizationHandle, _contacts_company.department, pCharArray.get());
1914 stringValue = organization.GetRole();
1915 if (!stringValue.IsEmpty())
1917 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1918 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1920 contacts_record_set_str(organizationHandle, _contacts_company.role, pCharArray.get());
1924 stringValue = organization.GetAgent();
1925 if (!stringValue.IsEmpty())
1927 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1928 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1930 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, pCharArray.get());
1936 switch (organization.GetType())
1938 case ORGANIZATION_TYPE_WORK:
1939 type = CONTACTS_COMPANY_TYPE_WORK;
1941 case ORGANIZATION_TYPE_CUSTOM:
1942 type = CONTACTS_COMPANY_TYPE_CUSTOM;
1944 case ORGANIZATION_TYPE_OTHER:
1947 type = CONTACTS_COMPANY_TYPE_OTHER;
1951 contacts_record_set_int(organizationHandle, _contacts_company.type, type);
1954 stringValue = organization.GetLabel();
1955 if (!stringValue.IsEmpty())
1957 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1958 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1960 contacts_record_set_str(organizationHandle, _contacts_company.label, pCharArray.get());
1964 stringValue = organization.GetDescription();
1965 if (!stringValue.IsEmpty())
1967 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1968 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1970 contacts_record_set_str(organizationHandle, _contacts_company.description, pCharArray.get());
1974 stringValue = organization.GetLocation();
1975 if (!stringValue.IsEmpty())
1977 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1978 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1980 contacts_record_set_str(organizationHandle, _contacts_company.location, pCharArray.get());
1984 stringValue = organization.GetPhoneticName();
1985 if (!stringValue.IsEmpty())
1987 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1988 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1990 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, pCharArray.get());
1994 if (_OrganizationImpl::GetInstance(organization)->IsLogoPathChanged() == true)
1996 stringValue = organization.GetLogoPath();
1997 if (!stringValue.IsEmpty())
1999 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2000 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2002 contacts_record_set_str(organizationHandle, _contacts_company.logo, pCharArray.get());
2006 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.company, organizationHandle);
2007 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2009 recordHandle.Release();
2015 _ContactImpl::RemoveAt(ContactMultiPropertyId id, int index)
2017 SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
2019 unsigned int count = 0;
2020 contacts_record_h recordHandle = null;
2024 case CONTACT_MPROPERTY_ID_PHONE_NUMBERS:
2025 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
2026 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of phone numbers %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2028 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.number, index, &recordHandle);
2029 contacts_record_remove_child_record(__contactHandle, _contacts_contact.number, recordHandle);
2032 case CONTACT_MPROPERTY_ID_EMAILS:
2033 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
2034 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of emails %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2036 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.email, index, &recordHandle);
2037 contacts_record_remove_child_record(__contactHandle, _contacts_contact.email, recordHandle);
2040 case CONTACT_MPROPERTY_ID_URLS:
2041 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
2042 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of urls %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2044 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.url, index, &recordHandle);
2045 contacts_record_remove_child_record(__contactHandle, _contacts_contact.url, recordHandle);
2048 case CONTACT_MPROPERTY_ID_ADDRESSES:
2049 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
2050 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of addresses %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2052 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.address, index, &recordHandle);
2053 contacts_record_remove_child_record(__contactHandle, _contacts_contact.address, recordHandle);
2056 case CONTACT_MPROPERTY_ID_IMADDRESSES:
2057 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
2058 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of IM addresses %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2060 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.messenger, index, &recordHandle);
2061 contacts_record_remove_child_record(__contactHandle, _contacts_contact.messenger, recordHandle);
2064 case CONTACT_MPROPERTY_ID_ORGANIZATIONS:
2065 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
2066 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of organizations %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2068 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, index, &recordHandle);
2069 contacts_record_remove_child_record(__contactHandle, _contacts_contact.company, recordHandle);
2072 case CONTACT_MPROPERTY_ID_EVENTS:
2073 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
2074 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of events %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2076 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, index, &recordHandle);
2077 contacts_record_remove_child_record(__contactHandle, _contacts_contact.event, recordHandle);
2080 case CONTACT_MPROPERTY_ID_RELATIONSHIPS:
2081 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.relationship, &count);
2082 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of relationships %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2084 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.relationship, index, &recordHandle);
2085 contacts_record_remove_child_record(__contactHandle, _contacts_contact.relationship, recordHandle);
2088 case CONTACT_MPROPERTY_ID_NOTES:
2089 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
2090 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of notes %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2092 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, index, &recordHandle);
2093 contacts_record_remove_child_record(__contactHandle, _contacts_contact.note, recordHandle);
2096 case CONTACT_MPROPERTY_ID_NICKNAMES:
2097 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
2098 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of nicknames %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2100 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, index, &recordHandle);
2101 contacts_record_remove_child_record(__contactHandle, _contacts_contact.nickname, recordHandle);
2105 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
2106 return E_INVALID_ARG;
2113 _ContactImpl::GetValuesN(const ContactMultiPropertyId id)
2115 IList* pList = null;
2117 SetLastResult(E_SUCCESS);
2121 case CONTACT_MPROPERTY_ID_PHONE_NUMBERS:
2122 pList = GetPhoneNumbersN();
2125 case CONTACT_MPROPERTY_ID_EMAILS:
2126 pList = GetEmailsN();
2129 case CONTACT_MPROPERTY_ID_URLS:
2133 case CONTACT_MPROPERTY_ID_ADDRESSES:
2134 pList = GetAddressesN();
2137 case CONTACT_MPROPERTY_ID_IMADDRESSES:
2138 pList = GetImAddressesN();
2141 case CONTACT_MPROPERTY_ID_ORGANIZATIONS:
2142 pList = GetOrganizationsN();
2145 case CONTACT_MPROPERTY_ID_EVENTS:
2146 pList = GetEventsN();
2149 case CONTACT_MPROPERTY_ID_RELATIONSHIPS:
2150 pList = GetRelationshipsN();
2153 case CONTACT_MPROPERTY_ID_NOTES:
2154 pList = GetNotesN();
2157 case CONTACT_MPROPERTY_ID_NICKNAMES:
2158 pList = GetNicknamesN();
2161 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
2165 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2171 _ContactImpl::SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber)
2173 SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
2174 SysTryReturn(NID_SCL, !phoneNumber.GetPhoneNumber().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The phoneNumber is string.", GetErrorMessage(E_INVALID_ARG));
2175 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2177 unsigned int count = 0;
2178 contacts_record_h recordHandle = null;
2183 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
2184 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of phone numbers.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2186 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.number, index, &recordHandle);
2189 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetLabel();
2191 switch (_PhoneNumberImpl::GetInstance(phoneNumber)->GetType())
2193 case PHONENUMBER_TYPE_HOME:
2194 type = CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE;
2196 case PHONENUMBER_TYPE_WORK:
2197 type = CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE;
2199 case PHONENUMBER_TYPE_MOBILE:
2200 type = CONTACTS_NUMBER_TYPE_CELL;
2202 case PHONENUMBER_TYPE_HOME_FAX:
2203 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME;
2205 case PHONENUMBER_TYPE_WORK_FAX:
2206 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK;
2208 case PHONENUMBER_TYPE_PAGER:
2209 type = CONTACTS_NUMBER_TYPE_PAGER;
2211 case PHONENUMBER_TYPE_CUSTOM:
2212 type = CONTACTS_NUMBER_TYPE_CUSTOM;
2214 case PHONENUMBER_TYPE_ASSISTANT:
2215 type = CONTACTS_NUMBER_TYPE_ASSISTANT;
2217 case PHONENUMBER_TYPE_OTHER:
2218 contacts_record_get_int(recordHandle, _contacts_number.type, &oriType);
2220 if (oriType == (CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE)
2221 || oriType == (CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE)
2222 || oriType == CONTACTS_NUMBER_TYPE_CELL
2223 || oriType == (CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME)
2224 || oriType == (CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK)
2225 || oriType == CONTACTS_NUMBER_TYPE_PAGER)
2227 type = CONTACTS_NUMBER_TYPE_OTHER;
2229 else if (oriType == CONTACTS_NUMBER_TYPE_CUSTOM)
2231 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
2233 char* pCharValue = null;
2235 contacts_record_get_str_p(recordHandle, _contacts_number.label, &pCharValue);
2237 stringValue = pCharValue;
2238 type = CONTACTS_NUMBER_TYPE_CUSTOM;
2243 type = CONTACTS_NUMBER_TYPE_OTHER;
2246 else if (oriType == CONTACTS_NUMBER_TYPE_ASSISTANT)
2248 if (_AppInfo::GetApiVersion() < _API_VERSION_2_1)
2250 type = CONTACTS_NUMBER_TYPE_ASSISTANT;
2254 type = CONTACTS_NUMBER_TYPE_OTHER;
2263 type = CONTACTS_NUMBER_TYPE_OTHER;
2268 contacts_record_set_int(recordHandle, _contacts_number.type, type);
2271 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2272 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2274 contacts_record_set_str(recordHandle, _contacts_number.label, pCharArray.get());
2277 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetPhoneNumber();
2278 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
2279 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2281 contacts_record_set_str(recordHandle, _contacts_number.number, pCharArray.get());
2287 _ContactImpl::SetNicknameAt(int index, const String& nickname)
2289 SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
2290 SysTryReturn(NID_SCL, !nickname.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The nickname is an empty string.", GetErrorMessage(E_INVALID_ARG));
2291 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2293 unsigned int count = 0;
2294 contacts_record_h nicknameHandle = null;
2296 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
2297 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of nicknames.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2299 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, index, &nicknameHandle);
2301 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(nickname));
2302 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2304 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
2310 _ContactImpl::SetNoteAt(int index, const String& note)
2312 SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
2313 SysTryReturn(NID_SCL, !note.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The note is an empty string.", GetErrorMessage(E_INVALID_ARG));
2314 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2316 unsigned int count = 0;
2317 contacts_record_h noteHandle = null;
2319 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
2320 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of notes.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2322 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, index, ¬eHandle);
2324 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(note));
2325 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2327 contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
2333 _ContactImpl::SetOrganizationAt(int index, const Organization& organization)
2335 SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
2336 SysTryReturn(NID_SCL
2337 , !organization.GetName().IsEmpty() ||
2338 !organization.GetJobTitle().IsEmpty() ||
2339 !organization.GetDepartment().IsEmpty() ||
2340 !organization.GetRole().IsEmpty() ||
2341 !organization.GetAgent().IsEmpty() ||
2342 !organization.GetDescription().IsEmpty() ||
2343 !organization.GetLocation().IsEmpty() ||
2344 !organization.GetPhoneticName().IsEmpty() ||
2345 !organization.GetLogoPath().IsEmpty()
2346 ,E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The organization is empty.", GetErrorMessage(E_INVALID_ARG));
2347 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2349 unsigned int count = 0;
2350 contacts_record_h organizationHandle = null;
2352 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
2353 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of organizations.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2356 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, index, &organizationHandle);
2359 String stringValue = organization.GetName();
2360 if (!stringValue.IsEmpty())
2362 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2363 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2365 contacts_record_set_str(organizationHandle, _contacts_company.name, pCharArray.get());
2369 contacts_record_set_str(organizationHandle, _contacts_company.name, null);
2373 stringValue = organization.GetJobTitle();
2374 if (!stringValue.IsEmpty())
2376 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2377 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2379 contacts_record_set_str(organizationHandle, _contacts_company.job_title, pCharArray.get());
2383 contacts_record_set_str(organizationHandle, _contacts_company.job_title, null);
2387 stringValue = organization.GetDepartment();
2388 if (!stringValue.IsEmpty())
2390 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2391 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2393 contacts_record_set_str(organizationHandle, _contacts_company.department, pCharArray.get());
2397 contacts_record_set_str(organizationHandle, _contacts_company.department, null);
2401 stringValue = organization.GetRole();
2402 if (!stringValue.IsEmpty())
2404 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2405 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2407 contacts_record_set_str(organizationHandle, _contacts_company.role, pCharArray.get());
2411 contacts_record_set_str(organizationHandle, _contacts_company.role, null);
2415 stringValue = organization.GetAgent();
2416 if (!stringValue.IsEmpty())
2418 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2419 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2421 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, pCharArray.get());
2425 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, null);
2431 switch (organization.GetType())
2433 case ORGANIZATION_TYPE_WORK:
2434 type = CONTACTS_COMPANY_TYPE_WORK;
2436 case ORGANIZATION_TYPE_CUSTOM:
2437 type = CONTACTS_COMPANY_TYPE_CUSTOM;
2439 case ORGANIZATION_TYPE_OTHER:
2442 type = CONTACTS_COMPANY_TYPE_OTHER;
2446 contacts_record_set_int(organizationHandle, _contacts_company.type, type);
2449 stringValue = organization.GetLabel();
2450 if (!stringValue.IsEmpty())
2452 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2453 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2455 contacts_record_set_str(organizationHandle, _contacts_company.label, pCharArray.get());
2459 contacts_record_set_str(organizationHandle, _contacts_company.label, null);
2463 stringValue = organization.GetDescription();
2464 if (!stringValue.IsEmpty())
2466 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2467 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2469 contacts_record_set_str(organizationHandle, _contacts_company.description, pCharArray.get());
2473 contacts_record_set_str(organizationHandle, _contacts_company.description, null);
2477 stringValue = organization.GetLocation();
2478 if (!stringValue.IsEmpty())
2480 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2481 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2483 contacts_record_set_str(organizationHandle, _contacts_company.location, pCharArray.get());
2487 contacts_record_set_str(organizationHandle, _contacts_company.location, null);
2491 stringValue = organization.GetPhoneticName();
2492 if (!stringValue.IsEmpty())
2494 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2495 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2497 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, pCharArray.get());
2501 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, null);
2505 if (_OrganizationImpl::GetInstance(organization)->IsLogoPathChanged() == true)
2507 stringValue = organization.GetLogoPath();
2508 if (!stringValue.IsEmpty())
2510 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2511 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2513 contacts_record_set_str(organizationHandle, _contacts_company.logo, pCharArray.get());
2517 contacts_record_set_str(organizationHandle, _contacts_company.logo, null);
2525 _ContactImpl::SetEventAt(int index, const ContactEvent& event)
2527 SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
2528 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2532 unsigned int count = 0;
2534 contacts_record_h eventHandle = null;
2536 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
2537 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of events.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2539 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, index, &eventHandle);
2541 switch (event.GetType())
2543 case CONTACT_EVENT_TYPE_ANNIVERSARY:
2544 type = CONTACTS_EVENT_TYPE_ANNIVERSARY;
2546 case CONTACT_EVENT_TYPE_BIRTHDAY:
2547 type = CONTACTS_EVENT_TYPE_BIRTH;
2549 case CONTACT_EVENT_TYPE_CUSTOM:
2550 type = CONTACTS_EVENT_TYPE_CUSTOM;
2552 case CONTACT_EVENT_TYPE_OTHER:
2555 type = CONTACTS_EVENT_TYPE_OTHER;
2560 contacts_record_set_int(eventHandle, _contacts_event.type, type);
2563 stringValue = event.GetLabel();
2565 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2566 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2568 contacts_record_set_str(eventHandle, _contacts_event.label, pCharArray.get());
2571 DateTime dateValue = event.GetDate();
2572 intValue = dateValue.GetYear()*10000 + dateValue.GetMonth()*100 + dateValue.GetDay();
2573 contacts_record_set_int(eventHandle, _contacts_event.date, intValue);
2579 _ContactImpl::SetRelationshipAt(int index, const Relationship& relationship)
2581 SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
2582 SysTryReturn(NID_SCL, !relationship.GetRelativeName().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The relationship is empty.", GetErrorMessage(E_INVALID_ARG));
2583 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2586 unsigned int count = 0;
2587 contacts_record_h relationshipHandle = null;
2589 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.relationship, &count);
2590 SysTryReturn(NID_SCL, count > (unsigned int)index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of relationships.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2592 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.relationship, index, &relationshipHandle);
2594 switch (relationship.GetType())
2596 case CONTACT_RELATIONSHIP_TYPE_ASSISTANT:
2597 intValue = CONTACTS_RELATIONSHIP_TYPE_ASSISTANT;
2599 case CONTACT_RELATIONSHIP_TYPE_BROTHER:
2600 intValue = CONTACTS_RELATIONSHIP_TYPE_BROTHER;
2602 case CONTACT_RELATIONSHIP_TYPE_CHILD:
2603 intValue = CONTACTS_RELATIONSHIP_TYPE_CHILD;
2605 case CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
2606 intValue = CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER;
2608 case CONTACT_RELATIONSHIP_TYPE_FATHER:
2609 intValue = CONTACTS_RELATIONSHIP_TYPE_FATHER;
2611 case CONTACT_RELATIONSHIP_TYPE_FRIEND:
2612 intValue = CONTACTS_RELATIONSHIP_TYPE_FRIEND;
2614 case CONTACT_RELATIONSHIP_TYPE_MANAGER:
2615 intValue = CONTACTS_RELATIONSHIP_TYPE_MANAGER;
2617 case CONTACT_RELATIONSHIP_TYPE_MOTHER:
2618 intValue = CONTACTS_RELATIONSHIP_TYPE_MOTHER;
2620 case CONTACT_RELATIONSHIP_TYPE_PARENT:
2621 intValue = CONTACTS_RELATIONSHIP_TYPE_PARENT;
2623 case CONTACT_RELATIONSHIP_TYPE_PARTNER:
2624 intValue = CONTACTS_RELATIONSHIP_TYPE_PARTNER;
2626 case CONTACT_RELATIONSHIP_TYPE_REFERRED_BY:
2627 intValue = CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY;
2629 case CONTACT_RELATIONSHIP_TYPE_RELATIVE:
2630 intValue = CONTACTS_RELATIONSHIP_TYPE_RELATIVE;
2632 case CONTACT_RELATIONSHIP_TYPE_SISTER:
2633 intValue = CONTACTS_RELATIONSHIP_TYPE_SISTER;
2635 case CONTACT_RELATIONSHIP_TYPE_SPOUSE:
2636 intValue = CONTACTS_RELATIONSHIP_TYPE_SPOUSE;
2638 case CONTACT_RELATIONSHIP_TYPE_CUSTOM:
2639 intValue = CONTACTS_RELATIONSHIP_TYPE_CUSTOM;
2642 intValue = CONTACTS_RELATIONSHIP_TYPE_OTHER;
2647 contacts_record_set_int(relationshipHandle, _contacts_relationship.type, intValue);
2650 String stringValue = relationship.GetLabel();
2651 if (!stringValue.IsEmpty())
2653 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2654 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2656 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, pCharArray.get());
2660 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, null);
2664 stringValue = relationship.GetRelativeName();
2665 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2666 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2668 contacts_record_set_str(relationshipHandle, _contacts_relationship.name, pCharArray.get());
2674 _ContactImpl::SetEmailAt(int index, const Email& email)
2676 SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
2677 SysTryReturn(NID_SCL, !email.GetEmail().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The email is empty.", GetErrorMessage(E_INVALID_ARG));
2678 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2680 unsigned int count = 0;
2681 contacts_record_h emailHandle = null;
2686 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
2687 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of emails.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2689 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.email, index, &emailHandle);
2691 stringValue = _EmailImpl::GetInstance(email)->GetLabel();
2693 switch (_EmailImpl::GetInstance(email)->GetType())
2695 case EMAIL_TYPE_PERSONAL:
2696 type = CONTACTS_EMAIL_TYPE_HOME;
2698 case EMAIL_TYPE_WORK:
2699 type = CONTACTS_EMAIL_TYPE_WORK;
2701 case EMAIL_TYPE_CUSTOM:
2702 type = CONTACTS_EMAIL_TYPE_CUSTOM;
2704 case EMAIL_TYPE_MOBILE:
2705 type = CONTACTS_EMAIL_TYPE_MOBILE;
2707 case EMAIL_TYPE_OTHER:
2708 contacts_record_get_int(emailHandle, _contacts_email.type, &oriType);
2709 if (oriType == CONTACTS_EMAIL_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
2711 char* pCharValue = null;
2713 contacts_record_get_str_p(emailHandle, _contacts_email.label, &pCharValue);
2715 stringValue = pCharValue;
2716 type = CONTACTS_EMAIL_TYPE_CUSTOM;
2718 else if (oriType == CONTACTS_EMAIL_TYPE_MOBILE && _AppInfo::GetApiVersion() < _API_VERSION_2_1)
2720 type = CONTACTS_EMAIL_TYPE_MOBILE;
2724 type = CONTACTS_EMAIL_TYPE_OTHER;
2728 type = CONTACTS_EMAIL_TYPE_OTHER;
2733 contacts_record_set_int(emailHandle, _contacts_email.type, type);
2736 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2737 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2739 contacts_record_set_str(emailHandle, _contacts_email.label, pCharArray.get());
2742 stringValue = _EmailImpl::GetInstance(email)->GetEmail();
2743 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
2744 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2746 contacts_record_set_str(emailHandle, _contacts_email.email, pCharArray.get());
2752 _ContactImpl::SetUrlAt(int index, const Url& url)
2754 SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
2755 SysTryReturn(NID_SCL, !url.GetUrl().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The url is empty.", GetErrorMessage(E_INVALID_ARG));
2756 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2758 unsigned int count = 0;
2759 contacts_record_h recordHandle = null;
2764 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
2765 SysTryReturn(NID_SCL, count > (unsigned int)index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of urls.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2767 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.url, index, &recordHandle);
2770 stringValue = _UrlImpl::GetInstance(url)->GetLabel();
2772 switch (_UrlImpl::GetInstance(url)->GetType())
2774 case URL_TYPE_PERSONAL:
2775 type = CONTACTS_URL_TYPE_HOME;
2778 type = CONTACTS_URL_TYPE_WORK;
2780 case URL_TYPE_CUSTOM:
2781 type = CONTACTS_URL_TYPE_CUSTOM;
2783 case URL_TYPE_OTHER:
2784 contacts_record_get_int(recordHandle, _contacts_url.type, &oriType);
2786 if (oriType == CONTACTS_URL_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
2788 char* pCharValue = null;
2790 contacts_record_get_str_p(recordHandle, _contacts_url.label, &pCharValue);
2792 stringValue = pCharValue;
2793 type = CONTACTS_URL_TYPE_CUSTOM;
2797 type = CONTACTS_URL_TYPE_OTHER;
2801 type = CONTACTS_URL_TYPE_OTHER;
2806 contacts_record_set_int(recordHandle, _contacts_url.type, type);
2809 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2810 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2812 contacts_record_set_str(recordHandle, _contacts_url.label, pCharArray.get());
2815 stringValue = _UrlImpl::GetInstance(url)->GetUrl();
2816 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
2817 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2819 contacts_record_set_str(recordHandle, _contacts_url.url, pCharArray.get());
2825 _ContactImpl::SetAddressAt(int index, const Address& address)
2827 SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_MEMORY, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
2828 SysTryReturn(NID_SCL,
2829 !address.GetCity().IsEmpty() ||
2830 !address.GetCountry().IsEmpty() ||
2831 !address.GetExtended().IsEmpty() ||
2832 !address.GetPostalCode().IsEmpty() ||
2833 !address.GetPostOfficeBoxNumber().IsEmpty() ||
2834 !address.GetState().IsEmpty() ||
2835 !address.GetStreet().IsEmpty(),
2836 E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The address is empty.", GetErrorMessage(E_INVALID_ARG));
2837 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2839 unsigned int count = 0;
2840 contacts_record_h recordHandle = null;
2845 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
2846 SysTryReturn(NID_SCL, count > (unsigned int)index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of addresses %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2848 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.address, index, &recordHandle);
2850 stringValue = _AddressImpl::GetInstance(address)->GetLabel();
2852 switch (_AddressImpl::GetInstance(address)->GetType())
2854 case ADDRESS_TYPE_HOME:
2855 type = CONTACTS_ADDRESS_TYPE_HOME;
2857 case ADDRESS_TYPE_WORK:
2858 type = CONTACTS_ADDRESS_TYPE_WORK;
2860 case ADDRESS_TYPE_CUSTOM:
2861 type = CONTACTS_ADDRESS_TYPE_CUSTOM;
2863 case ADDRESS_TYPE_OTHER:
2864 contacts_record_get_int(recordHandle, _contacts_address.type, &oriType);
2866 if (oriType == CONTACTS_ADDRESS_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
2868 char* pCharValue = null;
2870 contacts_record_get_str_p(recordHandle, _contacts_address.label, &pCharValue);
2872 stringValue = pCharValue;
2873 type = CONTACTS_ADDRESS_TYPE_CUSTOM;
2877 type = CONTACTS_ADDRESS_TYPE_OTHER;
2881 type = CONTACTS_ADDRESS_TYPE_OTHER;
2886 contacts_record_set_int(recordHandle, _contacts_address.type, type);
2889 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2890 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2892 contacts_record_set_str(recordHandle, _contacts_address.label, pCharArray.get());
2895 stringValue = _AddressImpl::GetInstance(address)->GetCity();
2896 if (!stringValue.IsEmpty())
2898 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2899 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2901 contacts_record_set_str(recordHandle, _contacts_address.locality, pCharArray.get());
2905 contacts_record_set_str(recordHandle, _contacts_address.locality, null);
2908 stringValue = _AddressImpl::GetInstance(address)->GetCountry();
2909 if (!stringValue.IsEmpty())
2911 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2912 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2914 contacts_record_set_str(recordHandle, _contacts_address.country, pCharArray.get());
2918 contacts_record_set_str(recordHandle, _contacts_address.country, null);
2921 stringValue = _AddressImpl::GetInstance(address)->GetExtended();
2922 if (!stringValue.IsEmpty())
2924 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2925 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2927 contacts_record_set_str(recordHandle, _contacts_address.extended, pCharArray.get());
2931 contacts_record_set_str(recordHandle, _contacts_address.extended, null);
2934 stringValue = _AddressImpl::GetInstance(address)->GetPostalCode();
2935 if (!stringValue.IsEmpty())
2937 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2938 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2940 contacts_record_set_str(recordHandle, _contacts_address.postal_code, pCharArray.get());
2944 contacts_record_set_str(recordHandle, _contacts_address.postal_code, null);
2947 stringValue = _AddressImpl::GetInstance(address)->GetPostOfficeBoxNumber();
2948 if (!stringValue.IsEmpty())
2950 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2951 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2953 contacts_record_set_str(recordHandle, _contacts_address.postbox, pCharArray.get());
2957 contacts_record_set_str(recordHandle, _contacts_address.postbox, null);
2960 stringValue = _AddressImpl::GetInstance(address)->GetState();
2961 if (!stringValue.IsEmpty())
2963 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2964 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2966 contacts_record_set_str(recordHandle, _contacts_address.region, pCharArray.get());
2970 contacts_record_set_str(recordHandle, _contacts_address.region, null);
2973 stringValue = _AddressImpl::GetInstance(address)->GetStreet();
2974 if (!stringValue.IsEmpty())
2976 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2977 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2979 contacts_record_set_str(recordHandle, _contacts_address.street, pCharArray.get());
2983 contacts_record_set_str(recordHandle, _contacts_address.street, null);
2990 _ContactImpl::SetImAddressAt(int index, const ImAddress& imAddress)
2992 SysTryReturn(NID_SCL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be greater than or equal to 0.", GetErrorMessage(E_OUT_OF_RANGE), index);
2993 SysTryReturn(NID_SCL, !imAddress.GetImAddress().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The imAddress is empty.", GetErrorMessage(E_INVALID_ARG));
2994 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2996 unsigned int count = 0;
2997 contacts_record_h messengerHandle = null;
3000 std::unique_ptr<char[]> pCharArray(null);
3002 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
3003 SysTryReturn(NID_SCL, count > (unsigned int)index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of IM addresses.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
3005 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.messenger, index, &messengerHandle);
3007 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetServiceProviderName();
3009 if (stringValue == IM_ADDRESS_GOOGLE_TALK)
3011 type = CONTACTS_MESSENGER_TYPE_GOOGLE;
3013 else if (stringValue == IM_ADDRESS_MSN)
3015 type = CONTACTS_MESSENGER_TYPE_WLM;
3017 else if (stringValue == IM_ADDRESS_ICQ)
3019 type = CONTACTS_MESSENGER_TYPE_ICQ;
3021 else if (stringValue == IM_ADDRESS_AIM)
3023 type = CONTACTS_MESSENGER_TYPE_AIM;
3025 else if (stringValue == IM_ADDRESS_YAHOO)
3027 type = CONTACTS_MESSENGER_TYPE_YAHOO;
3029 else if (stringValue == IM_ADDRESS_QQ)
3031 type = CONTACTS_MESSENGER_TYPE_QQ;
3033 else if (stringValue == IM_ADDRESS_SKYPE)
3035 type = CONTACTS_MESSENGER_TYPE_SKYPE;
3037 else if (stringValue == IM_ADDRESS_JABBER)
3039 type = CONTACTS_MESSENGER_TYPE_JABBER;
3043 type = CONTACTS_MESSENGER_TYPE_CUSTOM;
3046 contacts_record_set_int(messengerHandle, _contacts_messenger.type, type);
3047 if (type == CONTACTS_MESSENGER_TYPE_CUSTOM)
3049 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
3050 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3052 contacts_record_set_str(messengerHandle, _contacts_messenger.label, pCharArray.get());
3055 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetImAddress();
3056 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
3057 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3059 contacts_record_set_str(messengerHandle, _contacts_messenger.im_id, pCharArray.get());
3065 _ContactImpl::GetMaxLength(ContactPropertyId id)
3069 case CONTACT_PROPERTY_ID_FIRST_NAME:
3071 case CONTACT_PROPERTY_ID_LAST_NAME:
3073 case CONTACT_PROPERTY_ID_DISPLAY_NAME:
3075 case CONTACT_PROPERTY_ID_NICK_NAME:
3077 case CONTACT_PROPERTY_ID_MIDDLE_NAME:
3078 return MAX_CONTACT_NAME_LENGTH;
3080 case CONTACT_PROPERTY_ID_THUMBNAIL:
3083 case CONTACT_PROPERTY_ID_JOB_TITLE:
3084 return MAX_CONTACT_JOB_TITLE_LENGTH;
3086 case CONTACT_PROPERTY_ID_COMPANY:
3087 return MAX_CONTACT_COMPANY_LENGTH;
3089 case CONTACT_PROPERTY_ID_NOTE:
3090 return MAX_CONTACT_NOTE_LENGTH;
3092 case CONTACT_PROPERTY_ID_RINGTONE:
3095 case CONTACT_PROPERTY_ID_PHONETIC_FIRST_NAME:
3097 case CONTACT_PROPERTY_ID_PHONETIC_LAST_NAME:
3099 case CONTACT_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
3100 return MAX_CONTACT_NAME_LENGTH;
3108 _ContactImpl::GetOrganizationsN(void) const
3110 result r = E_SUCCESS;
3111 contacts_record_h organizationHandle = null;
3112 int ret = CONTACTS_ERROR_NONE;
3113 char* pCharValue = null;
3115 unsigned int count = 0;
3116 std::unique_ptr<Organization> pOrganization(null);
3118 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3119 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3121 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
3123 r = pList->Construct(count);
3124 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3126 for (unsigned int i = 0; i < count; i++)
3128 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, i, &organizationHandle);
3129 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
3131 pOrganization.reset(new (std::nothrow) Organization());
3132 SysTryReturn(NID_SCL, pOrganization != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3135 contacts_record_get_str_p(organizationHandle, _contacts_company.name, &pCharValue);
3136 pOrganization->SetName(pCharValue);
3139 contacts_record_get_str_p(organizationHandle, _contacts_company.job_title, &pCharValue);
3140 pOrganization->SetJobTitle(pCharValue);
3143 contacts_record_get_str_p(organizationHandle, _contacts_company.department, &pCharValue);
3144 pOrganization->SetDepartment(pCharValue);
3147 contacts_record_get_str_p(organizationHandle, _contacts_company.role, &pCharValue);
3148 pOrganization->SetRole(pCharValue);
3151 contacts_record_get_str_p(organizationHandle, _contacts_company.assistant_name, &pCharValue);
3152 pOrganization->SetAgent(pCharValue);
3155 contacts_record_get_int(organizationHandle, _contacts_company.type, &intValue);
3158 case CONTACTS_COMPANY_TYPE_WORK:
3159 pOrganization->SetType(ORGANIZATION_TYPE_WORK);
3161 case CONTACTS_COMPANY_TYPE_CUSTOM:
3162 pOrganization->SetType(ORGANIZATION_TYPE_CUSTOM);
3164 case CONTACTS_COMPANY_TYPE_OTHER:
3167 pOrganization->SetType(ORGANIZATION_TYPE_OTHER);
3172 contacts_record_get_str_p(organizationHandle, _contacts_company.label, &pCharValue);
3173 pOrganization->SetLabel(pCharValue);
3176 contacts_record_get_str_p(organizationHandle, _contacts_company.description, &pCharValue);
3177 pOrganization->SetDescription(pCharValue);
3180 contacts_record_get_str_p(organizationHandle, _contacts_company.location, &pCharValue);
3181 pOrganization->SetLocation(pCharValue);
3184 contacts_record_get_str_p(organizationHandle, _contacts_company.phonetic_name, &pCharValue);
3185 pOrganization->SetPhoneticName(pCharValue);
3188 contacts_record_get_str_p(organizationHandle, _contacts_company.logo, &pCharValue);
3189 _OrganizationImpl::GetInstance(*pOrganization)->SetLogoPath(pCharValue);
3191 r = pList->Add(*pOrganization);
3192 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3194 pOrganization.release();
3197 return pList.release();
3201 _ContactImpl::GetRelationshipsN(void) const
3203 result r = E_SUCCESS;
3204 contacts_record_h relationshipHandle = null;
3205 int ret = CONTACTS_ERROR_NONE;
3207 char* pCharValue = null;
3208 unsigned int count = 0;
3209 std::unique_ptr<Relationship> pRelationship(null);
3211 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3212 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3214 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.relationship, &count);
3216 r = pList->Construct(count);
3217 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3219 for (unsigned int i = 0; i < count; i++)
3221 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.relationship, i, &relationshipHandle);
3222 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
3224 pRelationship.reset(new (std::nothrow) Relationship());
3225 SysTryReturn(NID_SCL, pRelationship != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3228 contacts_record_get_int(relationshipHandle, _contacts_relationship.type, &intValue);
3231 case CONTACTS_RELATIONSHIP_TYPE_ASSISTANT:
3232 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_ASSISTANT);
3234 case CONTACTS_RELATIONSHIP_TYPE_BROTHER:
3235 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_BROTHER);
3237 case CONTACTS_RELATIONSHIP_TYPE_CHILD:
3238 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_CHILD);
3240 case CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
3241 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER);
3243 case CONTACTS_RELATIONSHIP_TYPE_FATHER:
3244 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_FATHER);
3246 case CONTACTS_RELATIONSHIP_TYPE_FRIEND:
3247 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_FRIEND);
3249 case CONTACTS_RELATIONSHIP_TYPE_MANAGER:
3250 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_MANAGER);
3252 case CONTACTS_RELATIONSHIP_TYPE_MOTHER:
3253 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_MOTHER);
3255 case CONTACTS_RELATIONSHIP_TYPE_PARENT:
3256 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_PARENT);
3258 case CONTACTS_RELATIONSHIP_TYPE_PARTNER:
3259 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_PARTNER);
3261 case CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY:
3262 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_REFERRED_BY);
3264 case CONTACTS_RELATIONSHIP_TYPE_RELATIVE:
3265 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_RELATIVE);
3267 case CONTACTS_RELATIONSHIP_TYPE_SISTER:
3268 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_SISTER);
3270 case CONTACTS_RELATIONSHIP_TYPE_SPOUSE:
3271 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_SPOUSE);
3273 case CONTACTS_RELATIONSHIP_TYPE_CUSTOM:
3276 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_CUSTOM);
3281 contacts_record_get_str_p(relationshipHandle, _contacts_relationship.label, &pCharValue);
3282 pRelationship->SetLabel(pCharValue);
3285 contacts_record_get_str_p(relationshipHandle, _contacts_relationship.name, &pCharValue);
3286 pRelationship->SetRelativeName(pCharValue);
3288 r = pList->Add(*pRelationship);
3289 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3291 pRelationship.release();
3294 return pList.release();
3298 _ContactImpl::GetEventsN(void) const
3300 result r = E_SUCCESS;
3301 char* pCharValue = null;
3303 unsigned int count = 0;
3304 contacts_record_h eventHandle = null;
3305 std::unique_ptr<ContactEvent> pEvent(null);
3307 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3308 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3310 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
3312 r = pList->Construct(count);
3313 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3315 for (unsigned int i = 0; i < count; i++)
3317 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
3319 pEvent.reset(new (std::nothrow) ContactEvent());
3320 SysTryReturn(NID_SCL, pEvent != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3323 contacts_record_get_str_p(eventHandle, _contacts_event.label, &pCharValue);
3324 pEvent->SetLabel(pCharValue);
3327 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
3330 case CONTACTS_EVENT_TYPE_BIRTH:
3331 pEvent->SetType(CONTACT_EVENT_TYPE_BIRTHDAY);
3333 case CONTACTS_EVENT_TYPE_ANNIVERSARY:
3334 pEvent->SetType(CONTACT_EVENT_TYPE_ANNIVERSARY);
3336 case CONTACTS_URL_TYPE_CUSTOM:
3337 pEvent->SetType(CONTACT_EVENT_TYPE_CUSTOM);
3340 pEvent->SetType(CONTACT_EVENT_TYPE_OTHER);
3346 contacts_record_get_int(eventHandle, _contacts_event.date, &intValue);
3347 __CONVERT_DATE_TO_DATETIME(intValue, dateTime);
3348 pEvent->SetDate(dateTime);
3350 pList->Add(*pEvent);
3351 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3356 return pList.release();
3360 _ContactImpl::GetNotesN(void) const
3362 result r = E_SUCCESS;
3363 char* pCharValue = null;
3364 unsigned int count = 0;
3365 contacts_record_h noteHandle = null;
3366 std::unique_ptr<String> pNote(null);
3368 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3369 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3371 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
3373 r = pList->Construct(count);
3374 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3376 for (unsigned int i = 0; i < count; i++)
3378 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, i, ¬eHandle);
3380 contacts_record_get_str_p(noteHandle, _contacts_note.note, &pCharValue);
3382 pNote.reset(new (std::nothrow) String(pCharValue));
3383 SysTryReturn(NID_SCL, pNote != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3386 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3391 return pList.release();
3395 _ContactImpl::GetNicknamesN(void) const
3397 result r = E_SUCCESS;
3398 char* pCharValue = null;
3399 unsigned int count = 0;
3400 contacts_record_h nicknameHandle = null;
3401 std::unique_ptr<String> pNickname(null);
3403 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3404 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3406 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
3408 r = pList->Construct(count);
3409 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3411 for (unsigned int i = 0; i < count; i++)
3413 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, i, &nicknameHandle);
3415 contacts_record_get_str_p(nicknameHandle, _contacts_nickname.name, &pCharValue);
3417 pNickname.reset(new (std::nothrow) String(pCharValue));
3418 SysTryReturn(NID_SCL, pNickname != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3420 pList->Add(*pNickname);
3421 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3423 pNickname.release();
3426 return pList.release();
3430 _ContactImpl::GetPhoneNumbersN(void) const
3432 result r = E_SUCCESS;
3433 unsigned int count = 0;
3434 contacts_record_h numberHandle = null;
3436 char* pCharValue = null;
3437 PhoneNumberType type = PHONENUMBER_TYPE_HOME;
3438 std::unique_ptr<PhoneNumber> pPhoneNumber(null);
3440 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3441 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3444 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
3446 contacts_record_get_int(__contactHandle, _contacts_contact.id, &intValue);
3448 r = pList->Construct(count);
3449 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3451 for (unsigned int i = 0; i < count; i++)
3453 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.number, i, &numberHandle);
3455 pPhoneNumber.reset(new (std::nothrow) PhoneNumber());
3456 SysTryReturn(NID_SCL, pPhoneNumber != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3458 contacts_record_get_int(numberHandle, _contacts_number.id, &intValue);
3459 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetRecordId(intValue);
3461 contacts_record_get_str_p(numberHandle, _contacts_number.label, &pCharValue);
3462 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetLabel(pCharValue);
3464 contacts_record_get_int(numberHandle, _contacts_number.type, &intValue);
3468 case CONTACTS_NUMBER_TYPE_HOME:
3470 case CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE:
3471 type = PHONENUMBER_TYPE_HOME;
3473 case CONTACTS_NUMBER_TYPE_WORK:
3475 case CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE:
3476 type = PHONENUMBER_TYPE_WORK;
3478 case CONTACTS_NUMBER_TYPE_CELL:
3479 type = PHONENUMBER_TYPE_MOBILE;
3481 case CONTACTS_NUMBER_TYPE_FAX:
3483 case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME:
3484 type = PHONENUMBER_TYPE_HOME_FAX;
3486 case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK:
3487 type = PHONENUMBER_TYPE_WORK_FAX;
3489 case CONTACTS_NUMBER_TYPE_PAGER:
3490 type = PHONENUMBER_TYPE_PAGER;
3492 case CONTACTS_NUMBER_TYPE_CUSTOM:
3493 type = PHONENUMBER_TYPE_CUSTOM;
3495 case CONTACTS_NUMBER_TYPE_ASSISTANT:
3496 if (_AppInfo::GetApiVersion() < _API_VERSION_2_1)
3498 type = PHONENUMBER_TYPE_OTHER;
3502 type = PHONENUMBER_TYPE_ASSISTANT;
3505 case CONTACTS_NUMBER_TYPE_OTHER:
3506 type = PHONENUMBER_TYPE_OTHER;
3509 if (intValue & CONTACTS_NUMBER_TYPE_FAX)
3511 type = PHONENUMBER_TYPE_HOME_FAX;
3513 else if (intValue & CONTACTS_NUMBER_TYPE_CELL)
3515 type = PHONENUMBER_TYPE_MOBILE;
3517 else if (intValue & CONTACTS_NUMBER_TYPE_PAGER)
3519 type = PHONENUMBER_TYPE_PAGER;
3521 else if (intValue & CONTACTS_NUMBER_TYPE_HOME)
3523 type = PHONENUMBER_TYPE_HOME;
3525 else if (intValue & CONTACTS_NUMBER_TYPE_WORK)
3527 type = PHONENUMBER_TYPE_WORK;
3529 else if (intValue & CONTACTS_NUMBER_TYPE_VOICE)
3531 type = PHONENUMBER_TYPE_HOME;
3535 type = PHONENUMBER_TYPE_OTHER;
3540 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetType(type);
3542 contacts_record_get_str_p(numberHandle, _contacts_number.number, &pCharValue);
3543 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetPhoneNumber(pCharValue);
3545 r = pList->Add(*pPhoneNumber);
3546 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3548 pPhoneNumber.release();
3551 return pList.release();
3555 _ContactImpl::GetEmailsN(void) const
3557 result r = E_SUCCESS;
3558 contacts_record_h currentHandle = null;
3559 int ret = CONTACTS_ERROR_NONE;
3561 unsigned int count = 0;
3562 char* pCharValue = null;
3563 EmailType type = EMAIL_TYPE_PERSONAL;
3564 std::unique_ptr<Email> pEmail(null);
3566 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3567 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3569 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
3571 r = pList->Construct(count);
3572 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3574 for (unsigned int i = 0; i < count; i++)
3576 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.email, i, ¤tHandle);
3577 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM))
3579 pEmail.reset(new (std::nothrow) Email());
3580 SysTryReturn(NID_SCL, pEmail != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3582 contacts_record_get_int(currentHandle, _contacts_email.id, &intValue);
3583 _EmailImpl::GetInstance(*pEmail)->SetRecordId(intValue);
3585 contacts_record_get_str_p(currentHandle, _contacts_email.label, &pCharValue);
3586 _EmailImpl::GetInstance(*pEmail)->SetLabel(pCharValue);
3588 contacts_record_get_int(currentHandle, _contacts_email.type, &intValue);
3591 case CONTACTS_EMAIL_TYPE_HOME:
3592 type = EMAIL_TYPE_PERSONAL;
3594 case CONTACTS_EMAIL_TYPE_WORK:
3595 type = EMAIL_TYPE_WORK;
3597 case CONTACTS_EMAIL_TYPE_CUSTOM:
3598 type = EMAIL_TYPE_CUSTOM;
3600 case CONTACTS_EMAIL_TYPE_MOBILE:
3601 if (_AppInfo::GetApiVersion() < _API_VERSION_2_1)
3603 type = EMAIL_TYPE_OTHER;
3607 type = EMAIL_TYPE_MOBILE;
3611 type = EMAIL_TYPE_OTHER;
3615 _EmailImpl::GetInstance(*pEmail)->SetType(type);
3617 contacts_record_get_str_p(currentHandle, _contacts_email.email, &pCharValue);
3618 _EmailImpl::GetInstance(*pEmail)->SetEmail(pCharValue);
3620 r = pList->Add(*pEmail);
3621 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3626 return pList.release();
3630 _ContactImpl::GetUrlsN(void) const
3632 result r = E_SUCCESS;
3633 char* pCharValue = null;
3635 unsigned int count = 0;
3636 UrlType type = URL_TYPE_PERSONAL;
3637 contacts_record_h urlHandle = null;
3638 std::unique_ptr<Url> pUrl(null);
3640 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3641 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3643 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
3645 r = pList->Construct(count);
3646 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3648 for (unsigned int i = 0; i < count; i++)
3650 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.url, i, &urlHandle);
3652 pUrl.reset(new (std::nothrow) Url());
3653 SysTryReturn(NID_SCL, pUrl != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3655 contacts_record_get_str_p(urlHandle, _contacts_url.label, &pCharValue);
3656 pUrl->SetLabel(pCharValue);
3658 contacts_record_get_int(urlHandle, _contacts_url.type, &intValue);
3661 case CONTACTS_URL_TYPE_HOME:
3662 type = URL_TYPE_PERSONAL;
3664 case CONTACTS_URL_TYPE_WORK:
3665 type = URL_TYPE_WORK;
3667 case CONTACTS_URL_TYPE_CUSTOM:
3668 type = URL_TYPE_CUSTOM;
3671 type = URL_TYPE_OTHER;
3675 pUrl->SetType(type);
3677 contacts_record_get_str_p(urlHandle, _contacts_url.url, &pCharValue);
3678 _UrlImpl::GetInstance(*pUrl)->SetUrl(pCharValue);
3681 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3686 return pList.release();
3690 _ContactImpl::GetAddressesN(void) const
3692 result r = E_SUCCESS;
3693 char* pCharValue = null;
3695 unsigned int count = 0;
3696 contacts_record_h addressHandle = 0;
3697 std::unique_ptr<Address> pAddress(null);
3699 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3700 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3702 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
3704 r = pList->Construct(count);
3705 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3708 for (unsigned int i = 0; i < count; i++)
3710 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.address, i, &addressHandle);
3712 pAddress.reset(new (std::nothrow) Address());
3713 SysTryReturn(NID_SCL, pAddress != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3715 contacts_record_get_str_p(addressHandle, _contacts_address.label, &pCharValue);
3716 pAddress->SetLabel(pCharValue);
3718 contacts_record_get_int(addressHandle, _contacts_address.type, &intValue);
3721 case CONTACTS_ADDRESS_TYPE_HOME:
3722 pAddress->SetType(ADDRESS_TYPE_HOME);
3724 case CONTACTS_ADDRESS_TYPE_WORK:
3725 pAddress->SetType(ADDRESS_TYPE_WORK);
3727 case CONTACTS_ADDRESS_TYPE_CUSTOM:
3728 pAddress->SetType(ADDRESS_TYPE_CUSTOM);
3731 pAddress->SetType(ADDRESS_TYPE_OTHER);
3736 contacts_record_get_str_p(addressHandle, _contacts_address.country, &pCharValue);
3737 _AddressImpl::GetInstance(*pAddress)->SetCountry(pCharValue);
3740 contacts_record_get_str_p(addressHandle, _contacts_address.region, &pCharValue);
3741 _AddressImpl::GetInstance(*pAddress)->SetState(pCharValue);
3744 contacts_record_get_str_p(addressHandle, _contacts_address.locality, &pCharValue);
3745 _AddressImpl::GetInstance(*pAddress)->SetCity(pCharValue);
3748 contacts_record_get_str_p(addressHandle, _contacts_address.street, &pCharValue);
3749 _AddressImpl::GetInstance(*pAddress)->SetStreet(pCharValue);
3752 contacts_record_get_str_p(addressHandle, _contacts_address.extended, &pCharValue);
3753 _AddressImpl::GetInstance(*pAddress)->SetExtended(pCharValue);
3756 contacts_record_get_str_p(addressHandle, _contacts_address.postbox, &pCharValue);
3757 _AddressImpl::GetInstance(*pAddress)->SetPostOfficeBoxNumber(pCharValue);
3760 contacts_record_get_str_p(addressHandle, _contacts_address.postal_code, &pCharValue);
3761 _AddressImpl::GetInstance(*pAddress)->SetPostalCode(pCharValue);
3763 r = pList->Add(*pAddress);
3764 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3769 return pList.release();
3773 _ContactImpl::GetImAddressesN(void) const
3775 result r = E_SUCCESS;
3776 char* pCharValue = null;
3778 contacts_record_h messengerHandle = null;
3779 unsigned int count = 0;
3780 std::unique_ptr<ImAddress> pImAddress(null);
3782 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3783 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3785 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
3787 r = pList->Construct(count);
3788 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3791 for (unsigned int i = 0; i < count; i++)
3793 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.messenger, i, &messengerHandle);
3795 pImAddress.reset(new (std::nothrow) ImAddress());
3796 SysTryReturn(NID_SCL, pImAddress != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3798 contacts_record_get_int(messengerHandle, _contacts_messenger.type, &intValue);
3801 case CONTACTS_MESSENGER_TYPE_GOOGLE:
3802 pImAddress->SetServiceProviderName(IM_ADDRESS_GOOGLE_TALK);
3804 case CONTACTS_MESSENGER_TYPE_WLM:
3805 pImAddress->SetServiceProviderName(IM_ADDRESS_MSN);
3807 case CONTACTS_MESSENGER_TYPE_ICQ:
3808 pImAddress->SetServiceProviderName(IM_ADDRESS_ICQ);
3810 case CONTACTS_MESSENGER_TYPE_AIM:
3811 pImAddress->SetServiceProviderName(IM_ADDRESS_AIM);
3813 case CONTACTS_MESSENGER_TYPE_YAHOO:
3814 pImAddress->SetServiceProviderName(IM_ADDRESS_YAHOO);
3816 case CONTACTS_MESSENGER_TYPE_QQ:
3817 pImAddress->SetServiceProviderName(IM_ADDRESS_QQ);
3819 case CONTACTS_MESSENGER_TYPE_SKYPE:
3820 pImAddress->SetServiceProviderName(IM_ADDRESS_SKYPE);
3822 case CONTACTS_MESSENGER_TYPE_JABBER:
3823 pImAddress->SetServiceProviderName(IM_ADDRESS_JABBER);
3825 case CONTACTS_MESSENGER_TYPE_CUSTOM:
3828 contacts_record_get_str_p(messengerHandle, _contacts_messenger.label, &pCharValue);
3829 pImAddress->SetServiceProviderName(pCharValue);
3833 contacts_record_get_str_p(messengerHandle, _contacts_messenger.im_id, &pCharValue);
3834 _ImAddressImpl::GetInstance(*pImAddress)->SetImAddress(pCharValue);
3836 r = pList->Add(*pImAddress);
3837 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3839 pImAddress.release();
3842 return pList.release();
3846 _ContactImpl::IsEmpty(void) const
3848 char* pCharValue = null;
3849 unsigned int count = 0;
3851 contacts_record_get_str_p(__contactHandle, _contacts_contact.ringtone_path, &pCharValue);
3852 if (pCharValue != null)
3857 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
3863 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
3869 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
3875 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
3881 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
3887 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
3893 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
3899 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
3905 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
3911 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
3917 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
3923 contacts_record_get_str_p(__contactHandle, _contacts_contact.uid, &pCharValue);
3924 if (pCharValue != null)
3933 _ContactImpl::GetAddressbookId(void) const
3935 int addressbookId = 0;
3937 contacts_record_get_int(__contactHandle, _contacts_contact.address_book_id, &addressbookId);
3939 return addressbookId;
3943 _ContactImpl::GetPersonId(void) const
3947 contacts_record_get_int(__contactHandle, _contacts_contact.person_id, &personId);
3953 _ContactImpl::SetAsRemoved(void)
3959 _ContactImpl::IsRemoved(void) const
3965 _ContactImpl::IsFavorite(void) const
3967 bool isFavorite = false;
3968 contacts_record_get_bool(__contactHandle, _contacts_contact.is_favorite, &isFavorite);
3974 _ContactImpl::SetAsFavorite(bool isFavorite)
3976 contacts_record_set_bool(__contactHandle, _contacts_contact.is_favorite, isFavorite);
3980 _ContactImpl::Invalidate(void)
3982 int ret = CONTACTS_ERROR_NONE;
3984 unsigned int count = 0;
3985 char* pCharValue = null;
3987 bool boolValue = false;
3989 contacts_record_h contactHandle = null;
3990 contacts_record_h sourceRecordHandle = null;
3991 contacts_record_h destRecordHandle = null;
3993 ret = contacts_record_create(_contacts_contact._uri, &contactHandle);
3994 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3996 __ContactsRecordHandle recordHandle(contactHandle);
3999 contacts_record_get_bool(sourceRecordHandle, _contacts_contact.is_favorite, &boolValue);
4000 contacts_record_set_bool(destRecordHandle, _contacts_contact.is_favorite, boolValue);
4003 contacts_record_get_str_p(sourceRecordHandle, _contacts_contact.uid, &pCharValue);
4004 contacts_record_set_str(destRecordHandle, _contacts_contact.uid, pCharValue);
4006 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4008 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4009 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
4012 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &sourceRecordHandle);
4014 ret = contacts_record_create(_contacts_name._uri, &destRecordHandle);
4015 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4017 __ContactsRecordHandle nameHandle(destRecordHandle);
4020 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.first, &pCharValue);
4021 contacts_record_set_str(destRecordHandle, _contacts_name.first, pCharValue);
4024 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.last, &pCharValue);
4025 contacts_record_set_str(destRecordHandle, _contacts_name.last, pCharValue);
4028 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.addition, &pCharValue);
4029 contacts_record_set_str(destRecordHandle, _contacts_name.addition, pCharValue);
4032 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.suffix, &pCharValue);
4033 contacts_record_set_str(destRecordHandle, _contacts_name.suffix, pCharValue);
4036 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.prefix, &pCharValue);
4037 contacts_record_set_str(destRecordHandle, _contacts_name.prefix, pCharValue);
4039 // 6. phonetic_first
4040 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_first, &pCharValue);
4041 contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_first, pCharValue);
4044 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_last, &pCharValue);
4045 contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_last, pCharValue);
4047 // 8. phonetic_middle
4048 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_middle, &pCharValue);
4049 contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_middle, pCharValue);
4051 contacts_record_add_child_record(contactHandle, _contacts_contact.name, destRecordHandle);
4053 nameHandle.Release();
4056 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4058 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4059 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
4062 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, 0, &sourceRecordHandle);
4064 ret = contacts_record_create(_contacts_image._uri, &destRecordHandle);
4065 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4067 __ContactsRecordHandle imageHandle(destRecordHandle);
4069 contacts_record_get_int(sourceRecordHandle, _contacts_image.type, &intValue);
4070 contacts_record_set_int(destRecordHandle, _contacts_image.type, intValue);
4072 contacts_record_get_str_p(sourceRecordHandle, _contacts_image.label, &pCharValue);
4073 contacts_record_set_str(destRecordHandle, _contacts_image.label, pCharValue);
4075 contacts_record_get_str_p(sourceRecordHandle, _contacts_image.path, &pCharValue);
4076 contacts_record_set_str(destRecordHandle, _contacts_image.path, pCharValue);
4078 contacts_record_add_child_record(contactHandle, _contacts_contact.image, destRecordHandle);
4080 imageHandle.Release();
4083 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4085 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4086 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
4087 for (i = 0; i < count; i++)
4089 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, i, &sourceRecordHandle);
4091 ret = contacts_record_create(_contacts_company._uri, &destRecordHandle);
4092 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4094 __ContactsRecordHandle companyHandle(destRecordHandle);
4096 contacts_record_get_int(sourceRecordHandle, _contacts_company.type, &intValue);
4097 contacts_record_set_int(destRecordHandle, _contacts_company.type, intValue);
4099 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.name, &pCharValue);
4100 contacts_record_set_str(destRecordHandle, _contacts_company.name, pCharValue);
4102 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.department, &pCharValue);
4103 contacts_record_set_str(destRecordHandle, _contacts_company.department, pCharValue);
4105 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.job_title, &pCharValue);
4106 contacts_record_set_str(destRecordHandle, _contacts_company.job_title, pCharValue);
4108 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.assistant_name, &pCharValue);
4109 contacts_record_set_str(destRecordHandle, _contacts_company.assistant_name, pCharValue);
4111 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.role, &pCharValue);
4112 contacts_record_set_str(destRecordHandle, _contacts_company.role, pCharValue);
4114 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.logo, &pCharValue);
4115 contacts_record_set_str(destRecordHandle, _contacts_company.logo, pCharValue);
4117 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.location, &pCharValue);
4118 contacts_record_set_str(destRecordHandle, _contacts_company.location, pCharValue);
4120 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.description, &pCharValue);
4121 contacts_record_set_str(destRecordHandle, _contacts_company.description, pCharValue);
4123 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.phonetic_name, &pCharValue);
4124 contacts_record_set_str(destRecordHandle, _contacts_company.phonetic_name, pCharValue);
4126 contacts_record_add_child_record(contactHandle, _contacts_contact.company, destRecordHandle);
4128 companyHandle.Release();
4131 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4133 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4134 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
4135 for (i = 0; i < count; i++)
4137 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, i, &sourceRecordHandle);
4139 ret = contacts_record_create(_contacts_note._uri, &destRecordHandle);
4140 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4142 __ContactsRecordHandle noteHandle(destRecordHandle);
4144 contacts_record_get_str_p(sourceRecordHandle, _contacts_note.note, &pCharValue);
4145 contacts_record_set_str(destRecordHandle, _contacts_note.note, pCharValue);
4147 contacts_record_add_child_record(contactHandle, _contacts_contact.note, destRecordHandle);
4149 noteHandle.Release();
4152 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4154 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4155 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
4156 for (i = 0; i < count; i++)
4158 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.number, i, &sourceRecordHandle);
4160 ret = contacts_record_create(_contacts_number._uri, &destRecordHandle);
4161 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4163 __ContactsRecordHandle numberHandle(destRecordHandle);
4165 contacts_record_get_int(sourceRecordHandle, _contacts_number.type, &intValue);
4166 contacts_record_set_int(destRecordHandle, _contacts_number.type, intValue);
4168 contacts_record_get_str_p(sourceRecordHandle, _contacts_number.label, &pCharValue);
4169 contacts_record_set_str(destRecordHandle, _contacts_number.label, pCharValue);
4171 contacts_record_get_str_p(sourceRecordHandle, _contacts_number.number, &pCharValue);
4172 contacts_record_set_str(destRecordHandle, _contacts_number.number, pCharValue);
4174 contacts_record_add_child_record(contactHandle, _contacts_contact.number, destRecordHandle);
4176 numberHandle.Release();
4179 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4181 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4182 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
4183 for (i = 0; i < count; i++)
4185 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.email, i, &sourceRecordHandle);
4187 ret = contacts_record_create(_contacts_email._uri, &destRecordHandle);
4188 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4190 __ContactsRecordHandle emailHandle(destRecordHandle);
4192 contacts_record_get_int(sourceRecordHandle, _contacts_email.type, &intValue);
4193 contacts_record_set_int(destRecordHandle, _contacts_email.type, intValue);
4195 contacts_record_get_str_p(sourceRecordHandle, _contacts_email.label, &pCharValue);
4196 contacts_record_set_str(destRecordHandle, _contacts_email.label, pCharValue);
4198 contacts_record_get_str_p(sourceRecordHandle, _contacts_email.email, &pCharValue);
4199 contacts_record_set_str(destRecordHandle, _contacts_email.email, pCharValue);
4201 contacts_record_add_child_record(contactHandle, _contacts_contact.email, destRecordHandle);
4203 emailHandle.Release();
4207 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4209 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4210 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
4211 for (i = 0; i < count; i++)
4213 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &sourceRecordHandle);
4215 ret = contacts_record_create(_contacts_event._uri, &destRecordHandle);
4216 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4218 __ContactsRecordHandle eventHandle(destRecordHandle);
4220 contacts_record_get_int(sourceRecordHandle, _contacts_event.type, &intValue);
4221 contacts_record_set_int(destRecordHandle, _contacts_event.type, intValue);
4223 contacts_record_get_str_p(sourceRecordHandle, _contacts_event.label, &pCharValue);
4224 contacts_record_set_str(destRecordHandle, _contacts_event.label, pCharValue);
4226 contacts_record_get_int(sourceRecordHandle, _contacts_event.date, &intValue);
4227 contacts_record_set_int(destRecordHandle, _contacts_event.date, intValue);
4229 contacts_record_add_child_record(contactHandle, _contacts_contact.event, destRecordHandle);
4231 eventHandle.Release();
4234 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4236 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4237 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
4238 for (i = 0; i < count; i++)
4240 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.messenger, i, &sourceRecordHandle);
4242 ret = contacts_record_create(_contacts_messenger._uri, &destRecordHandle);
4243 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4245 __ContactsRecordHandle imAddressHandle(destRecordHandle);
4247 contacts_record_get_int(sourceRecordHandle, _contacts_messenger.type, &intValue);
4248 contacts_record_set_int(destRecordHandle, _contacts_messenger.type, intValue);
4250 contacts_record_get_str_p(sourceRecordHandle, _contacts_messenger.label, &pCharValue);
4251 contacts_record_set_str(destRecordHandle, _contacts_messenger.label, pCharValue);
4253 contacts_record_get_str_p(sourceRecordHandle, _contacts_messenger.im_id, &pCharValue);
4254 contacts_record_set_str(destRecordHandle, _contacts_messenger.im_id, pCharValue);
4256 contacts_record_add_child_record(contactHandle, _contacts_contact.messenger, destRecordHandle);
4258 imAddressHandle.Release();
4261 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4263 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4264 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
4265 for (i = 0; i < count; i++)
4267 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.address, i, &sourceRecordHandle);
4269 ret = contacts_record_create(_contacts_address._uri, &destRecordHandle);
4270 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4272 __ContactsRecordHandle addressHandle(destRecordHandle);
4274 contacts_record_get_int(sourceRecordHandle, _contacts_address.type, &intValue);
4275 contacts_record_set_int(destRecordHandle, _contacts_address.type, intValue);
4277 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.label, &pCharValue);
4278 contacts_record_set_str(destRecordHandle, _contacts_address.label, pCharValue);
4280 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.postbox, &pCharValue);
4281 contacts_record_set_str(destRecordHandle, _contacts_address.postbox, pCharValue);
4283 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.extended, &pCharValue);
4284 contacts_record_set_str(destRecordHandle, _contacts_address.extended, pCharValue);
4286 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.street, &pCharValue);
4287 contacts_record_set_str(destRecordHandle, _contacts_address.street, pCharValue);
4289 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.locality, &pCharValue);
4290 contacts_record_set_str(destRecordHandle, _contacts_address.locality, pCharValue);
4292 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.region, &pCharValue);
4293 contacts_record_set_str(destRecordHandle, _contacts_address.region, pCharValue);
4295 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.postal_code, &pCharValue);
4296 contacts_record_set_str(destRecordHandle, _contacts_address.postal_code, pCharValue);
4298 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.country, &pCharValue);
4299 contacts_record_set_str(destRecordHandle, _contacts_address.country, pCharValue);
4301 contacts_record_add_child_record(contactHandle, _contacts_contact.address, destRecordHandle);
4303 addressHandle.Release();
4306 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4308 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4309 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
4310 for (i = 0; i < count; i++)
4312 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.url, i, &sourceRecordHandle);
4314 ret = contacts_record_create(_contacts_url._uri, &destRecordHandle);
4315 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4317 __ContactsRecordHandle urlHandle(destRecordHandle);
4319 contacts_record_get_int(sourceRecordHandle, _contacts_url.type, &intValue);
4320 contacts_record_set_int(destRecordHandle, _contacts_url.type, intValue);
4322 contacts_record_get_str_p(sourceRecordHandle, _contacts_url.label, &pCharValue);
4323 contacts_record_set_str(destRecordHandle, _contacts_url.label, pCharValue);
4325 contacts_record_get_str_p(sourceRecordHandle, _contacts_url.url, &pCharValue);
4326 contacts_record_set_str(destRecordHandle, _contacts_url.url, pCharValue);
4328 contacts_record_add_child_record(contactHandle, _contacts_contact.url, destRecordHandle);
4330 urlHandle.Release();
4333 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4335 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4336 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
4337 for (i = 0; i < count; i++)
4339 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, i, &sourceRecordHandle);
4341 ret = contacts_record_create(_contacts_nickname._uri, &destRecordHandle);
4342 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4344 __ContactsRecordHandle nicknameHandle(destRecordHandle);
4346 contacts_record_get_str_p(sourceRecordHandle, _contacts_nickname.name, &pCharValue);
4347 contacts_record_set_str(destRecordHandle, _contacts_nickname.name, pCharValue);
4349 contacts_record_add_child_record(contactHandle, _contacts_contact.nickname, destRecordHandle);
4351 nicknameHandle.Release();
4354 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4356 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4357 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.relationship, &count);
4358 for (i = 0; i < count; i++)
4360 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.relationship, i, &sourceRecordHandle);
4362 ret = contacts_record_create(_contacts_relationship._uri, &destRecordHandle);
4363 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4365 __ContactsRecordHandle relationshipHandle(destRecordHandle);
4367 contacts_record_get_str_p(sourceRecordHandle, _contacts_relationship.name, &pCharValue);
4368 contacts_record_set_str(destRecordHandle, _contacts_relationship.name, pCharValue);
4370 contacts_record_add_child_record(contactHandle, _contacts_contact.relationship, destRecordHandle);
4372 relationshipHandle.Release();
4375 contacts_record_destroy(__contactHandle, true);
4376 __contactHandle = contactHandle;
4378 __isRemoved = false;
4380 recordHandle.Release();
4386 _ContactImpl::GetInstance(const Contact& contact)
4388 return contact.__pContactImpl;
4392 _ContactImpl::GetInstance(Contact& contact)
4394 return contact.__pContactImpl;