2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 * @file FScl_ContactImpl.cpp
18 * @brief This is the implementation for _ContactImpl class.
20 * This file contains definitions of _ContactImpl class.
22 #include <FBaseString.h>
23 #include <FBaseColArrayList.h>
24 #include <FBaseSysLog.h>
26 #include <FMediaImage.h>
27 #include <FSclAddress.h>
28 #include <FSclPhoneNumber.h>
29 #include <FSclEmail.h>
31 #include <FSclImAddress.h>
32 #include <FSclOrganization.h>
33 #include <FSclContactEvent.h>
34 #include <FSclRelationship.h>
35 #include <FSclContact.h>
36 #include <FApp_AppInfo.h>
37 #include <FBase_StringConverter.h>
38 #include "FScl_ContactDbConnector.h"
39 #include "FScl_PhoneNumberImpl.h"
40 #include "FScl_ContactImpl.h"
41 #include "FScl_AddressbookUtil.h"
42 #include "FScl_UrlImpl.h"
43 #include "FScl_EmailImpl.h"
44 #include "FScl_AddressImpl.h"
45 #include "FScl_ImAddressImpl.h"
46 #include "FScl_OrganizationImpl.h"
47 #include "FScl_ContactEventImpl.h"
49 using namespace Tizen::App;
50 using namespace Tizen::Base;
51 using namespace Tizen::Base::Collection;
52 using namespace Tizen::Graphics;
53 using namespace Tizen::Media;
54 using namespace Tizen::Io;
56 namespace Tizen { namespace Social
59 extern const wchar_t OTHER_LABEL[] = L"Other";
61 const int __CONTACT_CHANGED_TIME_YEAR_OFFSET = 1900;
62 const int __CONTACT_CHANGED_TIME_MONTH_OFFSET = 1;
64 const int __CONTACT_MOD_YEAR = 10000;
65 const int __CONTACT_MOD_MONTH = 100;
67 #define __PARSE_DATE(date, year, month, day) \
71 year = temp/__CONTACT_MOD_YEAR; \
72 temp -= year*__CONTACT_MOD_YEAR; \
73 month = temp/__CONTACT_MOD_MONTH; \
74 day = temp - month*__CONTACT_MOD_MONTH; \
77 #define __CONVERT_DATE_TO_DATETIME(date, dateTime) \
84 year = temp/__CONTACT_MOD_YEAR; \
85 temp -= year*__CONTACT_MOD_YEAR; \
86 month = temp/__CONTACT_MOD_MONTH; \
87 day = temp - month*__CONTACT_MOD_MONTH; \
88 dateTime.SetValue(year, month, day, 0, 0, 0); \
92 #define __CONVERT_DATETIME_TO_DATE(dateTime, date) \
95 date = dateTime.GetYear()*__CONTACT_MOD_YEAR + dateTime.GetMonth()*__CONTACT_MOD_MONTH + dateTime.GetDay(); \
98 _ContactImpl::_ContactImpl(void)
99 : __contactHandle(null)
102 contacts_record_h contactHandle = null;
104 SysTryReturnVoidResult(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
106 int ret = contacts_record_create(_contacts_contact._uri, &contactHandle);
107 SysTryReturnVoidResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
109 __contactHandle = contactHandle;
112 _ContactImpl::_ContactImpl(const _ContactImpl& rhs)
113 : __contactHandle(null)
115 contacts_record_h contactHandle = null;
117 SysTryReturnVoidResult(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
119 int ret = contacts_record_clone(rhs.__contactHandle, &contactHandle);
120 SysTryReturnVoidResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
122 __contactHandle = contactHandle;
123 __isRemoved = rhs.__isRemoved;
126 _ContactImpl::~_ContactImpl(void)
128 if (__contactHandle != null)
130 contacts_record_destroy(__contactHandle, true);
135 _ContactImpl::operator =(const _ContactImpl& rhs)
142 contacts_record_h contactHandle = null;
144 int ret = contacts_record_clone(rhs.__contactHandle, &contactHandle);
145 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
147 contacts_record_destroy(__contactHandle, true);
148 __contactHandle = contactHandle;
150 __isRemoved = rhs.__isRemoved;
156 _ContactImpl::SetContactRecordHandle(contacts_record_h contactHandle)
158 contacts_record_destroy(__contactHandle, true);
160 __contactHandle = contactHandle;
164 _ContactImpl::GetContactRecordHandle(void) const
166 return __contactHandle;
170 _ContactImpl::SetThumbnailPath(const Tizen::Base::String& filePath)
172 SysTryReturn(NID_SCL, filePath.IsEmpty() || File::IsFileExist(filePath), E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[%s] The specified file is not found.", GetErrorMessage(E_FILE_NOT_FOUND));
174 unsigned int count = 0;
175 contacts_record_h imageHandle = null;
177 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
180 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, 0, &imageHandle);
182 if (!filePath.IsEmpty())
184 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(filePath));
185 SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
187 contacts_record_set_str(imageHandle, _contacts_image.path, pCharArray.get());
191 contacts_record_remove_child_record(__contactHandle, _contacts_contact.image, imageHandle);
192 contacts_record_destroy(imageHandle, true);
197 if (!filePath.IsEmpty())
199 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(filePath));
200 SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
202 int ret = contacts_record_create(_contacts_image._uri, &imageHandle);
203 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
205 contacts_record_set_str(imageHandle, _contacts_image.path, pCharArray.get());
207 contacts_record_add_child_record(__contactHandle, _contacts_contact.image, imageHandle);
215 _ContactImpl::GetThumbnailPath(void) const
217 unsigned int count = 0;
219 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
225 char* pCharValue = null;
226 contacts_record_h imageHandle = null;
228 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, 0, &imageHandle);
229 contacts_record_get_str_p(imageHandle, _contacts_image.path, &pCharValue);
231 return String(pCharValue);
235 _ContactImpl::GetThumbnailN(void) const
237 unsigned int count = 0;
238 char* pCharValue = null;
239 contacts_record_h imageHandle = null;
243 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
249 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, 0, &imageHandle);
250 contacts_record_get_str_p(imageHandle, _contacts_image.path, &pCharValue);
252 String thumbnailPath(pCharValue);
255 result r = image.Construct();
256 SysTryReturn(NID_SCL, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
257 SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Failed to construct Image.", GetErrorMessage(E_SYSTEM));
259 ImageFormat imageFormat = image.GetImageFormat(thumbnailPath);
260 SysTryReturn(NID_SCL, GetLastResult() != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
261 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, null, E_SYSTEM, "[%s] Failed to get the format of the thumbnail image.", GetErrorMessage(E_SYSTEM));
263 BitmapPixelFormat bitmapPixelFormat = BITMAP_PIXEL_FORMAT_RGB565;
272 bitmapPixelFormat = BITMAP_PIXEL_FORMAT_RGB565;
275 bitmapPixelFormat = BITMAP_PIXEL_FORMAT_ARGB8888;
278 SysLogException(NID_SCL, E_SYSTEM, "[%s] Unsupported image format.", GetErrorMessage(E_SYSTEM));
282 Bitmap* pBitmap = image.DecodeN(thumbnailPath, bitmapPixelFormat);
283 SysTryReturn(NID_SCL, GetLastResult() != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. ", GetErrorMessage(E_OUT_OF_MEMORY));
284 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred. ", GetErrorMessage(E_SYSTEM));
290 _ContactImpl::GetValue(const ContactPropertyId id, String& value) const
292 unsigned int count = 0;
293 char* pCharValue = null;
297 case CONTACT_PROPERTY_ID_FIRST_NAME:
299 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
302 contacts_record_h nameHandle = null;
304 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
305 contacts_record_get_str_p(nameHandle, _contacts_name.first, &pCharValue);
311 case CONTACT_PROPERTY_ID_LAST_NAME:
313 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
316 contacts_record_h nameHandle = null;
318 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
319 contacts_record_get_str_p(nameHandle, _contacts_name.last, &pCharValue);
325 case CONTACT_PROPERTY_ID_DISPLAY_NAME:
326 contacts_record_get_str_p(__contactHandle, _contacts_contact.display_name, &pCharValue);
329 case CONTACT_PROPERTY_ID_NICK_NAME:
331 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
334 contacts_record_h nicknameHandle = null;
336 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, 0, &nicknameHandle);
337 contacts_record_get_str_p(nicknameHandle, _contacts_nickname.name, &pCharValue);
343 case CONTACT_PROPERTY_ID_MIDDLE_NAME:
345 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
348 contacts_record_h nameHandle = null;
350 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
351 contacts_record_get_str_p(nameHandle, _contacts_name.addition, &pCharValue);
357 case CONTACT_PROPERTY_ID_NAME_PREFIX:
359 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
362 contacts_record_h nameHandle = null;
364 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
365 contacts_record_get_str_p(nameHandle, _contacts_name.prefix, &pCharValue);
371 case CONTACT_PROPERTY_ID_NAME_SUFFIX:
373 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
376 contacts_record_h nameHandle = null;
378 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
379 contacts_record_get_str_p(nameHandle, _contacts_name.suffix, &pCharValue);
385 case CONTACT_PROPERTY_ID_JOB_TITLE:
387 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
390 contacts_record_h companyHandle = null;
392 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
393 contacts_record_get_str_p(companyHandle, _contacts_company.job_title, &pCharValue);
399 case CONTACT_PROPERTY_ID_COMPANY:
401 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
404 contacts_record_h companyHandle = null;
406 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
407 contacts_record_get_str_p(companyHandle, _contacts_company.name, &pCharValue);
413 case CONTACT_PROPERTY_ID_NOTE:
415 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
418 contacts_record_h noteHandle = null;
420 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, 0, ¬eHandle);
421 contacts_record_get_str_p(noteHandle, _contacts_note.note, &pCharValue);
427 case CONTACT_PROPERTY_ID_RINGTONE:
428 contacts_record_get_str_p(__contactHandle, _contacts_contact.ringtone_path, &pCharValue);
431 case CONTACT_PROPERTY_ID_THUMBNAIL:
433 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
436 contacts_record_h imageHandle = null;
438 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, 0, &imageHandle);
439 contacts_record_get_str_p(imageHandle, _contacts_image.path, &pCharValue);
444 case CONTACT_PROPERTY_ID_PHONETIC_FIRST_NAME:
446 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
449 contacts_record_h phoneticNameHandle = null;
451 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
452 contacts_record_get_str_p(phoneticNameHandle, _contacts_name.phonetic_first, &pCharValue);
458 case CONTACT_PROPERTY_ID_PHONETIC_LAST_NAME:
460 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
463 contacts_record_h phoneticNameHandle = null;
465 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
466 contacts_record_get_str_p(phoneticNameHandle, _contacts_name.phonetic_last, &pCharValue);
472 case CONTACT_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
474 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
477 contacts_record_h phoneticNameHandle = null;
479 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
480 contacts_record_get_str_p(phoneticNameHandle, _contacts_name.phonetic_middle, &pCharValue);
486 case CONTACT_PROPERTY_ID_UID:
488 contacts_record_get_str_p(__contactHandle, _contacts_contact.uid, &pCharValue);
495 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d", GetErrorMessage(E_INVALID_ARG), id);
496 return E_INVALID_ARG;
503 _ContactImpl::GetValue(const ContactPropertyId id, DateTime& value) const
507 unsigned int count = 0;
509 value = DateTime::GetMinValue();
513 case CONTACT_PROPERTY_ID_BIRTHDAY:
515 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
522 contacts_record_h eventHandle = null;
523 for (unsigned int i = 0; i < count; i++)
525 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
526 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
527 if (intValue == CONTACTS_EVENT_TYPE_BIRTH)
529 contacts_record_get_int(eventHandle, _contacts_event.date, &intValue);
531 __PARSE_DATE(intValue, year, month, day);
533 value.SetValue(year, month, day, 0, 0, 0);
541 case CONTACT_PROPERTY_ID_ANNIVERSARY:
543 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
550 contacts_record_h eventHandle = null;
551 for (unsigned int i = 0; i < count; i++)
553 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
554 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
555 if (intValue == CONTACTS_EVENT_TYPE_ANNIVERSARY)
557 contacts_record_get_int(eventHandle, _contacts_event.date, &intValue);
559 __PARSE_DATE(intValue, year, month, day);
561 value.SetValue(year, month, day, 0, 0, 0);
569 case CONTACT_PROPERTY_ID_LAST_REVISION:
574 contacts_record_get_int(__contactHandle, _contacts_contact.changed_time, &intValue);
575 gmtime_r((time_t *)intValue, &ts);
577 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);
582 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
583 return E_INVALID_ARG;
590 _ContactImpl::IsEmptyCompany(contacts_record_h companyHandle)
592 char* pCharValue = null;
594 contacts_record_get_str_p(companyHandle, _contacts_company.name, &pCharValue);
595 if (pCharValue != null)
600 contacts_record_get_str_p(companyHandle, _contacts_company.job_title, &pCharValue);
601 if (pCharValue != null)
606 contacts_record_get_str_p(companyHandle, _contacts_company.department, &pCharValue);
607 if (pCharValue != null)
612 contacts_record_get_str_p(companyHandle, _contacts_company.role, &pCharValue);
613 if (pCharValue != null)
618 contacts_record_get_str_p(companyHandle, _contacts_company.assistant_name, &pCharValue);
619 if (pCharValue != null)
624 contacts_record_get_str_p(companyHandle, _contacts_company.description, &pCharValue);
625 if (pCharValue != null)
630 contacts_record_get_str_p(companyHandle, _contacts_company.location, &pCharValue);
631 if (pCharValue != null)
636 contacts_record_get_str_p(companyHandle, _contacts_company.phonetic_name, &pCharValue);
637 if (pCharValue != null)
642 contacts_record_get_str_p(companyHandle, _contacts_company.logo, &pCharValue);
643 if (pCharValue != null)
652 _ContactImpl::IsEmptyName(contacts_record_h nameHandle)
654 char* pCharValue = null;
656 contacts_record_get_str_p(nameHandle, _contacts_name.first, &pCharValue);
657 if (pCharValue != null)
662 contacts_record_get_str_p(nameHandle, _contacts_name.last, &pCharValue);
663 if (pCharValue != null)
668 contacts_record_get_str_p(nameHandle, _contacts_name.addition, &pCharValue);
669 if (pCharValue != null)
674 contacts_record_get_str_p(nameHandle, _contacts_name.prefix, &pCharValue);
675 if (pCharValue != null)
680 contacts_record_get_str_p(nameHandle, _contacts_name.suffix, &pCharValue);
681 if (pCharValue != null)
686 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_first, &pCharValue);
687 if (pCharValue != null)
692 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_last, &pCharValue);
693 if (pCharValue != null)
698 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_middle, &pCharValue);
699 if (pCharValue != null)
708 _ContactImpl::SetValue(ContactPropertyId id, const String& value)
710 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));
711 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));
713 int ret = CONTACTS_ERROR_NONE;
714 unsigned int count = 0;
716 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
718 int maxLength = GetMaxLength(id);
719 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));
724 case CONTACT_PROPERTY_ID_FIRST_NAME:
726 contacts_record_h nameHandle = null;
727 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
730 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
732 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
733 contacts_record_set_str(nameHandle, _contacts_name.first, pCharArray.get());
735 if (value.IsEmpty() && IsEmptyName(nameHandle))
737 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
738 contacts_record_destroy(nameHandle, true);
743 if (!value.IsEmpty())
745 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
746 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
748 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
749 contacts_record_set_str(nameHandle, _contacts_name.first, pCharArray.get());
751 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
757 case CONTACT_PROPERTY_ID_MIDDLE_NAME:
759 contacts_record_h nameHandle = null;
760 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
763 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
765 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
766 contacts_record_set_str(nameHandle, _contacts_name.addition, pCharArray.get());
768 if (value.IsEmpty() && IsEmptyName(nameHandle))
770 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
771 contacts_record_destroy(nameHandle, true);
776 if (!value.IsEmpty())
778 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
779 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
781 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
782 contacts_record_set_str(nameHandle, _contacts_name.addition, pCharArray.get());
784 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
792 case CONTACT_PROPERTY_ID_LAST_NAME:
794 contacts_record_h nameHandle = null;
795 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
798 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
800 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
801 contacts_record_set_str(nameHandle, _contacts_name.last, pCharArray.get());
803 if (value.IsEmpty() && IsEmptyName(nameHandle))
805 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
806 contacts_record_destroy(nameHandle, true);
811 if (!value.IsEmpty())
813 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
814 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
816 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
817 contacts_record_set_str(nameHandle, _contacts_name.last, pCharArray.get());
819 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
826 case CONTACT_PROPERTY_ID_NAME_SUFFIX:
828 contacts_record_h nameHandle = null;
829 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
832 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
834 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
835 contacts_record_set_str(nameHandle, _contacts_name.suffix, pCharArray.get());
837 if (value.IsEmpty() && IsEmptyName(nameHandle))
839 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
840 contacts_record_destroy(nameHandle, true);
846 if (!value.IsEmpty())
848 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
850 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
852 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
853 contacts_record_set_str(nameHandle, _contacts_name.suffix, pCharArray.get());
855 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
863 case CONTACT_PROPERTY_ID_NAME_PREFIX:
865 contacts_record_h nameHandle = null;
866 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
869 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
871 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
872 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
874 if (value.IsEmpty() && IsEmptyName(nameHandle))
876 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
877 contacts_record_destroy(nameHandle, true);
882 if (!value.IsEmpty())
884 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
885 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
887 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
888 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
890 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
898 case CONTACT_PROPERTY_ID_NICK_NAME:
900 contacts_record_h nicknameHandle = null;
901 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
904 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, 0, &nicknameHandle);
905 if (!value.IsEmpty())
907 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
908 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
914 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, 0, &nicknameHandle);
915 if (ret != CONTACTS_ERROR_NONE)
920 contacts_record_remove_child_record(__contactHandle, _contacts_contact.nickname, nicknameHandle);
921 contacts_record_destroy(nicknameHandle, true);
927 if (!value.IsEmpty())
929 ret = contacts_record_create(_contacts_nickname._uri, &nicknameHandle);
930 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
932 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
933 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
935 contacts_record_add_child_record(__contactHandle, _contacts_contact.nickname, nicknameHandle);
943 case CONTACT_PROPERTY_ID_JOB_TITLE:
945 contacts_record_h companyHandle = null;
946 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
949 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
951 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
952 contacts_record_set_str(companyHandle, _contacts_company.job_title, pCharArray.get());
954 if (value.IsEmpty() && IsEmptyCompany(companyHandle))
958 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
959 if (ret != CONTACTS_ERROR_NONE)
964 contacts_record_remove_child_record(__contactHandle, _contacts_contact.company, companyHandle);
965 contacts_record_destroy(companyHandle, true);
971 if (!value.IsEmpty())
973 ret = contacts_record_create(_contacts_company._uri, &companyHandle);
974 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
976 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
977 contacts_record_set_str(companyHandle, _contacts_company.job_title, pCharArray.get());
979 contacts_record_add_child_record(__contactHandle, _contacts_contact.company, companyHandle);
986 case CONTACT_PROPERTY_ID_COMPANY:
988 contacts_record_h companyHandle = null;
989 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
992 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
994 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(value));
995 contacts_record_set_str(companyHandle, _contacts_company.name, pCharArray.get());
997 if (value.IsEmpty() && IsEmptyCompany(companyHandle))
1001 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
1002 if (ret != CONTACTS_ERROR_NONE)
1007 contacts_record_remove_child_record(__contactHandle, _contacts_contact.company, companyHandle);
1008 contacts_record_destroy(companyHandle, true);
1015 if (!value.IsEmpty())
1017 ret = contacts_record_create(_contacts_company._uri, &companyHandle);
1018 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1020 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(value));
1021 contacts_record_set_str(companyHandle, _contacts_company.name, pCharArray.get());
1023 contacts_record_add_child_record(__contactHandle, _contacts_contact.company, companyHandle);
1030 case CONTACT_PROPERTY_ID_NOTE:
1032 contacts_record_h noteHandle = null;
1033 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
1036 if (!value.IsEmpty())
1038 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, 0, ¬eHandle);
1040 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(value));
1041 contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
1047 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, 0, ¬eHandle);
1048 if (ret != CONTACTS_ERROR_NONE)
1053 contacts_record_remove_child_record(__contactHandle, _contacts_contact.note, noteHandle);
1054 contacts_record_destroy(noteHandle, true);
1060 if (!value.IsEmpty())
1062 ret = contacts_record_create(_contacts_note._uri, ¬eHandle);
1063 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1065 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(value));
1066 contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
1068 contacts_record_add_child_record(__contactHandle, _contacts_contact.note, noteHandle);
1074 case CONTACT_PROPERTY_ID_RINGTONE:
1076 if (!value.IsEmpty() && !File::IsFileExist(value))
1078 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. The specified ringtone file does not exist.", GetErrorMessage(E_INVALID_ARG));
1079 return E_INVALID_ARG;
1082 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1084 contacts_record_set_str(__contactHandle, _contacts_contact.ringtone_path, pCharArray.get());
1088 case CONTACT_PROPERTY_ID_PHONETIC_FIRST_NAME:
1090 contacts_record_h phoneticNameHandle = null;
1091 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
1094 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
1096 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1097 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_first, pCharArray.get());
1099 if (value.IsEmpty() && IsEmptyName(phoneticNameHandle))
1101 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1102 contacts_record_destroy(phoneticNameHandle, true);
1107 if (!value.IsEmpty())
1109 ret = contacts_record_create(_contacts_name._uri, &phoneticNameHandle);
1110 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1112 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1113 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_first, pCharArray.get());
1115 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1120 case CONTACT_PROPERTY_ID_PHONETIC_LAST_NAME:
1122 contacts_record_h phoneticNameHandle = null;
1123 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
1126 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
1128 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1129 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_last, pCharArray.get());
1131 if (value.IsEmpty() && IsEmptyName(phoneticNameHandle))
1133 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1134 contacts_record_destroy(phoneticNameHandle, true);
1139 if (!value.IsEmpty())
1141 ret = contacts_record_create(_contacts_name._uri, &phoneticNameHandle);
1142 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1144 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1145 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_last, pCharArray.get());
1147 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1152 case CONTACT_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
1154 contacts_record_h phoneticNameHandle = null;
1155 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
1158 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
1160 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1161 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_middle, pCharArray.get());
1163 if (value.IsEmpty() && IsEmptyName(phoneticNameHandle))
1165 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1166 contacts_record_destroy(phoneticNameHandle, true);
1171 if (!value.IsEmpty())
1173 ret = contacts_record_create(_contacts_name._uri, &phoneticNameHandle);
1174 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1176 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1177 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_middle, pCharArray.get());
1179 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1184 case CONTACT_PROPERTY_ID_UID:
1186 if (!value.IsEmpty())
1188 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1189 contacts_record_set_str(__contactHandle, _contacts_contact.uid, pCharArray.get());
1193 contacts_record_set_str(__contactHandle, _contacts_contact.uid, null);
1198 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
1199 return E_INVALID_ARG;
1206 _ContactImpl::SetValue(ContactPropertyId id, const DateTime& value)
1208 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));
1210 unsigned int count = 0;
1212 int ret = CONTACTS_ERROR_NONE;
1216 case CONTACT_PROPERTY_ID_BIRTHDAY:
1220 contacts_record_h eventHandle = null;
1222 __CONVERT_DATETIME_TO_DATE(value, date);
1224 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
1227 for (unsigned int i = 0; i < count; i++)
1229 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
1230 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
1231 if (intValue == CONTACTS_EVENT_TYPE_BIRTH)
1233 contacts_record_set_int(eventHandle, _contacts_event.date, date);
1242 ret = contacts_record_create(_contacts_event._uri, &eventHandle);
1243 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1245 contacts_record_set_int(eventHandle, _contacts_event.type, CONTACTS_EVENT_TYPE_BIRTH);
1246 contacts_record_set_int(eventHandle, _contacts_event.date, date);
1248 contacts_record_add_child_record(__contactHandle, _contacts_contact.event, eventHandle);
1254 case CONTACT_PROPERTY_ID_ANNIVERSARY:
1258 contacts_record_h eventHandle = null;
1260 __CONVERT_DATETIME_TO_DATE(value, date);
1262 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
1265 for (unsigned int i = 0; i < count; i++)
1267 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
1268 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
1269 if (intValue == CONTACTS_EVENT_TYPE_ANNIVERSARY)
1271 contacts_record_set_int(eventHandle, _contacts_event.date, date);
1280 ret = contacts_record_create(_contacts_event._uri, &eventHandle);
1281 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1283 contacts_record_set_int(eventHandle, _contacts_event.type, CONTACTS_EVENT_TYPE_ANNIVERSARY);
1284 contacts_record_set_int(eventHandle, _contacts_event.date, date);
1286 contacts_record_add_child_record(__contactHandle, _contacts_contact.event, eventHandle);
1293 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
1294 return E_INVALID_ARG;
1301 _ContactImpl::AddPhoneNumber(const PhoneNumber& phoneNumber)
1303 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));
1304 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1308 contacts_record_h numberHandle = null;
1310 int ret = contacts_record_create(_contacts_number._uri, &numberHandle);
1311 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1313 __ContactsRecordHandle recordHandle(numberHandle);
1315 switch (_PhoneNumberImpl::GetInstance(phoneNumber)->GetType())
1317 case PHONENUMBER_TYPE_HOME:
1318 type = CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE;
1320 case PHONENUMBER_TYPE_WORK:
1321 type = CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE;
1323 case PHONENUMBER_TYPE_MOBILE:
1324 type = CONTACTS_NUMBER_TYPE_CELL;
1326 case PHONENUMBER_TYPE_HOME_FAX:
1327 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME;
1329 case PHONENUMBER_TYPE_WORK_FAX:
1330 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK;
1332 case PHONENUMBER_TYPE_PAGER:
1333 type = CONTACTS_NUMBER_TYPE_PAGER;
1335 case PHONENUMBER_TYPE_CUSTOM:
1336 type = CONTACTS_NUMBER_TYPE_CUSTOM;
1338 case PHONENUMBER_TYPE_ASSISTANT:
1339 type = CONTACTS_NUMBER_TYPE_ASSISTANT;
1341 case PHONENUMBER_TYPE_OTHER:
1343 type = CONTACTS_NUMBER_TYPE_OTHER;
1347 contacts_record_set_int(numberHandle, _contacts_number.type, type);
1349 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetLabel();
1351 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1352 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1354 contacts_record_set_str(numberHandle, _contacts_number.label, pCharArray.get());
1356 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetPhoneNumber();
1357 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1358 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1360 contacts_record_set_str(numberHandle, _contacts_number.number, pCharArray.get());
1362 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.number, numberHandle);
1363 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1365 recordHandle.Release();
1371 _ContactImpl::AddNickname(const String& nickname)
1373 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));
1374 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1375 contacts_record_h nicknameHandle = null;
1377 int ret = contacts_record_create(_contacts_nickname._uri, &nicknameHandle);
1378 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1380 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(nickname));
1381 SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1383 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
1385 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.nickname, nicknameHandle);
1386 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1392 _ContactImpl::AddNote(const String& note)
1394 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));
1395 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1396 contacts_record_h noteHandle = null;
1398 int ret = contacts_record_create(_contacts_note._uri, ¬eHandle);
1399 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1401 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(note));
1402 SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1404 contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
1406 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.note, noteHandle);
1407 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1413 _ContactImpl::AddEmail(const Email& email)
1415 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));
1416 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1420 contacts_record_h emailHandle = null;
1422 int ret = contacts_record_create(_contacts_email._uri, &emailHandle);
1423 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1425 __ContactsRecordHandle recordHandle(emailHandle);
1427 switch (_EmailImpl::GetInstance(email)->GetType())
1429 case EMAIL_TYPE_PERSONAL:
1430 type = CONTACTS_EMAIL_TYPE_HOME;
1432 case EMAIL_TYPE_WORK:
1433 type = CONTACTS_EMAIL_TYPE_WORK;
1435 case EMAIL_TYPE_CUSTOM:
1436 type = CONTACTS_EMAIL_TYPE_CUSTOM;
1438 case EMAIL_TYPE_MOBILE:
1439 type = CONTACTS_EMAIL_TYPE_MOBILE;
1441 case EMAIL_TYPE_OTHER:
1444 type = CONTACTS_EMAIL_TYPE_OTHER;
1448 contacts_record_set_int(emailHandle, _contacts_email.type, type);
1450 stringValue = _EmailImpl::GetInstance(email)->GetLabel();
1451 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1452 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1454 contacts_record_set_str(emailHandle, _contacts_email.label, pCharArray.get());
1456 stringValue = _EmailImpl::GetInstance(email)->GetEmail();
1457 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1458 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1460 contacts_record_set_str(emailHandle, _contacts_email.email, pCharArray.get());
1462 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.email, emailHandle);
1463 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1465 recordHandle.Release();
1471 _ContactImpl::AddUrl(const Url& url)
1473 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));
1474 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1478 contacts_record_h urlHandle = null;
1480 int ret = contacts_record_create(_contacts_url._uri, &urlHandle);
1481 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1483 __ContactsRecordHandle recordHandle(urlHandle);
1485 switch (_UrlImpl::GetInstance(url)->GetType())
1487 case URL_TYPE_PERSONAL:
1488 type = CONTACTS_URL_TYPE_HOME;
1491 type = CONTACTS_URL_TYPE_WORK;
1493 case URL_TYPE_CUSTOM:
1494 type = CONTACTS_URL_TYPE_CUSTOM;
1496 case URL_TYPE_OTHER:
1499 type = CONTACTS_URL_TYPE_OTHER;
1504 contacts_record_set_int(urlHandle, _contacts_url.type, type);
1507 stringValue = _UrlImpl::GetInstance(url)->GetLabel();
1508 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1509 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1511 contacts_record_set_str(urlHandle, _contacts_url.label, pCharArray.get());
1514 stringValue = _UrlImpl::GetInstance(url)->GetUrl();
1515 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1516 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1518 contacts_record_set_str(urlHandle, _contacts_url.url, pCharArray.get());
1520 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.url, urlHandle);
1521 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1523 recordHandle.Release();
1529 _ContactImpl::AddAddress(const Address& address)
1531 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));
1532 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1536 contacts_record_h addressHandle = null;
1538 int ret = contacts_record_create(_contacts_address._uri, &addressHandle);
1539 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1541 __ContactsRecordHandle recordHandle(addressHandle);
1543 switch (_AddressImpl::GetInstance(address)->GetType())
1545 case ADDRESS_TYPE_HOME:
1546 type = CONTACTS_ADDRESS_TYPE_HOME;
1548 case ADDRESS_TYPE_WORK:
1549 type = CONTACTS_ADDRESS_TYPE_WORK;
1551 case ADDRESS_TYPE_CUSTOM:
1552 type = CONTACTS_ADDRESS_TYPE_CUSTOM;
1554 case ADDRESS_TYPE_OTHER:
1557 type = CONTACTS_ADDRESS_TYPE_OTHER;
1561 contacts_record_set_int(addressHandle, _contacts_address.type, type);
1563 stringValue = _AddressImpl::GetInstance(address)->GetLabel();
1564 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1565 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1567 contacts_record_set_str(addressHandle, _contacts_address.label, pCharArray.get());
1569 stringValue = _AddressImpl::GetInstance(address)->GetCity();
1570 if (!stringValue.IsEmpty())
1572 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1573 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1575 contacts_record_set_str(addressHandle, _contacts_address.locality, pCharArray.get());
1579 stringValue = _AddressImpl::GetInstance(address)->GetCountry();
1580 if (!stringValue.IsEmpty())
1582 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1583 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1585 contacts_record_set_str(addressHandle, _contacts_address.country, pCharArray.get());
1588 stringValue = _AddressImpl::GetInstance(address)->GetExtended();
1589 if (!stringValue.IsEmpty())
1591 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1592 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1594 contacts_record_set_str(addressHandle, _contacts_address.extended, pCharArray.get());
1597 stringValue = _AddressImpl::GetInstance(address)->GetPostalCode();
1598 if (!stringValue.IsEmpty())
1600 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1601 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1603 contacts_record_set_str(addressHandle, _contacts_address.postal_code, pCharArray.get());
1606 stringValue = _AddressImpl::GetInstance(address)->GetPostOfficeBoxNumber();
1607 if (!stringValue.IsEmpty())
1609 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1610 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1612 contacts_record_set_str(addressHandle, _contacts_address.postbox, pCharArray.get());
1615 stringValue = _AddressImpl::GetInstance(address)->GetState();
1616 if (!stringValue.IsEmpty())
1618 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1619 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1621 contacts_record_set_str(addressHandle, _contacts_address.region, pCharArray.get());
1624 stringValue = _AddressImpl::GetInstance(address)->GetStreet();
1625 if (!stringValue.IsEmpty())
1627 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1628 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1630 contacts_record_set_str(addressHandle, _contacts_address.street, pCharArray.get());
1633 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.address, addressHandle);
1634 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1636 recordHandle.Release();
1642 _ContactImpl::AddImAddress(const ImAddress& imAddress)
1644 SysTryReturn(NID_SCL, !imAddress.GetImAddress().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%] Invalid argument is used. The imAddress is empty.", GetErrorMessage(E_INVALID_ARG));
1645 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1649 contacts_record_h messengerHandle = null;
1651 std::unique_ptr<char[]> pCharArray(null);
1653 int ret = contacts_record_create(_contacts_messenger._uri, &messengerHandle);
1654 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1656 __ContactsRecordHandle recordHandle(messengerHandle);
1658 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetServiceProviderName();
1660 if (stringValue == IM_ADDRESS_GOOGLE_TALK)
1662 type = CONTACTS_MESSENGER_TYPE_GOOGLE;
1664 else if (stringValue == IM_ADDRESS_MSN)
1666 type = CONTACTS_MESSENGER_TYPE_WLM;
1668 else if (stringValue == IM_ADDRESS_ICQ)
1670 type = CONTACTS_MESSENGER_TYPE_ICQ;
1672 else if (stringValue == IM_ADDRESS_AIM)
1674 type = CONTACTS_MESSENGER_TYPE_AIM;
1676 else if (stringValue == IM_ADDRESS_YAHOO)
1678 type = CONTACTS_MESSENGER_TYPE_YAHOO;
1680 else if (stringValue == IM_ADDRESS_QQ)
1682 type = CONTACTS_MESSENGER_TYPE_QQ;
1684 else if (stringValue == IM_ADDRESS_SKYPE)
1686 type = CONTACTS_MESSENGER_TYPE_SKYPE;
1688 else if (stringValue == IM_ADDRESS_JABBER)
1690 type = CONTACTS_MESSENGER_TYPE_JABBER;
1694 type = CONTACTS_MESSENGER_TYPE_CUSTOM;
1697 contacts_record_set_int(messengerHandle, _contacts_messenger.type, type);
1698 if (type == CONTACTS_MESSENGER_TYPE_CUSTOM)
1700 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1701 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1703 contacts_record_set_str(messengerHandle, _contacts_messenger.label, pCharArray.get());
1706 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetImAddress();
1707 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1708 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1710 contacts_record_set_str(messengerHandle, _contacts_messenger.im_id, pCharArray.get());
1712 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.messenger, messengerHandle);
1713 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1715 recordHandle.Release();
1720 _ContactImpl::AddRelationship(const Relationship& relationship)
1722 SysTryReturn(NID_SCL, !relationship.GetRelativeName().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%] Invalid argument is used. The relationship is empty.", GetErrorMessage(E_INVALID_ARG));
1723 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1726 contacts_record_h relationshipHandle = null;
1728 int ret = contacts_record_create(_contacts_relationship._uri, &relationshipHandle);
1729 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1731 __ContactsRecordHandle recordHandle(relationshipHandle);
1733 switch (relationship.GetType())
1735 case CONTACT_RELATIONSHIP_TYPE_ASSISTANT:
1736 intValue = CONTACTS_RELATIONSHIP_TYPE_ASSISTANT;
1738 case CONTACT_RELATIONSHIP_TYPE_BROTHER:
1739 intValue = CONTACTS_RELATIONSHIP_TYPE_BROTHER;
1741 case CONTACT_RELATIONSHIP_TYPE_CHILD:
1742 intValue = CONTACTS_RELATIONSHIP_TYPE_CHILD;
1744 case CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
1745 intValue = CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER;
1747 case CONTACT_RELATIONSHIP_TYPE_FATHER:
1748 intValue = CONTACTS_RELATIONSHIP_TYPE_FATHER;
1750 case CONTACT_RELATIONSHIP_TYPE_FRIEND:
1751 intValue = CONTACTS_RELATIONSHIP_TYPE_FRIEND;
1753 case CONTACT_RELATIONSHIP_TYPE_MANAGER:
1754 intValue = CONTACTS_RELATIONSHIP_TYPE_MANAGER;
1756 case CONTACT_RELATIONSHIP_TYPE_MOTHER:
1757 intValue = CONTACTS_RELATIONSHIP_TYPE_MOTHER;
1759 case CONTACT_RELATIONSHIP_TYPE_PARENT:
1760 intValue = CONTACTS_RELATIONSHIP_TYPE_PARENT;
1762 case CONTACT_RELATIONSHIP_TYPE_PARTNER:
1763 intValue = CONTACTS_RELATIONSHIP_TYPE_PARTNER;
1765 case CONTACT_RELATIONSHIP_TYPE_REFERRED_BY:
1766 intValue = CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY;
1768 case CONTACT_RELATIONSHIP_TYPE_RELATIVE:
1769 intValue = CONTACTS_RELATIONSHIP_TYPE_RELATIVE;
1771 case CONTACT_RELATIONSHIP_TYPE_SISTER:
1772 intValue = CONTACTS_RELATIONSHIP_TYPE_SISTER;
1774 case CONTACT_RELATIONSHIP_TYPE_SPOUSE:
1775 intValue = CONTACTS_RELATIONSHIP_TYPE_SPOUSE;
1777 case CONTACT_RELATIONSHIP_TYPE_CUSTOM:
1778 intValue = CONTACTS_RELATIONSHIP_TYPE_CUSTOM;
1781 intValue = CONTACTS_RELATIONSHIP_TYPE_OTHER;
1786 contacts_record_set_int(relationshipHandle, _contacts_relationship.type, intValue);
1789 String stringValue = relationship.GetLabel();
1790 if (!stringValue.IsEmpty())
1792 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1793 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1795 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, pCharArray.get());
1799 stringValue = relationship.GetRelativeName();
1800 if (!stringValue.IsEmpty())
1802 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1803 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1805 contacts_record_set_str(relationshipHandle, _contacts_relationship.name, pCharArray.get());
1808 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.relationship, relationshipHandle);
1809 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1811 recordHandle.Release();
1818 _ContactImpl::AddEvent(const ContactEvent& event)
1820 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1821 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));
1826 contacts_record_h eventHandle = null;
1828 int ret = contacts_record_create(_contacts_event._uri, &eventHandle);
1829 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1831 __ContactsRecordHandle recordHandle(eventHandle);
1833 switch (event.GetType())
1835 case CONTACT_EVENT_TYPE_ANNIVERSARY:
1836 type = CONTACTS_EVENT_TYPE_ANNIVERSARY;
1838 case CONTACT_EVENT_TYPE_BIRTHDAY:
1839 type = CONTACTS_EVENT_TYPE_BIRTH;
1841 case CONTACT_EVENT_TYPE_CUSTOM:
1842 type = CONTACTS_EVENT_TYPE_CUSTOM;
1844 case CONTACT_EVENT_TYPE_OTHER:
1847 type = CONTACTS_EVENT_TYPE_OTHER;
1852 contacts_record_set_int(eventHandle, _contacts_event.type, type);
1855 stringValue = event.GetLabel();
1856 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1857 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1859 contacts_record_set_str(eventHandle, _contacts_event.label, pCharArray.get());
1862 DateTime dateValue = event.GetDate();
1863 intValue = dateValue.GetYear()*10000 + dateValue.GetMonth()*100 + dateValue.GetDay();
1864 contacts_record_set_int(eventHandle, _contacts_event.date, intValue);
1866 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.event, eventHandle);
1867 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1869 recordHandle.Release();
1875 _ContactImpl::AddOrganization(const Organization& organization)
1877 SysTryReturn(NID_SCL
1878 , !organization.GetName().IsEmpty() ||
1879 !organization.GetJobTitle().IsEmpty() ||
1880 !organization.GetDepartment().IsEmpty() ||
1881 !organization.GetRole().IsEmpty() ||
1882 !organization.GetAgent().IsEmpty() ||
1883 !organization.GetDescription().IsEmpty() ||
1884 !organization.GetLocation().IsEmpty() ||
1885 !organization.GetPhoneticName().IsEmpty() ||
1886 !organization.GetLogoPath().IsEmpty()
1887 ,E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The organization is empty.", GetErrorMessage(E_INVALID_ARG));
1888 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1890 contacts_record_h organizationHandle = null;
1892 int ret = contacts_record_create(_contacts_company._uri, &organizationHandle);
1893 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1895 __ContactsRecordHandle recordHandle(organizationHandle);
1898 String stringValue = organization.GetName();
1899 if (!stringValue.IsEmpty())
1901 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1902 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1904 contacts_record_set_str(organizationHandle, _contacts_company.name, pCharArray.get());
1908 stringValue = organization.GetJobTitle();
1909 if (!stringValue.IsEmpty())
1911 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1912 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1914 contacts_record_set_str(organizationHandle, _contacts_company.job_title, pCharArray.get());
1918 stringValue = organization.GetDepartment();
1919 if (!stringValue.IsEmpty())
1921 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1922 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1924 contacts_record_set_str(organizationHandle, _contacts_company.department, pCharArray.get());
1928 stringValue = organization.GetRole();
1929 if (!stringValue.IsEmpty())
1931 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1932 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1934 contacts_record_set_str(organizationHandle, _contacts_company.role, pCharArray.get());
1938 stringValue = organization.GetAgent();
1939 if (!stringValue.IsEmpty())
1941 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1942 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1944 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, pCharArray.get());
1950 switch (organization.GetType())
1952 case ORGANIZATION_TYPE_WORK:
1953 type = CONTACTS_COMPANY_TYPE_WORK;
1955 case ORGANIZATION_TYPE_CUSTOM:
1956 type = CONTACTS_COMPANY_TYPE_CUSTOM;
1958 case ORGANIZATION_TYPE_OTHER:
1961 type = CONTACTS_COMPANY_TYPE_OTHER;
1965 contacts_record_set_int(organizationHandle, _contacts_company.type, type);
1968 stringValue = organization.GetLabel();
1969 if (!stringValue.IsEmpty())
1971 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1972 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1974 contacts_record_set_str(organizationHandle, _contacts_company.label, pCharArray.get());
1978 stringValue = organization.GetDescription();
1979 if (!stringValue.IsEmpty())
1981 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1982 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1984 contacts_record_set_str(organizationHandle, _contacts_company.description, pCharArray.get());
1988 stringValue = organization.GetLocation();
1989 if (!stringValue.IsEmpty())
1991 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1992 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1994 contacts_record_set_str(organizationHandle, _contacts_company.location, pCharArray.get());
1998 stringValue = organization.GetPhoneticName();
1999 if (!stringValue.IsEmpty())
2001 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2002 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2004 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, pCharArray.get());
2008 if (_OrganizationImpl::GetInstance(organization)->IsLogoPathChanged() == true)
2010 stringValue = organization.GetLogoPath();
2011 if (!stringValue.IsEmpty())
2013 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2014 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2016 contacts_record_set_str(organizationHandle, _contacts_company.logo, pCharArray.get());
2020 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.company, organizationHandle);
2021 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2023 recordHandle.Release();
2029 _ContactImpl::RemoveAt(ContactMultiPropertyId id, int index)
2031 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);
2033 unsigned int count = 0;
2034 contacts_record_h recordHandle = null;
2038 case CONTACT_MPROPERTY_ID_PHONE_NUMBERS:
2039 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
2040 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);
2042 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.number, index, &recordHandle);
2043 contacts_record_remove_child_record(__contactHandle, _contacts_contact.number, recordHandle);
2044 contacts_record_destroy(recordHandle, true);
2047 case CONTACT_MPROPERTY_ID_EMAILS:
2048 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
2049 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);
2051 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.email, index, &recordHandle);
2052 contacts_record_remove_child_record(__contactHandle, _contacts_contact.email, recordHandle);
2053 contacts_record_destroy(recordHandle, true);
2056 case CONTACT_MPROPERTY_ID_URLS:
2057 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
2058 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of urls %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2060 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.url, index, &recordHandle);
2061 contacts_record_remove_child_record(__contactHandle, _contacts_contact.url, recordHandle);
2062 contacts_record_destroy(recordHandle, true);
2065 case CONTACT_MPROPERTY_ID_ADDRESSES:
2066 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
2067 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);
2069 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.address, index, &recordHandle);
2070 contacts_record_remove_child_record(__contactHandle, _contacts_contact.address, recordHandle);
2071 contacts_record_destroy(recordHandle, true);
2074 case CONTACT_MPROPERTY_ID_IMADDRESSES:
2075 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
2076 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);
2078 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.messenger, index, &recordHandle);
2079 contacts_record_remove_child_record(__contactHandle, _contacts_contact.messenger, recordHandle);
2080 contacts_record_destroy(recordHandle, true);
2083 case CONTACT_MPROPERTY_ID_ORGANIZATIONS:
2084 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
2085 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);
2087 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, index, &recordHandle);
2088 contacts_record_remove_child_record(__contactHandle, _contacts_contact.company, recordHandle);
2089 contacts_record_destroy(recordHandle, true);
2092 case CONTACT_MPROPERTY_ID_EVENTS:
2093 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
2094 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);
2096 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, index, &recordHandle);
2097 contacts_record_remove_child_record(__contactHandle, _contacts_contact.event, recordHandle);
2098 contacts_record_destroy(recordHandle, true);
2101 case CONTACT_MPROPERTY_ID_RELATIONSHIPS:
2102 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.relationship, &count);
2103 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);
2105 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.relationship, index, &recordHandle);
2106 contacts_record_remove_child_record(__contactHandle, _contacts_contact.relationship, recordHandle);
2107 contacts_record_destroy(recordHandle, true);
2110 case CONTACT_MPROPERTY_ID_NOTES:
2111 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
2112 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);
2114 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, index, &recordHandle);
2115 contacts_record_remove_child_record(__contactHandle, _contacts_contact.note, recordHandle);
2116 contacts_record_destroy(recordHandle, true);
2119 case CONTACT_MPROPERTY_ID_NICKNAMES:
2120 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
2121 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);
2123 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, index, &recordHandle);
2124 contacts_record_remove_child_record(__contactHandle, _contacts_contact.nickname, recordHandle);
2125 contacts_record_destroy(recordHandle, true);
2129 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
2130 return E_INVALID_ARG;
2137 _ContactImpl::GetValuesN(const ContactMultiPropertyId id)
2139 IList* pList = null;
2141 SetLastResult(E_SUCCESS);
2145 case CONTACT_MPROPERTY_ID_PHONE_NUMBERS:
2146 pList = GetPhoneNumbersN();
2149 case CONTACT_MPROPERTY_ID_EMAILS:
2150 pList = GetEmailsN();
2153 case CONTACT_MPROPERTY_ID_URLS:
2157 case CONTACT_MPROPERTY_ID_ADDRESSES:
2158 pList = GetAddressesN();
2161 case CONTACT_MPROPERTY_ID_IMADDRESSES:
2162 pList = GetImAddressesN();
2165 case CONTACT_MPROPERTY_ID_ORGANIZATIONS:
2166 pList = GetOrganizationsN();
2169 case CONTACT_MPROPERTY_ID_EVENTS:
2170 pList = GetEventsN();
2173 case CONTACT_MPROPERTY_ID_RELATIONSHIPS:
2174 pList = GetRelationshipsN();
2177 case CONTACT_MPROPERTY_ID_NOTES:
2178 pList = GetNotesN();
2181 case CONTACT_MPROPERTY_ID_NICKNAMES:
2182 pList = GetNicknamesN();
2185 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
2189 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2195 _ContactImpl::SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber)
2197 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);
2198 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));
2199 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2201 unsigned int count = 0;
2202 contacts_record_h recordHandle = null;
2207 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
2208 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);
2210 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.number, index, &recordHandle);
2213 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetLabel();
2215 switch (_PhoneNumberImpl::GetInstance(phoneNumber)->GetType())
2217 case PHONENUMBER_TYPE_HOME:
2218 type = CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE;
2220 case PHONENUMBER_TYPE_WORK:
2221 type = CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE;
2223 case PHONENUMBER_TYPE_MOBILE:
2224 type = CONTACTS_NUMBER_TYPE_CELL;
2226 case PHONENUMBER_TYPE_HOME_FAX:
2227 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME;
2229 case PHONENUMBER_TYPE_WORK_FAX:
2230 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK;
2232 case PHONENUMBER_TYPE_PAGER:
2233 type = CONTACTS_NUMBER_TYPE_PAGER;
2235 case PHONENUMBER_TYPE_CUSTOM:
2236 type = CONTACTS_NUMBER_TYPE_CUSTOM;
2238 case PHONENUMBER_TYPE_ASSISTANT:
2239 type = CONTACTS_NUMBER_TYPE_ASSISTANT;
2241 case PHONENUMBER_TYPE_OTHER:
2242 contacts_record_get_int(recordHandle, _contacts_number.type, &oriType);
2244 if (oriType == (CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE)
2245 || oriType == (CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE)
2246 || oriType == CONTACTS_NUMBER_TYPE_CELL
2247 || oriType == (CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME)
2248 || oriType == (CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK)
2249 || oriType == CONTACTS_NUMBER_TYPE_PAGER)
2251 type = CONTACTS_NUMBER_TYPE_OTHER;
2253 else if (oriType == CONTACTS_NUMBER_TYPE_CUSTOM)
2255 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
2257 char* pCharValue = null;
2259 contacts_record_get_str_p(recordHandle, _contacts_number.label, &pCharValue);
2261 stringValue = pCharValue;
2262 type = CONTACTS_NUMBER_TYPE_CUSTOM;
2267 type = CONTACTS_NUMBER_TYPE_OTHER;
2270 else if (oriType == CONTACTS_NUMBER_TYPE_ASSISTANT)
2272 if (_AppInfo::GetApiVersion() < _API_VERSION_2_1)
2274 type = CONTACTS_NUMBER_TYPE_ASSISTANT;
2278 type = CONTACTS_NUMBER_TYPE_OTHER;
2287 type = CONTACTS_NUMBER_TYPE_OTHER;
2292 contacts_record_set_int(recordHandle, _contacts_number.type, type);
2295 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2296 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2298 contacts_record_set_str(recordHandle, _contacts_number.label, pCharArray.get());
2301 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetPhoneNumber();
2302 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
2303 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2305 contacts_record_set_str(recordHandle, _contacts_number.number, pCharArray.get());
2311 _ContactImpl::SetNicknameAt(int index, const String& nickname)
2313 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);
2314 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));
2315 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2317 unsigned int count = 0;
2318 contacts_record_h nicknameHandle = null;
2320 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
2321 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);
2323 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, index, &nicknameHandle);
2325 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(nickname));
2326 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2328 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
2334 _ContactImpl::SetNoteAt(int index, const String& note)
2336 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);
2337 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));
2338 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2340 unsigned int count = 0;
2341 contacts_record_h noteHandle = null;
2343 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
2344 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);
2346 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, index, ¬eHandle);
2348 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(note));
2349 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2351 contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
2357 _ContactImpl::SetOrganizationAt(int index, const Organization& organization)
2359 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);
2360 SysTryReturn(NID_SCL
2361 , !organization.GetName().IsEmpty() ||
2362 !organization.GetJobTitle().IsEmpty() ||
2363 !organization.GetDepartment().IsEmpty() ||
2364 !organization.GetRole().IsEmpty() ||
2365 !organization.GetAgent().IsEmpty() ||
2366 !organization.GetDescription().IsEmpty() ||
2367 !organization.GetLocation().IsEmpty() ||
2368 !organization.GetPhoneticName().IsEmpty() ||
2369 !organization.GetLogoPath().IsEmpty()
2370 ,E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The organization is empty.", GetErrorMessage(E_INVALID_ARG));
2371 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2373 unsigned int count = 0;
2374 contacts_record_h organizationHandle = null;
2376 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
2377 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);
2380 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, index, &organizationHandle);
2383 String stringValue = organization.GetName();
2384 if (!stringValue.IsEmpty())
2386 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2387 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2389 contacts_record_set_str(organizationHandle, _contacts_company.name, pCharArray.get());
2393 contacts_record_set_str(organizationHandle, _contacts_company.name, null);
2397 stringValue = organization.GetJobTitle();
2398 if (!stringValue.IsEmpty())
2400 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2401 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2403 contacts_record_set_str(organizationHandle, _contacts_company.job_title, pCharArray.get());
2407 contacts_record_set_str(organizationHandle, _contacts_company.job_title, null);
2411 stringValue = organization.GetDepartment();
2412 if (!stringValue.IsEmpty())
2414 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2415 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2417 contacts_record_set_str(organizationHandle, _contacts_company.department, pCharArray.get());
2421 contacts_record_set_str(organizationHandle, _contacts_company.department, null);
2425 stringValue = organization.GetRole();
2426 if (!stringValue.IsEmpty())
2428 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2429 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2431 contacts_record_set_str(organizationHandle, _contacts_company.role, pCharArray.get());
2435 contacts_record_set_str(organizationHandle, _contacts_company.role, null);
2439 stringValue = organization.GetAgent();
2440 if (!stringValue.IsEmpty())
2442 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2443 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2445 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, pCharArray.get());
2449 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, null);
2455 switch (organization.GetType())
2457 case ORGANIZATION_TYPE_WORK:
2458 type = CONTACTS_COMPANY_TYPE_WORK;
2460 case ORGANIZATION_TYPE_CUSTOM:
2461 type = CONTACTS_COMPANY_TYPE_CUSTOM;
2463 case ORGANIZATION_TYPE_OTHER:
2466 type = CONTACTS_COMPANY_TYPE_OTHER;
2470 contacts_record_set_int(organizationHandle, _contacts_company.type, type);
2473 stringValue = organization.GetLabel();
2474 if (!stringValue.IsEmpty())
2476 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2477 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2479 contacts_record_set_str(organizationHandle, _contacts_company.label, pCharArray.get());
2483 contacts_record_set_str(organizationHandle, _contacts_company.label, null);
2487 stringValue = organization.GetDescription();
2488 if (!stringValue.IsEmpty())
2490 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2491 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2493 contacts_record_set_str(organizationHandle, _contacts_company.description, pCharArray.get());
2497 contacts_record_set_str(organizationHandle, _contacts_company.description, null);
2501 stringValue = organization.GetLocation();
2502 if (!stringValue.IsEmpty())
2504 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2505 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2507 contacts_record_set_str(organizationHandle, _contacts_company.location, pCharArray.get());
2511 contacts_record_set_str(organizationHandle, _contacts_company.location, null);
2515 stringValue = organization.GetPhoneticName();
2516 if (!stringValue.IsEmpty())
2518 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2519 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2521 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, pCharArray.get());
2525 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, null);
2529 if (_OrganizationImpl::GetInstance(organization)->IsLogoPathChanged() == true)
2531 stringValue = organization.GetLogoPath();
2532 if (!stringValue.IsEmpty())
2534 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2535 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2537 contacts_record_set_str(organizationHandle, _contacts_company.logo, pCharArray.get());
2541 contacts_record_set_str(organizationHandle, _contacts_company.logo, null);
2549 _ContactImpl::SetEventAt(int index, const ContactEvent& event)
2551 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);
2552 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2553 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));
2557 unsigned int count = 0;
2559 contacts_record_h eventHandle = null;
2561 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
2562 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);
2564 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, index, &eventHandle);
2566 switch (event.GetType())
2568 case CONTACT_EVENT_TYPE_ANNIVERSARY:
2569 type = CONTACTS_EVENT_TYPE_ANNIVERSARY;
2571 case CONTACT_EVENT_TYPE_BIRTHDAY:
2572 type = CONTACTS_EVENT_TYPE_BIRTH;
2574 case CONTACT_EVENT_TYPE_CUSTOM:
2575 type = CONTACTS_EVENT_TYPE_CUSTOM;
2577 case CONTACT_EVENT_TYPE_OTHER:
2580 type = CONTACTS_EVENT_TYPE_OTHER;
2585 contacts_record_set_int(eventHandle, _contacts_event.type, type);
2588 stringValue = event.GetLabel();
2590 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2591 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2593 contacts_record_set_str(eventHandle, _contacts_event.label, pCharArray.get());
2596 DateTime dateValue = event.GetDate();
2597 intValue = dateValue.GetYear()*10000 + dateValue.GetMonth()*100 + dateValue.GetDay();
2598 contacts_record_set_int(eventHandle, _contacts_event.date, intValue);
2604 _ContactImpl::SetRelationshipAt(int index, const Relationship& relationship)
2606 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);
2607 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));
2608 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2611 unsigned int count = 0;
2612 contacts_record_h relationshipHandle = null;
2614 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.relationship, &count);
2615 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);
2617 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.relationship, index, &relationshipHandle);
2619 switch (relationship.GetType())
2621 case CONTACT_RELATIONSHIP_TYPE_ASSISTANT:
2622 intValue = CONTACTS_RELATIONSHIP_TYPE_ASSISTANT;
2624 case CONTACT_RELATIONSHIP_TYPE_BROTHER:
2625 intValue = CONTACTS_RELATIONSHIP_TYPE_BROTHER;
2627 case CONTACT_RELATIONSHIP_TYPE_CHILD:
2628 intValue = CONTACTS_RELATIONSHIP_TYPE_CHILD;
2630 case CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
2631 intValue = CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER;
2633 case CONTACT_RELATIONSHIP_TYPE_FATHER:
2634 intValue = CONTACTS_RELATIONSHIP_TYPE_FATHER;
2636 case CONTACT_RELATIONSHIP_TYPE_FRIEND:
2637 intValue = CONTACTS_RELATIONSHIP_TYPE_FRIEND;
2639 case CONTACT_RELATIONSHIP_TYPE_MANAGER:
2640 intValue = CONTACTS_RELATIONSHIP_TYPE_MANAGER;
2642 case CONTACT_RELATIONSHIP_TYPE_MOTHER:
2643 intValue = CONTACTS_RELATIONSHIP_TYPE_MOTHER;
2645 case CONTACT_RELATIONSHIP_TYPE_PARENT:
2646 intValue = CONTACTS_RELATIONSHIP_TYPE_PARENT;
2648 case CONTACT_RELATIONSHIP_TYPE_PARTNER:
2649 intValue = CONTACTS_RELATIONSHIP_TYPE_PARTNER;
2651 case CONTACT_RELATIONSHIP_TYPE_REFERRED_BY:
2652 intValue = CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY;
2654 case CONTACT_RELATIONSHIP_TYPE_RELATIVE:
2655 intValue = CONTACTS_RELATIONSHIP_TYPE_RELATIVE;
2657 case CONTACT_RELATIONSHIP_TYPE_SISTER:
2658 intValue = CONTACTS_RELATIONSHIP_TYPE_SISTER;
2660 case CONTACT_RELATIONSHIP_TYPE_SPOUSE:
2661 intValue = CONTACTS_RELATIONSHIP_TYPE_SPOUSE;
2663 case CONTACT_RELATIONSHIP_TYPE_CUSTOM:
2664 intValue = CONTACTS_RELATIONSHIP_TYPE_CUSTOM;
2667 intValue = CONTACTS_RELATIONSHIP_TYPE_OTHER;
2672 contacts_record_set_int(relationshipHandle, _contacts_relationship.type, intValue);
2675 String stringValue = relationship.GetLabel();
2676 if (!stringValue.IsEmpty())
2678 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2679 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2681 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, pCharArray.get());
2685 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, null);
2689 stringValue = relationship.GetRelativeName();
2690 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2691 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2693 contacts_record_set_str(relationshipHandle, _contacts_relationship.name, pCharArray.get());
2699 _ContactImpl::SetEmailAt(int index, const Email& email)
2701 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);
2702 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));
2703 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2705 unsigned int count = 0;
2706 contacts_record_h emailHandle = null;
2711 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
2712 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);
2714 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.email, index, &emailHandle);
2716 stringValue = _EmailImpl::GetInstance(email)->GetLabel();
2718 switch (_EmailImpl::GetInstance(email)->GetType())
2720 case EMAIL_TYPE_PERSONAL:
2721 type = CONTACTS_EMAIL_TYPE_HOME;
2723 case EMAIL_TYPE_WORK:
2724 type = CONTACTS_EMAIL_TYPE_WORK;
2726 case EMAIL_TYPE_CUSTOM:
2727 type = CONTACTS_EMAIL_TYPE_CUSTOM;
2729 case EMAIL_TYPE_MOBILE:
2730 type = CONTACTS_EMAIL_TYPE_MOBILE;
2732 case EMAIL_TYPE_OTHER:
2733 contacts_record_get_int(emailHandle, _contacts_email.type, &oriType);
2734 if (oriType == CONTACTS_EMAIL_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
2736 char* pCharValue = null;
2738 contacts_record_get_str_p(emailHandle, _contacts_email.label, &pCharValue);
2740 stringValue = pCharValue;
2741 type = CONTACTS_EMAIL_TYPE_CUSTOM;
2743 else if (oriType == CONTACTS_EMAIL_TYPE_MOBILE && _AppInfo::GetApiVersion() < _API_VERSION_2_1)
2745 type = CONTACTS_EMAIL_TYPE_MOBILE;
2749 type = CONTACTS_EMAIL_TYPE_OTHER;
2753 type = CONTACTS_EMAIL_TYPE_OTHER;
2758 contacts_record_set_int(emailHandle, _contacts_email.type, type);
2761 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2762 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2764 contacts_record_set_str(emailHandle, _contacts_email.label, pCharArray.get());
2767 stringValue = _EmailImpl::GetInstance(email)->GetEmail();
2768 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
2769 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2771 contacts_record_set_str(emailHandle, _contacts_email.email, pCharArray.get());
2777 _ContactImpl::SetUrlAt(int index, const Url& url)
2779 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);
2780 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));
2781 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2783 unsigned int count = 0;
2784 contacts_record_h recordHandle = null;
2789 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
2790 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);
2792 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.url, index, &recordHandle);
2795 stringValue = _UrlImpl::GetInstance(url)->GetLabel();
2797 switch (_UrlImpl::GetInstance(url)->GetType())
2799 case URL_TYPE_PERSONAL:
2800 type = CONTACTS_URL_TYPE_HOME;
2803 type = CONTACTS_URL_TYPE_WORK;
2805 case URL_TYPE_CUSTOM:
2806 type = CONTACTS_URL_TYPE_CUSTOM;
2808 case URL_TYPE_OTHER:
2809 contacts_record_get_int(recordHandle, _contacts_url.type, &oriType);
2811 if (oriType == CONTACTS_URL_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
2813 char* pCharValue = null;
2815 contacts_record_get_str_p(recordHandle, _contacts_url.label, &pCharValue);
2817 stringValue = pCharValue;
2818 type = CONTACTS_URL_TYPE_CUSTOM;
2822 type = CONTACTS_URL_TYPE_OTHER;
2826 type = CONTACTS_URL_TYPE_OTHER;
2831 contacts_record_set_int(recordHandle, _contacts_url.type, type);
2834 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2835 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2837 contacts_record_set_str(recordHandle, _contacts_url.label, pCharArray.get());
2840 stringValue = _UrlImpl::GetInstance(url)->GetUrl();
2841 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
2842 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2844 contacts_record_set_str(recordHandle, _contacts_url.url, pCharArray.get());
2850 _ContactImpl::SetAddressAt(int index, const Address& address)
2852 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);
2853 SysTryReturn(NID_SCL,
2854 !address.GetCity().IsEmpty() ||
2855 !address.GetCountry().IsEmpty() ||
2856 !address.GetExtended().IsEmpty() ||
2857 !address.GetPostalCode().IsEmpty() ||
2858 !address.GetPostOfficeBoxNumber().IsEmpty() ||
2859 !address.GetState().IsEmpty() ||
2860 !address.GetStreet().IsEmpty(),
2861 E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The address is empty.", GetErrorMessage(E_INVALID_ARG));
2862 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2864 unsigned int count = 0;
2865 contacts_record_h recordHandle = null;
2870 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
2871 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);
2873 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.address, index, &recordHandle);
2875 stringValue = _AddressImpl::GetInstance(address)->GetLabel();
2877 switch (_AddressImpl::GetInstance(address)->GetType())
2879 case ADDRESS_TYPE_HOME:
2880 type = CONTACTS_ADDRESS_TYPE_HOME;
2882 case ADDRESS_TYPE_WORK:
2883 type = CONTACTS_ADDRESS_TYPE_WORK;
2885 case ADDRESS_TYPE_CUSTOM:
2886 type = CONTACTS_ADDRESS_TYPE_CUSTOM;
2888 case ADDRESS_TYPE_OTHER:
2889 contacts_record_get_int(recordHandle, _contacts_address.type, &oriType);
2891 if (oriType == CONTACTS_ADDRESS_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
2893 char* pCharValue = null;
2895 contacts_record_get_str_p(recordHandle, _contacts_address.label, &pCharValue);
2897 stringValue = pCharValue;
2898 type = CONTACTS_ADDRESS_TYPE_CUSTOM;
2902 type = CONTACTS_ADDRESS_TYPE_OTHER;
2906 type = CONTACTS_ADDRESS_TYPE_OTHER;
2911 contacts_record_set_int(recordHandle, _contacts_address.type, type);
2914 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2915 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2917 contacts_record_set_str(recordHandle, _contacts_address.label, pCharArray.get());
2920 stringValue = _AddressImpl::GetInstance(address)->GetCity();
2921 if (!stringValue.IsEmpty())
2923 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2924 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2926 contacts_record_set_str(recordHandle, _contacts_address.locality, pCharArray.get());
2930 contacts_record_set_str(recordHandle, _contacts_address.locality, null);
2933 stringValue = _AddressImpl::GetInstance(address)->GetCountry();
2934 if (!stringValue.IsEmpty())
2936 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2937 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2939 contacts_record_set_str(recordHandle, _contacts_address.country, pCharArray.get());
2943 contacts_record_set_str(recordHandle, _contacts_address.country, null);
2946 stringValue = _AddressImpl::GetInstance(address)->GetExtended();
2947 if (!stringValue.IsEmpty())
2949 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2950 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2952 contacts_record_set_str(recordHandle, _contacts_address.extended, pCharArray.get());
2956 contacts_record_set_str(recordHandle, _contacts_address.extended, null);
2959 stringValue = _AddressImpl::GetInstance(address)->GetPostalCode();
2960 if (!stringValue.IsEmpty())
2962 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2963 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2965 contacts_record_set_str(recordHandle, _contacts_address.postal_code, pCharArray.get());
2969 contacts_record_set_str(recordHandle, _contacts_address.postal_code, null);
2972 stringValue = _AddressImpl::GetInstance(address)->GetPostOfficeBoxNumber();
2973 if (!stringValue.IsEmpty())
2975 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2976 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2978 contacts_record_set_str(recordHandle, _contacts_address.postbox, pCharArray.get());
2982 contacts_record_set_str(recordHandle, _contacts_address.postbox, null);
2985 stringValue = _AddressImpl::GetInstance(address)->GetState();
2986 if (!stringValue.IsEmpty())
2988 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2989 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2991 contacts_record_set_str(recordHandle, _contacts_address.region, pCharArray.get());
2995 contacts_record_set_str(recordHandle, _contacts_address.region, null);
2998 stringValue = _AddressImpl::GetInstance(address)->GetStreet();
2999 if (!stringValue.IsEmpty())
3001 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
3002 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3004 contacts_record_set_str(recordHandle, _contacts_address.street, pCharArray.get());
3008 contacts_record_set_str(recordHandle, _contacts_address.street, null);
3015 _ContactImpl::SetImAddressAt(int index, const ImAddress& imAddress)
3017 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);
3018 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));
3019 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3021 unsigned int count = 0;
3022 contacts_record_h messengerHandle = null;
3025 std::unique_ptr<char[]> pCharArray(null);
3027 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
3028 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);
3030 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.messenger, index, &messengerHandle);
3032 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetServiceProviderName();
3034 if (stringValue == IM_ADDRESS_GOOGLE_TALK)
3036 type = CONTACTS_MESSENGER_TYPE_GOOGLE;
3038 else if (stringValue == IM_ADDRESS_MSN)
3040 type = CONTACTS_MESSENGER_TYPE_WLM;
3042 else if (stringValue == IM_ADDRESS_ICQ)
3044 type = CONTACTS_MESSENGER_TYPE_ICQ;
3046 else if (stringValue == IM_ADDRESS_AIM)
3048 type = CONTACTS_MESSENGER_TYPE_AIM;
3050 else if (stringValue == IM_ADDRESS_YAHOO)
3052 type = CONTACTS_MESSENGER_TYPE_YAHOO;
3054 else if (stringValue == IM_ADDRESS_QQ)
3056 type = CONTACTS_MESSENGER_TYPE_QQ;
3058 else if (stringValue == IM_ADDRESS_SKYPE)
3060 type = CONTACTS_MESSENGER_TYPE_SKYPE;
3062 else if (stringValue == IM_ADDRESS_JABBER)
3064 type = CONTACTS_MESSENGER_TYPE_JABBER;
3068 type = CONTACTS_MESSENGER_TYPE_CUSTOM;
3071 contacts_record_set_int(messengerHandle, _contacts_messenger.type, type);
3072 if (type == CONTACTS_MESSENGER_TYPE_CUSTOM)
3074 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
3075 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3077 contacts_record_set_str(messengerHandle, _contacts_messenger.label, pCharArray.get());
3080 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetImAddress();
3081 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
3082 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3084 contacts_record_set_str(messengerHandle, _contacts_messenger.im_id, pCharArray.get());
3090 _ContactImpl::GetMaxLength(ContactPropertyId id)
3094 case CONTACT_PROPERTY_ID_FIRST_NAME:
3096 case CONTACT_PROPERTY_ID_LAST_NAME:
3098 case CONTACT_PROPERTY_ID_DISPLAY_NAME:
3100 case CONTACT_PROPERTY_ID_NICK_NAME:
3102 case CONTACT_PROPERTY_ID_MIDDLE_NAME:
3103 return MAX_CONTACT_NAME_LENGTH;
3105 case CONTACT_PROPERTY_ID_THUMBNAIL:
3108 case CONTACT_PROPERTY_ID_JOB_TITLE:
3109 return MAX_CONTACT_JOB_TITLE_LENGTH;
3111 case CONTACT_PROPERTY_ID_COMPANY:
3112 return MAX_CONTACT_COMPANY_LENGTH;
3114 case CONTACT_PROPERTY_ID_NOTE:
3115 return MAX_CONTACT_NOTE_LENGTH;
3117 case CONTACT_PROPERTY_ID_RINGTONE:
3120 case CONTACT_PROPERTY_ID_PHONETIC_FIRST_NAME:
3122 case CONTACT_PROPERTY_ID_PHONETIC_LAST_NAME:
3124 case CONTACT_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
3125 return MAX_CONTACT_NAME_LENGTH;
3133 _ContactImpl::GetOrganizationsN(void) const
3135 result r = E_SUCCESS;
3136 contacts_record_h organizationHandle = null;
3137 int ret = CONTACTS_ERROR_NONE;
3138 char* pCharValue = null;
3140 unsigned int count = 0;
3141 std::unique_ptr<Organization> pOrganization(null);
3143 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3144 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3146 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
3148 r = pList->Construct(count);
3149 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3151 for (unsigned int i = 0; i < count; i++)
3153 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, i, &organizationHandle);
3154 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
3156 pOrganization.reset(new (std::nothrow) Organization());
3157 SysTryReturn(NID_SCL, pOrganization != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3160 contacts_record_get_str_p(organizationHandle, _contacts_company.name, &pCharValue);
3161 pOrganization->SetName(pCharValue);
3164 contacts_record_get_str_p(organizationHandle, _contacts_company.job_title, &pCharValue);
3165 pOrganization->SetJobTitle(pCharValue);
3168 contacts_record_get_str_p(organizationHandle, _contacts_company.department, &pCharValue);
3169 pOrganization->SetDepartment(pCharValue);
3172 contacts_record_get_str_p(organizationHandle, _contacts_company.role, &pCharValue);
3173 pOrganization->SetRole(pCharValue);
3176 contacts_record_get_str_p(organizationHandle, _contacts_company.assistant_name, &pCharValue);
3177 pOrganization->SetAgent(pCharValue);
3180 contacts_record_get_int(organizationHandle, _contacts_company.type, &intValue);
3183 case CONTACTS_COMPANY_TYPE_WORK:
3184 pOrganization->SetType(ORGANIZATION_TYPE_WORK);
3186 case CONTACTS_COMPANY_TYPE_CUSTOM:
3187 pOrganization->SetType(ORGANIZATION_TYPE_CUSTOM);
3189 case CONTACTS_COMPANY_TYPE_OTHER:
3192 pOrganization->SetType(ORGANIZATION_TYPE_OTHER);
3197 contacts_record_get_str_p(organizationHandle, _contacts_company.label, &pCharValue);
3198 pOrganization->SetLabel(pCharValue);
3201 contacts_record_get_str_p(organizationHandle, _contacts_company.description, &pCharValue);
3202 pOrganization->SetDescription(pCharValue);
3205 contacts_record_get_str_p(organizationHandle, _contacts_company.location, &pCharValue);
3206 pOrganization->SetLocation(pCharValue);
3209 contacts_record_get_str_p(organizationHandle, _contacts_company.phonetic_name, &pCharValue);
3210 pOrganization->SetPhoneticName(pCharValue);
3213 contacts_record_get_str_p(organizationHandle, _contacts_company.logo, &pCharValue);
3214 _OrganizationImpl::GetInstance(*pOrganization)->SetLogoPath(pCharValue);
3216 r = pList->Add(*pOrganization);
3217 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3219 pOrganization.release();
3222 return pList.release();
3226 _ContactImpl::GetRelationshipsN(void) const
3228 result r = E_SUCCESS;
3229 contacts_record_h relationshipHandle = null;
3230 int ret = CONTACTS_ERROR_NONE;
3232 char* pCharValue = null;
3233 unsigned int count = 0;
3234 std::unique_ptr<Relationship> pRelationship(null);
3236 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3237 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3239 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.relationship, &count);
3241 r = pList->Construct(count);
3242 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3244 for (unsigned int i = 0; i < count; i++)
3246 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.relationship, i, &relationshipHandle);
3247 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
3249 pRelationship.reset(new (std::nothrow) Relationship());
3250 SysTryReturn(NID_SCL, pRelationship != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3253 contacts_record_get_int(relationshipHandle, _contacts_relationship.type, &intValue);
3256 case CONTACTS_RELATIONSHIP_TYPE_ASSISTANT:
3257 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_ASSISTANT);
3259 case CONTACTS_RELATIONSHIP_TYPE_BROTHER:
3260 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_BROTHER);
3262 case CONTACTS_RELATIONSHIP_TYPE_CHILD:
3263 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_CHILD);
3265 case CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
3266 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER);
3268 case CONTACTS_RELATIONSHIP_TYPE_FATHER:
3269 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_FATHER);
3271 case CONTACTS_RELATIONSHIP_TYPE_FRIEND:
3272 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_FRIEND);
3274 case CONTACTS_RELATIONSHIP_TYPE_MANAGER:
3275 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_MANAGER);
3277 case CONTACTS_RELATIONSHIP_TYPE_MOTHER:
3278 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_MOTHER);
3280 case CONTACTS_RELATIONSHIP_TYPE_PARENT:
3281 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_PARENT);
3283 case CONTACTS_RELATIONSHIP_TYPE_PARTNER:
3284 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_PARTNER);
3286 case CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY:
3287 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_REFERRED_BY);
3289 case CONTACTS_RELATIONSHIP_TYPE_RELATIVE:
3290 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_RELATIVE);
3292 case CONTACTS_RELATIONSHIP_TYPE_SISTER:
3293 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_SISTER);
3295 case CONTACTS_RELATIONSHIP_TYPE_SPOUSE:
3296 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_SPOUSE);
3298 case CONTACTS_RELATIONSHIP_TYPE_CUSTOM:
3301 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_CUSTOM);
3306 contacts_record_get_str_p(relationshipHandle, _contacts_relationship.label, &pCharValue);
3307 pRelationship->SetLabel(pCharValue);
3310 contacts_record_get_str_p(relationshipHandle, _contacts_relationship.name, &pCharValue);
3311 pRelationship->SetRelativeName(pCharValue);
3313 r = pList->Add(*pRelationship);
3314 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3316 pRelationship.release();
3319 return pList.release();
3323 _ContactImpl::GetEventsN(void) const
3325 result r = E_SUCCESS;
3326 char* pCharValue = null;
3328 unsigned int count = 0;
3329 contacts_record_h eventHandle = null;
3330 std::unique_ptr<ContactEvent> pEvent(null);
3332 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3333 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3335 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
3337 r = pList->Construct(count);
3338 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3340 for (unsigned int i = 0; i < count; i++)
3342 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
3344 pEvent.reset(new (std::nothrow) ContactEvent());
3345 SysTryReturn(NID_SCL, pEvent != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3348 contacts_record_get_str_p(eventHandle, _contacts_event.label, &pCharValue);
3349 pEvent->SetLabel(pCharValue);
3352 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
3355 case CONTACTS_EVENT_TYPE_BIRTH:
3356 pEvent->SetType(CONTACT_EVENT_TYPE_BIRTHDAY);
3358 case CONTACTS_EVENT_TYPE_ANNIVERSARY:
3359 pEvent->SetType(CONTACT_EVENT_TYPE_ANNIVERSARY);
3361 case CONTACTS_URL_TYPE_CUSTOM:
3362 pEvent->SetType(CONTACT_EVENT_TYPE_CUSTOM);
3365 pEvent->SetType(CONTACT_EVENT_TYPE_OTHER);
3371 contacts_record_get_int(eventHandle, _contacts_event.date, &intValue);
3372 __CONVERT_DATE_TO_DATETIME(intValue, dateTime);
3373 pEvent->SetDate(dateTime);
3375 pList->Add(*pEvent);
3376 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3381 return pList.release();
3385 _ContactImpl::GetNotesN(void) const
3387 result r = E_SUCCESS;
3388 char* pCharValue = null;
3389 unsigned int count = 0;
3390 contacts_record_h noteHandle = null;
3391 std::unique_ptr<String> pNote(null);
3393 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3394 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3396 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
3398 r = pList->Construct(count);
3399 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3401 for (unsigned int i = 0; i < count; i++)
3403 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, i, ¬eHandle);
3405 contacts_record_get_str_p(noteHandle, _contacts_note.note, &pCharValue);
3407 pNote.reset(new (std::nothrow) String(pCharValue));
3408 SysTryReturn(NID_SCL, pNote != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3411 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3416 return pList.release();
3420 _ContactImpl::GetNicknamesN(void) const
3422 result r = E_SUCCESS;
3423 char* pCharValue = null;
3424 unsigned int count = 0;
3425 contacts_record_h nicknameHandle = null;
3426 std::unique_ptr<String> pNickname(null);
3428 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3429 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3431 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
3433 r = pList->Construct(count);
3434 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3436 for (unsigned int i = 0; i < count; i++)
3438 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, i, &nicknameHandle);
3440 contacts_record_get_str_p(nicknameHandle, _contacts_nickname.name, &pCharValue);
3442 pNickname.reset(new (std::nothrow) String(pCharValue));
3443 SysTryReturn(NID_SCL, pNickname != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3445 pList->Add(*pNickname);
3446 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3448 pNickname.release();
3451 return pList.release();
3455 _ContactImpl::GetPhoneNumbersN(void) const
3457 result r = E_SUCCESS;
3458 unsigned int count = 0;
3459 contacts_record_h numberHandle = null;
3461 char* pCharValue = null;
3462 PhoneNumberType type = PHONENUMBER_TYPE_HOME;
3463 std::unique_ptr<PhoneNumber> pPhoneNumber(null);
3465 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3466 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3469 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
3471 contacts_record_get_int(__contactHandle, _contacts_contact.id, &intValue);
3473 r = pList->Construct(count);
3474 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3476 for (unsigned int i = 0; i < count; i++)
3478 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.number, i, &numberHandle);
3480 pPhoneNumber.reset(new (std::nothrow) PhoneNumber());
3481 SysTryReturn(NID_SCL, pPhoneNumber != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3483 contacts_record_get_int(numberHandle, _contacts_number.id, &intValue);
3484 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetRecordId(intValue);
3486 contacts_record_get_str_p(numberHandle, _contacts_number.label, &pCharValue);
3487 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetLabel(pCharValue);
3489 contacts_record_get_int(numberHandle, _contacts_number.type, &intValue);
3493 case CONTACTS_NUMBER_TYPE_HOME:
3495 case CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE:
3496 type = PHONENUMBER_TYPE_HOME;
3498 case CONTACTS_NUMBER_TYPE_WORK:
3500 case CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE:
3501 type = PHONENUMBER_TYPE_WORK;
3503 case CONTACTS_NUMBER_TYPE_CELL:
3504 type = PHONENUMBER_TYPE_MOBILE;
3506 case CONTACTS_NUMBER_TYPE_FAX:
3508 case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME:
3509 type = PHONENUMBER_TYPE_HOME_FAX;
3511 case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK:
3512 type = PHONENUMBER_TYPE_WORK_FAX;
3514 case CONTACTS_NUMBER_TYPE_PAGER:
3515 type = PHONENUMBER_TYPE_PAGER;
3517 case CONTACTS_NUMBER_TYPE_CUSTOM:
3518 type = PHONENUMBER_TYPE_CUSTOM;
3520 case CONTACTS_NUMBER_TYPE_ASSISTANT:
3521 if (_AppInfo::GetApiVersion() < _API_VERSION_2_1)
3523 type = PHONENUMBER_TYPE_OTHER;
3527 type = PHONENUMBER_TYPE_ASSISTANT;
3530 case CONTACTS_NUMBER_TYPE_OTHER:
3531 type = PHONENUMBER_TYPE_OTHER;
3534 if (intValue & CONTACTS_NUMBER_TYPE_FAX)
3536 type = PHONENUMBER_TYPE_HOME_FAX;
3538 else if (intValue & CONTACTS_NUMBER_TYPE_CELL)
3540 type = PHONENUMBER_TYPE_MOBILE;
3542 else if (intValue & CONTACTS_NUMBER_TYPE_PAGER)
3544 type = PHONENUMBER_TYPE_PAGER;
3546 else if (intValue & CONTACTS_NUMBER_TYPE_HOME)
3548 type = PHONENUMBER_TYPE_HOME;
3550 else if (intValue & CONTACTS_NUMBER_TYPE_WORK)
3552 type = PHONENUMBER_TYPE_WORK;
3554 else if (intValue & CONTACTS_NUMBER_TYPE_VOICE)
3556 type = PHONENUMBER_TYPE_HOME;
3560 type = PHONENUMBER_TYPE_OTHER;
3565 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetType(type);
3567 contacts_record_get_str_p(numberHandle, _contacts_number.number, &pCharValue);
3568 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetPhoneNumber(pCharValue);
3570 r = pList->Add(*pPhoneNumber);
3571 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3573 pPhoneNumber.release();
3576 return pList.release();
3580 _ContactImpl::GetEmailsN(void) const
3582 result r = E_SUCCESS;
3583 contacts_record_h currentHandle = null;
3584 int ret = CONTACTS_ERROR_NONE;
3586 unsigned int count = 0;
3587 char* pCharValue = null;
3588 EmailType type = EMAIL_TYPE_PERSONAL;
3589 std::unique_ptr<Email> pEmail(null);
3591 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3592 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3594 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
3596 r = pList->Construct(count);
3597 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3599 for (unsigned int i = 0; i < count; i++)
3601 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.email, i, ¤tHandle);
3602 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM))
3604 pEmail.reset(new (std::nothrow) Email());
3605 SysTryReturn(NID_SCL, pEmail != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3607 contacts_record_get_int(currentHandle, _contacts_email.id, &intValue);
3608 _EmailImpl::GetInstance(*pEmail)->SetRecordId(intValue);
3610 contacts_record_get_str_p(currentHandle, _contacts_email.label, &pCharValue);
3611 _EmailImpl::GetInstance(*pEmail)->SetLabel(pCharValue);
3613 contacts_record_get_int(currentHandle, _contacts_email.type, &intValue);
3616 case CONTACTS_EMAIL_TYPE_HOME:
3617 type = EMAIL_TYPE_PERSONAL;
3619 case CONTACTS_EMAIL_TYPE_WORK:
3620 type = EMAIL_TYPE_WORK;
3622 case CONTACTS_EMAIL_TYPE_CUSTOM:
3623 type = EMAIL_TYPE_CUSTOM;
3625 case CONTACTS_EMAIL_TYPE_MOBILE:
3626 if (_AppInfo::GetApiVersion() < _API_VERSION_2_1)
3628 type = EMAIL_TYPE_OTHER;
3632 type = EMAIL_TYPE_MOBILE;
3636 type = EMAIL_TYPE_OTHER;
3640 _EmailImpl::GetInstance(*pEmail)->SetType(type);
3642 contacts_record_get_str_p(currentHandle, _contacts_email.email, &pCharValue);
3643 _EmailImpl::GetInstance(*pEmail)->SetEmail(pCharValue);
3645 r = pList->Add(*pEmail);
3646 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3651 return pList.release();
3655 _ContactImpl::GetUrlsN(void) const
3657 result r = E_SUCCESS;
3658 char* pCharValue = null;
3660 unsigned int count = 0;
3661 UrlType type = URL_TYPE_PERSONAL;
3662 contacts_record_h urlHandle = null;
3663 std::unique_ptr<Url> pUrl(null);
3665 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3666 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3668 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
3670 r = pList->Construct(count);
3671 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3673 for (unsigned int i = 0; i < count; i++)
3675 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.url, i, &urlHandle);
3677 pUrl.reset(new (std::nothrow) Url());
3678 SysTryReturn(NID_SCL, pUrl != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3680 contacts_record_get_str_p(urlHandle, _contacts_url.label, &pCharValue);
3681 pUrl->SetLabel(pCharValue);
3683 contacts_record_get_int(urlHandle, _contacts_url.type, &intValue);
3686 case CONTACTS_URL_TYPE_HOME:
3687 type = URL_TYPE_PERSONAL;
3689 case CONTACTS_URL_TYPE_WORK:
3690 type = URL_TYPE_WORK;
3692 case CONTACTS_URL_TYPE_CUSTOM:
3693 type = URL_TYPE_CUSTOM;
3696 type = URL_TYPE_OTHER;
3700 pUrl->SetType(type);
3702 contacts_record_get_str_p(urlHandle, _contacts_url.url, &pCharValue);
3703 _UrlImpl::GetInstance(*pUrl)->SetUrl(pCharValue);
3706 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3711 return pList.release();
3715 _ContactImpl::GetAddressesN(void) const
3717 result r = E_SUCCESS;
3718 char* pCharValue = null;
3720 unsigned int count = 0;
3721 contacts_record_h addressHandle = 0;
3722 std::unique_ptr<Address> pAddress(null);
3724 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3725 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3727 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
3729 r = pList->Construct(count);
3730 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3733 for (unsigned int i = 0; i < count; i++)
3735 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.address, i, &addressHandle);
3737 pAddress.reset(new (std::nothrow) Address());
3738 SysTryReturn(NID_SCL, pAddress != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3740 contacts_record_get_str_p(addressHandle, _contacts_address.label, &pCharValue);
3741 pAddress->SetLabel(pCharValue);
3743 contacts_record_get_int(addressHandle, _contacts_address.type, &intValue);
3746 case CONTACTS_ADDRESS_TYPE_HOME:
3747 pAddress->SetType(ADDRESS_TYPE_HOME);
3749 case CONTACTS_ADDRESS_TYPE_WORK:
3750 pAddress->SetType(ADDRESS_TYPE_WORK);
3752 case CONTACTS_ADDRESS_TYPE_CUSTOM:
3753 pAddress->SetType(ADDRESS_TYPE_CUSTOM);
3756 pAddress->SetType(ADDRESS_TYPE_OTHER);
3761 contacts_record_get_str_p(addressHandle, _contacts_address.country, &pCharValue);
3762 _AddressImpl::GetInstance(*pAddress)->SetCountry(pCharValue);
3765 contacts_record_get_str_p(addressHandle, _contacts_address.region, &pCharValue);
3766 _AddressImpl::GetInstance(*pAddress)->SetState(pCharValue);
3769 contacts_record_get_str_p(addressHandle, _contacts_address.locality, &pCharValue);
3770 _AddressImpl::GetInstance(*pAddress)->SetCity(pCharValue);
3773 contacts_record_get_str_p(addressHandle, _contacts_address.street, &pCharValue);
3774 _AddressImpl::GetInstance(*pAddress)->SetStreet(pCharValue);
3777 contacts_record_get_str_p(addressHandle, _contacts_address.extended, &pCharValue);
3778 _AddressImpl::GetInstance(*pAddress)->SetExtended(pCharValue);
3781 contacts_record_get_str_p(addressHandle, _contacts_address.postbox, &pCharValue);
3782 _AddressImpl::GetInstance(*pAddress)->SetPostOfficeBoxNumber(pCharValue);
3785 contacts_record_get_str_p(addressHandle, _contacts_address.postal_code, &pCharValue);
3786 _AddressImpl::GetInstance(*pAddress)->SetPostalCode(pCharValue);
3788 r = pList->Add(*pAddress);
3789 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3794 return pList.release();
3798 _ContactImpl::GetImAddressesN(void) const
3800 result r = E_SUCCESS;
3801 char* pCharValue = null;
3803 contacts_record_h messengerHandle = null;
3804 unsigned int count = 0;
3805 std::unique_ptr<ImAddress> pImAddress(null);
3807 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3808 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3810 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
3812 r = pList->Construct(count);
3813 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3816 for (unsigned int i = 0; i < count; i++)
3818 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.messenger, i, &messengerHandle);
3820 pImAddress.reset(new (std::nothrow) ImAddress());
3821 SysTryReturn(NID_SCL, pImAddress != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3823 contacts_record_get_int(messengerHandle, _contacts_messenger.type, &intValue);
3826 case CONTACTS_MESSENGER_TYPE_GOOGLE:
3827 pImAddress->SetServiceProviderName(IM_ADDRESS_GOOGLE_TALK);
3829 case CONTACTS_MESSENGER_TYPE_WLM:
3830 pImAddress->SetServiceProviderName(IM_ADDRESS_MSN);
3832 case CONTACTS_MESSENGER_TYPE_ICQ:
3833 pImAddress->SetServiceProviderName(IM_ADDRESS_ICQ);
3835 case CONTACTS_MESSENGER_TYPE_AIM:
3836 pImAddress->SetServiceProviderName(IM_ADDRESS_AIM);
3838 case CONTACTS_MESSENGER_TYPE_YAHOO:
3839 pImAddress->SetServiceProviderName(IM_ADDRESS_YAHOO);
3841 case CONTACTS_MESSENGER_TYPE_QQ:
3842 pImAddress->SetServiceProviderName(IM_ADDRESS_QQ);
3844 case CONTACTS_MESSENGER_TYPE_SKYPE:
3845 pImAddress->SetServiceProviderName(IM_ADDRESS_SKYPE);
3847 case CONTACTS_MESSENGER_TYPE_JABBER:
3848 pImAddress->SetServiceProviderName(IM_ADDRESS_JABBER);
3850 case CONTACTS_MESSENGER_TYPE_CUSTOM:
3853 contacts_record_get_str_p(messengerHandle, _contacts_messenger.label, &pCharValue);
3854 pImAddress->SetServiceProviderName(pCharValue);
3858 contacts_record_get_str_p(messengerHandle, _contacts_messenger.im_id, &pCharValue);
3859 _ImAddressImpl::GetInstance(*pImAddress)->SetImAddress(pCharValue);
3861 r = pList->Add(*pImAddress);
3862 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3864 pImAddress.release();
3867 return pList.release();
3871 _ContactImpl::IsEmpty(void) const
3873 char* pCharValue = null;
3874 unsigned int count = 0;
3876 contacts_record_get_str_p(__contactHandle, _contacts_contact.ringtone_path, &pCharValue);
3877 if (pCharValue != null)
3882 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
3888 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
3894 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
3900 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
3906 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
3912 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
3918 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
3924 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
3930 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
3936 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
3942 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
3948 contacts_record_get_str_p(__contactHandle, _contacts_contact.uid, &pCharValue);
3949 if (pCharValue != null)
3958 _ContactImpl::GetAddressbookId(void) const
3960 int addressbookId = 0;
3962 contacts_record_get_int(__contactHandle, _contacts_contact.address_book_id, &addressbookId);
3964 return addressbookId;
3968 _ContactImpl::GetPersonId(void) const
3972 contacts_record_get_int(__contactHandle, _contacts_contact.person_id, &personId);
3978 _ContactImpl::SetAsRemoved(void)
3984 _ContactImpl::IsRemoved(void) const
3990 _ContactImpl::IsFavorite(void) const
3992 bool isFavorite = false;
3993 contacts_record_get_bool(__contactHandle, _contacts_contact.is_favorite, &isFavorite);
3999 _ContactImpl::SetAsFavorite(bool isFavorite)
4001 contacts_record_set_bool(__contactHandle, _contacts_contact.is_favorite, isFavorite);
4005 _ContactImpl::Invalidate(void)
4007 int ret = CONTACTS_ERROR_NONE;
4009 unsigned int count = 0;
4010 char* pCharValue = null;
4012 bool boolValue = false;
4014 contacts_record_h contactHandle = null;
4015 contacts_record_h sourceRecordHandle = null;
4016 contacts_record_h destRecordHandle = null;
4018 ret = contacts_record_create(_contacts_contact._uri, &contactHandle);
4019 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4021 __ContactsRecordHandle recordHandle(contactHandle);
4024 contacts_record_get_bool(sourceRecordHandle, _contacts_contact.is_favorite, &boolValue);
4025 contacts_record_set_bool(destRecordHandle, _contacts_contact.is_favorite, boolValue);
4028 contacts_record_get_str_p(sourceRecordHandle, _contacts_contact.uid, &pCharValue);
4029 contacts_record_set_str(destRecordHandle, _contacts_contact.uid, pCharValue);
4031 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4033 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4034 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
4037 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &sourceRecordHandle);
4039 ret = contacts_record_create(_contacts_name._uri, &destRecordHandle);
4040 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4042 __ContactsRecordHandle nameHandle(destRecordHandle);
4045 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.first, &pCharValue);
4046 contacts_record_set_str(destRecordHandle, _contacts_name.first, pCharValue);
4049 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.last, &pCharValue);
4050 contacts_record_set_str(destRecordHandle, _contacts_name.last, pCharValue);
4053 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.addition, &pCharValue);
4054 contacts_record_set_str(destRecordHandle, _contacts_name.addition, pCharValue);
4057 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.suffix, &pCharValue);
4058 contacts_record_set_str(destRecordHandle, _contacts_name.suffix, pCharValue);
4061 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.prefix, &pCharValue);
4062 contacts_record_set_str(destRecordHandle, _contacts_name.prefix, pCharValue);
4064 // 6. phonetic_first
4065 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_first, &pCharValue);
4066 contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_first, pCharValue);
4069 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_last, &pCharValue);
4070 contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_last, pCharValue);
4072 // 8. phonetic_middle
4073 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_middle, &pCharValue);
4074 contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_middle, pCharValue);
4076 contacts_record_add_child_record(contactHandle, _contacts_contact.name, destRecordHandle);
4078 nameHandle.Release();
4081 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4083 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4084 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
4087 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, 0, &sourceRecordHandle);
4089 ret = contacts_record_create(_contacts_image._uri, &destRecordHandle);
4090 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4092 __ContactsRecordHandle imageHandle(destRecordHandle);
4094 contacts_record_get_int(sourceRecordHandle, _contacts_image.type, &intValue);
4095 contacts_record_set_int(destRecordHandle, _contacts_image.type, intValue);
4097 contacts_record_get_str_p(sourceRecordHandle, _contacts_image.label, &pCharValue);
4098 contacts_record_set_str(destRecordHandle, _contacts_image.label, pCharValue);
4100 contacts_record_get_str_p(sourceRecordHandle, _contacts_image.path, &pCharValue);
4101 contacts_record_set_str(destRecordHandle, _contacts_image.path, pCharValue);
4103 contacts_record_add_child_record(contactHandle, _contacts_contact.image, destRecordHandle);
4105 imageHandle.Release();
4108 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4110 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4111 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
4112 for (i = 0; i < count; i++)
4114 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, i, &sourceRecordHandle);
4116 ret = contacts_record_create(_contacts_company._uri, &destRecordHandle);
4117 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4119 __ContactsRecordHandle companyHandle(destRecordHandle);
4121 contacts_record_get_int(sourceRecordHandle, _contacts_company.type, &intValue);
4122 contacts_record_set_int(destRecordHandle, _contacts_company.type, intValue);
4124 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.name, &pCharValue);
4125 contacts_record_set_str(destRecordHandle, _contacts_company.name, pCharValue);
4127 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.department, &pCharValue);
4128 contacts_record_set_str(destRecordHandle, _contacts_company.department, pCharValue);
4130 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.job_title, &pCharValue);
4131 contacts_record_set_str(destRecordHandle, _contacts_company.job_title, pCharValue);
4133 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.assistant_name, &pCharValue);
4134 contacts_record_set_str(destRecordHandle, _contacts_company.assistant_name, pCharValue);
4136 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.role, &pCharValue);
4137 contacts_record_set_str(destRecordHandle, _contacts_company.role, pCharValue);
4139 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.logo, &pCharValue);
4140 contacts_record_set_str(destRecordHandle, _contacts_company.logo, pCharValue);
4142 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.location, &pCharValue);
4143 contacts_record_set_str(destRecordHandle, _contacts_company.location, pCharValue);
4145 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.description, &pCharValue);
4146 contacts_record_set_str(destRecordHandle, _contacts_company.description, pCharValue);
4148 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.phonetic_name, &pCharValue);
4149 contacts_record_set_str(destRecordHandle, _contacts_company.phonetic_name, pCharValue);
4151 contacts_record_add_child_record(contactHandle, _contacts_contact.company, destRecordHandle);
4153 companyHandle.Release();
4156 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4158 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4159 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
4160 for (i = 0; i < count; i++)
4162 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, i, &sourceRecordHandle);
4164 ret = contacts_record_create(_contacts_note._uri, &destRecordHandle);
4165 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4167 __ContactsRecordHandle noteHandle(destRecordHandle);
4169 contacts_record_get_str_p(sourceRecordHandle, _contacts_note.note, &pCharValue);
4170 contacts_record_set_str(destRecordHandle, _contacts_note.note, pCharValue);
4172 contacts_record_add_child_record(contactHandle, _contacts_contact.note, destRecordHandle);
4174 noteHandle.Release();
4177 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4179 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4180 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
4181 for (i = 0; i < count; i++)
4183 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.number, i, &sourceRecordHandle);
4185 ret = contacts_record_create(_contacts_number._uri, &destRecordHandle);
4186 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4188 __ContactsRecordHandle numberHandle(destRecordHandle);
4190 contacts_record_get_int(sourceRecordHandle, _contacts_number.type, &intValue);
4191 contacts_record_set_int(destRecordHandle, _contacts_number.type, intValue);
4193 contacts_record_get_str_p(sourceRecordHandle, _contacts_number.label, &pCharValue);
4194 contacts_record_set_str(destRecordHandle, _contacts_number.label, pCharValue);
4196 contacts_record_get_str_p(sourceRecordHandle, _contacts_number.number, &pCharValue);
4197 contacts_record_set_str(destRecordHandle, _contacts_number.number, pCharValue);
4199 contacts_record_add_child_record(contactHandle, _contacts_contact.number, destRecordHandle);
4201 numberHandle.Release();
4204 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4206 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4207 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
4208 for (i = 0; i < count; i++)
4210 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.email, i, &sourceRecordHandle);
4212 ret = contacts_record_create(_contacts_email._uri, &destRecordHandle);
4213 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4215 __ContactsRecordHandle emailHandle(destRecordHandle);
4217 contacts_record_get_int(sourceRecordHandle, _contacts_email.type, &intValue);
4218 contacts_record_set_int(destRecordHandle, _contacts_email.type, intValue);
4220 contacts_record_get_str_p(sourceRecordHandle, _contacts_email.label, &pCharValue);
4221 contacts_record_set_str(destRecordHandle, _contacts_email.label, pCharValue);
4223 contacts_record_get_str_p(sourceRecordHandle, _contacts_email.email, &pCharValue);
4224 contacts_record_set_str(destRecordHandle, _contacts_email.email, pCharValue);
4226 contacts_record_add_child_record(contactHandle, _contacts_contact.email, destRecordHandle);
4228 emailHandle.Release();
4232 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4234 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4235 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
4236 for (i = 0; i < count; i++)
4238 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &sourceRecordHandle);
4240 ret = contacts_record_create(_contacts_event._uri, &destRecordHandle);
4241 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4243 __ContactsRecordHandle eventHandle(destRecordHandle);
4245 contacts_record_get_int(sourceRecordHandle, _contacts_event.type, &intValue);
4246 contacts_record_set_int(destRecordHandle, _contacts_event.type, intValue);
4248 contacts_record_get_str_p(sourceRecordHandle, _contacts_event.label, &pCharValue);
4249 contacts_record_set_str(destRecordHandle, _contacts_event.label, pCharValue);
4251 contacts_record_get_int(sourceRecordHandle, _contacts_event.date, &intValue);
4252 contacts_record_set_int(destRecordHandle, _contacts_event.date, intValue);
4254 contacts_record_add_child_record(contactHandle, _contacts_contact.event, destRecordHandle);
4256 eventHandle.Release();
4259 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4261 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4262 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
4263 for (i = 0; i < count; i++)
4265 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.messenger, i, &sourceRecordHandle);
4267 ret = contacts_record_create(_contacts_messenger._uri, &destRecordHandle);
4268 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4270 __ContactsRecordHandle imAddressHandle(destRecordHandle);
4272 contacts_record_get_int(sourceRecordHandle, _contacts_messenger.type, &intValue);
4273 contacts_record_set_int(destRecordHandle, _contacts_messenger.type, intValue);
4275 contacts_record_get_str_p(sourceRecordHandle, _contacts_messenger.label, &pCharValue);
4276 contacts_record_set_str(destRecordHandle, _contacts_messenger.label, pCharValue);
4278 contacts_record_get_str_p(sourceRecordHandle, _contacts_messenger.im_id, &pCharValue);
4279 contacts_record_set_str(destRecordHandle, _contacts_messenger.im_id, pCharValue);
4281 contacts_record_add_child_record(contactHandle, _contacts_contact.messenger, destRecordHandle);
4283 imAddressHandle.Release();
4286 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4288 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4289 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
4290 for (i = 0; i < count; i++)
4292 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.address, i, &sourceRecordHandle);
4294 ret = contacts_record_create(_contacts_address._uri, &destRecordHandle);
4295 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4297 __ContactsRecordHandle addressHandle(destRecordHandle);
4299 contacts_record_get_int(sourceRecordHandle, _contacts_address.type, &intValue);
4300 contacts_record_set_int(destRecordHandle, _contacts_address.type, intValue);
4302 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.label, &pCharValue);
4303 contacts_record_set_str(destRecordHandle, _contacts_address.label, pCharValue);
4305 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.postbox, &pCharValue);
4306 contacts_record_set_str(destRecordHandle, _contacts_address.postbox, pCharValue);
4308 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.extended, &pCharValue);
4309 contacts_record_set_str(destRecordHandle, _contacts_address.extended, pCharValue);
4311 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.street, &pCharValue);
4312 contacts_record_set_str(destRecordHandle, _contacts_address.street, pCharValue);
4314 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.locality, &pCharValue);
4315 contacts_record_set_str(destRecordHandle, _contacts_address.locality, pCharValue);
4317 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.region, &pCharValue);
4318 contacts_record_set_str(destRecordHandle, _contacts_address.region, pCharValue);
4320 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.postal_code, &pCharValue);
4321 contacts_record_set_str(destRecordHandle, _contacts_address.postal_code, pCharValue);
4323 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.country, &pCharValue);
4324 contacts_record_set_str(destRecordHandle, _contacts_address.country, pCharValue);
4326 contacts_record_add_child_record(contactHandle, _contacts_contact.address, destRecordHandle);
4328 addressHandle.Release();
4331 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4333 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4334 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
4335 for (i = 0; i < count; i++)
4337 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.url, i, &sourceRecordHandle);
4339 ret = contacts_record_create(_contacts_url._uri, &destRecordHandle);
4340 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4342 __ContactsRecordHandle urlHandle(destRecordHandle);
4344 contacts_record_get_int(sourceRecordHandle, _contacts_url.type, &intValue);
4345 contacts_record_set_int(destRecordHandle, _contacts_url.type, intValue);
4347 contacts_record_get_str_p(sourceRecordHandle, _contacts_url.label, &pCharValue);
4348 contacts_record_set_str(destRecordHandle, _contacts_url.label, pCharValue);
4350 contacts_record_get_str_p(sourceRecordHandle, _contacts_url.url, &pCharValue);
4351 contacts_record_set_str(destRecordHandle, _contacts_url.url, pCharValue);
4353 contacts_record_add_child_record(contactHandle, _contacts_contact.url, destRecordHandle);
4355 urlHandle.Release();
4358 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4360 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4361 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
4362 for (i = 0; i < count; i++)
4364 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, i, &sourceRecordHandle);
4366 ret = contacts_record_create(_contacts_nickname._uri, &destRecordHandle);
4367 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4369 __ContactsRecordHandle nicknameHandle(destRecordHandle);
4371 contacts_record_get_str_p(sourceRecordHandle, _contacts_nickname.name, &pCharValue);
4372 contacts_record_set_str(destRecordHandle, _contacts_nickname.name, pCharValue);
4374 contacts_record_add_child_record(contactHandle, _contacts_contact.nickname, destRecordHandle);
4376 nicknameHandle.Release();
4379 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4381 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4382 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.relationship, &count);
4383 for (i = 0; i < count; i++)
4385 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.relationship, i, &sourceRecordHandle);
4387 ret = contacts_record_create(_contacts_relationship._uri, &destRecordHandle);
4388 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4390 __ContactsRecordHandle relationshipHandle(destRecordHandle);
4392 contacts_record_get_str_p(sourceRecordHandle, _contacts_relationship.name, &pCharValue);
4393 contacts_record_set_str(destRecordHandle, _contacts_relationship.name, pCharValue);
4395 contacts_record_add_child_record(contactHandle, _contacts_contact.relationship, destRecordHandle);
4397 relationshipHandle.Release();
4400 contacts_record_destroy(__contactHandle, true);
4401 __contactHandle = contactHandle;
4403 __isRemoved = false;
4405 recordHandle.Release();
4411 _ContactImpl::GetInstance(const Contact& contact)
4413 return contact.__pContactImpl;
4417 _ContactImpl::GetInstance(Contact& contact)
4419 return contact.__pContactImpl;