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"
48 #include "FScl_ContactEventImpl.h"
50 using namespace Tizen::App;
51 using namespace Tizen::Base;
52 using namespace Tizen::Base::Collection;
53 using namespace Tizen::Graphics;
54 using namespace Tizen::Media;
55 using namespace Tizen::Io;
57 namespace Tizen { namespace Social
60 extern const wchar_t OTHER_LABEL[] = L"Other";
62 const int __CONTACT_CHANGED_TIME_YEAR_OFFSET = 1900;
63 const int __CONTACT_CHANGED_TIME_MONTH_OFFSET = 1;
65 const int __CONTACT_MOD_YEAR = 10000;
66 const int __CONTACT_MOD_MONTH = 100;
68 #define __PARSE_DATE(date, year, month, day) \
72 year = temp/__CONTACT_MOD_YEAR; \
73 temp -= year*__CONTACT_MOD_YEAR; \
74 month = temp/__CONTACT_MOD_MONTH; \
75 day = temp - month*__CONTACT_MOD_MONTH; \
78 #define __CONVERT_DATE_TO_DATETIME(date, dateTime) \
85 year = temp/__CONTACT_MOD_YEAR; \
86 temp -= year*__CONTACT_MOD_YEAR; \
87 month = temp/__CONTACT_MOD_MONTH; \
88 day = temp - month*__CONTACT_MOD_MONTH; \
89 dateTime.SetValue(year, month, day, 0, 0, 0); \
93 #define __CONVERT_DATETIME_TO_DATE(dateTime, date) \
96 date = dateTime.GetYear()*__CONTACT_MOD_YEAR + dateTime.GetMonth()*__CONTACT_MOD_MONTH + dateTime.GetDay(); \
99 _ContactImpl::_ContactImpl(void)
100 : __contactHandle(null)
103 contacts_record_h contactHandle = null;
105 SysTryReturnVoidResult(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
107 int ret = contacts_record_create(_contacts_contact._uri, &contactHandle);
108 SysTryReturnVoidResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
110 __contactHandle = contactHandle;
113 _ContactImpl::_ContactImpl(const _ContactImpl& rhs)
114 : __contactHandle(null)
116 contacts_record_h contactHandle = null;
118 SysTryReturnVoidResult(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
120 int ret = contacts_record_clone(rhs.__contactHandle, &contactHandle);
121 SysTryReturnVoidResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
123 __contactHandle = contactHandle;
124 __isRemoved = rhs.__isRemoved;
127 _ContactImpl::~_ContactImpl(void)
129 if (__contactHandle != null)
131 contacts_record_destroy(__contactHandle, true);
136 _ContactImpl::operator =(const _ContactImpl& rhs)
143 contacts_record_h contactHandle = null;
145 int ret = contacts_record_clone(rhs.__contactHandle, &contactHandle);
146 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
148 contacts_record_destroy(__contactHandle, true);
149 __contactHandle = contactHandle;
151 __isRemoved = rhs.__isRemoved;
157 _ContactImpl::SetContactRecordHandle(contacts_record_h contactHandle)
159 contacts_record_destroy(__contactHandle, true);
161 __contactHandle = contactHandle;
165 _ContactImpl::GetContactRecordHandle(void) const
167 return __contactHandle;
171 _ContactImpl::SetThumbnailPath(const Tizen::Base::String& filePath)
173 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));
175 unsigned int count = 0;
176 contacts_record_h imageHandle = null;
178 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
181 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, 0, &imageHandle);
183 if (!filePath.IsEmpty())
185 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(filePath));
186 SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
188 contacts_record_set_str(imageHandle, _contacts_image.path, pCharArray.get());
192 contacts_record_remove_child_record(__contactHandle, _contacts_contact.image, imageHandle);
193 contacts_record_destroy(imageHandle, true);
198 if (!filePath.IsEmpty())
200 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(filePath));
201 SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
203 int ret = contacts_record_create(_contacts_image._uri, &imageHandle);
204 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
206 contacts_record_set_str(imageHandle, _contacts_image.path, pCharArray.get());
208 contacts_record_add_child_record(__contactHandle, _contacts_contact.image, imageHandle);
216 _ContactImpl::GetThumbnailPath(void) const
218 unsigned int count = 0;
220 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
226 char* pCharValue = null;
227 contacts_record_h imageHandle = null;
229 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, 0, &imageHandle);
230 contacts_record_get_str_p(imageHandle, _contacts_image.path, &pCharValue);
232 return String(pCharValue);
236 _ContactImpl::GetThumbnailN(void) const
238 unsigned int count = 0;
239 char* pCharValue = null;
240 contacts_record_h imageHandle = null;
244 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
250 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, 0, &imageHandle);
251 contacts_record_get_str_p(imageHandle, _contacts_image.path, &pCharValue);
253 String thumbnailPath(pCharValue);
256 result r = image.Construct();
257 SysTryReturn(NID_SCL, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
258 SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Failed to construct Image.", GetErrorMessage(E_SYSTEM));
260 ImageFormat imageFormat = image.GetImageFormat(thumbnailPath);
261 SysTryReturn(NID_SCL, GetLastResult() != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
262 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, null, E_SYSTEM, "[%s] Failed to get the format of the thumbnail image.", GetErrorMessage(E_SYSTEM));
264 BitmapPixelFormat bitmapPixelFormat = BITMAP_PIXEL_FORMAT_RGB565;
273 bitmapPixelFormat = BITMAP_PIXEL_FORMAT_RGB565;
276 bitmapPixelFormat = BITMAP_PIXEL_FORMAT_ARGB8888;
279 SysLogException(NID_SCL, E_SYSTEM, "[%s] Unsupported image format.", GetErrorMessage(E_SYSTEM));
283 Bitmap* pBitmap = image.DecodeN(thumbnailPath, bitmapPixelFormat);
284 SysTryReturn(NID_SCL, GetLastResult() != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. ", GetErrorMessage(E_OUT_OF_MEMORY));
285 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred. ", GetErrorMessage(E_SYSTEM));
291 _ContactImpl::GetValue(const ContactPropertyId id, String& value) const
293 unsigned int count = 0;
294 char* pCharValue = null;
298 case CONTACT_PROPERTY_ID_FIRST_NAME:
300 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
303 contacts_record_h nameHandle = null;
305 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
306 contacts_record_get_str_p(nameHandle, _contacts_name.first, &pCharValue);
312 case CONTACT_PROPERTY_ID_LAST_NAME:
314 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
317 contacts_record_h nameHandle = null;
319 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
320 contacts_record_get_str_p(nameHandle, _contacts_name.last, &pCharValue);
326 case CONTACT_PROPERTY_ID_DISPLAY_NAME:
327 contacts_record_get_str_p(__contactHandle, _contacts_contact.display_name, &pCharValue);
330 case CONTACT_PROPERTY_ID_NICK_NAME:
332 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
335 contacts_record_h nicknameHandle = null;
337 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, 0, &nicknameHandle);
338 contacts_record_get_str_p(nicknameHandle, _contacts_nickname.name, &pCharValue);
344 case CONTACT_PROPERTY_ID_MIDDLE_NAME:
346 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
349 contacts_record_h nameHandle = null;
351 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
352 contacts_record_get_str_p(nameHandle, _contacts_name.addition, &pCharValue);
358 case CONTACT_PROPERTY_ID_NAME_PREFIX:
360 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
363 contacts_record_h nameHandle = null;
365 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
366 contacts_record_get_str_p(nameHandle, _contacts_name.prefix, &pCharValue);
372 case CONTACT_PROPERTY_ID_NAME_SUFFIX:
374 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
377 contacts_record_h nameHandle = null;
379 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
380 contacts_record_get_str_p(nameHandle, _contacts_name.suffix, &pCharValue);
386 case CONTACT_PROPERTY_ID_JOB_TITLE:
388 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
391 contacts_record_h companyHandle = null;
393 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
394 contacts_record_get_str_p(companyHandle, _contacts_company.job_title, &pCharValue);
400 case CONTACT_PROPERTY_ID_COMPANY:
402 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
405 contacts_record_h companyHandle = null;
407 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
408 contacts_record_get_str_p(companyHandle, _contacts_company.name, &pCharValue);
414 case CONTACT_PROPERTY_ID_NOTE:
416 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
419 contacts_record_h noteHandle = null;
421 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, 0, ¬eHandle);
422 contacts_record_get_str_p(noteHandle, _contacts_note.note, &pCharValue);
428 case CONTACT_PROPERTY_ID_RINGTONE:
429 contacts_record_get_str_p(__contactHandle, _contacts_contact.ringtone_path, &pCharValue);
432 case CONTACT_PROPERTY_ID_THUMBNAIL:
434 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
437 contacts_record_h imageHandle = null;
439 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, 0, &imageHandle);
440 contacts_record_get_str_p(imageHandle, _contacts_image.path, &pCharValue);
445 case CONTACT_PROPERTY_ID_PHONETIC_FIRST_NAME:
447 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
450 contacts_record_h phoneticNameHandle = null;
452 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
453 contacts_record_get_str_p(phoneticNameHandle, _contacts_name.phonetic_first, &pCharValue);
459 case CONTACT_PROPERTY_ID_PHONETIC_LAST_NAME:
461 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
464 contacts_record_h phoneticNameHandle = null;
466 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
467 contacts_record_get_str_p(phoneticNameHandle, _contacts_name.phonetic_last, &pCharValue);
473 case CONTACT_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
475 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
478 contacts_record_h phoneticNameHandle = null;
480 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
481 contacts_record_get_str_p(phoneticNameHandle, _contacts_name.phonetic_middle, &pCharValue);
487 case CONTACT_PROPERTY_ID_UID:
489 contacts_record_get_str_p(__contactHandle, _contacts_contact.uid, &pCharValue);
496 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d", GetErrorMessage(E_INVALID_ARG), id);
497 return E_INVALID_ARG;
504 _ContactImpl::GetValue(const ContactPropertyId id, DateTime& value) const
508 unsigned int count = 0;
510 value = DateTime::GetMinValue();
514 case CONTACT_PROPERTY_ID_BIRTHDAY:
516 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
523 contacts_record_h eventHandle = null;
524 for (unsigned int i = 0; i < count; i++)
526 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
527 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
528 if (intValue == CONTACTS_EVENT_TYPE_BIRTH)
530 contacts_record_get_int(eventHandle, _contacts_event.date, &intValue);
532 __PARSE_DATE(intValue, year, month, day);
534 value.SetValue(year, month, day, 0, 0, 0);
542 case CONTACT_PROPERTY_ID_ANNIVERSARY:
544 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
551 contacts_record_h eventHandle = null;
552 for (unsigned int i = 0; i < count; i++)
554 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
555 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
556 if (intValue == CONTACTS_EVENT_TYPE_ANNIVERSARY)
558 contacts_record_get_int(eventHandle, _contacts_event.date, &intValue);
560 __PARSE_DATE(intValue, year, month, day);
562 value.SetValue(year, month, day, 0, 0, 0);
570 case CONTACT_PROPERTY_ID_LAST_REVISION:
575 contacts_record_get_int(__contactHandle, _contacts_contact.changed_time, &intValue);
576 gmtime_r((time_t *)intValue, &ts);
578 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);
583 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
584 return E_INVALID_ARG;
591 _ContactImpl::IsEmptyCompany(contacts_record_h companyHandle)
593 char* pCharValue = null;
595 contacts_record_get_str_p(companyHandle, _contacts_company.name, &pCharValue);
596 if (pCharValue != null)
601 contacts_record_get_str_p(companyHandle, _contacts_company.job_title, &pCharValue);
602 if (pCharValue != null)
607 contacts_record_get_str_p(companyHandle, _contacts_company.department, &pCharValue);
608 if (pCharValue != null)
613 contacts_record_get_str_p(companyHandle, _contacts_company.role, &pCharValue);
614 if (pCharValue != null)
619 contacts_record_get_str_p(companyHandle, _contacts_company.assistant_name, &pCharValue);
620 if (pCharValue != null)
625 contacts_record_get_str_p(companyHandle, _contacts_company.description, &pCharValue);
626 if (pCharValue != null)
631 contacts_record_get_str_p(companyHandle, _contacts_company.location, &pCharValue);
632 if (pCharValue != null)
637 contacts_record_get_str_p(companyHandle, _contacts_company.phonetic_name, &pCharValue);
638 if (pCharValue != null)
643 contacts_record_get_str_p(companyHandle, _contacts_company.logo, &pCharValue);
644 if (pCharValue != null)
653 _ContactImpl::IsEmptyName(contacts_record_h nameHandle)
655 char* pCharValue = null;
657 contacts_record_get_str_p(nameHandle, _contacts_name.first, &pCharValue);
658 if (pCharValue != null)
663 contacts_record_get_str_p(nameHandle, _contacts_name.last, &pCharValue);
664 if (pCharValue != null)
669 contacts_record_get_str_p(nameHandle, _contacts_name.addition, &pCharValue);
670 if (pCharValue != null)
675 contacts_record_get_str_p(nameHandle, _contacts_name.prefix, &pCharValue);
676 if (pCharValue != null)
681 contacts_record_get_str_p(nameHandle, _contacts_name.suffix, &pCharValue);
682 if (pCharValue != null)
687 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_first, &pCharValue);
688 if (pCharValue != null)
693 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_last, &pCharValue);
694 if (pCharValue != null)
699 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_middle, &pCharValue);
700 if (pCharValue != null)
709 _ContactImpl::SetValue(ContactPropertyId id, const String& value)
711 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));
712 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));
714 int ret = CONTACTS_ERROR_NONE;
715 unsigned int count = 0;
717 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
719 int maxLength = GetMaxLength(id);
720 SysTryReturn(NID_SCL, value.GetLength() <= maxLength || maxLength == -1 , E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The length of the value exceeds the maximum length.", GetErrorMessage(E_INVALID_ARG));
725 case CONTACT_PROPERTY_ID_FIRST_NAME:
727 contacts_record_h nameHandle = null;
728 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
731 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
733 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
734 contacts_record_set_str(nameHandle, _contacts_name.first, pCharArray.get());
736 if (value.IsEmpty() && IsEmptyName(nameHandle))
738 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
739 contacts_record_destroy(nameHandle, true);
744 if (!value.IsEmpty())
746 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
747 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
749 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
750 contacts_record_set_str(nameHandle, _contacts_name.first, pCharArray.get());
752 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
758 case CONTACT_PROPERTY_ID_MIDDLE_NAME:
760 contacts_record_h nameHandle = null;
761 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
764 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
766 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
767 contacts_record_set_str(nameHandle, _contacts_name.addition, pCharArray.get());
769 if (value.IsEmpty() && IsEmptyName(nameHandle))
771 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
772 contacts_record_destroy(nameHandle, true);
777 if (!value.IsEmpty())
779 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
780 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
782 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
783 contacts_record_set_str(nameHandle, _contacts_name.addition, pCharArray.get());
785 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
793 case CONTACT_PROPERTY_ID_LAST_NAME:
795 contacts_record_h nameHandle = null;
796 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
799 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
801 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
802 contacts_record_set_str(nameHandle, _contacts_name.last, pCharArray.get());
804 if (value.IsEmpty() && IsEmptyName(nameHandle))
806 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
807 contacts_record_destroy(nameHandle, true);
812 if (!value.IsEmpty())
814 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
815 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
817 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
818 contacts_record_set_str(nameHandle, _contacts_name.last, pCharArray.get());
820 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
827 case CONTACT_PROPERTY_ID_NAME_SUFFIX:
829 contacts_record_h nameHandle = null;
830 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
833 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
835 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
836 contacts_record_set_str(nameHandle, _contacts_name.suffix, pCharArray.get());
838 if (value.IsEmpty() && IsEmptyName(nameHandle))
840 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
841 contacts_record_destroy(nameHandle, true);
847 if (!value.IsEmpty())
849 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
851 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
853 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
854 contacts_record_set_str(nameHandle, _contacts_name.suffix, pCharArray.get());
856 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
864 case CONTACT_PROPERTY_ID_NAME_PREFIX:
866 contacts_record_h nameHandle = null;
867 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
870 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
872 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
873 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
875 if (value.IsEmpty() && IsEmptyName(nameHandle))
877 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
878 contacts_record_destroy(nameHandle, true);
883 if (!value.IsEmpty())
885 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
886 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
888 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
889 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
891 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
899 case CONTACT_PROPERTY_ID_NICK_NAME:
901 contacts_record_h nicknameHandle = null;
902 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
905 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, 0, &nicknameHandle);
906 if (!value.IsEmpty())
908 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
909 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
915 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, 0, &nicknameHandle);
916 if (ret != CONTACTS_ERROR_NONE)
921 contacts_record_remove_child_record(__contactHandle, _contacts_contact.nickname, nicknameHandle);
922 contacts_record_destroy(nicknameHandle, true);
928 if (!value.IsEmpty())
930 ret = contacts_record_create(_contacts_nickname._uri, &nicknameHandle);
931 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
933 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
934 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
936 contacts_record_add_child_record(__contactHandle, _contacts_contact.nickname, nicknameHandle);
944 case CONTACT_PROPERTY_ID_JOB_TITLE:
946 contacts_record_h companyHandle = null;
947 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
950 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
952 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
953 contacts_record_set_str(companyHandle, _contacts_company.job_title, pCharArray.get());
955 if (value.IsEmpty() && IsEmptyCompany(companyHandle))
959 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
960 if (ret != CONTACTS_ERROR_NONE)
965 contacts_record_remove_child_record(__contactHandle, _contacts_contact.company, companyHandle);
966 contacts_record_destroy(companyHandle, true);
972 if (!value.IsEmpty())
974 ret = contacts_record_create(_contacts_company._uri, &companyHandle);
975 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
977 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
978 contacts_record_set_str(companyHandle, _contacts_company.job_title, pCharArray.get());
980 contacts_record_add_child_record(__contactHandle, _contacts_contact.company, companyHandle);
987 case CONTACT_PROPERTY_ID_COMPANY:
989 contacts_record_h companyHandle = null;
990 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
993 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
995 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(value));
996 contacts_record_set_str(companyHandle, _contacts_company.name, pCharArray.get());
998 if (value.IsEmpty() && IsEmptyCompany(companyHandle))
1002 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
1003 if (ret != CONTACTS_ERROR_NONE)
1008 contacts_record_remove_child_record(__contactHandle, _contacts_contact.company, companyHandle);
1009 contacts_record_destroy(companyHandle, true);
1016 if (!value.IsEmpty())
1018 ret = contacts_record_create(_contacts_company._uri, &companyHandle);
1019 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1021 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(value));
1022 contacts_record_set_str(companyHandle, _contacts_company.name, pCharArray.get());
1024 contacts_record_add_child_record(__contactHandle, _contacts_contact.company, companyHandle);
1031 case CONTACT_PROPERTY_ID_NOTE:
1033 contacts_record_h noteHandle = null;
1034 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
1037 if (!value.IsEmpty())
1039 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, 0, ¬eHandle);
1041 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(value));
1042 contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
1048 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, 0, ¬eHandle);
1049 if (ret != CONTACTS_ERROR_NONE)
1054 contacts_record_remove_child_record(__contactHandle, _contacts_contact.note, noteHandle);
1055 contacts_record_destroy(noteHandle, true);
1061 if (!value.IsEmpty())
1063 ret = contacts_record_create(_contacts_note._uri, ¬eHandle);
1064 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1066 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(value));
1067 contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
1069 contacts_record_add_child_record(__contactHandle, _contacts_contact.note, noteHandle);
1075 case CONTACT_PROPERTY_ID_RINGTONE:
1077 if (!value.IsEmpty() && !File::IsFileExist(value))
1079 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. The specified ringtone file does not exist.", GetErrorMessage(E_INVALID_ARG));
1080 return E_INVALID_ARG;
1083 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1085 contacts_record_set_str(__contactHandle, _contacts_contact.ringtone_path, pCharArray.get());
1089 case CONTACT_PROPERTY_ID_PHONETIC_FIRST_NAME:
1091 contacts_record_h phoneticNameHandle = null;
1092 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
1095 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
1097 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1098 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_first, pCharArray.get());
1100 if (value.IsEmpty() && IsEmptyName(phoneticNameHandle))
1102 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1103 contacts_record_destroy(phoneticNameHandle, true);
1108 if (!value.IsEmpty())
1110 ret = contacts_record_create(_contacts_name._uri, &phoneticNameHandle);
1111 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1113 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1114 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_first, pCharArray.get());
1116 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1121 case CONTACT_PROPERTY_ID_PHONETIC_LAST_NAME:
1123 contacts_record_h phoneticNameHandle = null;
1124 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
1127 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
1129 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1130 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_last, pCharArray.get());
1132 if (value.IsEmpty() && IsEmptyName(phoneticNameHandle))
1134 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1135 contacts_record_destroy(phoneticNameHandle, true);
1140 if (!value.IsEmpty())
1142 ret = contacts_record_create(_contacts_name._uri, &phoneticNameHandle);
1143 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1145 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1146 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_last, pCharArray.get());
1148 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1153 case CONTACT_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
1155 contacts_record_h phoneticNameHandle = null;
1156 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
1159 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
1161 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1162 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_middle, pCharArray.get());
1164 if (value.IsEmpty() && IsEmptyName(phoneticNameHandle))
1166 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1167 contacts_record_destroy(phoneticNameHandle, true);
1172 if (!value.IsEmpty())
1174 ret = contacts_record_create(_contacts_name._uri, &phoneticNameHandle);
1175 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1177 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1178 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_middle, pCharArray.get());
1180 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1185 case CONTACT_PROPERTY_ID_UID:
1187 if (!value.IsEmpty())
1189 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1190 contacts_record_set_str(__contactHandle, _contacts_contact.uid, pCharArray.get());
1194 contacts_record_set_str(__contactHandle, _contacts_contact.uid, null);
1199 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
1200 return E_INVALID_ARG;
1207 _ContactImpl::SetValue(ContactPropertyId id, const DateTime& value)
1209 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));
1211 unsigned int count = 0;
1213 int ret = CONTACTS_ERROR_NONE;
1217 case CONTACT_PROPERTY_ID_BIRTHDAY:
1221 contacts_record_h eventHandle = null;
1223 __CONVERT_DATETIME_TO_DATE(value, date);
1225 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
1228 for (unsigned int i = 0; i < count; i++)
1230 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
1231 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
1232 if (intValue == CONTACTS_EVENT_TYPE_BIRTH)
1234 contacts_record_set_int(eventHandle, _contacts_event.date, date);
1243 ret = contacts_record_create(_contacts_event._uri, &eventHandle);
1244 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1246 contacts_record_set_int(eventHandle, _contacts_event.type, CONTACTS_EVENT_TYPE_BIRTH);
1247 contacts_record_set_int(eventHandle, _contacts_event.date, date);
1249 contacts_record_add_child_record(__contactHandle, _contacts_contact.event, eventHandle);
1255 case CONTACT_PROPERTY_ID_ANNIVERSARY:
1259 contacts_record_h eventHandle = null;
1261 __CONVERT_DATETIME_TO_DATE(value, date);
1263 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
1266 for (unsigned int i = 0; i < count; i++)
1268 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
1269 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
1270 if (intValue == CONTACTS_EVENT_TYPE_ANNIVERSARY)
1272 contacts_record_set_int(eventHandle, _contacts_event.date, date);
1281 ret = contacts_record_create(_contacts_event._uri, &eventHandle);
1282 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1284 contacts_record_set_int(eventHandle, _contacts_event.type, CONTACTS_EVENT_TYPE_ANNIVERSARY);
1285 contacts_record_set_int(eventHandle, _contacts_event.date, date);
1287 contacts_record_add_child_record(__contactHandle, _contacts_contact.event, eventHandle);
1294 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
1295 return E_INVALID_ARG;
1302 _ContactImpl::AddPhoneNumber(const PhoneNumber& phoneNumber)
1304 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));
1305 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1309 contacts_record_h numberHandle = null;
1311 int ret = contacts_record_create(_contacts_number._uri, &numberHandle);
1312 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1314 __ContactsRecordHandle recordHandle(numberHandle);
1316 switch (_PhoneNumberImpl::GetInstance(phoneNumber)->GetType())
1318 case PHONENUMBER_TYPE_HOME:
1319 type = CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE;
1321 case PHONENUMBER_TYPE_WORK:
1322 type = CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE;
1324 case PHONENUMBER_TYPE_MOBILE:
1325 type = CONTACTS_NUMBER_TYPE_CELL;
1327 case PHONENUMBER_TYPE_HOME_FAX:
1328 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME;
1330 case PHONENUMBER_TYPE_WORK_FAX:
1331 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK;
1333 case PHONENUMBER_TYPE_PAGER:
1334 type = CONTACTS_NUMBER_TYPE_PAGER;
1336 case PHONENUMBER_TYPE_CUSTOM:
1337 type = CONTACTS_NUMBER_TYPE_CUSTOM;
1339 case PHONENUMBER_TYPE_ASSISTANT:
1340 type = CONTACTS_NUMBER_TYPE_ASSISTANT;
1342 case PHONENUMBER_TYPE_OTHER:
1344 type = CONTACTS_NUMBER_TYPE_OTHER;
1348 contacts_record_set_int(numberHandle, _contacts_number.type, type);
1350 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetLabel();
1352 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1353 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1355 contacts_record_set_str(numberHandle, _contacts_number.label, pCharArray.get());
1357 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetPhoneNumber();
1358 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1359 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1361 contacts_record_set_str(numberHandle, _contacts_number.number, pCharArray.get());
1363 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.number, numberHandle);
1364 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1366 recordHandle.Release();
1372 _ContactImpl::AddNickname(const String& nickname)
1374 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));
1375 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1376 contacts_record_h nicknameHandle = null;
1378 int ret = contacts_record_create(_contacts_nickname._uri, &nicknameHandle);
1379 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1381 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(nickname));
1382 SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1384 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
1386 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.nickname, nicknameHandle);
1387 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1393 _ContactImpl::AddNote(const String& note)
1395 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));
1396 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1397 contacts_record_h noteHandle = null;
1399 int ret = contacts_record_create(_contacts_note._uri, ¬eHandle);
1400 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1402 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(note));
1403 SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1405 contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
1407 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.note, noteHandle);
1408 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1414 _ContactImpl::AddEmail(const Email& email)
1416 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));
1417 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1421 contacts_record_h emailHandle = null;
1423 int ret = contacts_record_create(_contacts_email._uri, &emailHandle);
1424 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1426 __ContactsRecordHandle recordHandle(emailHandle);
1428 switch (_EmailImpl::GetInstance(email)->GetType())
1430 case EMAIL_TYPE_PERSONAL:
1431 type = CONTACTS_EMAIL_TYPE_HOME;
1433 case EMAIL_TYPE_WORK:
1434 type = CONTACTS_EMAIL_TYPE_WORK;
1436 case EMAIL_TYPE_CUSTOM:
1437 type = CONTACTS_EMAIL_TYPE_CUSTOM;
1439 case EMAIL_TYPE_MOBILE:
1440 type = CONTACTS_EMAIL_TYPE_MOBILE;
1442 case EMAIL_TYPE_OTHER:
1445 type = CONTACTS_EMAIL_TYPE_OTHER;
1449 contacts_record_set_int(emailHandle, _contacts_email.type, type);
1451 stringValue = _EmailImpl::GetInstance(email)->GetLabel();
1452 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1453 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1455 contacts_record_set_str(emailHandle, _contacts_email.label, pCharArray.get());
1457 stringValue = _EmailImpl::GetInstance(email)->GetEmail();
1458 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1459 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1461 contacts_record_set_str(emailHandle, _contacts_email.email, pCharArray.get());
1463 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.email, emailHandle);
1464 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1466 recordHandle.Release();
1472 _ContactImpl::AddUrl(const Url& url)
1474 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));
1475 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1479 contacts_record_h urlHandle = null;
1481 int ret = contacts_record_create(_contacts_url._uri, &urlHandle);
1482 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1484 __ContactsRecordHandle recordHandle(urlHandle);
1486 switch (_UrlImpl::GetInstance(url)->GetType())
1488 case URL_TYPE_PERSONAL:
1489 type = CONTACTS_URL_TYPE_HOME;
1492 type = CONTACTS_URL_TYPE_WORK;
1494 case URL_TYPE_CUSTOM:
1495 type = CONTACTS_URL_TYPE_CUSTOM;
1497 case URL_TYPE_OTHER:
1500 type = CONTACTS_URL_TYPE_OTHER;
1505 contacts_record_set_int(urlHandle, _contacts_url.type, type);
1508 stringValue = _UrlImpl::GetInstance(url)->GetLabel();
1509 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1510 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1512 contacts_record_set_str(urlHandle, _contacts_url.label, pCharArray.get());
1515 stringValue = _UrlImpl::GetInstance(url)->GetUrl();
1516 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1517 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1519 contacts_record_set_str(urlHandle, _contacts_url.url, pCharArray.get());
1521 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.url, urlHandle);
1522 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1524 recordHandle.Release();
1530 _ContactImpl::AddAddress(const Address& address)
1532 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));
1533 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1537 contacts_record_h addressHandle = null;
1539 int ret = contacts_record_create(_contacts_address._uri, &addressHandle);
1540 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1542 __ContactsRecordHandle recordHandle(addressHandle);
1544 switch (_AddressImpl::GetInstance(address)->GetType())
1546 case ADDRESS_TYPE_HOME:
1547 type = CONTACTS_ADDRESS_TYPE_HOME;
1549 case ADDRESS_TYPE_WORK:
1550 type = CONTACTS_ADDRESS_TYPE_WORK;
1552 case ADDRESS_TYPE_CUSTOM:
1553 type = CONTACTS_ADDRESS_TYPE_CUSTOM;
1555 case ADDRESS_TYPE_OTHER:
1558 type = CONTACTS_ADDRESS_TYPE_OTHER;
1562 contacts_record_set_int(addressHandle, _contacts_address.type, type);
1564 stringValue = _AddressImpl::GetInstance(address)->GetLabel();
1565 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1566 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1568 contacts_record_set_str(addressHandle, _contacts_address.label, pCharArray.get());
1570 stringValue = _AddressImpl::GetInstance(address)->GetCity();
1571 if (!stringValue.IsEmpty())
1573 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1574 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1576 contacts_record_set_str(addressHandle, _contacts_address.locality, pCharArray.get());
1580 stringValue = _AddressImpl::GetInstance(address)->GetCountry();
1581 if (!stringValue.IsEmpty())
1583 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1584 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1586 contacts_record_set_str(addressHandle, _contacts_address.country, pCharArray.get());
1589 stringValue = _AddressImpl::GetInstance(address)->GetExtended();
1590 if (!stringValue.IsEmpty())
1592 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1593 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1595 contacts_record_set_str(addressHandle, _contacts_address.extended, pCharArray.get());
1598 stringValue = _AddressImpl::GetInstance(address)->GetPostalCode();
1599 if (!stringValue.IsEmpty())
1601 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1602 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1604 contacts_record_set_str(addressHandle, _contacts_address.postal_code, pCharArray.get());
1607 stringValue = _AddressImpl::GetInstance(address)->GetPostOfficeBoxNumber();
1608 if (!stringValue.IsEmpty())
1610 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1611 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1613 contacts_record_set_str(addressHandle, _contacts_address.postbox, pCharArray.get());
1616 stringValue = _AddressImpl::GetInstance(address)->GetState();
1617 if (!stringValue.IsEmpty())
1619 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1620 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1622 contacts_record_set_str(addressHandle, _contacts_address.region, pCharArray.get());
1625 stringValue = _AddressImpl::GetInstance(address)->GetStreet();
1626 if (!stringValue.IsEmpty())
1628 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1629 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1631 contacts_record_set_str(addressHandle, _contacts_address.street, pCharArray.get());
1634 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.address, addressHandle);
1635 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1637 recordHandle.Release();
1643 _ContactImpl::AddImAddress(const ImAddress& imAddress)
1645 SysTryReturn(NID_SCL, !imAddress.GetImAddress().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%] Invalid argument is used. The imAddress is empty.", GetErrorMessage(E_INVALID_ARG));
1646 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1650 contacts_record_h messengerHandle = null;
1652 std::unique_ptr<char[]> pCharArray(null);
1654 int ret = contacts_record_create(_contacts_messenger._uri, &messengerHandle);
1655 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1657 __ContactsRecordHandle recordHandle(messengerHandle);
1659 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetServiceProviderName();
1661 if (stringValue == IM_ADDRESS_GOOGLE_TALK)
1663 type = CONTACTS_MESSENGER_TYPE_GOOGLE;
1665 else if (stringValue == IM_ADDRESS_MSN)
1667 type = CONTACTS_MESSENGER_TYPE_WLM;
1669 else if (stringValue == IM_ADDRESS_ICQ)
1671 type = CONTACTS_MESSENGER_TYPE_ICQ;
1673 else if (stringValue == IM_ADDRESS_AIM)
1675 type = CONTACTS_MESSENGER_TYPE_AIM;
1677 else if (stringValue == IM_ADDRESS_YAHOO)
1679 type = CONTACTS_MESSENGER_TYPE_YAHOO;
1681 else if (stringValue == IM_ADDRESS_QQ)
1683 type = CONTACTS_MESSENGER_TYPE_QQ;
1685 else if (stringValue == IM_ADDRESS_SKYPE)
1687 type = CONTACTS_MESSENGER_TYPE_SKYPE;
1689 else if (stringValue == IM_ADDRESS_JABBER)
1691 type = CONTACTS_MESSENGER_TYPE_JABBER;
1695 type = CONTACTS_MESSENGER_TYPE_CUSTOM;
1698 contacts_record_set_int(messengerHandle, _contacts_messenger.type, type);
1699 if (type == CONTACTS_MESSENGER_TYPE_CUSTOM)
1701 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1702 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1704 contacts_record_set_str(messengerHandle, _contacts_messenger.label, pCharArray.get());
1707 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetImAddress();
1708 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1709 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1711 contacts_record_set_str(messengerHandle, _contacts_messenger.im_id, pCharArray.get());
1713 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.messenger, messengerHandle);
1714 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1716 recordHandle.Release();
1721 _ContactImpl::AddRelationship(const Relationship& relationship)
1723 SysTryReturn(NID_SCL, !relationship.GetRelativeName().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%] Invalid argument is used. The relationship is empty.", GetErrorMessage(E_INVALID_ARG));
1724 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1727 contacts_record_h relationshipHandle = null;
1729 int ret = contacts_record_create(_contacts_relationship._uri, &relationshipHandle);
1730 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1732 __ContactsRecordHandle recordHandle(relationshipHandle);
1734 switch (relationship.GetType())
1736 case CONTACT_RELATIONSHIP_TYPE_ASSISTANT:
1737 intValue = CONTACTS_RELATIONSHIP_TYPE_ASSISTANT;
1739 case CONTACT_RELATIONSHIP_TYPE_BROTHER:
1740 intValue = CONTACTS_RELATIONSHIP_TYPE_BROTHER;
1742 case CONTACT_RELATIONSHIP_TYPE_CHILD:
1743 intValue = CONTACTS_RELATIONSHIP_TYPE_CHILD;
1745 case CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
1746 intValue = CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER;
1748 case CONTACT_RELATIONSHIP_TYPE_FATHER:
1749 intValue = CONTACTS_RELATIONSHIP_TYPE_FATHER;
1751 case CONTACT_RELATIONSHIP_TYPE_FRIEND:
1752 intValue = CONTACTS_RELATIONSHIP_TYPE_FRIEND;
1754 case CONTACT_RELATIONSHIP_TYPE_MANAGER:
1755 intValue = CONTACTS_RELATIONSHIP_TYPE_MANAGER;
1757 case CONTACT_RELATIONSHIP_TYPE_MOTHER:
1758 intValue = CONTACTS_RELATIONSHIP_TYPE_MOTHER;
1760 case CONTACT_RELATIONSHIP_TYPE_PARENT:
1761 intValue = CONTACTS_RELATIONSHIP_TYPE_PARENT;
1763 case CONTACT_RELATIONSHIP_TYPE_PARTNER:
1764 intValue = CONTACTS_RELATIONSHIP_TYPE_PARTNER;
1766 case CONTACT_RELATIONSHIP_TYPE_REFERRED_BY:
1767 intValue = CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY;
1769 case CONTACT_RELATIONSHIP_TYPE_RELATIVE:
1770 intValue = CONTACTS_RELATIONSHIP_TYPE_RELATIVE;
1772 case CONTACT_RELATIONSHIP_TYPE_SISTER:
1773 intValue = CONTACTS_RELATIONSHIP_TYPE_SISTER;
1775 case CONTACT_RELATIONSHIP_TYPE_SPOUSE:
1776 intValue = CONTACTS_RELATIONSHIP_TYPE_SPOUSE;
1778 case CONTACT_RELATIONSHIP_TYPE_CUSTOM:
1779 intValue = CONTACTS_RELATIONSHIP_TYPE_CUSTOM;
1782 intValue = CONTACTS_RELATIONSHIP_TYPE_OTHER;
1787 contacts_record_set_int(relationshipHandle, _contacts_relationship.type, intValue);
1790 String stringValue = relationship.GetLabel();
1791 if (!stringValue.IsEmpty())
1793 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1794 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1796 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, pCharArray.get());
1800 stringValue = relationship.GetRelativeName();
1801 if (!stringValue.IsEmpty())
1803 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1804 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1806 contacts_record_set_str(relationshipHandle, _contacts_relationship.name, pCharArray.get());
1809 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.relationship, relationshipHandle);
1810 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1812 recordHandle.Release();
1819 _ContactImpl::AddEvent(const ContactEvent& event)
1821 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1822 SysTryReturn(NID_SCL, _ContactEventImpl::GetInstance(event)->IsDateChanged(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The datetime of the event has not been set.", GetErrorMessage(E_INVALID_ARG));
1827 contacts_record_h eventHandle = null;
1829 int ret = contacts_record_create(_contacts_event._uri, &eventHandle);
1830 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1832 __ContactsRecordHandle recordHandle(eventHandle);
1834 switch (event.GetType())
1836 case CONTACT_EVENT_TYPE_ANNIVERSARY:
1837 type = CONTACTS_EVENT_TYPE_ANNIVERSARY;
1839 case CONTACT_EVENT_TYPE_BIRTHDAY:
1840 type = CONTACTS_EVENT_TYPE_BIRTH;
1842 case CONTACT_EVENT_TYPE_CUSTOM:
1843 type = CONTACTS_EVENT_TYPE_CUSTOM;
1845 case CONTACT_EVENT_TYPE_OTHER:
1848 type = CONTACTS_EVENT_TYPE_OTHER;
1853 contacts_record_set_int(eventHandle, _contacts_event.type, type);
1856 stringValue = event.GetLabel();
1857 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1858 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1860 contacts_record_set_str(eventHandle, _contacts_event.label, pCharArray.get());
1863 DateTime dateValue = event.GetDate();
1864 intValue = dateValue.GetYear()*10000 + dateValue.GetMonth()*100 + dateValue.GetDay();
1865 contacts_record_set_int(eventHandle, _contacts_event.date, intValue);
1867 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.event, eventHandle);
1868 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1870 recordHandle.Release();
1876 _ContactImpl::AddOrganization(const Organization& organization)
1878 SysTryReturn(NID_SCL
1879 , !organization.GetName().IsEmpty() ||
1880 !organization.GetJobTitle().IsEmpty() ||
1881 !organization.GetDepartment().IsEmpty() ||
1882 !organization.GetRole().IsEmpty() ||
1883 !organization.GetAgent().IsEmpty() ||
1884 !organization.GetDescription().IsEmpty() ||
1885 !organization.GetLocation().IsEmpty() ||
1886 !organization.GetPhoneticName().IsEmpty() ||
1887 !organization.GetLogoPath().IsEmpty()
1888 ,E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The organization is empty.", GetErrorMessage(E_INVALID_ARG));
1889 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1891 contacts_record_h organizationHandle = null;
1893 int ret = contacts_record_create(_contacts_company._uri, &organizationHandle);
1894 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1896 __ContactsRecordHandle recordHandle(organizationHandle);
1899 String stringValue = organization.GetName();
1900 if (!stringValue.IsEmpty())
1902 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1903 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1905 contacts_record_set_str(organizationHandle, _contacts_company.name, pCharArray.get());
1909 stringValue = organization.GetJobTitle();
1910 if (!stringValue.IsEmpty())
1912 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1913 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1915 contacts_record_set_str(organizationHandle, _contacts_company.job_title, pCharArray.get());
1919 stringValue = organization.GetDepartment();
1920 if (!stringValue.IsEmpty())
1922 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1923 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1925 contacts_record_set_str(organizationHandle, _contacts_company.department, pCharArray.get());
1929 stringValue = organization.GetRole();
1930 if (!stringValue.IsEmpty())
1932 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1933 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1935 contacts_record_set_str(organizationHandle, _contacts_company.role, pCharArray.get());
1939 stringValue = organization.GetAgent();
1940 if (!stringValue.IsEmpty())
1942 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1943 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1945 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, pCharArray.get());
1951 switch (organization.GetType())
1953 case ORGANIZATION_TYPE_WORK:
1954 type = CONTACTS_COMPANY_TYPE_WORK;
1956 case ORGANIZATION_TYPE_CUSTOM:
1957 type = CONTACTS_COMPANY_TYPE_CUSTOM;
1959 case ORGANIZATION_TYPE_OTHER:
1962 type = CONTACTS_COMPANY_TYPE_OTHER;
1966 contacts_record_set_int(organizationHandle, _contacts_company.type, type);
1969 stringValue = organization.GetLabel();
1970 if (!stringValue.IsEmpty())
1972 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1973 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1975 contacts_record_set_str(organizationHandle, _contacts_company.label, pCharArray.get());
1979 stringValue = organization.GetDescription();
1980 if (!stringValue.IsEmpty())
1982 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1983 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1985 contacts_record_set_str(organizationHandle, _contacts_company.description, pCharArray.get());
1989 stringValue = organization.GetLocation();
1990 if (!stringValue.IsEmpty())
1992 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1993 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1995 contacts_record_set_str(organizationHandle, _contacts_company.location, pCharArray.get());
1999 stringValue = organization.GetPhoneticName();
2000 if (!stringValue.IsEmpty())
2002 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2003 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2005 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, pCharArray.get());
2009 if (_OrganizationImpl::GetInstance(organization)->IsLogoPathChanged() == true)
2011 stringValue = organization.GetLogoPath();
2012 if (!stringValue.IsEmpty())
2014 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2015 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2017 contacts_record_set_str(organizationHandle, _contacts_company.logo, pCharArray.get());
2021 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.company, organizationHandle);
2022 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2024 recordHandle.Release();
2030 _ContactImpl::RemoveAt(ContactMultiPropertyId id, int index)
2032 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);
2034 unsigned int count = 0;
2035 contacts_record_h recordHandle = null;
2039 case CONTACT_MPROPERTY_ID_PHONE_NUMBERS:
2040 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
2041 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);
2043 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.number, index, &recordHandle);
2044 contacts_record_remove_child_record(__contactHandle, _contacts_contact.number, recordHandle);
2045 contacts_record_destroy(recordHandle, true);
2048 case CONTACT_MPROPERTY_ID_EMAILS:
2049 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &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 emails %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2052 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.email, index, &recordHandle);
2053 contacts_record_remove_child_record(__contactHandle, _contacts_contact.email, recordHandle);
2054 contacts_record_destroy(recordHandle, true);
2057 case CONTACT_MPROPERTY_ID_URLS:
2058 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
2059 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);
2061 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.url, index, &recordHandle);
2062 contacts_record_remove_child_record(__contactHandle, _contacts_contact.url, recordHandle);
2063 contacts_record_destroy(recordHandle, true);
2066 case CONTACT_MPROPERTY_ID_ADDRESSES:
2067 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
2068 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);
2070 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.address, index, &recordHandle);
2071 contacts_record_remove_child_record(__contactHandle, _contacts_contact.address, recordHandle);
2072 contacts_record_destroy(recordHandle, true);
2075 case CONTACT_MPROPERTY_ID_IMADDRESSES:
2076 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
2077 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);
2079 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.messenger, index, &recordHandle);
2080 contacts_record_remove_child_record(__contactHandle, _contacts_contact.messenger, recordHandle);
2081 contacts_record_destroy(recordHandle, true);
2084 case CONTACT_MPROPERTY_ID_ORGANIZATIONS:
2085 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
2086 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);
2088 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, index, &recordHandle);
2089 contacts_record_remove_child_record(__contactHandle, _contacts_contact.company, recordHandle);
2090 contacts_record_destroy(recordHandle, true);
2093 case CONTACT_MPROPERTY_ID_EVENTS:
2094 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
2095 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);
2097 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, index, &recordHandle);
2098 contacts_record_remove_child_record(__contactHandle, _contacts_contact.event, recordHandle);
2099 contacts_record_destroy(recordHandle, true);
2102 case CONTACT_MPROPERTY_ID_RELATIONSHIPS:
2103 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.relationship, &count);
2104 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);
2106 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.relationship, index, &recordHandle);
2107 contacts_record_remove_child_record(__contactHandle, _contacts_contact.relationship, recordHandle);
2108 contacts_record_destroy(recordHandle, true);
2111 case CONTACT_MPROPERTY_ID_NOTES:
2112 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
2113 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);
2115 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, index, &recordHandle);
2116 contacts_record_remove_child_record(__contactHandle, _contacts_contact.note, recordHandle);
2117 contacts_record_destroy(recordHandle, true);
2120 case CONTACT_MPROPERTY_ID_NICKNAMES:
2121 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
2122 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);
2124 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, index, &recordHandle);
2125 contacts_record_remove_child_record(__contactHandle, _contacts_contact.nickname, recordHandle);
2126 contacts_record_destroy(recordHandle, true);
2130 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
2131 return E_INVALID_ARG;
2138 _ContactImpl::GetValuesN(const ContactMultiPropertyId id)
2140 IList* pList = null;
2142 SetLastResult(E_SUCCESS);
2146 case CONTACT_MPROPERTY_ID_PHONE_NUMBERS:
2147 pList = GetPhoneNumbersN();
2150 case CONTACT_MPROPERTY_ID_EMAILS:
2151 pList = GetEmailsN();
2154 case CONTACT_MPROPERTY_ID_URLS:
2158 case CONTACT_MPROPERTY_ID_ADDRESSES:
2159 pList = GetAddressesN();
2162 case CONTACT_MPROPERTY_ID_IMADDRESSES:
2163 pList = GetImAddressesN();
2166 case CONTACT_MPROPERTY_ID_ORGANIZATIONS:
2167 pList = GetOrganizationsN();
2170 case CONTACT_MPROPERTY_ID_EVENTS:
2171 pList = GetEventsN();
2174 case CONTACT_MPROPERTY_ID_RELATIONSHIPS:
2175 pList = GetRelationshipsN();
2178 case CONTACT_MPROPERTY_ID_NOTES:
2179 pList = GetNotesN();
2182 case CONTACT_MPROPERTY_ID_NICKNAMES:
2183 pList = GetNicknamesN();
2186 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
2190 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2196 _ContactImpl::SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber)
2198 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);
2199 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));
2200 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2202 unsigned int count = 0;
2203 contacts_record_h recordHandle = null;
2208 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
2209 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);
2211 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.number, index, &recordHandle);
2214 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetLabel();
2216 switch (_PhoneNumberImpl::GetInstance(phoneNumber)->GetType())
2218 case PHONENUMBER_TYPE_HOME:
2219 type = CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE;
2221 case PHONENUMBER_TYPE_WORK:
2222 type = CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE;
2224 case PHONENUMBER_TYPE_MOBILE:
2225 type = CONTACTS_NUMBER_TYPE_CELL;
2227 case PHONENUMBER_TYPE_HOME_FAX:
2228 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME;
2230 case PHONENUMBER_TYPE_WORK_FAX:
2231 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK;
2233 case PHONENUMBER_TYPE_PAGER:
2234 type = CONTACTS_NUMBER_TYPE_PAGER;
2236 case PHONENUMBER_TYPE_CUSTOM:
2237 type = CONTACTS_NUMBER_TYPE_CUSTOM;
2239 case PHONENUMBER_TYPE_ASSISTANT:
2240 type = CONTACTS_NUMBER_TYPE_ASSISTANT;
2242 case PHONENUMBER_TYPE_OTHER:
2243 contacts_record_get_int(recordHandle, _contacts_number.type, &oriType);
2245 if (oriType == (CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE)
2246 || oriType == (CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE)
2247 || oriType == CONTACTS_NUMBER_TYPE_CELL
2248 || oriType == (CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME)
2249 || oriType == (CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK)
2250 || oriType == CONTACTS_NUMBER_TYPE_PAGER)
2252 type = CONTACTS_NUMBER_TYPE_OTHER;
2254 else if (oriType == CONTACTS_NUMBER_TYPE_CUSTOM)
2256 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
2258 char* pCharValue = null;
2260 contacts_record_get_str_p(recordHandle, _contacts_number.label, &pCharValue);
2262 stringValue = pCharValue;
2263 type = CONTACTS_NUMBER_TYPE_CUSTOM;
2268 type = CONTACTS_NUMBER_TYPE_OTHER;
2271 else if (oriType == CONTACTS_NUMBER_TYPE_ASSISTANT)
2273 if (_AppInfo::GetApiVersion() < _API_VERSION_2_1)
2275 type = CONTACTS_NUMBER_TYPE_ASSISTANT;
2279 type = CONTACTS_NUMBER_TYPE_OTHER;
2288 type = CONTACTS_NUMBER_TYPE_OTHER;
2293 contacts_record_set_int(recordHandle, _contacts_number.type, type);
2296 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2297 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2299 contacts_record_set_str(recordHandle, _contacts_number.label, pCharArray.get());
2302 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetPhoneNumber();
2303 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
2304 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2306 contacts_record_set_str(recordHandle, _contacts_number.number, pCharArray.get());
2312 _ContactImpl::SetNicknameAt(int index, const String& nickname)
2314 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);
2315 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));
2316 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2318 unsigned int count = 0;
2319 contacts_record_h nicknameHandle = null;
2321 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
2322 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);
2324 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, index, &nicknameHandle);
2326 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(nickname));
2327 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2329 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
2335 _ContactImpl::SetNoteAt(int index, const String& note)
2337 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);
2338 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));
2339 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2341 unsigned int count = 0;
2342 contacts_record_h noteHandle = null;
2344 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
2345 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);
2347 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, index, ¬eHandle);
2349 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(note));
2350 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2352 contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
2358 _ContactImpl::SetOrganizationAt(int index, const Organization& organization)
2360 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);
2361 SysTryReturn(NID_SCL
2362 , !organization.GetName().IsEmpty() ||
2363 !organization.GetJobTitle().IsEmpty() ||
2364 !organization.GetDepartment().IsEmpty() ||
2365 !organization.GetRole().IsEmpty() ||
2366 !organization.GetAgent().IsEmpty() ||
2367 !organization.GetDescription().IsEmpty() ||
2368 !organization.GetLocation().IsEmpty() ||
2369 !organization.GetPhoneticName().IsEmpty() ||
2370 !organization.GetLogoPath().IsEmpty()
2371 ,E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The organization is empty.", GetErrorMessage(E_INVALID_ARG));
2372 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2374 unsigned int count = 0;
2375 contacts_record_h organizationHandle = null;
2377 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
2378 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);
2381 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, index, &organizationHandle);
2384 String stringValue = organization.GetName();
2385 if (!stringValue.IsEmpty())
2387 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2388 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2390 contacts_record_set_str(organizationHandle, _contacts_company.name, pCharArray.get());
2394 contacts_record_set_str(organizationHandle, _contacts_company.name, null);
2398 stringValue = organization.GetJobTitle();
2399 if (!stringValue.IsEmpty())
2401 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2402 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2404 contacts_record_set_str(organizationHandle, _contacts_company.job_title, pCharArray.get());
2408 contacts_record_set_str(organizationHandle, _contacts_company.job_title, null);
2412 stringValue = organization.GetDepartment();
2413 if (!stringValue.IsEmpty())
2415 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2416 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2418 contacts_record_set_str(organizationHandle, _contacts_company.department, pCharArray.get());
2422 contacts_record_set_str(organizationHandle, _contacts_company.department, null);
2426 stringValue = organization.GetRole();
2427 if (!stringValue.IsEmpty())
2429 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2430 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2432 contacts_record_set_str(organizationHandle, _contacts_company.role, pCharArray.get());
2436 contacts_record_set_str(organizationHandle, _contacts_company.role, null);
2440 stringValue = organization.GetAgent();
2441 if (!stringValue.IsEmpty())
2443 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2444 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2446 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, pCharArray.get());
2450 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, null);
2456 switch (organization.GetType())
2458 case ORGANIZATION_TYPE_WORK:
2459 type = CONTACTS_COMPANY_TYPE_WORK;
2461 case ORGANIZATION_TYPE_CUSTOM:
2462 type = CONTACTS_COMPANY_TYPE_CUSTOM;
2464 case ORGANIZATION_TYPE_OTHER:
2467 type = CONTACTS_COMPANY_TYPE_OTHER;
2471 contacts_record_set_int(organizationHandle, _contacts_company.type, type);
2474 stringValue = organization.GetLabel();
2475 if (!stringValue.IsEmpty())
2477 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2478 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2480 contacts_record_set_str(organizationHandle, _contacts_company.label, pCharArray.get());
2484 contacts_record_set_str(organizationHandle, _contacts_company.label, null);
2488 stringValue = organization.GetDescription();
2489 if (!stringValue.IsEmpty())
2491 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2492 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2494 contacts_record_set_str(organizationHandle, _contacts_company.description, pCharArray.get());
2498 contacts_record_set_str(organizationHandle, _contacts_company.description, null);
2502 stringValue = organization.GetLocation();
2503 if (!stringValue.IsEmpty())
2505 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2506 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2508 contacts_record_set_str(organizationHandle, _contacts_company.location, pCharArray.get());
2512 contacts_record_set_str(organizationHandle, _contacts_company.location, null);
2516 stringValue = organization.GetPhoneticName();
2517 if (!stringValue.IsEmpty())
2519 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2520 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2522 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, pCharArray.get());
2526 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, null);
2530 if (_OrganizationImpl::GetInstance(organization)->IsLogoPathChanged() == true)
2532 stringValue = organization.GetLogoPath();
2533 if (!stringValue.IsEmpty())
2535 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2536 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2538 contacts_record_set_str(organizationHandle, _contacts_company.logo, pCharArray.get());
2542 contacts_record_set_str(organizationHandle, _contacts_company.logo, null);
2550 _ContactImpl::SetEventAt(int index, const ContactEvent& event)
2552 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);
2553 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2554 SysTryReturn(NID_SCL, _ContactEventImpl::GetInstance(event)->IsDateChanged(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The datetime of the event has not been set.", GetErrorMessage(E_INVALID_ARG));
2558 unsigned int count = 0;
2560 contacts_record_h eventHandle = null;
2562 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
2563 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);
2565 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, index, &eventHandle);
2567 switch (event.GetType())
2569 case CONTACT_EVENT_TYPE_ANNIVERSARY:
2570 type = CONTACTS_EVENT_TYPE_ANNIVERSARY;
2572 case CONTACT_EVENT_TYPE_BIRTHDAY:
2573 type = CONTACTS_EVENT_TYPE_BIRTH;
2575 case CONTACT_EVENT_TYPE_CUSTOM:
2576 type = CONTACTS_EVENT_TYPE_CUSTOM;
2578 case CONTACT_EVENT_TYPE_OTHER:
2581 type = CONTACTS_EVENT_TYPE_OTHER;
2586 contacts_record_set_int(eventHandle, _contacts_event.type, type);
2589 stringValue = event.GetLabel();
2591 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2592 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2594 contacts_record_set_str(eventHandle, _contacts_event.label, pCharArray.get());
2597 DateTime dateValue = event.GetDate();
2598 intValue = dateValue.GetYear()*10000 + dateValue.GetMonth()*100 + dateValue.GetDay();
2599 contacts_record_set_int(eventHandle, _contacts_event.date, intValue);
2605 _ContactImpl::SetRelationshipAt(int index, const Relationship& relationship)
2607 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);
2608 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));
2609 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2612 unsigned int count = 0;
2613 contacts_record_h relationshipHandle = null;
2615 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.relationship, &count);
2616 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);
2618 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.relationship, index, &relationshipHandle);
2620 switch (relationship.GetType())
2622 case CONTACT_RELATIONSHIP_TYPE_ASSISTANT:
2623 intValue = CONTACTS_RELATIONSHIP_TYPE_ASSISTANT;
2625 case CONTACT_RELATIONSHIP_TYPE_BROTHER:
2626 intValue = CONTACTS_RELATIONSHIP_TYPE_BROTHER;
2628 case CONTACT_RELATIONSHIP_TYPE_CHILD:
2629 intValue = CONTACTS_RELATIONSHIP_TYPE_CHILD;
2631 case CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
2632 intValue = CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER;
2634 case CONTACT_RELATIONSHIP_TYPE_FATHER:
2635 intValue = CONTACTS_RELATIONSHIP_TYPE_FATHER;
2637 case CONTACT_RELATIONSHIP_TYPE_FRIEND:
2638 intValue = CONTACTS_RELATIONSHIP_TYPE_FRIEND;
2640 case CONTACT_RELATIONSHIP_TYPE_MANAGER:
2641 intValue = CONTACTS_RELATIONSHIP_TYPE_MANAGER;
2643 case CONTACT_RELATIONSHIP_TYPE_MOTHER:
2644 intValue = CONTACTS_RELATIONSHIP_TYPE_MOTHER;
2646 case CONTACT_RELATIONSHIP_TYPE_PARENT:
2647 intValue = CONTACTS_RELATIONSHIP_TYPE_PARENT;
2649 case CONTACT_RELATIONSHIP_TYPE_PARTNER:
2650 intValue = CONTACTS_RELATIONSHIP_TYPE_PARTNER;
2652 case CONTACT_RELATIONSHIP_TYPE_REFERRED_BY:
2653 intValue = CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY;
2655 case CONTACT_RELATIONSHIP_TYPE_RELATIVE:
2656 intValue = CONTACTS_RELATIONSHIP_TYPE_RELATIVE;
2658 case CONTACT_RELATIONSHIP_TYPE_SISTER:
2659 intValue = CONTACTS_RELATIONSHIP_TYPE_SISTER;
2661 case CONTACT_RELATIONSHIP_TYPE_SPOUSE:
2662 intValue = CONTACTS_RELATIONSHIP_TYPE_SPOUSE;
2664 case CONTACT_RELATIONSHIP_TYPE_CUSTOM:
2665 intValue = CONTACTS_RELATIONSHIP_TYPE_CUSTOM;
2668 intValue = CONTACTS_RELATIONSHIP_TYPE_OTHER;
2673 contacts_record_set_int(relationshipHandle, _contacts_relationship.type, intValue);
2676 String stringValue = relationship.GetLabel();
2677 if (!stringValue.IsEmpty())
2679 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2680 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2682 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, pCharArray.get());
2686 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, null);
2690 stringValue = relationship.GetRelativeName();
2691 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2692 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2694 contacts_record_set_str(relationshipHandle, _contacts_relationship.name, pCharArray.get());
2700 _ContactImpl::SetEmailAt(int index, const Email& email)
2702 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);
2703 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));
2704 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2706 unsigned int count = 0;
2707 contacts_record_h emailHandle = null;
2712 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
2713 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);
2715 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.email, index, &emailHandle);
2717 stringValue = _EmailImpl::GetInstance(email)->GetLabel();
2719 switch (_EmailImpl::GetInstance(email)->GetType())
2721 case EMAIL_TYPE_PERSONAL:
2722 type = CONTACTS_EMAIL_TYPE_HOME;
2724 case EMAIL_TYPE_WORK:
2725 type = CONTACTS_EMAIL_TYPE_WORK;
2727 case EMAIL_TYPE_CUSTOM:
2728 type = CONTACTS_EMAIL_TYPE_CUSTOM;
2730 case EMAIL_TYPE_MOBILE:
2731 type = CONTACTS_EMAIL_TYPE_MOBILE;
2733 case EMAIL_TYPE_OTHER:
2734 contacts_record_get_int(emailHandle, _contacts_email.type, &oriType);
2735 if (oriType == CONTACTS_EMAIL_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
2737 char* pCharValue = null;
2739 contacts_record_get_str_p(emailHandle, _contacts_email.label, &pCharValue);
2741 stringValue = pCharValue;
2742 type = CONTACTS_EMAIL_TYPE_CUSTOM;
2744 else if (oriType == CONTACTS_EMAIL_TYPE_MOBILE && _AppInfo::GetApiVersion() < _API_VERSION_2_1)
2746 type = CONTACTS_EMAIL_TYPE_MOBILE;
2750 type = CONTACTS_EMAIL_TYPE_OTHER;
2754 type = CONTACTS_EMAIL_TYPE_OTHER;
2759 contacts_record_set_int(emailHandle, _contacts_email.type, type);
2762 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2763 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2765 contacts_record_set_str(emailHandle, _contacts_email.label, pCharArray.get());
2768 stringValue = _EmailImpl::GetInstance(email)->GetEmail();
2769 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
2770 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2772 contacts_record_set_str(emailHandle, _contacts_email.email, pCharArray.get());
2778 _ContactImpl::SetUrlAt(int index, const Url& url)
2780 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);
2781 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));
2782 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2784 unsigned int count = 0;
2785 contacts_record_h recordHandle = null;
2790 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
2791 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);
2793 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.url, index, &recordHandle);
2796 stringValue = _UrlImpl::GetInstance(url)->GetLabel();
2798 switch (_UrlImpl::GetInstance(url)->GetType())
2800 case URL_TYPE_PERSONAL:
2801 type = CONTACTS_URL_TYPE_HOME;
2804 type = CONTACTS_URL_TYPE_WORK;
2806 case URL_TYPE_CUSTOM:
2807 type = CONTACTS_URL_TYPE_CUSTOM;
2809 case URL_TYPE_OTHER:
2810 contacts_record_get_int(recordHandle, _contacts_url.type, &oriType);
2812 if (oriType == CONTACTS_URL_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
2814 char* pCharValue = null;
2816 contacts_record_get_str_p(recordHandle, _contacts_url.label, &pCharValue);
2818 stringValue = pCharValue;
2819 type = CONTACTS_URL_TYPE_CUSTOM;
2823 type = CONTACTS_URL_TYPE_OTHER;
2827 type = CONTACTS_URL_TYPE_OTHER;
2832 contacts_record_set_int(recordHandle, _contacts_url.type, type);
2835 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2836 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2838 contacts_record_set_str(recordHandle, _contacts_url.label, pCharArray.get());
2841 stringValue = _UrlImpl::GetInstance(url)->GetUrl();
2842 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
2843 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2845 contacts_record_set_str(recordHandle, _contacts_url.url, pCharArray.get());
2851 _ContactImpl::SetAddressAt(int index, const Address& address)
2853 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);
2854 SysTryReturn(NID_SCL,
2855 !address.GetCity().IsEmpty() ||
2856 !address.GetCountry().IsEmpty() ||
2857 !address.GetExtended().IsEmpty() ||
2858 !address.GetPostalCode().IsEmpty() ||
2859 !address.GetPostOfficeBoxNumber().IsEmpty() ||
2860 !address.GetState().IsEmpty() ||
2861 !address.GetStreet().IsEmpty(),
2862 E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The address is empty.", GetErrorMessage(E_INVALID_ARG));
2863 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2865 unsigned int count = 0;
2866 contacts_record_h recordHandle = null;
2871 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
2872 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);
2874 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.address, index, &recordHandle);
2876 stringValue = _AddressImpl::GetInstance(address)->GetLabel();
2878 switch (_AddressImpl::GetInstance(address)->GetType())
2880 case ADDRESS_TYPE_HOME:
2881 type = CONTACTS_ADDRESS_TYPE_HOME;
2883 case ADDRESS_TYPE_WORK:
2884 type = CONTACTS_ADDRESS_TYPE_WORK;
2886 case ADDRESS_TYPE_CUSTOM:
2887 type = CONTACTS_ADDRESS_TYPE_CUSTOM;
2889 case ADDRESS_TYPE_OTHER:
2890 contacts_record_get_int(recordHandle, _contacts_address.type, &oriType);
2892 if (oriType == CONTACTS_ADDRESS_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
2894 char* pCharValue = null;
2896 contacts_record_get_str_p(recordHandle, _contacts_address.label, &pCharValue);
2898 stringValue = pCharValue;
2899 type = CONTACTS_ADDRESS_TYPE_CUSTOM;
2903 type = CONTACTS_ADDRESS_TYPE_OTHER;
2907 type = CONTACTS_ADDRESS_TYPE_OTHER;
2912 contacts_record_set_int(recordHandle, _contacts_address.type, type);
2915 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2916 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2918 contacts_record_set_str(recordHandle, _contacts_address.label, pCharArray.get());
2921 stringValue = _AddressImpl::GetInstance(address)->GetCity();
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.locality, pCharArray.get());
2931 contacts_record_set_str(recordHandle, _contacts_address.locality, null);
2934 stringValue = _AddressImpl::GetInstance(address)->GetCountry();
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.country, pCharArray.get());
2944 contacts_record_set_str(recordHandle, _contacts_address.country, null);
2947 stringValue = _AddressImpl::GetInstance(address)->GetExtended();
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.extended, pCharArray.get());
2957 contacts_record_set_str(recordHandle, _contacts_address.extended, null);
2960 stringValue = _AddressImpl::GetInstance(address)->GetPostalCode();
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.postal_code, pCharArray.get());
2970 contacts_record_set_str(recordHandle, _contacts_address.postal_code, null);
2973 stringValue = _AddressImpl::GetInstance(address)->GetPostOfficeBoxNumber();
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.postbox, pCharArray.get());
2983 contacts_record_set_str(recordHandle, _contacts_address.postbox, null);
2986 stringValue = _AddressImpl::GetInstance(address)->GetState();
2987 if (!stringValue.IsEmpty())
2989 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2990 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2992 contacts_record_set_str(recordHandle, _contacts_address.region, pCharArray.get());
2996 contacts_record_set_str(recordHandle, _contacts_address.region, null);
2999 stringValue = _AddressImpl::GetInstance(address)->GetStreet();
3000 if (!stringValue.IsEmpty())
3002 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
3003 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3005 contacts_record_set_str(recordHandle, _contacts_address.street, pCharArray.get());
3009 contacts_record_set_str(recordHandle, _contacts_address.street, null);
3016 _ContactImpl::SetImAddressAt(int index, const ImAddress& imAddress)
3018 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);
3019 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));
3020 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3022 unsigned int count = 0;
3023 contacts_record_h messengerHandle = null;
3026 std::unique_ptr<char[]> pCharArray(null);
3028 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
3029 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);
3031 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.messenger, index, &messengerHandle);
3033 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetServiceProviderName();
3035 if (stringValue == IM_ADDRESS_GOOGLE_TALK)
3037 type = CONTACTS_MESSENGER_TYPE_GOOGLE;
3039 else if (stringValue == IM_ADDRESS_MSN)
3041 type = CONTACTS_MESSENGER_TYPE_WLM;
3043 else if (stringValue == IM_ADDRESS_ICQ)
3045 type = CONTACTS_MESSENGER_TYPE_ICQ;
3047 else if (stringValue == IM_ADDRESS_AIM)
3049 type = CONTACTS_MESSENGER_TYPE_AIM;
3051 else if (stringValue == IM_ADDRESS_YAHOO)
3053 type = CONTACTS_MESSENGER_TYPE_YAHOO;
3055 else if (stringValue == IM_ADDRESS_QQ)
3057 type = CONTACTS_MESSENGER_TYPE_QQ;
3059 else if (stringValue == IM_ADDRESS_SKYPE)
3061 type = CONTACTS_MESSENGER_TYPE_SKYPE;
3063 else if (stringValue == IM_ADDRESS_JABBER)
3065 type = CONTACTS_MESSENGER_TYPE_JABBER;
3069 type = CONTACTS_MESSENGER_TYPE_CUSTOM;
3072 contacts_record_set_int(messengerHandle, _contacts_messenger.type, type);
3073 if (type == CONTACTS_MESSENGER_TYPE_CUSTOM)
3075 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
3076 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3078 contacts_record_set_str(messengerHandle, _contacts_messenger.label, pCharArray.get());
3081 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetImAddress();
3082 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
3083 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3085 contacts_record_set_str(messengerHandle, _contacts_messenger.im_id, pCharArray.get());
3091 _ContactImpl::GetMaxLength(ContactPropertyId id)
3095 case CONTACT_PROPERTY_ID_FIRST_NAME:
3097 case CONTACT_PROPERTY_ID_LAST_NAME:
3099 case CONTACT_PROPERTY_ID_DISPLAY_NAME:
3101 case CONTACT_PROPERTY_ID_NICK_NAME:
3103 case CONTACT_PROPERTY_ID_MIDDLE_NAME:
3104 return MAX_CONTACT_NAME_LENGTH;
3106 case CONTACT_PROPERTY_ID_THUMBNAIL:
3109 case CONTACT_PROPERTY_ID_JOB_TITLE:
3110 return MAX_CONTACT_JOB_TITLE_LENGTH;
3112 case CONTACT_PROPERTY_ID_COMPANY:
3113 return MAX_CONTACT_COMPANY_LENGTH;
3115 case CONTACT_PROPERTY_ID_NOTE:
3116 return MAX_CONTACT_NOTE_LENGTH;
3118 case CONTACT_PROPERTY_ID_RINGTONE:
3121 case CONTACT_PROPERTY_ID_PHONETIC_FIRST_NAME:
3123 case CONTACT_PROPERTY_ID_PHONETIC_LAST_NAME:
3125 case CONTACT_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
3126 return MAX_CONTACT_NAME_LENGTH;
3134 _ContactImpl::GetOrganizationsN(void) const
3136 result r = E_SUCCESS;
3137 contacts_record_h organizationHandle = null;
3138 int ret = CONTACTS_ERROR_NONE;
3139 char* pCharValue = null;
3141 unsigned int count = 0;
3142 std::unique_ptr<Organization> pOrganization(null);
3144 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3145 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3147 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
3149 r = pList->Construct(count);
3150 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3152 for (unsigned int i = 0; i < count; i++)
3154 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, i, &organizationHandle);
3155 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
3157 pOrganization.reset(new (std::nothrow) Organization());
3158 SysTryReturn(NID_SCL, pOrganization != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3161 contacts_record_get_str_p(organizationHandle, _contacts_company.name, &pCharValue);
3162 pOrganization->SetName(pCharValue);
3165 contacts_record_get_str_p(organizationHandle, _contacts_company.job_title, &pCharValue);
3166 pOrganization->SetJobTitle(pCharValue);
3169 contacts_record_get_str_p(organizationHandle, _contacts_company.department, &pCharValue);
3170 pOrganization->SetDepartment(pCharValue);
3173 contacts_record_get_str_p(organizationHandle, _contacts_company.role, &pCharValue);
3174 pOrganization->SetRole(pCharValue);
3177 contacts_record_get_str_p(organizationHandle, _contacts_company.assistant_name, &pCharValue);
3178 pOrganization->SetAgent(pCharValue);
3181 contacts_record_get_int(organizationHandle, _contacts_company.type, &intValue);
3184 case CONTACTS_COMPANY_TYPE_WORK:
3185 pOrganization->SetType(ORGANIZATION_TYPE_WORK);
3187 case CONTACTS_COMPANY_TYPE_CUSTOM:
3188 pOrganization->SetType(ORGANIZATION_TYPE_CUSTOM);
3190 case CONTACTS_COMPANY_TYPE_OTHER:
3193 pOrganization->SetType(ORGANIZATION_TYPE_OTHER);
3198 contacts_record_get_str_p(organizationHandle, _contacts_company.label, &pCharValue);
3199 pOrganization->SetLabel(pCharValue);
3202 contacts_record_get_str_p(organizationHandle, _contacts_company.description, &pCharValue);
3203 pOrganization->SetDescription(pCharValue);
3206 contacts_record_get_str_p(organizationHandle, _contacts_company.location, &pCharValue);
3207 pOrganization->SetLocation(pCharValue);
3210 contacts_record_get_str_p(organizationHandle, _contacts_company.phonetic_name, &pCharValue);
3211 pOrganization->SetPhoneticName(pCharValue);
3214 contacts_record_get_str_p(organizationHandle, _contacts_company.logo, &pCharValue);
3215 _OrganizationImpl::GetInstance(*pOrganization)->SetLogoPath(pCharValue);
3217 r = pList->Add(*pOrganization);
3218 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3220 pOrganization.release();
3223 return pList.release();
3227 _ContactImpl::GetRelationshipsN(void) const
3229 result r = E_SUCCESS;
3230 contacts_record_h relationshipHandle = null;
3231 int ret = CONTACTS_ERROR_NONE;
3233 char* pCharValue = null;
3234 unsigned int count = 0;
3235 std::unique_ptr<Relationship> pRelationship(null);
3237 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3238 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3240 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.relationship, &count);
3242 r = pList->Construct(count);
3243 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3245 for (unsigned int i = 0; i < count; i++)
3247 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.relationship, i, &relationshipHandle);
3248 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
3250 pRelationship.reset(new (std::nothrow) Relationship());
3251 SysTryReturn(NID_SCL, pRelationship != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3254 contacts_record_get_int(relationshipHandle, _contacts_relationship.type, &intValue);
3257 case CONTACTS_RELATIONSHIP_TYPE_ASSISTANT:
3258 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_ASSISTANT);
3260 case CONTACTS_RELATIONSHIP_TYPE_BROTHER:
3261 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_BROTHER);
3263 case CONTACTS_RELATIONSHIP_TYPE_CHILD:
3264 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_CHILD);
3266 case CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
3267 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER);
3269 case CONTACTS_RELATIONSHIP_TYPE_FATHER:
3270 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_FATHER);
3272 case CONTACTS_RELATIONSHIP_TYPE_FRIEND:
3273 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_FRIEND);
3275 case CONTACTS_RELATIONSHIP_TYPE_MANAGER:
3276 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_MANAGER);
3278 case CONTACTS_RELATIONSHIP_TYPE_MOTHER:
3279 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_MOTHER);
3281 case CONTACTS_RELATIONSHIP_TYPE_PARENT:
3282 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_PARENT);
3284 case CONTACTS_RELATIONSHIP_TYPE_PARTNER:
3285 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_PARTNER);
3287 case CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY:
3288 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_REFERRED_BY);
3290 case CONTACTS_RELATIONSHIP_TYPE_RELATIVE:
3291 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_RELATIVE);
3293 case CONTACTS_RELATIONSHIP_TYPE_SISTER:
3294 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_SISTER);
3296 case CONTACTS_RELATIONSHIP_TYPE_SPOUSE:
3297 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_SPOUSE);
3299 case CONTACTS_RELATIONSHIP_TYPE_CUSTOM:
3302 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_CUSTOM);
3307 contacts_record_get_str_p(relationshipHandle, _contacts_relationship.label, &pCharValue);
3308 pRelationship->SetLabel(pCharValue);
3311 contacts_record_get_str_p(relationshipHandle, _contacts_relationship.name, &pCharValue);
3312 pRelationship->SetRelativeName(pCharValue);
3314 r = pList->Add(*pRelationship);
3315 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3317 pRelationship.release();
3320 return pList.release();
3324 _ContactImpl::GetEventsN(void) const
3326 result r = E_SUCCESS;
3327 char* pCharValue = null;
3329 unsigned int count = 0;
3330 contacts_record_h eventHandle = null;
3331 std::unique_ptr<ContactEvent> pEvent(null);
3333 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3334 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3336 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
3338 r = pList->Construct(count);
3339 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3341 for (unsigned int i = 0; i < count; i++)
3343 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
3345 pEvent.reset(new (std::nothrow) ContactEvent());
3346 SysTryReturn(NID_SCL, pEvent != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3349 contacts_record_get_str_p(eventHandle, _contacts_event.label, &pCharValue);
3350 pEvent->SetLabel(pCharValue);
3353 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
3356 case CONTACTS_EVENT_TYPE_BIRTH:
3357 pEvent->SetType(CONTACT_EVENT_TYPE_BIRTHDAY);
3359 case CONTACTS_EVENT_TYPE_ANNIVERSARY:
3360 pEvent->SetType(CONTACT_EVENT_TYPE_ANNIVERSARY);
3362 case CONTACTS_URL_TYPE_CUSTOM:
3363 pEvent->SetType(CONTACT_EVENT_TYPE_CUSTOM);
3366 pEvent->SetType(CONTACT_EVENT_TYPE_OTHER);
3372 contacts_record_get_int(eventHandle, _contacts_event.date, &intValue);
3373 __CONVERT_DATE_TO_DATETIME(intValue, dateTime);
3374 pEvent->SetDate(dateTime);
3376 pList->Add(*pEvent);
3377 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3382 return pList.release();
3386 _ContactImpl::GetNotesN(void) const
3388 result r = E_SUCCESS;
3389 char* pCharValue = null;
3390 unsigned int count = 0;
3391 contacts_record_h noteHandle = null;
3392 std::unique_ptr<String> pNote(null);
3394 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3395 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3397 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
3399 r = pList->Construct(count);
3400 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3402 for (unsigned int i = 0; i < count; i++)
3404 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, i, ¬eHandle);
3406 contacts_record_get_str_p(noteHandle, _contacts_note.note, &pCharValue);
3408 pNote.reset(new (std::nothrow) String(pCharValue));
3409 SysTryReturn(NID_SCL, pNote != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3412 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3417 return pList.release();
3421 _ContactImpl::GetNicknamesN(void) const
3423 result r = E_SUCCESS;
3424 char* pCharValue = null;
3425 unsigned int count = 0;
3426 contacts_record_h nicknameHandle = null;
3427 std::unique_ptr<String> pNickname(null);
3429 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3430 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3432 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
3434 r = pList->Construct(count);
3435 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3437 for (unsigned int i = 0; i < count; i++)
3439 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, i, &nicknameHandle);
3441 contacts_record_get_str_p(nicknameHandle, _contacts_nickname.name, &pCharValue);
3443 pNickname.reset(new (std::nothrow) String(pCharValue));
3444 SysTryReturn(NID_SCL, pNickname != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3446 pList->Add(*pNickname);
3447 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3449 pNickname.release();
3452 return pList.release();
3456 _ContactImpl::GetPhoneNumbersN(void) const
3458 result r = E_SUCCESS;
3459 unsigned int count = 0;
3460 contacts_record_h numberHandle = null;
3462 char* pCharValue = null;
3463 PhoneNumberType type = PHONENUMBER_TYPE_HOME;
3464 std::unique_ptr<PhoneNumber> pPhoneNumber(null);
3466 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3467 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3470 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
3472 contacts_record_get_int(__contactHandle, _contacts_contact.id, &intValue);
3474 r = pList->Construct(count);
3475 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3477 for (unsigned int i = 0; i < count; i++)
3479 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.number, i, &numberHandle);
3481 pPhoneNumber.reset(new (std::nothrow) PhoneNumber());
3482 SysTryReturn(NID_SCL, pPhoneNumber != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3484 contacts_record_get_int(numberHandle, _contacts_number.id, &intValue);
3485 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetRecordId(intValue);
3487 contacts_record_get_str_p(numberHandle, _contacts_number.label, &pCharValue);
3488 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetLabel(pCharValue);
3490 contacts_record_get_int(numberHandle, _contacts_number.type, &intValue);
3494 case CONTACTS_NUMBER_TYPE_HOME:
3496 case CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE:
3497 type = PHONENUMBER_TYPE_HOME;
3499 case CONTACTS_NUMBER_TYPE_WORK:
3501 case CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE:
3502 type = PHONENUMBER_TYPE_WORK;
3504 case CONTACTS_NUMBER_TYPE_CELL:
3505 type = PHONENUMBER_TYPE_MOBILE;
3507 case CONTACTS_NUMBER_TYPE_FAX:
3509 case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME:
3510 type = PHONENUMBER_TYPE_HOME_FAX;
3512 case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK:
3513 type = PHONENUMBER_TYPE_WORK_FAX;
3515 case CONTACTS_NUMBER_TYPE_PAGER:
3516 type = PHONENUMBER_TYPE_PAGER;
3518 case CONTACTS_NUMBER_TYPE_CUSTOM:
3519 type = PHONENUMBER_TYPE_CUSTOM;
3521 case CONTACTS_NUMBER_TYPE_ASSISTANT:
3522 if (_AppInfo::GetApiVersion() < _API_VERSION_2_1)
3524 type = PHONENUMBER_TYPE_OTHER;
3528 type = PHONENUMBER_TYPE_ASSISTANT;
3531 case CONTACTS_NUMBER_TYPE_OTHER:
3532 type = PHONENUMBER_TYPE_OTHER;
3535 if (intValue & CONTACTS_NUMBER_TYPE_FAX)
3537 type = PHONENUMBER_TYPE_HOME_FAX;
3539 else if (intValue & CONTACTS_NUMBER_TYPE_CELL)
3541 type = PHONENUMBER_TYPE_MOBILE;
3543 else if (intValue & CONTACTS_NUMBER_TYPE_PAGER)
3545 type = PHONENUMBER_TYPE_PAGER;
3547 else if (intValue & CONTACTS_NUMBER_TYPE_HOME)
3549 type = PHONENUMBER_TYPE_HOME;
3551 else if (intValue & CONTACTS_NUMBER_TYPE_WORK)
3553 type = PHONENUMBER_TYPE_WORK;
3555 else if (intValue & CONTACTS_NUMBER_TYPE_VOICE)
3557 type = PHONENUMBER_TYPE_HOME;
3561 type = PHONENUMBER_TYPE_OTHER;
3566 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetType(type);
3568 contacts_record_get_str_p(numberHandle, _contacts_number.number, &pCharValue);
3569 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetPhoneNumber(pCharValue);
3571 r = pList->Add(*pPhoneNumber);
3572 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3574 pPhoneNumber.release();
3577 return pList.release();
3581 _ContactImpl::GetEmailsN(void) const
3583 result r = E_SUCCESS;
3584 contacts_record_h currentHandle = null;
3585 int ret = CONTACTS_ERROR_NONE;
3587 unsigned int count = 0;
3588 char* pCharValue = null;
3589 EmailType type = EMAIL_TYPE_PERSONAL;
3590 std::unique_ptr<Email> pEmail(null);
3592 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3593 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3595 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
3597 r = pList->Construct(count);
3598 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3600 for (unsigned int i = 0; i < count; i++)
3602 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.email, i, ¤tHandle);
3603 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM))
3605 pEmail.reset(new (std::nothrow) Email());
3606 SysTryReturn(NID_SCL, pEmail != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3608 contacts_record_get_int(currentHandle, _contacts_email.id, &intValue);
3609 _EmailImpl::GetInstance(*pEmail)->SetRecordId(intValue);
3611 contacts_record_get_str_p(currentHandle, _contacts_email.label, &pCharValue);
3612 _EmailImpl::GetInstance(*pEmail)->SetLabel(pCharValue);
3614 contacts_record_get_int(currentHandle, _contacts_email.type, &intValue);
3617 case CONTACTS_EMAIL_TYPE_HOME:
3618 type = EMAIL_TYPE_PERSONAL;
3620 case CONTACTS_EMAIL_TYPE_WORK:
3621 type = EMAIL_TYPE_WORK;
3623 case CONTACTS_EMAIL_TYPE_CUSTOM:
3624 type = EMAIL_TYPE_CUSTOM;
3626 case CONTACTS_EMAIL_TYPE_MOBILE:
3627 if (_AppInfo::GetApiVersion() < _API_VERSION_2_1)
3629 type = EMAIL_TYPE_OTHER;
3633 type = EMAIL_TYPE_MOBILE;
3637 type = EMAIL_TYPE_OTHER;
3641 _EmailImpl::GetInstance(*pEmail)->SetType(type);
3643 contacts_record_get_str_p(currentHandle, _contacts_email.email, &pCharValue);
3644 _EmailImpl::GetInstance(*pEmail)->SetEmail(pCharValue);
3646 r = pList->Add(*pEmail);
3647 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3652 return pList.release();
3656 _ContactImpl::GetUrlsN(void) const
3658 result r = E_SUCCESS;
3659 char* pCharValue = null;
3661 unsigned int count = 0;
3662 UrlType type = URL_TYPE_PERSONAL;
3663 contacts_record_h urlHandle = null;
3664 std::unique_ptr<Url> pUrl(null);
3666 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3667 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3669 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
3671 r = pList->Construct(count);
3672 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3674 for (unsigned int i = 0; i < count; i++)
3676 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.url, i, &urlHandle);
3678 pUrl.reset(new (std::nothrow) Url());
3679 SysTryReturn(NID_SCL, pUrl != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3681 contacts_record_get_str_p(urlHandle, _contacts_url.label, &pCharValue);
3682 pUrl->SetLabel(pCharValue);
3684 contacts_record_get_int(urlHandle, _contacts_url.type, &intValue);
3687 case CONTACTS_URL_TYPE_HOME:
3688 type = URL_TYPE_PERSONAL;
3690 case CONTACTS_URL_TYPE_WORK:
3691 type = URL_TYPE_WORK;
3693 case CONTACTS_URL_TYPE_CUSTOM:
3694 type = URL_TYPE_CUSTOM;
3697 type = URL_TYPE_OTHER;
3701 pUrl->SetType(type);
3703 contacts_record_get_str_p(urlHandle, _contacts_url.url, &pCharValue);
3704 _UrlImpl::GetInstance(*pUrl)->SetUrl(pCharValue);
3707 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3712 return pList.release();
3716 _ContactImpl::GetAddressesN(void) const
3718 result r = E_SUCCESS;
3719 char* pCharValue = null;
3721 unsigned int count = 0;
3722 contacts_record_h addressHandle = 0;
3723 std::unique_ptr<Address> pAddress(null);
3725 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3726 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3728 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
3730 r = pList->Construct(count);
3731 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3734 for (unsigned int i = 0; i < count; i++)
3736 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.address, i, &addressHandle);
3738 pAddress.reset(new (std::nothrow) Address());
3739 SysTryReturn(NID_SCL, pAddress != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3741 contacts_record_get_str_p(addressHandle, _contacts_address.label, &pCharValue);
3742 pAddress->SetLabel(pCharValue);
3744 contacts_record_get_int(addressHandle, _contacts_address.type, &intValue);
3747 case CONTACTS_ADDRESS_TYPE_HOME:
3748 pAddress->SetType(ADDRESS_TYPE_HOME);
3750 case CONTACTS_ADDRESS_TYPE_WORK:
3751 pAddress->SetType(ADDRESS_TYPE_WORK);
3753 case CONTACTS_ADDRESS_TYPE_CUSTOM:
3754 pAddress->SetType(ADDRESS_TYPE_CUSTOM);
3757 pAddress->SetType(ADDRESS_TYPE_OTHER);
3762 contacts_record_get_str_p(addressHandle, _contacts_address.country, &pCharValue);
3763 _AddressImpl::GetInstance(*pAddress)->SetCountry(pCharValue);
3766 contacts_record_get_str_p(addressHandle, _contacts_address.region, &pCharValue);
3767 _AddressImpl::GetInstance(*pAddress)->SetState(pCharValue);
3770 contacts_record_get_str_p(addressHandle, _contacts_address.locality, &pCharValue);
3771 _AddressImpl::GetInstance(*pAddress)->SetCity(pCharValue);
3774 contacts_record_get_str_p(addressHandle, _contacts_address.street, &pCharValue);
3775 _AddressImpl::GetInstance(*pAddress)->SetStreet(pCharValue);
3778 contacts_record_get_str_p(addressHandle, _contacts_address.extended, &pCharValue);
3779 _AddressImpl::GetInstance(*pAddress)->SetExtended(pCharValue);
3782 contacts_record_get_str_p(addressHandle, _contacts_address.postbox, &pCharValue);
3783 _AddressImpl::GetInstance(*pAddress)->SetPostOfficeBoxNumber(pCharValue);
3786 contacts_record_get_str_p(addressHandle, _contacts_address.postal_code, &pCharValue);
3787 _AddressImpl::GetInstance(*pAddress)->SetPostalCode(pCharValue);
3789 r = pList->Add(*pAddress);
3790 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3795 return pList.release();
3799 _ContactImpl::GetImAddressesN(void) const
3801 result r = E_SUCCESS;
3802 char* pCharValue = null;
3804 contacts_record_h messengerHandle = null;
3805 unsigned int count = 0;
3806 std::unique_ptr<ImAddress> pImAddress(null);
3808 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3809 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3811 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
3813 r = pList->Construct(count);
3814 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3817 for (unsigned int i = 0; i < count; i++)
3819 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.messenger, i, &messengerHandle);
3821 pImAddress.reset(new (std::nothrow) ImAddress());
3822 SysTryReturn(NID_SCL, pImAddress != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3824 contacts_record_get_int(messengerHandle, _contacts_messenger.type, &intValue);
3827 case CONTACTS_MESSENGER_TYPE_GOOGLE:
3828 pImAddress->SetServiceProviderName(IM_ADDRESS_GOOGLE_TALK);
3830 case CONTACTS_MESSENGER_TYPE_WLM:
3831 pImAddress->SetServiceProviderName(IM_ADDRESS_MSN);
3833 case CONTACTS_MESSENGER_TYPE_ICQ:
3834 pImAddress->SetServiceProviderName(IM_ADDRESS_ICQ);
3836 case CONTACTS_MESSENGER_TYPE_AIM:
3837 pImAddress->SetServiceProviderName(IM_ADDRESS_AIM);
3839 case CONTACTS_MESSENGER_TYPE_YAHOO:
3840 pImAddress->SetServiceProviderName(IM_ADDRESS_YAHOO);
3842 case CONTACTS_MESSENGER_TYPE_QQ:
3843 pImAddress->SetServiceProviderName(IM_ADDRESS_QQ);
3845 case CONTACTS_MESSENGER_TYPE_SKYPE:
3846 pImAddress->SetServiceProviderName(IM_ADDRESS_SKYPE);
3848 case CONTACTS_MESSENGER_TYPE_JABBER:
3849 pImAddress->SetServiceProviderName(IM_ADDRESS_JABBER);
3851 case CONTACTS_MESSENGER_TYPE_CUSTOM:
3854 contacts_record_get_str_p(messengerHandle, _contacts_messenger.label, &pCharValue);
3855 pImAddress->SetServiceProviderName(pCharValue);
3859 contacts_record_get_str_p(messengerHandle, _contacts_messenger.im_id, &pCharValue);
3860 _ImAddressImpl::GetInstance(*pImAddress)->SetImAddress(pCharValue);
3862 r = pList->Add(*pImAddress);
3863 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3865 pImAddress.release();
3868 return pList.release();
3872 _ContactImpl::IsEmpty(void) const
3874 char* pCharValue = null;
3875 unsigned int count = 0;
3877 contacts_record_get_str_p(__contactHandle, _contacts_contact.ringtone_path, &pCharValue);
3878 if (pCharValue != null)
3883 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
3889 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
3895 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
3901 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
3907 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
3913 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
3919 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
3925 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
3931 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
3937 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
3943 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
3949 contacts_record_get_str_p(__contactHandle, _contacts_contact.uid, &pCharValue);
3950 if (pCharValue != null)
3959 _ContactImpl::GetAddressbookId(void) const
3961 int addressbookId = 0;
3963 contacts_record_get_int(__contactHandle, _contacts_contact.address_book_id, &addressbookId);
3965 return addressbookId;
3969 _ContactImpl::GetPersonId(void) const
3973 contacts_record_get_int(__contactHandle, _contacts_contact.person_id, &personId);
3979 _ContactImpl::SetAsRemoved(void)
3985 _ContactImpl::IsRemoved(void) const
3991 _ContactImpl::IsFavorite(void) const
3993 bool isFavorite = false;
3994 contacts_record_get_bool(__contactHandle, _contacts_contact.is_favorite, &isFavorite);
4000 _ContactImpl::SetAsFavorite(bool isFavorite)
4002 contacts_record_set_bool(__contactHandle, _contacts_contact.is_favorite, isFavorite);
4006 _ContactImpl::Invalidate(void)
4008 int ret = CONTACTS_ERROR_NONE;
4010 unsigned int count = 0;
4011 char* pCharValue = null;
4013 bool boolValue = false;
4015 contacts_record_h contactHandle = null;
4016 contacts_record_h sourceRecordHandle = null;
4017 contacts_record_h destRecordHandle = null;
4019 ret = contacts_record_create(_contacts_contact._uri, &contactHandle);
4020 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4022 __ContactsRecordHandle recordHandle(contactHandle);
4025 contacts_record_get_bool(sourceRecordHandle, _contacts_contact.is_favorite, &boolValue);
4026 contacts_record_set_bool(destRecordHandle, _contacts_contact.is_favorite, boolValue);
4029 contacts_record_get_str_p(sourceRecordHandle, _contacts_contact.uid, &pCharValue);
4030 contacts_record_set_str(destRecordHandle, _contacts_contact.uid, pCharValue);
4032 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4034 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4035 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
4038 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &sourceRecordHandle);
4040 ret = contacts_record_create(_contacts_name._uri, &destRecordHandle);
4041 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4043 __ContactsRecordHandle nameHandle(destRecordHandle);
4046 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.first, &pCharValue);
4047 contacts_record_set_str(destRecordHandle, _contacts_name.first, pCharValue);
4050 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.last, &pCharValue);
4051 contacts_record_set_str(destRecordHandle, _contacts_name.last, pCharValue);
4054 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.addition, &pCharValue);
4055 contacts_record_set_str(destRecordHandle, _contacts_name.addition, pCharValue);
4058 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.suffix, &pCharValue);
4059 contacts_record_set_str(destRecordHandle, _contacts_name.suffix, pCharValue);
4062 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.prefix, &pCharValue);
4063 contacts_record_set_str(destRecordHandle, _contacts_name.prefix, pCharValue);
4065 // 6. phonetic_first
4066 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_first, &pCharValue);
4067 contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_first, pCharValue);
4070 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_last, &pCharValue);
4071 contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_last, pCharValue);
4073 // 8. phonetic_middle
4074 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_middle, &pCharValue);
4075 contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_middle, pCharValue);
4077 contacts_record_add_child_record(contactHandle, _contacts_contact.name, destRecordHandle);
4079 nameHandle.Release();
4082 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4084 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4085 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
4088 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, 0, &sourceRecordHandle);
4090 ret = contacts_record_create(_contacts_image._uri, &destRecordHandle);
4091 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4093 __ContactsRecordHandle imageHandle(destRecordHandle);
4095 contacts_record_get_int(sourceRecordHandle, _contacts_image.type, &intValue);
4096 contacts_record_set_int(destRecordHandle, _contacts_image.type, intValue);
4098 contacts_record_get_str_p(sourceRecordHandle, _contacts_image.label, &pCharValue);
4099 contacts_record_set_str(destRecordHandle, _contacts_image.label, pCharValue);
4101 contacts_record_get_str_p(sourceRecordHandle, _contacts_image.path, &pCharValue);
4102 contacts_record_set_str(destRecordHandle, _contacts_image.path, pCharValue);
4104 contacts_record_add_child_record(contactHandle, _contacts_contact.image, destRecordHandle);
4106 imageHandle.Release();
4109 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4111 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4112 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
4113 for (i = 0; i < count; i++)
4115 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, i, &sourceRecordHandle);
4117 ret = contacts_record_create(_contacts_company._uri, &destRecordHandle);
4118 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4120 __ContactsRecordHandle companyHandle(destRecordHandle);
4122 contacts_record_get_int(sourceRecordHandle, _contacts_company.type, &intValue);
4123 contacts_record_set_int(destRecordHandle, _contacts_company.type, intValue);
4125 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.name, &pCharValue);
4126 contacts_record_set_str(destRecordHandle, _contacts_company.name, pCharValue);
4128 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.department, &pCharValue);
4129 contacts_record_set_str(destRecordHandle, _contacts_company.department, pCharValue);
4131 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.job_title, &pCharValue);
4132 contacts_record_set_str(destRecordHandle, _contacts_company.job_title, pCharValue);
4134 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.assistant_name, &pCharValue);
4135 contacts_record_set_str(destRecordHandle, _contacts_company.assistant_name, pCharValue);
4137 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.role, &pCharValue);
4138 contacts_record_set_str(destRecordHandle, _contacts_company.role, pCharValue);
4140 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.logo, &pCharValue);
4141 contacts_record_set_str(destRecordHandle, _contacts_company.logo, pCharValue);
4143 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.location, &pCharValue);
4144 contacts_record_set_str(destRecordHandle, _contacts_company.location, pCharValue);
4146 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.description, &pCharValue);
4147 contacts_record_set_str(destRecordHandle, _contacts_company.description, pCharValue);
4149 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.phonetic_name, &pCharValue);
4150 contacts_record_set_str(destRecordHandle, _contacts_company.phonetic_name, pCharValue);
4152 contacts_record_add_child_record(contactHandle, _contacts_contact.company, destRecordHandle);
4154 companyHandle.Release();
4157 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4159 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4160 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
4161 for (i = 0; i < count; i++)
4163 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, i, &sourceRecordHandle);
4165 ret = contacts_record_create(_contacts_note._uri, &destRecordHandle);
4166 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4168 __ContactsRecordHandle noteHandle(destRecordHandle);
4170 contacts_record_get_str_p(sourceRecordHandle, _contacts_note.note, &pCharValue);
4171 contacts_record_set_str(destRecordHandle, _contacts_note.note, pCharValue);
4173 contacts_record_add_child_record(contactHandle, _contacts_contact.note, destRecordHandle);
4175 noteHandle.Release();
4178 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4180 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4181 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
4182 for (i = 0; i < count; i++)
4184 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.number, i, &sourceRecordHandle);
4186 ret = contacts_record_create(_contacts_number._uri, &destRecordHandle);
4187 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4189 __ContactsRecordHandle numberHandle(destRecordHandle);
4191 contacts_record_get_int(sourceRecordHandle, _contacts_number.type, &intValue);
4192 contacts_record_set_int(destRecordHandle, _contacts_number.type, intValue);
4194 contacts_record_get_str_p(sourceRecordHandle, _contacts_number.label, &pCharValue);
4195 contacts_record_set_str(destRecordHandle, _contacts_number.label, pCharValue);
4197 contacts_record_get_str_p(sourceRecordHandle, _contacts_number.number, &pCharValue);
4198 contacts_record_set_str(destRecordHandle, _contacts_number.number, pCharValue);
4200 contacts_record_add_child_record(contactHandle, _contacts_contact.number, destRecordHandle);
4202 numberHandle.Release();
4205 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4207 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4208 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
4209 for (i = 0; i < count; i++)
4211 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.email, i, &sourceRecordHandle);
4213 ret = contacts_record_create(_contacts_email._uri, &destRecordHandle);
4214 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4216 __ContactsRecordHandle emailHandle(destRecordHandle);
4218 contacts_record_get_int(sourceRecordHandle, _contacts_email.type, &intValue);
4219 contacts_record_set_int(destRecordHandle, _contacts_email.type, intValue);
4221 contacts_record_get_str_p(sourceRecordHandle, _contacts_email.label, &pCharValue);
4222 contacts_record_set_str(destRecordHandle, _contacts_email.label, pCharValue);
4224 contacts_record_get_str_p(sourceRecordHandle, _contacts_email.email, &pCharValue);
4225 contacts_record_set_str(destRecordHandle, _contacts_email.email, pCharValue);
4227 contacts_record_add_child_record(contactHandle, _contacts_contact.email, destRecordHandle);
4229 emailHandle.Release();
4233 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4235 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4236 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
4237 for (i = 0; i < count; i++)
4239 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &sourceRecordHandle);
4241 ret = contacts_record_create(_contacts_event._uri, &destRecordHandle);
4242 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4244 __ContactsRecordHandle eventHandle(destRecordHandle);
4246 contacts_record_get_int(sourceRecordHandle, _contacts_event.type, &intValue);
4247 contacts_record_set_int(destRecordHandle, _contacts_event.type, intValue);
4249 contacts_record_get_str_p(sourceRecordHandle, _contacts_event.label, &pCharValue);
4250 contacts_record_set_str(destRecordHandle, _contacts_event.label, pCharValue);
4252 contacts_record_get_int(sourceRecordHandle, _contacts_event.date, &intValue);
4253 contacts_record_set_int(destRecordHandle, _contacts_event.date, intValue);
4255 contacts_record_add_child_record(contactHandle, _contacts_contact.event, destRecordHandle);
4257 eventHandle.Release();
4260 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4262 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4263 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
4264 for (i = 0; i < count; i++)
4266 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.messenger, i, &sourceRecordHandle);
4268 ret = contacts_record_create(_contacts_messenger._uri, &destRecordHandle);
4269 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4271 __ContactsRecordHandle imAddressHandle(destRecordHandle);
4273 contacts_record_get_int(sourceRecordHandle, _contacts_messenger.type, &intValue);
4274 contacts_record_set_int(destRecordHandle, _contacts_messenger.type, intValue);
4276 contacts_record_get_str_p(sourceRecordHandle, _contacts_messenger.label, &pCharValue);
4277 contacts_record_set_str(destRecordHandle, _contacts_messenger.label, pCharValue);
4279 contacts_record_get_str_p(sourceRecordHandle, _contacts_messenger.im_id, &pCharValue);
4280 contacts_record_set_str(destRecordHandle, _contacts_messenger.im_id, pCharValue);
4282 contacts_record_add_child_record(contactHandle, _contacts_contact.messenger, destRecordHandle);
4284 imAddressHandle.Release();
4287 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4289 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4290 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
4291 for (i = 0; i < count; i++)
4293 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.address, i, &sourceRecordHandle);
4295 ret = contacts_record_create(_contacts_address._uri, &destRecordHandle);
4296 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4298 __ContactsRecordHandle addressHandle(destRecordHandle);
4300 contacts_record_get_int(sourceRecordHandle, _contacts_address.type, &intValue);
4301 contacts_record_set_int(destRecordHandle, _contacts_address.type, intValue);
4303 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.label, &pCharValue);
4304 contacts_record_set_str(destRecordHandle, _contacts_address.label, pCharValue);
4306 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.postbox, &pCharValue);
4307 contacts_record_set_str(destRecordHandle, _contacts_address.postbox, pCharValue);
4309 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.extended, &pCharValue);
4310 contacts_record_set_str(destRecordHandle, _contacts_address.extended, pCharValue);
4312 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.street, &pCharValue);
4313 contacts_record_set_str(destRecordHandle, _contacts_address.street, pCharValue);
4315 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.locality, &pCharValue);
4316 contacts_record_set_str(destRecordHandle, _contacts_address.locality, pCharValue);
4318 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.region, &pCharValue);
4319 contacts_record_set_str(destRecordHandle, _contacts_address.region, pCharValue);
4321 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.postal_code, &pCharValue);
4322 contacts_record_set_str(destRecordHandle, _contacts_address.postal_code, pCharValue);
4324 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.country, &pCharValue);
4325 contacts_record_set_str(destRecordHandle, _contacts_address.country, pCharValue);
4327 contacts_record_add_child_record(contactHandle, _contacts_contact.address, destRecordHandle);
4329 addressHandle.Release();
4332 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4334 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4335 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
4336 for (i = 0; i < count; i++)
4338 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.url, i, &sourceRecordHandle);
4340 ret = contacts_record_create(_contacts_url._uri, &destRecordHandle);
4341 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4343 __ContactsRecordHandle urlHandle(destRecordHandle);
4345 contacts_record_get_int(sourceRecordHandle, _contacts_url.type, &intValue);
4346 contacts_record_set_int(destRecordHandle, _contacts_url.type, intValue);
4348 contacts_record_get_str_p(sourceRecordHandle, _contacts_url.label, &pCharValue);
4349 contacts_record_set_str(destRecordHandle, _contacts_url.label, pCharValue);
4351 contacts_record_get_str_p(sourceRecordHandle, _contacts_url.url, &pCharValue);
4352 contacts_record_set_str(destRecordHandle, _contacts_url.url, pCharValue);
4354 contacts_record_add_child_record(contactHandle, _contacts_contact.url, destRecordHandle);
4356 urlHandle.Release();
4359 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4361 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4362 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
4363 for (i = 0; i < count; i++)
4365 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, i, &sourceRecordHandle);
4367 ret = contacts_record_create(_contacts_nickname._uri, &destRecordHandle);
4368 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4370 __ContactsRecordHandle nicknameHandle(destRecordHandle);
4372 contacts_record_get_str_p(sourceRecordHandle, _contacts_nickname.name, &pCharValue);
4373 contacts_record_set_str(destRecordHandle, _contacts_nickname.name, pCharValue);
4375 contacts_record_add_child_record(contactHandle, _contacts_contact.nickname, destRecordHandle);
4377 nicknameHandle.Release();
4380 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4382 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4383 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.relationship, &count);
4384 for (i = 0; i < count; i++)
4386 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.relationship, i, &sourceRecordHandle);
4388 ret = contacts_record_create(_contacts_relationship._uri, &destRecordHandle);
4389 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4391 __ContactsRecordHandle relationshipHandle(destRecordHandle);
4393 contacts_record_get_str_p(sourceRecordHandle, _contacts_relationship.name, &pCharValue);
4394 contacts_record_set_str(destRecordHandle, _contacts_relationship.name, pCharValue);
4396 contacts_record_add_child_record(contactHandle, _contacts_contact.relationship, destRecordHandle);
4398 relationshipHandle.Release();
4401 contacts_record_destroy(__contactHandle, true);
4402 __contactHandle = contactHandle;
4404 __isRemoved = false;
4406 recordHandle.Release();
4412 _ContactImpl::GetInstance(const Contact& contact)
4414 return contact.__pContactImpl;
4418 _ContactImpl::GetInstance(Contact& contact)
4420 return contact.__pContactImpl;