2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FScl_UserProfileImpl.cpp
19 * @brief This is the implementation for _UserProfileImpl class.
21 * This file contains definitions of _UserProfileImpl class.
23 #include <FBaseString.h>
24 #include <FBaseColArrayList.h>
25 #include <FBaseSysLog.h>
27 #include <FMediaImage.h>
28 #include <FSclAddress.h>
29 #include <FSclPhoneNumber.h>
30 #include <FSclEmail.h>
32 #include <FSclImAddress.h>
33 #include <FSclOrganization.h>
34 #include <FSclContactEvent.h>
35 #include <FSclRelationship.h>
36 #include <FSclContact.h>
37 #include <FSclUserProfile.h>
38 #include <FBase_StringConverter.h>
39 #include "FScl_ContactDbConnector.h"
40 #include "FScl_PhoneNumberImpl.h"
41 #include "FScl_AddressbookUtil.h"
42 #include "FScl_UrlImpl.h"
43 #include "FScl_EmailImpl.h"
44 #include "FScl_AddressImpl.h"
45 #include "FScl_ImAddressImpl.h"
46 #include "FScl_UserProfileImpl.h"
47 #include "FScl_OrganizationImpl.h"
49 using namespace Tizen::Base;
50 using namespace Tizen::Base::Collection;
51 using namespace Tizen::Graphics;
52 using namespace Tizen::Media;
53 using namespace Tizen::Io;
55 namespace Tizen { namespace Social
58 const int __CONTACT_MOD_YEAR = 10000;
59 const int __CONTACT_MOD_MONTH = 100;
61 #define __CONVERT_DATE_TO_DATETIME(date, dateTime) \
68 year = temp/__CONTACT_MOD_YEAR; \
69 temp -= year*__CONTACT_MOD_YEAR; \
70 month = temp/__CONTACT_MOD_MONTH; \
71 day = temp - month*__CONTACT_MOD_MONTH; \
72 dateTime.SetValue(year, month, day, 0, 0, 0); \
75 _UserProfileImpl::_UserProfileImpl(void)
76 : __profileHandle(null)
78 contacts_record_h profileHandle = null;
80 SysTryReturnVoidResult(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
82 int ret = contacts_record_create(_contacts_my_profile._uri, &profileHandle);
83 SysTryReturnVoidResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
85 __profileHandle = profileHandle;
88 _UserProfileImpl::_UserProfileImpl(const _UserProfileImpl& rhs)
89 : __profileHandle(null)
91 contacts_record_h profileHandle = null;
93 SysTryReturnVoidResult(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
95 int ret = contacts_record_clone(rhs.__profileHandle, &profileHandle);
96 SysTryReturnVoidResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
98 __profileHandle = profileHandle;
101 _UserProfileImpl::~_UserProfileImpl(void)
103 if (__profileHandle != null)
105 contacts_record_destroy(__profileHandle, true);
110 _UserProfileImpl::operator =(const _UserProfileImpl& rhs)
117 contacts_record_h profileHandle = null;
119 int ret = contacts_record_clone(rhs.__profileHandle, &profileHandle);
120 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
122 contacts_record_destroy(__profileHandle, true);
123 __profileHandle = profileHandle;
125 //__isRemoved = rhs.__isRemoved;
131 _UserProfileImpl::Equals(const Object& rhs) const
133 const _UserProfileImpl* pRhs = dynamic_cast<const _UserProfileImpl*>(&rhs);
140 //compare single value properties
141 if (this->GetValue(USER_PROFILE_PROPERTY_ID_FIRST_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_FIRST_NAME))
146 if (this->GetValue(USER_PROFILE_PROPERTY_ID_LAST_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_LAST_NAME))
151 if (this->GetValue(USER_PROFILE_PROPERTY_ID_MIDDLE_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_MIDDLE_NAME))
156 if (this->GetValue(USER_PROFILE_PROPERTY_ID_NAME_PREFIX) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_NAME_PREFIX))
161 if (this->GetValue(USER_PROFILE_PROPERTY_ID_NAME_SUFFIX) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_NAME_SUFFIX))
166 if (this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME))
171 if (this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME))
176 if (this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME))
181 //compare multivalue properties
182 std::unique_ptr<ArrayList, AllElementsDeleter> pCurrentObjectList(null);
183 std::unique_ptr<ArrayList, AllElementsDeleter> pRhsObjectList(null);
185 pCurrentObjectList = std::unique_ptr<ArrayList, AllElementsDeleter> (static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS)));
186 pRhsObjectList = std::unique_ptr<ArrayList, AllElementsDeleter> (static_cast<ArrayList*>(pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS)));
188 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
193 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_EMAILS))));
194 pRhsObjectList.reset((static_cast<ArrayList*>(pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_EMAILS))));
196 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
201 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_URLS))));
202 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_URLS))));
204 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
209 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_ADDRESSES))));
210 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_ADDRESSES))));
212 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
217 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_IMADDRESSES))));
218 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_IMADDRESSES))));
220 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
225 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_EVENTS))));
226 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_EVENTS))));
228 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
233 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS))));
234 pRhsObjectList.reset((static_cast<ArrayList*>(pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS))));
236 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
241 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_NOTES))));
242 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_NOTES))));
244 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
249 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_NICKNAMES))));
250 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_NICKNAMES))));
252 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
257 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS))));
258 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS))));
260 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
269 _UserProfileImpl::GetHashCode(void) const
272 std::unique_ptr<IList, AllElementsDeleter> pMultiPropertyList(null);
274 //calculate single value properties
275 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_FIRST_NAME).GetHashCode();
276 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_LAST_NAME).GetHashCode();
277 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_MIDDLE_NAME).GetHashCode();
278 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_NAME_PREFIX).GetHashCode();
279 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_NAME_SUFFIX).GetHashCode();
280 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME).GetHashCode();
281 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME).GetHashCode();
282 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME).GetHashCode();
283 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetThumbnailPath().GetHashCode();
285 //calculate multi value properties
286 PhoneNumber* pPhoneNumber = null;
287 pMultiPropertyList = std::unique_ptr<IList, AllElementsDeleter> (this->GetValuesN(USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS));
288 std::unique_ptr<IEnumerator> pEnum(pMultiPropertyList->GetEnumeratorN());
289 while (pEnum->MoveNext() == E_SUCCESS)
291 pPhoneNumber = static_cast<PhoneNumber*>(pEnum->GetCurrent());
292 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pPhoneNumber->GetHashCode();
295 Email* pEmail = null;
296 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_EMAILS));
297 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
298 while (pEnum->MoveNext() == E_SUCCESS)
300 pEmail = static_cast<Email*>(pEnum->GetCurrent());
301 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pEmail->GetHashCode();
305 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_URLS));
306 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
307 while (pEnum->MoveNext() == E_SUCCESS)
309 pUrl = static_cast<Url*>(pEnum->GetCurrent());
310 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pUrl->GetHashCode();
313 Address* pAddress = null;
314 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_ADDRESSES));
315 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
316 while (pEnum->MoveNext() == E_SUCCESS)
318 pAddress = static_cast<Address*>(pEnum->GetCurrent());
319 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pAddress->GetHashCode();
322 ImAddress* pImAddress = null;
323 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_IMADDRESSES));
324 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
325 while (pEnum->MoveNext() == E_SUCCESS)
327 pImAddress = static_cast<ImAddress*>(pEnum->GetCurrent());
328 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pImAddress->GetHashCode();
331 ContactEvent* pEvent = null;
332 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_EVENTS));
333 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
334 while (pEnum->MoveNext() == E_SUCCESS)
336 pEvent = static_cast<ContactEvent*>(pEnum->GetCurrent());
337 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pEvent->GetHashCode();
340 Organization* pOrganization = null;
341 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS));
342 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
343 while (pEnum->MoveNext() == E_SUCCESS)
345 pOrganization = static_cast<Organization*>(pEnum->GetCurrent());
346 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pOrganization->GetHashCode();
349 String* pNote = null;
350 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_NOTES));
351 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
352 while (pEnum->MoveNext() == E_SUCCESS)
354 pNote = static_cast<String*>(pEnum->GetCurrent());
355 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pNote->GetHashCode();
358 String* pNickname = null;
359 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_NICKNAMES));
360 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
361 while (pEnum->MoveNext() == E_SUCCESS)
363 pNickname = static_cast<String*>(pEnum->GetCurrent());
364 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pNickname->GetHashCode();
367 Relationship* pRelationship = null;
368 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS));
369 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
370 while (pEnum->MoveNext() == E_SUCCESS)
372 pRelationship = static_cast<Relationship*>(pEnum->GetCurrent());
373 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pRelationship->GetHashCode();
380 _UserProfileImpl::GetThumbnailPath(void) const
382 unsigned int count = 0;
384 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.image, &count);
390 char* pCharValue = null;
391 contacts_record_h imageHandle = null;
393 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.image, 0, &imageHandle);
394 contacts_record_get_str_p(imageHandle, _contacts_image.path, &pCharValue);
396 return String(pCharValue);
400 _UserProfileImpl::SetThumbnail(const String& filePath)
402 unsigned int count = 0;
403 contacts_record_h imageHandle = null;
405 bool fileExist = true;
407 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.image, &count);
410 errCode = contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.image, 0, &imageHandle);
411 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
412 "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
414 if (!filePath.IsEmpty())
416 fileExist = File::IsFileExist(filePath);
417 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, E_INVALID_ARG, E_INVALID_ARG,
418 "[%s] Invalid file path.", GetErrorMessage(E_INVALID_ARG));
419 SysTryReturn(NID_SCL, fileExist != false, E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
420 "[%s] The specified file is not found.", GetErrorMessage(E_FILE_NOT_FOUND));
422 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(filePath));
423 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
425 errCode = contacts_record_set_str(imageHandle, _contacts_image.path, pCharArray.get());
426 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
427 "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
431 errCode = contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.image, imageHandle);
432 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
433 "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
438 if (!filePath.IsEmpty())
440 fileExist = File::IsFileExist(filePath);
441 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, E_INVALID_ARG, E_INVALID_ARG,
442 "[%s] Invalid file path.", GetErrorMessage(E_INVALID_ARG));
443 SysTryReturn(NID_SCL, fileExist != false, E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
444 "[%s] The specified file is not found.", GetErrorMessage(E_FILE_NOT_FOUND));
446 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(filePath));
447 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
449 errCode = contacts_record_create(_contacts_image._uri, &imageHandle);
450 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
451 "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
453 errCode = contacts_record_set_str(imageHandle, _contacts_image.path, pCharArray.get());
454 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
455 "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
457 errCode = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.image, imageHandle);
458 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
459 "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
468 _UserProfileImpl::SetValue(UserProfilePropertyId id, const String& value)
470 SysTryReturn(NID_SCL, id != USER_PROFILE_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));
472 int ret = CONTACTS_ERROR_NONE;
473 unsigned int count = 0;
477 case USER_PROFILE_PROPERTY_ID_FIRST_NAME:
479 contacts_record_h nameHandle = null;
480 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
484 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
486 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
487 contacts_record_set_str(nameHandle, _contacts_name.first, pCharArray.get());
489 if (value.IsEmpty() && IsEmptyName(nameHandle))
491 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
496 if (!value.IsEmpty())
498 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
499 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
501 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
502 contacts_record_set_str(nameHandle, _contacts_name.first, pCharArray.get());
504 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
510 case USER_PROFILE_PROPERTY_ID_MIDDLE_NAME:
512 contacts_record_h nameHandle = null;
513 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
517 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
519 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
520 ret = contacts_record_set_str(nameHandle, _contacts_name.addition, pCharArray.get());
522 if (value.IsEmpty() && IsEmptyName(nameHandle))
524 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
529 if (!value.IsEmpty())
531 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
532 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
534 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
535 contacts_record_set_str(nameHandle, _contacts_name.addition, pCharArray.get());
537 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
545 case USER_PROFILE_PROPERTY_ID_LAST_NAME:
547 contacts_record_h nameHandle = null;
548 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
552 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
554 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
555 contacts_record_set_str(nameHandle, _contacts_name.last, pCharArray.get());
557 if (value.IsEmpty() && IsEmptyName(nameHandle))
559 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
564 if (!value.IsEmpty())
566 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
567 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
569 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
570 contacts_record_set_str(nameHandle, _contacts_name.last, pCharArray.get());
572 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
579 case USER_PROFILE_PROPERTY_ID_NAME_SUFFIX:
581 contacts_record_h nameHandle = null;
582 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
586 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
588 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
589 contacts_record_set_str(nameHandle, _contacts_name.suffix, pCharArray.get());
591 if (value.IsEmpty() && IsEmptyName(nameHandle))
593 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
599 if (!value.IsEmpty())
601 contacts_record_create(_contacts_name._uri, &nameHandle);
602 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
604 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
605 contacts_record_set_str(nameHandle, _contacts_name.suffix, pCharArray.get());
607 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
615 case USER_PROFILE_PROPERTY_ID_NAME_PREFIX:
617 contacts_record_h nameHandle = null;
618 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
622 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
624 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
625 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
627 if (value.IsEmpty() && IsEmptyName(nameHandle))
629 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
634 if (!value.IsEmpty())
636 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
637 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
639 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
640 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
642 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
650 case USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME:
652 contacts_record_h nameHandle = null;
653 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
657 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
659 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
660 contacts_record_set_str(nameHandle, _contacts_name.phonetic_first, pCharArray.get());
662 if (value.IsEmpty() && IsEmptyName(nameHandle))
664 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
669 if (!value.IsEmpty())
671 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
672 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
674 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
675 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
677 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
685 case USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME:
687 contacts_record_h nameHandle = null;
688 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
692 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
694 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
695 contacts_record_set_str(nameHandle, _contacts_name.phonetic_last, pCharArray.get());
697 if (value.IsEmpty() && IsEmptyName(nameHandle))
699 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
704 if (!value.IsEmpty())
706 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
707 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
709 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
710 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
712 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
720 case USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
722 contacts_record_h nameHandle = null;
723 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
727 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
729 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
730 contacts_record_set_str(nameHandle, _contacts_name.phonetic_middle, pCharArray.get());
732 if (value.IsEmpty() && IsEmptyName(nameHandle))
734 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
739 if (!value.IsEmpty())
741 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
742 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
744 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
745 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
747 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
756 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
757 return E_INVALID_ARG;
764 _UserProfileImpl::GetValue(UserProfilePropertyId id) const
766 unsigned int count = 0;
767 char* pCharValue = null;
772 case USER_PROFILE_PROPERTY_ID_FIRST_NAME:
774 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
777 contacts_record_h nameHandle = null;
779 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
780 contacts_record_get_str_p(nameHandle, _contacts_name.first, &pCharValue);
786 case USER_PROFILE_PROPERTY_ID_LAST_NAME:
788 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
791 contacts_record_h nameHandle = null;
793 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
794 contacts_record_get_str_p(nameHandle, _contacts_name.last, &pCharValue);
800 case USER_PROFILE_PROPERTY_ID_MIDDLE_NAME:
802 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
805 contacts_record_h nameHandle = null;
807 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
808 contacts_record_get_str_p(nameHandle, _contacts_name.addition, &pCharValue);
814 case USER_PROFILE_PROPERTY_ID_NAME_PREFIX:
816 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
819 contacts_record_h nameHandle = null;
821 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
822 contacts_record_get_str_p(nameHandle, _contacts_name.prefix, &pCharValue);
828 case USER_PROFILE_PROPERTY_ID_NAME_SUFFIX:
830 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
833 contacts_record_h nameHandle = null;
835 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
836 contacts_record_get_str_p(nameHandle, _contacts_name.suffix, &pCharValue);
842 case USER_PROFILE_PROPERTY_ID_DISPLAY_NAME:
843 contacts_record_get_str_p(__profileHandle, _contacts_my_profile.display_name, &pCharValue);
846 case USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME:
848 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
851 contacts_record_h nameHandle = null;
853 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
854 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_first, &pCharValue);
860 case USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME:
862 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
865 contacts_record_h nameHandle = null;
867 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
868 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_last, &pCharValue);
874 case USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
876 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
879 contacts_record_h nameHandle = null;
881 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
882 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_middle, &pCharValue);
890 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d", GetErrorMessage(E_INVALID_ARG), id);
898 _UserProfileImpl::SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber)
900 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);
901 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));
903 unsigned int count = 0;
904 contacts_record_h recordHandle = null;
909 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.number, &count);
910 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);
912 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.number, index, &recordHandle);
914 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetLabel();
916 switch (_PhoneNumberImpl::GetInstance(phoneNumber)->GetType())
918 case PHONENUMBER_TYPE_HOME:
919 type = CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE;
921 case PHONENUMBER_TYPE_WORK:
922 type = CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE;
924 case PHONENUMBER_TYPE_MOBILE:
925 type = CONTACTS_NUMBER_TYPE_CELL;
927 case PHONENUMBER_TYPE_HOME_FAX:
928 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME;
930 case PHONENUMBER_TYPE_WORK_FAX:
931 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK;
933 case PHONENUMBER_TYPE_PAGER:
934 type = CONTACTS_NUMBER_TYPE_PAGER;
936 case PHONENUMBER_TYPE_CUSTOM:
937 type = CONTACTS_NUMBER_TYPE_CUSTOM;
939 case PHONENUMBER_TYPE_ASSISTANT:
940 type = CONTACTS_NUMBER_TYPE_ASSISTANT;
942 case PHONENUMBER_TYPE_OTHER:
943 contacts_record_get_int(recordHandle, _contacts_number.type, &oriType);
945 if (oriType == (CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE)
946 || oriType == (CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE)
947 || oriType == CONTACTS_NUMBER_TYPE_CELL
948 || oriType == (CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME)
949 || oriType == (CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK)
950 || oriType == CONTACTS_NUMBER_TYPE_PAGER
951 || oriType == CONTACTS_NUMBER_TYPE_CUSTOM)
953 type = CONTACTS_NUMBER_TYPE_OTHER;
961 type = CONTACTS_NUMBER_TYPE_OTHER;
966 contacts_record_set_int(recordHandle, _contacts_number.type, type);
969 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
970 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
972 contacts_record_set_str(recordHandle, _contacts_number.label, pCharArray.get());
975 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetPhoneNumber();
976 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
977 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
979 contacts_record_set_str(recordHandle, _contacts_number.number, pCharArray.get());
986 _UserProfileImpl::SetEmailAt(int index, const Email& email)
988 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);
989 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));
991 unsigned int count = 0;
992 contacts_record_h emailHandle = null;
996 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.email, &count);
997 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);
999 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.email, index, &emailHandle);
1001 stringValue = _EmailImpl::GetInstance(email)->GetLabel();
1003 switch (_EmailImpl::GetInstance(email)->GetType())
1005 case EMAIL_TYPE_PERSONAL:
1006 type = CONTACTS_EMAIL_TYPE_HOME;
1008 case EMAIL_TYPE_WORK:
1009 type = CONTACTS_EMAIL_TYPE_WORK;
1011 case EMAIL_TYPE_CUSTOM:
1012 type = CONTACTS_EMAIL_TYPE_CUSTOM;
1014 case EMAIL_TYPE_MOBILE:
1015 type = CONTACTS_EMAIL_TYPE_MOBILE;
1017 case EMAIL_TYPE_OTHER:
1020 type = CONTACTS_EMAIL_TYPE_OTHER;
1025 contacts_record_set_int(emailHandle, _contacts_email.type, type);
1028 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1029 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1031 contacts_record_set_str(emailHandle, _contacts_email.label, pCharArray.get());
1034 stringValue = _EmailImpl::GetInstance(email)->GetEmail();
1035 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1036 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1038 contacts_record_set_str(emailHandle, _contacts_email.email, pCharArray.get());
1044 _UserProfileImpl::SetUrlAt(int index, const Url& url)
1046 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);
1047 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));
1048 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1050 unsigned int count = 0;
1051 contacts_record_h urlHandle = null;
1055 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.url, &count);
1056 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);
1058 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.url, index, &urlHandle);
1061 stringValue = _UrlImpl::GetInstance(url)->GetLabel();
1063 switch (_UrlImpl::GetInstance(url)->GetType())
1065 case URL_TYPE_PERSONAL:
1066 type = CONTACTS_URL_TYPE_HOME;
1069 type = CONTACTS_URL_TYPE_WORK;
1071 case URL_TYPE_CUSTOM:
1072 type = CONTACTS_URL_TYPE_CUSTOM;
1074 case URL_TYPE_OTHER:
1077 type = CONTACTS_URL_TYPE_OTHER;
1082 contacts_record_set_int(urlHandle, _contacts_url.type, type);
1085 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1086 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1088 contacts_record_set_str(urlHandle, _contacts_url.label, pCharArray.get());
1091 stringValue = _UrlImpl::GetInstance(url)->GetUrl();
1092 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1093 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1095 contacts_record_set_str(urlHandle, _contacts_url.url, pCharArray.get());
1102 _UserProfileImpl::SetAddressAt(int index, const Address& address)
1104 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);
1105 SysTryReturn(NID_SCL,
1106 !address.GetCity().IsEmpty() ||
1107 !address.GetCountry().IsEmpty() ||
1108 !address.GetExtended().IsEmpty() ||
1109 !address.GetPostalCode().IsEmpty() ||
1110 !address.GetPostOfficeBoxNumber().IsEmpty() ||
1111 !address.GetState().IsEmpty() ||
1112 !address.GetStreet().IsEmpty(),
1113 E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The address is empty.", GetErrorMessage(E_INVALID_ARG));
1115 unsigned int count = 0;
1116 contacts_record_h addressHandle = null;
1120 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.address, &count);
1121 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);
1123 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.address, index, &addressHandle);
1125 stringValue = _AddressImpl::GetInstance(address)->GetLabel();
1127 switch (_AddressImpl::GetInstance(address)->GetType())
1129 case ADDRESS_TYPE_HOME:
1130 type = CONTACTS_ADDRESS_TYPE_HOME;
1132 case ADDRESS_TYPE_WORK:
1133 type = CONTACTS_ADDRESS_TYPE_WORK;
1135 case ADDRESS_TYPE_CUSTOM:
1136 type = CONTACTS_ADDRESS_TYPE_CUSTOM;
1138 case ADDRESS_TYPE_OTHER:
1141 type = CONTACTS_ADDRESS_TYPE_OTHER;
1146 contacts_record_set_int(addressHandle, _contacts_address.type, type);
1149 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1150 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1152 contacts_record_set_str(addressHandle, _contacts_address.label, pCharArray.get());
1155 stringValue = _AddressImpl::GetInstance(address)->GetCity();
1156 if (!stringValue.IsEmpty())
1158 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1159 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1161 contacts_record_set_str(addressHandle, _contacts_address.locality, pCharArray.get());
1165 contacts_record_set_str(addressHandle, _contacts_address.locality, null);
1168 stringValue = _AddressImpl::GetInstance(address)->GetCountry();
1169 if (!stringValue.IsEmpty())
1171 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1172 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1174 contacts_record_set_str(addressHandle, _contacts_address.country, pCharArray.get());
1178 contacts_record_set_str(addressHandle, _contacts_address.country, null);
1181 stringValue = _AddressImpl::GetInstance(address)->GetExtended();
1182 if (!stringValue.IsEmpty())
1184 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1185 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1187 contacts_record_set_str(addressHandle, _contacts_address.extended, pCharArray.get());
1191 contacts_record_set_str(addressHandle, _contacts_address.extended, null);
1194 stringValue = _AddressImpl::GetInstance(address)->GetPostalCode();
1195 if (!stringValue.IsEmpty())
1197 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1198 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1200 contacts_record_set_str(addressHandle, _contacts_address.postal_code, pCharArray.get());
1204 contacts_record_set_str(addressHandle, _contacts_address.postal_code, null);
1207 stringValue = _AddressImpl::GetInstance(address)->GetPostOfficeBoxNumber();
1208 if (!stringValue.IsEmpty())
1210 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1211 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1213 contacts_record_set_str(addressHandle, _contacts_address.postbox, pCharArray.get());
1217 contacts_record_set_str(addressHandle, _contacts_address.postbox, null);
1220 stringValue = _AddressImpl::GetInstance(address)->GetState();
1221 if (!stringValue.IsEmpty())
1223 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1224 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1226 contacts_record_set_str(addressHandle, _contacts_address.region, pCharArray.get());
1230 contacts_record_set_str(addressHandle, _contacts_address.region, null);
1233 stringValue = _AddressImpl::GetInstance(address)->GetStreet();
1234 if (!stringValue.IsEmpty())
1236 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1237 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1239 contacts_record_set_str(addressHandle, _contacts_address.street, pCharArray.get());
1243 contacts_record_set_str(addressHandle, _contacts_address.street, null);
1250 _UserProfileImpl::SetImAddressAt(int index, const ImAddress& imAddress)
1252 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);
1253 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));
1254 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1256 unsigned int count = 0;
1257 contacts_record_h messengerHandle = null;
1260 std::unique_ptr<char[]> pCharArray(null);
1262 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.messenger, &count);
1263 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);
1265 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.messenger, index, &messengerHandle);
1267 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetServiceProviderName();
1269 if (stringValue == IM_ADDRESS_GOOGLE_TALK)
1271 type = CONTACTS_MESSENGER_TYPE_GOOGLE;
1273 else if (stringValue == IM_ADDRESS_MSN)
1275 type = CONTACTS_MESSENGER_TYPE_WLM;
1277 else if (stringValue == IM_ADDRESS_ICQ)
1279 type = CONTACTS_MESSENGER_TYPE_ICQ;
1281 else if (stringValue == IM_ADDRESS_AIM)
1283 type = CONTACTS_MESSENGER_TYPE_AIM;
1285 else if (stringValue == IM_ADDRESS_YAHOO)
1287 type = CONTACTS_MESSENGER_TYPE_YAHOO;
1289 else if (stringValue == IM_ADDRESS_QQ)
1291 type = CONTACTS_MESSENGER_TYPE_QQ;
1293 else if (stringValue == IM_ADDRESS_SKYPE)
1295 type = CONTACTS_MESSENGER_TYPE_SKYPE;
1297 else if (stringValue == IM_ADDRESS_JABBER)
1299 type = CONTACTS_MESSENGER_TYPE_JABBER;
1303 type = CONTACTS_MESSENGER_TYPE_CUSTOM;
1306 contacts_record_set_int(messengerHandle, _contacts_messenger.type, type);
1307 if (type == CONTACTS_MESSENGER_TYPE_CUSTOM)
1309 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1310 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1312 contacts_record_set_str(messengerHandle, _contacts_messenger.label, pCharArray.get());
1315 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetImAddress();
1316 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1317 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1319 contacts_record_set_str(messengerHandle, _contacts_messenger.im_id, pCharArray.get());
1326 _UserProfileImpl::SetNoteAt(int index, const String& note)
1328 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);
1329 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));
1330 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1332 unsigned int count = 0;
1333 contacts_record_h noteHandle = null;
1335 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.note, &count);
1336 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);
1338 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.note, index, ¬eHandle);
1340 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(note));
1341 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1343 contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
1349 _UserProfileImpl::SetNicknameAt(int index, const String& nickname)
1351 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);
1352 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));
1353 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1355 unsigned int count = 0;
1356 contacts_record_h nicknameHandle = null;
1358 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.nickname, &count);
1359 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);
1361 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.nickname, index, &nicknameHandle);
1363 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(nickname));
1364 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1366 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
1372 _UserProfileImpl::SetEventAt(int index, const ContactEvent& event)
1374 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);
1375 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1379 unsigned int count = 0;
1381 contacts_record_h eventHandle = null;
1383 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.event, &count);
1384 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);
1386 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.event, index, &eventHandle);
1388 switch (event.GetType())
1390 case CONTACT_EVENT_TYPE_ANNIVERSARY:
1391 type = CONTACTS_EVENT_TYPE_ANNIVERSARY;
1393 case CONTACT_EVENT_TYPE_BIRTHDAY:
1394 type = CONTACTS_EVENT_TYPE_BIRTH;
1396 case CONTACT_EVENT_TYPE_CUSTOM:
1397 type = CONTACTS_EVENT_TYPE_CUSTOM;
1399 case CONTACT_EVENT_TYPE_OTHER:
1402 type = CONTACTS_EVENT_TYPE_OTHER;
1407 contacts_record_set_int(eventHandle, _contacts_event.type, type);
1410 stringValue = event.GetLabel();
1412 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1413 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1415 contacts_record_set_str(eventHandle, _contacts_event.label, pCharArray.get());
1418 DateTime dateValue = event.GetDate();
1419 intValue = dateValue.GetYear()*10000 + dateValue.GetMonth()*100 + dateValue.GetDay();
1420 contacts_record_set_int(eventHandle, _contacts_event.date, intValue);
1427 _UserProfileImpl::SetOrganizationAt(int index, const Organization& organization)
1429 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);
1430 SysTryReturn(NID_SCL
1431 , !organization.GetName().IsEmpty() ||
1432 !organization.GetJobTitle().IsEmpty() ||
1433 !organization.GetDepartment().IsEmpty() ||
1434 !organization.GetRole().IsEmpty() ||
1435 !organization.GetAgent().IsEmpty() ||
1436 !organization.GetLocation().IsEmpty() ||
1437 !organization.GetDescription().IsEmpty() ||
1438 !organization.GetPhoneticName().IsEmpty() ||
1439 !organization.GetLogoPath().IsEmpty()
1440 ,E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The organization is empty.", GetErrorMessage(E_INVALID_ARG));
1442 unsigned int count = 0;
1443 contacts_record_h organizationHandle = null;
1445 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.company, &count);
1446 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);
1449 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.company, index, &organizationHandle);
1452 String stringValue = organization.GetName();
1453 if (!stringValue.IsEmpty())
1455 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1456 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1458 contacts_record_set_str(organizationHandle, _contacts_company.name, pCharArray.get());
1462 contacts_record_set_str(organizationHandle, _contacts_company.name, null);
1466 stringValue = organization.GetJobTitle();
1467 if (!stringValue.IsEmpty())
1469 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1470 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1472 contacts_record_set_str(organizationHandle, _contacts_company.job_title, pCharArray.get());
1476 contacts_record_set_str(organizationHandle, _contacts_company.job_title, null);
1480 stringValue = organization.GetDepartment();
1481 if (!stringValue.IsEmpty())
1483 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1484 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1486 contacts_record_set_str(organizationHandle, _contacts_company.department, pCharArray.get());
1490 contacts_record_set_str(organizationHandle, _contacts_company.department, null);
1494 stringValue = organization.GetRole();
1495 if (!stringValue.IsEmpty())
1497 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1498 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1500 contacts_record_set_str(organizationHandle, _contacts_company.role, pCharArray.get());
1504 contacts_record_set_str(organizationHandle, _contacts_company.role, null);
1508 stringValue = organization.GetAgent();
1509 if (!stringValue.IsEmpty())
1511 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1512 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1514 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, pCharArray.get());
1518 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, null);
1524 switch (organization.GetType())
1526 case ORGANIZATION_TYPE_WORK:
1527 type = CONTACTS_COMPANY_TYPE_WORK;
1529 case ORGANIZATION_TYPE_CUSTOM:
1530 type = CONTACTS_COMPANY_TYPE_CUSTOM;
1532 case ORGANIZATION_TYPE_OTHER:
1535 type = CONTACTS_COMPANY_TYPE_OTHER;
1538 contacts_record_set_int(organizationHandle, _contacts_company.type, type);
1541 stringValue = organization.GetLabel();
1542 if (!stringValue.IsEmpty())
1544 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1545 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1547 contacts_record_set_str(organizationHandle, _contacts_company.label, pCharArray.get());
1551 contacts_record_set_str(organizationHandle, _contacts_company.label, null);
1555 stringValue = organization.GetLocation();
1556 if (!stringValue.IsEmpty())
1558 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1559 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1561 contacts_record_set_str(organizationHandle, _contacts_company.location, pCharArray.get());
1565 contacts_record_set_str(organizationHandle, _contacts_company.location, null);
1569 stringValue = organization.GetDescription();
1570 if (!stringValue.IsEmpty())
1572 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1573 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1575 contacts_record_set_str(organizationHandle, _contacts_company.description, pCharArray.get());
1579 contacts_record_set_str(organizationHandle, _contacts_company.description, null);
1583 stringValue = organization.GetPhoneticName();
1584 if (!stringValue.IsEmpty())
1586 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1587 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1589 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, pCharArray.get());
1593 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, null);
1597 if (_OrganizationImpl::GetInstance(organization)->IsLogoPathChanged() == true)
1599 stringValue = organization.GetLogoPath();
1600 if (!stringValue.IsEmpty())
1602 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1603 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1605 contacts_record_set_str(organizationHandle, _contacts_company.logo, pCharArray.get());
1609 contacts_record_set_str(organizationHandle, _contacts_company.logo, null);
1617 _UserProfileImpl::SetRelationshipAt(int index, const Relationship& relationship)
1619 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);
1620 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));
1621 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1624 unsigned int count = 0;
1625 contacts_record_h relationshipHandle = null;
1627 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.relationship, &count);
1628 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);
1630 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.relationship, index, &relationshipHandle);
1632 switch (relationship.GetType())
1634 case CONTACT_RELATIONSHIP_TYPE_ASSISTANT:
1635 intValue = CONTACTS_RELATIONSHIP_TYPE_ASSISTANT;
1637 case CONTACT_RELATIONSHIP_TYPE_BROTHER:
1638 intValue = CONTACTS_RELATIONSHIP_TYPE_BROTHER;
1640 case CONTACT_RELATIONSHIP_TYPE_CHILD:
1641 intValue = CONTACTS_RELATIONSHIP_TYPE_CHILD;
1643 case CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
1644 intValue = CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER;
1646 case CONTACT_RELATIONSHIP_TYPE_FATHER:
1647 intValue = CONTACTS_RELATIONSHIP_TYPE_FATHER;
1649 case CONTACT_RELATIONSHIP_TYPE_FRIEND:
1650 intValue = CONTACTS_RELATIONSHIP_TYPE_FRIEND;
1652 case CONTACT_RELATIONSHIP_TYPE_MANAGER:
1653 intValue = CONTACTS_RELATIONSHIP_TYPE_MANAGER;
1655 case CONTACT_RELATIONSHIP_TYPE_MOTHER:
1656 intValue = CONTACTS_RELATIONSHIP_TYPE_MOTHER;
1658 case CONTACT_RELATIONSHIP_TYPE_PARENT:
1659 intValue = CONTACTS_RELATIONSHIP_TYPE_PARENT;
1661 case CONTACT_RELATIONSHIP_TYPE_PARTNER:
1662 intValue = CONTACTS_RELATIONSHIP_TYPE_PARTNER;
1664 case CONTACT_RELATIONSHIP_TYPE_REFERRED_BY:
1665 intValue = CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY;
1667 case CONTACT_RELATIONSHIP_TYPE_RELATIVE:
1668 intValue = CONTACTS_RELATIONSHIP_TYPE_RELATIVE;
1670 case CONTACT_RELATIONSHIP_TYPE_SISTER:
1671 intValue = CONTACTS_RELATIONSHIP_TYPE_SISTER;
1673 case CONTACT_RELATIONSHIP_TYPE_SPOUSE:
1674 intValue = CONTACTS_RELATIONSHIP_TYPE_SPOUSE;
1676 case CONTACT_RELATIONSHIP_TYPE_CUSTOM:
1677 intValue = CONTACTS_RELATIONSHIP_TYPE_CUSTOM;
1680 intValue = CONTACTS_RELATIONSHIP_TYPE_OTHER;
1685 contacts_record_set_int(relationshipHandle, _contacts_relationship.type, intValue);
1688 String stringValue = relationship.GetLabel();
1689 if (!stringValue.IsEmpty())
1691 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1692 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1694 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, pCharArray.get());
1698 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, null);
1702 stringValue = relationship.GetRelativeName();
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(relationshipHandle, _contacts_relationship.name, pCharArray.get());
1712 _UserProfileImpl::GetAddressbookId(void) const
1714 int addressbookId = 0;
1716 contacts_record_get_int(__profileHandle, _contacts_my_profile.address_book_id, &addressbookId);
1718 return addressbookId;
1722 _UserProfileImpl::GetValuesN(const UserProfileMultiPropertyId id) const
1724 IList* pList = null;
1730 case USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS:
1731 pList = GetPhoneNumbersN();
1734 case USER_PROFILE_MPROPERTY_ID_EMAILS:
1735 pList = GetEmailsN();
1738 case USER_PROFILE_MPROPERTY_ID_URLS:
1742 case USER_PROFILE_MPROPERTY_ID_ADDRESSES:
1743 pList = GetAddressesN();
1746 case USER_PROFILE_MPROPERTY_ID_IMADDRESSES:
1747 pList = GetImAddressesN();
1750 case USER_PROFILE_MPROPERTY_ID_EVENTS:
1751 pList = GetEventsN();
1754 case USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS:
1755 pList = GetOrganizationsN();
1758 case USER_PROFILE_MPROPERTY_ID_NOTES:
1759 pList = GetNotesN();
1762 case CONTACT_MPROPERTY_ID_NICKNAMES:
1763 pList = GetNicknamesN();
1766 case USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS:
1767 pList = GetRelationshipsN();
1772 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
1776 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1783 _UserProfileImpl::AddPhoneNumber(const PhoneNumber& phoneNumber)
1785 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));
1789 contacts_record_h numberHandle = null;
1791 int ret = contacts_record_create(_contacts_number._uri, &numberHandle);
1792 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1794 __ContactsRecordHandle recordHandle(numberHandle);
1796 switch (_PhoneNumberImpl::GetInstance(phoneNumber)->GetType())
1798 case PHONENUMBER_TYPE_HOME:
1799 type = CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE;
1801 case PHONENUMBER_TYPE_WORK:
1802 type = CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE;
1804 case PHONENUMBER_TYPE_MOBILE:
1805 type = CONTACTS_NUMBER_TYPE_CELL;
1807 case PHONENUMBER_TYPE_HOME_FAX:
1808 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME;
1810 case PHONENUMBER_TYPE_WORK_FAX:
1811 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK;
1813 case PHONENUMBER_TYPE_PAGER:
1814 type = CONTACTS_NUMBER_TYPE_PAGER;
1816 case PHONENUMBER_TYPE_CUSTOM:
1817 type = CONTACTS_NUMBER_TYPE_CUSTOM;
1819 case PHONENUMBER_TYPE_ASSISTANT:
1820 type = CONTACTS_NUMBER_TYPE_ASSISTANT;
1822 case PHONENUMBER_TYPE_OTHER:
1824 type = CONTACTS_NUMBER_TYPE_OTHER;
1828 contacts_record_set_int(numberHandle, _contacts_number.type, type);
1830 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetLabel();
1832 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1833 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1835 contacts_record_set_str(numberHandle, _contacts_number.label, pCharArray.get());
1837 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetPhoneNumber();
1838 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1839 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1841 contacts_record_set_str(numberHandle, _contacts_number.number, pCharArray.get());
1843 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.number, numberHandle);
1844 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1846 recordHandle.Release();
1853 _UserProfileImpl::AddNickname(const String& nickname)
1856 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));
1858 contacts_record_h nicknameHandle = null;
1860 int ret = contacts_record_create(_contacts_nickname._uri, &nicknameHandle);
1861 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1863 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(nickname));
1864 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1866 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
1868 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.nickname, nicknameHandle);
1869 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1876 _UserProfileImpl::AddNote(const String& note)
1878 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));
1880 contacts_record_h noteHandle = null;
1882 int ret = contacts_record_create(_contacts_note._uri, ¬eHandle);
1883 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1885 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(note));
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(noteHandle, _contacts_note.note, pCharArray.get());
1890 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.note, noteHandle);
1891 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1898 _UserProfileImpl::AddEmail(const Email& email)
1901 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));
1905 contacts_record_h emailHandle = null;
1907 int ret = contacts_record_create(_contacts_email._uri, &emailHandle);
1908 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1910 __ContactsRecordHandle recordHandle(emailHandle);
1912 switch (_EmailImpl::GetInstance(email)->GetType())
1914 case EMAIL_TYPE_PERSONAL:
1915 type = CONTACTS_EMAIL_TYPE_HOME;
1917 case EMAIL_TYPE_WORK:
1918 type = CONTACTS_EMAIL_TYPE_WORK;
1920 case EMAIL_TYPE_CUSTOM:
1921 type = CONTACTS_EMAIL_TYPE_CUSTOM;
1923 case EMAIL_TYPE_MOBILE:
1924 type = CONTACTS_EMAIL_TYPE_MOBILE;
1926 case EMAIL_TYPE_OTHER:
1929 type = CONTACTS_EMAIL_TYPE_OTHER;
1933 contacts_record_set_int(emailHandle, _contacts_email.type, type);
1935 stringValue = _EmailImpl::GetInstance(email)->GetLabel();
1936 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1937 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1939 contacts_record_set_str(emailHandle, _contacts_email.label, pCharArray.get());
1941 stringValue = _EmailImpl::GetInstance(email)->GetEmail();
1942 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1943 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1945 contacts_record_set_str(emailHandle, _contacts_email.email, pCharArray.get());
1947 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.email, emailHandle);
1948 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1950 recordHandle.Release();
1957 _UserProfileImpl::AddUrl(const Url& url)
1959 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));
1963 contacts_record_h urlHandle = null;
1965 int ret = contacts_record_create(_contacts_url._uri, &urlHandle);
1966 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1968 __ContactsRecordHandle recordHandle(urlHandle);
1970 switch (_UrlImpl::GetInstance(url)->GetType())
1972 case URL_TYPE_PERSONAL:
1973 type = CONTACTS_URL_TYPE_HOME;
1976 type = CONTACTS_URL_TYPE_WORK;
1978 case URL_TYPE_CUSTOM:
1979 type = CONTACTS_URL_TYPE_CUSTOM;
1981 case URL_TYPE_OTHER:
1984 type = CONTACTS_URL_TYPE_OTHER;
1989 contacts_record_set_int(urlHandle, _contacts_url.type, type);
1992 stringValue = _UrlImpl::GetInstance(url)->GetLabel();
1993 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1994 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1996 contacts_record_set_str(urlHandle, _contacts_url.label, pCharArray.get());
1999 stringValue = _UrlImpl::GetInstance(url)->GetUrl();
2000 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
2001 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2003 contacts_record_set_str(urlHandle, _contacts_url.url, pCharArray.get());
2005 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.url, urlHandle);
2006 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2008 recordHandle.Release();
2015 _UserProfileImpl::AddAddress(const Address& address)
2018 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));
2022 contacts_record_h addressHandle = null;
2024 int ret = contacts_record_create(_contacts_address._uri, &addressHandle);
2025 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2027 __ContactsRecordHandle recordHandle(addressHandle);
2029 switch (_AddressImpl::GetInstance(address)->GetType())
2031 case ADDRESS_TYPE_HOME:
2032 type = CONTACTS_ADDRESS_TYPE_HOME;
2034 case ADDRESS_TYPE_WORK:
2035 type = CONTACTS_ADDRESS_TYPE_WORK;
2037 case ADDRESS_TYPE_CUSTOM:
2038 type = CONTACTS_ADDRESS_TYPE_CUSTOM;
2040 case ADDRESS_TYPE_OTHER:
2043 type = CONTACTS_ADDRESS_TYPE_OTHER;
2047 contacts_record_set_int(addressHandle, _contacts_address.type, type);
2049 stringValue = _AddressImpl::GetInstance(address)->GetLabel();
2050 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2051 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2053 contacts_record_set_str(addressHandle, _contacts_address.label, pCharArray.get());
2055 stringValue = _AddressImpl::GetInstance(address)->GetCity();
2056 if (!stringValue.IsEmpty())
2058 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2059 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2061 contacts_record_set_str(addressHandle, _contacts_address.locality, pCharArray.get());
2065 stringValue = _AddressImpl::GetInstance(address)->GetCountry();
2066 if (!stringValue.IsEmpty())
2068 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2069 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2071 contacts_record_set_str(addressHandle, _contacts_address.country, pCharArray.get());
2074 stringValue = _AddressImpl::GetInstance(address)->GetExtended();
2075 if (!stringValue.IsEmpty())
2077 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2078 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2080 contacts_record_set_str(addressHandle, _contacts_address.extended, pCharArray.get());
2083 stringValue = _AddressImpl::GetInstance(address)->GetPostalCode();
2084 if (!stringValue.IsEmpty())
2086 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2087 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2089 contacts_record_set_str(addressHandle, _contacts_address.postal_code, pCharArray.get());
2092 stringValue = _AddressImpl::GetInstance(address)->GetPostOfficeBoxNumber();
2093 if (!stringValue.IsEmpty())
2095 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2096 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2098 contacts_record_set_str(addressHandle, _contacts_address.postbox, pCharArray.get());
2101 stringValue = _AddressImpl::GetInstance(address)->GetState();
2102 if (!stringValue.IsEmpty())
2104 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2105 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2107 contacts_record_set_str(addressHandle, _contacts_address.region, pCharArray.get());
2110 stringValue = _AddressImpl::GetInstance(address)->GetStreet();
2111 if (!stringValue.IsEmpty())
2113 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2114 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2116 contacts_record_set_str(addressHandle, _contacts_address.street, pCharArray.get());
2119 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.address, addressHandle);
2120 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2122 recordHandle.Release();
2129 _UserProfileImpl::AddImAddress(const ImAddress& imAddress)
2132 SysTryReturn(NID_SCL, !imAddress.GetImAddress().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%] Invalid argument is used. The imAddress is empty.", GetErrorMessage(E_INVALID_ARG));
2136 contacts_record_h messengerHandle = null;
2138 std::unique_ptr<char[]> pCharArray(null);
2140 int ret = contacts_record_create(_contacts_messenger._uri, &messengerHandle);
2141 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2143 __ContactsRecordHandle recordHandle(messengerHandle);
2145 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetServiceProviderName();
2147 if (stringValue == IM_ADDRESS_GOOGLE_TALK)
2149 type = CONTACTS_MESSENGER_TYPE_GOOGLE;
2151 else if (stringValue == IM_ADDRESS_MSN)
2153 type = CONTACTS_MESSENGER_TYPE_WLM;
2155 else if (stringValue == IM_ADDRESS_ICQ)
2157 type = CONTACTS_MESSENGER_TYPE_ICQ;
2159 else if (stringValue == IM_ADDRESS_AIM)
2161 type = CONTACTS_MESSENGER_TYPE_AIM;
2163 else if (stringValue == IM_ADDRESS_YAHOO)
2165 type = CONTACTS_MESSENGER_TYPE_YAHOO;
2167 else if (stringValue == IM_ADDRESS_QQ)
2169 type = CONTACTS_MESSENGER_TYPE_QQ;
2171 else if (stringValue == IM_ADDRESS_SKYPE)
2173 type = CONTACTS_MESSENGER_TYPE_SKYPE;
2175 else if (stringValue == IM_ADDRESS_JABBER)
2177 type = CONTACTS_MESSENGER_TYPE_JABBER;
2181 type = CONTACTS_MESSENGER_TYPE_CUSTOM;
2184 contacts_record_set_int(messengerHandle, _contacts_messenger.type, type);
2185 if (type == CONTACTS_MESSENGER_TYPE_CUSTOM)
2187 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
2188 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2190 contacts_record_set_str(messengerHandle, _contacts_messenger.label, pCharArray.get());
2193 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetImAddress();
2194 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
2195 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2197 contacts_record_set_str(messengerHandle, _contacts_messenger.im_id, pCharArray.get());
2199 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.messenger, messengerHandle);
2200 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2202 recordHandle.Release();
2208 _UserProfileImpl::AddRelationship(const Relationship& relationship)
2210 SysTryReturn(NID_SCL, !relationship.GetRelativeName().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%] Invalid argument is used. The relationship is empty.", GetErrorMessage(E_INVALID_ARG));
2213 contacts_record_h relationshipHandle = null;
2215 int ret = contacts_record_create(_contacts_relationship._uri, &relationshipHandle);
2216 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2218 __ContactsRecordHandle recordHandle(relationshipHandle);
2220 switch (relationship.GetType())
2222 case CONTACT_RELATIONSHIP_TYPE_ASSISTANT:
2223 intValue = CONTACTS_RELATIONSHIP_TYPE_ASSISTANT;
2225 case CONTACT_RELATIONSHIP_TYPE_BROTHER:
2226 intValue = CONTACTS_RELATIONSHIP_TYPE_BROTHER;
2228 case CONTACT_RELATIONSHIP_TYPE_CHILD:
2229 intValue = CONTACTS_RELATIONSHIP_TYPE_CHILD;
2231 case CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
2232 intValue = CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER;
2234 case CONTACT_RELATIONSHIP_TYPE_FATHER:
2235 intValue = CONTACTS_RELATIONSHIP_TYPE_FATHER;
2237 case CONTACT_RELATIONSHIP_TYPE_FRIEND:
2238 intValue = CONTACTS_RELATIONSHIP_TYPE_FRIEND;
2240 case CONTACT_RELATIONSHIP_TYPE_MANAGER:
2241 intValue = CONTACTS_RELATIONSHIP_TYPE_MANAGER;
2243 case CONTACT_RELATIONSHIP_TYPE_MOTHER:
2244 intValue = CONTACTS_RELATIONSHIP_TYPE_MOTHER;
2246 case CONTACT_RELATIONSHIP_TYPE_PARENT:
2247 intValue = CONTACTS_RELATIONSHIP_TYPE_PARENT;
2249 case CONTACT_RELATIONSHIP_TYPE_PARTNER:
2250 intValue = CONTACTS_RELATIONSHIP_TYPE_PARTNER;
2252 case CONTACT_RELATIONSHIP_TYPE_REFERRED_BY:
2253 intValue = CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY;
2255 case CONTACT_RELATIONSHIP_TYPE_RELATIVE:
2256 intValue = CONTACTS_RELATIONSHIP_TYPE_RELATIVE;
2258 case CONTACT_RELATIONSHIP_TYPE_SISTER:
2259 intValue = CONTACTS_RELATIONSHIP_TYPE_SISTER;
2261 case CONTACT_RELATIONSHIP_TYPE_SPOUSE:
2262 intValue = CONTACTS_RELATIONSHIP_TYPE_SPOUSE;
2264 case CONTACT_RELATIONSHIP_TYPE_CUSTOM:
2265 intValue = CONTACTS_RELATIONSHIP_TYPE_CUSTOM;
2268 intValue = CONTACTS_RELATIONSHIP_TYPE_OTHER;
2273 contacts_record_set_int(relationshipHandle, _contacts_relationship.type, intValue);
2276 String stringValue = relationship.GetLabel();
2277 if (!stringValue.IsEmpty())
2279 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2280 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2282 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, pCharArray.get());
2286 stringValue = relationship.GetRelativeName();
2287 if (!stringValue.IsEmpty())
2289 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2290 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2292 contacts_record_set_str(relationshipHandle, _contacts_relationship.name, pCharArray.get());
2295 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.relationship, relationshipHandle);
2296 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2298 recordHandle.Release();
2306 _UserProfileImpl::AddEvent(const ContactEvent& event)
2312 contacts_record_h eventHandle = null;
2314 int ret = contacts_record_create(_contacts_event._uri, &eventHandle);
2315 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2317 __ContactsRecordHandle recordHandle(eventHandle);
2319 switch (event.GetType())
2321 case CONTACT_EVENT_TYPE_ANNIVERSARY:
2322 type = CONTACTS_EVENT_TYPE_ANNIVERSARY;
2324 case CONTACT_EVENT_TYPE_BIRTHDAY:
2325 type = CONTACTS_EVENT_TYPE_BIRTH;
2327 case CONTACT_EVENT_TYPE_CUSTOM:
2328 type = CONTACTS_EVENT_TYPE_CUSTOM;
2330 case CONTACT_EVENT_TYPE_OTHER:
2333 type = CONTACTS_EVENT_TYPE_OTHER;
2338 contacts_record_set_int(eventHandle, _contacts_event.type, type);
2341 stringValue = event.GetLabel();
2342 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2343 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2345 contacts_record_set_str(eventHandle, _contacts_event.label, pCharArray.get());
2348 DateTime dateValue = event.GetDate();
2349 intValue = dateValue.GetYear()*10000 + dateValue.GetMonth()*100 + dateValue.GetDay();
2350 contacts_record_set_int(eventHandle, _contacts_event.date, intValue);
2352 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.event, eventHandle);
2353 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2355 recordHandle.Release();
2362 _UserProfileImpl::AddOrganization(const Organization& organization)
2364 SysTryReturn(NID_SCL
2365 , !organization.GetName().IsEmpty() ||
2366 !organization.GetJobTitle().IsEmpty() ||
2367 !organization.GetDepartment().IsEmpty() ||
2368 !organization.GetRole().IsEmpty() ||
2369 !organization.GetAgent().IsEmpty() ||
2370 !organization.GetDescription().IsEmpty() ||
2371 !organization.GetLocation().IsEmpty() ||
2372 !organization.GetPhoneticName().IsEmpty() ||
2373 !organization.GetLogoPath().IsEmpty()
2374 ,E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The organization is empty.", GetErrorMessage(E_INVALID_ARG));
2376 contacts_record_h organizationHandle = null;
2378 int ret = contacts_record_create(_contacts_company._uri, &organizationHandle);
2379 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2381 __ContactsRecordHandle recordHandle(organizationHandle);
2384 String stringValue = organization.GetName();
2385 if (!stringValue.IsEmpty())
2387 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2388 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2390 contacts_record_set_str(organizationHandle, _contacts_company.name, pCharArray.get());
2394 stringValue = organization.GetJobTitle();
2395 if (!stringValue.IsEmpty())
2397 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2398 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2400 contacts_record_set_str(organizationHandle, _contacts_company.job_title, pCharArray.get());
2404 stringValue = organization.GetDepartment();
2405 if (!stringValue.IsEmpty())
2407 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2408 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2410 contacts_record_set_str(organizationHandle, _contacts_company.department, pCharArray.get());
2414 stringValue = organization.GetRole();
2415 if (!stringValue.IsEmpty())
2417 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2418 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2420 contacts_record_set_str(organizationHandle, _contacts_company.role, pCharArray.get());
2424 stringValue = organization.GetAgent();
2425 if (!stringValue.IsEmpty())
2427 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2428 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2430 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, pCharArray.get());
2436 switch (organization.GetType())
2438 case ORGANIZATION_TYPE_WORK:
2439 type = CONTACTS_COMPANY_TYPE_WORK;
2441 case ORGANIZATION_TYPE_CUSTOM:
2442 type = CONTACTS_COMPANY_TYPE_CUSTOM;
2444 case ORGANIZATION_TYPE_OTHER:
2447 type = CONTACTS_COMPANY_TYPE_OTHER;
2451 contacts_record_set_int(organizationHandle, _contacts_company.type, type);
2454 stringValue = organization.GetLabel();
2455 if (!stringValue.IsEmpty())
2457 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2458 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2460 contacts_record_set_str(organizationHandle, _contacts_company.label, pCharArray.get());
2464 stringValue = organization.GetDescription();
2465 if (!stringValue.IsEmpty())
2467 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2468 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2470 contacts_record_set_str(organizationHandle, _contacts_company.description, pCharArray.get());
2474 stringValue = organization.GetLocation();
2475 if (!stringValue.IsEmpty())
2477 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2478 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2480 contacts_record_set_str(organizationHandle, _contacts_company.location, pCharArray.get());
2484 stringValue = organization.GetPhoneticName();
2485 if (!stringValue.IsEmpty())
2487 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2488 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2490 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, pCharArray.get());
2494 if (_OrganizationImpl::GetInstance(organization)->IsLogoPathChanged() == true)
2496 stringValue = organization.GetLogoPath();
2497 if (!stringValue.IsEmpty())
2499 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2500 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2502 contacts_record_set_str(organizationHandle, _contacts_company.logo, pCharArray.get());
2506 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.company, organizationHandle);
2507 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2509 recordHandle.Release();
2516 _UserProfileImpl::RemoveAt(UserProfileMultiPropertyId id, int index)
2518 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);
2520 unsigned int count = 0;
2521 contacts_record_h recordHandle = null;
2525 case USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS:
2526 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.number, &count);
2527 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);
2529 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.number, index, &recordHandle);
2530 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.number, recordHandle);
2533 case USER_PROFILE_MPROPERTY_ID_EMAILS:
2534 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.email, &count);
2535 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);
2537 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.email, index, &recordHandle);
2538 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.email, recordHandle);
2541 case USER_PROFILE_MPROPERTY_ID_URLS:
2542 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.url, &count);
2543 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);
2545 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.url, index, &recordHandle);
2546 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.url, recordHandle);
2549 case USER_PROFILE_MPROPERTY_ID_ADDRESSES:
2550 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.address, &count);
2551 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);
2553 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.address, index, &recordHandle);
2554 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.address, recordHandle);
2557 case USER_PROFILE_MPROPERTY_ID_IMADDRESSES:
2558 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.messenger, &count);
2559 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);
2561 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.messenger, index, &recordHandle);
2562 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.messenger, recordHandle);
2565 case USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS:
2566 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.company, &count);
2567 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);
2569 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.company, index, &recordHandle);
2570 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.company, recordHandle);
2573 case USER_PROFILE_MPROPERTY_ID_EVENTS:
2574 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.event, &count);
2575 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);
2577 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.event, index, &recordHandle);
2578 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.event, recordHandle);
2581 case USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS:
2582 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.relationship, &count);
2583 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);
2585 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.relationship, index, &recordHandle);
2586 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.relationship, recordHandle);
2589 case USER_PROFILE_MPROPERTY_ID_NOTES:
2590 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.note, &count);
2591 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);
2593 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.note, index, &recordHandle);
2594 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.note, recordHandle);
2597 case USER_PROFILE_MPROPERTY_ID_NICKNAMES:
2598 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.nickname, &count);
2599 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);
2601 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.nickname, index, &recordHandle);
2602 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.nickname, recordHandle);
2606 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
2607 return E_INVALID_ARG;
2615 _UserProfileImpl::GetOrganizationsN(void) const
2617 result r = E_SUCCESS;
2618 contacts_record_h organizationHandle = null;
2619 int ret = CONTACTS_ERROR_NONE;
2620 char* pCharValue = null;
2622 unsigned int count = 0;
2623 std::unique_ptr<Organization> pOrganization(null);
2625 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2626 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2628 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.company, &count);
2630 r = pList->Construct(count);
2631 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2633 for (unsigned int index = 0; index < count; index++)
2635 ret = contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.company, index, &organizationHandle);
2636 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2638 pOrganization.reset(new (std::nothrow) Organization());
2639 SysTryReturn(NID_SCL, pOrganization != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2642 contacts_record_get_str_p(organizationHandle, _contacts_company.name, &pCharValue);
2643 pOrganization->SetName(pCharValue);
2646 contacts_record_get_str_p(organizationHandle, _contacts_company.job_title, &pCharValue);
2647 pOrganization->SetJobTitle(pCharValue);
2650 contacts_record_get_str_p(organizationHandle, _contacts_company.department, &pCharValue);
2651 pOrganization->SetDepartment(pCharValue);
2654 contacts_record_get_str_p(organizationHandle, _contacts_company.role, &pCharValue);
2655 pOrganization->SetRole(pCharValue);
2658 contacts_record_get_str_p(organizationHandle, _contacts_company.assistant_name, &pCharValue);
2659 pOrganization->SetAgent(pCharValue);
2662 contacts_record_get_int(organizationHandle, _contacts_company.type, &intValue);
2665 case CONTACTS_COMPANY_TYPE_WORK:
2666 pOrganization->SetType(ORGANIZATION_TYPE_WORK);
2668 case CONTACTS_COMPANY_TYPE_CUSTOM:
2669 pOrganization->SetType(ORGANIZATION_TYPE_CUSTOM);
2671 case CONTACTS_COMPANY_TYPE_OTHER:
2674 pOrganization->SetType(ORGANIZATION_TYPE_OTHER);
2679 contacts_record_get_str_p(organizationHandle, _contacts_company.label, &pCharValue);
2680 pOrganization->SetLabel(pCharValue);
2683 contacts_record_get_str_p(organizationHandle, _contacts_company.description, &pCharValue);
2684 pOrganization->SetDescription(pCharValue);
2687 contacts_record_get_str_p(organizationHandle, _contacts_company.location, &pCharValue);
2688 pOrganization->SetLocation(pCharValue);
2691 contacts_record_get_str_p(organizationHandle, _contacts_company.phonetic_name, &pCharValue);
2692 pOrganization->SetPhoneticName(pCharValue);
2695 contacts_record_get_str_p(organizationHandle, _contacts_company.logo, &pCharValue);
2696 _OrganizationImpl::GetInstance(*pOrganization)->SetLogoPath(pCharValue);
2698 r = pList->Add(*pOrganization);
2699 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2701 pOrganization.release();
2704 return pList.release();
2709 _UserProfileImpl::GetRelationshipsN(void) const
2712 result r = E_SUCCESS;
2713 contacts_record_h relationshipHandle = null;
2714 int ret = CONTACTS_ERROR_NONE;
2716 char* pCharValue = null;
2717 unsigned int count = 0;
2718 std::unique_ptr<Relationship> pRelationship(null);
2720 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2721 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2723 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.relationship, &count);
2725 r = pList->Construct(count);
2726 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2728 for (unsigned int index = 0; index < count; index++)
2730 ret = contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.relationship, index, &relationshipHandle);
2731 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2733 pRelationship.reset(new (std::nothrow) Relationship());
2734 SysTryReturn(NID_SCL, pRelationship != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2737 contacts_record_get_int(relationshipHandle, _contacts_relationship.type, &intValue);
2740 case CONTACTS_RELATIONSHIP_TYPE_ASSISTANT:
2741 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_ASSISTANT);
2743 case CONTACTS_RELATIONSHIP_TYPE_BROTHER:
2744 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_BROTHER);
2746 case CONTACTS_RELATIONSHIP_TYPE_CHILD:
2747 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_CHILD);
2749 case CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
2750 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER);
2752 case CONTACTS_RELATIONSHIP_TYPE_FATHER:
2753 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_FATHER);
2755 case CONTACTS_RELATIONSHIP_TYPE_FRIEND:
2756 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_FRIEND);
2758 case CONTACTS_RELATIONSHIP_TYPE_MANAGER:
2759 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_MANAGER);
2761 case CONTACTS_RELATIONSHIP_TYPE_MOTHER:
2762 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_MOTHER);
2764 case CONTACTS_RELATIONSHIP_TYPE_PARENT:
2765 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_PARENT);
2767 case CONTACTS_RELATIONSHIP_TYPE_PARTNER:
2768 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_PARTNER);
2770 case CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY:
2771 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_REFERRED_BY);
2773 case CONTACTS_RELATIONSHIP_TYPE_RELATIVE:
2774 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_RELATIVE);
2776 case CONTACTS_RELATIONSHIP_TYPE_SISTER:
2777 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_SISTER);
2779 case CONTACTS_RELATIONSHIP_TYPE_SPOUSE:
2780 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_SPOUSE);
2782 case CONTACTS_RELATIONSHIP_TYPE_CUSTOM:
2785 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_CUSTOM);
2790 contacts_record_get_str_p(relationshipHandle, _contacts_relationship.label, &pCharValue);
2791 pRelationship->SetLabel(pCharValue);
2794 contacts_record_get_str_p(relationshipHandle, _contacts_relationship.name, &pCharValue);
2795 pRelationship->SetRelativeName(pCharValue);
2797 r = pList->Add(*pRelationship);
2798 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2800 pRelationship.release();
2803 return pList.release();
2808 _UserProfileImpl::GetEventsN(void) const
2810 result r = E_SUCCESS;
2811 char* pCharValue = null;
2813 unsigned int count = 0;
2814 contacts_record_h eventHandle = null;
2815 std::unique_ptr<ContactEvent> pEvent(null);
2817 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2818 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2820 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.event, &count);
2822 r = pList->Construct(count);
2823 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2825 for (unsigned int index = 0; index < count; index++)
2827 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.event, index, &eventHandle);
2829 pEvent.reset(new (std::nothrow) ContactEvent());
2830 SysTryReturn(NID_SCL, pEvent != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2833 contacts_record_get_str_p(eventHandle, _contacts_event.label, &pCharValue);
2834 pEvent->SetLabel(pCharValue);
2837 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
2840 case CONTACTS_EVENT_TYPE_BIRTH:
2841 pEvent->SetType(CONTACT_EVENT_TYPE_BIRTHDAY);
2843 case CONTACTS_EVENT_TYPE_ANNIVERSARY:
2844 pEvent->SetType(CONTACT_EVENT_TYPE_ANNIVERSARY);
2846 case CONTACTS_URL_TYPE_CUSTOM:
2847 pEvent->SetType(CONTACT_EVENT_TYPE_CUSTOM);
2850 pEvent->SetType(CONTACT_EVENT_TYPE_OTHER);
2856 contacts_record_get_int(eventHandle, _contacts_event.date, &intValue);
2857 __CONVERT_DATE_TO_DATETIME(intValue, dateTime);
2858 pEvent->SetDate(dateTime);
2860 pList->Add(*pEvent);
2861 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2866 return pList.release();
2871 _UserProfileImpl::GetNotesN(void) const
2873 result r = E_SUCCESS;
2874 char* pCharValue = null;
2875 unsigned int count = 0;
2876 contacts_record_h noteHandle = null;
2877 std::unique_ptr<String> pNote(null);
2879 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2880 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2882 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.note, &count);
2884 r = pList->Construct(count);
2885 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2887 for (unsigned int index = 0; index < count; index++)
2889 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.note, index, ¬eHandle);
2891 contacts_record_get_str_p(noteHandle, _contacts_note.note, &pCharValue);
2893 pNote.reset(new (std::nothrow) String(pCharValue));
2894 SysTryReturn(NID_SCL, pNote != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2897 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2902 return pList.release();
2907 _UserProfileImpl::GetNicknamesN(void) const
2909 result r = E_SUCCESS;
2910 char* pCharValue = null;
2911 unsigned int count = 0;
2912 contacts_record_h nicknameHandle = null;
2913 std::unique_ptr<String> pNickname(null);
2915 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2916 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2918 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.nickname, &count);
2920 r = pList->Construct(count);
2921 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2923 for (unsigned int index = 0; index < count; index++)
2925 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.nickname, index, &nicknameHandle);
2927 contacts_record_get_str_p(nicknameHandle, _contacts_nickname.name, &pCharValue);
2929 pNickname.reset(new (std::nothrow) String(pCharValue));
2930 SysTryReturn(NID_SCL, pNickname != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2932 pList->Add(*pNickname);
2933 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2935 pNickname.release();
2938 return pList.release();
2943 _UserProfileImpl::GetPhoneNumbersN(void) const
2945 result r = E_SUCCESS;
2946 unsigned int count = 0;
2947 contacts_record_h numberHandle = null;
2949 char* pCharValue = null;
2950 PhoneNumberType type = PHONENUMBER_TYPE_HOME;
2951 std::unique_ptr<PhoneNumber> pPhoneNumber(null);
2953 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2954 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2957 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.number, &count);
2959 contacts_record_get_int(__profileHandle, _contacts_my_profile.id, &intValue);
2961 r = pList->Construct(count);
2962 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2964 for (unsigned int index = 0; index < count; index++)
2966 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.number, index, &numberHandle);
2968 pPhoneNumber.reset(new (std::nothrow) PhoneNumber());
2969 SysTryReturn(NID_SCL, pPhoneNumber != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2971 contacts_record_get_int(numberHandle, _contacts_number.id, &intValue);
2972 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetRecordId(intValue);
2974 contacts_record_get_str_p(numberHandle, _contacts_number.label, &pCharValue);
2975 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetLabel(pCharValue);
2977 contacts_record_get_int(numberHandle, _contacts_number.type, &intValue);
2981 case CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE:
2982 type = PHONENUMBER_TYPE_HOME;
2984 case CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE:
2985 type = PHONENUMBER_TYPE_WORK;
2987 case CONTACTS_NUMBER_TYPE_CELL:
2988 type = PHONENUMBER_TYPE_MOBILE;
2990 case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME:
2991 type = PHONENUMBER_TYPE_HOME_FAX;
2993 case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK:
2994 type = PHONENUMBER_TYPE_WORK_FAX;
2996 case CONTACTS_NUMBER_TYPE_PAGER:
2997 type = PHONENUMBER_TYPE_PAGER;
2999 case CONTACTS_NUMBER_TYPE_CUSTOM:
3000 type = PHONENUMBER_TYPE_CUSTOM;
3002 case CONTACTS_NUMBER_TYPE_ASSISTANT:
3003 type = PHONENUMBER_TYPE_ASSISTANT;
3006 if (intValue & CONTACTS_NUMBER_TYPE_FAX)
3008 type = PHONENUMBER_TYPE_HOME_FAX;
3010 else if (intValue & CONTACTS_NUMBER_TYPE_CELL)
3012 type = PHONENUMBER_TYPE_MOBILE;
3014 else if (intValue & CONTACTS_NUMBER_TYPE_PAGER)
3016 type = PHONENUMBER_TYPE_PAGER;
3018 else if (intValue & CONTACTS_NUMBER_TYPE_HOME)
3020 type = PHONENUMBER_TYPE_HOME;
3022 else if (intValue & CONTACTS_NUMBER_TYPE_WORK)
3024 type = PHONENUMBER_TYPE_WORK;
3026 else if (intValue & CONTACTS_NUMBER_TYPE_VOICE)
3028 type = PHONENUMBER_TYPE_HOME;
3032 type = PHONENUMBER_TYPE_OTHER;
3037 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetType(type);
3039 contacts_record_get_str_p(numberHandle, _contacts_number.number, &pCharValue);
3040 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetPhoneNumber(pCharValue);
3042 r = pList->Add(*pPhoneNumber);
3043 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3045 pPhoneNumber.release();
3048 return pList.release();
3053 _UserProfileImpl::GetEmailsN(void) const
3055 result r = E_SUCCESS;
3056 contacts_record_h currentHandle = null;
3057 int ret = CONTACTS_ERROR_NONE;
3059 unsigned int count = 0;
3060 char* pCharValue = null;
3061 EmailType type = EMAIL_TYPE_PERSONAL;
3062 std::unique_ptr<Email> pEmail(null);
3064 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3065 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3067 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.email, &count);
3069 r = pList->Construct(count);
3070 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3072 for (unsigned int index = 0; index < count; index++)
3074 ret = contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.email, index, ¤tHandle);
3075 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM))
3077 pEmail.reset(new (std::nothrow) Email());
3078 SysTryReturn(NID_SCL, pEmail != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3080 contacts_record_get_int(currentHandle, _contacts_email.id, &intValue);
3081 _EmailImpl::GetInstance(*pEmail)->SetRecordId(intValue);
3083 contacts_record_get_str_p(currentHandle, _contacts_email.label, &pCharValue);
3084 _EmailImpl::GetInstance(*pEmail)->SetLabel(pCharValue);
3086 contacts_record_get_int(currentHandle, _contacts_email.type, &intValue);
3089 case CONTACTS_EMAIL_TYPE_HOME:
3090 type = EMAIL_TYPE_PERSONAL;
3092 case CONTACTS_EMAIL_TYPE_WORK:
3093 type = EMAIL_TYPE_WORK;
3095 case CONTACTS_EMAIL_TYPE_CUSTOM:
3096 type = EMAIL_TYPE_CUSTOM;
3098 case CONTACTS_EMAIL_TYPE_MOBILE:
3099 type = EMAIL_TYPE_MOBILE;
3102 type = EMAIL_TYPE_OTHER;
3106 _EmailImpl::GetInstance(*pEmail)->SetType(type);
3108 contacts_record_get_str_p(currentHandle, _contacts_email.email, &pCharValue);
3109 _EmailImpl::GetInstance(*pEmail)->SetEmail(pCharValue);
3111 r = pList->Add(*pEmail);
3112 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3117 return pList.release();
3122 _UserProfileImpl::GetUrlsN(void) const
3125 result r = E_SUCCESS;
3126 char* pCharValue = null;
3128 unsigned int count = 0;
3129 UrlType type = URL_TYPE_PERSONAL;
3130 contacts_record_h urlHandle = null;
3131 std::unique_ptr<Url> pUrl(null);
3133 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3134 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3136 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.url, &count);
3138 r = pList->Construct(count);
3139 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3141 for (unsigned int index = 0; index < count; index++)
3143 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.url, index, &urlHandle);
3145 pUrl.reset(new (std::nothrow) Url());
3146 SysTryReturn(NID_SCL, pUrl != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3148 contacts_record_get_str_p(urlHandle, _contacts_url.label, &pCharValue);
3149 pUrl->SetLabel(pCharValue);
3151 contacts_record_get_int(urlHandle, _contacts_url.type, &intValue);
3154 case CONTACTS_URL_TYPE_HOME:
3155 type = URL_TYPE_PERSONAL;
3157 case CONTACTS_URL_TYPE_WORK:
3158 type = URL_TYPE_WORK;
3160 case CONTACTS_URL_TYPE_CUSTOM:
3161 type = URL_TYPE_CUSTOM;
3164 type = URL_TYPE_OTHER;
3168 pUrl->SetType(type);
3170 contacts_record_get_str_p(urlHandle, _contacts_url.url, &pCharValue);
3171 _UrlImpl::GetInstance(*pUrl)->SetUrl(pCharValue);
3174 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3179 return pList.release();
3184 _UserProfileImpl::GetAddressesN(void) const
3186 result r = E_SUCCESS;
3187 char* pCharValue = null;
3189 unsigned int count = 0;
3190 contacts_record_h addressHandle = 0;
3191 std::unique_ptr<Address> pAddress(null);
3193 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3194 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3196 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.address, &count);
3198 r = pList->Construct(count);
3199 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3202 for (unsigned int index = 0; index < count; index++)
3204 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.address, index, &addressHandle);
3206 pAddress.reset(new (std::nothrow) Address());
3207 SysTryReturn(NID_SCL, pAddress != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3209 contacts_record_get_str_p(addressHandle, _contacts_address.label, &pCharValue);
3210 pAddress->SetLabel(pCharValue);
3212 contacts_record_get_int(addressHandle, _contacts_address.type, &intValue);
3215 case CONTACTS_ADDRESS_TYPE_HOME:
3216 pAddress->SetType(ADDRESS_TYPE_HOME);
3218 case CONTACTS_ADDRESS_TYPE_WORK:
3219 pAddress->SetType(ADDRESS_TYPE_WORK);
3221 case CONTACTS_ADDRESS_TYPE_CUSTOM:
3222 pAddress->SetType(ADDRESS_TYPE_CUSTOM);
3225 pAddress->SetType(ADDRESS_TYPE_OTHER);
3230 contacts_record_get_str_p(addressHandle, _contacts_address.country, &pCharValue);
3231 _AddressImpl::GetInstance(*pAddress)->SetCountry(pCharValue);
3234 contacts_record_get_str_p(addressHandle, _contacts_address.region, &pCharValue);
3235 _AddressImpl::GetInstance(*pAddress)->SetState(pCharValue);
3238 contacts_record_get_str_p(addressHandle, _contacts_address.locality, &pCharValue);
3239 _AddressImpl::GetInstance(*pAddress)->SetCity(pCharValue);
3242 contacts_record_get_str_p(addressHandle, _contacts_address.street, &pCharValue);
3243 _AddressImpl::GetInstance(*pAddress)->SetStreet(pCharValue);
3246 contacts_record_get_str_p(addressHandle, _contacts_address.extended, &pCharValue);
3247 _AddressImpl::GetInstance(*pAddress)->SetExtended(pCharValue);
3250 contacts_record_get_str_p(addressHandle, _contacts_address.postbox, &pCharValue);
3251 _AddressImpl::GetInstance(*pAddress)->SetPostOfficeBoxNumber(pCharValue);
3254 contacts_record_get_str_p(addressHandle, _contacts_address.postal_code, &pCharValue);
3255 _AddressImpl::GetInstance(*pAddress)->SetPostalCode(pCharValue);
3257 r = pList->Add(*pAddress);
3258 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3263 return pList.release();
3268 _UserProfileImpl::GetImAddressesN(void) const
3270 result r = E_SUCCESS;
3271 char* pCharValue = null;
3273 contacts_record_h messengerHandle = null;
3274 unsigned int count = 0;
3275 std::unique_ptr<ImAddress> pImAddress(null);
3277 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3278 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3280 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.messenger, &count);
3282 r = pList->Construct(count);
3283 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3285 for (unsigned int index = 0; index < count; index++)
3287 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.messenger, index, &messengerHandle);
3289 pImAddress.reset(new (std::nothrow) ImAddress());
3290 SysTryReturn(NID_SCL, pImAddress != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3292 contacts_record_get_int(messengerHandle, _contacts_messenger.type, &intValue);
3295 case CONTACTS_MESSENGER_TYPE_GOOGLE:
3296 pImAddress->SetServiceProviderName(IM_ADDRESS_GOOGLE_TALK);
3298 case CONTACTS_MESSENGER_TYPE_WLM:
3299 pImAddress->SetServiceProviderName(IM_ADDRESS_MSN);
3301 case CONTACTS_MESSENGER_TYPE_ICQ:
3302 pImAddress->SetServiceProviderName(IM_ADDRESS_ICQ);
3304 case CONTACTS_MESSENGER_TYPE_AIM:
3305 pImAddress->SetServiceProviderName(IM_ADDRESS_AIM);
3307 case CONTACTS_MESSENGER_TYPE_YAHOO:
3308 pImAddress->SetServiceProviderName(IM_ADDRESS_YAHOO);
3310 case CONTACTS_MESSENGER_TYPE_QQ:
3311 pImAddress->SetServiceProviderName(IM_ADDRESS_QQ);
3313 case CONTACTS_MESSENGER_TYPE_SKYPE:
3314 pImAddress->SetServiceProviderName(IM_ADDRESS_SKYPE);
3316 case CONTACTS_MESSENGER_TYPE_JABBER:
3317 pImAddress->SetServiceProviderName(IM_ADDRESS_JABBER);
3319 case CONTACTS_MESSENGER_TYPE_CUSTOM:
3322 contacts_record_get_str_p(messengerHandle, _contacts_messenger.label, &pCharValue);
3323 pImAddress->SetServiceProviderName(pCharValue);
3327 contacts_record_get_str_p(messengerHandle, _contacts_messenger.im_id, &pCharValue);
3328 _ImAddressImpl::GetInstance(*pImAddress)->SetImAddress(pCharValue);
3330 r = pList->Add(*pImAddress);
3331 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3333 pImAddress.release();
3336 return pList.release();
3342 _UserProfileImpl::IsEmptyCompany(contacts_record_h companyHandle)
3344 char* pCharValue = null;
3346 contacts_record_get_str_p(companyHandle, _contacts_company.name, &pCharValue);
3347 if (pCharValue != null)
3352 contacts_record_get_str_p(companyHandle, _contacts_company.job_title, &pCharValue);
3353 if (pCharValue != null)
3359 contacts_record_get_str_p(companyHandle, _contacts_company.department, &pCharValue);
3360 if (pCharValue != null)
3365 contacts_record_get_str_p(companyHandle, _contacts_company.role, &pCharValue);
3366 if (pCharValue != null)
3371 contacts_record_get_str_p(companyHandle, _contacts_company.assistant_name, &pCharValue);
3372 if (pCharValue != null)
3381 _UserProfileImpl::IsEmptyName(contacts_record_h nameHandle)
3383 char* pCharValue = null;
3385 contacts_record_get_str_p(nameHandle, _contacts_name.first, &pCharValue);
3386 if (pCharValue != null)
3391 contacts_record_get_str_p(nameHandle, _contacts_name.last, &pCharValue);
3392 if (pCharValue != null)
3397 contacts_record_get_str_p(nameHandle, _contacts_name.addition, &pCharValue);
3398 if (pCharValue != null)
3403 contacts_record_get_str_p(nameHandle, _contacts_name.prefix, &pCharValue);
3404 if (pCharValue != null)
3409 contacts_record_get_str_p(nameHandle, _contacts_name.suffix, &pCharValue);
3410 if (pCharValue != null)
3420 _UserProfileImpl::IsEmpty(void) const
3422 unsigned int count = 0;
3424 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.number, &count);
3430 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.email, &count);
3436 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.url, &count);
3442 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.address, &count);
3448 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.messenger, &count);
3454 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
3460 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.company, &count);
3466 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.event, &count);
3472 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.note, &count);
3478 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.nickname, &count);
3484 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.image, &count);
3495 _UserProfileImpl::SetUserProfileHandle(contacts_record_h profileHandle)
3497 contacts_record_destroy(__profileHandle, true);
3499 __profileHandle = profileHandle;
3503 _UserProfileImpl::GetUserProfileHandle(void) const
3505 return __profileHandle;
3508 const _UserProfileImpl*
3509 _UserProfileImpl::GetInstance(const UserProfile& userProfile)
3511 return userProfile.__pUserProfileImpl;
3515 _UserProfileImpl::GetInstance(UserProfile& userProfile)
3517 return userProfile.__pUserProfileImpl;