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 <FSclContactAppLaunchData.h>
36 #include <FSclContact.h>
37 #include <FApp_AppInfo.h>
38 #include <FBase_StringConverter.h>
39 #include <FIo_FileImpl.h>
40 #include "FScl_ContactDbConnector.h"
41 #include "FScl_PhoneNumberImpl.h"
42 #include "FScl_ContactImpl.h"
43 #include "FScl_AddressbookUtil.h"
44 #include "FScl_UrlImpl.h"
45 #include "FScl_EmailImpl.h"
46 #include "FScl_AddressImpl.h"
47 #include "FScl_ImAddressImpl.h"
48 #include "FScl_OrganizationImpl.h"
49 #include "FScl_ContactEventImpl.h"
50 #include "FScl_ContactAppLaunchDataImpl.h"
52 using namespace Tizen::App;
53 using namespace Tizen::Base;
54 using namespace Tizen::Base::Utility;
55 using namespace Tizen::Base::Collection;
56 using namespace Tizen::Graphics;
57 using namespace Tizen::Media;
58 using namespace Tizen::Io;
60 namespace Tizen { namespace Social
63 const int __CONTACT_CHANGED_TIME_YEAR_OFFSET = 1900;
64 const int __CONTACT_CHANGED_TIME_MONTH_OFFSET = 1;
66 const int __CONTACT_MOD_YEAR = 10000;
67 const int __CONTACT_MOD_MONTH = 100;
69 #define __PARSE_DATE(date, year, month, day) \
73 year = temp/__CONTACT_MOD_YEAR; \
74 temp -= year*__CONTACT_MOD_YEAR; \
75 month = temp/__CONTACT_MOD_MONTH; \
76 day = temp - month*__CONTACT_MOD_MONTH; \
79 #define __CONVERT_DATE_TO_DATETIME(date, dateTime) \
86 year = temp/__CONTACT_MOD_YEAR; \
87 temp -= year*__CONTACT_MOD_YEAR; \
88 month = temp/__CONTACT_MOD_MONTH; \
89 day = temp - month*__CONTACT_MOD_MONTH; \
90 dateTime.SetValue(year, month, day, 0, 0, 0); \
94 #define __CONVERT_DATETIME_TO_DATE(dateTime, date) \
97 date = dateTime.GetYear()*__CONTACT_MOD_YEAR + dateTime.GetMonth()*__CONTACT_MOD_MONTH + dateTime.GetDay(); \
100 _ContactImpl::_ContactImpl(void)
101 : __contactHandle(null)
104 contacts_record_h contactHandle = null;
106 SysTryReturnVoidResult(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
108 int ret = contacts_record_create(_contacts_contact._uri, &contactHandle);
109 SysTryReturnVoidResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
111 __contactHandle = contactHandle;
114 _ContactImpl::_ContactImpl(const _ContactImpl& rhs)
115 : __contactHandle(null)
117 contacts_record_h contactHandle = null;
119 SysTryReturnVoidResult(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
121 int ret = contacts_record_clone(rhs.__contactHandle, &contactHandle);
122 SysTryReturnVoidResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
124 __contactHandle = contactHandle;
125 __isRemoved = rhs.__isRemoved;
128 _ContactImpl::~_ContactImpl(void)
130 if (__contactHandle != null)
132 contacts_record_destroy(__contactHandle, true);
137 _ContactImpl::operator =(const _ContactImpl& rhs)
144 contacts_record_h contactHandle = null;
146 int ret = contacts_record_clone(rhs.__contactHandle, &contactHandle);
147 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
149 contacts_record_destroy(__contactHandle, true);
150 __contactHandle = contactHandle;
152 __isRemoved = rhs.__isRemoved;
158 _ContactImpl::SetContactRecordHandle(contacts_record_h contactHandle)
160 contacts_record_destroy(__contactHandle, true);
162 __contactHandle = contactHandle;
166 _ContactImpl::GetContactRecordHandle(void) const
168 return __contactHandle;
172 _ContactImpl::SetThumbnailPath(const Tizen::Base::String& filePath)
174 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));
176 String thumbnailPath;
177 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
179 _FileImpl::ConvertVirtualToPhysicalPath(filePath, thumbnailPath);
183 thumbnailPath = filePath;
186 int ret = CONTACTS_ERROR_NONE;
187 unsigned int count = 0;
188 contacts_record_h imageHandle = null;
190 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
193 if (!thumbnailPath.IsEmpty())
195 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(thumbnailPath));
196 SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
198 bool isDefault = false;
200 for (unsigned int i = 0; i < count; i++)
202 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, i, &imageHandle);
203 contacts_record_get_bool(imageHandle, _contacts_image.is_default, &isDefault);
209 contacts_record_set_bool(imageHandle, _contacts_image.is_default, true);
210 contacts_record_set_str(imageHandle, _contacts_image.path, pCharArray.get());
216 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, 0, &imageHandle);
217 if (ret != CONTACTS_ERROR_NONE)
222 contacts_record_remove_child_record(__contactHandle, _contacts_contact.image, imageHandle);
223 contacts_record_destroy(imageHandle, true);
230 if (!thumbnailPath.IsEmpty())
232 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(thumbnailPath));
233 SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
235 int ret = contacts_record_create(_contacts_image._uri, &imageHandle);
236 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
238 contacts_record_set_bool(imageHandle, _contacts_image.is_default, true);
239 contacts_record_set_str(imageHandle, _contacts_image.path, pCharArray.get());
241 contacts_record_add_child_record(__contactHandle, _contacts_contact.image, imageHandle);
249 _ContactImpl::GetThumbnailPath(void) const
251 unsigned int count = 0;
252 bool isDefault = false;
254 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
260 char* pCharValue = null;
261 contacts_record_h imageHandle = null;
263 for (unsigned int i = 0; i < count; i++)
265 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, i, &imageHandle);
266 contacts_record_get_str_p(imageHandle, _contacts_image.path, &pCharValue);
268 contacts_record_get_bool(imageHandle, _contacts_image.is_default, &isDefault);
275 return String(pCharValue);
279 _ContactImpl::GetThumbnailN(void) const
281 unsigned int count = 0;
282 char* pCharValue = null;
283 bool isDefault = false;
284 contacts_record_h imageHandle = null;
288 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
294 for (unsigned int i = 0; i < count; i++)
296 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, i, &imageHandle);
297 contacts_record_get_str_p(imageHandle, _contacts_image.path, &pCharValue);
299 contacts_record_get_bool(imageHandle, _contacts_image.is_default, &isDefault);
306 String thumbnailPath(pCharValue);
307 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
309 _FileImpl::ConvertPhysicalToVirtualPath(pCharValue, thumbnailPath);
313 result r = image.Construct();
314 SysTryReturn(NID_SCL, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
315 SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Failed to construct Image.", GetErrorMessage(E_SYSTEM));
317 ImageFormat imageFormat = image.GetImageFormat(thumbnailPath);
318 SysTryReturn(NID_SCL, GetLastResult() != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
319 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, null, E_SYSTEM, "[%s] Failed to get the format of the thumbnail image.", GetErrorMessage(E_SYSTEM));
321 BitmapPixelFormat bitmapPixelFormat = BITMAP_PIXEL_FORMAT_RGB565;
330 bitmapPixelFormat = BITMAP_PIXEL_FORMAT_RGB565;
333 bitmapPixelFormat = BITMAP_PIXEL_FORMAT_ARGB8888;
336 SysLogException(NID_SCL, E_SYSTEM, "[%s] Unsupported image format.", GetErrorMessage(E_SYSTEM));
340 Bitmap* pBitmap = image.DecodeN(thumbnailPath, bitmapPixelFormat);
341 SysTryReturn(NID_SCL, GetLastResult() != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. ", GetErrorMessage(E_OUT_OF_MEMORY));
342 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred. ", GetErrorMessage(E_SYSTEM));
348 _ContactImpl::GetValue(const ContactPropertyId id, String& value) const
350 unsigned int count = 0;
351 char* pCharValue = null;
355 case CONTACT_PROPERTY_ID_FIRST_NAME:
357 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
360 contacts_record_h nameHandle = null;
362 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
363 contacts_record_get_str_p(nameHandle, _contacts_name.first, &pCharValue);
369 case CONTACT_PROPERTY_ID_LAST_NAME:
371 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
374 contacts_record_h nameHandle = null;
376 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
377 contacts_record_get_str_p(nameHandle, _contacts_name.last, &pCharValue);
383 case CONTACT_PROPERTY_ID_DISPLAY_NAME:
384 contacts_record_get_str_p(__contactHandle, _contacts_contact.display_name, &pCharValue);
387 case CONTACT_PROPERTY_ID_NICK_NAME:
389 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
392 contacts_record_h nicknameHandle = null;
394 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, 0, &nicknameHandle);
395 contacts_record_get_str_p(nicknameHandle, _contacts_nickname.name, &pCharValue);
401 case CONTACT_PROPERTY_ID_MIDDLE_NAME:
403 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
406 contacts_record_h nameHandle = null;
408 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
409 contacts_record_get_str_p(nameHandle, _contacts_name.addition, &pCharValue);
415 case CONTACT_PROPERTY_ID_NAME_PREFIX:
417 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
420 contacts_record_h nameHandle = null;
422 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
423 contacts_record_get_str_p(nameHandle, _contacts_name.prefix, &pCharValue);
429 case CONTACT_PROPERTY_ID_NAME_SUFFIX:
431 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
434 contacts_record_h nameHandle = null;
436 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
437 contacts_record_get_str_p(nameHandle, _contacts_name.suffix, &pCharValue);
443 case CONTACT_PROPERTY_ID_JOB_TITLE:
445 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
448 contacts_record_h companyHandle = null;
450 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
451 contacts_record_get_str_p(companyHandle, _contacts_company.job_title, &pCharValue);
457 case CONTACT_PROPERTY_ID_COMPANY:
459 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
462 contacts_record_h companyHandle = null;
464 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
465 contacts_record_get_str_p(companyHandle, _contacts_company.name, &pCharValue);
471 case CONTACT_PROPERTY_ID_NOTE:
473 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
476 contacts_record_h noteHandle = null;
478 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, 0, ¬eHandle);
479 contacts_record_get_str_p(noteHandle, _contacts_note.note, &pCharValue);
485 case CONTACT_PROPERTY_ID_RINGTONE:
486 contacts_record_get_str_p(__contactHandle, _contacts_contact.ringtone_path, &pCharValue);
489 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
492 _FileImpl::ConvertPhysicalToVirtualPath(pCharValue, temp);
496 case CONTACT_PROPERTY_ID_THUMBNAIL:
498 bool isDefault = false;
499 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
502 contacts_record_h imageHandle = null;
504 for (unsigned int i = 0; i < count; i++)
506 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, i, &imageHandle);
507 contacts_record_get_str_p(imageHandle, _contacts_image.path, &pCharValue);
509 contacts_record_get_bool(imageHandle, _contacts_image.is_default, &isDefault);
519 case CONTACT_PROPERTY_ID_PHONETIC_FIRST_NAME:
521 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
524 contacts_record_h phoneticNameHandle = null;
526 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
527 contacts_record_get_str_p(phoneticNameHandle, _contacts_name.phonetic_first, &pCharValue);
533 case CONTACT_PROPERTY_ID_PHONETIC_LAST_NAME:
535 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
538 contacts_record_h phoneticNameHandle = null;
540 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
541 contacts_record_get_str_p(phoneticNameHandle, _contacts_name.phonetic_last, &pCharValue);
547 case CONTACT_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
549 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
552 contacts_record_h phoneticNameHandle = null;
554 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
555 contacts_record_get_str_p(phoneticNameHandle, _contacts_name.phonetic_middle, &pCharValue);
561 case CONTACT_PROPERTY_ID_UID:
563 contacts_record_get_str_p(__contactHandle, _contacts_contact.uid, &pCharValue);
570 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d", GetErrorMessage(E_INVALID_ARG), id);
571 return E_INVALID_ARG;
578 _ContactImpl::GetValue(const ContactPropertyId id, DateTime& value) const
582 unsigned int count = 0;
584 value = DateTime::GetMinValue();
588 case CONTACT_PROPERTY_ID_BIRTHDAY:
590 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
597 contacts_record_h eventHandle = null;
598 for (unsigned int i = 0; i < count; i++)
600 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
601 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
602 if (intValue == CONTACTS_EVENT_TYPE_BIRTH)
604 contacts_record_get_int(eventHandle, _contacts_event.date, &intValue);
606 __PARSE_DATE(intValue, year, month, day);
608 value.SetValue(year, month, day, 0, 0, 0);
616 case CONTACT_PROPERTY_ID_ANNIVERSARY:
618 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
625 contacts_record_h eventHandle = null;
626 for (unsigned int i = 0; i < count; i++)
628 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
629 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
630 if (intValue == CONTACTS_EVENT_TYPE_ANNIVERSARY)
632 contacts_record_get_int(eventHandle, _contacts_event.date, &intValue);
634 __PARSE_DATE(intValue, year, month, day);
636 value.SetValue(year, month, day, 0, 0, 0);
644 case CONTACT_PROPERTY_ID_LAST_REVISION:
649 contacts_record_get_int(__contactHandle, _contacts_contact.changed_time, &intValue);
650 gmtime_r((time_t *)intValue, &ts);
652 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);
657 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
658 return E_INVALID_ARG;
665 _ContactImpl::IsEmptyCompany(contacts_record_h companyHandle)
667 char* pCharValue = null;
669 contacts_record_get_str_p(companyHandle, _contacts_company.name, &pCharValue);
670 if (pCharValue != null)
675 contacts_record_get_str_p(companyHandle, _contacts_company.job_title, &pCharValue);
676 if (pCharValue != null)
681 contacts_record_get_str_p(companyHandle, _contacts_company.department, &pCharValue);
682 if (pCharValue != null)
687 contacts_record_get_str_p(companyHandle, _contacts_company.role, &pCharValue);
688 if (pCharValue != null)
693 contacts_record_get_str_p(companyHandle, _contacts_company.assistant_name, &pCharValue);
694 if (pCharValue != null)
699 contacts_record_get_str_p(companyHandle, _contacts_company.description, &pCharValue);
700 if (pCharValue != null)
705 contacts_record_get_str_p(companyHandle, _contacts_company.location, &pCharValue);
706 if (pCharValue != null)
711 contacts_record_get_str_p(companyHandle, _contacts_company.phonetic_name, &pCharValue);
712 if (pCharValue != null)
717 contacts_record_get_str_p(companyHandle, _contacts_company.logo, &pCharValue);
718 if (pCharValue != null)
727 _ContactImpl::IsEmptyName(contacts_record_h nameHandle)
729 char* pCharValue = null;
731 contacts_record_get_str_p(nameHandle, _contacts_name.first, &pCharValue);
732 if (pCharValue != null)
737 contacts_record_get_str_p(nameHandle, _contacts_name.last, &pCharValue);
738 if (pCharValue != null)
743 contacts_record_get_str_p(nameHandle, _contacts_name.addition, &pCharValue);
744 if (pCharValue != null)
749 contacts_record_get_str_p(nameHandle, _contacts_name.prefix, &pCharValue);
750 if (pCharValue != null)
755 contacts_record_get_str_p(nameHandle, _contacts_name.suffix, &pCharValue);
756 if (pCharValue != null)
761 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_first, &pCharValue);
762 if (pCharValue != null)
767 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_last, &pCharValue);
768 if (pCharValue != null)
773 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_middle, &pCharValue);
774 if (pCharValue != null)
783 _ContactImpl::SetValue(ContactPropertyId id, const String& value)
785 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));
786 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));
788 int ret = CONTACTS_ERROR_NONE;
789 unsigned int count = 0;
791 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
793 int maxLength = GetMaxLength(id);
794 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));
799 case CONTACT_PROPERTY_ID_FIRST_NAME:
801 contacts_record_h nameHandle = null;
802 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
805 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
807 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
808 contacts_record_set_str(nameHandle, _contacts_name.first, pCharArray.get());
810 if (value.IsEmpty() && IsEmptyName(nameHandle))
812 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
813 contacts_record_destroy(nameHandle, true);
818 if (!value.IsEmpty())
820 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
821 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
823 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
824 contacts_record_set_str(nameHandle, _contacts_name.first, pCharArray.get());
826 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
832 case CONTACT_PROPERTY_ID_MIDDLE_NAME:
834 contacts_record_h nameHandle = null;
835 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
838 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
840 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
841 contacts_record_set_str(nameHandle, _contacts_name.addition, pCharArray.get());
843 if (value.IsEmpty() && IsEmptyName(nameHandle))
845 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
846 contacts_record_destroy(nameHandle, true);
851 if (!value.IsEmpty())
853 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
854 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
856 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
857 contacts_record_set_str(nameHandle, _contacts_name.addition, pCharArray.get());
859 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
867 case CONTACT_PROPERTY_ID_LAST_NAME:
869 contacts_record_h nameHandle = null;
870 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
873 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
875 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
876 contacts_record_set_str(nameHandle, _contacts_name.last, pCharArray.get());
878 if (value.IsEmpty() && IsEmptyName(nameHandle))
880 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
881 contacts_record_destroy(nameHandle, true);
886 if (!value.IsEmpty())
888 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
889 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
891 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
892 contacts_record_set_str(nameHandle, _contacts_name.last, pCharArray.get());
894 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
901 case CONTACT_PROPERTY_ID_NAME_SUFFIX:
903 contacts_record_h nameHandle = null;
904 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
907 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
909 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
910 contacts_record_set_str(nameHandle, _contacts_name.suffix, pCharArray.get());
912 if (value.IsEmpty() && IsEmptyName(nameHandle))
914 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
915 contacts_record_destroy(nameHandle, true);
921 if (!value.IsEmpty())
923 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
925 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
927 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
928 contacts_record_set_str(nameHandle, _contacts_name.suffix, pCharArray.get());
930 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
938 case CONTACT_PROPERTY_ID_NAME_PREFIX:
940 contacts_record_h nameHandle = null;
941 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
944 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &nameHandle);
946 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
947 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
949 if (value.IsEmpty() && IsEmptyName(nameHandle))
951 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, nameHandle);
952 contacts_record_destroy(nameHandle, true);
957 if (!value.IsEmpty())
959 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
960 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
962 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
963 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
965 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, nameHandle);
973 case CONTACT_PROPERTY_ID_NICK_NAME:
975 contacts_record_h nicknameHandle = null;
976 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
979 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, 0, &nicknameHandle);
980 if (!value.IsEmpty())
982 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
983 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
989 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, 0, &nicknameHandle);
990 if (ret != CONTACTS_ERROR_NONE)
995 contacts_record_remove_child_record(__contactHandle, _contacts_contact.nickname, nicknameHandle);
996 contacts_record_destroy(nicknameHandle, true);
1002 if (!value.IsEmpty())
1004 ret = contacts_record_create(_contacts_nickname._uri, &nicknameHandle);
1005 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1007 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1008 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
1010 contacts_record_add_child_record(__contactHandle, _contacts_contact.nickname, nicknameHandle);
1018 case CONTACT_PROPERTY_ID_JOB_TITLE:
1020 contacts_record_h companyHandle = null;
1021 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
1024 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
1026 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1027 contacts_record_set_str(companyHandle, _contacts_company.job_title, pCharArray.get());
1029 if (value.IsEmpty() && IsEmptyCompany(companyHandle))
1033 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
1034 if (ret != CONTACTS_ERROR_NONE)
1039 contacts_record_remove_child_record(__contactHandle, _contacts_contact.company, companyHandle);
1040 contacts_record_destroy(companyHandle, true);
1046 if (!value.IsEmpty())
1048 ret = contacts_record_create(_contacts_company._uri, &companyHandle);
1049 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1051 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1052 contacts_record_set_str(companyHandle, _contacts_company.job_title, pCharArray.get());
1054 contacts_record_add_child_record(__contactHandle, _contacts_contact.company, companyHandle);
1061 case CONTACT_PROPERTY_ID_COMPANY:
1063 contacts_record_h companyHandle = null;
1064 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
1067 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
1069 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(value));
1070 contacts_record_set_str(companyHandle, _contacts_company.name, pCharArray.get());
1072 if (value.IsEmpty() && IsEmptyCompany(companyHandle))
1076 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, 0, &companyHandle);
1077 if (ret != CONTACTS_ERROR_NONE)
1082 contacts_record_remove_child_record(__contactHandle, _contacts_contact.company, companyHandle);
1083 contacts_record_destroy(companyHandle, true);
1090 if (!value.IsEmpty())
1092 ret = contacts_record_create(_contacts_company._uri, &companyHandle);
1093 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1095 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(value));
1096 contacts_record_set_str(companyHandle, _contacts_company.name, pCharArray.get());
1098 contacts_record_add_child_record(__contactHandle, _contacts_contact.company, companyHandle);
1105 case CONTACT_PROPERTY_ID_NOTE:
1107 contacts_record_h noteHandle = null;
1108 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
1111 if (!value.IsEmpty())
1113 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, 0, ¬eHandle);
1115 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(value));
1116 contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
1122 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, 0, ¬eHandle);
1123 if (ret != CONTACTS_ERROR_NONE)
1128 contacts_record_remove_child_record(__contactHandle, _contacts_contact.note, noteHandle);
1129 contacts_record_destroy(noteHandle, true);
1135 if (!value.IsEmpty())
1137 ret = contacts_record_create(_contacts_note._uri, ¬eHandle);
1138 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1140 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(value));
1141 contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
1143 contacts_record_add_child_record(__contactHandle, _contacts_contact.note, noteHandle);
1149 case CONTACT_PROPERTY_ID_RINGTONE:
1151 SysTryReturn(NID_SCL, value.IsEmpty() || File::IsFileExist(value), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
1153 String ringtonePath;
1154 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
1156 if (!value.IsEmpty())
1158 result r = _FileImpl::ConvertVirtualToPhysicalPath(value, ringtonePath);
1159 SysTryReturn(NID_SCL, r != E_INVALID_ARG, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
1164 ringtonePath = value;
1167 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(ringtonePath));
1169 contacts_record_set_str(__contactHandle, _contacts_contact.ringtone_path, pCharArray.get());
1173 case CONTACT_PROPERTY_ID_PHONETIC_FIRST_NAME:
1175 contacts_record_h phoneticNameHandle = null;
1176 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
1179 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
1181 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1182 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_first, pCharArray.get());
1184 if (value.IsEmpty() && IsEmptyName(phoneticNameHandle))
1186 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1187 contacts_record_destroy(phoneticNameHandle, true);
1192 if (!value.IsEmpty())
1194 ret = contacts_record_create(_contacts_name._uri, &phoneticNameHandle);
1195 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1197 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1198 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_first, pCharArray.get());
1200 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1205 case CONTACT_PROPERTY_ID_PHONETIC_LAST_NAME:
1207 contacts_record_h phoneticNameHandle = null;
1208 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
1211 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
1213 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1214 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_last, pCharArray.get());
1216 if (value.IsEmpty() && IsEmptyName(phoneticNameHandle))
1218 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1219 contacts_record_destroy(phoneticNameHandle, true);
1224 if (!value.IsEmpty())
1226 ret = contacts_record_create(_contacts_name._uri, &phoneticNameHandle);
1227 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1229 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1230 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_last, pCharArray.get());
1232 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1237 case CONTACT_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
1239 contacts_record_h phoneticNameHandle = null;
1240 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
1243 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &phoneticNameHandle);
1245 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1246 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_middle, pCharArray.get());
1248 if (value.IsEmpty() && IsEmptyName(phoneticNameHandle))
1250 contacts_record_remove_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1251 contacts_record_destroy(phoneticNameHandle, true);
1256 if (!value.IsEmpty())
1258 ret = contacts_record_create(_contacts_name._uri, &phoneticNameHandle);
1259 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1261 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1262 contacts_record_set_str(phoneticNameHandle, _contacts_name.phonetic_middle, pCharArray.get());
1264 contacts_record_add_child_record(__contactHandle, _contacts_contact.name, phoneticNameHandle);
1269 case CONTACT_PROPERTY_ID_UID:
1271 if (!value.IsEmpty())
1273 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
1274 contacts_record_set_str(__contactHandle, _contacts_contact.uid, pCharArray.get());
1278 contacts_record_set_str(__contactHandle, _contacts_contact.uid, null);
1283 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
1284 return E_INVALID_ARG;
1291 _ContactImpl::SetValue(ContactPropertyId id, const DateTime& value)
1293 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));
1295 unsigned int count = 0;
1297 int ret = CONTACTS_ERROR_NONE;
1301 case CONTACT_PROPERTY_ID_BIRTHDAY:
1305 contacts_record_h eventHandle = null;
1307 __CONVERT_DATETIME_TO_DATE(value, date);
1309 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
1312 for (unsigned int i = 0; i < count; i++)
1314 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
1315 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
1316 if (intValue == CONTACTS_EVENT_TYPE_BIRTH)
1318 contacts_record_set_int(eventHandle, _contacts_event.date, date);
1327 ret = contacts_record_create(_contacts_event._uri, &eventHandle);
1328 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1330 contacts_record_set_int(eventHandle, _contacts_event.type, CONTACTS_EVENT_TYPE_BIRTH);
1331 contacts_record_set_int(eventHandle, _contacts_event.date, date);
1333 contacts_record_add_child_record(__contactHandle, _contacts_contact.event, eventHandle);
1339 case CONTACT_PROPERTY_ID_ANNIVERSARY:
1343 contacts_record_h eventHandle = null;
1345 __CONVERT_DATETIME_TO_DATE(value, date);
1347 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
1350 for (unsigned int i = 0; i < count; i++)
1352 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
1353 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
1354 if (intValue == CONTACTS_EVENT_TYPE_ANNIVERSARY)
1356 contacts_record_set_int(eventHandle, _contacts_event.date, date);
1365 ret = contacts_record_create(_contacts_event._uri, &eventHandle);
1366 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1368 contacts_record_set_int(eventHandle, _contacts_event.type, CONTACTS_EVENT_TYPE_ANNIVERSARY);
1369 contacts_record_set_int(eventHandle, _contacts_event.date, date);
1371 contacts_record_add_child_record(__contactHandle, _contacts_contact.event, eventHandle);
1378 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
1379 return E_INVALID_ARG;
1386 _ContactImpl::AddPhoneNumber(const PhoneNumber& phoneNumber)
1388 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));
1389 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1393 contacts_record_h numberHandle = null;
1395 int ret = contacts_record_create(_contacts_number._uri, &numberHandle);
1396 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1398 __ContactsRecordHandle recordHandle(numberHandle);
1400 switch (_PhoneNumberImpl::GetInstance(phoneNumber)->GetType())
1402 case PHONENUMBER_TYPE_HOME:
1403 type = CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE;
1405 case PHONENUMBER_TYPE_WORK:
1406 type = CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE;
1408 case PHONENUMBER_TYPE_MOBILE:
1409 type = CONTACTS_NUMBER_TYPE_CELL;
1411 case PHONENUMBER_TYPE_HOME_FAX:
1412 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME;
1414 case PHONENUMBER_TYPE_WORK_FAX:
1415 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK;
1417 case PHONENUMBER_TYPE_PAGER:
1418 type = CONTACTS_NUMBER_TYPE_PAGER;
1420 case PHONENUMBER_TYPE_CUSTOM:
1421 type = CONTACTS_NUMBER_TYPE_CUSTOM;
1423 case PHONENUMBER_TYPE_ASSISTANT:
1424 type = CONTACTS_NUMBER_TYPE_ASSISTANT;
1426 case PHONENUMBER_TYPE_OTHER:
1428 type = CONTACTS_NUMBER_TYPE_OTHER;
1432 contacts_record_set_int(numberHandle, _contacts_number.type, type);
1434 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetLabel();
1436 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1437 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1439 contacts_record_set_str(numberHandle, _contacts_number.label, pCharArray.get());
1441 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetPhoneNumber();
1442 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1443 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1445 contacts_record_set_str(numberHandle, _contacts_number.number, pCharArray.get());
1447 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.number, numberHandle);
1448 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1450 recordHandle.Release();
1456 _ContactImpl::AddNickname(const String& nickname)
1458 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));
1459 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1460 contacts_record_h nicknameHandle = null;
1462 int ret = contacts_record_create(_contacts_nickname._uri, &nicknameHandle);
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 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(nickname));
1466 SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1468 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
1470 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.nickname, nicknameHandle);
1471 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1477 _ContactImpl::AddNote(const String& note)
1479 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));
1480 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1481 contacts_record_h noteHandle = null;
1483 int ret = contacts_record_create(_contacts_note._uri, ¬eHandle);
1484 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1486 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(note));
1487 SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1489 contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
1491 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.note, noteHandle);
1492 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1498 _ContactImpl::AddEmail(const Email& email)
1500 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));
1501 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1505 contacts_record_h emailHandle = null;
1507 int ret = contacts_record_create(_contacts_email._uri, &emailHandle);
1508 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1510 __ContactsRecordHandle recordHandle(emailHandle);
1512 switch (_EmailImpl::GetInstance(email)->GetType())
1514 case EMAIL_TYPE_PERSONAL:
1515 type = CONTACTS_EMAIL_TYPE_HOME;
1517 case EMAIL_TYPE_WORK:
1518 type = CONTACTS_EMAIL_TYPE_WORK;
1520 case EMAIL_TYPE_CUSTOM:
1521 type = CONTACTS_EMAIL_TYPE_CUSTOM;
1523 case EMAIL_TYPE_MOBILE:
1524 type = CONTACTS_EMAIL_TYPE_MOBILE;
1526 case EMAIL_TYPE_OTHER:
1529 type = CONTACTS_EMAIL_TYPE_OTHER;
1533 contacts_record_set_int(emailHandle, _contacts_email.type, type);
1535 stringValue = _EmailImpl::GetInstance(email)->GetLabel();
1536 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1537 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1539 contacts_record_set_str(emailHandle, _contacts_email.label, pCharArray.get());
1541 stringValue = _EmailImpl::GetInstance(email)->GetEmail();
1542 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1543 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1545 contacts_record_set_str(emailHandle, _contacts_email.email, pCharArray.get());
1547 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.email, emailHandle);
1548 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1550 recordHandle.Release();
1556 _ContactImpl::AddUrl(const Url& url)
1558 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));
1559 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1563 contacts_record_h urlHandle = null;
1565 int ret = contacts_record_create(_contacts_url._uri, &urlHandle);
1566 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1568 __ContactsRecordHandle recordHandle(urlHandle);
1570 switch (_UrlImpl::GetInstance(url)->GetType())
1572 case URL_TYPE_PERSONAL:
1573 type = CONTACTS_URL_TYPE_HOME;
1576 type = CONTACTS_URL_TYPE_WORK;
1578 case URL_TYPE_CUSTOM:
1579 type = CONTACTS_URL_TYPE_CUSTOM;
1581 case URL_TYPE_OTHER:
1584 type = CONTACTS_URL_TYPE_OTHER;
1589 contacts_record_set_int(urlHandle, _contacts_url.type, type);
1592 stringValue = _UrlImpl::GetInstance(url)->GetLabel();
1593 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1594 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1596 contacts_record_set_str(urlHandle, _contacts_url.label, pCharArray.get());
1599 stringValue = _UrlImpl::GetInstance(url)->GetUrl();
1600 pCharArray.reset(_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(urlHandle, _contacts_url.url, pCharArray.get());
1605 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.url, urlHandle);
1606 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1608 recordHandle.Release();
1614 _ContactImpl::AddAddress(const Address& address)
1616 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));
1617 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1621 contacts_record_h addressHandle = null;
1623 int ret = contacts_record_create(_contacts_address._uri, &addressHandle);
1624 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1626 __ContactsRecordHandle recordHandle(addressHandle);
1628 switch (_AddressImpl::GetInstance(address)->GetType())
1630 case ADDRESS_TYPE_HOME:
1631 type = CONTACTS_ADDRESS_TYPE_HOME;
1633 case ADDRESS_TYPE_WORK:
1634 type = CONTACTS_ADDRESS_TYPE_WORK;
1636 case ADDRESS_TYPE_CUSTOM:
1637 type = CONTACTS_ADDRESS_TYPE_CUSTOM;
1639 case ADDRESS_TYPE_OTHER:
1642 type = CONTACTS_ADDRESS_TYPE_OTHER;
1646 contacts_record_set_int(addressHandle, _contacts_address.type, type);
1648 stringValue = _AddressImpl::GetInstance(address)->GetLabel();
1649 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1650 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1652 contacts_record_set_str(addressHandle, _contacts_address.label, pCharArray.get());
1654 stringValue = _AddressImpl::GetInstance(address)->GetCity();
1655 if (!stringValue.IsEmpty())
1657 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1658 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1660 contacts_record_set_str(addressHandle, _contacts_address.locality, pCharArray.get());
1664 stringValue = _AddressImpl::GetInstance(address)->GetCountry();
1665 if (!stringValue.IsEmpty())
1667 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1668 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1670 contacts_record_set_str(addressHandle, _contacts_address.country, pCharArray.get());
1673 stringValue = _AddressImpl::GetInstance(address)->GetExtended();
1674 if (!stringValue.IsEmpty())
1676 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1677 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1679 contacts_record_set_str(addressHandle, _contacts_address.extended, pCharArray.get());
1682 stringValue = _AddressImpl::GetInstance(address)->GetPostalCode();
1683 if (!stringValue.IsEmpty())
1685 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1686 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1688 contacts_record_set_str(addressHandle, _contacts_address.postal_code, pCharArray.get());
1691 stringValue = _AddressImpl::GetInstance(address)->GetPostOfficeBoxNumber();
1692 if (!stringValue.IsEmpty())
1694 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1695 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1697 contacts_record_set_str(addressHandle, _contacts_address.postbox, pCharArray.get());
1700 stringValue = _AddressImpl::GetInstance(address)->GetState();
1701 if (!stringValue.IsEmpty())
1703 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1704 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1706 contacts_record_set_str(addressHandle, _contacts_address.region, pCharArray.get());
1709 stringValue = _AddressImpl::GetInstance(address)->GetStreet();
1710 if (!stringValue.IsEmpty())
1712 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1713 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1715 contacts_record_set_str(addressHandle, _contacts_address.street, pCharArray.get());
1718 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.address, addressHandle);
1719 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1721 recordHandle.Release();
1727 _ContactImpl::AddImAddress(const ImAddress& imAddress)
1729 SysTryReturn(NID_SCL, !imAddress.GetImAddress().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%] Invalid argument is used. The imAddress is empty.", GetErrorMessage(E_INVALID_ARG));
1730 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1734 contacts_record_h messengerHandle = null;
1736 std::unique_ptr<char[]> pCharArray(null);
1738 int ret = contacts_record_create(_contacts_messenger._uri, &messengerHandle);
1739 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1741 __ContactsRecordHandle recordHandle(messengerHandle);
1743 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetServiceProviderName();
1745 if (stringValue == IM_ADDRESS_GOOGLE_TALK)
1747 type = CONTACTS_MESSENGER_TYPE_GOOGLE;
1749 else if (stringValue == IM_ADDRESS_MSN)
1751 type = CONTACTS_MESSENGER_TYPE_WLM;
1753 else if (stringValue == IM_ADDRESS_ICQ)
1755 type = CONTACTS_MESSENGER_TYPE_ICQ;
1757 else if (stringValue == IM_ADDRESS_AIM)
1759 type = CONTACTS_MESSENGER_TYPE_AIM;
1761 else if (stringValue == IM_ADDRESS_YAHOO)
1763 type = CONTACTS_MESSENGER_TYPE_YAHOO;
1765 else if (stringValue == IM_ADDRESS_QQ)
1767 type = CONTACTS_MESSENGER_TYPE_QQ;
1769 else if (stringValue == IM_ADDRESS_SKYPE)
1771 type = CONTACTS_MESSENGER_TYPE_SKYPE;
1773 else if (stringValue == IM_ADDRESS_JABBER)
1775 type = CONTACTS_MESSENGER_TYPE_JABBER;
1777 else if (stringValue == IM_ADDRESS_IRC)
1779 type = CONTACTS_MESSENGER_TYPE_IRC;
1781 else if (stringValue == IM_ADDRESS_FACEBOOK)
1783 type = CONTACTS_MESSENGER_TYPE_FACEBOOK;
1787 type = CONTACTS_MESSENGER_TYPE_CUSTOM;
1790 contacts_record_set_int(messengerHandle, _contacts_messenger.type, type);
1791 if (type == CONTACTS_MESSENGER_TYPE_CUSTOM)
1793 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1794 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1796 contacts_record_set_str(messengerHandle, _contacts_messenger.label, pCharArray.get());
1799 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetImAddress();
1800 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1801 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1803 contacts_record_set_str(messengerHandle, _contacts_messenger.im_id, pCharArray.get());
1805 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.messenger, messengerHandle);
1806 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1808 recordHandle.Release();
1813 _ContactImpl::AddRelationship(const Relationship& relationship)
1815 SysTryReturn(NID_SCL, !relationship.GetRelativeName().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%] Invalid argument is used. The relationship is empty.", GetErrorMessage(E_INVALID_ARG));
1816 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1819 contacts_record_h relationshipHandle = null;
1821 int ret = contacts_record_create(_contacts_relationship._uri, &relationshipHandle);
1822 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1824 __ContactsRecordHandle recordHandle(relationshipHandle);
1826 switch (relationship.GetType())
1828 case CONTACT_RELATIONSHIP_TYPE_ASSISTANT:
1829 intValue = CONTACTS_RELATIONSHIP_TYPE_ASSISTANT;
1831 case CONTACT_RELATIONSHIP_TYPE_BROTHER:
1832 intValue = CONTACTS_RELATIONSHIP_TYPE_BROTHER;
1834 case CONTACT_RELATIONSHIP_TYPE_CHILD:
1835 intValue = CONTACTS_RELATIONSHIP_TYPE_CHILD;
1837 case CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
1838 intValue = CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER;
1840 case CONTACT_RELATIONSHIP_TYPE_FATHER:
1841 intValue = CONTACTS_RELATIONSHIP_TYPE_FATHER;
1843 case CONTACT_RELATIONSHIP_TYPE_FRIEND:
1844 intValue = CONTACTS_RELATIONSHIP_TYPE_FRIEND;
1846 case CONTACT_RELATIONSHIP_TYPE_MANAGER:
1847 intValue = CONTACTS_RELATIONSHIP_TYPE_MANAGER;
1849 case CONTACT_RELATIONSHIP_TYPE_MOTHER:
1850 intValue = CONTACTS_RELATIONSHIP_TYPE_MOTHER;
1852 case CONTACT_RELATIONSHIP_TYPE_PARENT:
1853 intValue = CONTACTS_RELATIONSHIP_TYPE_PARENT;
1855 case CONTACT_RELATIONSHIP_TYPE_PARTNER:
1856 intValue = CONTACTS_RELATIONSHIP_TYPE_PARTNER;
1858 case CONTACT_RELATIONSHIP_TYPE_REFERRED_BY:
1859 intValue = CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY;
1861 case CONTACT_RELATIONSHIP_TYPE_RELATIVE:
1862 intValue = CONTACTS_RELATIONSHIP_TYPE_RELATIVE;
1864 case CONTACT_RELATIONSHIP_TYPE_SISTER:
1865 intValue = CONTACTS_RELATIONSHIP_TYPE_SISTER;
1867 case CONTACT_RELATIONSHIP_TYPE_SPOUSE:
1868 intValue = CONTACTS_RELATIONSHIP_TYPE_SPOUSE;
1870 case CONTACT_RELATIONSHIP_TYPE_CUSTOM:
1871 intValue = CONTACTS_RELATIONSHIP_TYPE_CUSTOM;
1874 intValue = CONTACTS_RELATIONSHIP_TYPE_OTHER;
1879 contacts_record_set_int(relationshipHandle, _contacts_relationship.type, intValue);
1882 String stringValue = relationship.GetLabel();
1883 if (!stringValue.IsEmpty())
1885 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1886 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1888 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, pCharArray.get());
1892 stringValue = relationship.GetRelativeName();
1893 if (!stringValue.IsEmpty())
1895 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1896 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1898 contacts_record_set_str(relationshipHandle, _contacts_relationship.name, pCharArray.get());
1901 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.relationship, relationshipHandle);
1902 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1904 recordHandle.Release();
1911 _ContactImpl::AddContactAppLaunchData(const ContactAppLaunchData& appLaunchData)
1913 SysTryReturn(NID_SCL, !_ContactAppLaunchDataImpl::GetInstance(appLaunchData)->IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified app launch data does not have any property.", GetErrorMessage(E_INVALID_ARG));
1915 String strValue = L"";
1917 std::unique_ptr<ContactRecord, ContactRecordDeleter> pProfileRecord(_AddressbookUtil::CreateContactRecordN(_contacts_profile._uri));
1918 SysTryReturn(NID_SCL, pProfileRecord != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1920 strValue = appLaunchData.GetDisplayText();
1921 if (!strValue.IsEmpty())
1923 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
1924 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1926 contacts_record_set_str(pProfileRecord.get(), _contacts_profile.text, pCharArray.get());
1929 strValue = _ContactAppLaunchDataImpl::GetInstance(appLaunchData)->GetUid();
1930 if (!strValue.IsEmpty())
1932 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
1933 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1935 contacts_record_set_str(pProfileRecord.get(), _contacts_profile.uid, pCharArray.get());
1938 strValue = appLaunchData.GetAppId();
1939 if (!strValue.IsEmpty())
1941 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
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(pProfileRecord.get(), _contacts_profile.app_id, pCharArray.get());
1947 strValue = appLaunchData.GetOperationId();
1948 if (!strValue.IsEmpty())
1950 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
1951 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1953 contacts_record_set_str(pProfileRecord.get(), _contacts_profile.service_operation, pCharArray.get());
1956 strValue = appLaunchData.GetUri();
1957 if (!strValue.IsEmpty())
1959 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
1960 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1962 contacts_record_set_str(pProfileRecord.get(), _contacts_profile.uri, pCharArray.get());
1965 strValue = _ContactAppLaunchDataImpl::GetInstance(appLaunchData)->GetCategory();
1966 if (!strValue.IsEmpty())
1968 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
1969 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1971 contacts_record_set_str(pProfileRecord.get(), _contacts_profile.category, pCharArray.get());
1974 strValue = appLaunchData.GetMime();
1975 if (!strValue.IsEmpty())
1977 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
1978 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1980 contacts_record_set_str(pProfileRecord.get(), _contacts_profile.mime, pCharArray.get());
1984 std::unique_ptr<IMap, AllElementsDeleter> pExtraData(appLaunchData.GetExtraDataN());
1985 SysTryReturn(NID_SCL, pExtraData != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1987 std::unique_ptr<IMapEnumerator> pMapEnum(pExtraData->GetMapEnumeratorN());
1988 SysTryReturn(NID_SCL, pMapEnum != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1990 result r = E_SUCCESS;
1992 bool isFirst = true;
1993 String extraData(L"");
1994 String encodedString(L"");
1995 std::unique_ptr<ByteBuffer> pByteBuffer(null);
1997 String* pKey = null;
1998 String* pVal = null;
2000 while (pMapEnum->MoveNext() == E_SUCCESS)
2004 extraData.Append(L",");
2011 pKey = static_cast<String*> (pMapEnum->GetKey());
2012 pVal = static_cast<String*> (pMapEnum->GetValue());
2014 pByteBuffer.reset(StringUtil::StringToUtf8N(*pKey));
2015 SysTryReturn(NID_SCL, pByteBuffer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2017 limit = pByteBuffer->GetLimit();
2018 pByteBuffer->SetLimit(limit - 1);
2020 r = StringUtil::EncodeToBase64String(*pByteBuffer, encodedString);
2021 SysTryReturn(NID_SCL, !IsFailed(r), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argutmnet is used.", GetErrorMessage(E_INVALID_ARG));
2023 extraData.Append(encodedString);
2024 extraData.Append(L":");
2026 pByteBuffer.reset(StringUtil::StringToUtf8N(*pVal));
2027 SysTryReturn(NID_SCL, pByteBuffer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2029 limit = pByteBuffer->GetLimit();
2030 pByteBuffer->SetLimit(limit - 1);
2032 r = StringUtil::EncodeToBase64String(*pByteBuffer, encodedString);
2033 SysTryReturn(NID_SCL, !IsFailed(r), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argutmnet is used.", GetErrorMessage(E_INVALID_ARG));
2035 extraData.Append(encodedString);
2038 if (!extraData.IsEmpty())
2040 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(extraData));
2041 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2043 contacts_record_set_str(pProfileRecord.get(), _contacts_profile.extra_data, pCharArray.get());
2046 int ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.profile, pProfileRecord.get());
2047 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2049 pProfileRecord.release();
2055 _ContactImpl::AddEvent(const ContactEvent& event)
2057 SysTryReturn(NID_SCL, !__isRemoved || !IsFailed(Invalidate()), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2058 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));
2063 contacts_record_h eventHandle = null;
2065 int ret = contacts_record_create(_contacts_event._uri, &eventHandle);
2066 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2068 __ContactsRecordHandle recordHandle(eventHandle);
2070 switch (event.GetType())
2072 case CONTACT_EVENT_TYPE_ANNIVERSARY:
2073 type = CONTACTS_EVENT_TYPE_ANNIVERSARY;
2075 case CONTACT_EVENT_TYPE_BIRTHDAY:
2076 type = CONTACTS_EVENT_TYPE_BIRTH;
2078 case CONTACT_EVENT_TYPE_CUSTOM:
2079 type = CONTACTS_EVENT_TYPE_CUSTOM;
2081 case CONTACT_EVENT_TYPE_OTHER:
2084 type = CONTACTS_EVENT_TYPE_OTHER;
2089 contacts_record_set_int(eventHandle, _contacts_event.type, type);
2092 stringValue = event.GetLabel();
2093 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2094 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2096 contacts_record_set_str(eventHandle, _contacts_event.label, pCharArray.get());
2099 DateTime dateValue = event.GetDate();
2100 intValue = dateValue.GetYear()*10000 + dateValue.GetMonth()*100 + dateValue.GetDay();
2101 contacts_record_set_int(eventHandle, _contacts_event.date, intValue);
2103 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.event, eventHandle);
2104 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2106 recordHandle.Release();
2112 _ContactImpl::AddOrganization(const Organization& organization)
2114 SysTryReturn(NID_SCL
2115 , !organization.GetName().IsEmpty() ||
2116 !organization.GetJobTitle().IsEmpty() ||
2117 !organization.GetDepartment().IsEmpty() ||
2118 !organization.GetRole().IsEmpty() ||
2119 !organization.GetAgent().IsEmpty() ||
2120 !organization.GetDescription().IsEmpty() ||
2121 !organization.GetLocation().IsEmpty() ||
2122 !organization.GetPhoneticName().IsEmpty() ||
2123 !organization.GetLogoPath().IsEmpty()
2124 ,E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The organization is empty.", GetErrorMessage(E_INVALID_ARG));
2125 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2127 contacts_record_h organizationHandle = null;
2129 int ret = contacts_record_create(_contacts_company._uri, &organizationHandle);
2130 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2132 __ContactsRecordHandle recordHandle(organizationHandle);
2135 String stringValue = organization.GetName();
2136 if (!stringValue.IsEmpty())
2138 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2139 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2141 contacts_record_set_str(organizationHandle, _contacts_company.name, pCharArray.get());
2145 stringValue = organization.GetJobTitle();
2146 if (!stringValue.IsEmpty())
2148 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2149 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2151 contacts_record_set_str(organizationHandle, _contacts_company.job_title, pCharArray.get());
2155 stringValue = organization.GetDepartment();
2156 if (!stringValue.IsEmpty())
2158 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2159 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2161 contacts_record_set_str(organizationHandle, _contacts_company.department, pCharArray.get());
2165 stringValue = organization.GetRole();
2166 if (!stringValue.IsEmpty())
2168 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2169 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2171 contacts_record_set_str(organizationHandle, _contacts_company.role, pCharArray.get());
2175 stringValue = organization.GetAgent();
2176 if (!stringValue.IsEmpty())
2178 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2179 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2181 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, pCharArray.get());
2187 switch (organization.GetType())
2189 case ORGANIZATION_TYPE_WORK:
2190 type = CONTACTS_COMPANY_TYPE_WORK;
2192 case ORGANIZATION_TYPE_CUSTOM:
2193 type = CONTACTS_COMPANY_TYPE_CUSTOM;
2195 case ORGANIZATION_TYPE_OTHER:
2198 type = CONTACTS_COMPANY_TYPE_OTHER;
2202 contacts_record_set_int(organizationHandle, _contacts_company.type, type);
2205 stringValue = organization.GetLabel();
2206 if (!stringValue.IsEmpty())
2208 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2209 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2211 contacts_record_set_str(organizationHandle, _contacts_company.label, pCharArray.get());
2215 stringValue = organization.GetDescription();
2216 if (!stringValue.IsEmpty())
2218 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2219 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2221 contacts_record_set_str(organizationHandle, _contacts_company.description, pCharArray.get());
2225 stringValue = organization.GetLocation();
2226 if (!stringValue.IsEmpty())
2228 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2229 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2231 contacts_record_set_str(organizationHandle, _contacts_company.location, pCharArray.get());
2235 stringValue = organization.GetPhoneticName();
2236 if (!stringValue.IsEmpty())
2238 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2239 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2241 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, pCharArray.get());
2245 if (_OrganizationImpl::GetInstance(organization)->IsLogoPathChanged() == true)
2247 stringValue = organization.GetLogoPath();
2248 if (!stringValue.IsEmpty())
2250 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2251 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2253 contacts_record_set_str(organizationHandle, _contacts_company.logo, pCharArray.get());
2257 ret = contacts_record_add_child_record(__contactHandle, _contacts_contact.company, organizationHandle);
2258 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2260 recordHandle.Release();
2266 _ContactImpl::RemoveAt(ContactMultiPropertyId id, int index)
2268 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);
2270 unsigned int count = 0;
2271 contacts_record_h recordHandle = null;
2275 case CONTACT_MPROPERTY_ID_PHONE_NUMBERS:
2276 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
2277 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);
2279 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.number, index, &recordHandle);
2280 contacts_record_remove_child_record(__contactHandle, _contacts_contact.number, recordHandle);
2281 contacts_record_destroy(recordHandle, true);
2284 case CONTACT_MPROPERTY_ID_EMAILS:
2285 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
2286 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);
2288 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.email, index, &recordHandle);
2289 contacts_record_remove_child_record(__contactHandle, _contacts_contact.email, recordHandle);
2290 contacts_record_destroy(recordHandle, true);
2293 case CONTACT_MPROPERTY_ID_URLS:
2294 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
2295 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);
2297 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.url, index, &recordHandle);
2298 contacts_record_remove_child_record(__contactHandle, _contacts_contact.url, recordHandle);
2299 contacts_record_destroy(recordHandle, true);
2302 case CONTACT_MPROPERTY_ID_ADDRESSES:
2303 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
2304 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);
2306 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.address, index, &recordHandle);
2307 contacts_record_remove_child_record(__contactHandle, _contacts_contact.address, recordHandle);
2308 contacts_record_destroy(recordHandle, true);
2311 case CONTACT_MPROPERTY_ID_IMADDRESSES:
2312 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
2313 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);
2315 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.messenger, index, &recordHandle);
2316 contacts_record_remove_child_record(__contactHandle, _contacts_contact.messenger, recordHandle);
2317 contacts_record_destroy(recordHandle, true);
2320 case CONTACT_MPROPERTY_ID_ORGANIZATIONS:
2321 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
2322 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of organizations %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2324 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, index, &recordHandle);
2325 contacts_record_remove_child_record(__contactHandle, _contacts_contact.company, recordHandle);
2326 contacts_record_destroy(recordHandle, true);
2329 case CONTACT_MPROPERTY_ID_EVENTS:
2330 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
2331 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);
2333 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, index, &recordHandle);
2334 contacts_record_remove_child_record(__contactHandle, _contacts_contact.event, recordHandle);
2335 contacts_record_destroy(recordHandle, true);
2338 case CONTACT_MPROPERTY_ID_RELATIONSHIPS:
2339 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.relationship, &count);
2340 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);
2342 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.relationship, index, &recordHandle);
2343 contacts_record_remove_child_record(__contactHandle, _contacts_contact.relationship, recordHandle);
2344 contacts_record_destroy(recordHandle, true);
2347 case CONTACT_MPROPERTY_ID_NOTES:
2348 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
2349 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);
2351 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, index, &recordHandle);
2352 contacts_record_remove_child_record(__contactHandle, _contacts_contact.note, recordHandle);
2353 contacts_record_destroy(recordHandle, true);
2356 case CONTACT_MPROPERTY_ID_NICKNAMES:
2357 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
2358 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);
2360 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, index, &recordHandle);
2361 contacts_record_remove_child_record(__contactHandle, _contacts_contact.nickname, recordHandle);
2362 contacts_record_destroy(recordHandle, true);
2365 case CONTACT_MPROPERTY_ID_APP_LAUNCH_DATA:
2366 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.profile, &count);
2367 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);
2369 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.profile, index, &recordHandle);
2370 contacts_record_remove_child_record(__contactHandle, _contacts_contact.profile, recordHandle);
2371 contacts_record_destroy(recordHandle, true);
2375 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
2376 return E_INVALID_ARG;
2383 _ContactImpl::GetValuesN(const ContactMultiPropertyId id)
2385 IList* pList = null;
2387 SetLastResult(E_SUCCESS);
2391 case CONTACT_MPROPERTY_ID_PHONE_NUMBERS:
2392 pList = GetPhoneNumbersN();
2395 case CONTACT_MPROPERTY_ID_EMAILS:
2396 pList = GetEmailsN();
2399 case CONTACT_MPROPERTY_ID_URLS:
2403 case CONTACT_MPROPERTY_ID_ADDRESSES:
2404 pList = GetAddressesN();
2407 case CONTACT_MPROPERTY_ID_IMADDRESSES:
2408 pList = GetImAddressesN();
2411 case CONTACT_MPROPERTY_ID_ORGANIZATIONS:
2412 pList = GetOrganizationsN();
2415 case CONTACT_MPROPERTY_ID_EVENTS:
2416 pList = GetEventsN();
2419 case CONTACT_MPROPERTY_ID_RELATIONSHIPS:
2420 pList = GetRelationshipsN();
2423 case CONTACT_MPROPERTY_ID_NOTES:
2424 pList = GetNotesN();
2427 case CONTACT_MPROPERTY_ID_NICKNAMES:
2428 pList = GetNicknamesN();
2430 case CONTACT_MPROPERTY_ID_APP_LAUNCH_DATA:
2431 pList = GetContactAppLaunchDataN();
2434 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
2438 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2444 _ContactImpl::SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber)
2446 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);
2447 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));
2448 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2450 unsigned int count = 0;
2451 contacts_record_h recordHandle = null;
2455 PhoneNumberType phoneNumberType = PHONENUMBER_TYPE_HOME;
2456 bool isChanged = false;
2458 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
2459 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);
2461 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.number, index, &recordHandle);
2464 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetLabel();
2466 switch (_PhoneNumberImpl::GetInstance(phoneNumber)->GetType())
2468 case PHONENUMBER_TYPE_HOME:
2469 type = CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE;
2471 case PHONENUMBER_TYPE_WORK:
2472 type = CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE;
2474 case PHONENUMBER_TYPE_MOBILE:
2475 type = CONTACTS_NUMBER_TYPE_CELL;
2477 case PHONENUMBER_TYPE_HOME_FAX:
2478 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME;
2480 case PHONENUMBER_TYPE_WORK_FAX:
2481 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK;
2483 case PHONENUMBER_TYPE_PAGER:
2484 type = CONTACTS_NUMBER_TYPE_PAGER;
2486 case PHONENUMBER_TYPE_CUSTOM:
2487 type = CONTACTS_NUMBER_TYPE_CUSTOM;
2489 case PHONENUMBER_TYPE_ASSISTANT:
2490 type = CONTACTS_NUMBER_TYPE_ASSISTANT;
2492 case PHONENUMBER_TYPE_OTHER:
2493 isChanged = _PhoneNumberImpl::GetInstance(phoneNumber)->IsPhoneNumberTypeChanged();
2496 type = CONTACTS_NUMBER_TYPE_OTHER;
2500 contacts_record_get_int(recordHandle, _contacts_number.type, &oriType);
2501 phoneNumberType = GetNativePhoneNumberType(oriType);
2502 if (phoneNumberType == PHONENUMBER_TYPE_OTHER)
2508 type = CONTACTS_NUMBER_TYPE_OTHER;
2512 type = CONTACTS_NUMBER_TYPE_OTHER;
2517 contacts_record_set_int(recordHandle, _contacts_number.type, type);
2520 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2521 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2523 contacts_record_set_str(recordHandle, _contacts_number.label, pCharArray.get());
2526 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetPhoneNumber();
2527 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
2528 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2530 contacts_record_set_str(recordHandle, _contacts_number.number, pCharArray.get());
2536 _ContactImpl::SetNicknameAt(int index, const String& nickname)
2538 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);
2539 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));
2540 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2542 unsigned int count = 0;
2543 contacts_record_h nicknameHandle = null;
2545 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
2546 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);
2548 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, index, &nicknameHandle);
2550 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(nickname));
2551 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2553 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
2559 _ContactImpl::SetNoteAt(int index, const String& note)
2561 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);
2562 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));
2563 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2565 unsigned int count = 0;
2566 contacts_record_h noteHandle = null;
2568 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
2569 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);
2571 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, index, ¬eHandle);
2573 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(note));
2574 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2576 contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
2582 _ContactImpl::SetOrganizationAt(int index, const Organization& organization)
2584 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);
2585 SysTryReturn(NID_SCL
2586 , !organization.GetName().IsEmpty() ||
2587 !organization.GetJobTitle().IsEmpty() ||
2588 !organization.GetDepartment().IsEmpty() ||
2589 !organization.GetRole().IsEmpty() ||
2590 !organization.GetAgent().IsEmpty() ||
2591 !organization.GetDescription().IsEmpty() ||
2592 !organization.GetLocation().IsEmpty() ||
2593 !organization.GetPhoneticName().IsEmpty() ||
2594 !organization.GetLogoPath().IsEmpty()
2595 ,E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The organization is empty.", GetErrorMessage(E_INVALID_ARG));
2596 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2598 unsigned int count = 0;
2599 contacts_record_h organizationHandle = null;
2601 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
2602 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);
2605 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, index, &organizationHandle);
2608 String stringValue = organization.GetName();
2609 if (!stringValue.IsEmpty())
2611 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2612 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2614 contacts_record_set_str(organizationHandle, _contacts_company.name, pCharArray.get());
2618 contacts_record_set_str(organizationHandle, _contacts_company.name, null);
2622 stringValue = organization.GetJobTitle();
2623 if (!stringValue.IsEmpty())
2625 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2626 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2628 contacts_record_set_str(organizationHandle, _contacts_company.job_title, pCharArray.get());
2632 contacts_record_set_str(organizationHandle, _contacts_company.job_title, null);
2636 stringValue = organization.GetDepartment();
2637 if (!stringValue.IsEmpty())
2639 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2640 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2642 contacts_record_set_str(organizationHandle, _contacts_company.department, pCharArray.get());
2646 contacts_record_set_str(organizationHandle, _contacts_company.department, null);
2650 stringValue = organization.GetRole();
2651 if (!stringValue.IsEmpty())
2653 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2654 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2656 contacts_record_set_str(organizationHandle, _contacts_company.role, pCharArray.get());
2660 contacts_record_set_str(organizationHandle, _contacts_company.role, null);
2664 stringValue = organization.GetAgent();
2665 if (!stringValue.IsEmpty())
2667 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2668 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2670 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, pCharArray.get());
2674 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, null);
2680 switch (organization.GetType())
2682 case ORGANIZATION_TYPE_WORK:
2683 type = CONTACTS_COMPANY_TYPE_WORK;
2685 case ORGANIZATION_TYPE_CUSTOM:
2686 type = CONTACTS_COMPANY_TYPE_CUSTOM;
2688 case ORGANIZATION_TYPE_OTHER:
2691 type = CONTACTS_COMPANY_TYPE_OTHER;
2695 contacts_record_set_int(organizationHandle, _contacts_company.type, type);
2698 stringValue = organization.GetLabel();
2699 if (!stringValue.IsEmpty())
2701 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2702 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2704 contacts_record_set_str(organizationHandle, _contacts_company.label, pCharArray.get());
2708 contacts_record_set_str(organizationHandle, _contacts_company.label, null);
2712 stringValue = organization.GetDescription();
2713 if (!stringValue.IsEmpty())
2715 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2716 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2718 contacts_record_set_str(organizationHandle, _contacts_company.description, pCharArray.get());
2722 contacts_record_set_str(organizationHandle, _contacts_company.description, null);
2726 stringValue = organization.GetLocation();
2727 if (!stringValue.IsEmpty())
2729 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2730 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2732 contacts_record_set_str(organizationHandle, _contacts_company.location, pCharArray.get());
2736 contacts_record_set_str(organizationHandle, _contacts_company.location, null);
2740 stringValue = organization.GetPhoneticName();
2741 if (!stringValue.IsEmpty())
2743 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2744 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2746 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, pCharArray.get());
2750 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, null);
2754 if (_OrganizationImpl::GetInstance(organization)->IsLogoPathChanged() == true)
2756 stringValue = organization.GetLogoPath();
2757 if (!stringValue.IsEmpty())
2759 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2760 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2762 contacts_record_set_str(organizationHandle, _contacts_company.logo, pCharArray.get());
2766 contacts_record_set_str(organizationHandle, _contacts_company.logo, null);
2774 _ContactImpl::SetEventAt(int index, const ContactEvent& event)
2776 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);
2777 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2778 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));
2782 unsigned int count = 0;
2784 contacts_record_h eventHandle = null;
2786 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
2787 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);
2789 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, index, &eventHandle);
2791 switch (event.GetType())
2793 case CONTACT_EVENT_TYPE_ANNIVERSARY:
2794 type = CONTACTS_EVENT_TYPE_ANNIVERSARY;
2796 case CONTACT_EVENT_TYPE_BIRTHDAY:
2797 type = CONTACTS_EVENT_TYPE_BIRTH;
2799 case CONTACT_EVENT_TYPE_CUSTOM:
2800 type = CONTACTS_EVENT_TYPE_CUSTOM;
2802 case CONTACT_EVENT_TYPE_OTHER:
2805 type = CONTACTS_EVENT_TYPE_OTHER;
2810 contacts_record_set_int(eventHandle, _contacts_event.type, type);
2813 stringValue = event.GetLabel();
2815 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2816 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2818 contacts_record_set_str(eventHandle, _contacts_event.label, pCharArray.get());
2821 DateTime dateValue = event.GetDate();
2822 intValue = dateValue.GetYear()*10000 + dateValue.GetMonth()*100 + dateValue.GetDay();
2823 contacts_record_set_int(eventHandle, _contacts_event.date, intValue);
2829 _ContactImpl::SetRelationshipAt(int index, const Relationship& relationship)
2831 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);
2832 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));
2833 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2836 unsigned int count = 0;
2837 contacts_record_h relationshipHandle = null;
2839 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.relationship, &count);
2840 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);
2842 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.relationship, index, &relationshipHandle);
2844 switch (relationship.GetType())
2846 case CONTACT_RELATIONSHIP_TYPE_ASSISTANT:
2847 intValue = CONTACTS_RELATIONSHIP_TYPE_ASSISTANT;
2849 case CONTACT_RELATIONSHIP_TYPE_BROTHER:
2850 intValue = CONTACTS_RELATIONSHIP_TYPE_BROTHER;
2852 case CONTACT_RELATIONSHIP_TYPE_CHILD:
2853 intValue = CONTACTS_RELATIONSHIP_TYPE_CHILD;
2855 case CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
2856 intValue = CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER;
2858 case CONTACT_RELATIONSHIP_TYPE_FATHER:
2859 intValue = CONTACTS_RELATIONSHIP_TYPE_FATHER;
2861 case CONTACT_RELATIONSHIP_TYPE_FRIEND:
2862 intValue = CONTACTS_RELATIONSHIP_TYPE_FRIEND;
2864 case CONTACT_RELATIONSHIP_TYPE_MANAGER:
2865 intValue = CONTACTS_RELATIONSHIP_TYPE_MANAGER;
2867 case CONTACT_RELATIONSHIP_TYPE_MOTHER:
2868 intValue = CONTACTS_RELATIONSHIP_TYPE_MOTHER;
2870 case CONTACT_RELATIONSHIP_TYPE_PARENT:
2871 intValue = CONTACTS_RELATIONSHIP_TYPE_PARENT;
2873 case CONTACT_RELATIONSHIP_TYPE_PARTNER:
2874 intValue = CONTACTS_RELATIONSHIP_TYPE_PARTNER;
2876 case CONTACT_RELATIONSHIP_TYPE_REFERRED_BY:
2877 intValue = CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY;
2879 case CONTACT_RELATIONSHIP_TYPE_RELATIVE:
2880 intValue = CONTACTS_RELATIONSHIP_TYPE_RELATIVE;
2882 case CONTACT_RELATIONSHIP_TYPE_SISTER:
2883 intValue = CONTACTS_RELATIONSHIP_TYPE_SISTER;
2885 case CONTACT_RELATIONSHIP_TYPE_SPOUSE:
2886 intValue = CONTACTS_RELATIONSHIP_TYPE_SPOUSE;
2888 case CONTACT_RELATIONSHIP_TYPE_CUSTOM:
2889 intValue = CONTACTS_RELATIONSHIP_TYPE_CUSTOM;
2892 intValue = CONTACTS_RELATIONSHIP_TYPE_OTHER;
2897 contacts_record_set_int(relationshipHandle, _contacts_relationship.type, intValue);
2900 String stringValue = relationship.GetLabel();
2901 if (!stringValue.IsEmpty())
2903 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2904 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2906 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, pCharArray.get());
2910 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, null);
2914 stringValue = relationship.GetRelativeName();
2915 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2916 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2918 contacts_record_set_str(relationshipHandle, _contacts_relationship.name, pCharArray.get());
2924 _ContactImpl::SetEmailAt(int index, const Email& email)
2926 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);
2927 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));
2928 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2930 unsigned int count = 0;
2931 contacts_record_h emailHandle = null;
2936 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
2937 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);
2939 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.email, index, &emailHandle);
2941 stringValue = _EmailImpl::GetInstance(email)->GetLabel();
2943 switch (_EmailImpl::GetInstance(email)->GetType())
2945 case EMAIL_TYPE_PERSONAL:
2946 type = CONTACTS_EMAIL_TYPE_HOME;
2948 case EMAIL_TYPE_WORK:
2949 type = CONTACTS_EMAIL_TYPE_WORK;
2951 case EMAIL_TYPE_CUSTOM:
2952 type = CONTACTS_EMAIL_TYPE_CUSTOM;
2954 case EMAIL_TYPE_MOBILE:
2955 type = CONTACTS_EMAIL_TYPE_MOBILE;
2957 case EMAIL_TYPE_OTHER:
2958 contacts_record_get_int(emailHandle, _contacts_email.type, &oriType);
2959 if (oriType == CONTACTS_EMAIL_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
2961 char* pCharValue = null;
2963 contacts_record_get_str_p(emailHandle, _contacts_email.label, &pCharValue);
2965 stringValue = pCharValue;
2966 type = CONTACTS_EMAIL_TYPE_CUSTOM;
2968 else if (oriType == CONTACTS_EMAIL_TYPE_MOBILE && _AppInfo::GetApiVersion() < _API_VERSION_2_1)
2970 type = CONTACTS_EMAIL_TYPE_MOBILE;
2974 type = CONTACTS_EMAIL_TYPE_OTHER;
2978 type = CONTACTS_EMAIL_TYPE_OTHER;
2983 contacts_record_set_int(emailHandle, _contacts_email.type, type);
2986 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2987 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2989 contacts_record_set_str(emailHandle, _contacts_email.label, pCharArray.get());
2992 stringValue = _EmailImpl::GetInstance(email)->GetEmail();
2993 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
2994 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2996 contacts_record_set_str(emailHandle, _contacts_email.email, pCharArray.get());
3002 _ContactImpl::SetUrlAt(int index, const Url& url)
3004 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);
3005 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));
3006 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3008 unsigned int count = 0;
3009 contacts_record_h recordHandle = null;
3014 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
3015 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);
3017 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.url, index, &recordHandle);
3020 stringValue = _UrlImpl::GetInstance(url)->GetLabel();
3022 switch (_UrlImpl::GetInstance(url)->GetType())
3024 case URL_TYPE_PERSONAL:
3025 type = CONTACTS_URL_TYPE_HOME;
3028 type = CONTACTS_URL_TYPE_WORK;
3030 case URL_TYPE_CUSTOM:
3031 type = CONTACTS_URL_TYPE_CUSTOM;
3033 case URL_TYPE_OTHER:
3034 contacts_record_get_int(recordHandle, _contacts_url.type, &oriType);
3036 if (oriType == CONTACTS_URL_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
3038 char* pCharValue = null;
3040 contacts_record_get_str_p(recordHandle, _contacts_url.label, &pCharValue);
3042 stringValue = pCharValue;
3043 type = CONTACTS_URL_TYPE_CUSTOM;
3047 type = CONTACTS_URL_TYPE_OTHER;
3051 type = CONTACTS_URL_TYPE_OTHER;
3056 contacts_record_set_int(recordHandle, _contacts_url.type, type);
3059 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
3060 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3062 contacts_record_set_str(recordHandle, _contacts_url.label, pCharArray.get());
3065 stringValue = _UrlImpl::GetInstance(url)->GetUrl();
3066 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
3067 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3069 contacts_record_set_str(recordHandle, _contacts_url.url, pCharArray.get());
3075 _ContactImpl::SetAddressAt(int index, const Address& address)
3077 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);
3078 SysTryReturn(NID_SCL,
3079 !address.GetCity().IsEmpty() ||
3080 !address.GetCountry().IsEmpty() ||
3081 !address.GetExtended().IsEmpty() ||
3082 !address.GetPostalCode().IsEmpty() ||
3083 !address.GetPostOfficeBoxNumber().IsEmpty() ||
3084 !address.GetState().IsEmpty() ||
3085 !address.GetStreet().IsEmpty(),
3086 E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The address is empty.", GetErrorMessage(E_INVALID_ARG));
3087 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3089 unsigned int count = 0;
3090 contacts_record_h recordHandle = null;
3095 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
3096 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);
3098 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.address, index, &recordHandle);
3100 stringValue = _AddressImpl::GetInstance(address)->GetLabel();
3102 switch (_AddressImpl::GetInstance(address)->GetType())
3104 case ADDRESS_TYPE_HOME:
3105 type = CONTACTS_ADDRESS_TYPE_HOME;
3107 case ADDRESS_TYPE_WORK:
3108 type = CONTACTS_ADDRESS_TYPE_WORK;
3110 case ADDRESS_TYPE_CUSTOM:
3111 type = CONTACTS_ADDRESS_TYPE_CUSTOM;
3113 case ADDRESS_TYPE_OTHER:
3114 contacts_record_get_int(recordHandle, _contacts_address.type, &oriType);
3116 if (oriType == CONTACTS_ADDRESS_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
3118 char* pCharValue = null;
3120 contacts_record_get_str_p(recordHandle, _contacts_address.label, &pCharValue);
3122 stringValue = pCharValue;
3123 type = CONTACTS_ADDRESS_TYPE_CUSTOM;
3127 type = CONTACTS_ADDRESS_TYPE_OTHER;
3131 type = CONTACTS_ADDRESS_TYPE_OTHER;
3136 contacts_record_set_int(recordHandle, _contacts_address.type, type);
3139 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
3140 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3142 contacts_record_set_str(recordHandle, _contacts_address.label, pCharArray.get());
3145 stringValue = _AddressImpl::GetInstance(address)->GetCity();
3146 if (!stringValue.IsEmpty())
3148 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
3149 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3151 contacts_record_set_str(recordHandle, _contacts_address.locality, pCharArray.get());
3155 contacts_record_set_str(recordHandle, _contacts_address.locality, null);
3158 stringValue = _AddressImpl::GetInstance(address)->GetCountry();
3159 if (!stringValue.IsEmpty())
3161 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
3162 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3164 contacts_record_set_str(recordHandle, _contacts_address.country, pCharArray.get());
3168 contacts_record_set_str(recordHandle, _contacts_address.country, null);
3171 stringValue = _AddressImpl::GetInstance(address)->GetExtended();
3172 if (!stringValue.IsEmpty())
3174 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
3175 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3177 contacts_record_set_str(recordHandle, _contacts_address.extended, pCharArray.get());
3181 contacts_record_set_str(recordHandle, _contacts_address.extended, null);
3184 stringValue = _AddressImpl::GetInstance(address)->GetPostalCode();
3185 if (!stringValue.IsEmpty())
3187 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
3188 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3190 contacts_record_set_str(recordHandle, _contacts_address.postal_code, pCharArray.get());
3194 contacts_record_set_str(recordHandle, _contacts_address.postal_code, null);
3197 stringValue = _AddressImpl::GetInstance(address)->GetPostOfficeBoxNumber();
3198 if (!stringValue.IsEmpty())
3200 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
3201 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3203 contacts_record_set_str(recordHandle, _contacts_address.postbox, pCharArray.get());
3207 contacts_record_set_str(recordHandle, _contacts_address.postbox, null);
3210 stringValue = _AddressImpl::GetInstance(address)->GetState();
3211 if (!stringValue.IsEmpty())
3213 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
3214 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3216 contacts_record_set_str(recordHandle, _contacts_address.region, pCharArray.get());
3220 contacts_record_set_str(recordHandle, _contacts_address.region, null);
3223 stringValue = _AddressImpl::GetInstance(address)->GetStreet();
3224 if (!stringValue.IsEmpty())
3226 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
3227 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3229 contacts_record_set_str(recordHandle, _contacts_address.street, pCharArray.get());
3233 contacts_record_set_str(recordHandle, _contacts_address.street, null);
3240 _ContactImpl::SetImAddressAt(int index, const ImAddress& imAddress)
3242 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);
3243 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));
3244 SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3246 unsigned int count = 0;
3247 contacts_record_h messengerHandle = null;
3250 std::unique_ptr<char[]> pCharArray(null);
3252 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
3253 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);
3255 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.messenger, index, &messengerHandle);
3257 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetServiceProviderName();
3259 if (stringValue == IM_ADDRESS_GOOGLE_TALK)
3261 type = CONTACTS_MESSENGER_TYPE_GOOGLE;
3263 else if (stringValue == IM_ADDRESS_MSN)
3265 type = CONTACTS_MESSENGER_TYPE_WLM;
3267 else if (stringValue == IM_ADDRESS_ICQ)
3269 type = CONTACTS_MESSENGER_TYPE_ICQ;
3271 else if (stringValue == IM_ADDRESS_AIM)
3273 type = CONTACTS_MESSENGER_TYPE_AIM;
3275 else if (stringValue == IM_ADDRESS_YAHOO)
3277 type = CONTACTS_MESSENGER_TYPE_YAHOO;
3279 else if (stringValue == IM_ADDRESS_QQ)
3281 type = CONTACTS_MESSENGER_TYPE_QQ;
3283 else if (stringValue == IM_ADDRESS_SKYPE)
3285 type = CONTACTS_MESSENGER_TYPE_SKYPE;
3287 else if (stringValue == IM_ADDRESS_JABBER)
3289 type = CONTACTS_MESSENGER_TYPE_JABBER;
3291 else if (stringValue == IM_ADDRESS_IRC)
3293 type = CONTACTS_MESSENGER_TYPE_IRC;
3295 else if (stringValue == IM_ADDRESS_FACEBOOK)
3297 type = CONTACTS_MESSENGER_TYPE_FACEBOOK;
3301 type = CONTACTS_MESSENGER_TYPE_CUSTOM;
3304 contacts_record_set_int(messengerHandle, _contacts_messenger.type, type);
3305 if (type == CONTACTS_MESSENGER_TYPE_CUSTOM)
3307 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
3308 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3310 contacts_record_set_str(messengerHandle, _contacts_messenger.label, pCharArray.get());
3313 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetImAddress();
3314 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
3315 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3317 contacts_record_set_str(messengerHandle, _contacts_messenger.im_id, pCharArray.get());
3323 _ContactImpl::SetContactAppLaunchDataAt(int index, const ContactAppLaunchData& appLaunchData)
3325 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);
3326 SysTryReturn(NID_SCL, !_ContactAppLaunchDataImpl::GetInstance(appLaunchData)->IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified app launch data does not have any property.", GetErrorMessage(E_INVALID_ARG));
3328 unsigned int count = 0;
3331 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.profile, &count);
3332 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 contact profile %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
3334 contacts_record_h profileRecord = null;
3335 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.profile, index, &profileRecord);
3337 strValue = _ContactAppLaunchDataImpl::GetInstance(appLaunchData)->GetDisplayText();
3338 if (strValue.IsEmpty())
3340 contacts_record_set_str(profileRecord, _contacts_profile.text, null);
3345 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
3346 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3348 contacts_record_set_str(profileRecord, _contacts_profile.text, pCharArray.get());
3351 strValue = _ContactAppLaunchDataImpl::GetInstance(appLaunchData)->GetUid();
3352 if (strValue.IsEmpty())
3354 contacts_record_set_str(profileRecord, _contacts_profile.uid, null);
3359 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
3360 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3362 contacts_record_set_str(profileRecord, _contacts_profile.uid, pCharArray.get());
3365 strValue = _ContactAppLaunchDataImpl::GetInstance(appLaunchData)->GetAppId();
3366 if (strValue.IsEmpty())
3368 contacts_record_set_str(profileRecord, _contacts_profile.app_id, null);
3373 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
3374 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3376 contacts_record_set_str(profileRecord, _contacts_profile.app_id, pCharArray.get());
3379 strValue = _ContactAppLaunchDataImpl::GetInstance(appLaunchData)->GetOperationId();
3380 if (strValue.IsEmpty())
3382 contacts_record_set_str(profileRecord, _contacts_profile.service_operation, null);
3387 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
3388 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3390 contacts_record_set_str(profileRecord, _contacts_profile.service_operation, pCharArray.get());
3393 strValue = _ContactAppLaunchDataImpl::GetInstance(appLaunchData)->GetUri();
3394 if (strValue.IsEmpty())
3396 contacts_record_set_str(profileRecord, _contacts_profile.uri, null);
3401 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
3402 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3404 contacts_record_set_str(profileRecord, _contacts_profile.uri, pCharArray.get());
3407 strValue = _ContactAppLaunchDataImpl::GetInstance(appLaunchData)->GetCategory();
3408 if (strValue.IsEmpty())
3410 contacts_record_set_str(profileRecord, _contacts_profile.category, null);
3415 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
3416 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3418 contacts_record_set_str(profileRecord, _contacts_profile.category, pCharArray.get());
3421 strValue = _ContactAppLaunchDataImpl::GetInstance(appLaunchData)->GetMime();
3422 if (strValue.IsEmpty())
3424 contacts_record_set_str(profileRecord, _contacts_profile.mime, null);
3429 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(strValue));
3430 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3432 contacts_record_set_str(profileRecord, _contacts_profile.mime, pCharArray.get());
3436 std::unique_ptr<IMap, AllElementsDeleter> pExtraData(appLaunchData.GetExtraDataN());
3437 SysTryReturn(NID_SCL, pExtraData != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3439 std::unique_ptr<IMapEnumerator> pMapEnum(pExtraData->GetMapEnumeratorN());
3440 SysTryReturn(NID_SCL, pMapEnum != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
3442 result r = E_SUCCESS;
3444 bool isFirst = true;
3445 String extraData(L"");
3446 String encodedString(L"");
3447 std::unique_ptr<ByteBuffer> pByteBuffer(null);
3449 String* pKey = null;
3450 String* pVal = null;
3452 while (pMapEnum->MoveNext() == E_SUCCESS)
3456 extraData.Append(L",");
3463 pKey = static_cast<String*> (pMapEnum->GetKey());
3464 pVal = static_cast<String*> (pMapEnum->GetValue());
3466 pByteBuffer.reset(StringUtil::StringToUtf8N(*pKey));
3467 SysTryReturn(NID_SCL, pByteBuffer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3469 limit = pByteBuffer->GetLimit();
3470 pByteBuffer->SetLimit(limit - 1);
3472 r = StringUtil::EncodeToBase64String(*pByteBuffer, encodedString);
3473 SysTryReturn(NID_SCL, !IsFailed(r), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argutmnet is used.", GetErrorMessage(E_INVALID_ARG));
3475 extraData.Append(encodedString);
3476 extraData.Append(L":");
3478 pByteBuffer.reset(StringUtil::StringToUtf8N(*pVal));
3479 SysTryReturn(NID_SCL, pByteBuffer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3481 limit = pByteBuffer->GetLimit();
3482 pByteBuffer->SetLimit(limit - 1);
3484 r = StringUtil::EncodeToBase64String(*pByteBuffer, encodedString);
3485 SysTryReturn(NID_SCL, !IsFailed(r), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argutmnet is used.", GetErrorMessage(E_INVALID_ARG));
3487 extraData.Append(encodedString);
3490 if (!extraData.IsEmpty())
3492 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(extraData));
3493 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3495 contacts_record_set_str(profileRecord, _contacts_profile.extra_data, pCharArray.get());
3499 contacts_record_set_str(profileRecord, _contacts_profile.extra_data, null);
3509 _ContactImpl::GetMaxLength(ContactPropertyId id)
3513 case CONTACT_PROPERTY_ID_FIRST_NAME:
3515 case CONTACT_PROPERTY_ID_LAST_NAME:
3517 case CONTACT_PROPERTY_ID_DISPLAY_NAME:
3519 case CONTACT_PROPERTY_ID_NICK_NAME:
3521 case CONTACT_PROPERTY_ID_MIDDLE_NAME:
3522 return MAX_CONTACT_NAME_LENGTH;
3524 case CONTACT_PROPERTY_ID_THUMBNAIL:
3527 case CONTACT_PROPERTY_ID_JOB_TITLE:
3528 return MAX_CONTACT_JOB_TITLE_LENGTH;
3530 case CONTACT_PROPERTY_ID_COMPANY:
3531 return MAX_CONTACT_COMPANY_LENGTH;
3533 case CONTACT_PROPERTY_ID_NOTE:
3534 return MAX_CONTACT_NOTE_LENGTH;
3536 case CONTACT_PROPERTY_ID_RINGTONE:
3539 case CONTACT_PROPERTY_ID_PHONETIC_FIRST_NAME:
3541 case CONTACT_PROPERTY_ID_PHONETIC_LAST_NAME:
3543 case CONTACT_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
3544 return MAX_CONTACT_NAME_LENGTH;
3552 _ContactImpl::GetOrganizationsN(void) const
3554 result r = E_SUCCESS;
3555 contacts_record_h organizationHandle = null;
3556 int ret = CONTACTS_ERROR_NONE;
3557 char* pCharValue = null;
3559 unsigned int count = 0;
3560 std::unique_ptr<Organization> pOrganization(null);
3562 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3563 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3565 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
3567 r = pList->Construct(count);
3568 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3570 for (unsigned int i = 0; i < count; i++)
3572 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, i, &organizationHandle);
3573 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
3575 pOrganization.reset(new (std::nothrow) Organization());
3576 SysTryReturn(NID_SCL, pOrganization != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3579 contacts_record_get_str_p(organizationHandle, _contacts_company.name, &pCharValue);
3580 pOrganization->SetName(pCharValue);
3583 contacts_record_get_str_p(organizationHandle, _contacts_company.job_title, &pCharValue);
3584 pOrganization->SetJobTitle(pCharValue);
3587 contacts_record_get_str_p(organizationHandle, _contacts_company.department, &pCharValue);
3588 pOrganization->SetDepartment(pCharValue);
3591 contacts_record_get_str_p(organizationHandle, _contacts_company.role, &pCharValue);
3592 pOrganization->SetRole(pCharValue);
3595 contacts_record_get_str_p(organizationHandle, _contacts_company.assistant_name, &pCharValue);
3596 pOrganization->SetAgent(pCharValue);
3599 contacts_record_get_int(organizationHandle, _contacts_company.type, &intValue);
3602 case CONTACTS_COMPANY_TYPE_WORK:
3603 pOrganization->SetType(ORGANIZATION_TYPE_WORK);
3605 case CONTACTS_COMPANY_TYPE_CUSTOM:
3606 pOrganization->SetType(ORGANIZATION_TYPE_CUSTOM);
3608 case CONTACTS_COMPANY_TYPE_OTHER:
3611 pOrganization->SetType(ORGANIZATION_TYPE_OTHER);
3616 contacts_record_get_str_p(organizationHandle, _contacts_company.label, &pCharValue);
3617 pOrganization->SetLabel(pCharValue);
3620 contacts_record_get_str_p(organizationHandle, _contacts_company.description, &pCharValue);
3621 pOrganization->SetDescription(pCharValue);
3624 contacts_record_get_str_p(organizationHandle, _contacts_company.location, &pCharValue);
3625 pOrganization->SetLocation(pCharValue);
3628 contacts_record_get_str_p(organizationHandle, _contacts_company.phonetic_name, &pCharValue);
3629 pOrganization->SetPhoneticName(pCharValue);
3632 contacts_record_get_str_p(organizationHandle, _contacts_company.logo, &pCharValue);
3633 _OrganizationImpl::GetInstance(*pOrganization)->SetLogoPath(pCharValue);
3635 r = pList->Add(*pOrganization);
3636 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3638 pOrganization.release();
3641 return pList.release();
3645 _ContactImpl::GetRelationshipsN(void) const
3647 result r = E_SUCCESS;
3648 contacts_record_h relationshipHandle = null;
3649 int ret = CONTACTS_ERROR_NONE;
3651 char* pCharValue = null;
3652 unsigned int count = 0;
3653 std::unique_ptr<Relationship> pRelationship(null);
3655 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3656 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3658 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.relationship, &count);
3660 r = pList->Construct(count);
3661 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3663 for (unsigned int i = 0; i < count; i++)
3665 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.relationship, i, &relationshipHandle);
3666 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
3668 pRelationship.reset(new (std::nothrow) Relationship());
3669 SysTryReturn(NID_SCL, pRelationship != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3672 contacts_record_get_int(relationshipHandle, _contacts_relationship.type, &intValue);
3675 case CONTACTS_RELATIONSHIP_TYPE_ASSISTANT:
3676 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_ASSISTANT);
3678 case CONTACTS_RELATIONSHIP_TYPE_BROTHER:
3679 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_BROTHER);
3681 case CONTACTS_RELATIONSHIP_TYPE_CHILD:
3682 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_CHILD);
3684 case CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
3685 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER);
3687 case CONTACTS_RELATIONSHIP_TYPE_FATHER:
3688 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_FATHER);
3690 case CONTACTS_RELATIONSHIP_TYPE_FRIEND:
3691 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_FRIEND);
3693 case CONTACTS_RELATIONSHIP_TYPE_MANAGER:
3694 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_MANAGER);
3696 case CONTACTS_RELATIONSHIP_TYPE_MOTHER:
3697 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_MOTHER);
3699 case CONTACTS_RELATIONSHIP_TYPE_PARENT:
3700 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_PARENT);
3702 case CONTACTS_RELATIONSHIP_TYPE_PARTNER:
3703 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_PARTNER);
3705 case CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY:
3706 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_REFERRED_BY);
3708 case CONTACTS_RELATIONSHIP_TYPE_RELATIVE:
3709 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_RELATIVE);
3711 case CONTACTS_RELATIONSHIP_TYPE_SISTER:
3712 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_SISTER);
3714 case CONTACTS_RELATIONSHIP_TYPE_SPOUSE:
3715 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_SPOUSE);
3717 case CONTACTS_RELATIONSHIP_TYPE_CUSTOM:
3720 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_CUSTOM);
3725 contacts_record_get_str_p(relationshipHandle, _contacts_relationship.label, &pCharValue);
3726 pRelationship->SetLabel(pCharValue);
3729 contacts_record_get_str_p(relationshipHandle, _contacts_relationship.name, &pCharValue);
3730 pRelationship->SetRelativeName(pCharValue);
3732 r = pList->Add(*pRelationship);
3733 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3735 pRelationship.release();
3738 return pList.release();
3742 _ContactImpl::GetEventsN(void) const
3744 result r = E_SUCCESS;
3745 char* pCharValue = null;
3747 unsigned int count = 0;
3748 contacts_record_h eventHandle = null;
3749 std::unique_ptr<ContactEvent> pEvent(null);
3751 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3752 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3754 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
3756 r = pList->Construct(count);
3757 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3759 for (unsigned int i = 0; i < count; i++)
3761 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &eventHandle);
3763 pEvent.reset(new (std::nothrow) ContactEvent());
3764 SysTryReturn(NID_SCL, pEvent != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3767 contacts_record_get_str_p(eventHandle, _contacts_event.label, &pCharValue);
3768 pEvent->SetLabel(pCharValue);
3771 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
3774 case CONTACTS_EVENT_TYPE_BIRTH:
3775 pEvent->SetType(CONTACT_EVENT_TYPE_BIRTHDAY);
3777 case CONTACTS_EVENT_TYPE_ANNIVERSARY:
3778 pEvent->SetType(CONTACT_EVENT_TYPE_ANNIVERSARY);
3780 case CONTACTS_URL_TYPE_CUSTOM:
3781 pEvent->SetType(CONTACT_EVENT_TYPE_CUSTOM);
3784 pEvent->SetType(CONTACT_EVENT_TYPE_OTHER);
3790 contacts_record_get_int(eventHandle, _contacts_event.date, &intValue);
3791 __CONVERT_DATE_TO_DATETIME(intValue, dateTime);
3792 pEvent->SetDate(dateTime);
3794 pList->Add(*pEvent);
3795 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3800 return pList.release();
3804 _ContactImpl::GetNotesN(void) const
3806 result r = E_SUCCESS;
3807 char* pCharValue = null;
3808 unsigned int count = 0;
3809 contacts_record_h noteHandle = null;
3810 std::unique_ptr<String> pNote(null);
3812 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3813 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3815 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
3817 r = pList->Construct(count);
3818 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3820 for (unsigned int i = 0; i < count; i++)
3822 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, i, ¬eHandle);
3824 contacts_record_get_str_p(noteHandle, _contacts_note.note, &pCharValue);
3826 pNote.reset(new (std::nothrow) String(pCharValue));
3827 SysTryReturn(NID_SCL, pNote != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3830 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3835 return pList.release();
3839 _ContactImpl::GetNicknamesN(void) const
3841 result r = E_SUCCESS;
3842 char* pCharValue = null;
3843 unsigned int count = 0;
3844 contacts_record_h nicknameHandle = null;
3845 std::unique_ptr<String> pNickname(null);
3847 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3848 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3850 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
3852 r = pList->Construct(count);
3853 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3855 for (unsigned int i = 0; i < count; i++)
3857 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, i, &nicknameHandle);
3859 contacts_record_get_str_p(nicknameHandle, _contacts_nickname.name, &pCharValue);
3861 pNickname.reset(new (std::nothrow) String(pCharValue));
3862 SysTryReturn(NID_SCL, pNickname != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3864 pList->Add(*pNickname);
3865 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3867 pNickname.release();
3870 return pList.release();
3874 _ContactImpl::GetContactAppLaunchDataN(void) const
3876 std::unique_ptr<ArrayList, AllElementsDeleter> pContactAppLaunchDataList(new (std::nothrow) ArrayList());
3877 SysTryReturn(NID_SCL, pContactAppLaunchDataList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3879 unsigned int count = 0;
3880 char* pCharValue = null;
3881 contacts_record_h profileRecord = null;
3882 std::unique_ptr<ContactAppLaunchData> pContactAppLaunchData(null);
3884 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.profile, &count);
3886 result r = pContactAppLaunchDataList->Construct(count);
3887 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3889 for (unsigned int i = 0; i < count; i++)
3891 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.profile, i, &profileRecord);
3893 pContactAppLaunchData.reset(new (std::nothrow) ContactAppLaunchData());
3894 SysTryReturn(NID_SCL, pContactAppLaunchData != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3896 contacts_record_get_str_p(profileRecord, _contacts_profile.text, &pCharValue);
3897 pContactAppLaunchData->SetDisplayText(pCharValue);
3899 contacts_record_get_str_p(profileRecord, _contacts_profile.uid, &pCharValue);
3900 _ContactAppLaunchDataImpl::GetInstance(*pContactAppLaunchData)->SetUid(pCharValue);
3902 contacts_record_get_str_p(profileRecord, _contacts_profile.app_id, &pCharValue);
3903 pContactAppLaunchData->SetAppId(pCharValue);
3905 contacts_record_get_str_p(profileRecord, _contacts_profile.service_operation, &pCharValue);
3906 pContactAppLaunchData->SetOperationId(pCharValue);
3908 contacts_record_get_str_p(profileRecord, _contacts_profile.uri, &pCharValue);
3909 pContactAppLaunchData->SetUri(pCharValue);
3911 contacts_record_get_str_p(profileRecord, _contacts_profile.category, &pCharValue);
3912 _ContactAppLaunchDataImpl::GetInstance(*pContactAppLaunchData)->SetCategory(pCharValue);
3914 contacts_record_get_str_p(profileRecord, _contacts_profile.mime, &pCharValue);
3915 pContactAppLaunchData->SetMime(pCharValue);
3917 contacts_record_get_str_p(profileRecord, _contacts_profile.extra_data, &pCharValue);
3918 if (pCharValue != null)
3920 result r = E_SUCCESS;
3921 String delim(L":,");
3922 String extraData(pCharValue);
3923 String decodedString(L"");
3924 std::unique_ptr<ByteBuffer> pByteBuffer(null);
3926 std::unique_ptr<HashMap, AllElementsDeleter> pHashMap(new (std::nothrow) HashMap());
3927 SysTryReturn(NID_SCL, pHashMap != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3929 r = pHashMap->Construct();
3930 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3932 StringTokenizer tokerizer(extraData, delim);
3935 while (tokerizer.HasMoreTokens())
3938 r = tokerizer.GetNextToken(token);
3944 pByteBuffer.reset(StringUtil::DecodeBase64StringN(token));
3945 SysTryReturn(NID_SCL, pByteBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3947 std::unique_ptr<String> pKey(new (std::nothrow) String());
3948 SysTryReturn(NID_SCL, pKey != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3950 StringUtil::Utf8ToString((const char*)pByteBuffer->GetPointer(), *pKey);
3953 r = tokerizer.GetNextToken(token);
3959 pByteBuffer.reset(StringUtil::DecodeBase64StringN(token));
3960 SysTryReturn(NID_SCL, pByteBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3962 std::unique_ptr<String> pValue(new (std::nothrow) String());
3963 SysTryReturn(NID_SCL, pValue != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3964 StringUtil::Utf8ToString((const char*)pByteBuffer->GetPointer(), *pValue);
3966 r = pHashMap->Add(pKey.get(), pValue.get());
3967 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3973 if (pHashMap->GetCount() > 0)
3975 pContactAppLaunchData->SetExtraData(pHashMap.get());
3979 r = pContactAppLaunchDataList->Add(*pContactAppLaunchData);
3980 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3982 pContactAppLaunchData.release();
3985 return pContactAppLaunchDataList.release();
3990 _ContactImpl::GetNativePhoneNumberType(int coreType) const
3992 PhoneNumberType type = PHONENUMBER_TYPE_HOME;
3996 case CONTACTS_NUMBER_TYPE_HOME:
3998 case CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE:
3999 type = PHONENUMBER_TYPE_HOME;
4001 case CONTACTS_NUMBER_TYPE_WORK:
4003 case CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE:
4004 type = PHONENUMBER_TYPE_WORK;
4006 case CONTACTS_NUMBER_TYPE_CELL:
4007 type = PHONENUMBER_TYPE_MOBILE;
4009 case CONTACTS_NUMBER_TYPE_FAX:
4011 case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME:
4012 type = PHONENUMBER_TYPE_HOME_FAX;
4014 case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK:
4015 type = PHONENUMBER_TYPE_WORK_FAX;
4017 case CONTACTS_NUMBER_TYPE_PAGER:
4018 type = PHONENUMBER_TYPE_PAGER;
4020 case CONTACTS_NUMBER_TYPE_CUSTOM:
4021 type = PHONENUMBER_TYPE_CUSTOM;
4023 case CONTACTS_NUMBER_TYPE_ASSISTANT:
4024 if (_AppInfo::GetApiVersion() < _API_VERSION_2_1)
4026 type = PHONENUMBER_TYPE_OTHER;
4030 type = PHONENUMBER_TYPE_ASSISTANT;
4033 case CONTACTS_NUMBER_TYPE_OTHER:
4034 type = PHONENUMBER_TYPE_OTHER;
4037 if (coreType & CONTACTS_NUMBER_TYPE_FAX)
4039 type = PHONENUMBER_TYPE_HOME_FAX;
4041 else if (coreType & CONTACTS_NUMBER_TYPE_CELL)
4043 type = PHONENUMBER_TYPE_MOBILE;
4045 else if (coreType & CONTACTS_NUMBER_TYPE_PAGER)
4047 type = PHONENUMBER_TYPE_PAGER;
4049 else if (coreType & CONTACTS_NUMBER_TYPE_HOME)
4051 type = PHONENUMBER_TYPE_HOME;
4053 else if (coreType & CONTACTS_NUMBER_TYPE_WORK)
4055 type = PHONENUMBER_TYPE_WORK;
4057 else if (coreType & CONTACTS_NUMBER_TYPE_VOICE)
4059 type = PHONENUMBER_TYPE_HOME;
4063 type = PHONENUMBER_TYPE_OTHER;
4072 _ContactImpl::GetPhoneNumbersN(void) const
4074 result r = E_SUCCESS;
4075 unsigned int count = 0;
4076 contacts_record_h numberHandle = null;
4078 char* pCharValue = null;
4079 PhoneNumberType type = PHONENUMBER_TYPE_HOME;
4080 std::unique_ptr<PhoneNumber> pPhoneNumber(null);
4082 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
4083 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4086 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
4088 contacts_record_get_int(__contactHandle, _contacts_contact.id, &intValue);
4090 r = pList->Construct(count);
4091 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4093 for (unsigned int i = 0; i < count; i++)
4095 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.number, i, &numberHandle);
4097 pPhoneNumber.reset(new (std::nothrow) PhoneNumber());
4098 SysTryReturn(NID_SCL, pPhoneNumber != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4100 contacts_record_get_int(numberHandle, _contacts_number.id, &intValue);
4101 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetRecordId(intValue);
4103 contacts_record_get_str_p(numberHandle, _contacts_number.label, &pCharValue);
4104 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetLabel(pCharValue);
4106 contacts_record_get_int(numberHandle, _contacts_number.type, &intValue);
4108 type = GetNativePhoneNumberType(intValue);
4110 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetType(type);
4112 contacts_record_get_str_p(numberHandle, _contacts_number.number, &pCharValue);
4113 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetPhoneNumber(pCharValue);
4115 r = pList->Add(*pPhoneNumber);
4116 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4118 pPhoneNumber.release();
4121 return pList.release();
4125 _ContactImpl::GetEmailsN(void) const
4127 result r = E_SUCCESS;
4128 contacts_record_h currentHandle = null;
4129 int ret = CONTACTS_ERROR_NONE;
4131 unsigned int count = 0;
4132 char* pCharValue = null;
4133 EmailType type = EMAIL_TYPE_PERSONAL;
4134 std::unique_ptr<Email> pEmail(null);
4136 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
4137 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4139 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
4141 r = pList->Construct(count);
4142 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4144 for (unsigned int i = 0; i < count; i++)
4146 ret = contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.email, i, ¤tHandle);
4147 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM))
4149 pEmail.reset(new (std::nothrow) Email());
4150 SysTryReturn(NID_SCL, pEmail != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4152 contacts_record_get_int(currentHandle, _contacts_email.id, &intValue);
4153 _EmailImpl::GetInstance(*pEmail)->SetRecordId(intValue);
4155 contacts_record_get_str_p(currentHandle, _contacts_email.label, &pCharValue);
4156 _EmailImpl::GetInstance(*pEmail)->SetLabel(pCharValue);
4158 contacts_record_get_int(currentHandle, _contacts_email.type, &intValue);
4161 case CONTACTS_EMAIL_TYPE_HOME:
4162 type = EMAIL_TYPE_PERSONAL;
4164 case CONTACTS_EMAIL_TYPE_WORK:
4165 type = EMAIL_TYPE_WORK;
4167 case CONTACTS_EMAIL_TYPE_CUSTOM:
4168 type = EMAIL_TYPE_CUSTOM;
4170 case CONTACTS_EMAIL_TYPE_MOBILE:
4171 if (_AppInfo::GetApiVersion() < _API_VERSION_2_1)
4173 type = EMAIL_TYPE_OTHER;
4177 type = EMAIL_TYPE_MOBILE;
4181 type = EMAIL_TYPE_OTHER;
4185 _EmailImpl::GetInstance(*pEmail)->SetType(type);
4187 contacts_record_get_str_p(currentHandle, _contacts_email.email, &pCharValue);
4188 _EmailImpl::GetInstance(*pEmail)->SetEmail(pCharValue);
4190 r = pList->Add(*pEmail);
4191 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4196 return pList.release();
4200 _ContactImpl::GetUrlsN(void) const
4202 result r = E_SUCCESS;
4203 char* pCharValue = null;
4205 unsigned int count = 0;
4206 UrlType type = URL_TYPE_PERSONAL;
4207 contacts_record_h urlHandle = null;
4208 std::unique_ptr<Url> pUrl(null);
4210 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
4211 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4213 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
4215 r = pList->Construct(count);
4216 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4218 for (unsigned int i = 0; i < count; i++)
4220 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.url, i, &urlHandle);
4222 pUrl.reset(new (std::nothrow) Url());
4223 SysTryReturn(NID_SCL, pUrl != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4225 contacts_record_get_str_p(urlHandle, _contacts_url.label, &pCharValue);
4226 pUrl->SetLabel(pCharValue);
4228 contacts_record_get_int(urlHandle, _contacts_url.type, &intValue);
4231 case CONTACTS_URL_TYPE_HOME:
4232 type = URL_TYPE_PERSONAL;
4234 case CONTACTS_URL_TYPE_WORK:
4235 type = URL_TYPE_WORK;
4237 case CONTACTS_URL_TYPE_CUSTOM:
4238 type = URL_TYPE_CUSTOM;
4241 type = URL_TYPE_OTHER;
4245 pUrl->SetType(type);
4247 contacts_record_get_str_p(urlHandle, _contacts_url.url, &pCharValue);
4248 _UrlImpl::GetInstance(*pUrl)->SetUrl(pCharValue);
4251 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4256 return pList.release();
4260 _ContactImpl::GetAddressesN(void) const
4262 result r = E_SUCCESS;
4263 char* pCharValue = null;
4265 unsigned int count = 0;
4266 contacts_record_h addressHandle = 0;
4267 std::unique_ptr<Address> pAddress(null);
4269 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
4270 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4272 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
4274 r = pList->Construct(count);
4275 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4278 for (unsigned int i = 0; i < count; i++)
4280 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.address, i, &addressHandle);
4282 pAddress.reset(new (std::nothrow) Address());
4283 SysTryReturn(NID_SCL, pAddress != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4285 contacts_record_get_str_p(addressHandle, _contacts_address.label, &pCharValue);
4286 pAddress->SetLabel(pCharValue);
4288 contacts_record_get_int(addressHandle, _contacts_address.type, &intValue);
4291 case CONTACTS_ADDRESS_TYPE_HOME:
4292 pAddress->SetType(ADDRESS_TYPE_HOME);
4294 case CONTACTS_ADDRESS_TYPE_WORK:
4295 pAddress->SetType(ADDRESS_TYPE_WORK);
4297 case CONTACTS_ADDRESS_TYPE_CUSTOM:
4298 pAddress->SetType(ADDRESS_TYPE_CUSTOM);
4301 pAddress->SetType(ADDRESS_TYPE_OTHER);
4306 contacts_record_get_str_p(addressHandle, _contacts_address.country, &pCharValue);
4307 _AddressImpl::GetInstance(*pAddress)->SetCountry(pCharValue);
4310 contacts_record_get_str_p(addressHandle, _contacts_address.region, &pCharValue);
4311 _AddressImpl::GetInstance(*pAddress)->SetState(pCharValue);
4314 contacts_record_get_str_p(addressHandle, _contacts_address.locality, &pCharValue);
4315 _AddressImpl::GetInstance(*pAddress)->SetCity(pCharValue);
4318 contacts_record_get_str_p(addressHandle, _contacts_address.street, &pCharValue);
4319 _AddressImpl::GetInstance(*pAddress)->SetStreet(pCharValue);
4322 contacts_record_get_str_p(addressHandle, _contacts_address.extended, &pCharValue);
4323 _AddressImpl::GetInstance(*pAddress)->SetExtended(pCharValue);
4326 contacts_record_get_str_p(addressHandle, _contacts_address.postbox, &pCharValue);
4327 _AddressImpl::GetInstance(*pAddress)->SetPostOfficeBoxNumber(pCharValue);
4330 contacts_record_get_str_p(addressHandle, _contacts_address.postal_code, &pCharValue);
4331 _AddressImpl::GetInstance(*pAddress)->SetPostalCode(pCharValue);
4333 r = pList->Add(*pAddress);
4334 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4339 return pList.release();
4343 _ContactImpl::GetImAddressesN(void) const
4345 result r = E_SUCCESS;
4346 char* pCharValue = null;
4348 contacts_record_h messengerHandle = null;
4349 unsigned int count = 0;
4350 std::unique_ptr<ImAddress> pImAddress(null);
4352 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
4353 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4355 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
4357 r = pList->Construct(count);
4358 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4361 for (unsigned int i = 0; i < count; i++)
4363 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.messenger, i, &messengerHandle);
4365 pImAddress.reset(new (std::nothrow) ImAddress());
4366 SysTryReturn(NID_SCL, pImAddress != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4368 contacts_record_get_int(messengerHandle, _contacts_messenger.type, &intValue);
4371 case CONTACTS_MESSENGER_TYPE_GOOGLE:
4372 pImAddress->SetServiceProviderName(IM_ADDRESS_GOOGLE_TALK);
4374 case CONTACTS_MESSENGER_TYPE_WLM:
4375 pImAddress->SetServiceProviderName(IM_ADDRESS_MSN);
4377 case CONTACTS_MESSENGER_TYPE_ICQ:
4378 pImAddress->SetServiceProviderName(IM_ADDRESS_ICQ);
4380 case CONTACTS_MESSENGER_TYPE_AIM:
4381 pImAddress->SetServiceProviderName(IM_ADDRESS_AIM);
4383 case CONTACTS_MESSENGER_TYPE_YAHOO:
4384 pImAddress->SetServiceProviderName(IM_ADDRESS_YAHOO);
4386 case CONTACTS_MESSENGER_TYPE_QQ:
4387 pImAddress->SetServiceProviderName(IM_ADDRESS_QQ);
4389 case CONTACTS_MESSENGER_TYPE_SKYPE:
4390 pImAddress->SetServiceProviderName(IM_ADDRESS_SKYPE);
4392 case CONTACTS_MESSENGER_TYPE_JABBER:
4393 pImAddress->SetServiceProviderName(IM_ADDRESS_JABBER);
4395 case CONTACTS_MESSENGER_TYPE_IRC:
4396 pImAddress->SetServiceProviderName(IM_ADDRESS_IRC);
4398 case CONTACTS_MESSENGER_TYPE_FACEBOOK:
4399 pImAddress->SetServiceProviderName(IM_ADDRESS_FACEBOOK);
4401 case CONTACTS_MESSENGER_TYPE_CUSTOM:
4404 contacts_record_get_str_p(messengerHandle, _contacts_messenger.label, &pCharValue);
4405 pImAddress->SetServiceProviderName(pCharValue);
4409 contacts_record_get_str_p(messengerHandle, _contacts_messenger.im_id, &pCharValue);
4410 _ImAddressImpl::GetInstance(*pImAddress)->SetImAddress(pCharValue);
4412 r = pList->Add(*pImAddress);
4413 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4415 pImAddress.release();
4418 return pList.release();
4422 _ContactImpl::IsEmpty(void) const
4424 char* pCharValue = null;
4425 unsigned int count = 0;
4427 contacts_record_get_str_p(__contactHandle, _contacts_contact.ringtone_path, &pCharValue);
4428 if (pCharValue != null)
4433 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
4439 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
4445 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
4451 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
4457 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
4463 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
4469 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
4475 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
4481 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
4487 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
4493 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
4499 contacts_record_get_str_p(__contactHandle, _contacts_contact.uid, &pCharValue);
4500 if (pCharValue != null)
4509 _ContactImpl::GetAddressbookId(void) const
4511 int addressbookId = 0;
4513 contacts_record_get_int(__contactHandle, _contacts_contact.address_book_id, &addressbookId);
4515 return addressbookId;
4519 _ContactImpl::GetPersonId(void) const
4523 contacts_record_get_int(__contactHandle, _contacts_contact.person_id, &personId);
4529 _ContactImpl::SetAsRemoved(void)
4535 _ContactImpl::IsRemoved(void) const
4541 _ContactImpl::IsFavorite(void) const
4543 bool isFavorite = false;
4544 contacts_record_get_bool(__contactHandle, _contacts_contact.is_favorite, &isFavorite);
4550 _ContactImpl::SetAsFavorite(bool isFavorite)
4552 contacts_record_set_bool(__contactHandle, _contacts_contact.is_favorite, isFavorite);
4556 _ContactImpl::Invalidate(void)
4558 int ret = CONTACTS_ERROR_NONE;
4560 unsigned int count = 0;
4561 char* pCharValue = null;
4563 bool boolValue = false;
4565 contacts_record_h contactHandle = null;
4566 contacts_record_h sourceRecordHandle = null;
4567 contacts_record_h destRecordHandle = null;
4569 ret = contacts_record_create(_contacts_contact._uri, &contactHandle);
4570 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4572 __ContactsRecordHandle recordHandle(contactHandle);
4575 contacts_record_get_bool(sourceRecordHandle, _contacts_contact.is_favorite, &boolValue);
4576 contacts_record_set_bool(destRecordHandle, _contacts_contact.is_favorite, boolValue);
4579 contacts_record_get_str_p(sourceRecordHandle, _contacts_contact.uid, &pCharValue);
4580 contacts_record_set_str(destRecordHandle, _contacts_contact.uid, pCharValue);
4582 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4584 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4585 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.name, &count);
4588 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.name, 0, &sourceRecordHandle);
4590 ret = contacts_record_create(_contacts_name._uri, &destRecordHandle);
4591 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4593 __ContactsRecordHandle nameHandle(destRecordHandle);
4596 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.first, &pCharValue);
4597 contacts_record_set_str(destRecordHandle, _contacts_name.first, pCharValue);
4600 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.last, &pCharValue);
4601 contacts_record_set_str(destRecordHandle, _contacts_name.last, pCharValue);
4604 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.addition, &pCharValue);
4605 contacts_record_set_str(destRecordHandle, _contacts_name.addition, pCharValue);
4608 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.suffix, &pCharValue);
4609 contacts_record_set_str(destRecordHandle, _contacts_name.suffix, pCharValue);
4612 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.prefix, &pCharValue);
4613 contacts_record_set_str(destRecordHandle, _contacts_name.prefix, pCharValue);
4615 // 6. phonetic_first
4616 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_first, &pCharValue);
4617 contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_first, pCharValue);
4620 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_last, &pCharValue);
4621 contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_last, pCharValue);
4623 // 8. phonetic_middle
4624 contacts_record_get_str_p(sourceRecordHandle, _contacts_name.phonetic_middle, &pCharValue);
4625 contacts_record_set_str(destRecordHandle, _contacts_name.phonetic_middle, pCharValue);
4627 contacts_record_add_child_record(contactHandle, _contacts_contact.name, destRecordHandle);
4629 nameHandle.Release();
4632 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4634 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4635 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.image, &count);
4636 for (i = 0; i < count; i++)
4638 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.image, i, &sourceRecordHandle);
4640 ret = contacts_record_create(_contacts_image._uri, &destRecordHandle);
4641 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4643 __ContactsRecordHandle imageHandle(destRecordHandle);
4645 contacts_record_get_int(sourceRecordHandle, _contacts_image.type, &intValue);
4646 contacts_record_set_int(destRecordHandle, _contacts_image.type, intValue);
4648 contacts_record_get_str_p(sourceRecordHandle, _contacts_image.label, &pCharValue);
4649 contacts_record_set_str(destRecordHandle, _contacts_image.label, pCharValue);
4651 contacts_record_get_str_p(sourceRecordHandle, _contacts_image.path, &pCharValue);
4652 contacts_record_set_str(destRecordHandle, _contacts_image.path, pCharValue);
4654 contacts_record_add_child_record(contactHandle, _contacts_contact.image, destRecordHandle);
4656 imageHandle.Release();
4659 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4661 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4662 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.company, &count);
4663 for (i = 0; i < count; i++)
4665 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.company, i, &sourceRecordHandle);
4667 ret = contacts_record_create(_contacts_company._uri, &destRecordHandle);
4668 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4670 __ContactsRecordHandle companyHandle(destRecordHandle);
4672 contacts_record_get_int(sourceRecordHandle, _contacts_company.type, &intValue);
4673 contacts_record_set_int(destRecordHandle, _contacts_company.type, intValue);
4675 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.name, &pCharValue);
4676 contacts_record_set_str(destRecordHandle, _contacts_company.name, pCharValue);
4678 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.department, &pCharValue);
4679 contacts_record_set_str(destRecordHandle, _contacts_company.department, pCharValue);
4681 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.job_title, &pCharValue);
4682 contacts_record_set_str(destRecordHandle, _contacts_company.job_title, pCharValue);
4684 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.assistant_name, &pCharValue);
4685 contacts_record_set_str(destRecordHandle, _contacts_company.assistant_name, pCharValue);
4687 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.role, &pCharValue);
4688 contacts_record_set_str(destRecordHandle, _contacts_company.role, pCharValue);
4690 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.logo, &pCharValue);
4691 contacts_record_set_str(destRecordHandle, _contacts_company.logo, pCharValue);
4693 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.location, &pCharValue);
4694 contacts_record_set_str(destRecordHandle, _contacts_company.location, pCharValue);
4696 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.description, &pCharValue);
4697 contacts_record_set_str(destRecordHandle, _contacts_company.description, pCharValue);
4699 contacts_record_get_str_p(sourceRecordHandle, _contacts_company.phonetic_name, &pCharValue);
4700 contacts_record_set_str(destRecordHandle, _contacts_company.phonetic_name, pCharValue);
4702 contacts_record_add_child_record(contactHandle, _contacts_contact.company, destRecordHandle);
4704 companyHandle.Release();
4707 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4709 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4710 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.note, &count);
4711 for (i = 0; i < count; i++)
4713 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.note, i, &sourceRecordHandle);
4715 ret = contacts_record_create(_contacts_note._uri, &destRecordHandle);
4716 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4718 __ContactsRecordHandle noteHandle(destRecordHandle);
4720 contacts_record_get_str_p(sourceRecordHandle, _contacts_note.note, &pCharValue);
4721 contacts_record_set_str(destRecordHandle, _contacts_note.note, pCharValue);
4723 contacts_record_add_child_record(contactHandle, _contacts_contact.note, destRecordHandle);
4725 noteHandle.Release();
4728 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4730 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4731 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
4732 for (i = 0; i < count; i++)
4734 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.number, i, &sourceRecordHandle);
4736 ret = contacts_record_create(_contacts_number._uri, &destRecordHandle);
4737 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4739 __ContactsRecordHandle numberHandle(destRecordHandle);
4741 contacts_record_get_int(sourceRecordHandle, _contacts_number.type, &intValue);
4742 contacts_record_set_int(destRecordHandle, _contacts_number.type, intValue);
4744 contacts_record_get_str_p(sourceRecordHandle, _contacts_number.label, &pCharValue);
4745 contacts_record_set_str(destRecordHandle, _contacts_number.label, pCharValue);
4747 contacts_record_get_str_p(sourceRecordHandle, _contacts_number.number, &pCharValue);
4748 contacts_record_set_str(destRecordHandle, _contacts_number.number, pCharValue);
4750 contacts_record_add_child_record(contactHandle, _contacts_contact.number, destRecordHandle);
4752 numberHandle.Release();
4755 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4757 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4758 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.email, &count);
4759 for (i = 0; i < count; i++)
4761 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.email, i, &sourceRecordHandle);
4763 ret = contacts_record_create(_contacts_email._uri, &destRecordHandle);
4764 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4766 __ContactsRecordHandle emailHandle(destRecordHandle);
4768 contacts_record_get_int(sourceRecordHandle, _contacts_email.type, &intValue);
4769 contacts_record_set_int(destRecordHandle, _contacts_email.type, intValue);
4771 contacts_record_get_str_p(sourceRecordHandle, _contacts_email.label, &pCharValue);
4772 contacts_record_set_str(destRecordHandle, _contacts_email.label, pCharValue);
4774 contacts_record_get_str_p(sourceRecordHandle, _contacts_email.email, &pCharValue);
4775 contacts_record_set_str(destRecordHandle, _contacts_email.email, pCharValue);
4777 contacts_record_add_child_record(contactHandle, _contacts_contact.email, destRecordHandle);
4779 emailHandle.Release();
4783 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4785 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4786 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.event, &count);
4787 for (i = 0; i < count; i++)
4789 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.event, i, &sourceRecordHandle);
4791 ret = contacts_record_create(_contacts_event._uri, &destRecordHandle);
4792 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4794 __ContactsRecordHandle eventHandle(destRecordHandle);
4796 contacts_record_get_int(sourceRecordHandle, _contacts_event.type, &intValue);
4797 contacts_record_set_int(destRecordHandle, _contacts_event.type, intValue);
4799 contacts_record_get_str_p(sourceRecordHandle, _contacts_event.label, &pCharValue);
4800 contacts_record_set_str(destRecordHandle, _contacts_event.label, pCharValue);
4802 contacts_record_get_int(sourceRecordHandle, _contacts_event.date, &intValue);
4803 contacts_record_set_int(destRecordHandle, _contacts_event.date, intValue);
4805 contacts_record_add_child_record(contactHandle, _contacts_contact.event, destRecordHandle);
4807 eventHandle.Release();
4810 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4812 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4813 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.messenger, &count);
4814 for (i = 0; i < count; i++)
4816 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.messenger, i, &sourceRecordHandle);
4818 ret = contacts_record_create(_contacts_messenger._uri, &destRecordHandle);
4819 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4821 __ContactsRecordHandle imAddressHandle(destRecordHandle);
4823 contacts_record_get_int(sourceRecordHandle, _contacts_messenger.type, &intValue);
4824 contacts_record_set_int(destRecordHandle, _contacts_messenger.type, intValue);
4826 contacts_record_get_str_p(sourceRecordHandle, _contacts_messenger.label, &pCharValue);
4827 contacts_record_set_str(destRecordHandle, _contacts_messenger.label, pCharValue);
4829 contacts_record_get_str_p(sourceRecordHandle, _contacts_messenger.im_id, &pCharValue);
4830 contacts_record_set_str(destRecordHandle, _contacts_messenger.im_id, pCharValue);
4832 contacts_record_add_child_record(contactHandle, _contacts_contact.messenger, destRecordHandle);
4834 imAddressHandle.Release();
4837 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4839 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4840 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.address, &count);
4841 for (i = 0; i < count; i++)
4843 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.address, i, &sourceRecordHandle);
4845 ret = contacts_record_create(_contacts_address._uri, &destRecordHandle);
4846 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4848 __ContactsRecordHandle addressHandle(destRecordHandle);
4850 contacts_record_get_int(sourceRecordHandle, _contacts_address.type, &intValue);
4851 contacts_record_set_int(destRecordHandle, _contacts_address.type, intValue);
4853 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.label, &pCharValue);
4854 contacts_record_set_str(destRecordHandle, _contacts_address.label, pCharValue);
4856 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.postbox, &pCharValue);
4857 contacts_record_set_str(destRecordHandle, _contacts_address.postbox, pCharValue);
4859 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.extended, &pCharValue);
4860 contacts_record_set_str(destRecordHandle, _contacts_address.extended, pCharValue);
4862 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.street, &pCharValue);
4863 contacts_record_set_str(destRecordHandle, _contacts_address.street, pCharValue);
4865 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.locality, &pCharValue);
4866 contacts_record_set_str(destRecordHandle, _contacts_address.locality, pCharValue);
4868 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.region, &pCharValue);
4869 contacts_record_set_str(destRecordHandle, _contacts_address.region, pCharValue);
4871 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.postal_code, &pCharValue);
4872 contacts_record_set_str(destRecordHandle, _contacts_address.postal_code, pCharValue);
4874 contacts_record_get_str_p(sourceRecordHandle, _contacts_address.country, &pCharValue);
4875 contacts_record_set_str(destRecordHandle, _contacts_address.country, pCharValue);
4877 contacts_record_add_child_record(contactHandle, _contacts_contact.address, destRecordHandle);
4879 addressHandle.Release();
4882 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4884 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4885 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.url, &count);
4886 for (i = 0; i < count; i++)
4888 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.url, i, &sourceRecordHandle);
4890 ret = contacts_record_create(_contacts_url._uri, &destRecordHandle);
4891 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4893 __ContactsRecordHandle urlHandle(destRecordHandle);
4895 contacts_record_get_int(sourceRecordHandle, _contacts_url.type, &intValue);
4896 contacts_record_set_int(destRecordHandle, _contacts_url.type, intValue);
4898 contacts_record_get_str_p(sourceRecordHandle, _contacts_url.label, &pCharValue);
4899 contacts_record_set_str(destRecordHandle, _contacts_url.label, pCharValue);
4901 contacts_record_get_str_p(sourceRecordHandle, _contacts_url.url, &pCharValue);
4902 contacts_record_set_str(destRecordHandle, _contacts_url.url, pCharValue);
4904 contacts_record_add_child_record(contactHandle, _contacts_contact.url, destRecordHandle);
4906 urlHandle.Release();
4909 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4911 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4912 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.nickname, &count);
4913 for (i = 0; i < count; i++)
4915 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.nickname, i, &sourceRecordHandle);
4917 ret = contacts_record_create(_contacts_nickname._uri, &destRecordHandle);
4918 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4920 __ContactsRecordHandle nicknameHandle(destRecordHandle);
4922 contacts_record_get_str_p(sourceRecordHandle, _contacts_nickname.name, &pCharValue);
4923 contacts_record_set_str(destRecordHandle, _contacts_nickname.name, pCharValue);
4925 contacts_record_add_child_record(contactHandle, _contacts_contact.nickname, destRecordHandle);
4927 nicknameHandle.Release();
4930 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4932 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4933 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.relationship, &count);
4934 for (i = 0; i < count; i++)
4936 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.relationship, i, &sourceRecordHandle);
4938 ret = contacts_record_create(_contacts_relationship._uri, &destRecordHandle);
4939 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4941 __ContactsRecordHandle relationshipHandle(destRecordHandle);
4943 contacts_record_get_str_p(sourceRecordHandle, _contacts_relationship.name, &pCharValue);
4944 contacts_record_set_str(destRecordHandle, _contacts_relationship.name, pCharValue);
4946 contacts_record_add_child_record(contactHandle, _contacts_contact.relationship, destRecordHandle);
4948 relationshipHandle.Release();
4951 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4953 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
4954 contacts_record_get_child_record_count(__contactHandle, _contacts_contact.profile, &count);
4955 for (i = 0; i < count; i++)
4957 contacts_record_get_child_record_at_p(__contactHandle, _contacts_contact.profile, i, &sourceRecordHandle);
4959 ret = contacts_record_create(_contacts_profile._uri, &destRecordHandle);
4960 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4962 __ContactsRecordHandle profileHandle(destRecordHandle);
4964 contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.text, &pCharValue);
4965 contacts_record_set_str(destRecordHandle, _contacts_profile.text, pCharValue);
4967 contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.uid, &pCharValue);
4968 contacts_record_set_str(destRecordHandle, _contacts_profile.uid, pCharValue);
4970 contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.app_id, &pCharValue);
4971 contacts_record_set_str(destRecordHandle, _contacts_profile.app_id, pCharValue);
4973 contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.service_operation, &pCharValue);
4974 contacts_record_set_str(destRecordHandle, _contacts_profile.service_operation, pCharValue);
4976 contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.uri, &pCharValue);
4977 contacts_record_set_str(destRecordHandle, _contacts_profile.uri, pCharValue);
4979 contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.category, &pCharValue);
4980 contacts_record_set_str(destRecordHandle, _contacts_profile.category, pCharValue);
4982 contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.mime, &pCharValue);
4983 contacts_record_set_str(destRecordHandle, _contacts_profile.mime, pCharValue);
4985 contacts_record_get_str_p(sourceRecordHandle, _contacts_profile.extra_data, &pCharValue);
4986 contacts_record_set_str(destRecordHandle, _contacts_profile.extra_data, pCharValue);
4988 contacts_record_add_child_record(contactHandle, _contacts_contact.profile, destRecordHandle);
4990 profileHandle.Release();
4993 contacts_record_destroy(__contactHandle, true);
4994 __contactHandle = contactHandle;
4996 __isRemoved = false;
4998 recordHandle.Release();
5004 _ContactImpl::GetInstance(const Contact& contact)
5006 return contact.__pContactImpl;
5010 _ContactImpl::GetInstance(Contact& contact)
5012 return contact.__pContactImpl;