2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FScl_UserProfileImpl.cpp
19 * @brief This is the implementation for _UserProfileImpl class.
21 * This file contains definitions of _UserProfileImpl class.
23 #include <FBaseString.h>
24 #include <FBaseColArrayList.h>
25 #include <FBaseSysLog.h>
27 #include <FMediaImage.h>
28 #include <FSclAddress.h>
29 #include <FSclPhoneNumber.h>
30 #include <FSclEmail.h>
32 #include <FSclImAddress.h>
33 #include <FSclOrganization.h>
34 #include <FSclContactEvent.h>
35 #include <FSclRelationship.h>
36 #include <FSclContact.h>
37 #include <FSclUserProfile.h>
38 #include <FBase_StringConverter.h>
39 #include "FScl_ContactDbConnector.h"
40 #include "FScl_PhoneNumberImpl.h"
41 #include "FScl_AddressbookUtil.h"
42 #include "FScl_UrlImpl.h"
43 #include "FScl_EmailImpl.h"
44 #include "FScl_AddressImpl.h"
45 #include "FScl_ImAddressImpl.h"
46 #include "FScl_UserProfileImpl.h"
47 #include "FScl_OrganizationImpl.h"
49 using namespace Tizen::Base;
50 using namespace Tizen::Base::Collection;
51 using namespace Tizen::Graphics;
52 using namespace Tizen::Media;
53 using namespace Tizen::Io;
55 namespace Tizen { namespace Social
58 const int __CONTACT_MOD_YEAR = 10000;
59 const int __CONTACT_MOD_MONTH = 100;
61 #define __CONVERT_DATE_TO_DATETIME(date, dateTime) \
68 year = temp/__CONTACT_MOD_YEAR; \
69 temp -= year*__CONTACT_MOD_YEAR; \
70 month = temp/__CONTACT_MOD_MONTH; \
71 day = temp - month*__CONTACT_MOD_MONTH; \
72 dateTime.SetValue(year, month, day, 0, 0, 0); \
75 _UserProfileImpl::_UserProfileImpl(void)
76 : __profileHandle(null)
78 contacts_record_h profileHandle = null;
80 SysTryReturnVoidResult(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
82 int ret = contacts_record_create(_contacts_my_profile._uri, &profileHandle);
83 SysTryReturnVoidResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
85 __profileHandle = profileHandle;
88 _UserProfileImpl::_UserProfileImpl(const _UserProfileImpl& rhs)
89 : __profileHandle(null)
91 contacts_record_h profileHandle = null;
93 SysTryReturnVoidResult(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
95 int ret = contacts_record_clone(rhs.__profileHandle, &profileHandle);
96 SysTryReturnVoidResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
98 __profileHandle = profileHandle;
101 _UserProfileImpl::~_UserProfileImpl(void)
103 if (__profileHandle != null)
105 contacts_record_destroy(__profileHandle, true);
110 _UserProfileImpl::operator =(const _UserProfileImpl& rhs)
117 contacts_record_h profileHandle = null;
119 int ret = contacts_record_clone(rhs.__profileHandle, &profileHandle);
120 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
122 contacts_record_destroy(__profileHandle, true);
123 __profileHandle = profileHandle;
125 //__isRemoved = rhs.__isRemoved;
131 _UserProfileImpl::Equals(const Object& rhs) const
133 const _UserProfileImpl* pRhs = dynamic_cast<const _UserProfileImpl*>(&rhs);
140 //compare single value properties
141 if (this->GetValue(USER_PROFILE_PROPERTY_ID_FIRST_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_FIRST_NAME))
146 if (this->GetValue(USER_PROFILE_PROPERTY_ID_LAST_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_LAST_NAME))
151 if (this->GetValue(USER_PROFILE_PROPERTY_ID_MIDDLE_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_MIDDLE_NAME))
156 if (this->GetValue(USER_PROFILE_PROPERTY_ID_NAME_PREFIX) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_NAME_PREFIX))
161 if (this->GetValue(USER_PROFILE_PROPERTY_ID_NAME_SUFFIX) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_NAME_SUFFIX))
166 if (this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME))
171 if (this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME))
176 if (this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME) != pRhs->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME))
181 //compare multivalue properties
182 std::unique_ptr<ArrayList, AllElementsDeleter> pCurrentObjectList(null);
183 std::unique_ptr<ArrayList, AllElementsDeleter> pRhsObjectList(null);
185 pCurrentObjectList = std::unique_ptr<ArrayList, AllElementsDeleter> (static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS)));
186 pRhsObjectList = std::unique_ptr<ArrayList, AllElementsDeleter> (static_cast<ArrayList*>(pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS)));
188 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
193 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_EMAILS))));
194 pRhsObjectList.reset((static_cast<ArrayList*>(pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_EMAILS))));
196 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
201 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_URLS))));
202 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_URLS))));
204 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
209 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_ADDRESSES))));
210 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_ADDRESSES))));
212 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
217 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_IMADDRESSES))));
218 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_IMADDRESSES))));
220 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
225 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_EVENTS))));
226 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_EVENTS))));
228 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
233 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS))));
234 pRhsObjectList.reset((static_cast<ArrayList*>(pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS))));
236 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
241 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_NOTES))));
242 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_NOTES))));
244 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
249 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_NICKNAMES))));
250 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_NICKNAMES))));
252 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
257 pCurrentObjectList.reset((static_cast<ArrayList*>(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS))));
258 pRhsObjectList.reset((static_cast<ArrayList*>( pRhs->GetValuesN(USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS))));
260 if (!pCurrentObjectList->Equals(*(pRhsObjectList.get())))
269 _UserProfileImpl::GetHashCode(void) const
272 std::unique_ptr<IList, AllElementsDeleter> pMultiPropertyList(null);
274 //calculate single value properties
275 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_FIRST_NAME).GetHashCode();
276 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_LAST_NAME).GetHashCode();
277 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_MIDDLE_NAME).GetHashCode();
278 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_NAME_PREFIX).GetHashCode();
279 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_NAME_SUFFIX).GetHashCode();
280 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME).GetHashCode();
281 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME).GetHashCode();
282 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetValue(USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME).GetHashCode();
283 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ this->GetThumbnailPath().GetHashCode();
285 //calculate multi value properties
286 PhoneNumber* pPhoneNumber = null;
287 pMultiPropertyList = std::unique_ptr<IList, AllElementsDeleter> (this->GetValuesN(USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS));
288 std::unique_ptr<IEnumerator> pEnum(pMultiPropertyList->GetEnumeratorN());
289 while (pEnum->MoveNext() == E_SUCCESS)
291 pPhoneNumber = static_cast<PhoneNumber*>(pEnum->GetCurrent());
292 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pPhoneNumber->GetHashCode();
295 Email* pEmail = null;
296 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_EMAILS));
297 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
298 while (pEnum->MoveNext() == E_SUCCESS)
300 pEmail = static_cast<Email*>(pEnum->GetCurrent());
301 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pEmail->GetHashCode();
305 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_URLS));
306 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
307 while (pEnum->MoveNext() == E_SUCCESS)
309 pUrl = static_cast<Url*>(pEnum->GetCurrent());
310 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pUrl->GetHashCode();
313 Address* pAddress = null;
314 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_ADDRESSES));
315 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
316 while (pEnum->MoveNext() == E_SUCCESS)
318 pAddress = static_cast<Address*>(pEnum->GetCurrent());
319 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pAddress->GetHashCode();
322 ImAddress* pImAddress = null;
323 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_IMADDRESSES));
324 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
325 while (pEnum->MoveNext() == E_SUCCESS)
327 pImAddress = static_cast<ImAddress*>(pEnum->GetCurrent());
328 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pImAddress->GetHashCode();
331 ContactEvent* pEvent = null;
332 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_EVENTS));
333 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
334 while (pEnum->MoveNext() == E_SUCCESS)
336 pEvent = static_cast<ContactEvent*>(pEnum->GetCurrent());
337 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pEvent->GetHashCode();
340 Organization* pOrganization = null;
341 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS));
342 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
343 while (pEnum->MoveNext() == E_SUCCESS)
345 pOrganization = static_cast<Organization*>(pEnum->GetCurrent());
346 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pOrganization->GetHashCode();
349 String* pNote = null;
350 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_NOTES));
351 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
352 while (pEnum->MoveNext() == E_SUCCESS)
354 pNote = static_cast<String*>(pEnum->GetCurrent());
355 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pNote->GetHashCode();
358 String* pNickname = null;
359 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_NICKNAMES));
360 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
361 while (pEnum->MoveNext() == E_SUCCESS)
363 pNickname = static_cast<String*>(pEnum->GetCurrent());
364 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pNickname->GetHashCode();
367 Relationship* pRelationship = null;
368 pMultiPropertyList.reset(this->GetValuesN(USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS));
369 pEnum.reset(pMultiPropertyList->GetEnumeratorN());
370 while (pEnum->MoveNext() == E_SUCCESS)
372 pRelationship = static_cast<Relationship*>(pEnum->GetCurrent());
373 hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ pRelationship->GetHashCode();
380 _UserProfileImpl::GetThumbnailPath(void) const
382 unsigned int count = 0;
384 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.image, &count);
390 char* pCharValue = null;
391 contacts_record_h imageHandle = null;
393 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.image, 0, &imageHandle);
394 contacts_record_get_str_p(imageHandle, _contacts_image.path, &pCharValue);
396 return String(pCharValue);
400 _UserProfileImpl::SetThumbnail(const String& filePath)
402 unsigned int count = 0;
403 contacts_record_h imageHandle = null;
405 bool fileExist = true;
407 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.image, &count);
410 errCode = contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.image, 0, &imageHandle);
411 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
412 "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
414 if (!filePath.IsEmpty())
416 fileExist = File::IsFileExist(filePath);
417 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, E_INVALID_ARG, E_INVALID_ARG,
418 "[%s] Invalid file path.", GetErrorMessage(E_INVALID_ARG));
419 SysTryReturn(NID_SCL, fileExist != false, E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
420 "[%s] The specified file is not found.", GetErrorMessage(E_FILE_NOT_FOUND));
422 std::unique_ptr<char[]> pCharArray( _StringConverter::CopyToCharArrayN(filePath));
423 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
425 errCode = contacts_record_set_str(imageHandle, _contacts_image.path, pCharArray.get());
426 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
427 "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
431 errCode = contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.image, imageHandle);
432 contacts_record_destroy(imageHandle, true);
433 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
434 "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
439 if (!filePath.IsEmpty())
441 fileExist = File::IsFileExist(filePath);
442 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, E_INVALID_ARG, E_INVALID_ARG,
443 "[%s] Invalid file path.", GetErrorMessage(E_INVALID_ARG));
444 SysTryReturn(NID_SCL, fileExist != false, E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
445 "[%s] The specified file is not found.", GetErrorMessage(E_FILE_NOT_FOUND));
447 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(filePath));
448 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
450 errCode = contacts_record_create(_contacts_image._uri, &imageHandle);
451 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
452 "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
454 errCode = contacts_record_set_str(imageHandle, _contacts_image.path, pCharArray.get());
455 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
456 "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
458 errCode = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.image, imageHandle);
459 SysTryReturn(NID_SCL, errCode != CONTACTS_ERROR_INVALID_PARAMETER, E_SYSTEM, E_SYSTEM,
460 "[%s] An Invalid Paramenter has been passed", GetErrorMessage(E_SYSTEM));
469 _UserProfileImpl::SetValue(UserProfilePropertyId id, const String& value)
471 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));
473 int ret = CONTACTS_ERROR_NONE;
474 unsigned int count = 0;
478 case USER_PROFILE_PROPERTY_ID_FIRST_NAME:
480 contacts_record_h nameHandle = null;
481 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
485 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
487 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
488 contacts_record_set_str(nameHandle, _contacts_name.first, pCharArray.get());
490 if (value.IsEmpty() && IsEmptyName(nameHandle))
492 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
493 contacts_record_destroy(nameHandle, true);
498 if (!value.IsEmpty())
500 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
501 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
503 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
504 contacts_record_set_str(nameHandle, _contacts_name.first, pCharArray.get());
506 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
512 case USER_PROFILE_PROPERTY_ID_MIDDLE_NAME:
514 contacts_record_h nameHandle = null;
515 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
519 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
521 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
522 ret = contacts_record_set_str(nameHandle, _contacts_name.addition, pCharArray.get());
524 if (value.IsEmpty() && IsEmptyName(nameHandle))
526 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
527 contacts_record_destroy(nameHandle, true);
532 if (!value.IsEmpty())
534 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
535 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
537 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
538 contacts_record_set_str(nameHandle, _contacts_name.addition, pCharArray.get());
540 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
548 case USER_PROFILE_PROPERTY_ID_LAST_NAME:
550 contacts_record_h nameHandle = null;
551 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
555 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
557 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
558 contacts_record_set_str(nameHandle, _contacts_name.last, pCharArray.get());
560 if (value.IsEmpty() && IsEmptyName(nameHandle))
562 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
563 contacts_record_destroy(nameHandle, true);
568 if (!value.IsEmpty())
570 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
571 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
573 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
574 contacts_record_set_str(nameHandle, _contacts_name.last, pCharArray.get());
576 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
583 case USER_PROFILE_PROPERTY_ID_NAME_SUFFIX:
585 contacts_record_h nameHandle = null;
586 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
590 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
592 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
593 contacts_record_set_str(nameHandle, _contacts_name.suffix, pCharArray.get());
595 if (value.IsEmpty() && IsEmptyName(nameHandle))
597 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
598 contacts_record_destroy(nameHandle, true);
604 if (!value.IsEmpty())
606 contacts_record_create(_contacts_name._uri, &nameHandle);
607 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
609 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
610 contacts_record_set_str(nameHandle, _contacts_name.suffix, pCharArray.get());
612 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
620 case USER_PROFILE_PROPERTY_ID_NAME_PREFIX:
622 contacts_record_h nameHandle = null;
623 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
627 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
629 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
630 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
632 if (value.IsEmpty() && IsEmptyName(nameHandle))
634 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
635 contacts_record_destroy(nameHandle, true);
640 if (!value.IsEmpty())
642 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
643 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
645 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
646 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
648 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
656 case USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME:
658 contacts_record_h nameHandle = null;
659 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
663 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
665 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
666 contacts_record_set_str(nameHandle, _contacts_name.phonetic_first, pCharArray.get());
668 if (value.IsEmpty() && IsEmptyName(nameHandle))
670 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
671 contacts_record_destroy(nameHandle, true);
676 if (!value.IsEmpty())
678 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
679 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
681 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
682 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
684 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
692 case USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME:
694 contacts_record_h nameHandle = null;
695 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
699 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
701 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
702 contacts_record_set_str(nameHandle, _contacts_name.phonetic_last, pCharArray.get());
704 if (value.IsEmpty() && IsEmptyName(nameHandle))
706 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
707 contacts_record_destroy(nameHandle, true);
712 if (!value.IsEmpty())
714 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
715 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
717 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
718 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
720 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
728 case USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
730 contacts_record_h nameHandle = null;
731 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
735 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
737 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
738 contacts_record_set_str(nameHandle, _contacts_name.phonetic_middle, pCharArray.get());
740 if (value.IsEmpty() && IsEmptyName(nameHandle))
742 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
743 contacts_record_destroy(nameHandle, true);
748 if (!value.IsEmpty())
750 ret = contacts_record_create(_contacts_name._uri, &nameHandle);
751 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
753 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(value));
754 contacts_record_set_str(nameHandle, _contacts_name.prefix, pCharArray.get());
756 contacts_record_add_child_record(__profileHandle, _contacts_my_profile.name, nameHandle);
765 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
766 return E_INVALID_ARG;
773 _UserProfileImpl::GetValue(UserProfilePropertyId id) const
775 unsigned int count = 0;
776 char* pCharValue = null;
781 case USER_PROFILE_PROPERTY_ID_FIRST_NAME:
783 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
786 contacts_record_h nameHandle = null;
788 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
789 contacts_record_get_str_p(nameHandle, _contacts_name.first, &pCharValue);
795 case USER_PROFILE_PROPERTY_ID_LAST_NAME:
797 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
800 contacts_record_h nameHandle = null;
802 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
803 contacts_record_get_str_p(nameHandle, _contacts_name.last, &pCharValue);
809 case USER_PROFILE_PROPERTY_ID_MIDDLE_NAME:
811 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
814 contacts_record_h nameHandle = null;
816 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
817 contacts_record_get_str_p(nameHandle, _contacts_name.addition, &pCharValue);
823 case USER_PROFILE_PROPERTY_ID_NAME_PREFIX:
825 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
828 contacts_record_h nameHandle = null;
830 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
831 contacts_record_get_str_p(nameHandle, _contacts_name.prefix, &pCharValue);
837 case USER_PROFILE_PROPERTY_ID_NAME_SUFFIX:
839 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
842 contacts_record_h nameHandle = null;
844 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
845 contacts_record_get_str_p(nameHandle, _contacts_name.suffix, &pCharValue);
851 case USER_PROFILE_PROPERTY_ID_DISPLAY_NAME:
852 contacts_record_get_str_p(__profileHandle, _contacts_my_profile.display_name, &pCharValue);
855 case USER_PROFILE_PROPERTY_ID_PHONETIC_FIRST_NAME:
857 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
860 contacts_record_h nameHandle = null;
862 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
863 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_first, &pCharValue);
869 case USER_PROFILE_PROPERTY_ID_PHONETIC_LAST_NAME:
871 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
874 contacts_record_h nameHandle = null;
876 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
877 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_last, &pCharValue);
883 case USER_PROFILE_PROPERTY_ID_PHONETIC_MIDDLE_NAME:
885 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
888 contacts_record_h nameHandle = null;
890 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.name, 0, &nameHandle);
891 contacts_record_get_str_p(nameHandle, _contacts_name.phonetic_middle, &pCharValue);
899 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d", GetErrorMessage(E_INVALID_ARG), id);
907 _UserProfileImpl::SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber)
909 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);
910 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));
912 unsigned int count = 0;
913 contacts_record_h recordHandle = null;
918 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.number, &count);
919 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);
921 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.number, index, &recordHandle);
923 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetLabel();
925 switch (_PhoneNumberImpl::GetInstance(phoneNumber)->GetType())
927 case PHONENUMBER_TYPE_HOME:
928 type = CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE;
930 case PHONENUMBER_TYPE_WORK:
931 type = CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE;
933 case PHONENUMBER_TYPE_MOBILE:
934 type = CONTACTS_NUMBER_TYPE_CELL;
936 case PHONENUMBER_TYPE_HOME_FAX:
937 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME;
939 case PHONENUMBER_TYPE_WORK_FAX:
940 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK;
942 case PHONENUMBER_TYPE_PAGER:
943 type = CONTACTS_NUMBER_TYPE_PAGER;
945 case PHONENUMBER_TYPE_CUSTOM:
946 type = CONTACTS_NUMBER_TYPE_CUSTOM;
948 case PHONENUMBER_TYPE_ASSISTANT:
949 type = CONTACTS_NUMBER_TYPE_ASSISTANT;
951 case PHONENUMBER_TYPE_OTHER:
952 contacts_record_get_int(recordHandle, _contacts_number.type, &oriType);
954 if (oriType == (CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE)
955 || oriType == (CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE)
956 || oriType == CONTACTS_NUMBER_TYPE_CELL
957 || oriType == (CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME)
958 || oriType == (CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK)
959 || oriType == CONTACTS_NUMBER_TYPE_PAGER
960 || oriType == CONTACTS_NUMBER_TYPE_CUSTOM)
962 type = CONTACTS_NUMBER_TYPE_OTHER;
970 type = CONTACTS_NUMBER_TYPE_OTHER;
975 contacts_record_set_int(recordHandle, _contacts_number.type, type);
978 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
979 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
981 contacts_record_set_str(recordHandle, _contacts_number.label, pCharArray.get());
984 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetPhoneNumber();
985 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
986 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
988 contacts_record_set_str(recordHandle, _contacts_number.number, pCharArray.get());
995 _UserProfileImpl::SetEmailAt(int index, const Email& email)
997 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);
998 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));
1000 unsigned int count = 0;
1001 contacts_record_h emailHandle = null;
1005 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.email, &count);
1006 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);
1008 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.email, index, &emailHandle);
1010 stringValue = _EmailImpl::GetInstance(email)->GetLabel();
1012 switch (_EmailImpl::GetInstance(email)->GetType())
1014 case EMAIL_TYPE_PERSONAL:
1015 type = CONTACTS_EMAIL_TYPE_HOME;
1017 case EMAIL_TYPE_WORK:
1018 type = CONTACTS_EMAIL_TYPE_WORK;
1020 case EMAIL_TYPE_CUSTOM:
1021 type = CONTACTS_EMAIL_TYPE_CUSTOM;
1023 case EMAIL_TYPE_MOBILE:
1024 type = CONTACTS_EMAIL_TYPE_MOBILE;
1026 case EMAIL_TYPE_OTHER:
1029 type = CONTACTS_EMAIL_TYPE_OTHER;
1034 contacts_record_set_int(emailHandle, _contacts_email.type, type);
1037 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1038 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1040 contacts_record_set_str(emailHandle, _contacts_email.label, pCharArray.get());
1043 stringValue = _EmailImpl::GetInstance(email)->GetEmail();
1044 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1045 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1047 contacts_record_set_str(emailHandle, _contacts_email.email, pCharArray.get());
1053 _UserProfileImpl::SetUrlAt(int index, const Url& url)
1055 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);
1056 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));
1057 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1059 unsigned int count = 0;
1060 contacts_record_h urlHandle = null;
1064 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.url, &count);
1065 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);
1067 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.url, index, &urlHandle);
1070 stringValue = _UrlImpl::GetInstance(url)->GetLabel();
1072 switch (_UrlImpl::GetInstance(url)->GetType())
1074 case URL_TYPE_PERSONAL:
1075 type = CONTACTS_URL_TYPE_HOME;
1078 type = CONTACTS_URL_TYPE_WORK;
1080 case URL_TYPE_CUSTOM:
1081 type = CONTACTS_URL_TYPE_CUSTOM;
1083 case URL_TYPE_OTHER:
1086 type = CONTACTS_URL_TYPE_OTHER;
1091 contacts_record_set_int(urlHandle, _contacts_url.type, type);
1094 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1095 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1097 contacts_record_set_str(urlHandle, _contacts_url.label, pCharArray.get());
1100 stringValue = _UrlImpl::GetInstance(url)->GetUrl();
1101 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1102 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1104 contacts_record_set_str(urlHandle, _contacts_url.url, pCharArray.get());
1111 _UserProfileImpl::SetAddressAt(int index, const Address& address)
1113 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);
1114 SysTryReturn(NID_SCL,
1115 !address.GetCity().IsEmpty() ||
1116 !address.GetCountry().IsEmpty() ||
1117 !address.GetExtended().IsEmpty() ||
1118 !address.GetPostalCode().IsEmpty() ||
1119 !address.GetPostOfficeBoxNumber().IsEmpty() ||
1120 !address.GetState().IsEmpty() ||
1121 !address.GetStreet().IsEmpty(),
1122 E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The address is empty.", GetErrorMessage(E_INVALID_ARG));
1124 unsigned int count = 0;
1125 contacts_record_h addressHandle = null;
1129 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.address, &count);
1130 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);
1132 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.address, index, &addressHandle);
1134 stringValue = _AddressImpl::GetInstance(address)->GetLabel();
1136 switch (_AddressImpl::GetInstance(address)->GetType())
1138 case ADDRESS_TYPE_HOME:
1139 type = CONTACTS_ADDRESS_TYPE_HOME;
1141 case ADDRESS_TYPE_WORK:
1142 type = CONTACTS_ADDRESS_TYPE_WORK;
1144 case ADDRESS_TYPE_CUSTOM:
1145 type = CONTACTS_ADDRESS_TYPE_CUSTOM;
1147 case ADDRESS_TYPE_OTHER:
1150 type = CONTACTS_ADDRESS_TYPE_OTHER;
1155 contacts_record_set_int(addressHandle, _contacts_address.type, type);
1158 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1159 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1161 contacts_record_set_str(addressHandle, _contacts_address.label, pCharArray.get());
1164 stringValue = _AddressImpl::GetInstance(address)->GetCity();
1165 if (!stringValue.IsEmpty())
1167 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1168 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1170 contacts_record_set_str(addressHandle, _contacts_address.locality, pCharArray.get());
1174 contacts_record_set_str(addressHandle, _contacts_address.locality, null);
1177 stringValue = _AddressImpl::GetInstance(address)->GetCountry();
1178 if (!stringValue.IsEmpty())
1180 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1181 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1183 contacts_record_set_str(addressHandle, _contacts_address.country, pCharArray.get());
1187 contacts_record_set_str(addressHandle, _contacts_address.country, null);
1190 stringValue = _AddressImpl::GetInstance(address)->GetExtended();
1191 if (!stringValue.IsEmpty())
1193 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1194 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1196 contacts_record_set_str(addressHandle, _contacts_address.extended, pCharArray.get());
1200 contacts_record_set_str(addressHandle, _contacts_address.extended, null);
1203 stringValue = _AddressImpl::GetInstance(address)->GetPostalCode();
1204 if (!stringValue.IsEmpty())
1206 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1207 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1209 contacts_record_set_str(addressHandle, _contacts_address.postal_code, pCharArray.get());
1213 contacts_record_set_str(addressHandle, _contacts_address.postal_code, null);
1216 stringValue = _AddressImpl::GetInstance(address)->GetPostOfficeBoxNumber();
1217 if (!stringValue.IsEmpty())
1219 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1220 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1222 contacts_record_set_str(addressHandle, _contacts_address.postbox, pCharArray.get());
1226 contacts_record_set_str(addressHandle, _contacts_address.postbox, null);
1229 stringValue = _AddressImpl::GetInstance(address)->GetState();
1230 if (!stringValue.IsEmpty())
1232 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1233 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1235 contacts_record_set_str(addressHandle, _contacts_address.region, pCharArray.get());
1239 contacts_record_set_str(addressHandle, _contacts_address.region, null);
1242 stringValue = _AddressImpl::GetInstance(address)->GetStreet();
1243 if (!stringValue.IsEmpty())
1245 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1246 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1248 contacts_record_set_str(addressHandle, _contacts_address.street, pCharArray.get());
1252 contacts_record_set_str(addressHandle, _contacts_address.street, null);
1259 _UserProfileImpl::SetImAddressAt(int index, const ImAddress& imAddress)
1261 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);
1262 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));
1263 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1265 unsigned int count = 0;
1266 contacts_record_h messengerHandle = null;
1269 std::unique_ptr<char[]> pCharArray(null);
1271 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.messenger, &count);
1272 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);
1274 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.messenger, index, &messengerHandle);
1276 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetServiceProviderName();
1278 if (stringValue == IM_ADDRESS_GOOGLE_TALK)
1280 type = CONTACTS_MESSENGER_TYPE_GOOGLE;
1282 else if (stringValue == IM_ADDRESS_MSN)
1284 type = CONTACTS_MESSENGER_TYPE_WLM;
1286 else if (stringValue == IM_ADDRESS_ICQ)
1288 type = CONTACTS_MESSENGER_TYPE_ICQ;
1290 else if (stringValue == IM_ADDRESS_AIM)
1292 type = CONTACTS_MESSENGER_TYPE_AIM;
1294 else if (stringValue == IM_ADDRESS_YAHOO)
1296 type = CONTACTS_MESSENGER_TYPE_YAHOO;
1298 else if (stringValue == IM_ADDRESS_QQ)
1300 type = CONTACTS_MESSENGER_TYPE_QQ;
1302 else if (stringValue == IM_ADDRESS_SKYPE)
1304 type = CONTACTS_MESSENGER_TYPE_SKYPE;
1306 else if (stringValue == IM_ADDRESS_JABBER)
1308 type = CONTACTS_MESSENGER_TYPE_JABBER;
1312 type = CONTACTS_MESSENGER_TYPE_CUSTOM;
1315 contacts_record_set_int(messengerHandle, _contacts_messenger.type, type);
1316 if (type == CONTACTS_MESSENGER_TYPE_CUSTOM)
1318 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1319 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1321 contacts_record_set_str(messengerHandle, _contacts_messenger.label, pCharArray.get());
1324 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetImAddress();
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.im_id, pCharArray.get());
1335 _UserProfileImpl::SetNoteAt(int index, const String& note)
1337 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);
1338 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));
1339 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1341 unsigned int count = 0;
1342 contacts_record_h noteHandle = null;
1344 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.note, &count);
1345 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);
1347 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.note, index, ¬eHandle);
1349 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(note));
1350 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1352 contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
1358 _UserProfileImpl::SetNicknameAt(int index, const String& nickname)
1360 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);
1361 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));
1362 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1364 unsigned int count = 0;
1365 contacts_record_h nicknameHandle = null;
1367 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.nickname, &count);
1368 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);
1370 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.nickname, index, &nicknameHandle);
1372 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(nickname));
1373 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1375 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
1381 _UserProfileImpl::SetEventAt(int index, const ContactEvent& event)
1383 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);
1384 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1388 unsigned int count = 0;
1390 contacts_record_h eventHandle = null;
1392 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.event, &count);
1393 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);
1395 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.event, index, &eventHandle);
1397 switch (event.GetType())
1399 case CONTACT_EVENT_TYPE_ANNIVERSARY:
1400 type = CONTACTS_EVENT_TYPE_ANNIVERSARY;
1402 case CONTACT_EVENT_TYPE_BIRTHDAY:
1403 type = CONTACTS_EVENT_TYPE_BIRTH;
1405 case CONTACT_EVENT_TYPE_CUSTOM:
1406 type = CONTACTS_EVENT_TYPE_CUSTOM;
1408 case CONTACT_EVENT_TYPE_OTHER:
1411 type = CONTACTS_EVENT_TYPE_OTHER;
1416 contacts_record_set_int(eventHandle, _contacts_event.type, type);
1419 stringValue = event.GetLabel();
1421 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1422 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1424 contacts_record_set_str(eventHandle, _contacts_event.label, pCharArray.get());
1427 DateTime dateValue = event.GetDate();
1428 intValue = dateValue.GetYear()*10000 + dateValue.GetMonth()*100 + dateValue.GetDay();
1429 contacts_record_set_int(eventHandle, _contacts_event.date, intValue);
1436 _UserProfileImpl::SetOrganizationAt(int index, const Organization& organization)
1438 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);
1439 SysTryReturn(NID_SCL
1440 , !organization.GetName().IsEmpty() ||
1441 !organization.GetJobTitle().IsEmpty() ||
1442 !organization.GetDepartment().IsEmpty() ||
1443 !organization.GetRole().IsEmpty() ||
1444 !organization.GetAgent().IsEmpty() ||
1445 !organization.GetLocation().IsEmpty() ||
1446 !organization.GetDescription().IsEmpty() ||
1447 !organization.GetPhoneticName().IsEmpty() ||
1448 !organization.GetLogoPath().IsEmpty()
1449 ,E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The organization is empty.", GetErrorMessage(E_INVALID_ARG));
1451 unsigned int count = 0;
1452 contacts_record_h organizationHandle = null;
1454 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.company, &count);
1455 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);
1458 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.company, index, &organizationHandle);
1461 String stringValue = organization.GetName();
1462 if (!stringValue.IsEmpty())
1464 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1465 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1467 contacts_record_set_str(organizationHandle, _contacts_company.name, pCharArray.get());
1471 contacts_record_set_str(organizationHandle, _contacts_company.name, null);
1475 stringValue = organization.GetJobTitle();
1476 if (!stringValue.IsEmpty())
1478 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1479 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1481 contacts_record_set_str(organizationHandle, _contacts_company.job_title, pCharArray.get());
1485 contacts_record_set_str(organizationHandle, _contacts_company.job_title, null);
1489 stringValue = organization.GetDepartment();
1490 if (!stringValue.IsEmpty())
1492 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1493 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1495 contacts_record_set_str(organizationHandle, _contacts_company.department, pCharArray.get());
1499 contacts_record_set_str(organizationHandle, _contacts_company.department, null);
1503 stringValue = organization.GetRole();
1504 if (!stringValue.IsEmpty())
1506 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1507 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1509 contacts_record_set_str(organizationHandle, _contacts_company.role, pCharArray.get());
1513 contacts_record_set_str(organizationHandle, _contacts_company.role, null);
1517 stringValue = organization.GetAgent();
1518 if (!stringValue.IsEmpty())
1520 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1521 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1523 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, pCharArray.get());
1527 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, null);
1533 switch (organization.GetType())
1535 case ORGANIZATION_TYPE_WORK:
1536 type = CONTACTS_COMPANY_TYPE_WORK;
1538 case ORGANIZATION_TYPE_CUSTOM:
1539 type = CONTACTS_COMPANY_TYPE_CUSTOM;
1541 case ORGANIZATION_TYPE_OTHER:
1544 type = CONTACTS_COMPANY_TYPE_OTHER;
1547 contacts_record_set_int(organizationHandle, _contacts_company.type, type);
1550 stringValue = organization.GetLabel();
1551 if (!stringValue.IsEmpty())
1553 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1554 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1556 contacts_record_set_str(organizationHandle, _contacts_company.label, pCharArray.get());
1560 contacts_record_set_str(organizationHandle, _contacts_company.label, null);
1564 stringValue = organization.GetLocation();
1565 if (!stringValue.IsEmpty())
1567 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1568 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1570 contacts_record_set_str(organizationHandle, _contacts_company.location, pCharArray.get());
1574 contacts_record_set_str(organizationHandle, _contacts_company.location, null);
1578 stringValue = organization.GetDescription();
1579 if (!stringValue.IsEmpty())
1581 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1582 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1584 contacts_record_set_str(organizationHandle, _contacts_company.description, pCharArray.get());
1588 contacts_record_set_str(organizationHandle, _contacts_company.description, null);
1592 stringValue = organization.GetPhoneticName();
1593 if (!stringValue.IsEmpty())
1595 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1596 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1598 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, pCharArray.get());
1602 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, null);
1606 if (_OrganizationImpl::GetInstance(organization)->IsLogoPathChanged() == true)
1608 stringValue = organization.GetLogoPath();
1609 if (!stringValue.IsEmpty())
1611 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1612 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1614 contacts_record_set_str(organizationHandle, _contacts_company.logo, pCharArray.get());
1618 contacts_record_set_str(organizationHandle, _contacts_company.logo, null);
1626 _UserProfileImpl::SetRelationshipAt(int index, const Relationship& relationship)
1628 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);
1629 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));
1630 //SysTryReturn(NID_SCL, !__isRemoved || Invalidate() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1633 unsigned int count = 0;
1634 contacts_record_h relationshipHandle = null;
1636 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.relationship, &count);
1637 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);
1639 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.relationship, index, &relationshipHandle);
1641 switch (relationship.GetType())
1643 case CONTACT_RELATIONSHIP_TYPE_ASSISTANT:
1644 intValue = CONTACTS_RELATIONSHIP_TYPE_ASSISTANT;
1646 case CONTACT_RELATIONSHIP_TYPE_BROTHER:
1647 intValue = CONTACTS_RELATIONSHIP_TYPE_BROTHER;
1649 case CONTACT_RELATIONSHIP_TYPE_CHILD:
1650 intValue = CONTACTS_RELATIONSHIP_TYPE_CHILD;
1652 case CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
1653 intValue = CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER;
1655 case CONTACT_RELATIONSHIP_TYPE_FATHER:
1656 intValue = CONTACTS_RELATIONSHIP_TYPE_FATHER;
1658 case CONTACT_RELATIONSHIP_TYPE_FRIEND:
1659 intValue = CONTACTS_RELATIONSHIP_TYPE_FRIEND;
1661 case CONTACT_RELATIONSHIP_TYPE_MANAGER:
1662 intValue = CONTACTS_RELATIONSHIP_TYPE_MANAGER;
1664 case CONTACT_RELATIONSHIP_TYPE_MOTHER:
1665 intValue = CONTACTS_RELATIONSHIP_TYPE_MOTHER;
1667 case CONTACT_RELATIONSHIP_TYPE_PARENT:
1668 intValue = CONTACTS_RELATIONSHIP_TYPE_PARENT;
1670 case CONTACT_RELATIONSHIP_TYPE_PARTNER:
1671 intValue = CONTACTS_RELATIONSHIP_TYPE_PARTNER;
1673 case CONTACT_RELATIONSHIP_TYPE_REFERRED_BY:
1674 intValue = CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY;
1676 case CONTACT_RELATIONSHIP_TYPE_RELATIVE:
1677 intValue = CONTACTS_RELATIONSHIP_TYPE_RELATIVE;
1679 case CONTACT_RELATIONSHIP_TYPE_SISTER:
1680 intValue = CONTACTS_RELATIONSHIP_TYPE_SISTER;
1682 case CONTACT_RELATIONSHIP_TYPE_SPOUSE:
1683 intValue = CONTACTS_RELATIONSHIP_TYPE_SPOUSE;
1685 case CONTACT_RELATIONSHIP_TYPE_CUSTOM:
1686 intValue = CONTACTS_RELATIONSHIP_TYPE_CUSTOM;
1689 intValue = CONTACTS_RELATIONSHIP_TYPE_OTHER;
1694 contacts_record_set_int(relationshipHandle, _contacts_relationship.type, intValue);
1697 String stringValue = relationship.GetLabel();
1698 if (!stringValue.IsEmpty())
1700 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1701 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1703 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, pCharArray.get());
1707 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, null);
1711 stringValue = relationship.GetRelativeName();
1712 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1713 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1715 contacts_record_set_str(relationshipHandle, _contacts_relationship.name, pCharArray.get());
1721 _UserProfileImpl::GetAddressbookId(void) const
1723 int addressbookId = 0;
1725 contacts_record_get_int(__profileHandle, _contacts_my_profile.address_book_id, &addressbookId);
1727 return addressbookId;
1731 _UserProfileImpl::GetValuesN(const UserProfileMultiPropertyId id) const
1733 IList* pList = null;
1739 case USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS:
1740 pList = GetPhoneNumbersN();
1743 case USER_PROFILE_MPROPERTY_ID_EMAILS:
1744 pList = GetEmailsN();
1747 case USER_PROFILE_MPROPERTY_ID_URLS:
1751 case USER_PROFILE_MPROPERTY_ID_ADDRESSES:
1752 pList = GetAddressesN();
1755 case USER_PROFILE_MPROPERTY_ID_IMADDRESSES:
1756 pList = GetImAddressesN();
1759 case USER_PROFILE_MPROPERTY_ID_EVENTS:
1760 pList = GetEventsN();
1763 case USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS:
1764 pList = GetOrganizationsN();
1767 case USER_PROFILE_MPROPERTY_ID_NOTES:
1768 pList = GetNotesN();
1771 case CONTACT_MPROPERTY_ID_NICKNAMES:
1772 pList = GetNicknamesN();
1775 case USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS:
1776 pList = GetRelationshipsN();
1781 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
1785 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1792 _UserProfileImpl::AddPhoneNumber(const PhoneNumber& phoneNumber)
1794 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));
1798 contacts_record_h numberHandle = null;
1800 int ret = contacts_record_create(_contacts_number._uri, &numberHandle);
1801 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1803 __ContactsRecordHandle recordHandle(numberHandle);
1805 switch (_PhoneNumberImpl::GetInstance(phoneNumber)->GetType())
1807 case PHONENUMBER_TYPE_HOME:
1808 type = CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE;
1810 case PHONENUMBER_TYPE_WORK:
1811 type = CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE;
1813 case PHONENUMBER_TYPE_MOBILE:
1814 type = CONTACTS_NUMBER_TYPE_CELL;
1816 case PHONENUMBER_TYPE_HOME_FAX:
1817 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME;
1819 case PHONENUMBER_TYPE_WORK_FAX:
1820 type = CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK;
1822 case PHONENUMBER_TYPE_PAGER:
1823 type = CONTACTS_NUMBER_TYPE_PAGER;
1825 case PHONENUMBER_TYPE_CUSTOM:
1826 type = CONTACTS_NUMBER_TYPE_CUSTOM;
1828 case PHONENUMBER_TYPE_ASSISTANT:
1829 type = CONTACTS_NUMBER_TYPE_ASSISTANT;
1831 case PHONENUMBER_TYPE_OTHER:
1833 type = CONTACTS_NUMBER_TYPE_OTHER;
1837 contacts_record_set_int(numberHandle, _contacts_number.type, type);
1839 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetLabel();
1841 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1842 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1844 contacts_record_set_str(numberHandle, _contacts_number.label, pCharArray.get());
1846 stringValue = _PhoneNumberImpl::GetInstance(phoneNumber)->GetPhoneNumber();
1847 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1848 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1850 contacts_record_set_str(numberHandle, _contacts_number.number, pCharArray.get());
1852 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.number, numberHandle);
1853 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1855 recordHandle.Release();
1862 _UserProfileImpl::AddNickname(const String& nickname)
1865 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));
1867 contacts_record_h nicknameHandle = null;
1869 int ret = contacts_record_create(_contacts_nickname._uri, &nicknameHandle);
1870 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1872 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(nickname));
1873 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1875 contacts_record_set_str(nicknameHandle, _contacts_nickname.name, pCharArray.get());
1877 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.nickname, nicknameHandle);
1878 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1885 _UserProfileImpl::AddNote(const String& note)
1887 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));
1889 contacts_record_h noteHandle = null;
1891 int ret = contacts_record_create(_contacts_note._uri, ¬eHandle);
1892 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1894 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(note));
1895 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1897 contacts_record_set_str(noteHandle, _contacts_note.note, pCharArray.get());
1899 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.note, noteHandle);
1900 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1907 _UserProfileImpl::AddEmail(const Email& email)
1910 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));
1914 contacts_record_h emailHandle = null;
1916 int ret = contacts_record_create(_contacts_email._uri, &emailHandle);
1917 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1919 __ContactsRecordHandle recordHandle(emailHandle);
1921 switch (_EmailImpl::GetInstance(email)->GetType())
1923 case EMAIL_TYPE_PERSONAL:
1924 type = CONTACTS_EMAIL_TYPE_HOME;
1926 case EMAIL_TYPE_WORK:
1927 type = CONTACTS_EMAIL_TYPE_WORK;
1929 case EMAIL_TYPE_CUSTOM:
1930 type = CONTACTS_EMAIL_TYPE_CUSTOM;
1932 case EMAIL_TYPE_MOBILE:
1933 type = CONTACTS_EMAIL_TYPE_MOBILE;
1935 case EMAIL_TYPE_OTHER:
1938 type = CONTACTS_EMAIL_TYPE_OTHER;
1942 contacts_record_set_int(emailHandle, _contacts_email.type, type);
1944 stringValue = _EmailImpl::GetInstance(email)->GetLabel();
1945 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
1946 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1948 contacts_record_set_str(emailHandle, _contacts_email.label, pCharArray.get());
1950 stringValue = _EmailImpl::GetInstance(email)->GetEmail();
1951 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
1952 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1954 contacts_record_set_str(emailHandle, _contacts_email.email, pCharArray.get());
1956 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.email, emailHandle);
1957 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1959 recordHandle.Release();
1966 _UserProfileImpl::AddUrl(const Url& url)
1968 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));
1972 contacts_record_h urlHandle = null;
1974 int ret = contacts_record_create(_contacts_url._uri, &urlHandle);
1975 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1977 __ContactsRecordHandle recordHandle(urlHandle);
1979 switch (_UrlImpl::GetInstance(url)->GetType())
1981 case URL_TYPE_PERSONAL:
1982 type = CONTACTS_URL_TYPE_HOME;
1985 type = CONTACTS_URL_TYPE_WORK;
1987 case URL_TYPE_CUSTOM:
1988 type = CONTACTS_URL_TYPE_CUSTOM;
1990 case URL_TYPE_OTHER:
1993 type = CONTACTS_URL_TYPE_OTHER;
1998 contacts_record_set_int(urlHandle, _contacts_url.type, type);
2001 stringValue = _UrlImpl::GetInstance(url)->GetLabel();
2002 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2003 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2005 contacts_record_set_str(urlHandle, _contacts_url.label, pCharArray.get());
2008 stringValue = _UrlImpl::GetInstance(url)->GetUrl();
2009 pCharArray.reset(_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.url, pCharArray.get());
2014 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.url, urlHandle);
2015 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2017 recordHandle.Release();
2024 _UserProfileImpl::AddAddress(const Address& address)
2027 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));
2031 contacts_record_h addressHandle = null;
2033 int ret = contacts_record_create(_contacts_address._uri, &addressHandle);
2034 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2036 __ContactsRecordHandle recordHandle(addressHandle);
2038 switch (_AddressImpl::GetInstance(address)->GetType())
2040 case ADDRESS_TYPE_HOME:
2041 type = CONTACTS_ADDRESS_TYPE_HOME;
2043 case ADDRESS_TYPE_WORK:
2044 type = CONTACTS_ADDRESS_TYPE_WORK;
2046 case ADDRESS_TYPE_CUSTOM:
2047 type = CONTACTS_ADDRESS_TYPE_CUSTOM;
2049 case ADDRESS_TYPE_OTHER:
2052 type = CONTACTS_ADDRESS_TYPE_OTHER;
2056 contacts_record_set_int(addressHandle, _contacts_address.type, type);
2058 stringValue = _AddressImpl::GetInstance(address)->GetLabel();
2059 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2060 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2062 contacts_record_set_str(addressHandle, _contacts_address.label, pCharArray.get());
2064 stringValue = _AddressImpl::GetInstance(address)->GetCity();
2065 if (!stringValue.IsEmpty())
2067 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2068 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2070 contacts_record_set_str(addressHandle, _contacts_address.locality, pCharArray.get());
2074 stringValue = _AddressImpl::GetInstance(address)->GetCountry();
2075 if (!stringValue.IsEmpty())
2077 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2078 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2080 contacts_record_set_str(addressHandle, _contacts_address.country, pCharArray.get());
2083 stringValue = _AddressImpl::GetInstance(address)->GetExtended();
2084 if (!stringValue.IsEmpty())
2086 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2087 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2089 contacts_record_set_str(addressHandle, _contacts_address.extended, pCharArray.get());
2092 stringValue = _AddressImpl::GetInstance(address)->GetPostalCode();
2093 if (!stringValue.IsEmpty())
2095 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2096 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2098 contacts_record_set_str(addressHandle, _contacts_address.postal_code, pCharArray.get());
2101 stringValue = _AddressImpl::GetInstance(address)->GetPostOfficeBoxNumber();
2102 if (!stringValue.IsEmpty())
2104 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2105 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2107 contacts_record_set_str(addressHandle, _contacts_address.postbox, pCharArray.get());
2110 stringValue = _AddressImpl::GetInstance(address)->GetState();
2111 if (!stringValue.IsEmpty())
2113 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2114 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2116 contacts_record_set_str(addressHandle, _contacts_address.region, pCharArray.get());
2119 stringValue = _AddressImpl::GetInstance(address)->GetStreet();
2120 if (!stringValue.IsEmpty())
2122 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2123 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2125 contacts_record_set_str(addressHandle, _contacts_address.street, pCharArray.get());
2128 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.address, addressHandle);
2129 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2131 recordHandle.Release();
2138 _UserProfileImpl::AddImAddress(const ImAddress& imAddress)
2141 SysTryReturn(NID_SCL, !imAddress.GetImAddress().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%] Invalid argument is used. The imAddress is empty.", GetErrorMessage(E_INVALID_ARG));
2145 contacts_record_h messengerHandle = null;
2147 std::unique_ptr<char[]> pCharArray(null);
2149 int ret = contacts_record_create(_contacts_messenger._uri, &messengerHandle);
2150 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2152 __ContactsRecordHandle recordHandle(messengerHandle);
2154 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetServiceProviderName();
2156 if (stringValue == IM_ADDRESS_GOOGLE_TALK)
2158 type = CONTACTS_MESSENGER_TYPE_GOOGLE;
2160 else if (stringValue == IM_ADDRESS_MSN)
2162 type = CONTACTS_MESSENGER_TYPE_WLM;
2164 else if (stringValue == IM_ADDRESS_ICQ)
2166 type = CONTACTS_MESSENGER_TYPE_ICQ;
2168 else if (stringValue == IM_ADDRESS_AIM)
2170 type = CONTACTS_MESSENGER_TYPE_AIM;
2172 else if (stringValue == IM_ADDRESS_YAHOO)
2174 type = CONTACTS_MESSENGER_TYPE_YAHOO;
2176 else if (stringValue == IM_ADDRESS_QQ)
2178 type = CONTACTS_MESSENGER_TYPE_QQ;
2180 else if (stringValue == IM_ADDRESS_SKYPE)
2182 type = CONTACTS_MESSENGER_TYPE_SKYPE;
2184 else if (stringValue == IM_ADDRESS_JABBER)
2186 type = CONTACTS_MESSENGER_TYPE_JABBER;
2190 type = CONTACTS_MESSENGER_TYPE_CUSTOM;
2193 contacts_record_set_int(messengerHandle, _contacts_messenger.type, type);
2194 if (type == CONTACTS_MESSENGER_TYPE_CUSTOM)
2196 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
2197 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2199 contacts_record_set_str(messengerHandle, _contacts_messenger.label, pCharArray.get());
2202 stringValue = _ImAddressImpl::GetInstance(imAddress)->GetImAddress();
2203 pCharArray.reset(_StringConverter::CopyToCharArrayN(stringValue));
2204 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2206 contacts_record_set_str(messengerHandle, _contacts_messenger.im_id, pCharArray.get());
2208 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.messenger, messengerHandle);
2209 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2211 recordHandle.Release();
2217 _UserProfileImpl::AddRelationship(const Relationship& relationship)
2219 SysTryReturn(NID_SCL, !relationship.GetRelativeName().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%] Invalid argument is used. The relationship is empty.", GetErrorMessage(E_INVALID_ARG));
2222 contacts_record_h relationshipHandle = null;
2224 int ret = contacts_record_create(_contacts_relationship._uri, &relationshipHandle);
2225 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2227 __ContactsRecordHandle recordHandle(relationshipHandle);
2229 switch (relationship.GetType())
2231 case CONTACT_RELATIONSHIP_TYPE_ASSISTANT:
2232 intValue = CONTACTS_RELATIONSHIP_TYPE_ASSISTANT;
2234 case CONTACT_RELATIONSHIP_TYPE_BROTHER:
2235 intValue = CONTACTS_RELATIONSHIP_TYPE_BROTHER;
2237 case CONTACT_RELATIONSHIP_TYPE_CHILD:
2238 intValue = CONTACTS_RELATIONSHIP_TYPE_CHILD;
2240 case CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
2241 intValue = CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER;
2243 case CONTACT_RELATIONSHIP_TYPE_FATHER:
2244 intValue = CONTACTS_RELATIONSHIP_TYPE_FATHER;
2246 case CONTACT_RELATIONSHIP_TYPE_FRIEND:
2247 intValue = CONTACTS_RELATIONSHIP_TYPE_FRIEND;
2249 case CONTACT_RELATIONSHIP_TYPE_MANAGER:
2250 intValue = CONTACTS_RELATIONSHIP_TYPE_MANAGER;
2252 case CONTACT_RELATIONSHIP_TYPE_MOTHER:
2253 intValue = CONTACTS_RELATIONSHIP_TYPE_MOTHER;
2255 case CONTACT_RELATIONSHIP_TYPE_PARENT:
2256 intValue = CONTACTS_RELATIONSHIP_TYPE_PARENT;
2258 case CONTACT_RELATIONSHIP_TYPE_PARTNER:
2259 intValue = CONTACTS_RELATIONSHIP_TYPE_PARTNER;
2261 case CONTACT_RELATIONSHIP_TYPE_REFERRED_BY:
2262 intValue = CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY;
2264 case CONTACT_RELATIONSHIP_TYPE_RELATIVE:
2265 intValue = CONTACTS_RELATIONSHIP_TYPE_RELATIVE;
2267 case CONTACT_RELATIONSHIP_TYPE_SISTER:
2268 intValue = CONTACTS_RELATIONSHIP_TYPE_SISTER;
2270 case CONTACT_RELATIONSHIP_TYPE_SPOUSE:
2271 intValue = CONTACTS_RELATIONSHIP_TYPE_SPOUSE;
2273 case CONTACT_RELATIONSHIP_TYPE_CUSTOM:
2274 intValue = CONTACTS_RELATIONSHIP_TYPE_CUSTOM;
2277 intValue = CONTACTS_RELATIONSHIP_TYPE_OTHER;
2282 contacts_record_set_int(relationshipHandle, _contacts_relationship.type, intValue);
2285 String stringValue = relationship.GetLabel();
2286 if (!stringValue.IsEmpty())
2288 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2289 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2291 contacts_record_set_str(relationshipHandle, _contacts_relationship.label, pCharArray.get());
2295 stringValue = relationship.GetRelativeName();
2296 if (!stringValue.IsEmpty())
2298 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2299 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2301 contacts_record_set_str(relationshipHandle, _contacts_relationship.name, pCharArray.get());
2304 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.relationship, relationshipHandle);
2305 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2307 recordHandle.Release();
2315 _UserProfileImpl::AddEvent(const ContactEvent& event)
2321 contacts_record_h eventHandle = null;
2323 int ret = contacts_record_create(_contacts_event._uri, &eventHandle);
2324 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2326 __ContactsRecordHandle recordHandle(eventHandle);
2328 switch (event.GetType())
2330 case CONTACT_EVENT_TYPE_ANNIVERSARY:
2331 type = CONTACTS_EVENT_TYPE_ANNIVERSARY;
2333 case CONTACT_EVENT_TYPE_BIRTHDAY:
2334 type = CONTACTS_EVENT_TYPE_BIRTH;
2336 case CONTACT_EVENT_TYPE_CUSTOM:
2337 type = CONTACTS_EVENT_TYPE_CUSTOM;
2339 case CONTACT_EVENT_TYPE_OTHER:
2342 type = CONTACTS_EVENT_TYPE_OTHER;
2347 contacts_record_set_int(eventHandle, _contacts_event.type, type);
2350 stringValue = event.GetLabel();
2351 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2352 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2354 contacts_record_set_str(eventHandle, _contacts_event.label, pCharArray.get());
2357 DateTime dateValue = event.GetDate();
2358 intValue = dateValue.GetYear()*10000 + dateValue.GetMonth()*100 + dateValue.GetDay();
2359 contacts_record_set_int(eventHandle, _contacts_event.date, intValue);
2361 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.event, eventHandle);
2362 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2364 recordHandle.Release();
2371 _UserProfileImpl::AddOrganization(const Organization& organization)
2373 SysTryReturn(NID_SCL
2374 , !organization.GetName().IsEmpty() ||
2375 !organization.GetJobTitle().IsEmpty() ||
2376 !organization.GetDepartment().IsEmpty() ||
2377 !organization.GetRole().IsEmpty() ||
2378 !organization.GetAgent().IsEmpty() ||
2379 !organization.GetDescription().IsEmpty() ||
2380 !organization.GetLocation().IsEmpty() ||
2381 !organization.GetPhoneticName().IsEmpty() ||
2382 !organization.GetLogoPath().IsEmpty()
2383 ,E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The organization is empty.", GetErrorMessage(E_INVALID_ARG));
2385 contacts_record_h organizationHandle = null;
2387 int ret = contacts_record_create(_contacts_company._uri, &organizationHandle);
2388 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2390 __ContactsRecordHandle recordHandle(organizationHandle);
2393 String stringValue = organization.GetName();
2394 if (!stringValue.IsEmpty())
2396 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2397 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2399 contacts_record_set_str(organizationHandle, _contacts_company.name, pCharArray.get());
2403 stringValue = organization.GetJobTitle();
2404 if (!stringValue.IsEmpty())
2406 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2407 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2409 contacts_record_set_str(organizationHandle, _contacts_company.job_title, pCharArray.get());
2413 stringValue = organization.GetDepartment();
2414 if (!stringValue.IsEmpty())
2416 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2417 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2419 contacts_record_set_str(organizationHandle, _contacts_company.department, pCharArray.get());
2423 stringValue = organization.GetRole();
2424 if (!stringValue.IsEmpty())
2426 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2427 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2429 contacts_record_set_str(organizationHandle, _contacts_company.role, pCharArray.get());
2433 stringValue = organization.GetAgent();
2434 if (!stringValue.IsEmpty())
2436 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2437 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2439 contacts_record_set_str(organizationHandle, _contacts_company.assistant_name, pCharArray.get());
2445 switch (organization.GetType())
2447 case ORGANIZATION_TYPE_WORK:
2448 type = CONTACTS_COMPANY_TYPE_WORK;
2450 case ORGANIZATION_TYPE_CUSTOM:
2451 type = CONTACTS_COMPANY_TYPE_CUSTOM;
2453 case ORGANIZATION_TYPE_OTHER:
2456 type = CONTACTS_COMPANY_TYPE_OTHER;
2460 contacts_record_set_int(organizationHandle, _contacts_company.type, type);
2463 stringValue = organization.GetLabel();
2464 if (!stringValue.IsEmpty())
2466 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2467 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2469 contacts_record_set_str(organizationHandle, _contacts_company.label, pCharArray.get());
2473 stringValue = organization.GetDescription();
2474 if (!stringValue.IsEmpty())
2476 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2477 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2479 contacts_record_set_str(organizationHandle, _contacts_company.description, pCharArray.get());
2483 stringValue = organization.GetLocation();
2484 if (!stringValue.IsEmpty())
2486 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2487 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2489 contacts_record_set_str(organizationHandle, _contacts_company.location, pCharArray.get());
2493 stringValue = organization.GetPhoneticName();
2494 if (!stringValue.IsEmpty())
2496 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2497 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2499 contacts_record_set_str(organizationHandle, _contacts_company.phonetic_name, pCharArray.get());
2503 if (_OrganizationImpl::GetInstance(organization)->IsLogoPathChanged() == true)
2505 stringValue = organization.GetLogoPath();
2506 if (!stringValue.IsEmpty())
2508 std::unique_ptr<char[]> pCharArray(_StringConverter::CopyToCharArrayN(stringValue));
2509 SysTryReturn(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2511 contacts_record_set_str(organizationHandle, _contacts_company.logo, pCharArray.get());
2515 ret = contacts_record_add_child_record(__profileHandle, _contacts_my_profile.company, organizationHandle);
2516 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2518 recordHandle.Release();
2525 _UserProfileImpl::RemoveAt(UserProfileMultiPropertyId id, int index)
2527 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);
2529 unsigned int count = 0;
2530 contacts_record_h recordHandle = null;
2534 case USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS:
2535 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.number, &count);
2536 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);
2538 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.number, index, &recordHandle);
2539 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.number, recordHandle);
2540 contacts_record_destroy(recordHandle, true);
2543 case USER_PROFILE_MPROPERTY_ID_EMAILS:
2544 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.email, &count);
2545 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);
2547 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.email, index, &recordHandle);
2548 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.email, recordHandle);
2549 contacts_record_destroy(recordHandle, true);
2552 case USER_PROFILE_MPROPERTY_ID_URLS:
2553 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.url, &count);
2554 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of urls %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2556 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.url, index, &recordHandle);
2557 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.url, recordHandle);
2558 contacts_record_destroy(recordHandle, true);
2561 case USER_PROFILE_MPROPERTY_ID_ADDRESSES:
2562 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.address, &count);
2563 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);
2565 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.address, index, &recordHandle);
2566 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.address, recordHandle);
2567 contacts_record_destroy(recordHandle, true);
2570 case USER_PROFILE_MPROPERTY_ID_IMADDRESSES:
2571 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.messenger, &count);
2572 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);
2574 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.messenger, index, &recordHandle);
2575 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.messenger, recordHandle);
2576 contacts_record_destroy(recordHandle, true);
2579 case USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS:
2580 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.company, &count);
2581 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);
2583 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.company, index, &recordHandle);
2584 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.company, recordHandle);
2585 contacts_record_destroy(recordHandle, true);
2588 case USER_PROFILE_MPROPERTY_ID_EVENTS:
2589 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.event, &count);
2590 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);
2592 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.event, index, &recordHandle);
2593 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.event, recordHandle);
2594 contacts_record_destroy(recordHandle, true);
2597 case USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS:
2598 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.relationship, &count);
2599 SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index %d must be less than the current count of relationships %d.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
2601 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.relationship, index, &recordHandle);
2602 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.relationship, recordHandle);
2603 contacts_record_destroy(recordHandle, true);
2606 case USER_PROFILE_MPROPERTY_ID_NOTES:
2607 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.note, &count);
2608 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);
2610 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.note, index, &recordHandle);
2611 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.note, recordHandle);
2612 contacts_record_destroy(recordHandle, true);
2615 case USER_PROFILE_MPROPERTY_ID_NICKNAMES:
2616 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.nickname, &count);
2617 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);
2619 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.nickname, index, &recordHandle);
2620 contacts_record_remove_child_record(__profileHandle, _contacts_my_profile.nickname, recordHandle);
2621 contacts_record_destroy(recordHandle, true);
2625 SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. id=%d.", GetErrorMessage(E_INVALID_ARG), id);
2626 return E_INVALID_ARG;
2633 _UserProfileImpl::GetOrganizationsN(void) const
2635 result r = E_SUCCESS;
2636 contacts_record_h organizationHandle = null;
2637 int ret = CONTACTS_ERROR_NONE;
2638 char* pCharValue = null;
2640 unsigned int count = 0;
2641 std::unique_ptr<Organization> pOrganization(null);
2643 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2644 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2646 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.company, &count);
2648 r = pList->Construct(count);
2649 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2651 for (unsigned int index = 0; index < count; index++)
2653 ret = contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.company, index, &organizationHandle);
2654 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2656 pOrganization.reset(new (std::nothrow) Organization());
2657 SysTryReturn(NID_SCL, pOrganization != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2660 contacts_record_get_str_p(organizationHandle, _contacts_company.name, &pCharValue);
2661 pOrganization->SetName(pCharValue);
2664 contacts_record_get_str_p(organizationHandle, _contacts_company.job_title, &pCharValue);
2665 pOrganization->SetJobTitle(pCharValue);
2668 contacts_record_get_str_p(organizationHandle, _contacts_company.department, &pCharValue);
2669 pOrganization->SetDepartment(pCharValue);
2672 contacts_record_get_str_p(organizationHandle, _contacts_company.role, &pCharValue);
2673 pOrganization->SetRole(pCharValue);
2676 contacts_record_get_str_p(organizationHandle, _contacts_company.assistant_name, &pCharValue);
2677 pOrganization->SetAgent(pCharValue);
2680 contacts_record_get_int(organizationHandle, _contacts_company.type, &intValue);
2683 case CONTACTS_COMPANY_TYPE_WORK:
2684 pOrganization->SetType(ORGANIZATION_TYPE_WORK);
2686 case CONTACTS_COMPANY_TYPE_CUSTOM:
2687 pOrganization->SetType(ORGANIZATION_TYPE_CUSTOM);
2689 case CONTACTS_COMPANY_TYPE_OTHER:
2692 pOrganization->SetType(ORGANIZATION_TYPE_OTHER);
2697 contacts_record_get_str_p(organizationHandle, _contacts_company.label, &pCharValue);
2698 pOrganization->SetLabel(pCharValue);
2701 contacts_record_get_str_p(organizationHandle, _contacts_company.description, &pCharValue);
2702 pOrganization->SetDescription(pCharValue);
2705 contacts_record_get_str_p(organizationHandle, _contacts_company.location, &pCharValue);
2706 pOrganization->SetLocation(pCharValue);
2709 contacts_record_get_str_p(organizationHandle, _contacts_company.phonetic_name, &pCharValue);
2710 pOrganization->SetPhoneticName(pCharValue);
2713 contacts_record_get_str_p(organizationHandle, _contacts_company.logo, &pCharValue);
2714 _OrganizationImpl::GetInstance(*pOrganization)->SetLogoPath(pCharValue);
2716 r = pList->Add(*pOrganization);
2717 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2719 pOrganization.release();
2722 return pList.release();
2727 _UserProfileImpl::GetRelationshipsN(void) const
2730 result r = E_SUCCESS;
2731 contacts_record_h relationshipHandle = null;
2732 int ret = CONTACTS_ERROR_NONE;
2734 char* pCharValue = null;
2735 unsigned int count = 0;
2736 std::unique_ptr<Relationship> pRelationship(null);
2738 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2739 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2741 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.relationship, &count);
2743 r = pList->Construct(count);
2744 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2746 for (unsigned int index = 0; index < count; index++)
2748 ret = contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.relationship, index, &relationshipHandle);
2749 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
2751 pRelationship.reset(new (std::nothrow) Relationship());
2752 SysTryReturn(NID_SCL, pRelationship != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2755 contacts_record_get_int(relationshipHandle, _contacts_relationship.type, &intValue);
2758 case CONTACTS_RELATIONSHIP_TYPE_ASSISTANT:
2759 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_ASSISTANT);
2761 case CONTACTS_RELATIONSHIP_TYPE_BROTHER:
2762 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_BROTHER);
2764 case CONTACTS_RELATIONSHIP_TYPE_CHILD:
2765 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_CHILD);
2767 case CONTACTS_RELATIONSHIP_TYPE_DOMESTIC_PARTNER:
2768 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_DOMESTIC_PARTNER);
2770 case CONTACTS_RELATIONSHIP_TYPE_FATHER:
2771 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_FATHER);
2773 case CONTACTS_RELATIONSHIP_TYPE_FRIEND:
2774 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_FRIEND);
2776 case CONTACTS_RELATIONSHIP_TYPE_MANAGER:
2777 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_MANAGER);
2779 case CONTACTS_RELATIONSHIP_TYPE_MOTHER:
2780 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_MOTHER);
2782 case CONTACTS_RELATIONSHIP_TYPE_PARENT:
2783 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_PARENT);
2785 case CONTACTS_RELATIONSHIP_TYPE_PARTNER:
2786 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_PARTNER);
2788 case CONTACTS_RELATIONSHIP_TYPE_REFERRED_BY:
2789 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_REFERRED_BY);
2791 case CONTACTS_RELATIONSHIP_TYPE_RELATIVE:
2792 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_RELATIVE);
2794 case CONTACTS_RELATIONSHIP_TYPE_SISTER:
2795 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_SISTER);
2797 case CONTACTS_RELATIONSHIP_TYPE_SPOUSE:
2798 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_SPOUSE);
2800 case CONTACTS_RELATIONSHIP_TYPE_CUSTOM:
2803 pRelationship->SetType(CONTACT_RELATIONSHIP_TYPE_CUSTOM);
2808 contacts_record_get_str_p(relationshipHandle, _contacts_relationship.label, &pCharValue);
2809 pRelationship->SetLabel(pCharValue);
2812 contacts_record_get_str_p(relationshipHandle, _contacts_relationship.name, &pCharValue);
2813 pRelationship->SetRelativeName(pCharValue);
2815 r = pList->Add(*pRelationship);
2816 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2818 pRelationship.release();
2821 return pList.release();
2826 _UserProfileImpl::GetEventsN(void) const
2828 result r = E_SUCCESS;
2829 char* pCharValue = null;
2831 unsigned int count = 0;
2832 contacts_record_h eventHandle = null;
2833 std::unique_ptr<ContactEvent> pEvent(null);
2835 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2836 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2838 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.event, &count);
2840 r = pList->Construct(count);
2841 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2843 for (unsigned int index = 0; index < count; index++)
2845 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.event, index, &eventHandle);
2847 pEvent.reset(new (std::nothrow) ContactEvent());
2848 SysTryReturn(NID_SCL, pEvent != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2851 contacts_record_get_str_p(eventHandle, _contacts_event.label, &pCharValue);
2852 pEvent->SetLabel(pCharValue);
2855 contacts_record_get_int(eventHandle, _contacts_event.type, &intValue);
2858 case CONTACTS_EVENT_TYPE_BIRTH:
2859 pEvent->SetType(CONTACT_EVENT_TYPE_BIRTHDAY);
2861 case CONTACTS_EVENT_TYPE_ANNIVERSARY:
2862 pEvent->SetType(CONTACT_EVENT_TYPE_ANNIVERSARY);
2864 case CONTACTS_URL_TYPE_CUSTOM:
2865 pEvent->SetType(CONTACT_EVENT_TYPE_CUSTOM);
2868 pEvent->SetType(CONTACT_EVENT_TYPE_OTHER);
2874 contacts_record_get_int(eventHandle, _contacts_event.date, &intValue);
2875 __CONVERT_DATE_TO_DATETIME(intValue, dateTime);
2876 pEvent->SetDate(dateTime);
2878 pList->Add(*pEvent);
2879 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2884 return pList.release();
2889 _UserProfileImpl::GetNotesN(void) const
2891 result r = E_SUCCESS;
2892 char* pCharValue = null;
2893 unsigned int count = 0;
2894 contacts_record_h noteHandle = null;
2895 std::unique_ptr<String> pNote(null);
2897 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2898 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2900 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.note, &count);
2902 r = pList->Construct(count);
2903 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2905 for (unsigned int index = 0; index < count; index++)
2907 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.note, index, ¬eHandle);
2909 contacts_record_get_str_p(noteHandle, _contacts_note.note, &pCharValue);
2911 pNote.reset(new (std::nothrow) String(pCharValue));
2912 SysTryReturn(NID_SCL, pNote != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2915 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2920 return pList.release();
2925 _UserProfileImpl::GetNicknamesN(void) const
2927 result r = E_SUCCESS;
2928 char* pCharValue = null;
2929 unsigned int count = 0;
2930 contacts_record_h nicknameHandle = null;
2931 std::unique_ptr<String> pNickname(null);
2933 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2934 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2936 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.nickname, &count);
2938 r = pList->Construct(count);
2939 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2941 for (unsigned int index = 0; index < count; index++)
2943 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.nickname, index, &nicknameHandle);
2945 contacts_record_get_str_p(nicknameHandle, _contacts_nickname.name, &pCharValue);
2947 pNickname.reset(new (std::nothrow) String(pCharValue));
2948 SysTryReturn(NID_SCL, pNickname != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2950 pList->Add(*pNickname);
2951 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2953 pNickname.release();
2956 return pList.release();
2961 _UserProfileImpl::GetPhoneNumbersN(void) const
2963 result r = E_SUCCESS;
2964 unsigned int count = 0;
2965 contacts_record_h numberHandle = null;
2967 char* pCharValue = null;
2968 PhoneNumberType type = PHONENUMBER_TYPE_HOME;
2969 std::unique_ptr<PhoneNumber> pPhoneNumber(null);
2971 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
2972 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2975 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.number, &count);
2977 contacts_record_get_int(__profileHandle, _contacts_my_profile.id, &intValue);
2979 r = pList->Construct(count);
2980 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2982 for (unsigned int index = 0; index < count; index++)
2984 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.number, index, &numberHandle);
2986 pPhoneNumber.reset(new (std::nothrow) PhoneNumber());
2987 SysTryReturn(NID_SCL, pPhoneNumber != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2989 contacts_record_get_int(numberHandle, _contacts_number.id, &intValue);
2990 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetRecordId(intValue);
2992 contacts_record_get_str_p(numberHandle, _contacts_number.label, &pCharValue);
2993 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetLabel(pCharValue);
2995 contacts_record_get_int(numberHandle, _contacts_number.type, &intValue);
2999 case CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE:
3000 type = PHONENUMBER_TYPE_HOME;
3002 case CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE:
3003 type = PHONENUMBER_TYPE_WORK;
3005 case CONTACTS_NUMBER_TYPE_CELL:
3006 type = PHONENUMBER_TYPE_MOBILE;
3008 case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME:
3009 type = PHONENUMBER_TYPE_HOME_FAX;
3011 case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK:
3012 type = PHONENUMBER_TYPE_WORK_FAX;
3014 case CONTACTS_NUMBER_TYPE_PAGER:
3015 type = PHONENUMBER_TYPE_PAGER;
3017 case CONTACTS_NUMBER_TYPE_CUSTOM:
3018 type = PHONENUMBER_TYPE_CUSTOM;
3020 case CONTACTS_NUMBER_TYPE_ASSISTANT:
3021 type = PHONENUMBER_TYPE_ASSISTANT;
3024 if (intValue & CONTACTS_NUMBER_TYPE_FAX)
3026 type = PHONENUMBER_TYPE_HOME_FAX;
3028 else if (intValue & CONTACTS_NUMBER_TYPE_CELL)
3030 type = PHONENUMBER_TYPE_MOBILE;
3032 else if (intValue & CONTACTS_NUMBER_TYPE_PAGER)
3034 type = PHONENUMBER_TYPE_PAGER;
3036 else if (intValue & CONTACTS_NUMBER_TYPE_HOME)
3038 type = PHONENUMBER_TYPE_HOME;
3040 else if (intValue & CONTACTS_NUMBER_TYPE_WORK)
3042 type = PHONENUMBER_TYPE_WORK;
3044 else if (intValue & CONTACTS_NUMBER_TYPE_VOICE)
3046 type = PHONENUMBER_TYPE_HOME;
3050 type = PHONENUMBER_TYPE_OTHER;
3055 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetType(type);
3057 contacts_record_get_str_p(numberHandle, _contacts_number.number, &pCharValue);
3058 _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetPhoneNumber(pCharValue);
3060 r = pList->Add(*pPhoneNumber);
3061 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3063 pPhoneNumber.release();
3066 return pList.release();
3071 _UserProfileImpl::GetEmailsN(void) const
3073 result r = E_SUCCESS;
3074 contacts_record_h currentHandle = null;
3075 int ret = CONTACTS_ERROR_NONE;
3077 unsigned int count = 0;
3078 char* pCharValue = null;
3079 EmailType type = EMAIL_TYPE_PERSONAL;
3080 std::unique_ptr<Email> pEmail(null);
3082 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3083 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3085 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.email, &count);
3087 r = pList->Construct(count);
3088 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3090 for (unsigned int index = 0; index < count; index++)
3092 ret = contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.email, index, ¤tHandle);
3093 SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM))
3095 pEmail.reset(new (std::nothrow) Email());
3096 SysTryReturn(NID_SCL, pEmail != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3098 contacts_record_get_int(currentHandle, _contacts_email.id, &intValue);
3099 _EmailImpl::GetInstance(*pEmail)->SetRecordId(intValue);
3101 contacts_record_get_str_p(currentHandle, _contacts_email.label, &pCharValue);
3102 _EmailImpl::GetInstance(*pEmail)->SetLabel(pCharValue);
3104 contacts_record_get_int(currentHandle, _contacts_email.type, &intValue);
3107 case CONTACTS_EMAIL_TYPE_HOME:
3108 type = EMAIL_TYPE_PERSONAL;
3110 case CONTACTS_EMAIL_TYPE_WORK:
3111 type = EMAIL_TYPE_WORK;
3113 case CONTACTS_EMAIL_TYPE_CUSTOM:
3114 type = EMAIL_TYPE_CUSTOM;
3116 case CONTACTS_EMAIL_TYPE_MOBILE:
3117 type = EMAIL_TYPE_MOBILE;
3120 type = EMAIL_TYPE_OTHER;
3124 _EmailImpl::GetInstance(*pEmail)->SetType(type);
3126 contacts_record_get_str_p(currentHandle, _contacts_email.email, &pCharValue);
3127 _EmailImpl::GetInstance(*pEmail)->SetEmail(pCharValue);
3129 r = pList->Add(*pEmail);
3130 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3135 return pList.release();
3140 _UserProfileImpl::GetUrlsN(void) const
3143 result r = E_SUCCESS;
3144 char* pCharValue = null;
3146 unsigned int count = 0;
3147 UrlType type = URL_TYPE_PERSONAL;
3148 contacts_record_h urlHandle = null;
3149 std::unique_ptr<Url> pUrl(null);
3151 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3152 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3154 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.url, &count);
3156 r = pList->Construct(count);
3157 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3159 for (unsigned int index = 0; index < count; index++)
3161 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.url, index, &urlHandle);
3163 pUrl.reset(new (std::nothrow) Url());
3164 SysTryReturn(NID_SCL, pUrl != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3166 contacts_record_get_str_p(urlHandle, _contacts_url.label, &pCharValue);
3167 pUrl->SetLabel(pCharValue);
3169 contacts_record_get_int(urlHandle, _contacts_url.type, &intValue);
3172 case CONTACTS_URL_TYPE_HOME:
3173 type = URL_TYPE_PERSONAL;
3175 case CONTACTS_URL_TYPE_WORK:
3176 type = URL_TYPE_WORK;
3178 case CONTACTS_URL_TYPE_CUSTOM:
3179 type = URL_TYPE_CUSTOM;
3182 type = URL_TYPE_OTHER;
3186 pUrl->SetType(type);
3188 contacts_record_get_str_p(urlHandle, _contacts_url.url, &pCharValue);
3189 _UrlImpl::GetInstance(*pUrl)->SetUrl(pCharValue);
3192 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3197 return pList.release();
3202 _UserProfileImpl::GetAddressesN(void) const
3204 result r = E_SUCCESS;
3205 char* pCharValue = null;
3207 unsigned int count = 0;
3208 contacts_record_h addressHandle = 0;
3209 std::unique_ptr<Address> pAddress(null);
3211 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3212 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3214 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.address, &count);
3216 r = pList->Construct(count);
3217 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3220 for (unsigned int index = 0; index < count; index++)
3222 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.address, index, &addressHandle);
3224 pAddress.reset(new (std::nothrow) Address());
3225 SysTryReturn(NID_SCL, pAddress != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3227 contacts_record_get_str_p(addressHandle, _contacts_address.label, &pCharValue);
3228 pAddress->SetLabel(pCharValue);
3230 contacts_record_get_int(addressHandle, _contacts_address.type, &intValue);
3233 case CONTACTS_ADDRESS_TYPE_HOME:
3234 pAddress->SetType(ADDRESS_TYPE_HOME);
3236 case CONTACTS_ADDRESS_TYPE_WORK:
3237 pAddress->SetType(ADDRESS_TYPE_WORK);
3239 case CONTACTS_ADDRESS_TYPE_CUSTOM:
3240 pAddress->SetType(ADDRESS_TYPE_CUSTOM);
3243 pAddress->SetType(ADDRESS_TYPE_OTHER);
3248 contacts_record_get_str_p(addressHandle, _contacts_address.country, &pCharValue);
3249 _AddressImpl::GetInstance(*pAddress)->SetCountry(pCharValue);
3252 contacts_record_get_str_p(addressHandle, _contacts_address.region, &pCharValue);
3253 _AddressImpl::GetInstance(*pAddress)->SetState(pCharValue);
3256 contacts_record_get_str_p(addressHandle, _contacts_address.locality, &pCharValue);
3257 _AddressImpl::GetInstance(*pAddress)->SetCity(pCharValue);
3260 contacts_record_get_str_p(addressHandle, _contacts_address.street, &pCharValue);
3261 _AddressImpl::GetInstance(*pAddress)->SetStreet(pCharValue);
3264 contacts_record_get_str_p(addressHandle, _contacts_address.extended, &pCharValue);
3265 _AddressImpl::GetInstance(*pAddress)->SetExtended(pCharValue);
3268 contacts_record_get_str_p(addressHandle, _contacts_address.postbox, &pCharValue);
3269 _AddressImpl::GetInstance(*pAddress)->SetPostOfficeBoxNumber(pCharValue);
3272 contacts_record_get_str_p(addressHandle, _contacts_address.postal_code, &pCharValue);
3273 _AddressImpl::GetInstance(*pAddress)->SetPostalCode(pCharValue);
3275 r = pList->Add(*pAddress);
3276 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3281 return pList.release();
3286 _UserProfileImpl::GetImAddressesN(void) const
3288 result r = E_SUCCESS;
3289 char* pCharValue = null;
3291 contacts_record_h messengerHandle = null;
3292 unsigned int count = 0;
3293 std::unique_ptr<ImAddress> pImAddress(null);
3295 std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
3296 SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3298 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.messenger, &count);
3300 r = pList->Construct(count);
3301 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3303 for (unsigned int index = 0; index < count; index++)
3305 contacts_record_get_child_record_at_p(__profileHandle, _contacts_my_profile.messenger, index, &messengerHandle);
3307 pImAddress.reset(new (std::nothrow) ImAddress());
3308 SysTryReturn(NID_SCL, pImAddress != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3310 contacts_record_get_int(messengerHandle, _contacts_messenger.type, &intValue);
3313 case CONTACTS_MESSENGER_TYPE_GOOGLE:
3314 pImAddress->SetServiceProviderName(IM_ADDRESS_GOOGLE_TALK);
3316 case CONTACTS_MESSENGER_TYPE_WLM:
3317 pImAddress->SetServiceProviderName(IM_ADDRESS_MSN);
3319 case CONTACTS_MESSENGER_TYPE_ICQ:
3320 pImAddress->SetServiceProviderName(IM_ADDRESS_ICQ);
3322 case CONTACTS_MESSENGER_TYPE_AIM:
3323 pImAddress->SetServiceProviderName(IM_ADDRESS_AIM);
3325 case CONTACTS_MESSENGER_TYPE_YAHOO:
3326 pImAddress->SetServiceProviderName(IM_ADDRESS_YAHOO);
3328 case CONTACTS_MESSENGER_TYPE_QQ:
3329 pImAddress->SetServiceProviderName(IM_ADDRESS_QQ);
3331 case CONTACTS_MESSENGER_TYPE_SKYPE:
3332 pImAddress->SetServiceProviderName(IM_ADDRESS_SKYPE);
3334 case CONTACTS_MESSENGER_TYPE_JABBER:
3335 pImAddress->SetServiceProviderName(IM_ADDRESS_JABBER);
3337 case CONTACTS_MESSENGER_TYPE_CUSTOM:
3340 contacts_record_get_str_p(messengerHandle, _contacts_messenger.label, &pCharValue);
3341 pImAddress->SetServiceProviderName(pCharValue);
3345 contacts_record_get_str_p(messengerHandle, _contacts_messenger.im_id, &pCharValue);
3346 _ImAddressImpl::GetInstance(*pImAddress)->SetImAddress(pCharValue);
3348 r = pList->Add(*pImAddress);
3349 SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3351 pImAddress.release();
3354 return pList.release();
3360 _UserProfileImpl::IsEmptyCompany(contacts_record_h companyHandle)
3362 char* pCharValue = null;
3364 contacts_record_get_str_p(companyHandle, _contacts_company.name, &pCharValue);
3365 if (pCharValue != null)
3370 contacts_record_get_str_p(companyHandle, _contacts_company.job_title, &pCharValue);
3371 if (pCharValue != null)
3377 contacts_record_get_str_p(companyHandle, _contacts_company.department, &pCharValue);
3378 if (pCharValue != null)
3383 contacts_record_get_str_p(companyHandle, _contacts_company.role, &pCharValue);
3384 if (pCharValue != null)
3389 contacts_record_get_str_p(companyHandle, _contacts_company.assistant_name, &pCharValue);
3390 if (pCharValue != null)
3399 _UserProfileImpl::IsEmptyName(contacts_record_h nameHandle)
3401 char* pCharValue = null;
3403 contacts_record_get_str_p(nameHandle, _contacts_name.first, &pCharValue);
3404 if (pCharValue != null)
3409 contacts_record_get_str_p(nameHandle, _contacts_name.last, &pCharValue);
3410 if (pCharValue != null)
3415 contacts_record_get_str_p(nameHandle, _contacts_name.addition, &pCharValue);
3416 if (pCharValue != null)
3421 contacts_record_get_str_p(nameHandle, _contacts_name.prefix, &pCharValue);
3422 if (pCharValue != null)
3427 contacts_record_get_str_p(nameHandle, _contacts_name.suffix, &pCharValue);
3428 if (pCharValue != null)
3438 _UserProfileImpl::IsEmpty(void) const
3440 unsigned int count = 0;
3442 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.number, &count);
3448 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.email, &count);
3454 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.url, &count);
3460 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.address, &count);
3466 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.messenger, &count);
3472 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.name, &count);
3478 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.company, &count);
3484 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.event, &count);
3490 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.note, &count);
3496 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.nickname, &count);
3502 contacts_record_get_child_record_count(__profileHandle, _contacts_my_profile.image, &count);
3513 _UserProfileImpl::SetUserProfileHandle(contacts_record_h profileHandle)
3515 contacts_record_destroy(__profileHandle, true);
3517 __profileHandle = profileHandle;
3521 _UserProfileImpl::GetUserProfileHandle(void) const
3523 return __profileHandle;
3526 const _UserProfileImpl*
3527 _UserProfileImpl::GetInstance(const UserProfile& userProfile)
3529 return userProfile.__pUserProfileImpl;
3533 _UserProfileImpl::GetInstance(UserProfile& userProfile)
3535 return userProfile.__pUserProfileImpl;