2 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 * @file FScl_UserProfileImpl.cpp
18 * @brief This is the implementation for _UserProfileImpl class.
20 * This file contains definitions of _UserProfileImpl class.
22 #include <FBaseString.h>
23 #include <FBaseColArrayList.h>
24 #include <FBaseSysLog.h>
26 #include <FMediaImage.h>
27 #include <FSclAddress.h>
28 #include <FSclPhoneNumber.h>
29 #include <FSclEmail.h>
31 #include <FSclImAddress.h>
32 #include <FSclOrganization.h>
33 #include <FSclContactEvent.h>
34 #include <FSclRelationship.h>
35 #include <FSclContact.h>
36 #include <FSclUserProfile.h>
37 #include <FBase_StringConverter.h>
38 #include "FScl_ContactDbConnector.h"
39 #include "FScl_PhoneNumberImpl.h"
40 #include "FScl_AddressbookUtil.h"
41 #include "FScl_UrlImpl.h"
42 #include "FScl_EmailImpl.h"
43 #include "FScl_AddressImpl.h"
44 #include "FScl_ImAddressImpl.h"
45 #include "FScl_UserProfileImpl.h"
46 #include "FScl_OrganizationImpl.h"
48 using namespace Tizen::Base;
49 using namespace Tizen::Base::Collection;
50 using namespace Tizen::Graphics;
51 using namespace Tizen::Media;
52 using namespace Tizen::Io;
54 namespace Tizen { namespace Social
57 const int __CONTACT_MOD_YEAR = 10000;
58 const int __CONTACT_MOD_MONTH = 100;
60 #define __CONVERT_DATE_TO_DATETIME(date, dateTime) \
67 year = temp/__CONTACT_MOD_YEAR; \
68 temp -= year*__CONTACT_MOD_YEAR; \
69 month = temp/__CONTACT_MOD_MONTH; \
70 day = temp - month*__CONTACT_MOD_MONTH; \
71 dateTime.SetValue(year, month, day, 0, 0, 0); \
74 _UserProfileImpl::_UserProfileImpl(void)
75 : __profileHandle(null)
77 contacts_record_h profileHandle = null;
79 _AddressbookUtil::InitContactViews();
81 int ret = contacts_record_create(_contacts_my_profile._uri, &profileHandle);
82 SysTryReturnVoidResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
84 __profileHandle = profileHandle;
87 _UserProfileImpl::_UserProfileImpl(const _UserProfileImpl& rhs)
88 : __profileHandle(null)
90 contacts_record_h profileHandle = null;
92 _AddressbookUtil::InitContactViews();
94 int ret = contacts_record_clone(rhs.__profileHandle, &profileHandle);
95 SysTryReturnVoidResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
97 __profileHandle = profileHandle;
100 _UserProfileImpl::~_UserProfileImpl(void)
102 if (__profileHandle != null)
104 contacts_record_destroy(__profileHandle, true);
109 _UserProfileImpl::operator =(const _UserProfileImpl& rhs)
116 contacts_record_h profileHandle = null;
118 int ret = contacts_record_clone(rhs.__profileHandle, &profileHandle);
119 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
121 contacts_record_destroy(__profileHandle, true);
122 __profileHandle = profileHandle;
124 //__isRemoved = rhs.__isRemoved;
130 _UserProfileImpl::Equals(const Object& rhs) const
132 const _UserProfileImpl* pRhs = dynamic_cast<const _UserProfileImpl*>(&rhs);
139 //compare single value properties
140 if (this->GetValue(USER_PROFILE_PROPERTY_ID_FIRST_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_FIRST_NAME))
145 if (this->GetValue(USER_PROFILE_PROPERTY_ID_LAST_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_LAST_NAME))
150 if (this->GetValue(USER_PROFILE_PROPERTY_ID_MIDDLE_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_MIDDLE_NAME))
155 if (this->GetValue(USER_PROFILE_PROPERTY_ID_NAME_PREFIX) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_NAME_PREFIX))
160 if (this->GetValue(USER_PROFILE_PROPERTY_ID_NAME_SUFFIX) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_NAME_SUFFIX))
165 if (this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME))
170 if (this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME))
175 if (this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME))
180 //compare multivalue properties
181 std::unique_ptr<ArrayList, AllElementsDeleter> pCurrentObjectList(null);
182 std::unique_ptr<ArrayList, AllElementsDeleter> pRhsObjectList(null);
184 pCurrentObjectList = std::unique_ptr<ArrayList, AllElementsDeleter> (static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS)));
185 pRhsObjectList = std::unique_ptr<ArrayList, AllElementsDeleter> (static_cast<ArrayList*>(pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS)));
187 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
192 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_EMAILS))));
193 pRhsObjectList.reset((static_cast<ArrayList*>(pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_EMAILS))));
195 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
200 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_URLS))));
201 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_URLS))));
203 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
208 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_ADDRESSES))));
209 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_ADDRESSES))));
211 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
216 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_IMADDRESSES))));
217 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_IMADDRESSES))));
219 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
224 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_EVENTS))));
225 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_EVENTS))));
227 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
232 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS))));
233 pRhsObjectList.reset((static_cast<ArrayList*>(pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS))));
235 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
240 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_NOTES))));
241 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_NOTES))));
243 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
248 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_NICKNAMES))));
249 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_NICKNAMES))));
251 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
256 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS))));
257 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS))));
259 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
268 _UserProfileImpl::GetHashCode(void) const
271 std::unique_ptr<IList, AllElementsDeleter> pMultiPropertyList(null);
273 //calculate single value properties
274 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_FIRST_NAME).GetHashCode();
275 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_LAST_NAME).GetHashCode();
276 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_MIDDLE_NAME).GetHashCode();
277 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_NAME_PREFIX).GetHashCode();
278 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_NAME_SUFFIX).GetHashCode();
279 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME).GetHashCode();
280 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME).GetHashCode();
281 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME).GetHashCode();
282 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetThumbnailPath().GetHashCode();
284 //calculate multi value properties
285 PhoneNumber* pPhoneNumber = null;
286 pMultiPropertyList = std::unique_ptr<IList, AllElementsDeleter> (this->GetValuesN(USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS));
287 std::unique_ptr<IEnumerator> pEnum(pMultiPropertyList->GetEnumeratorN());
288 while (pEnum->MoveNext() == E_SUCCESS)
290 pPhoneNumber = static_cast<PhoneNumber*>(pEnum->GetCurrent());
291 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pPhoneNumber->GetHashCode();
294 Email* pEmail = null;
295 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_EMAILS));
296 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
297 while (pEnum->MoveNext() == E_SUCCESS)
299 pEmail = static_cast<Email*>(pEnum->GetCurrent());
300 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pEmail->GetHashCode();
304 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_URLS));
305 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
306 while (pEnum->MoveNext() == E_SUCCESS)
308 pUrl = static_cast<Url*>(pEnum->GetCurrent());
309 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pUrl->GetHashCode();
312 Address* pAddress = null;
313 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_ADDRESSES));
314 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
315 while (pEnum->MoveNext() == E_SUCCESS)
317 pAddress = static_cast<Address*>(pEnum->GetCurrent());
318 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pAddress->GetHashCode();
321 ImAddress* pImAddress = null;
322 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_IMADDRESSES));
323 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
324 while (pEnum->MoveNext() == E_SUCCESS)
326 pImAddress = static_cast<ImAddress*>(pEnum->GetCurrent());
327 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pImAddress->GetHashCode();
330 ContactEvent* pEvent = null;
331 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_EVENTS));
332 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
333 while (pEnum->MoveNext() == E_SUCCESS)
335 pEvent = static_cast<ContactEvent*>(pEnum->GetCurrent());
336 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pEvent->GetHashCode();
339 Organization* pOrganization = null;
340 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS));
341 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
342 while (pEnum->MoveNext() == E_SUCCESS)
344 pOrganization = static_cast<Organization*>(pEnum->GetCurrent());
345 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pOrganization->GetHashCode();
348 String* pNote = null;
349 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_NOTES));
350 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
351 while (pEnum->MoveNext() == E_SUCCESS)
353 pNote = static_cast<String*>(pEnum->GetCurrent());
354 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pNote->GetHashCode();
357 String* pNickname = null;
358 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_NICKNAMES));
359 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
360 while (pEnum->MoveNext() == E_SUCCESS)
362 pNickname = static_cast<String*>(pEnum->GetCurrent());
363 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pNickname->GetHashCode();
366 Relationship* pRelationship = null;
367 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS));
368 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
369 while (pEnum->MoveNext() == E_SUCCESS)
371 pRelationship = static_cast<Relationship*>(pEnum->GetCurrent());
372 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pRelationship->GetHashCode();
379 _UserProfileImpl::GetThumbnailPath(void) const
381 unsigned int count = 0;
383 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.image, &count);
389 char* pCharValue = null;
390 contacts_record_h imageHandle = null;
392 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.image, 0, &imageHandle);
393 contacts_record_get_str_p(imageHandle, _contacts_image.path, &pCharValue);
395 return String(pCharValue);
399 _UserProfileImpl::SetThumbnail(const String& filePath)
401 unsigned int count = 0;
402 contacts_record_h imageHandle = null;
404 bool fileExist = true;
406 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.image, &count);
409 errCode = contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.image, 0, &imageHandle);
410 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
411 "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
413 if (!filePath.IsEmpty())
415 fileExist = File::IsFileExist(filePath);
416 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, E_INVALID_ARG, E_INVALID_ARG,
417 "[%s] Invalid file path.", GetErrorMessage(E_INVALID_ARG));
418 SysTryReturn(NID_SCL, fileExist != false, E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
419 "[%s] The specified file is not found.", GetErrorMessage(E_FILE_NOT_FOUND));
421 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(filePath));
422 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
424 errCode = contacts_record_set_str(imageHandle, _contacts_image.path, pCharArray.get());
425 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
426 "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
430 errCode = contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.image, imageHandle);
431 contacts_record_destroy(imageHandle, true);
432 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
433 "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
438 if (!filePath.IsEmpty())
440 fileExist = File::IsFileExist(filePath);
441 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, E_INVALID_ARG, E_INVALID_ARG,
442 "[%s] Invalid file path.", GetErrorMessage(E_INVALID_ARG));
443 SysTryReturn(NID_SCL, fileExist != false, E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
444 "[%s] The specified file is not found.", GetErrorMessage(E_FILE_NOT_FOUND));
446 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(filePath));
447 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
449 errCode = contacts_record_create(_contacts_image._uri, &imageHandle);
450 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
451 "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
453 errCode = contacts_record_set_str(imageHandle, _contacts_image.path, pCharArray.get());
454 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
455 "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
457 errCode = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.image, imageHandle);
458 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
459 "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
468 _UserProfileImpl::SetValue(UserProfilePropertyId id, const String& value)
470 SysTryReturn(NID_SCL, id != USER_PROFILE_PROPERTY_ID_DISPLAY_NAME, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. Display cannot be set using this.", GetErrorMessage(E_INVALID_ARG));
472 int ret = CONTACTS_ERROR_NONE;
473 unsigned int count = 0;
477 case USER_PROFILE_PROPERTY_ID_FIRST_NAME:
479 contacts_record_h nameHandle = null;
480 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
484 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
486 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
487 contacts_record_set_str(nameHandle, _contacts_name.first, pCharArray.get());
489 if (value.IsEmpty() && IsEmptyName(nameHandle))
491 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
492 contacts_record_destroy(nameHandle, true);
497 if (!value.IsEmpty())
499 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
500 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
502 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
503 contacts_record_set_str(nameHandle, _contacts_name.first, pCharArray.get());
505 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
511 case USER_PROFILE_PROPERTY_ID_MIDDLE_NAME:
513 contacts_record_h nameHandle = null;
514 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
518 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
520 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
521 ret = contacts_record_set_str(nameHandle, _contacts_name.addition, pCharArray.get());
523 if (value.IsEmpty() && IsEmptyName(nameHandle))
525 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
526 contacts_record_destroy(nameHandle, true);
531 if (!value.IsEmpty())
533 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
534 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
536 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
537 contacts_record_set_str(nameHandle, _contacts_name.addition, pCharArray.get());
539 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
547 case USER_PROFILE_PROPERTY_ID_LAST_NAME:
549 contacts_record_h nameHandle = null;
550 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
554 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
556 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
557 contacts_record_set_str(nameHandle, _contacts_name.last, pCharArray.get());
559 if (value.IsEmpty() && IsEmptyName(nameHandle))
561 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
562 contacts_record_destroy(nameHandle, true);
567 if (!value.IsEmpty())
569 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
570 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
572 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
573 contacts_record_set_str(nameHandle, _contacts_name.last, pCharArray.get());
575 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
582 case USER_PROFILE_PROPERTY_ID_NAME_SUFFIX:
584 contacts_record_h nameHandle = null;
585 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
589 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
591 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
592 contacts_record_set_str(nameHandle, _contacts_name.suffix, pCharArray.get());
594 if (value.IsEmpty() && IsEmptyName(nameHandle))
596 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
597 contacts_record_destroy(nameHandle, true);
603 if (!value.IsEmpty())
605 contacts_record_create(_contacts_name._uri, &nameHandle);
606 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
608 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
609 contacts_record_set_str(nameHandle, _contacts_name.suffix, pCharArray.get());
611 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
619 case USER_PROFILE_PROPERTY_ID_NAME_PREFIX:
621 contacts_record_h nameHandle = null;
622 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
626 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
628 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
629 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
631 if (value.IsEmpty() && IsEmptyName(nameHandle))
633 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
634 contacts_record_destroy(nameHandle, true);
639 if (!value.IsEmpty())
641 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
642 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
644 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
645 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
647 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
655 case USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME:
657 contacts_record_h nameHandle = null;
658 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
662 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
664 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
665 contacts_record_set_str(nameHandle, _contacts_name.phonetic_first, pCharArray.get());
667 if (value.IsEmpty() && IsEmptyName(nameHandle))
669 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
670 contacts_record_destroy(nameHandle, true);
675 if (!value.IsEmpty())
677 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
678 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
680 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
681 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
683 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
691 case USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME:
693 contacts_record_h nameHandle = null;
694 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
698 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
700 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
701 contacts_record_set_str(nameHandle, _contacts_name.phonetic_last, pCharArray.get());
703 if (value.IsEmpty() && IsEmptyName(nameHandle))
705 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
706 contacts_record_destroy(nameHandle, true);
711 if (!value.IsEmpty())
713 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
714 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
716 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
717 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
719 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
727 case USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
729 contacts_record_h nameHandle = null;
730 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
734 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
736 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
737 contacts_record_set_str(nameHandle, _contacts_name.phonetic_middle, pCharArray.get());
739 if (value.IsEmpty() && IsEmptyName(nameHandle))
741 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
742 contacts_record_destroy(nameHandle, true);
747 if (!value.IsEmpty())
749 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
750 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
752 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
753 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
755 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
764 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
765 return E_INVALID_ARG;
772 _UserProfileImpl::GetValue(UserProfilePropertyId id) const
774 unsigned int count = 0;
775 char* pCharValue = null;
780 case USER_PROFILE_PROPERTY_ID_FIRST_NAME:
782 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
785 contacts_record_h nameHandle = null;
787 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
788 contacts_record_get_str_p(nameHandle, _contacts_name.first, &pCharValue);
794 case USER_PROFILE_PROPERTY_ID_LAST_NAME:
796 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
799 contacts_record_h nameHandle = null;
801 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
802 contacts_record_get_str_p(nameHandle, _contacts_name.last, &pCharValue);
808 case USER_PROFILE_PROPERTY_ID_MIDDLE_NAME:
810 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
813 contacts_record_h nameHandle = null;
815 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
816 contacts_record_get_str_p(nameHandle, _contacts_name.addition, &pCharValue);
822 case USER_PROFILE_PROPERTY_ID_NAME_PREFIX:
824 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
827 contacts_record_h nameHandle = null;
829 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
830 contacts_record_get_str_p(nameHandle, _contacts_name.prefix, &pCharValue);
836 case USER_PROFILE_PROPERTY_ID_NAME_SUFFIX:
838 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
841 contacts_record_h nameHandle = null;
843 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
844 contacts_record_get_str_p(nameHandle, _contacts_name.suffix, &pCharValue);
850 case USER_PROFILE_PROPERTY_ID_DISPLAY_NAME:
851 contacts_record_get_str_p(__profileHandle, _contacts_my_profile.display_name, &pCharValue);
854 case USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME:
856 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
859 contacts_record_h nameHandle = null;
861 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
862 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_first, &pCharValue);
868 case USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME:
870 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
873 contacts_record_h nameHandle = null;
875 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
876 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_last, &pCharValue);
882 case USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
884 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
887 contacts_record_h nameHandle = null;
889 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
890 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_middle, &pCharValue);
898 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d", GetErrorMessage(E_INVALID_ARG), id);
906 _UserProfileImpl::SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber)
908 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);
909 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));
911 unsigned int count = 0;
912 contacts_record_h recordHandle = null;
917 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.number, &count);
918 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);
920 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.number, index, &recordHandle);
922 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetLabel();
924 switch (_PhoneNumberImpl::GetInstance(phoneNumber)->GetType())
926 case PHONENUMBER_TYPE_HOME:
927 type = CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE;
929 case PHONENUMBER_TYPE_WORK:
930 type = CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE;
932 case PHONENUMBER_TYPE_MOBILE:
933 type = CONTACTS_NUMBER_TYPE_CELL;
935 case PHONENUMBER_TYPE_HOME_FAX:
936 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME;
938 case PHONENUMBER_TYPE_WORK_FAX:
939 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK;
941 case PHONENUMBER_TYPE_PAGER:
942 type = CONTACTS_NUMBER_TYPE_PAGER;
944 case PHONENUMBER_TYPE_CUSTOM:
945 type = CONTACTS_NUMBER_TYPE_CUSTOM;
947 case PHONENUMBER_TYPE_ASSISTANT:
948 type = CONTACTS_NUMBER_TYPE_ASSISTANT;
950 case PHONENUMBER_TYPE_OTHER:
951 contacts_record_get_int(recordHandle, _contacts_number.type, &oriType);
953 if (oriType == (CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE)
954 || oriType == (CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE)
955 || oriType == CONTACTS_NUMBER_TYPE_CELL
956 || oriType == (CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME)
957 || oriType == (CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK)
958 || oriType == CONTACTS_NUMBER_TYPE_PAGER
959 || oriType == CONTACTS_NUMBER_TYPE_CUSTOM)
961 type = CONTACTS_NUMBER_TYPE_OTHER;
969 type = CONTACTS_NUMBER_TYPE_OTHER;
974 contacts_record_set_int(recordHandle, _contacts_number.type, type);
977 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
978 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
980 contacts_record_set_str(recordHandle, _contacts_number.label, pCharArray.get());
983 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetPhoneNumber();
984 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
985 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
987 contacts_record_set_str(recordHandle, _contacts_number.number, pCharArray.get());
994 _UserProfileImpl::SetEmailAt(int index, const Email& email)
996 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);
997 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));
999 unsigned int count = 0;
1000 contacts_record_h emailHandle = null;
1004 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.email, &count);
1005 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);
1007 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.email, index, &emailHandle);
1009 stringValue = _EmailImpl::GetInstance(email)->GetLabel();
1011 switch (_EmailImpl::GetInstance(email)->GetType())
1013 case EMAIL_TYPE_PERSONAL:
1014 type = CONTACTS_EMAIL_TYPE_HOME;
1016 case EMAIL_TYPE_WORK:
1017 type = CONTACTS_EMAIL_TYPE_WORK;
1019 case EMAIL_TYPE_CUSTOM:
1020 type = CONTACTS_EMAIL_TYPE_CUSTOM;
1022 case EMAIL_TYPE_MOBILE:
1023 type = CONTACTS_EMAIL_TYPE_MOBILE;
1025 case EMAIL_TYPE_OTHER:
1028 type = CONTACTS_EMAIL_TYPE_OTHER;
1033 contacts_record_set_int(emailHandle, _contacts_email.type, type);
1036 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1037 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1039 contacts_record_set_str(emailHandle, _contacts_email.label, pCharArray.get());
1042 stringValue = _EmailImpl::GetInstance(email)->GetEmail();
1043 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1044 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1046 contacts_record_set_str(emailHandle, _contacts_email.email, pCharArray.get());
1052 _UserProfileImpl::SetUrlAt(int index, const Url& url)
1054 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);
1055 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));
1056 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1058 unsigned int count = 0;
1059 contacts_record_h urlHandle = null;
1063 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.url, &count);
1064 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);
1066 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.url, index, &urlHandle);
1069 stringValue = _UrlImpl::GetInstance(url)->GetLabel();
1071 switch (_UrlImpl::GetInstance(url)->GetType())
1073 case URL_TYPE_PERSONAL:
1074 type = CONTACTS_URL_TYPE_HOME;
1077 type = CONTACTS_URL_TYPE_WORK;
1079 case URL_TYPE_CUSTOM:
1080 type = CONTACTS_URL_TYPE_CUSTOM;
1082 case URL_TYPE_OTHER:
1085 type = CONTACTS_URL_TYPE_OTHER;
1090 contacts_record_set_int(urlHandle, _contacts_url.type, type);
1093 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1094 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1096 contacts_record_set_str(urlHandle, _contacts_url.label, pCharArray.get());
1099 stringValue = _UrlImpl::GetInstance(url)->GetUrl();
1100 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1101 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1103 contacts_record_set_str(urlHandle, _contacts_url.url, pCharArray.get());
1110 _UserProfileImpl::SetAddressAt(int index, const Address& address)
1112 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);
1113 SysTryReturn(NID_SCL,
1114 !address.GetCity().IsEmpty() ||
1115 !address.GetCountry().IsEmpty() ||
1116 !address.GetExtended().IsEmpty() ||
1117 !address.GetPostalCode().IsEmpty() ||
1118 !address.GetPostOfficeBoxNumber().IsEmpty() ||
1119 !address.GetState().IsEmpty() ||
1120 !address.GetStreet().IsEmpty(),
1121 E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The address is empty.", GetErrorMessage(E_INVALID_ARG));
1123 unsigned int count = 0;
1124 contacts_record_h addressHandle = null;
1128 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.address, &count);
1129 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);
1131 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.address, index, &addressHandle);
1133 stringValue = _AddressImpl::GetInstance(address)->GetLabel();
1135 switch (_AddressImpl::GetInstance(address)->GetType())
1137 case ADDRESS_TYPE_HOME:
1138 type = CONTACTS_ADDRESS_TYPE_HOME;
1140 case ADDRESS_TYPE_WORK:
1141 type = CONTACTS_ADDRESS_TYPE_WORK;
1143 case ADDRESS_TYPE_CUSTOM:
1144 type = CONTACTS_ADDRESS_TYPE_CUSTOM;
1146 case ADDRESS_TYPE_OTHER:
1149 type = CONTACTS_ADDRESS_TYPE_OTHER;
1154 contacts_record_set_int(addressHandle, _contacts_address.type, type);
1157 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1158 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1160 contacts_record_set_str(addressHandle, _contacts_address.label, pCharArray.get());
1163 stringValue = _AddressImpl::GetInstance(address)->GetCity();
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.locality, pCharArray.get());
1173 contacts_record_set_str(addressHandle, _contacts_address.locality, null);
1176 stringValue = _AddressImpl::GetInstance(address)->GetCountry();
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.country, pCharArray.get());
1186 contacts_record_set_str(addressHandle, _contacts_address.country, null);
1189 stringValue = _AddressImpl::GetInstance(address)->GetExtended();
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.extended, pCharArray.get());
1199 contacts_record_set_str(addressHandle, _contacts_address.extended, null);
1202 stringValue = _AddressImpl::GetInstance(address)->GetPostalCode();
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.postal_code, pCharArray.get());
1212 contacts_record_set_str(addressHandle, _contacts_address.postal_code, null);
1215 stringValue = _AddressImpl::GetInstance(address)->GetPostOfficeBoxNumber();
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.postbox, pCharArray.get());
1225 contacts_record_set_str(addressHandle, _contacts_address.postbox, null);
1228 stringValue = _AddressImpl::GetInstance(address)->GetState();
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.region, pCharArray.get());
1238 contacts_record_set_str(addressHandle, _contacts_address.region, null);
1241 stringValue = _AddressImpl::GetInstance(address)->GetStreet();
1242 if (!stringValue.IsEmpty())
1244 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1245 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1247 contacts_record_set_str(addressHandle, _contacts_address.street, pCharArray.get());
1251 contacts_record_set_str(addressHandle, _contacts_address.street, null);
1258 _UserProfileImpl::SetImAddressAt(int index, const ImAddress& imAddress)
1260 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);
1261 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));
1262 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1264 unsigned int count = 0;
1265 contacts_record_h messengerHandle = null;
1268 std::unique_ptr<char[]> pCharArray(null);
1270 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.messenger, &count);
1271 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);
1273 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.messenger, index, &messengerHandle);
1275 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetServiceProviderName();
1277 if (stringValue == IM_ADDRESS_GOOGLE_TALK)
1279 type = CONTACTS_MESSENGER_TYPE_GOOGLE;
1281 else if (stringValue == IM_ADDRESS_MSN)
1283 type = CONTACTS_MESSENGER_TYPE_WLM;
1285 else if (stringValue == IM_ADDRESS_ICQ)
1287 type = CONTACTS_MESSENGER_TYPE_ICQ;
1289 else if (stringValue == IM_ADDRESS_AIM)
1291 type = CONTACTS_MESSENGER_TYPE_AIM;
1293 else if (stringValue == IM_ADDRESS_YAHOO)
1295 type = CONTACTS_MESSENGER_TYPE_YAHOO;
1297 else if (stringValue == IM_ADDRESS_QQ)
1299 type = CONTACTS_MESSENGER_TYPE_QQ;
1301 else if (stringValue == IM_ADDRESS_SKYPE)
1303 type = CONTACTS_MESSENGER_TYPE_SKYPE;
1305 else if (stringValue == IM_ADDRESS_JABBER)
1307 type = CONTACTS_MESSENGER_TYPE_JABBER;
1309 else if (stringValue == IM_ADDRESS_IRC)
1311 type = CONTACTS_MESSENGER_TYPE_IRC;
1313 else if (stringValue == IM_ADDRESS_FACEBOOK)
1315 type = CONTACTS_MESSENGER_TYPE_FACEBOOK;
1319 type = CONTACTS_MESSENGER_TYPE_CUSTOM;
1322 contacts_record_set_int(messengerHandle, _contacts_messenger.type, type);
1323 if (type == CONTACTS_MESSENGER_TYPE_CUSTOM)
1325 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1326 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1328 contacts_record_set_str(messengerHandle, _contacts_messenger.label, pCharArray.get());
1331 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetImAddress();
1332 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1333 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1335 contacts_record_set_str(messengerHandle, _contacts_messenger.im_id, pCharArray.get());
1342 _UserProfileImpl::SetNoteAt(int index, const String& note)
1344 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);
1345 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));
1346 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1348 unsigned int count = 0;
1349 contacts_record_h noteHandle = null;
1351 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.note, &count);
1352 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);
1354 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.note, index, ¬eHandle);
1356 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(note));
1357 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1359 contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
1365 _UserProfileImpl::SetNicknameAt(int index, const String& nickname)
1367 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);
1368 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));
1369 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1371 unsigned int count = 0;
1372 contacts_record_h nicknameHandle = null;
1374 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.nickname, &count);
1375 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);
1377 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.nickname, index, &nicknameHandle);
1379 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(nickname));
1380 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1382 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
1388 _UserProfileImpl::SetEventAt(int index, const ContactEvent& event)
1390 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);
1391 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1395 unsigned int count = 0;
1397 contacts_record_h eventHandle = null;
1399 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.event, &count);
1400 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);
1402 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.event, index, &eventHandle);
1404 switch (event.GetType())
1406 case CONTACT_EVENT_TYPE_ANNIVERSARY:
1407 type = CONTACTS_EVENT_TYPE_ANNIVERSARY;
1409 case CONTACT_EVENT_TYPE_BIRTHDAY:
1410 type = CONTACTS_EVENT_TYPE_BIRTH;
1412 case CONTACT_EVENT_TYPE_CUSTOM:
1413 type = CONTACTS_EVENT_TYPE_CUSTOM;
1415 case CONTACT_EVENT_TYPE_OTHER:
1418 type = CONTACTS_EVENT_TYPE_OTHER;
1423 contacts_record_set_int(eventHandle, _contacts_event.type, type);
1426 stringValue = event.GetLabel();
1428 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1429 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1431 contacts_record_set_str(eventHandle, _contacts_event.label, pCharArray.get());
1434 DateTime dateValue = event.GetDate();
1435 intValue = dateValue.GetYear()*10000 + dateValue.GetMonth()*100 + dateValue.GetDay();
1436 contacts_record_set_int(eventHandle, _contacts_event.date, intValue);
1443 _UserProfileImpl::SetOrganizationAt(int index, const Organization& organization)
1445 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);
1446 SysTryReturn(NID_SCL
1447 , !organization.GetName().IsEmpty() ||
1448 !organization.GetJobTitle().IsEmpty() ||
1449 !organization.GetDepartment().IsEmpty() ||
1450 !organization.GetRole().IsEmpty() ||
1451 !organization.GetAgent().IsEmpty() ||
1452 !organization.GetLocation().IsEmpty() ||
1453 !organization.GetDescription().IsEmpty() ||
1454 !organization.GetPhoneticName().IsEmpty() ||
1455 !organization.GetLogoPath().IsEmpty()
1456 ,E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The organization is empty.", GetErrorMessage(E_INVALID_ARG));
1458 unsigned int count = 0;
1459 contacts_record_h organizationHandle = null;
1461 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.company, &count);
1462 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);
1465 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.company, index, &organizationHandle);
1468 String stringValue = organization.GetName();
1469 if (!stringValue.IsEmpty())
1471 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1472 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1474 contacts_record_set_str(organizationHandle, _contacts_company.name, pCharArray.get());
1478 contacts_record_set_str(organizationHandle, _contacts_company.name, null);
1482 stringValue = organization.GetJobTitle();
1483 if (!stringValue.IsEmpty())
1485 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1486 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1488 contacts_record_set_str(organizationHandle, _contacts_company.job_title, pCharArray.get());
1492 contacts_record_set_str(organizationHandle, _contacts_company.job_title, null);
1496 stringValue = organization.GetDepartment();
1497 if (!stringValue.IsEmpty())
1499 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1500 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1502 contacts_record_set_str(organizationHandle, _contacts_company.department, pCharArray.get());
1506 contacts_record_set_str(organizationHandle, _contacts_company.department, null);
1510 stringValue = organization.GetRole();
1511 if (!stringValue.IsEmpty())
1513 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1514 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1516 contacts_record_set_str(organizationHandle, _contacts_company.role, pCharArray.get());
1520 contacts_record_set_str(organizationHandle, _contacts_company.role, null);
1524 stringValue = organization.GetAgent();
1525 if (!stringValue.IsEmpty())
1527 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1528 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1530 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, pCharArray.get());
1534 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, null);
1540 switch (organization.GetType())
1542 case ORGANIZATION_TYPE_WORK:
1543 type = CONTACTS_COMPANY_TYPE_WORK;
1545 case ORGANIZATION_TYPE_CUSTOM:
1546 type = CONTACTS_COMPANY_TYPE_CUSTOM;
1548 case ORGANIZATION_TYPE_OTHER:
1551 type = CONTACTS_COMPANY_TYPE_OTHER;
1554 contacts_record_set_int(organizationHandle, _contacts_company.type, type);
1557 stringValue = organization.GetLabel();
1558 if (!stringValue.IsEmpty())
1560 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1561 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1563 contacts_record_set_str(organizationHandle, _contacts_company.label, pCharArray.get());
1567 contacts_record_set_str(organizationHandle, _contacts_company.label, null);
1571 stringValue = organization.GetLocation();
1572 if (!stringValue.IsEmpty())
1574 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1575 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1577 contacts_record_set_str(organizationHandle, _contacts_company.location, pCharArray.get());
1581 contacts_record_set_str(organizationHandle, _contacts_company.location, null);
1585 stringValue = organization.GetDescription();
1586 if (!stringValue.IsEmpty())
1588 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1589 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1591 contacts_record_set_str(organizationHandle, _contacts_company.description, pCharArray.get());
1595 contacts_record_set_str(organizationHandle, _contacts_company.description, null);
1599 stringValue = organization.GetPhoneticName();
1600 if (!stringValue.IsEmpty())
1602 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1603 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1605 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, pCharArray.get());
1609 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, null);
1613 if (_OrganizationImpl::GetInstance(organization)->IsLogoPathChanged() == true)
1615 stringValue = organization.GetLogoPath();
1616 if (!stringValue.IsEmpty())
1618 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1619 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1621 contacts_record_set_str(organizationHandle, _contacts_company.logo, pCharArray.get());
1625 contacts_record_set_str(organizationHandle, _contacts_company.logo, null);
1633 _UserProfileImpl::SetRelationshipAt(int index, const Relationship& relationship)
1635 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);
1636 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));
1637 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1640 unsigned int count = 0;
1641 contacts_record_h relationshipHandle = null;
1643 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.relationship, &count);
1644 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);
1646 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.relationship, index, &relationshipHandle);
1648 switch (relationship.GetType())
1650 case CONTACT_RELATIONSHIP_TYPE_ASSISTANT:
1651 intValue = CONTACTS_RELATIONSHIP_TYPE_ASSISTANT;
1653 case CONTACT_RELATIONSHIP_TYPE_BROTHER:
1654 intValue = CONTACTS_RELATIONSHIP_TYPE_BROTHER;
1656 case CONTACT_RELATIONSHIP_TYPE_CHILD:
1657 intValue = CONTACTS_RELATIONSHIP_TYPE_CHILD;
1659 case CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
1660 intValue = CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER;
1662 case CONTACT_RELATIONSHIP_TYPE_FATHER:
1663 intValue = CONTACTS_RELATIONSHIP_TYPE_FATHER;
1665 case CONTACT_RELATIONSHIP_TYPE_FRIEND:
1666 intValue = CONTACTS_RELATIONSHIP_TYPE_FRIEND;
1668 case CONTACT_RELATIONSHIP_TYPE_MANAGER:
1669 intValue = CONTACTS_RELATIONSHIP_TYPE_MANAGER;
1671 case CONTACT_RELATIONSHIP_TYPE_MOTHER:
1672 intValue = CONTACTS_RELATIONSHIP_TYPE_MOTHER;
1674 case CONTACT_RELATIONSHIP_TYPE_PARENT:
1675 intValue = CONTACTS_RELATIONSHIP_TYPE_PARENT;
1677 case CONTACT_RELATIONSHIP_TYPE_PARTNER:
1678 intValue = CONTACTS_RELATIONSHIP_TYPE_PARTNER;
1680 case CONTACT_RELATIONSHIP_TYPE_REFERRED_BY:
1681 intValue = CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY;
1683 case CONTACT_RELATIONSHIP_TYPE_RELATIVE:
1684 intValue = CONTACTS_RELATIONSHIP_TYPE_RELATIVE;
1686 case CONTACT_RELATIONSHIP_TYPE_SISTER:
1687 intValue = CONTACTS_RELATIONSHIP_TYPE_SISTER;
1689 case CONTACT_RELATIONSHIP_TYPE_SPOUSE:
1690 intValue = CONTACTS_RELATIONSHIP_TYPE_SPOUSE;
1692 case CONTACT_RELATIONSHIP_TYPE_CUSTOM:
1693 intValue = CONTACTS_RELATIONSHIP_TYPE_CUSTOM;
1696 intValue = CONTACTS_RELATIONSHIP_TYPE_OTHER;
1701 contacts_record_set_int(relationshipHandle, _contacts_relationship.type, intValue);
1704 String stringValue = relationship.GetLabel();
1705 if (!stringValue.IsEmpty())
1707 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1708 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1710 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, pCharArray.get());
1714 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, null);
1718 stringValue = relationship.GetRelativeName();
1719 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1720 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1722 contacts_record_set_str(relationshipHandle, _contacts_relationship.name, pCharArray.get());
1728 _UserProfileImpl::GetAddressbookId(void) const
1730 int addressbookId = 0;
1732 contacts_record_get_int(__profileHandle, _contacts_my_profile.address_book_id, &addressbookId);
1734 return addressbookId;
1738 _UserProfileImpl::GetValuesN(const UserProfileMultiPropertyId id) const
1740 IList* pList = null;
1746 case USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS:
1747 pList = GetPhoneNumbersN();
1750 case USER_PROFILE_MPROPERTY_ID_EMAILS:
1751 pList = GetEmailsN();
1754 case USER_PROFILE_MPROPERTY_ID_URLS:
1758 case USER_PROFILE_MPROPERTY_ID_ADDRESSES:
1759 pList = GetAddressesN();
1762 case USER_PROFILE_MPROPERTY_ID_IMADDRESSES:
1763 pList = GetImAddressesN();
1766 case USER_PROFILE_MPROPERTY_ID_EVENTS:
1767 pList = GetEventsN();
1770 case USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS:
1771 pList = GetOrganizationsN();
1774 case USER_PROFILE_MPROPERTY_ID_NOTES:
1775 pList = GetNotesN();
1778 case CONTACT_MPROPERTY_ID_NICKNAMES:
1779 pList = GetNicknamesN();
1782 case USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS:
1783 pList = GetRelationshipsN();
1788 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
1792 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1799 _UserProfileImpl::AddPhoneNumber(const PhoneNumber& phoneNumber)
1801 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));
1805 contacts_record_h numberHandle = null;
1807 int ret = contacts_record_create(_contacts_number._uri, &numberHandle);
1808 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1810 __ContactsRecordHandle recordHandle(numberHandle);
1812 switch (_PhoneNumberImpl::GetInstance(phoneNumber)->GetType())
1814 case PHONENUMBER_TYPE_HOME:
1815 type = CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE;
1817 case PHONENUMBER_TYPE_WORK:
1818 type = CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE;
1820 case PHONENUMBER_TYPE_MOBILE:
1821 type = CONTACTS_NUMBER_TYPE_CELL;
1823 case PHONENUMBER_TYPE_HOME_FAX:
1824 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME;
1826 case PHONENUMBER_TYPE_WORK_FAX:
1827 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK;
1829 case PHONENUMBER_TYPE_PAGER:
1830 type = CONTACTS_NUMBER_TYPE_PAGER;
1832 case PHONENUMBER_TYPE_CUSTOM:
1833 type = CONTACTS_NUMBER_TYPE_CUSTOM;
1835 case PHONENUMBER_TYPE_ASSISTANT:
1836 type = CONTACTS_NUMBER_TYPE_ASSISTANT;
1838 case PHONENUMBER_TYPE_OTHER:
1840 type = CONTACTS_NUMBER_TYPE_OTHER;
1844 contacts_record_set_int(numberHandle, _contacts_number.type, type);
1846 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetLabel();
1848 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1849 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1851 contacts_record_set_str(numberHandle, _contacts_number.label, pCharArray.get());
1853 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetPhoneNumber();
1854 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1855 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1857 contacts_record_set_str(numberHandle, _contacts_number.number, pCharArray.get());
1859 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.number, numberHandle);
1860 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1862 recordHandle.Release();
1869 _UserProfileImpl::AddNickname(const String& nickname)
1872 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));
1874 contacts_record_h nicknameHandle = null;
1876 int ret = contacts_record_create(_contacts_nickname._uri, &nicknameHandle);
1877 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1879 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(nickname));
1880 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1882 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
1884 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.nickname, nicknameHandle);
1885 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1892 _UserProfileImpl::AddNote(const String& note)
1894 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));
1896 contacts_record_h noteHandle = null;
1898 int ret = contacts_record_create(_contacts_note._uri, ¬eHandle);
1899 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1901 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(note));
1902 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1904 contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
1906 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.note, noteHandle);
1907 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1914 _UserProfileImpl::AddEmail(const Email& email)
1917 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));
1921 contacts_record_h emailHandle = null;
1923 int ret = contacts_record_create(_contacts_email._uri, &emailHandle);
1924 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1926 __ContactsRecordHandle recordHandle(emailHandle);
1928 switch (_EmailImpl::GetInstance(email)->GetType())
1930 case EMAIL_TYPE_PERSONAL:
1931 type = CONTACTS_EMAIL_TYPE_HOME;
1933 case EMAIL_TYPE_WORK:
1934 type = CONTACTS_EMAIL_TYPE_WORK;
1936 case EMAIL_TYPE_CUSTOM:
1937 type = CONTACTS_EMAIL_TYPE_CUSTOM;
1939 case EMAIL_TYPE_MOBILE:
1940 type = CONTACTS_EMAIL_TYPE_MOBILE;
1942 case EMAIL_TYPE_OTHER:
1945 type = CONTACTS_EMAIL_TYPE_OTHER;
1949 contacts_record_set_int(emailHandle, _contacts_email.type, type);
1951 stringValue = _EmailImpl::GetInstance(email)->GetLabel();
1952 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1953 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1955 contacts_record_set_str(emailHandle, _contacts_email.label, pCharArray.get());
1957 stringValue = _EmailImpl::GetInstance(email)->GetEmail();
1958 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1959 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1961 contacts_record_set_str(emailHandle, _contacts_email.email, pCharArray.get());
1963 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.email, emailHandle);
1964 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1966 recordHandle.Release();
1973 _UserProfileImpl::AddUrl(const Url& url)
1975 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));
1979 contacts_record_h urlHandle = null;
1981 int ret = contacts_record_create(_contacts_url._uri, &urlHandle);
1982 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1984 __ContactsRecordHandle recordHandle(urlHandle);
1986 switch (_UrlImpl::GetInstance(url)->GetType())
1988 case URL_TYPE_PERSONAL:
1989 type = CONTACTS_URL_TYPE_HOME;
1992 type = CONTACTS_URL_TYPE_WORK;
1994 case URL_TYPE_CUSTOM:
1995 type = CONTACTS_URL_TYPE_CUSTOM;
1997 case URL_TYPE_OTHER:
2000 type = CONTACTS_URL_TYPE_OTHER;
2005 contacts_record_set_int(urlHandle, _contacts_url.type, type);
2008 stringValue = _UrlImpl::GetInstance(url)->GetLabel();
2009 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2010 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2012 contacts_record_set_str(urlHandle, _contacts_url.label, pCharArray.get());
2015 stringValue = _UrlImpl::GetInstance(url)->GetUrl();
2016 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
2017 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2019 contacts_record_set_str(urlHandle, _contacts_url.url, pCharArray.get());
2021 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.url, urlHandle);
2022 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2024 recordHandle.Release();
2031 _UserProfileImpl::AddAddress(const Address& address)
2034 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));
2038 contacts_record_h addressHandle = null;
2040 int ret = contacts_record_create(_contacts_address._uri, &addressHandle);
2041 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2043 __ContactsRecordHandle recordHandle(addressHandle);
2045 switch (_AddressImpl::GetInstance(address)->GetType())
2047 case ADDRESS_TYPE_HOME:
2048 type = CONTACTS_ADDRESS_TYPE_HOME;
2050 case ADDRESS_TYPE_WORK:
2051 type = CONTACTS_ADDRESS_TYPE_WORK;
2053 case ADDRESS_TYPE_CUSTOM:
2054 type = CONTACTS_ADDRESS_TYPE_CUSTOM;
2056 case ADDRESS_TYPE_OTHER:
2059 type = CONTACTS_ADDRESS_TYPE_OTHER;
2063 contacts_record_set_int(addressHandle, _contacts_address.type, type);
2065 stringValue = _AddressImpl::GetInstance(address)->GetLabel();
2066 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2067 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2069 contacts_record_set_str(addressHandle, _contacts_address.label, pCharArray.get());
2071 stringValue = _AddressImpl::GetInstance(address)->GetCity();
2072 if (!stringValue.IsEmpty())
2074 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2075 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2077 contacts_record_set_str(addressHandle, _contacts_address.locality, pCharArray.get());
2081 stringValue = _AddressImpl::GetInstance(address)->GetCountry();
2082 if (!stringValue.IsEmpty())
2084 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2085 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2087 contacts_record_set_str(addressHandle, _contacts_address.country, pCharArray.get());
2090 stringValue = _AddressImpl::GetInstance(address)->GetExtended();
2091 if (!stringValue.IsEmpty())
2093 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2094 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2096 contacts_record_set_str(addressHandle, _contacts_address.extended, pCharArray.get());
2099 stringValue = _AddressImpl::GetInstance(address)->GetPostalCode();
2100 if (!stringValue.IsEmpty())
2102 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2103 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2105 contacts_record_set_str(addressHandle, _contacts_address.postal_code, pCharArray.get());
2108 stringValue = _AddressImpl::GetInstance(address)->GetPostOfficeBoxNumber();
2109 if (!stringValue.IsEmpty())
2111 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2112 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2114 contacts_record_set_str(addressHandle, _contacts_address.postbox, pCharArray.get());
2117 stringValue = _AddressImpl::GetInstance(address)->GetState();
2118 if (!stringValue.IsEmpty())
2120 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2121 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2123 contacts_record_set_str(addressHandle, _contacts_address.region, pCharArray.get());
2126 stringValue = _AddressImpl::GetInstance(address)->GetStreet();
2127 if (!stringValue.IsEmpty())
2129 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2130 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2132 contacts_record_set_str(addressHandle, _contacts_address.street, pCharArray.get());
2135 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.address, addressHandle);
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 recordHandle.Release();
2145 _UserProfileImpl::AddImAddress(const ImAddress& imAddress)
2148 SysTryReturn(NID_SCL, !imAddress.GetImAddress().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%] Invalid argument is used. The imAddress is empty.", GetErrorMessage(E_INVALID_ARG));
2152 contacts_record_h messengerHandle = null;
2154 std::unique_ptr<char[]> pCharArray(null);
2156 int ret = contacts_record_create(_contacts_messenger._uri, &messengerHandle);
2157 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2159 __ContactsRecordHandle recordHandle(messengerHandle);
2161 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetServiceProviderName();
2163 if (stringValue == IM_ADDRESS_GOOGLE_TALK)
2165 type = CONTACTS_MESSENGER_TYPE_GOOGLE;
2167 else if (stringValue == IM_ADDRESS_MSN)
2169 type = CONTACTS_MESSENGER_TYPE_WLM;
2171 else if (stringValue == IM_ADDRESS_ICQ)
2173 type = CONTACTS_MESSENGER_TYPE_ICQ;
2175 else if (stringValue == IM_ADDRESS_AIM)
2177 type = CONTACTS_MESSENGER_TYPE_AIM;
2179 else if (stringValue == IM_ADDRESS_YAHOO)
2181 type = CONTACTS_MESSENGER_TYPE_YAHOO;
2183 else if (stringValue == IM_ADDRESS_QQ)
2185 type = CONTACTS_MESSENGER_TYPE_QQ;
2187 else if (stringValue == IM_ADDRESS_SKYPE)
2189 type = CONTACTS_MESSENGER_TYPE_SKYPE;
2191 else if (stringValue == IM_ADDRESS_JABBER)
2193 type = CONTACTS_MESSENGER_TYPE_JABBER;
2195 else if (stringValue == IM_ADDRESS_IRC)
2197 type = CONTACTS_MESSENGER_TYPE_IRC;
2199 else if (stringValue == IM_ADDRESS_FACEBOOK)
2201 type = CONTACTS_MESSENGER_TYPE_FACEBOOK;
2205 type = CONTACTS_MESSENGER_TYPE_CUSTOM;
2208 contacts_record_set_int(messengerHandle, _contacts_messenger.type, type);
2209 if (type == CONTACTS_MESSENGER_TYPE_CUSTOM)
2211 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
2212 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2214 contacts_record_set_str(messengerHandle, _contacts_messenger.label, pCharArray.get());
2217 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetImAddress();
2218 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
2219 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2221 contacts_record_set_str(messengerHandle, _contacts_messenger.im_id, pCharArray.get());
2223 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.messenger, messengerHandle);
2224 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2226 recordHandle.Release();
2232 _UserProfileImpl::AddRelationship(const Relationship& relationship)
2234 SysTryReturn(NID_SCL, !relationship.GetRelativeName().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%] Invalid argument is used. The relationship is empty.", GetErrorMessage(E_INVALID_ARG));
2237 contacts_record_h relationshipHandle = null;
2239 int ret = contacts_record_create(_contacts_relationship._uri, &relationshipHandle);
2240 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2242 __ContactsRecordHandle recordHandle(relationshipHandle);
2244 switch (relationship.GetType())
2246 case CONTACT_RELATIONSHIP_TYPE_ASSISTANT:
2247 intValue = CONTACTS_RELATIONSHIP_TYPE_ASSISTANT;
2249 case CONTACT_RELATIONSHIP_TYPE_BROTHER:
2250 intValue = CONTACTS_RELATIONSHIP_TYPE_BROTHER;
2252 case CONTACT_RELATIONSHIP_TYPE_CHILD:
2253 intValue = CONTACTS_RELATIONSHIP_TYPE_CHILD;
2255 case CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
2256 intValue = CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER;
2258 case CONTACT_RELATIONSHIP_TYPE_FATHER:
2259 intValue = CONTACTS_RELATIONSHIP_TYPE_FATHER;
2261 case CONTACT_RELATIONSHIP_TYPE_FRIEND:
2262 intValue = CONTACTS_RELATIONSHIP_TYPE_FRIEND;
2264 case CONTACT_RELATIONSHIP_TYPE_MANAGER:
2265 intValue = CONTACTS_RELATIONSHIP_TYPE_MANAGER;
2267 case CONTACT_RELATIONSHIP_TYPE_MOTHER:
2268 intValue = CONTACTS_RELATIONSHIP_TYPE_MOTHER;
2270 case CONTACT_RELATIONSHIP_TYPE_PARENT:
2271 intValue = CONTACTS_RELATIONSHIP_TYPE_PARENT;
2273 case CONTACT_RELATIONSHIP_TYPE_PARTNER:
2274 intValue = CONTACTS_RELATIONSHIP_TYPE_PARTNER;
2276 case CONTACT_RELATIONSHIP_TYPE_REFERRED_BY:
2277 intValue = CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY;
2279 case CONTACT_RELATIONSHIP_TYPE_RELATIVE:
2280 intValue = CONTACTS_RELATIONSHIP_TYPE_RELATIVE;
2282 case CONTACT_RELATIONSHIP_TYPE_SISTER:
2283 intValue = CONTACTS_RELATIONSHIP_TYPE_SISTER;
2285 case CONTACT_RELATIONSHIP_TYPE_SPOUSE:
2286 intValue = CONTACTS_RELATIONSHIP_TYPE_SPOUSE;
2288 case CONTACT_RELATIONSHIP_TYPE_CUSTOM:
2289 intValue = CONTACTS_RELATIONSHIP_TYPE_CUSTOM;
2292 intValue = CONTACTS_RELATIONSHIP_TYPE_OTHER;
2297 contacts_record_set_int(relationshipHandle, _contacts_relationship.type, intValue);
2300 String stringValue = relationship.GetLabel();
2301 if (!stringValue.IsEmpty())
2303 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2304 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2306 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, pCharArray.get());
2310 stringValue = relationship.GetRelativeName();
2311 if (!stringValue.IsEmpty())
2313 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2314 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2316 contacts_record_set_str(relationshipHandle, _contacts_relationship.name, pCharArray.get());
2319 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.relationship, relationshipHandle);
2320 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2322 recordHandle.Release();
2330 _UserProfileImpl::AddEvent(const ContactEvent& event)
2336 contacts_record_h eventHandle = null;
2338 int ret = contacts_record_create(_contacts_event._uri, &eventHandle);
2339 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2341 __ContactsRecordHandle recordHandle(eventHandle);
2343 switch (event.GetType())
2345 case CONTACT_EVENT_TYPE_ANNIVERSARY:
2346 type = CONTACTS_EVENT_TYPE_ANNIVERSARY;
2348 case CONTACT_EVENT_TYPE_BIRTHDAY:
2349 type = CONTACTS_EVENT_TYPE_BIRTH;
2351 case CONTACT_EVENT_TYPE_CUSTOM:
2352 type = CONTACTS_EVENT_TYPE_CUSTOM;
2354 case CONTACT_EVENT_TYPE_OTHER:
2357 type = CONTACTS_EVENT_TYPE_OTHER;
2362 contacts_record_set_int(eventHandle, _contacts_event.type, type);
2365 stringValue = event.GetLabel();
2366 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2367 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2369 contacts_record_set_str(eventHandle, _contacts_event.label, pCharArray.get());
2372 DateTime dateValue = event.GetDate();
2373 intValue = dateValue.GetYear()*10000 + dateValue.GetMonth()*100 + dateValue.GetDay();
2374 contacts_record_set_int(eventHandle, _contacts_event.date, intValue);
2376 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.event, eventHandle);
2377 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2379 recordHandle.Release();
2386 _UserProfileImpl::AddOrganization(const Organization& organization)
2388 SysTryReturn(NID_SCL
2389 , !organization.GetName().IsEmpty() ||
2390 !organization.GetJobTitle().IsEmpty() ||
2391 !organization.GetDepartment().IsEmpty() ||
2392 !organization.GetRole().IsEmpty() ||
2393 !organization.GetAgent().IsEmpty() ||
2394 !organization.GetDescription().IsEmpty() ||
2395 !organization.GetLocation().IsEmpty() ||
2396 !organization.GetPhoneticName().IsEmpty() ||
2397 !organization.GetLogoPath().IsEmpty()
2398 ,E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The organization is empty.", GetErrorMessage(E_INVALID_ARG));
2400 contacts_record_h organizationHandle = null;
2402 int ret = contacts_record_create(_contacts_company._uri, &organizationHandle);
2403 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2405 __ContactsRecordHandle recordHandle(organizationHandle);
2408 String stringValue = organization.GetName();
2409 if (!stringValue.IsEmpty())
2411 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2412 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2414 contacts_record_set_str(organizationHandle, _contacts_company.name, pCharArray.get());
2418 stringValue = organization.GetJobTitle();
2419 if (!stringValue.IsEmpty())
2421 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2422 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2424 contacts_record_set_str(organizationHandle, _contacts_company.job_title, pCharArray.get());
2428 stringValue = organization.GetDepartment();
2429 if (!stringValue.IsEmpty())
2431 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2432 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2434 contacts_record_set_str(organizationHandle, _contacts_company.department, pCharArray.get());
2438 stringValue = organization.GetRole();
2439 if (!stringValue.IsEmpty())
2441 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2442 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2444 contacts_record_set_str(organizationHandle, _contacts_company.role, pCharArray.get());
2448 stringValue = organization.GetAgent();
2449 if (!stringValue.IsEmpty())
2451 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2452 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2454 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, pCharArray.get());
2460 switch (organization.GetType())
2462 case ORGANIZATION_TYPE_WORK:
2463 type = CONTACTS_COMPANY_TYPE_WORK;
2465 case ORGANIZATION_TYPE_CUSTOM:
2466 type = CONTACTS_COMPANY_TYPE_CUSTOM;
2468 case ORGANIZATION_TYPE_OTHER:
2471 type = CONTACTS_COMPANY_TYPE_OTHER;
2475 contacts_record_set_int(organizationHandle, _contacts_company.type, type);
2478 stringValue = organization.GetLabel();
2479 if (!stringValue.IsEmpty())
2481 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2482 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2484 contacts_record_set_str(organizationHandle, _contacts_company.label, pCharArray.get());
2488 stringValue = organization.GetDescription();
2489 if (!stringValue.IsEmpty())
2491 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2492 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2494 contacts_record_set_str(organizationHandle, _contacts_company.description, pCharArray.get());
2498 stringValue = organization.GetLocation();
2499 if (!stringValue.IsEmpty())
2501 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2502 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2504 contacts_record_set_str(organizationHandle, _contacts_company.location, pCharArray.get());
2508 stringValue = organization.GetPhoneticName();
2509 if (!stringValue.IsEmpty())
2511 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2512 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2514 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, pCharArray.get());
2518 if (_OrganizationImpl::GetInstance(organization)->IsLogoPathChanged() == true)
2520 stringValue = organization.GetLogoPath();
2521 if (!stringValue.IsEmpty())
2523 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2524 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2526 contacts_record_set_str(organizationHandle, _contacts_company.logo, pCharArray.get());
2530 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.company, organizationHandle);
2531 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2533 recordHandle.Release();
2540 _UserProfileImpl::RemoveAt(UserProfileMultiPropertyId id, int index)
2542 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);
2544 unsigned int count = 0;
2545 contacts_record_h recordHandle = null;
2549 case USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS:
2550 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.number, &count);
2551 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of phone numbers %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2553 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.number, index, &recordHandle);
2554 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.number, recordHandle);
2555 contacts_record_destroy(recordHandle, true);
2558 case USER_PROFILE_MPROPERTY_ID_EMAILS:
2559 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.email, &count);
2560 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);
2562 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.email, index, &recordHandle);
2563 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.email, recordHandle);
2564 contacts_record_destroy(recordHandle, true);
2567 case USER_PROFILE_MPROPERTY_ID_URLS:
2568 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.url, &count);
2569 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of urls %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2571 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.url, index, &recordHandle);
2572 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.url, recordHandle);
2573 contacts_record_destroy(recordHandle, true);
2576 case USER_PROFILE_MPROPERTY_ID_ADDRESSES:
2577 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.address, &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 addresses %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2580 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.address, index, &recordHandle);
2581 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.address, recordHandle);
2582 contacts_record_destroy(recordHandle, true);
2585 case USER_PROFILE_MPROPERTY_ID_IMADDRESSES:
2586 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.messenger, &count);
2587 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);
2589 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.messenger, index, &recordHandle);
2590 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.messenger, recordHandle);
2591 contacts_record_destroy(recordHandle, true);
2594 case USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS:
2595 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.company, &count);
2596 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);
2598 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.company, index, &recordHandle);
2599 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.company, recordHandle);
2600 contacts_record_destroy(recordHandle, true);
2603 case USER_PROFILE_MPROPERTY_ID_EVENTS:
2604 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.event, &count);
2605 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);
2607 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.event, index, &recordHandle);
2608 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.event, recordHandle);
2609 contacts_record_destroy(recordHandle, true);
2612 case USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS:
2613 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.relationship, &count);
2614 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);
2616 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.relationship, index, &recordHandle);
2617 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.relationship, recordHandle);
2618 contacts_record_destroy(recordHandle, true);
2621 case USER_PROFILE_MPROPERTY_ID_NOTES:
2622 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.note, &count);
2623 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);
2625 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.note, index, &recordHandle);
2626 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.note, recordHandle);
2627 contacts_record_destroy(recordHandle, true);
2630 case USER_PROFILE_MPROPERTY_ID_NICKNAMES:
2631 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.nickname, &count);
2632 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);
2634 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.nickname, index, &recordHandle);
2635 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.nickname, recordHandle);
2636 contacts_record_destroy(recordHandle, true);
2640 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
2641 return E_INVALID_ARG;
2648 _UserProfileImpl::GetOrganizationsN(void) const
2650 result r = E_SUCCESS;
2651 contacts_record_h organizationHandle = null;
2652 int ret = CONTACTS_ERROR_NONE;
2653 char* pCharValue = null;
2655 unsigned int count = 0;
2656 std::unique_ptr<Organization> pOrganization(null);
2658 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2659 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2661 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.company, &count);
2663 r = pList->Construct(count);
2664 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2666 for (unsigned int index = 0; index < count; index++)
2668 ret = contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.company, index, &organizationHandle);
2669 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2671 pOrganization.reset(new (std::nothrow) Organization());
2672 SysTryReturn(NID_SCL, pOrganization != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2675 contacts_record_get_str_p(organizationHandle, _contacts_company.name, &pCharValue);
2676 pOrganization->SetName(pCharValue);
2679 contacts_record_get_str_p(organizationHandle, _contacts_company.job_title, &pCharValue);
2680 pOrganization->SetJobTitle(pCharValue);
2683 contacts_record_get_str_p(organizationHandle, _contacts_company.department, &pCharValue);
2684 pOrganization->SetDepartment(pCharValue);
2687 contacts_record_get_str_p(organizationHandle, _contacts_company.role, &pCharValue);
2688 pOrganization->SetRole(pCharValue);
2691 contacts_record_get_str_p(organizationHandle, _contacts_company.assistant_name, &pCharValue);
2692 pOrganization->SetAgent(pCharValue);
2695 contacts_record_get_int(organizationHandle, _contacts_company.type, &intValue);
2698 case CONTACTS_COMPANY_TYPE_WORK:
2699 pOrganization->SetType(ORGANIZATION_TYPE_WORK);
2701 case CONTACTS_COMPANY_TYPE_CUSTOM:
2702 pOrganization->SetType(ORGANIZATION_TYPE_CUSTOM);
2704 case CONTACTS_COMPANY_TYPE_OTHER:
2707 pOrganization->SetType(ORGANIZATION_TYPE_OTHER);
2712 contacts_record_get_str_p(organizationHandle, _contacts_company.label, &pCharValue);
2713 pOrganization->SetLabel(pCharValue);
2716 contacts_record_get_str_p(organizationHandle, _contacts_company.description, &pCharValue);
2717 pOrganization->SetDescription(pCharValue);
2720 contacts_record_get_str_p(organizationHandle, _contacts_company.location, &pCharValue);
2721 pOrganization->SetLocation(pCharValue);
2724 contacts_record_get_str_p(organizationHandle, _contacts_company.phonetic_name, &pCharValue);
2725 pOrganization->SetPhoneticName(pCharValue);
2728 contacts_record_get_str_p(organizationHandle, _contacts_company.logo, &pCharValue);
2729 _OrganizationImpl::GetInstance(*pOrganization)->SetLogoPath(pCharValue);
2731 r = pList->Add(*pOrganization);
2732 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2734 pOrganization.release();
2737 return pList.release();
2742 _UserProfileImpl::GetRelationshipsN(void) const
2745 result r = E_SUCCESS;
2746 contacts_record_h relationshipHandle = null;
2747 int ret = CONTACTS_ERROR_NONE;
2749 char* pCharValue = null;
2750 unsigned int count = 0;
2751 std::unique_ptr<Relationship> pRelationship(null);
2753 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2754 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2756 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.relationship, &count);
2758 r = pList->Construct(count);
2759 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2761 for (unsigned int index = 0; index < count; index++)
2763 ret = contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.relationship, index, &relationshipHandle);
2764 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2766 pRelationship.reset(new (std::nothrow) Relationship());
2767 SysTryReturn(NID_SCL, pRelationship != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2770 contacts_record_get_int(relationshipHandle, _contacts_relationship.type, &intValue);
2773 case CONTACTS_RELATIONSHIP_TYPE_ASSISTANT:
2774 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_ASSISTANT);
2776 case CONTACTS_RELATIONSHIP_TYPE_BROTHER:
2777 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_BROTHER);
2779 case CONTACTS_RELATIONSHIP_TYPE_CHILD:
2780 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_CHILD);
2782 case CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
2783 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER);
2785 case CONTACTS_RELATIONSHIP_TYPE_FATHER:
2786 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_FATHER);
2788 case CONTACTS_RELATIONSHIP_TYPE_FRIEND:
2789 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_FRIEND);
2791 case CONTACTS_RELATIONSHIP_TYPE_MANAGER:
2792 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_MANAGER);
2794 case CONTACTS_RELATIONSHIP_TYPE_MOTHER:
2795 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_MOTHER);
2797 case CONTACTS_RELATIONSHIP_TYPE_PARENT:
2798 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_PARENT);
2800 case CONTACTS_RELATIONSHIP_TYPE_PARTNER:
2801 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_PARTNER);
2803 case CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY:
2804 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_REFERRED_BY);
2806 case CONTACTS_RELATIONSHIP_TYPE_RELATIVE:
2807 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_RELATIVE);
2809 case CONTACTS_RELATIONSHIP_TYPE_SISTER:
2810 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_SISTER);
2812 case CONTACTS_RELATIONSHIP_TYPE_SPOUSE:
2813 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_SPOUSE);
2815 case CONTACTS_RELATIONSHIP_TYPE_CUSTOM:
2818 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_CUSTOM);
2823 contacts_record_get_str_p(relationshipHandle, _contacts_relationship.label, &pCharValue);
2824 pRelationship->SetLabel(pCharValue);
2827 contacts_record_get_str_p(relationshipHandle, _contacts_relationship.name, &pCharValue);
2828 pRelationship->SetRelativeName(pCharValue);
2830 r = pList->Add(*pRelationship);
2831 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2833 pRelationship.release();
2836 return pList.release();
2841 _UserProfileImpl::GetEventsN(void) const
2843 result r = E_SUCCESS;
2844 char* pCharValue = null;
2846 unsigned int count = 0;
2847 contacts_record_h eventHandle = null;
2848 std::unique_ptr<ContactEvent> pEvent(null);
2850 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2851 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2853 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.event, &count);
2855 r = pList->Construct(count);
2856 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2858 for (unsigned int index = 0; index < count; index++)
2860 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.event, index, &eventHandle);
2862 pEvent.reset(new (std::nothrow) ContactEvent());
2863 SysTryReturn(NID_SCL, pEvent != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2866 contacts_record_get_str_p(eventHandle, _contacts_event.label, &pCharValue);
2867 pEvent->SetLabel(pCharValue);
2870 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
2873 case CONTACTS_EVENT_TYPE_BIRTH:
2874 pEvent->SetType(CONTACT_EVENT_TYPE_BIRTHDAY);
2876 case CONTACTS_EVENT_TYPE_ANNIVERSARY:
2877 pEvent->SetType(CONTACT_EVENT_TYPE_ANNIVERSARY);
2879 case CONTACTS_URL_TYPE_CUSTOM:
2880 pEvent->SetType(CONTACT_EVENT_TYPE_CUSTOM);
2883 pEvent->SetType(CONTACT_EVENT_TYPE_OTHER);
2889 contacts_record_get_int(eventHandle, _contacts_event.date, &intValue);
2890 __CONVERT_DATE_TO_DATETIME(intValue, dateTime);
2891 pEvent->SetDate(dateTime);
2893 pList->Add(*pEvent);
2894 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2899 return pList.release();
2904 _UserProfileImpl::GetNotesN(void) const
2906 result r = E_SUCCESS;
2907 char* pCharValue = null;
2908 unsigned int count = 0;
2909 contacts_record_h noteHandle = null;
2910 std::unique_ptr<String> pNote(null);
2912 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2913 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2915 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.note, &count);
2917 r = pList->Construct(count);
2918 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2920 for (unsigned int index = 0; index < count; index++)
2922 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.note, index, ¬eHandle);
2924 contacts_record_get_str_p(noteHandle, _contacts_note.note, &pCharValue);
2926 pNote.reset(new (std::nothrow) String(pCharValue));
2927 SysTryReturn(NID_SCL, pNote != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2930 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2935 return pList.release();
2940 _UserProfileImpl::GetNicknamesN(void) const
2942 result r = E_SUCCESS;
2943 char* pCharValue = null;
2944 unsigned int count = 0;
2945 contacts_record_h nicknameHandle = null;
2946 std::unique_ptr<String> pNickname(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));
2951 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.nickname, &count);
2953 r = pList->Construct(count);
2954 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2956 for (unsigned int index = 0; index < count; index++)
2958 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.nickname, index, &nicknameHandle);
2960 contacts_record_get_str_p(nicknameHandle, _contacts_nickname.name, &pCharValue);
2962 pNickname.reset(new (std::nothrow) String(pCharValue));
2963 SysTryReturn(NID_SCL, pNickname != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2965 pList->Add(*pNickname);
2966 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2968 pNickname.release();
2971 return pList.release();
2976 _UserProfileImpl::GetPhoneNumbersN(void) const
2978 result r = E_SUCCESS;
2979 unsigned int count = 0;
2980 contacts_record_h numberHandle = null;
2982 char* pCharValue = null;
2983 PhoneNumberType type = PHONENUMBER_TYPE_HOME;
2984 std::unique_ptr<PhoneNumber> pPhoneNumber(null);
2986 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2987 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2990 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.number, &count);
2992 contacts_record_get_int(__profileHandle, _contacts_my_profile.id, &intValue);
2994 r = pList->Construct(count);
2995 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2997 for (unsigned int index = 0; index < count; index++)
2999 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.number, index, &numberHandle);
3001 pPhoneNumber.reset(new (std::nothrow) PhoneNumber());
3002 SysTryReturn(NID_SCL, pPhoneNumber != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3004 contacts_record_get_int(numberHandle, _contacts_number.id, &intValue);
3005 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetRecordId(intValue);
3007 contacts_record_get_str_p(numberHandle, _contacts_number.label, &pCharValue);
3008 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetLabel(pCharValue);
3010 contacts_record_get_int(numberHandle, _contacts_number.type, &intValue);
3014 case CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE:
3015 type = PHONENUMBER_TYPE_HOME;
3017 case CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE:
3018 type = PHONENUMBER_TYPE_WORK;
3020 case CONTACTS_NUMBER_TYPE_CELL:
3021 type = PHONENUMBER_TYPE_MOBILE;
3023 case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME:
3024 type = PHONENUMBER_TYPE_HOME_FAX;
3026 case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK:
3027 type = PHONENUMBER_TYPE_WORK_FAX;
3029 case CONTACTS_NUMBER_TYPE_PAGER:
3030 type = PHONENUMBER_TYPE_PAGER;
3032 case CONTACTS_NUMBER_TYPE_CUSTOM:
3033 type = PHONENUMBER_TYPE_CUSTOM;
3035 case CONTACTS_NUMBER_TYPE_ASSISTANT:
3036 type = PHONENUMBER_TYPE_ASSISTANT;
3039 if (intValue & CONTACTS_NUMBER_TYPE_FAX)
3041 type = PHONENUMBER_TYPE_HOME_FAX;
3043 else if (intValue & CONTACTS_NUMBER_TYPE_CELL)
3045 type = PHONENUMBER_TYPE_MOBILE;
3047 else if (intValue & CONTACTS_NUMBER_TYPE_PAGER)
3049 type = PHONENUMBER_TYPE_PAGER;
3051 else if (intValue & CONTACTS_NUMBER_TYPE_HOME)
3053 type = PHONENUMBER_TYPE_HOME;
3055 else if (intValue & CONTACTS_NUMBER_TYPE_WORK)
3057 type = PHONENUMBER_TYPE_WORK;
3059 else if (intValue & CONTACTS_NUMBER_TYPE_VOICE)
3061 type = PHONENUMBER_TYPE_HOME;
3065 type = PHONENUMBER_TYPE_OTHER;
3070 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetType(type);
3072 contacts_record_get_str_p(numberHandle, _contacts_number.number, &pCharValue);
3073 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetPhoneNumber(pCharValue);
3075 r = pList->Add(*pPhoneNumber);
3076 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3078 pPhoneNumber.release();
3081 return pList.release();
3086 _UserProfileImpl::GetEmailsN(void) const
3088 result r = E_SUCCESS;
3089 contacts_record_h currentHandle = null;
3090 int ret = CONTACTS_ERROR_NONE;
3092 unsigned int count = 0;
3093 char* pCharValue = null;
3094 EmailType type = EMAIL_TYPE_PERSONAL;
3095 std::unique_ptr<Email> pEmail(null);
3097 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3098 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3100 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.email, &count);
3102 r = pList->Construct(count);
3103 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3105 for (unsigned int index = 0; index < count; index++)
3107 ret = contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.email, index, ¤tHandle);
3108 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM))
3110 pEmail.reset(new (std::nothrow) Email());
3111 SysTryReturn(NID_SCL, pEmail != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3113 contacts_record_get_int(currentHandle, _contacts_email.id, &intValue);
3114 _EmailImpl::GetInstance(*pEmail)->SetRecordId(intValue);
3116 contacts_record_get_str_p(currentHandle, _contacts_email.label, &pCharValue);
3117 _EmailImpl::GetInstance(*pEmail)->SetLabel(pCharValue);
3119 contacts_record_get_int(currentHandle, _contacts_email.type, &intValue);
3122 case CONTACTS_EMAIL_TYPE_HOME:
3123 type = EMAIL_TYPE_PERSONAL;
3125 case CONTACTS_EMAIL_TYPE_WORK:
3126 type = EMAIL_TYPE_WORK;
3128 case CONTACTS_EMAIL_TYPE_CUSTOM:
3129 type = EMAIL_TYPE_CUSTOM;
3131 case CONTACTS_EMAIL_TYPE_MOBILE:
3132 type = EMAIL_TYPE_MOBILE;
3135 type = EMAIL_TYPE_OTHER;
3139 _EmailImpl::GetInstance(*pEmail)->SetType(type);
3141 contacts_record_get_str_p(currentHandle, _contacts_email.email, &pCharValue);
3142 _EmailImpl::GetInstance(*pEmail)->SetEmail(pCharValue);
3144 r = pList->Add(*pEmail);
3145 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3150 return pList.release();
3155 _UserProfileImpl::GetUrlsN(void) const
3158 result r = E_SUCCESS;
3159 char* pCharValue = null;
3161 unsigned int count = 0;
3162 UrlType type = URL_TYPE_PERSONAL;
3163 contacts_record_h urlHandle = null;
3164 std::unique_ptr<Url> pUrl(null);
3166 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3167 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3169 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.url, &count);
3171 r = pList->Construct(count);
3172 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3174 for (unsigned int index = 0; index < count; index++)
3176 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.url, index, &urlHandle);
3178 pUrl.reset(new (std::nothrow) Url());
3179 SysTryReturn(NID_SCL, pUrl != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3181 contacts_record_get_str_p(urlHandle, _contacts_url.label, &pCharValue);
3182 pUrl->SetLabel(pCharValue);
3184 contacts_record_get_int(urlHandle, _contacts_url.type, &intValue);
3187 case CONTACTS_URL_TYPE_HOME:
3188 type = URL_TYPE_PERSONAL;
3190 case CONTACTS_URL_TYPE_WORK:
3191 type = URL_TYPE_WORK;
3193 case CONTACTS_URL_TYPE_CUSTOM:
3194 type = URL_TYPE_CUSTOM;
3197 type = URL_TYPE_OTHER;
3201 pUrl->SetType(type);
3203 contacts_record_get_str_p(urlHandle, _contacts_url.url, &pCharValue);
3204 _UrlImpl::GetInstance(*pUrl)->SetUrl(pCharValue);
3207 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3212 return pList.release();
3217 _UserProfileImpl::GetAddressesN(void) const
3219 result r = E_SUCCESS;
3220 char* pCharValue = null;
3222 unsigned int count = 0;
3223 contacts_record_h addressHandle = 0;
3224 std::unique_ptr<Address> pAddress(null);
3226 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3227 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3229 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.address, &count);
3231 r = pList->Construct(count);
3232 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3235 for (unsigned int index = 0; index < count; index++)
3237 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.address, index, &addressHandle);
3239 pAddress.reset(new (std::nothrow) Address());
3240 SysTryReturn(NID_SCL, pAddress != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3242 contacts_record_get_str_p(addressHandle, _contacts_address.label, &pCharValue);
3243 pAddress->SetLabel(pCharValue);
3245 contacts_record_get_int(addressHandle, _contacts_address.type, &intValue);
3248 case CONTACTS_ADDRESS_TYPE_HOME:
3249 pAddress->SetType(ADDRESS_TYPE_HOME);
3251 case CONTACTS_ADDRESS_TYPE_WORK:
3252 pAddress->SetType(ADDRESS_TYPE_WORK);
3254 case CONTACTS_ADDRESS_TYPE_CUSTOM:
3255 pAddress->SetType(ADDRESS_TYPE_CUSTOM);
3258 pAddress->SetType(ADDRESS_TYPE_OTHER);
3263 contacts_record_get_str_p(addressHandle, _contacts_address.country, &pCharValue);
3264 _AddressImpl::GetInstance(*pAddress)->SetCountry(pCharValue);
3267 contacts_record_get_str_p(addressHandle, _contacts_address.region, &pCharValue);
3268 _AddressImpl::GetInstance(*pAddress)->SetState(pCharValue);
3271 contacts_record_get_str_p(addressHandle, _contacts_address.locality, &pCharValue);
3272 _AddressImpl::GetInstance(*pAddress)->SetCity(pCharValue);
3275 contacts_record_get_str_p(addressHandle, _contacts_address.street, &pCharValue);
3276 _AddressImpl::GetInstance(*pAddress)->SetStreet(pCharValue);
3279 contacts_record_get_str_p(addressHandle, _contacts_address.extended, &pCharValue);
3280 _AddressImpl::GetInstance(*pAddress)->SetExtended(pCharValue);
3283 contacts_record_get_str_p(addressHandle, _contacts_address.postbox, &pCharValue);
3284 _AddressImpl::GetInstance(*pAddress)->SetPostOfficeBoxNumber(pCharValue);
3287 contacts_record_get_str_p(addressHandle, _contacts_address.postal_code, &pCharValue);
3288 _AddressImpl::GetInstance(*pAddress)->SetPostalCode(pCharValue);
3290 r = pList->Add(*pAddress);
3291 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3296 return pList.release();
3301 _UserProfileImpl::GetImAddressesN(void) const
3303 result r = E_SUCCESS;
3304 char* pCharValue = null;
3306 contacts_record_h messengerHandle = null;
3307 unsigned int count = 0;
3308 std::unique_ptr<ImAddress> pImAddress(null);
3310 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3311 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3313 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.messenger, &count);
3315 r = pList->Construct(count);
3316 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3318 for (unsigned int index = 0; index < count; index++)
3320 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.messenger, index, &messengerHandle);
3322 pImAddress.reset(new (std::nothrow) ImAddress());
3323 SysTryReturn(NID_SCL, pImAddress != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3325 contacts_record_get_int(messengerHandle, _contacts_messenger.type, &intValue);
3328 case CONTACTS_MESSENGER_TYPE_GOOGLE:
3329 pImAddress->SetServiceProviderName(IM_ADDRESS_GOOGLE_TALK);
3331 case CONTACTS_MESSENGER_TYPE_WLM:
3332 pImAddress->SetServiceProviderName(IM_ADDRESS_MSN);
3334 case CONTACTS_MESSENGER_TYPE_ICQ:
3335 pImAddress->SetServiceProviderName(IM_ADDRESS_ICQ);
3337 case CONTACTS_MESSENGER_TYPE_AIM:
3338 pImAddress->SetServiceProviderName(IM_ADDRESS_AIM);
3340 case CONTACTS_MESSENGER_TYPE_YAHOO:
3341 pImAddress->SetServiceProviderName(IM_ADDRESS_YAHOO);
3343 case CONTACTS_MESSENGER_TYPE_QQ:
3344 pImAddress->SetServiceProviderName(IM_ADDRESS_QQ);
3346 case CONTACTS_MESSENGER_TYPE_SKYPE:
3347 pImAddress->SetServiceProviderName(IM_ADDRESS_SKYPE);
3349 case CONTACTS_MESSENGER_TYPE_JABBER:
3350 pImAddress->SetServiceProviderName(IM_ADDRESS_JABBER);
3352 case CONTACTS_MESSENGER_TYPE_IRC:
3353 pImAddress->SetServiceProviderName(IM_ADDRESS_IRC);
3355 case CONTACTS_MESSENGER_TYPE_FACEBOOK:
3356 pImAddress->SetServiceProviderName(IM_ADDRESS_FACEBOOK);
3358 case CONTACTS_MESSENGER_TYPE_CUSTOM:
3361 contacts_record_get_str_p(messengerHandle, _contacts_messenger.label, &pCharValue);
3362 pImAddress->SetServiceProviderName(pCharValue);
3366 contacts_record_get_str_p(messengerHandle, _contacts_messenger.im_id, &pCharValue);
3367 _ImAddressImpl::GetInstance(*pImAddress)->SetImAddress(pCharValue);
3369 r = pList->Add(*pImAddress);
3370 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3372 pImAddress.release();
3375 return pList.release();
3381 _UserProfileImpl::IsEmptyCompany(contacts_record_h companyHandle)
3383 char* pCharValue = null;
3385 contacts_record_get_str_p(companyHandle, _contacts_company.name, &pCharValue);
3386 if (pCharValue != null)
3391 contacts_record_get_str_p(companyHandle, _contacts_company.job_title, &pCharValue);
3392 if (pCharValue != null)
3398 contacts_record_get_str_p(companyHandle, _contacts_company.department, &pCharValue);
3399 if (pCharValue != null)
3404 contacts_record_get_str_p(companyHandle, _contacts_company.role, &pCharValue);
3405 if (pCharValue != null)
3410 contacts_record_get_str_p(companyHandle, _contacts_company.assistant_name, &pCharValue);
3411 if (pCharValue != null)
3420 _UserProfileImpl::IsEmptyName(contacts_record_h nameHandle)
3422 char* pCharValue = null;
3424 contacts_record_get_str_p(nameHandle, _contacts_name.first, &pCharValue);
3425 if (pCharValue != null)
3430 contacts_record_get_str_p(nameHandle, _contacts_name.last, &pCharValue);
3431 if (pCharValue != null)
3436 contacts_record_get_str_p(nameHandle, _contacts_name.addition, &pCharValue);
3437 if (pCharValue != null)
3442 contacts_record_get_str_p(nameHandle, _contacts_name.prefix, &pCharValue);
3443 if (pCharValue != null)
3448 contacts_record_get_str_p(nameHandle, _contacts_name.suffix, &pCharValue);
3449 if (pCharValue != null)
3459 _UserProfileImpl::IsEmpty(void) const
3461 unsigned int count = 0;
3463 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.number, &count);
3469 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.email, &count);
3475 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.url, &count);
3481 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.address, &count);
3487 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.messenger, &count);
3493 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
3499 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.company, &count);
3505 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.event, &count);
3511 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.note, &count);
3517 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.nickname, &count);
3523 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.image, &count);
3534 _UserProfileImpl::SetUserProfileHandle(contacts_record_h profileHandle)
3536 contacts_record_destroy(__profileHandle, true);
3538 __profileHandle = profileHandle;
3542 _UserProfileImpl::GetUserProfileHandle(void) const
3544 return __profileHandle;
3547 const _UserProfileImpl*
3548 _UserProfileImpl::GetInstance(const UserProfile& userProfile)
3550 return userProfile.__pUserProfileImpl;
3554 _UserProfileImpl::GetInstance(UserProfile& userProfile)
3556 return userProfile.__pUserProfileImpl;