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);
135 //compare single value properties
136 if (this->GetValue(USER_PROFILE_PROPERTY_ID_FIRST_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_FIRST_NAME))
141 if (this->GetValue(USER_PROFILE_PROPERTY_ID_LAST_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_LAST_NAME))
146 if (this->GetValue(USER_PROFILE_PROPERTY_ID_MIDDLE_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_MIDDLE_NAME))
151 if (this->GetValue(USER_PROFILE_PROPERTY_ID_NAME_PREFIX) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_NAME_PREFIX))
156 if (this->GetValue(USER_PROFILE_PROPERTY_ID_NAME_SUFFIX) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_NAME_SUFFIX))
161 if (this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME))
166 if (this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME))
171 if (this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME))
176 //compare multivalue properties
177 std::unique_ptr<ArrayList, AllElementsDeleter> pCurrentObjectList(null);
178 std::unique_ptr<ArrayList, AllElementsDeleter> pRhsObjectList(null);
180 pCurrentObjectList = std::unique_ptr<ArrayList, AllElementsDeleter> (static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS)));
181 pRhsObjectList = std::unique_ptr<ArrayList, AllElementsDeleter> (static_cast<ArrayList*>(pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS)));
183 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
188 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_EMAILS))));
189 pRhsObjectList.reset((static_cast<ArrayList*>(pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_EMAILS))));
191 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
196 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_URLS))));
197 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_URLS))));
199 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
204 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_ADDRESSES))));
205 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_ADDRESSES))));
207 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
212 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_IMADDRESSES))));
213 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_IMADDRESSES))));
215 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
220 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_EVENTS))));
221 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_EVENTS))));
223 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
228 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS))));
229 pRhsObjectList.reset((static_cast<ArrayList*>(pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS))));
231 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
236 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_NOTES))));
237 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_NOTES))));
239 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
244 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_NICKNAMES))));
245 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_NICKNAMES))));
247 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
252 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS))));
253 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS))));
255 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
264 _UserProfileImpl::GetHashCode(void) const
267 std::unique_ptr<IList, AllElementsDeleter> pMultiPropertyList(null);
269 //calculate single value properties
270 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_FIRST_NAME).GetHashCode();
271 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_LAST_NAME).GetHashCode();
272 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_MIDDLE_NAME).GetHashCode();
273 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_NAME_PREFIX).GetHashCode();
274 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_NAME_SUFFIX).GetHashCode();
275 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME).GetHashCode();
276 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME).GetHashCode();
277 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME).GetHashCode();
278 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetThumbnailPath().GetHashCode();
280 //calculate multi value properties
281 PhoneNumber* pPhoneNumber = null;
282 pMultiPropertyList = std::unique_ptr<IList, AllElementsDeleter> (this->GetValuesN(USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS));
283 std::unique_ptr<IEnumerator> pEnum(pMultiPropertyList->GetEnumeratorN());
284 while (pEnum->MoveNext() == E_SUCCESS)
286 pPhoneNumber = static_cast<PhoneNumber*>(pEnum->GetCurrent());
287 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pPhoneNumber->GetHashCode();
290 Email* pEmail = null;
291 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_EMAILS));
292 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
293 while (pEnum->MoveNext() == E_SUCCESS)
295 pEmail = static_cast<Email*>(pEnum->GetCurrent());
296 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pEmail->GetHashCode();
300 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_URLS));
301 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
302 while (pEnum->MoveNext() == E_SUCCESS)
304 pUrl = static_cast<Url*>(pEnum->GetCurrent());
305 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pUrl->GetHashCode();
308 Address* pAddress = null;
309 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_ADDRESSES));
310 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
311 while (pEnum->MoveNext() == E_SUCCESS)
313 pAddress = static_cast<Address*>(pEnum->GetCurrent());
314 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pAddress->GetHashCode();
317 ImAddress* pImAddress = null;
318 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_IMADDRESSES));
319 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
320 while (pEnum->MoveNext() == E_SUCCESS)
322 pImAddress = static_cast<ImAddress*>(pEnum->GetCurrent());
323 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pImAddress->GetHashCode();
326 ContactEvent* pEvent = null;
327 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_EVENTS));
328 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
329 while (pEnum->MoveNext() == E_SUCCESS)
331 pEvent = static_cast<ContactEvent*>(pEnum->GetCurrent());
332 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pEvent->GetHashCode();
335 Organization* pOrganization = null;
336 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS));
337 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
338 while (pEnum->MoveNext() == E_SUCCESS)
340 pOrganization = static_cast<Organization*>(pEnum->GetCurrent());
341 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pOrganization->GetHashCode();
344 String* pNote = null;
345 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_NOTES));
346 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
347 while (pEnum->MoveNext() == E_SUCCESS)
349 pNote = static_cast<String*>(pEnum->GetCurrent());
350 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pNote->GetHashCode();
353 String* pNickname = null;
354 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_NICKNAMES));
355 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
356 while (pEnum->MoveNext() == E_SUCCESS)
358 pNickname = static_cast<String*>(pEnum->GetCurrent());
359 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pNickname->GetHashCode();
362 Relationship* pRelationship = null;
363 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS));
364 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
365 while (pEnum->MoveNext() == E_SUCCESS)
367 pRelationship = static_cast<Relationship*>(pEnum->GetCurrent());
368 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pRelationship->GetHashCode();
375 _UserProfileImpl::GetThumbnailPath(void) const
377 unsigned int count = 0;
379 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.image, &count);
385 char* pCharValue = null;
386 contacts_record_h imageHandle = null;
388 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.image, 0, &imageHandle);
389 contacts_record_get_str_p(imageHandle, _contacts_image.path, &pCharValue);
391 return String(pCharValue);
395 _UserProfileImpl::SetThumbnail(const String& filePath)
397 unsigned int count = 0;
398 contacts_record_h imageHandle = null;
400 bool fileExist = true;
402 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.image, &count);
405 errCode = contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.image, 0, &imageHandle);
406 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
407 "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
409 if (!filePath.IsEmpty())
411 fileExist = File::IsFileExist(filePath);
412 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, E_INVALID_ARG, E_INVALID_ARG,
413 "[%s] Invalid file path.", GetErrorMessage(E_INVALID_ARG));
414 SysTryReturn(NID_SCL, fileExist != false, E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
415 "[%s] The specified file is not found.", GetErrorMessage(E_FILE_NOT_FOUND));
417 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(filePath));
418 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
420 errCode = contacts_record_set_str(imageHandle, _contacts_image.path, pCharArray.get());
421 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
422 "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
426 errCode = contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.image, imageHandle);
427 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
428 "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
433 if (!filePath.IsEmpty())
435 fileExist = File::IsFileExist(filePath);
436 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, E_INVALID_ARG, E_INVALID_ARG,
437 "[%s] Invalid file path.", GetErrorMessage(E_INVALID_ARG));
438 SysTryReturn(NID_SCL, fileExist != false, E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
439 "[%s] The specified file is not found.", GetErrorMessage(E_FILE_NOT_FOUND));
441 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(filePath));
442 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
444 errCode = contacts_record_create(_contacts_image._uri, &imageHandle);
445 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
446 "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
448 errCode = contacts_record_set_str(imageHandle, _contacts_image.path, pCharArray.get());
449 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
450 "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
452 errCode = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.image, imageHandle);
453 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
454 "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
463 _UserProfileImpl::SetValue(UserProfilePropertyId id, const String& value)
465 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));
467 int ret = CONTACTS_ERROR_NONE;
468 unsigned int count = 0;
472 case USER_PROFILE_PROPERTY_ID_FIRST_NAME:
474 contacts_record_h nameHandle = null;
475 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
479 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
481 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
482 contacts_record_set_str(nameHandle, _contacts_name.first, pCharArray.get());
484 if (value.IsEmpty() && IsEmptyName(nameHandle))
486 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
491 if (!value.IsEmpty())
493 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
494 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
496 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
497 contacts_record_set_str(nameHandle, _contacts_name.first, pCharArray.get());
499 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
505 case USER_PROFILE_PROPERTY_ID_MIDDLE_NAME:
507 contacts_record_h nameHandle = null;
508 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
512 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
514 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
515 ret = contacts_record_set_str(nameHandle, _contacts_name.addition, pCharArray.get());
517 if (value.IsEmpty() && IsEmptyName(nameHandle))
519 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
524 if (!value.IsEmpty())
526 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
527 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
529 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
530 contacts_record_set_str(nameHandle, _contacts_name.addition, pCharArray.get());
532 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
540 case USER_PROFILE_PROPERTY_ID_LAST_NAME:
542 contacts_record_h nameHandle = null;
543 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
547 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
549 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
550 contacts_record_set_str(nameHandle, _contacts_name.last, pCharArray.get());
552 if (value.IsEmpty() && IsEmptyName(nameHandle))
554 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
559 if (!value.IsEmpty())
561 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
562 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
564 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
565 contacts_record_set_str(nameHandle, _contacts_name.last, pCharArray.get());
567 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
574 case USER_PROFILE_PROPERTY_ID_NAME_SUFFIX:
576 contacts_record_h nameHandle = null;
577 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
581 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
583 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
584 contacts_record_set_str(nameHandle, _contacts_name.suffix, pCharArray.get());
586 if (value.IsEmpty() && IsEmptyName(nameHandle))
588 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
594 if (!value.IsEmpty())
596 contacts_record_create(_contacts_name._uri, &nameHandle);
597 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
599 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
600 contacts_record_set_str(nameHandle, _contacts_name.suffix, pCharArray.get());
602 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
610 case USER_PROFILE_PROPERTY_ID_NAME_PREFIX:
612 contacts_record_h nameHandle = null;
613 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
617 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
619 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
620 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
622 if (value.IsEmpty() && IsEmptyName(nameHandle))
624 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
629 if (!value.IsEmpty())
631 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
632 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
634 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
635 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
637 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
645 case USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME:
647 contacts_record_h nameHandle = null;
648 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
652 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
654 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
655 contacts_record_set_str(nameHandle, _contacts_name.phonetic_first, pCharArray.get());
657 if (value.IsEmpty() && IsEmptyName(nameHandle))
659 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
664 if (!value.IsEmpty())
666 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
667 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
669 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
670 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
672 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
680 case USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME:
682 contacts_record_h nameHandle = null;
683 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
687 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
689 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
690 contacts_record_set_str(nameHandle, _contacts_name.phonetic_last, pCharArray.get());
692 if (value.IsEmpty() && IsEmptyName(nameHandle))
694 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
699 if (!value.IsEmpty())
701 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
702 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
704 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
705 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
707 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
715 case USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
717 contacts_record_h nameHandle = null;
718 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
722 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
724 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
725 contacts_record_set_str(nameHandle, _contacts_name.phonetic_middle, pCharArray.get());
727 if (value.IsEmpty() && IsEmptyName(nameHandle))
729 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
734 if (!value.IsEmpty())
736 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
737 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
739 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
740 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
742 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
751 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
752 return E_INVALID_ARG;
759 _UserProfileImpl::GetValue(UserProfilePropertyId id) const
761 unsigned int count = 0;
762 char* pCharValue = null;
767 case USER_PROFILE_PROPERTY_ID_FIRST_NAME:
769 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
772 contacts_record_h nameHandle = null;
774 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
775 contacts_record_get_str_p(nameHandle, _contacts_name.first, &pCharValue);
781 case USER_PROFILE_PROPERTY_ID_LAST_NAME:
783 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
786 contacts_record_h nameHandle = null;
788 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
789 contacts_record_get_str_p(nameHandle, _contacts_name.last, &pCharValue);
795 case USER_PROFILE_PROPERTY_ID_MIDDLE_NAME:
797 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
800 contacts_record_h nameHandle = null;
802 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
803 contacts_record_get_str_p(nameHandle, _contacts_name.addition, &pCharValue);
809 case USER_PROFILE_PROPERTY_ID_NAME_PREFIX:
811 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
814 contacts_record_h nameHandle = null;
816 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
817 contacts_record_get_str_p(nameHandle, _contacts_name.prefix, &pCharValue);
823 case USER_PROFILE_PROPERTY_ID_NAME_SUFFIX:
825 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
828 contacts_record_h nameHandle = null;
830 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
831 contacts_record_get_str_p(nameHandle, _contacts_name.suffix, &pCharValue);
837 case USER_PROFILE_PROPERTY_ID_DISPLAY_NAME:
838 contacts_record_get_str_p(__profileHandle, _contacts_my_profile.display_name, &pCharValue);
841 case USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME:
843 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
846 contacts_record_h nameHandle = null;
848 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
849 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_first, &pCharValue);
855 case USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME:
857 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
860 contacts_record_h nameHandle = null;
862 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
863 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_last, &pCharValue);
869 case USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
871 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
874 contacts_record_h nameHandle = null;
876 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
877 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_middle, &pCharValue);
885 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d", GetErrorMessage(E_INVALID_ARG), id);
893 _UserProfileImpl::SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber)
895 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);
896 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));
898 unsigned int count = 0;
899 contacts_record_h recordHandle = null;
904 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.number, &count);
905 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);
907 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.number, index, &recordHandle);
909 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetLabel();
911 switch (_PhoneNumberImpl::GetInstance(phoneNumber)->GetType())
913 case PHONENUMBER_TYPE_HOME:
914 type = CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE;
916 case PHONENUMBER_TYPE_WORK:
917 type = CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE;
919 case PHONENUMBER_TYPE_MOBILE:
920 type = CONTACTS_NUMBER_TYPE_CELL;
922 case PHONENUMBER_TYPE_HOME_FAX:
923 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME;
925 case PHONENUMBER_TYPE_WORK_FAX:
926 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK;
928 case PHONENUMBER_TYPE_PAGER:
929 type = CONTACTS_NUMBER_TYPE_PAGER;
931 case PHONENUMBER_TYPE_CUSTOM:
932 type = CONTACTS_NUMBER_TYPE_CUSTOM;
934 case PHONENUMBER_TYPE_ASSISTANT:
935 type = CONTACTS_NUMBER_TYPE_ASSISTANT;
937 case PHONENUMBER_TYPE_OTHER:
938 contacts_record_get_int(recordHandle, _contacts_number.type, &oriType);
940 if (oriType == (CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE)
941 || oriType == (CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE)
942 || oriType == CONTACTS_NUMBER_TYPE_CELL
943 || oriType == (CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME)
944 || oriType == (CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK)
945 || oriType == CONTACTS_NUMBER_TYPE_PAGER
946 || oriType == CONTACTS_NUMBER_TYPE_CUSTOM)
948 type = CONTACTS_NUMBER_TYPE_OTHER;
956 type = CONTACTS_NUMBER_TYPE_OTHER;
961 contacts_record_set_int(recordHandle, _contacts_number.type, type);
964 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
965 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
967 contacts_record_set_str(recordHandle, _contacts_number.label, pCharArray.get());
970 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetPhoneNumber();
971 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
972 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
974 contacts_record_set_str(recordHandle, _contacts_number.number, pCharArray.get());
981 _UserProfileImpl::SetEmailAt(int index, const Email& email)
983 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);
984 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));
986 unsigned int count = 0;
987 contacts_record_h emailHandle = null;
991 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.email, &count);
992 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);
994 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.email, index, &emailHandle);
996 stringValue = _EmailImpl::GetInstance(email)->GetLabel();
998 switch (_EmailImpl::GetInstance(email)->GetType())
1000 case EMAIL_TYPE_PERSONAL:
1001 type = CONTACTS_EMAIL_TYPE_HOME;
1003 case EMAIL_TYPE_WORK:
1004 type = CONTACTS_EMAIL_TYPE_WORK;
1006 case EMAIL_TYPE_CUSTOM:
1007 type = CONTACTS_EMAIL_TYPE_CUSTOM;
1009 case EMAIL_TYPE_MOBILE:
1010 type = CONTACTS_EMAIL_TYPE_MOBILE;
1012 case EMAIL_TYPE_OTHER:
1015 type = CONTACTS_EMAIL_TYPE_OTHER;
1020 contacts_record_set_int(emailHandle, _contacts_email.type, type);
1023 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1024 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1026 contacts_record_set_str(emailHandle, _contacts_email.label, pCharArray.get());
1029 stringValue = _EmailImpl::GetInstance(email)->GetEmail();
1030 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1031 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1033 contacts_record_set_str(emailHandle, _contacts_email.email, pCharArray.get());
1039 _UserProfileImpl::SetUrlAt(int index, const Url& url)
1041 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);
1042 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));
1043 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1045 unsigned int count = 0;
1046 contacts_record_h urlHandle = null;
1050 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.url, &count);
1051 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);
1053 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.url, index, &urlHandle);
1056 stringValue = _UrlImpl::GetInstance(url)->GetLabel();
1058 switch (_UrlImpl::GetInstance(url)->GetType())
1060 case URL_TYPE_PERSONAL:
1061 type = CONTACTS_URL_TYPE_HOME;
1064 type = CONTACTS_URL_TYPE_WORK;
1066 case URL_TYPE_CUSTOM:
1067 type = CONTACTS_URL_TYPE_CUSTOM;
1069 case URL_TYPE_OTHER:
1072 type = CONTACTS_URL_TYPE_OTHER;
1077 contacts_record_set_int(urlHandle, _contacts_url.type, type);
1080 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1081 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1083 contacts_record_set_str(urlHandle, _contacts_url.label, pCharArray.get());
1086 stringValue = _UrlImpl::GetInstance(url)->GetUrl();
1087 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1088 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1090 contacts_record_set_str(urlHandle, _contacts_url.url, pCharArray.get());
1097 _UserProfileImpl::SetAddressAt(int index, const Address& address)
1099 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);
1100 SysTryReturn(NID_SCL,
1101 !address.GetCity().IsEmpty() ||
1102 !address.GetCountry().IsEmpty() ||
1103 !address.GetExtended().IsEmpty() ||
1104 !address.GetPostalCode().IsEmpty() ||
1105 !address.GetPostOfficeBoxNumber().IsEmpty() ||
1106 !address.GetState().IsEmpty() ||
1107 !address.GetStreet().IsEmpty(),
1108 E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The address is empty.", GetErrorMessage(E_INVALID_ARG));
1110 unsigned int count = 0;
1111 contacts_record_h addressHandle = null;
1115 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.address, &count);
1116 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);
1118 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.address, index, &addressHandle);
1120 stringValue = _AddressImpl::GetInstance(address)->GetLabel();
1122 switch (_AddressImpl::GetInstance(address)->GetType())
1124 case ADDRESS_TYPE_HOME:
1125 type = CONTACTS_ADDRESS_TYPE_HOME;
1127 case ADDRESS_TYPE_WORK:
1128 type = CONTACTS_ADDRESS_TYPE_WORK;
1130 case ADDRESS_TYPE_CUSTOM:
1131 type = CONTACTS_ADDRESS_TYPE_CUSTOM;
1133 case ADDRESS_TYPE_OTHER:
1136 type = CONTACTS_ADDRESS_TYPE_OTHER;
1141 contacts_record_set_int(addressHandle, _contacts_address.type, type);
1144 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1145 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1147 contacts_record_set_str(addressHandle, _contacts_address.label, pCharArray.get());
1150 stringValue = _AddressImpl::GetInstance(address)->GetCity();
1151 if (!stringValue.IsEmpty())
1153 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1154 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1156 contacts_record_set_str(addressHandle, _contacts_address.locality, pCharArray.get());
1160 contacts_record_set_str(addressHandle, _contacts_address.locality, null);
1163 stringValue = _AddressImpl::GetInstance(address)->GetCountry();
1164 if (!stringValue.IsEmpty())
1166 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1167 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1169 contacts_record_set_str(addressHandle, _contacts_address.country, pCharArray.get());
1173 contacts_record_set_str(addressHandle, _contacts_address.country, null);
1176 stringValue = _AddressImpl::GetInstance(address)->GetExtended();
1177 if (!stringValue.IsEmpty())
1179 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1180 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1182 contacts_record_set_str(addressHandle, _contacts_address.extended, pCharArray.get());
1186 contacts_record_set_str(addressHandle, _contacts_address.extended, null);
1189 stringValue = _AddressImpl::GetInstance(address)->GetPostalCode();
1190 if (!stringValue.IsEmpty())
1192 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1193 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1195 contacts_record_set_str(addressHandle, _contacts_address.postal_code, pCharArray.get());
1199 contacts_record_set_str(addressHandle, _contacts_address.postal_code, null);
1202 stringValue = _AddressImpl::GetInstance(address)->GetPostOfficeBoxNumber();
1203 if (!stringValue.IsEmpty())
1205 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1206 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1208 contacts_record_set_str(addressHandle, _contacts_address.postbox, pCharArray.get());
1212 contacts_record_set_str(addressHandle, _contacts_address.postbox, null);
1215 stringValue = _AddressImpl::GetInstance(address)->GetState();
1216 if (!stringValue.IsEmpty())
1218 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1219 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1221 contacts_record_set_str(addressHandle, _contacts_address.region, pCharArray.get());
1225 contacts_record_set_str(addressHandle, _contacts_address.region, null);
1228 stringValue = _AddressImpl::GetInstance(address)->GetStreet();
1229 if (!stringValue.IsEmpty())
1231 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1232 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1234 contacts_record_set_str(addressHandle, _contacts_address.street, pCharArray.get());
1238 contacts_record_set_str(addressHandle, _contacts_address.street, null);
1245 _UserProfileImpl::SetImAddressAt(int index, const ImAddress& imAddress)
1247 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);
1248 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));
1249 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1251 unsigned int count = 0;
1252 contacts_record_h messengerHandle = null;
1255 std::unique_ptr<char[]> pCharArray(null);
1257 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.messenger, &count);
1258 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);
1260 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.messenger, index, &messengerHandle);
1262 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetServiceProviderName();
1264 if (stringValue == IM_ADDRESS_GOOGLE_TALK)
1266 type = CONTACTS_MESSENGER_TYPE_GOOGLE;
1268 else if (stringValue == IM_ADDRESS_MSN)
1270 type = CONTACTS_MESSENGER_TYPE_WLM;
1272 else if (stringValue == IM_ADDRESS_ICQ)
1274 type = CONTACTS_MESSENGER_TYPE_ICQ;
1276 else if (stringValue == IM_ADDRESS_AIM)
1278 type = CONTACTS_MESSENGER_TYPE_AIM;
1280 else if (stringValue == IM_ADDRESS_YAHOO)
1282 type = CONTACTS_MESSENGER_TYPE_YAHOO;
1284 else if (stringValue == IM_ADDRESS_QQ)
1286 type = CONTACTS_MESSENGER_TYPE_QQ;
1288 else if (stringValue == IM_ADDRESS_SKYPE)
1290 type = CONTACTS_MESSENGER_TYPE_SKYPE;
1292 else if (stringValue == IM_ADDRESS_JABBER)
1294 type = CONTACTS_MESSENGER_TYPE_JABBER;
1298 type = CONTACTS_MESSENGER_TYPE_CUSTOM;
1301 contacts_record_set_int(messengerHandle, _contacts_messenger.type, type);
1302 if (type == CONTACTS_MESSENGER_TYPE_CUSTOM)
1304 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1305 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1307 contacts_record_set_str(messengerHandle, _contacts_messenger.label, pCharArray.get());
1310 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetImAddress();
1311 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1312 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1314 contacts_record_set_str(messengerHandle, _contacts_messenger.im_id, pCharArray.get());
1321 _UserProfileImpl::SetNoteAt(int index, const String& note)
1323 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);
1324 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));
1325 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1327 unsigned int count = 0;
1328 contacts_record_h noteHandle = null;
1330 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.note, &count);
1331 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);
1333 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.note, index, ¬eHandle);
1335 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(note));
1336 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1338 contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
1344 _UserProfileImpl::SetNicknameAt(int index, const String& nickname)
1346 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);
1347 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));
1348 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1350 unsigned int count = 0;
1351 contacts_record_h nicknameHandle = null;
1353 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.nickname, &count);
1354 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);
1356 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.nickname, index, &nicknameHandle);
1358 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(nickname));
1359 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1361 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
1367 _UserProfileImpl::SetEventAt(int index, const ContactEvent& event)
1369 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);
1370 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1374 unsigned int count = 0;
1376 contacts_record_h eventHandle = null;
1378 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.event, &count);
1379 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);
1381 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.event, index, &eventHandle);
1383 switch (event.GetType())
1385 case CONTACT_EVENT_TYPE_ANNIVERSARY:
1386 type = CONTACTS_EVENT_TYPE_ANNIVERSARY;
1388 case CONTACT_EVENT_TYPE_BIRTHDAY:
1389 type = CONTACTS_EVENT_TYPE_BIRTH;
1391 case CONTACT_EVENT_TYPE_CUSTOM:
1392 type = CONTACTS_EVENT_TYPE_CUSTOM;
1394 case CONTACT_EVENT_TYPE_OTHER:
1397 type = CONTACTS_EVENT_TYPE_OTHER;
1402 contacts_record_set_int(eventHandle, _contacts_event.type, type);
1405 stringValue = event.GetLabel();
1407 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1408 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1410 contacts_record_set_str(eventHandle, _contacts_event.label, pCharArray.get());
1413 DateTime dateValue = event.GetDate();
1414 intValue = dateValue.GetYear()*10000 + dateValue.GetMonth()*100 + dateValue.GetDay();
1415 contacts_record_set_int(eventHandle, _contacts_event.date, intValue);
1422 _UserProfileImpl::SetOrganizationAt(int index, const Organization& organization)
1424 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);
1425 SysTryReturn(NID_SCL
1426 , !organization.GetName().IsEmpty() ||
1427 !organization.GetJobTitle().IsEmpty() ||
1428 !organization.GetDepartment().IsEmpty() ||
1429 !organization.GetRole().IsEmpty() ||
1430 !organization.GetAgent().IsEmpty() ||
1431 !organization.GetLocation().IsEmpty() ||
1432 !organization.GetDescription().IsEmpty() ||
1433 !organization.GetPhoneticName().IsEmpty() ||
1434 !organization.GetLogoPath().IsEmpty()
1435 ,E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The organization is empty.", GetErrorMessage(E_INVALID_ARG));
1437 unsigned int count = 0;
1438 contacts_record_h organizationHandle = null;
1440 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.company, &count);
1441 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);
1444 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.company, index, &organizationHandle);
1447 String stringValue = organization.GetName();
1448 if (!stringValue.IsEmpty())
1450 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1451 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1453 contacts_record_set_str(organizationHandle, _contacts_company.name, pCharArray.get());
1457 contacts_record_set_str(organizationHandle, _contacts_company.name, null);
1461 stringValue = organization.GetJobTitle();
1462 if (!stringValue.IsEmpty())
1464 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1465 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1467 contacts_record_set_str(organizationHandle, _contacts_company.job_title, pCharArray.get());
1471 contacts_record_set_str(organizationHandle, _contacts_company.job_title, null);
1475 stringValue = organization.GetDepartment();
1476 if (!stringValue.IsEmpty())
1478 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1479 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1481 contacts_record_set_str(organizationHandle, _contacts_company.department, pCharArray.get());
1485 contacts_record_set_str(organizationHandle, _contacts_company.department, null);
1489 stringValue = organization.GetRole();
1490 if (!stringValue.IsEmpty())
1492 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1493 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1495 contacts_record_set_str(organizationHandle, _contacts_company.role, pCharArray.get());
1499 contacts_record_set_str(organizationHandle, _contacts_company.role, null);
1503 stringValue = organization.GetAgent();
1504 if (!stringValue.IsEmpty())
1506 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1507 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1509 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, pCharArray.get());
1513 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, null);
1519 switch (organization.GetType())
1521 case ORGANIZATION_TYPE_WORK:
1522 type = CONTACTS_COMPANY_TYPE_WORK;
1524 case ORGANIZATION_TYPE_CUSTOM:
1525 type = CONTACTS_COMPANY_TYPE_CUSTOM;
1527 case ORGANIZATION_TYPE_OTHER:
1530 type = CONTACTS_COMPANY_TYPE_OTHER;
1533 contacts_record_set_int(organizationHandle, _contacts_company.type, type);
1536 stringValue = organization.GetLabel();
1537 if (!stringValue.IsEmpty())
1539 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1540 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1542 contacts_record_set_str(organizationHandle, _contacts_company.label, pCharArray.get());
1546 contacts_record_set_str(organizationHandle, _contacts_company.label, null);
1550 stringValue = organization.GetLocation();
1551 if (!stringValue.IsEmpty())
1553 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1554 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1556 contacts_record_set_str(organizationHandle, _contacts_company.location, pCharArray.get());
1560 contacts_record_set_str(organizationHandle, _contacts_company.location, null);
1564 stringValue = organization.GetDescription();
1565 if (!stringValue.IsEmpty())
1567 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1568 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1570 contacts_record_set_str(organizationHandle, _contacts_company.description, pCharArray.get());
1574 contacts_record_set_str(organizationHandle, _contacts_company.description, null);
1578 stringValue = organization.GetPhoneticName();
1579 if (!stringValue.IsEmpty())
1581 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1582 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1584 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, pCharArray.get());
1588 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, null);
1592 if (_OrganizationImpl::GetInstance(organization)->IsLogoPathChanged() == true)
1594 stringValue = organization.GetLogoPath();
1595 if (!stringValue.IsEmpty())
1597 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1598 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1600 contacts_record_set_str(organizationHandle, _contacts_company.logo, pCharArray.get());
1604 contacts_record_set_str(organizationHandle, _contacts_company.logo, null);
1612 _UserProfileImpl::SetRelationshipAt(int index, const Relationship& relationship)
1614 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);
1615 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));
1616 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1619 unsigned int count = 0;
1620 contacts_record_h relationshipHandle = null;
1622 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.relationship, &count);
1623 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);
1625 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.relationship, index, &relationshipHandle);
1627 switch (relationship.GetType())
1629 case CONTACT_RELATIONSHIP_TYPE_ASSISTANT:
1630 intValue = CONTACTS_RELATIONSHIP_TYPE_ASSISTANT;
1632 case CONTACT_RELATIONSHIP_TYPE_BROTHER:
1633 intValue = CONTACTS_RELATIONSHIP_TYPE_BROTHER;
1635 case CONTACT_RELATIONSHIP_TYPE_CHILD:
1636 intValue = CONTACTS_RELATIONSHIP_TYPE_CHILD;
1638 case CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
1639 intValue = CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER;
1641 case CONTACT_RELATIONSHIP_TYPE_FATHER:
1642 intValue = CONTACTS_RELATIONSHIP_TYPE_FATHER;
1644 case CONTACT_RELATIONSHIP_TYPE_FRIEND:
1645 intValue = CONTACTS_RELATIONSHIP_TYPE_FRIEND;
1647 case CONTACT_RELATIONSHIP_TYPE_MANAGER:
1648 intValue = CONTACTS_RELATIONSHIP_TYPE_MANAGER;
1650 case CONTACT_RELATIONSHIP_TYPE_MOTHER:
1651 intValue = CONTACTS_RELATIONSHIP_TYPE_MOTHER;
1653 case CONTACT_RELATIONSHIP_TYPE_PARENT:
1654 intValue = CONTACTS_RELATIONSHIP_TYPE_PARENT;
1656 case CONTACT_RELATIONSHIP_TYPE_PARTNER:
1657 intValue = CONTACTS_RELATIONSHIP_TYPE_PARTNER;
1659 case CONTACT_RELATIONSHIP_TYPE_REFERRED_BY:
1660 intValue = CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY;
1662 case CONTACT_RELATIONSHIP_TYPE_RELATIVE:
1663 intValue = CONTACTS_RELATIONSHIP_TYPE_RELATIVE;
1665 case CONTACT_RELATIONSHIP_TYPE_SISTER:
1666 intValue = CONTACTS_RELATIONSHIP_TYPE_SISTER;
1668 case CONTACT_RELATIONSHIP_TYPE_SPOUSE:
1669 intValue = CONTACTS_RELATIONSHIP_TYPE_SPOUSE;
1671 case CONTACT_RELATIONSHIP_TYPE_CUSTOM:
1672 intValue = CONTACTS_RELATIONSHIP_TYPE_CUSTOM;
1675 intValue = CONTACTS_RELATIONSHIP_TYPE_OTHER;
1680 contacts_record_set_int(relationshipHandle, _contacts_relationship.type, intValue);
1683 String stringValue = relationship.GetLabel();
1684 if (!stringValue.IsEmpty())
1686 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1687 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1689 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, pCharArray.get());
1693 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, null);
1697 stringValue = relationship.GetRelativeName();
1698 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1699 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1701 contacts_record_set_str(relationshipHandle, _contacts_relationship.name, pCharArray.get());
1707 _UserProfileImpl::GetAddressbookId(void) const
1709 int addressbookId = 0;
1711 contacts_record_get_int(__profileHandle, _contacts_my_profile.address_book_id, &addressbookId);
1713 return addressbookId;
1717 _UserProfileImpl::GetValuesN(const UserProfileMultiPropertyId id) const
1719 IList* pList = null;
1725 case USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS:
1726 pList = GetPhoneNumbersN();
1729 case USER_PROFILE_MPROPERTY_ID_EMAILS:
1730 pList = GetEmailsN();
1733 case USER_PROFILE_MPROPERTY_ID_URLS:
1737 case USER_PROFILE_MPROPERTY_ID_ADDRESSES:
1738 pList = GetAddressesN();
1741 case USER_PROFILE_MPROPERTY_ID_IMADDRESSES:
1742 pList = GetImAddressesN();
1745 case USER_PROFILE_MPROPERTY_ID_EVENTS:
1746 pList = GetEventsN();
1749 case USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS:
1750 pList = GetOrganizationsN();
1753 case USER_PROFILE_MPROPERTY_ID_NOTES:
1754 pList = GetNotesN();
1757 case CONTACT_MPROPERTY_ID_NICKNAMES:
1758 pList = GetNicknamesN();
1761 case USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS:
1762 pList = GetRelationshipsN();
1767 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
1771 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1778 _UserProfileImpl::AddPhoneNumber(const PhoneNumber& phoneNumber)
1780 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));
1784 contacts_record_h numberHandle = null;
1786 int ret = contacts_record_create(_contacts_number._uri, &numberHandle);
1787 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1789 __ContactsRecordHandle recordHandle(numberHandle);
1791 switch (_PhoneNumberImpl::GetInstance(phoneNumber)->GetType())
1793 case PHONENUMBER_TYPE_HOME:
1794 type = CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE;
1796 case PHONENUMBER_TYPE_WORK:
1797 type = CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE;
1799 case PHONENUMBER_TYPE_MOBILE:
1800 type = CONTACTS_NUMBER_TYPE_CELL;
1802 case PHONENUMBER_TYPE_HOME_FAX:
1803 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME;
1805 case PHONENUMBER_TYPE_WORK_FAX:
1806 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK;
1808 case PHONENUMBER_TYPE_PAGER:
1809 type = CONTACTS_NUMBER_TYPE_PAGER;
1811 case PHONENUMBER_TYPE_CUSTOM:
1812 type = CONTACTS_NUMBER_TYPE_CUSTOM;
1814 case PHONENUMBER_TYPE_ASSISTANT:
1815 type = CONTACTS_NUMBER_TYPE_ASSISTANT;
1817 case PHONENUMBER_TYPE_OTHER:
1819 type = CONTACTS_NUMBER_TYPE_OTHER;
1823 contacts_record_set_int(numberHandle, _contacts_number.type, type);
1825 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetLabel();
1827 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1828 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1830 contacts_record_set_str(numberHandle, _contacts_number.label, pCharArray.get());
1832 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetPhoneNumber();
1833 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1834 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1836 contacts_record_set_str(numberHandle, _contacts_number.number, pCharArray.get());
1838 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.number, numberHandle);
1839 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1841 recordHandle.Release();
1848 _UserProfileImpl::AddNickname(const String& nickname)
1851 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));
1853 contacts_record_h nicknameHandle = null;
1855 int ret = contacts_record_create(_contacts_nickname._uri, &nicknameHandle);
1856 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1858 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(nickname));
1859 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1861 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
1863 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.nickname, nicknameHandle);
1864 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1871 _UserProfileImpl::AddNote(const String& note)
1873 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));
1875 contacts_record_h noteHandle = null;
1877 int ret = contacts_record_create(_contacts_note._uri, ¬eHandle);
1878 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1880 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(note));
1881 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1883 contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
1885 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.note, noteHandle);
1886 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1893 _UserProfileImpl::AddEmail(const Email& email)
1896 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));
1900 contacts_record_h emailHandle = null;
1902 int ret = contacts_record_create(_contacts_email._uri, &emailHandle);
1903 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1905 __ContactsRecordHandle recordHandle(emailHandle);
1907 switch (_EmailImpl::GetInstance(email)->GetType())
1909 case EMAIL_TYPE_PERSONAL:
1910 type = CONTACTS_EMAIL_TYPE_HOME;
1912 case EMAIL_TYPE_WORK:
1913 type = CONTACTS_EMAIL_TYPE_WORK;
1915 case EMAIL_TYPE_CUSTOM:
1916 type = CONTACTS_EMAIL_TYPE_CUSTOM;
1918 case EMAIL_TYPE_MOBILE:
1919 type = CONTACTS_EMAIL_TYPE_MOBILE;
1921 case EMAIL_TYPE_OTHER:
1924 type = CONTACTS_EMAIL_TYPE_OTHER;
1928 contacts_record_set_int(emailHandle, _contacts_email.type, type);
1930 stringValue = _EmailImpl::GetInstance(email)->GetLabel();
1931 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1932 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1934 contacts_record_set_str(emailHandle, _contacts_email.label, pCharArray.get());
1936 stringValue = _EmailImpl::GetInstance(email)->GetEmail();
1937 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1938 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1940 contacts_record_set_str(emailHandle, _contacts_email.email, pCharArray.get());
1942 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.email, emailHandle);
1943 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1945 recordHandle.Release();
1952 _UserProfileImpl::AddUrl(const Url& url)
1954 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));
1958 contacts_record_h urlHandle = null;
1960 int ret = contacts_record_create(_contacts_url._uri, &urlHandle);
1961 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1963 __ContactsRecordHandle recordHandle(urlHandle);
1965 switch (_UrlImpl::GetInstance(url)->GetType())
1967 case URL_TYPE_PERSONAL:
1968 type = CONTACTS_URL_TYPE_HOME;
1971 type = CONTACTS_URL_TYPE_WORK;
1973 case URL_TYPE_CUSTOM:
1974 type = CONTACTS_URL_TYPE_CUSTOM;
1976 case URL_TYPE_OTHER:
1979 type = CONTACTS_URL_TYPE_OTHER;
1984 contacts_record_set_int(urlHandle, _contacts_url.type, type);
1987 stringValue = _UrlImpl::GetInstance(url)->GetLabel();
1988 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1989 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1991 contacts_record_set_str(urlHandle, _contacts_url.label, pCharArray.get());
1994 stringValue = _UrlImpl::GetInstance(url)->GetUrl();
1995 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1996 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1998 contacts_record_set_str(urlHandle, _contacts_url.url, pCharArray.get());
2000 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.url, urlHandle);
2001 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2003 recordHandle.Release();
2010 _UserProfileImpl::AddAddress(const Address& address)
2013 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));
2017 contacts_record_h addressHandle = null;
2019 int ret = contacts_record_create(_contacts_address._uri, &addressHandle);
2020 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2022 __ContactsRecordHandle recordHandle(addressHandle);
2024 switch (_AddressImpl::GetInstance(address)->GetType())
2026 case ADDRESS_TYPE_HOME:
2027 type = CONTACTS_ADDRESS_TYPE_HOME;
2029 case ADDRESS_TYPE_WORK:
2030 type = CONTACTS_ADDRESS_TYPE_WORK;
2032 case ADDRESS_TYPE_CUSTOM:
2033 type = CONTACTS_ADDRESS_TYPE_CUSTOM;
2035 case ADDRESS_TYPE_OTHER:
2038 type = CONTACTS_ADDRESS_TYPE_OTHER;
2042 contacts_record_set_int(addressHandle, _contacts_address.type, type);
2044 stringValue = _AddressImpl::GetInstance(address)->GetLabel();
2045 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2046 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2048 contacts_record_set_str(addressHandle, _contacts_address.label, pCharArray.get());
2050 stringValue = _AddressImpl::GetInstance(address)->GetCity();
2051 if (!stringValue.IsEmpty())
2053 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2054 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2056 contacts_record_set_str(addressHandle, _contacts_address.locality, pCharArray.get());
2060 stringValue = _AddressImpl::GetInstance(address)->GetCountry();
2061 if (!stringValue.IsEmpty())
2063 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2064 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2066 contacts_record_set_str(addressHandle, _contacts_address.country, pCharArray.get());
2069 stringValue = _AddressImpl::GetInstance(address)->GetExtended();
2070 if (!stringValue.IsEmpty())
2072 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2073 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2075 contacts_record_set_str(addressHandle, _contacts_address.extended, pCharArray.get());
2078 stringValue = _AddressImpl::GetInstance(address)->GetPostalCode();
2079 if (!stringValue.IsEmpty())
2081 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2082 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2084 contacts_record_set_str(addressHandle, _contacts_address.postal_code, pCharArray.get());
2087 stringValue = _AddressImpl::GetInstance(address)->GetPostOfficeBoxNumber();
2088 if (!stringValue.IsEmpty())
2090 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2091 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2093 contacts_record_set_str(addressHandle, _contacts_address.postbox, pCharArray.get());
2096 stringValue = _AddressImpl::GetInstance(address)->GetState();
2097 if (!stringValue.IsEmpty())
2099 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2100 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2102 contacts_record_set_str(addressHandle, _contacts_address.region, pCharArray.get());
2105 stringValue = _AddressImpl::GetInstance(address)->GetStreet();
2106 if (!stringValue.IsEmpty())
2108 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2109 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2111 contacts_record_set_str(addressHandle, _contacts_address.street, pCharArray.get());
2114 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.address, addressHandle);
2115 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2117 recordHandle.Release();
2124 _UserProfileImpl::AddImAddress(const ImAddress& imAddress)
2127 SysTryReturn(NID_SCL, !imAddress.GetImAddress().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%] Invalid argument is used. The imAddress is empty.", GetErrorMessage(E_INVALID_ARG));
2131 contacts_record_h messengerHandle = null;
2133 std::unique_ptr<char[]> pCharArray(null);
2135 int ret = contacts_record_create(_contacts_messenger._uri, &messengerHandle);
2136 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2138 __ContactsRecordHandle recordHandle(messengerHandle);
2140 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetServiceProviderName();
2142 if (stringValue == IM_ADDRESS_GOOGLE_TALK)
2144 type = CONTACTS_MESSENGER_TYPE_GOOGLE;
2146 else if (stringValue == IM_ADDRESS_MSN)
2148 type = CONTACTS_MESSENGER_TYPE_WLM;
2150 else if (stringValue == IM_ADDRESS_ICQ)
2152 type = CONTACTS_MESSENGER_TYPE_ICQ;
2154 else if (stringValue == IM_ADDRESS_AIM)
2156 type = CONTACTS_MESSENGER_TYPE_AIM;
2158 else if (stringValue == IM_ADDRESS_YAHOO)
2160 type = CONTACTS_MESSENGER_TYPE_YAHOO;
2162 else if (stringValue == IM_ADDRESS_QQ)
2164 type = CONTACTS_MESSENGER_TYPE_QQ;
2166 else if (stringValue == IM_ADDRESS_SKYPE)
2168 type = CONTACTS_MESSENGER_TYPE_SKYPE;
2170 else if (stringValue == IM_ADDRESS_JABBER)
2172 type = CONTACTS_MESSENGER_TYPE_JABBER;
2176 type = CONTACTS_MESSENGER_TYPE_CUSTOM;
2179 contacts_record_set_int(messengerHandle, _contacts_messenger.type, type);
2180 if (type == CONTACTS_MESSENGER_TYPE_CUSTOM)
2182 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
2183 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2185 contacts_record_set_str(messengerHandle, _contacts_messenger.label, pCharArray.get());
2188 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetImAddress();
2189 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
2190 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2192 contacts_record_set_str(messengerHandle, _contacts_messenger.im_id, pCharArray.get());
2194 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.messenger, messengerHandle);
2195 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2197 recordHandle.Release();
2203 _UserProfileImpl::AddRelationship(const Relationship& relationship)
2205 SysTryReturn(NID_SCL, !relationship.GetRelativeName().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%] Invalid argument is used. The relationship is empty.", GetErrorMessage(E_INVALID_ARG));
2208 contacts_record_h relationshipHandle = null;
2210 int ret = contacts_record_create(_contacts_relationship._uri, &relationshipHandle);
2211 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2213 __ContactsRecordHandle recordHandle(relationshipHandle);
2215 switch (relationship.GetType())
2217 case CONTACT_RELATIONSHIP_TYPE_ASSISTANT:
2218 intValue = CONTACTS_RELATIONSHIP_TYPE_ASSISTANT;
2220 case CONTACT_RELATIONSHIP_TYPE_BROTHER:
2221 intValue = CONTACTS_RELATIONSHIP_TYPE_BROTHER;
2223 case CONTACT_RELATIONSHIP_TYPE_CHILD:
2224 intValue = CONTACTS_RELATIONSHIP_TYPE_CHILD;
2226 case CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
2227 intValue = CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER;
2229 case CONTACT_RELATIONSHIP_TYPE_FATHER:
2230 intValue = CONTACTS_RELATIONSHIP_TYPE_FATHER;
2232 case CONTACT_RELATIONSHIP_TYPE_FRIEND:
2233 intValue = CONTACTS_RELATIONSHIP_TYPE_FRIEND;
2235 case CONTACT_RELATIONSHIP_TYPE_MANAGER:
2236 intValue = CONTACTS_RELATIONSHIP_TYPE_MANAGER;
2238 case CONTACT_RELATIONSHIP_TYPE_MOTHER:
2239 intValue = CONTACTS_RELATIONSHIP_TYPE_MOTHER;
2241 case CONTACT_RELATIONSHIP_TYPE_PARENT:
2242 intValue = CONTACTS_RELATIONSHIP_TYPE_PARENT;
2244 case CONTACT_RELATIONSHIP_TYPE_PARTNER:
2245 intValue = CONTACTS_RELATIONSHIP_TYPE_PARTNER;
2247 case CONTACT_RELATIONSHIP_TYPE_REFERRED_BY:
2248 intValue = CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY;
2250 case CONTACT_RELATIONSHIP_TYPE_RELATIVE:
2251 intValue = CONTACTS_RELATIONSHIP_TYPE_RELATIVE;
2253 case CONTACT_RELATIONSHIP_TYPE_SISTER:
2254 intValue = CONTACTS_RELATIONSHIP_TYPE_SISTER;
2256 case CONTACT_RELATIONSHIP_TYPE_SPOUSE:
2257 intValue = CONTACTS_RELATIONSHIP_TYPE_SPOUSE;
2259 case CONTACT_RELATIONSHIP_TYPE_CUSTOM:
2260 intValue = CONTACTS_RELATIONSHIP_TYPE_CUSTOM;
2263 intValue = CONTACTS_RELATIONSHIP_TYPE_OTHER;
2268 contacts_record_set_int(relationshipHandle, _contacts_relationship.type, intValue);
2271 String stringValue = relationship.GetLabel();
2272 if (!stringValue.IsEmpty())
2274 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2275 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2277 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, pCharArray.get());
2281 stringValue = relationship.GetRelativeName();
2282 if (!stringValue.IsEmpty())
2284 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2285 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2287 contacts_record_set_str(relationshipHandle, _contacts_relationship.name, pCharArray.get());
2290 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.relationship, relationshipHandle);
2291 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2293 recordHandle.Release();
2301 _UserProfileImpl::AddEvent(const ContactEvent& event)
2307 contacts_record_h eventHandle = null;
2309 int ret = contacts_record_create(_contacts_event._uri, &eventHandle);
2310 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2312 __ContactsRecordHandle recordHandle(eventHandle);
2314 switch (event.GetType())
2316 case CONTACT_EVENT_TYPE_ANNIVERSARY:
2317 type = CONTACTS_EVENT_TYPE_ANNIVERSARY;
2319 case CONTACT_EVENT_TYPE_BIRTHDAY:
2320 type = CONTACTS_EVENT_TYPE_BIRTH;
2322 case CONTACT_EVENT_TYPE_CUSTOM:
2323 type = CONTACTS_EVENT_TYPE_CUSTOM;
2325 case CONTACT_EVENT_TYPE_OTHER:
2328 type = CONTACTS_EVENT_TYPE_OTHER;
2333 contacts_record_set_int(eventHandle, _contacts_event.type, type);
2336 stringValue = event.GetLabel();
2337 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2338 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2340 contacts_record_set_str(eventHandle, _contacts_event.label, pCharArray.get());
2343 DateTime dateValue = event.GetDate();
2344 intValue = dateValue.GetYear()*10000 + dateValue.GetMonth()*100 + dateValue.GetDay();
2345 contacts_record_set_int(eventHandle, _contacts_event.date, intValue);
2347 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.event, eventHandle);
2348 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2350 recordHandle.Release();
2357 _UserProfileImpl::AddOrganization(const Organization& organization)
2359 SysTryReturn(NID_SCL
2360 , !organization.GetName().IsEmpty() ||
2361 !organization.GetJobTitle().IsEmpty() ||
2362 !organization.GetDepartment().IsEmpty() ||
2363 !organization.GetRole().IsEmpty() ||
2364 !organization.GetAgent().IsEmpty() ||
2365 !organization.GetDescription().IsEmpty() ||
2366 !organization.GetLocation().IsEmpty() ||
2367 !organization.GetPhoneticName().IsEmpty() ||
2368 !organization.GetLogoPath().IsEmpty()
2369 ,E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The organization is empty.", GetErrorMessage(E_INVALID_ARG));
2371 contacts_record_h organizationHandle = null;
2373 int ret = contacts_record_create(_contacts_company._uri, &organizationHandle);
2374 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2376 __ContactsRecordHandle recordHandle(organizationHandle);
2379 String stringValue = organization.GetName();
2380 if (!stringValue.IsEmpty())
2382 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2383 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2385 contacts_record_set_str(organizationHandle, _contacts_company.name, pCharArray.get());
2389 stringValue = organization.GetJobTitle();
2390 if (!stringValue.IsEmpty())
2392 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2393 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2395 contacts_record_set_str(organizationHandle, _contacts_company.job_title, pCharArray.get());
2399 stringValue = organization.GetDepartment();
2400 if (!stringValue.IsEmpty())
2402 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2403 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2405 contacts_record_set_str(organizationHandle, _contacts_company.department, pCharArray.get());
2409 stringValue = organization.GetRole();
2410 if (!stringValue.IsEmpty())
2412 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2413 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2415 contacts_record_set_str(organizationHandle, _contacts_company.role, pCharArray.get());
2419 stringValue = organization.GetAgent();
2420 if (!stringValue.IsEmpty())
2422 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2423 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2425 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, pCharArray.get());
2431 switch (organization.GetType())
2433 case ORGANIZATION_TYPE_WORK:
2434 type = CONTACTS_COMPANY_TYPE_WORK;
2436 case ORGANIZATION_TYPE_CUSTOM:
2437 type = CONTACTS_COMPANY_TYPE_CUSTOM;
2439 case ORGANIZATION_TYPE_OTHER:
2442 type = CONTACTS_COMPANY_TYPE_OTHER;
2446 contacts_record_set_int(organizationHandle, _contacts_company.type, type);
2449 stringValue = organization.GetLabel();
2450 if (!stringValue.IsEmpty())
2452 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2453 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2455 contacts_record_set_str(organizationHandle, _contacts_company.label, pCharArray.get());
2459 stringValue = organization.GetDescription();
2460 if (!stringValue.IsEmpty())
2462 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2463 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2465 contacts_record_set_str(organizationHandle, _contacts_company.description, pCharArray.get());
2469 stringValue = organization.GetLocation();
2470 if (!stringValue.IsEmpty())
2472 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2473 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2475 contacts_record_set_str(organizationHandle, _contacts_company.location, pCharArray.get());
2479 stringValue = organization.GetPhoneticName();
2480 if (!stringValue.IsEmpty())
2482 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2483 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2485 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, pCharArray.get());
2489 if (_OrganizationImpl::GetInstance(organization)->IsLogoPathChanged() == true)
2491 stringValue = organization.GetLogoPath();
2492 if (!stringValue.IsEmpty())
2494 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2495 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2497 contacts_record_set_str(organizationHandle, _contacts_company.logo, pCharArray.get());
2501 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.company, organizationHandle);
2502 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2504 recordHandle.Release();
2511 _UserProfileImpl::RemoveAt(UserProfileMultiPropertyId id, int index)
2513 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);
2515 unsigned int count = 0;
2516 contacts_record_h recordHandle = null;
2520 case USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS:
2521 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.number, &count);
2522 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);
2524 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.number, index, &recordHandle);
2525 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.number, recordHandle);
2528 case USER_PROFILE_MPROPERTY_ID_EMAILS:
2529 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.email, &count);
2530 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);
2532 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.email, index, &recordHandle);
2533 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.email, recordHandle);
2536 case USER_PROFILE_MPROPERTY_ID_URLS:
2537 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.url, &count);
2538 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);
2540 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.url, index, &recordHandle);
2541 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.url, recordHandle);
2544 case USER_PROFILE_MPROPERTY_ID_ADDRESSES:
2545 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.address, &count);
2546 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of addresses %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2548 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.address, index, &recordHandle);
2549 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.address, recordHandle);
2552 case USER_PROFILE_MPROPERTY_ID_IMADDRESSES:
2553 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.messenger, &count);
2554 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);
2556 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.messenger, index, &recordHandle);
2557 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.messenger, recordHandle);
2560 case USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS:
2561 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.company, &count);
2562 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of organizations %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2564 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.company, index, &recordHandle);
2565 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.company, recordHandle);
2568 case USER_PROFILE_MPROPERTY_ID_EVENTS:
2569 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.event, &count);
2570 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);
2572 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.event, index, &recordHandle);
2573 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.event, recordHandle);
2576 case USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS:
2577 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.relationship, &count);
2578 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);
2580 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.relationship, index, &recordHandle);
2581 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.relationship, recordHandle);
2584 case USER_PROFILE_MPROPERTY_ID_NOTES:
2585 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.note, &count);
2586 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);
2588 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.note, index, &recordHandle);
2589 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.note, recordHandle);
2592 case USER_PROFILE_MPROPERTY_ID_NICKNAMES:
2593 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.nickname, &count);
2594 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);
2596 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.nickname, index, &recordHandle);
2597 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.nickname, recordHandle);
2601 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
2602 return E_INVALID_ARG;
2610 _UserProfileImpl::GetOrganizationsN(void) const
2612 result r = E_SUCCESS;
2613 contacts_record_h organizationHandle = null;
2614 int ret = CONTACTS_ERROR_NONE;
2615 char* pCharValue = null;
2617 unsigned int count = 0;
2618 std::unique_ptr<Organization> pOrganization(null);
2620 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2621 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2623 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.company, &count);
2625 r = pList->Construct(count);
2626 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2628 for (unsigned int index = 0; index < count; index++)
2630 ret = contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.company, index, &organizationHandle);
2631 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2633 pOrganization.reset(new (std::nothrow) Organization());
2634 SysTryReturn(NID_SCL, pOrganization != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2637 contacts_record_get_str_p(organizationHandle, _contacts_company.name, &pCharValue);
2638 pOrganization->SetName(pCharValue);
2641 contacts_record_get_str_p(organizationHandle, _contacts_company.job_title, &pCharValue);
2642 pOrganization->SetJobTitle(pCharValue);
2645 contacts_record_get_str_p(organizationHandle, _contacts_company.department, &pCharValue);
2646 pOrganization->SetDepartment(pCharValue);
2649 contacts_record_get_str_p(organizationHandle, _contacts_company.role, &pCharValue);
2650 pOrganization->SetRole(pCharValue);
2653 contacts_record_get_str_p(organizationHandle, _contacts_company.assistant_name, &pCharValue);
2654 pOrganization->SetAgent(pCharValue);
2657 contacts_record_get_int(organizationHandle, _contacts_company.type, &intValue);
2660 case CONTACTS_COMPANY_TYPE_WORK:
2661 pOrganization->SetType(ORGANIZATION_TYPE_WORK);
2663 case CONTACTS_COMPANY_TYPE_CUSTOM:
2664 pOrganization->SetType(ORGANIZATION_TYPE_CUSTOM);
2666 case CONTACTS_COMPANY_TYPE_OTHER:
2669 pOrganization->SetType(ORGANIZATION_TYPE_OTHER);
2674 contacts_record_get_str_p(organizationHandle, _contacts_company.label, &pCharValue);
2675 pOrganization->SetLabel(pCharValue);
2678 contacts_record_get_str_p(organizationHandle, _contacts_company.description, &pCharValue);
2679 pOrganization->SetDescription(pCharValue);
2682 contacts_record_get_str_p(organizationHandle, _contacts_company.location, &pCharValue);
2683 pOrganization->SetLocation(pCharValue);
2686 contacts_record_get_str_p(organizationHandle, _contacts_company.phonetic_name, &pCharValue);
2687 pOrganization->SetPhoneticName(pCharValue);
2690 contacts_record_get_str_p(organizationHandle, _contacts_company.logo, &pCharValue);
2691 _OrganizationImpl::GetInstance(*pOrganization)->SetLogoPath(pCharValue);
2693 r = pList->Add(*pOrganization);
2694 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2696 pOrganization.release();
2699 return pList.release();
2704 _UserProfileImpl::GetRelationshipsN(void) const
2707 result r = E_SUCCESS;
2708 contacts_record_h relationshipHandle = null;
2709 int ret = CONTACTS_ERROR_NONE;
2711 char* pCharValue = null;
2712 unsigned int count = 0;
2713 std::unique_ptr<Relationship> pRelationship(null);
2715 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2716 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2718 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.relationship, &count);
2720 r = pList->Construct(count);
2721 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2723 for (unsigned int index = 0; index < count; index++)
2725 ret = contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.relationship, index, &relationshipHandle);
2726 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2728 pRelationship.reset(new (std::nothrow) Relationship());
2729 SysTryReturn(NID_SCL, pRelationship != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2732 contacts_record_get_int(relationshipHandle, _contacts_relationship.type, &intValue);
2735 case CONTACTS_RELATIONSHIP_TYPE_ASSISTANT:
2736 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_ASSISTANT);
2738 case CONTACTS_RELATIONSHIP_TYPE_BROTHER:
2739 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_BROTHER);
2741 case CONTACTS_RELATIONSHIP_TYPE_CHILD:
2742 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_CHILD);
2744 case CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
2745 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER);
2747 case CONTACTS_RELATIONSHIP_TYPE_FATHER:
2748 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_FATHER);
2750 case CONTACTS_RELATIONSHIP_TYPE_FRIEND:
2751 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_FRIEND);
2753 case CONTACTS_RELATIONSHIP_TYPE_MANAGER:
2754 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_MANAGER);
2756 case CONTACTS_RELATIONSHIP_TYPE_MOTHER:
2757 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_MOTHER);
2759 case CONTACTS_RELATIONSHIP_TYPE_PARENT:
2760 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_PARENT);
2762 case CONTACTS_RELATIONSHIP_TYPE_PARTNER:
2763 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_PARTNER);
2765 case CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY:
2766 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_REFERRED_BY);
2768 case CONTACTS_RELATIONSHIP_TYPE_RELATIVE:
2769 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_RELATIVE);
2771 case CONTACTS_RELATIONSHIP_TYPE_SISTER:
2772 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_SISTER);
2774 case CONTACTS_RELATIONSHIP_TYPE_SPOUSE:
2775 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_SPOUSE);
2777 case CONTACTS_RELATIONSHIP_TYPE_CUSTOM:
2780 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_CUSTOM);
2785 contacts_record_get_str_p(relationshipHandle, _contacts_relationship.label, &pCharValue);
2786 pRelationship->SetLabel(pCharValue);
2789 contacts_record_get_str_p(relationshipHandle, _contacts_relationship.name, &pCharValue);
2790 pRelationship->SetRelativeName(pCharValue);
2792 r = pList->Add(*pRelationship);
2793 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2795 pRelationship.release();
2798 return pList.release();
2803 _UserProfileImpl::GetEventsN(void) const
2805 result r = E_SUCCESS;
2806 char* pCharValue = null;
2808 unsigned int count = 0;
2809 contacts_record_h eventHandle = null;
2810 std::unique_ptr<ContactEvent> pEvent(null);
2812 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2813 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2815 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.event, &count);
2817 r = pList->Construct(count);
2818 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2820 for (unsigned int index = 0; index < count; index++)
2822 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.event, index, &eventHandle);
2824 pEvent.reset(new (std::nothrow) ContactEvent());
2825 SysTryReturn(NID_SCL, pEvent != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2828 contacts_record_get_str_p(eventHandle, _contacts_event.label, &pCharValue);
2829 pEvent->SetLabel(pCharValue);
2832 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
2835 case CONTACTS_EVENT_TYPE_BIRTH:
2836 pEvent->SetType(CONTACT_EVENT_TYPE_BIRTHDAY);
2838 case CONTACTS_EVENT_TYPE_ANNIVERSARY:
2839 pEvent->SetType(CONTACT_EVENT_TYPE_ANNIVERSARY);
2841 case CONTACTS_URL_TYPE_CUSTOM:
2842 pEvent->SetType(CONTACT_EVENT_TYPE_CUSTOM);
2845 pEvent->SetType(CONTACT_EVENT_TYPE_OTHER);
2851 contacts_record_get_int(eventHandle, _contacts_event.date, &intValue);
2852 __CONVERT_DATE_TO_DATETIME(intValue, dateTime);
2853 pEvent->SetDate(dateTime);
2855 pList->Add(*pEvent);
2856 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2861 return pList.release();
2866 _UserProfileImpl::GetNotesN(void) const
2868 result r = E_SUCCESS;
2869 char* pCharValue = null;
2870 unsigned int count = 0;
2871 contacts_record_h noteHandle = null;
2872 std::unique_ptr<String> pNote(null);
2874 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2875 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2877 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.note, &count);
2879 r = pList->Construct(count);
2880 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2882 for (unsigned int index = 0; index < count; index++)
2884 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.note, index, ¬eHandle);
2886 contacts_record_get_str_p(noteHandle, _contacts_note.note, &pCharValue);
2888 pNote.reset(new (std::nothrow) String(pCharValue));
2889 SysTryReturn(NID_SCL, pNote != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2892 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2897 return pList.release();
2902 _UserProfileImpl::GetNicknamesN(void) const
2904 result r = E_SUCCESS;
2905 char* pCharValue = null;
2906 unsigned int count = 0;
2907 contacts_record_h nicknameHandle = null;
2908 std::unique_ptr<String> pNickname(null);
2910 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2911 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2913 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.nickname, &count);
2915 r = pList->Construct(count);
2916 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2918 for (unsigned int index = 0; index < count; index++)
2920 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.nickname, index, &nicknameHandle);
2922 contacts_record_get_str_p(nicknameHandle, _contacts_nickname.name, &pCharValue);
2924 pNickname.reset(new (std::nothrow) String(pCharValue));
2925 SysTryReturn(NID_SCL, pNickname != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2927 pList->Add(*pNickname);
2928 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2930 pNickname.release();
2933 return pList.release();
2938 _UserProfileImpl::GetPhoneNumbersN(void) const
2940 result r = E_SUCCESS;
2941 unsigned int count = 0;
2942 contacts_record_h numberHandle = null;
2944 char* pCharValue = null;
2945 PhoneNumberType type = PHONENUMBER_TYPE_HOME;
2946 std::unique_ptr<PhoneNumber> pPhoneNumber(null);
2948 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2949 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2952 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.number, &count);
2954 contacts_record_get_int(__profileHandle, _contacts_my_profile.id, &intValue);
2956 r = pList->Construct(count);
2957 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2959 for (unsigned int index = 0; index < count; index++)
2961 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.number, index, &numberHandle);
2963 pPhoneNumber.reset(new (std::nothrow) PhoneNumber());
2964 SysTryReturn(NID_SCL, pPhoneNumber != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2966 contacts_record_get_int(numberHandle, _contacts_number.id, &intValue);
2967 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetRecordId(intValue);
2969 contacts_record_get_str_p(numberHandle, _contacts_number.label, &pCharValue);
2970 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetLabel(pCharValue);
2972 contacts_record_get_int(numberHandle, _contacts_number.type, &intValue);
2976 case CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE:
2977 type = PHONENUMBER_TYPE_HOME;
2979 case CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE:
2980 type = PHONENUMBER_TYPE_WORK;
2982 case CONTACTS_NUMBER_TYPE_CELL:
2983 type = PHONENUMBER_TYPE_MOBILE;
2985 case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME:
2986 type = PHONENUMBER_TYPE_HOME_FAX;
2988 case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK:
2989 type = PHONENUMBER_TYPE_WORK_FAX;
2991 case CONTACTS_NUMBER_TYPE_PAGER:
2992 type = PHONENUMBER_TYPE_PAGER;
2994 case CONTACTS_NUMBER_TYPE_CUSTOM:
2995 type = PHONENUMBER_TYPE_CUSTOM;
2997 case CONTACTS_NUMBER_TYPE_ASSISTANT:
2998 type = PHONENUMBER_TYPE_ASSISTANT;
3001 if (intValue & CONTACTS_NUMBER_TYPE_FAX)
3003 type = PHONENUMBER_TYPE_HOME_FAX;
3005 else if (intValue & CONTACTS_NUMBER_TYPE_CELL)
3007 type = PHONENUMBER_TYPE_MOBILE;
3009 else if (intValue & CONTACTS_NUMBER_TYPE_PAGER)
3011 type = PHONENUMBER_TYPE_PAGER;
3013 else if (intValue & CONTACTS_NUMBER_TYPE_HOME)
3015 type = PHONENUMBER_TYPE_HOME;
3017 else if (intValue & CONTACTS_NUMBER_TYPE_WORK)
3019 type = PHONENUMBER_TYPE_WORK;
3021 else if (intValue & CONTACTS_NUMBER_TYPE_VOICE)
3023 type = PHONENUMBER_TYPE_HOME;
3027 type = PHONENUMBER_TYPE_OTHER;
3032 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetType(type);
3034 contacts_record_get_str_p(numberHandle, _contacts_number.number, &pCharValue);
3035 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetPhoneNumber(pCharValue);
3037 r = pList->Add(*pPhoneNumber);
3038 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3040 pPhoneNumber.release();
3043 return pList.release();
3048 _UserProfileImpl::GetEmailsN(void) const
3050 result r = E_SUCCESS;
3051 contacts_record_h currentHandle = null;
3052 int ret = CONTACTS_ERROR_NONE;
3054 unsigned int count = 0;
3055 char* pCharValue = null;
3056 EmailType type = EMAIL_TYPE_PERSONAL;
3057 std::unique_ptr<Email> pEmail(null);
3059 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3060 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3062 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.email, &count);
3064 r = pList->Construct(count);
3065 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3067 for (unsigned int index = 0; index < count; index++)
3069 ret = contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.email, index, ¤tHandle);
3070 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM))
3072 pEmail.reset(new (std::nothrow) Email());
3073 SysTryReturn(NID_SCL, pEmail != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3075 contacts_record_get_int(currentHandle, _contacts_email.id, &intValue);
3076 _EmailImpl::GetInstance(*pEmail)->SetRecordId(intValue);
3078 contacts_record_get_str_p(currentHandle, _contacts_email.label, &pCharValue);
3079 _EmailImpl::GetInstance(*pEmail)->SetLabel(pCharValue);
3081 contacts_record_get_int(currentHandle, _contacts_email.type, &intValue);
3084 case CONTACTS_EMAIL_TYPE_HOME:
3085 type = EMAIL_TYPE_PERSONAL;
3087 case CONTACTS_EMAIL_TYPE_WORK:
3088 type = EMAIL_TYPE_WORK;
3090 case CONTACTS_EMAIL_TYPE_CUSTOM:
3091 type = EMAIL_TYPE_CUSTOM;
3093 case CONTACTS_EMAIL_TYPE_MOBILE:
3094 type = EMAIL_TYPE_MOBILE;
3097 type = EMAIL_TYPE_OTHER;
3101 _EmailImpl::GetInstance(*pEmail)->SetType(type);
3103 contacts_record_get_str_p(currentHandle, _contacts_email.email, &pCharValue);
3104 _EmailImpl::GetInstance(*pEmail)->SetEmail(pCharValue);
3106 r = pList->Add(*pEmail);
3107 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3112 return pList.release();
3117 _UserProfileImpl::GetUrlsN(void) const
3120 result r = E_SUCCESS;
3121 char* pCharValue = null;
3123 unsigned int count = 0;
3124 UrlType type = URL_TYPE_PERSONAL;
3125 contacts_record_h urlHandle = null;
3126 std::unique_ptr<Url> pUrl(null);
3128 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3129 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3131 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.url, &count);
3133 r = pList->Construct(count);
3134 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3136 for (unsigned int index = 0; index < count; index++)
3138 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.url, index, &urlHandle);
3140 pUrl.reset(new (std::nothrow) Url());
3141 SysTryReturn(NID_SCL, pUrl != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3143 contacts_record_get_str_p(urlHandle, _contacts_url.label, &pCharValue);
3144 pUrl->SetLabel(pCharValue);
3146 contacts_record_get_int(urlHandle, _contacts_url.type, &intValue);
3149 case CONTACTS_URL_TYPE_HOME:
3150 type = URL_TYPE_PERSONAL;
3152 case CONTACTS_URL_TYPE_WORK:
3153 type = URL_TYPE_WORK;
3155 case CONTACTS_URL_TYPE_CUSTOM:
3156 type = URL_TYPE_CUSTOM;
3159 type = URL_TYPE_OTHER;
3163 pUrl->SetType(type);
3165 contacts_record_get_str_p(urlHandle, _contacts_url.url, &pCharValue);
3166 _UrlImpl::GetInstance(*pUrl)->SetUrl(pCharValue);
3169 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3174 return pList.release();
3179 _UserProfileImpl::GetAddressesN(void) const
3181 result r = E_SUCCESS;
3182 char* pCharValue = null;
3184 unsigned int count = 0;
3185 contacts_record_h addressHandle = 0;
3186 std::unique_ptr<Address> pAddress(null);
3188 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3189 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3191 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.address, &count);
3193 r = pList->Construct(count);
3194 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3197 for (unsigned int index = 0; index < count; index++)
3199 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.address, index, &addressHandle);
3201 pAddress.reset(new (std::nothrow) Address());
3202 SysTryReturn(NID_SCL, pAddress != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3204 contacts_record_get_str_p(addressHandle, _contacts_address.label, &pCharValue);
3205 pAddress->SetLabel(pCharValue);
3207 contacts_record_get_int(addressHandle, _contacts_address.type, &intValue);
3210 case CONTACTS_ADDRESS_TYPE_HOME:
3211 pAddress->SetType(ADDRESS_TYPE_HOME);
3213 case CONTACTS_ADDRESS_TYPE_WORK:
3214 pAddress->SetType(ADDRESS_TYPE_WORK);
3216 case CONTACTS_ADDRESS_TYPE_CUSTOM:
3217 pAddress->SetType(ADDRESS_TYPE_CUSTOM);
3220 pAddress->SetType(ADDRESS_TYPE_OTHER);
3225 contacts_record_get_str_p(addressHandle, _contacts_address.country, &pCharValue);
3226 _AddressImpl::GetInstance(*pAddress)->SetCountry(pCharValue);
3229 contacts_record_get_str_p(addressHandle, _contacts_address.region, &pCharValue);
3230 _AddressImpl::GetInstance(*pAddress)->SetState(pCharValue);
3233 contacts_record_get_str_p(addressHandle, _contacts_address.locality, &pCharValue);
3234 _AddressImpl::GetInstance(*pAddress)->SetCity(pCharValue);
3237 contacts_record_get_str_p(addressHandle, _contacts_address.street, &pCharValue);
3238 _AddressImpl::GetInstance(*pAddress)->SetStreet(pCharValue);
3241 contacts_record_get_str_p(addressHandle, _contacts_address.extended, &pCharValue);
3242 _AddressImpl::GetInstance(*pAddress)->SetExtended(pCharValue);
3245 contacts_record_get_str_p(addressHandle, _contacts_address.postbox, &pCharValue);
3246 _AddressImpl::GetInstance(*pAddress)->SetPostOfficeBoxNumber(pCharValue);
3249 contacts_record_get_str_p(addressHandle, _contacts_address.postal_code, &pCharValue);
3250 _AddressImpl::GetInstance(*pAddress)->SetPostalCode(pCharValue);
3252 r = pList->Add(*pAddress);
3253 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3258 return pList.release();
3263 _UserProfileImpl::GetImAddressesN(void) const
3265 result r = E_SUCCESS;
3266 char* pCharValue = null;
3268 contacts_record_h messengerHandle = null;
3269 unsigned int count = 0;
3270 std::unique_ptr<ImAddress> pImAddress(null);
3272 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3273 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3275 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.messenger, &count);
3277 r = pList->Construct(count);
3278 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3280 for (unsigned int index = 0; index < count; index++)
3282 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.messenger, index, &messengerHandle);
3284 pImAddress.reset(new (std::nothrow) ImAddress());
3285 SysTryReturn(NID_SCL, pImAddress != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3287 contacts_record_get_int(messengerHandle, _contacts_messenger.type, &intValue);
3290 case CONTACTS_MESSENGER_TYPE_GOOGLE:
3291 pImAddress->SetServiceProviderName(IM_ADDRESS_GOOGLE_TALK);
3293 case CONTACTS_MESSENGER_TYPE_WLM:
3294 pImAddress->SetServiceProviderName(IM_ADDRESS_MSN);
3296 case CONTACTS_MESSENGER_TYPE_ICQ:
3297 pImAddress->SetServiceProviderName(IM_ADDRESS_ICQ);
3299 case CONTACTS_MESSENGER_TYPE_AIM:
3300 pImAddress->SetServiceProviderName(IM_ADDRESS_AIM);
3302 case CONTACTS_MESSENGER_TYPE_YAHOO:
3303 pImAddress->SetServiceProviderName(IM_ADDRESS_YAHOO);
3305 case CONTACTS_MESSENGER_TYPE_QQ:
3306 pImAddress->SetServiceProviderName(IM_ADDRESS_QQ);
3308 case CONTACTS_MESSENGER_TYPE_SKYPE:
3309 pImAddress->SetServiceProviderName(IM_ADDRESS_SKYPE);
3311 case CONTACTS_MESSENGER_TYPE_JABBER:
3312 pImAddress->SetServiceProviderName(IM_ADDRESS_JABBER);
3314 case CONTACTS_MESSENGER_TYPE_CUSTOM:
3317 contacts_record_get_str_p(messengerHandle, _contacts_messenger.label, &pCharValue);
3318 pImAddress->SetServiceProviderName(pCharValue);
3322 contacts_record_get_str_p(messengerHandle, _contacts_messenger.im_id, &pCharValue);
3323 _ImAddressImpl::GetInstance(*pImAddress)->SetImAddress(pCharValue);
3325 r = pList->Add(*pImAddress);
3326 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3328 pImAddress.release();
3331 return pList.release();
3337 _UserProfileImpl::IsEmptyCompany(contacts_record_h companyHandle)
3339 char* pCharValue = null;
3341 contacts_record_get_str_p(companyHandle, _contacts_company.name, &pCharValue);
3342 if (pCharValue != null)
3347 contacts_record_get_str_p(companyHandle, _contacts_company.job_title, &pCharValue);
3348 if (pCharValue != null)
3354 contacts_record_get_str_p(companyHandle, _contacts_company.department, &pCharValue);
3355 if (pCharValue != null)
3360 contacts_record_get_str_p(companyHandle, _contacts_company.role, &pCharValue);
3361 if (pCharValue != null)
3366 contacts_record_get_str_p(companyHandle, _contacts_company.assistant_name, &pCharValue);
3367 if (pCharValue != null)
3376 _UserProfileImpl::IsEmptyName(contacts_record_h nameHandle)
3378 char* pCharValue = null;
3380 contacts_record_get_str_p(nameHandle, _contacts_name.first, &pCharValue);
3381 if (pCharValue != null)
3386 contacts_record_get_str_p(nameHandle, _contacts_name.last, &pCharValue);
3387 if (pCharValue != null)
3392 contacts_record_get_str_p(nameHandle, _contacts_name.addition, &pCharValue);
3393 if (pCharValue != null)
3398 contacts_record_get_str_p(nameHandle, _contacts_name.prefix, &pCharValue);
3399 if (pCharValue != null)
3404 contacts_record_get_str_p(nameHandle, _contacts_name.suffix, &pCharValue);
3405 if (pCharValue != null)
3415 _UserProfileImpl::IsEmpty(void) const
3417 unsigned int count = 0;
3419 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.number, &count);
3425 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.email, &count);
3431 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.url, &count);
3437 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.address, &count);
3443 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.messenger, &count);
3449 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
3455 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.company, &count);
3461 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.event, &count);
3467 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.note, &count);
3473 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.nickname, &count);
3479 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.image, &count);
3490 _UserProfileImpl::SetUserProfileHandle(contacts_record_h profileHandle)
3492 contacts_record_destroy(__profileHandle, true);
3494 __profileHandle = profileHandle;
3498 _UserProfileImpl::GetUserProfileHandle(void) const
3500 return __profileHandle;
3503 const _UserProfileImpl*
3504 _UserProfileImpl::GetInstance(const UserProfile& userProfile)
3506 return userProfile.__pUserProfileImpl;
3510 _UserProfileImpl::GetInstance(UserProfile& userProfile)
3512 return userProfile.__pUserProfileImpl;