2 // Tizen Web Device API
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.
19 * @file ContactObjectP2AConverter.cpp
20 * @author Kisub Song (kisubs.song@samsung.com)
22 * @brief Converter (contacts_record_h -> ContactPtr)
25 #include "ContactObjectP2AConverter.h"
29 #include <dpl/log/log.h>
30 #include <Commons/Exception.h>
31 #include <Commons/Regex.h>
32 #include "AddressBook.h"
34 #include "ContactUtility.h"
39 using namespace WrtDeviceApis::Commons;
42 ContactObjectP2AConverter::ContactObjectP2AConverter(contacts_record_h platformContact,
44 m_platformContact(platformContact),
45 m_abstractContact(ContactPtr(NULL)),
46 m_forScratch(forScratch),
47 m_convertFinished(false)
51 ContactObjectP2AConverter::ContactObjectP2AConverter(contacts_record_h platformContact,
53 ContactPtr &abstractContact) :
54 m_platformContact(platformContact),
55 m_abstractContact(abstractContact),
56 m_forScratch(forScratch),
57 m_convertFinished(false)
61 ContactObjectP2AConverter::~ContactObjectP2AConverter()
65 ContactPtr ContactObjectP2AConverter::getAbstractContact()
69 if(m_platformContact == NULL)
71 LogError("Platform contact object did not set");
72 ThrowMsg(InvalidArgumentException, "Platform contact object did not set");
75 if(m_abstractContact == NULL)
77 //LogDebug("Abstract contact object did not set, so a new object has been created");
78 m_abstractContact = ContactPtr(new Contact());
81 //LogDebug("for scratch : " << m_forScratch);
85 if(m_convertFinished == false)
86 convertToAbstractObject();
90 LogError("Error while converting - " << _rethrown_exception.GetMessage());
91 ThrowMsg(PlatformException, "Fail to convert platform object to abstract object.");
94 return m_abstractContact;
97 void ContactObjectP2AConverter::convertToAbstractObject()
99 exportBaseInfoValue();
105 exportGrouprelList();
109 exportNicknameList();
111 m_convertFinished = true;
114 void ContactObjectP2AConverter::exportBaseInfoValue()
121 contacts_record_get_int(m_platformContact, _contacts_contact.id, &id);
122 m_abstractContact->setId(id);
124 int addressBookId = 0;
125 contacts_record_get_int(m_platformContact, _contacts_contact.address_book_id, &addressBookId);
126 m_abstractContact->setAddressBookId(addressBookId);
129 contacts_record_get_int(m_platformContact, _contacts_contact.person_id, &personId);
130 m_abstractContact->setPersonId(personId);
133 contacts_record_get_int(m_platformContact, _contacts_contact.changed_time, &changedTime);
134 time_t changedTimeT = static_cast<time_t>(changedTime);
135 struct tm *changedTimeTm = gmtime(&changedTimeT);
136 m_abstractContact->setLastUpdated(*changedTimeTm);
138 bool isFavorite = false;
139 errorCode = contacts_record_get_bool(m_platformContact, _contacts_contact.is_favorite, &isFavorite);
140 if(errorCode != CONTACTS_ERROR_NONE)
141 LogError("contacts_record_get_bool returned " << errorCode);
142 m_abstractContact->setIsFavorite(isFavorite);
145 char *charValue = NULL;
147 contacts_record_get_str_p(m_platformContact, _contacts_contact.image_thumbnail_path, &charValue);
149 m_abstractContact->setPhotoURI(ContactUtility::convertPathToUri(charValue));
152 if(m_abstractContact->getPhotoURIIsSet())
153 m_abstractContact->unsetPhotoURI();
156 contacts_record_get_str_p(m_platformContact, _contacts_contact.ringtone_path, &charValue);
158 m_abstractContact->setRingtoneURI(ContactUtility::convertPathToUri(charValue));
161 if(m_abstractContact->getRingtoneURIIsSet())
162 m_abstractContact->unsetRingtoneURI();
167 contacts_record_get_str_p(m_platformContact, _contacts_contact.display_name, &charValue);
170 ContactNamePtr contactName = m_abstractContact->getName();
171 if(contactName == NULL)
173 contactName = ContactNamePtr(new ContactName());
174 m_abstractContact->setName(contactName);
176 contactName->setDisplayName(charValue);
179 // ThrowMsg(UnknownException, "converting base data (no display name)");
183 void ContactObjectP2AConverter::exportNameValue()
186 contacts_record_h child_record = NULL;
188 errorCode = contacts_record_get_child_record_at_p(m_platformContact, _contacts_contact.name, 0, &child_record);
189 if(errorCode != CONTACTS_ERROR_NONE && errorCode != CONTACTS_ERROR_NO_DATA)
190 ThrowMsg(UnknownException, "getting name value (err:" << errorCode << ")");
192 if(child_record == NULL || errorCode == CONTACTS_ERROR_NO_DATA)
194 //LogDebug("Platform contact don't have name value");
195 ContactNamePtr contactName = m_abstractContact->getName();
196 if(contactName != NULL)
198 if(contactName->getFirstNameIsSet())
199 contactName->unsetFirstName();
201 if(contactName->getMiddleNameIsSet())
202 contactName->unsetMiddleName();
204 if(contactName->getLastNameIsSet())
205 contactName->unsetLastName();
207 if(contactName->getPrefixIsSet())
208 contactName->unsetPrefix();
210 if(contactName->getSuffixIsSet())
211 contactName->unsetSuffix();
213 if(contactName->getPhoneticFirstNameIsSet())
214 contactName->unsetPhoneticFirstName();
216 if(contactName->getPhoneticLastNameIsSet())
217 contactName->unsetPhoneticLastName();
222 ContactNamePtr contactName = m_abstractContact->getName();
223 if(contactName == NULL)
225 contactName = ContactNamePtr(new ContactName());
226 m_abstractContact->setName(contactName);
229 char *charValue = NULL;
231 contacts_record_get_str_p(child_record, _contacts_name.first, &charValue);
233 contactName->setFirstName(charValue);
236 if(contactName->getFirstNameIsSet())
237 contactName->unsetFirstName();
240 contacts_record_get_str_p(child_record, _contacts_name.addition, &charValue);
242 contactName->setMiddleName(charValue);
245 if(contactName->getMiddleNameIsSet())
246 contactName->unsetMiddleName();
249 contacts_record_get_str_p(child_record, _contacts_name.last, &charValue);
251 contactName->setLastName(charValue);
254 if(contactName->getLastNameIsSet())
255 contactName->unsetLastName();
258 contacts_record_get_str_p(child_record, _contacts_name.prefix, &charValue);
260 contactName->setPrefix(charValue);
263 if(contactName->getPrefixIsSet())
264 contactName->unsetPrefix();
267 contacts_record_get_str_p(child_record, _contacts_name.suffix, &charValue);
269 contactName->setSuffix(charValue);
272 if(contactName->getSuffixIsSet())
273 contactName->unsetSuffix();
276 contacts_record_get_str_p(child_record, _contacts_name.phonetic_first, &charValue);
278 contactName->setPhoneticFirstName(charValue);
281 if(contactName->getPhoneticFirstNameIsSet())
282 contactName->unsetPhoneticFirstName();
285 contacts_record_get_str_p(child_record, _contacts_name.phonetic_last, &charValue);
287 contactName->setPhoneticLastName(charValue);
290 if(contactName->getPhoneticLastNameIsSet())
291 contactName->unsetPhoneticLastName();
295 void ContactObjectP2AConverter::exportCompanyList()
298 unsigned int child_count = 0;
300 if(m_abstractContact->getOrganizationsNum() > 0)
301 m_abstractContact->clearOrganizations();
303 errorCode = contacts_record_get_child_record_count(m_platformContact, _contacts_contact.company, &child_count);
304 if(errorCode != CONTACTS_ERROR_NONE && errorCode != CONTACTS_ERROR_NO_DATA)
305 ThrowMsg(UnknownException, "getting company list (err:" << errorCode << ")");
307 if(child_count == 0 || errorCode == CONTACTS_ERROR_NO_DATA)
309 //LogDebug("Platform contact don't have company list");
313 ContactOrganizationArrayPtr organizations = m_abstractContact->getOrganizations();
315 for(unsigned int i=0; i<child_count; i++)
317 contacts_record_h child_record = NULL;
319 errorCode = contacts_record_get_child_record_at_p(m_platformContact, _contacts_contact.company, i, &child_record);
320 if(errorCode != CONTACTS_ERROR_NONE && errorCode != CONTACTS_ERROR_NO_DATA)
323 ContactOrganizationPtr organization(new ContactOrganization());
325 organizations->push_back(organization);
327 char *charValue = NULL;
329 contacts_record_get_str_p(child_record, _contacts_company.name, &charValue);
331 organization->setName(charValue);
334 if(organization->getNameIsSet())
335 organization->unsetName();
338 contacts_record_get_str_p(child_record, _contacts_company.department, &charValue);
340 organization->setDepartment(charValue);
343 if(organization->getDepartmentIsSet())
344 organization->unsetDepartment();
347 contacts_record_get_str_p(child_record, _contacts_company.job_title, &charValue);
349 organization->setTitle(charValue);
352 if(organization->getTitleIsSet())
353 organization->unsetTitle();
356 contacts_record_get_str_p(child_record, _contacts_company.role, &charValue);
358 organization->setRole(charValue);
361 if(organization->getRoleIsSet())
362 organization->unsetRole();
365 contacts_record_get_str_p(child_record, _contacts_company.logo, &charValue);
367 organization->setLogoURI(ContactUtility::convertPathToUri(charValue));
370 if(organization->getLogoURIIsSet())
371 organization->unsetLogoURI();
376 void ContactObjectP2AConverter::exportNoteList()
379 unsigned int child_count = 0;
381 if(m_abstractContact->getNotesNum() > 0)
382 m_abstractContact->clearNotes();
384 errorCode = contacts_record_get_child_record_count(m_platformContact, _contacts_contact.note, &child_count);
385 if(errorCode != CONTACTS_ERROR_NONE && errorCode != CONTACTS_ERROR_NO_DATA)
386 ThrowMsg(UnknownException, "getting note list (err:" << errorCode << ")");
388 if(child_count == 0 || errorCode == CONTACTS_ERROR_NO_DATA)
390 //LogDebug("Platform contact don't have note list");
394 StringArrayPtr notes = m_abstractContact->getNotes();
396 for(unsigned int i=0; i<child_count; i++)
398 contacts_record_h child_record = NULL;
400 errorCode = contacts_record_get_child_record_at_p(m_platformContact, _contacts_contact.note, i, &child_record);
401 if(errorCode != CONTACTS_ERROR_NONE && errorCode != CONTACTS_ERROR_NO_DATA)
404 char *charValue = NULL;
406 contacts_record_get_str_p(child_record, _contacts_note.note, &charValue);
408 notes->push_back(charValue);
412 void ContactObjectP2AConverter::exportNumberList()
415 unsigned int child_count = 0;
417 if(m_abstractContact->getPhoneNumbersNum() > 0)
418 m_abstractContact->clearPhoneNumbers();
420 errorCode = contacts_record_get_child_record_count(m_platformContact, _contacts_contact.number, &child_count);
421 if(errorCode != CONTACTS_ERROR_NONE && errorCode != CONTACTS_ERROR_NO_DATA)
422 ThrowMsg(UnknownException, "getting number list (err:" << errorCode << ")");
424 if(child_count == 0 || errorCode == CONTACTS_ERROR_NO_DATA)
426 //LogDebug("Platform contact don't have number list");
430 ContactPhoneNumberArrayPtr phoneNumbers = m_abstractContact->getPhoneNumbers();
432 for(unsigned int i=0; i<child_count; i++)
434 contacts_record_h child_record = NULL;
436 errorCode = contacts_record_get_child_record_at_p(m_platformContact, _contacts_contact.number, i, &child_record);
437 if(errorCode != CONTACTS_ERROR_NONE && errorCode != CONTACTS_ERROR_NO_DATA)
440 ContactPhoneNumberPtr phoneNumber(new ContactPhoneNumber());
442 char *charValue = NULL;
443 bool boolValue = false;
446 contacts_record_get_str_p(child_record, _contacts_number.number, &charValue);
449 phoneNumber->setNumber(charValue);
450 phoneNumbers->push_back(phoneNumber);
454 //LogDebug("Platform contact have a empty phone number");
458 contacts_record_get_bool(child_record, _contacts_number.is_default, &boolValue);
459 phoneNumber->setIsDefault(boolValue);
461 contacts_record_get_int(child_record, _contacts_number.type, &intValue);
462 if(intValue & CONTACTS_NUMBER_TYPE_HOME)
463 phoneNumber->addType(CONTACT_PHONE_NUMBER_TYPE_HOME);
464 if(intValue & CONTACTS_NUMBER_TYPE_WORK)
465 phoneNumber->addType(CONTACT_PHONE_NUMBER_TYPE_WORK);
466 if(intValue & CONTACTS_NUMBER_TYPE_VOICE)
467 phoneNumber->addType(CONTACT_PHONE_NUMBER_TYPE_VOICE);
468 if(intValue & CONTACTS_NUMBER_TYPE_FAX)
469 phoneNumber->addType(CONTACT_PHONE_NUMBER_TYPE_FAX);
470 if(intValue & CONTACTS_NUMBER_TYPE_MSG)
471 phoneNumber->addType(CONTACT_PHONE_NUMBER_TYPE_MSG);
472 if(intValue & CONTACTS_NUMBER_TYPE_CELL)
473 phoneNumber->addType(CONTACT_PHONE_NUMBER_TYPE_CELL);
474 if(intValue & CONTACTS_NUMBER_TYPE_PAGER)
475 phoneNumber->addType(CONTACT_PHONE_NUMBER_TYPE_PAGER);
476 if(intValue & CONTACTS_NUMBER_TYPE_BBS)
477 phoneNumber->addType(CONTACT_PHONE_NUMBER_TYPE_BBS);
478 if(intValue & CONTACTS_NUMBER_TYPE_MODEM)
479 phoneNumber->addType(CONTACT_PHONE_NUMBER_TYPE_MODEM);
480 if(intValue & CONTACTS_NUMBER_TYPE_CAR)
481 phoneNumber->addType(CONTACT_PHONE_NUMBER_TYPE_CAR);
482 if(intValue & CONTACTS_NUMBER_TYPE_ISDN)
483 phoneNumber->addType(CONTACT_PHONE_NUMBER_TYPE_ISDN);
484 if(intValue & CONTACTS_NUMBER_TYPE_VIDEO)
485 phoneNumber->addType(CONTACT_PHONE_NUMBER_TYPE_VIDEO);
486 if(intValue & CONTACTS_NUMBER_TYPE_PCS)
487 phoneNumber->addType(CONTACT_PHONE_NUMBER_TYPE_PCS);
489 // TODO Will be added after type changed to string
490 // if(intValue & CONTACTS_NUMBER_TYPE_CUSTOM)
492 // contacts_record_get_str_p(child_record, _contacts_number.label, &charValue);
494 // phoneNumber->addType(CUSTOM);
499 void ContactObjectP2AConverter::exportEmailList()
502 unsigned int child_count = 0;
504 if(m_abstractContact->getEmailsNum() > 0)
505 m_abstractContact->clearEmails();
507 errorCode = contacts_record_get_child_record_count(m_platformContact, _contacts_contact.email, &child_count);
508 if(errorCode != CONTACTS_ERROR_NONE && errorCode != CONTACTS_ERROR_NO_DATA)
509 ThrowMsg(UnknownException, "getting email list (err:" << errorCode << ")");
511 if(child_count == 0 || errorCode == CONTACTS_ERROR_NO_DATA)
513 //LogDebug("Platform contact don't have email list");
517 ContactEmailAddressArrayPtr emails = m_abstractContact->getEmails();
519 for(unsigned int i=0; i<child_count; i++)
521 contacts_record_h child_record = NULL;
523 errorCode = contacts_record_get_child_record_at_p(m_platformContact, _contacts_contact.email, i, &child_record);
524 if(errorCode != CONTACTS_ERROR_NONE && errorCode != CONTACTS_ERROR_NO_DATA)
527 ContactEmailAddressPtr email(new ContactEmailAddress());
529 char *charValue = NULL;
530 bool boolValue = false;
533 contacts_record_get_str_p(child_record, _contacts_email.email, &charValue);
536 email->setEmail(charValue);
537 emails->push_back(email);
541 //LogDebug("Platform contact have a empty email address");
545 contacts_record_get_bool(child_record, _contacts_email.is_default, &boolValue);
546 email->setIsDefault(boolValue);
548 contacts_record_get_int(child_record, _contacts_email.type, &intValue);
549 if(intValue & CONTACTS_EMAIL_TYPE_HOME)
550 email->addType(CONTACT_EMAIL_TYPE_HOME);
551 if(intValue & CONTACTS_EMAIL_TYPE_WORK)
552 email->addType(CONTACT_EMAIL_TYPE_WORK);
554 // TODO Will be added after type changed to string
555 // if(intValue & CONTACTS_EMAIL_TYPE_CUSTOM)
557 // contacts_record_get_str_p(child_record, _contacts_email.label, &charValue);
559 // email->addType(CUSTOM);
564 void ContactObjectP2AConverter::exportGrouprelList()
567 unsigned int child_count = 0;
569 if(m_abstractContact->getGroupIdsNum() > 0)
570 m_abstractContact->clearGroupIds();
572 errorCode = contacts_record_get_child_record_count(m_platformContact, _contacts_contact.group_relation, &child_count);
573 if(errorCode != CONTACTS_ERROR_NONE && errorCode != CONTACTS_ERROR_NO_DATA)
574 ThrowMsg(UnknownException, "getting group list (err:" << errorCode << ")");
576 if(child_count == 0 || errorCode == CONTACTS_ERROR_NO_DATA)
578 //LogDebug("Platform contact don't have group list");
582 StringArrayPtr groupIds = m_abstractContact->getGroupIds();
584 for(unsigned int i=0; i<child_count; i++)
586 contacts_record_h child_record = NULL;
588 errorCode = contacts_record_get_child_record_at_p(m_platformContact, _contacts_contact.group_relation, i, &child_record);
589 if(errorCode != CONTACTS_ERROR_NONE && errorCode != CONTACTS_ERROR_NO_DATA)
594 contacts_record_get_int(child_record, _contacts_group_relation.group_id, &groupId);
596 groupIds->push_back(ContactUtility::intToStr(groupId));
600 void ContactObjectP2AConverter::exportEventList()
603 unsigned int child_count = 0;
605 if(m_abstractContact->getAnniversariesNum() > 0)
606 m_abstractContact->clearAnniversaries();
608 if(m_abstractContact->getBirthdayIsSet())
609 m_abstractContact->unsetBirthday();
611 errorCode = contacts_record_get_child_record_count(m_platformContact, _contacts_contact.event, &child_count);
612 if(errorCode != CONTACTS_ERROR_NONE && errorCode != CONTACTS_ERROR_NO_DATA)
613 ThrowMsg(UnknownException, "getting event list (err:" << errorCode << ")");
615 if(child_count == 0 || errorCode == CONTACTS_ERROR_NO_DATA)
617 //LogDebug("Platform contact don't have group list");
621 ContactAnniversaryArrayPtr anniversaries = m_abstractContact->getAnniversaries();
623 for(unsigned int i=0; i<child_count; i++)
625 contacts_record_h child_record = NULL;
627 errorCode = contacts_record_get_child_record_at_p(m_platformContact, _contacts_contact.event, i, &child_record);
628 if(errorCode != CONTACTS_ERROR_NONE && errorCode != CONTACTS_ERROR_NO_DATA)
631 char *charValue = NULL;
632 int intValueType = 0;
633 int intValueDate = 0;
635 contacts_record_get_int(child_record, _contacts_event.date, &intValueDate);
640 tmDate = ContactUtility::toDateTmFromDateDbInt(intValueDate);
642 LogError("date has wrong value");
645 contacts_record_get_int(child_record, _contacts_event.type, &intValueType);
646 if (intValueType == CONTACTS_EVENT_TYPE_BIRTH)
648 m_abstractContact->setBirthday(tmDate);
650 else if(intValueType == CONTACTS_EVENT_TYPE_ANNIVERSARY)
652 ContactAnniversaryPtr anniversary = ContactAnniversaryPtr(new ContactAnniversary());
654 anniversary->setDate(tmDate);
655 contacts_record_get_str_p(child_record, _contacts_event.label, &charValue);
657 anniversary->setLabel(charValue);
659 anniversaries->push_back(anniversary);
664 void ContactObjectP2AConverter::exportPostalList()
667 unsigned int child_count = 0;
669 if(m_abstractContact->getAddressesNum() > 0)
670 m_abstractContact->clearAddresses();
672 errorCode = contacts_record_get_child_record_count(m_platformContact, _contacts_contact.address, &child_count);
673 if(errorCode != CONTACTS_ERROR_NONE && errorCode != CONTACTS_ERROR_NO_DATA)
674 ThrowMsg(UnknownException, "getting address list (err:" << errorCode << ")");
676 if(child_count == 0 || errorCode == CONTACTS_ERROR_NO_DATA)
678 //LogDebug("Platform contact don't have address list");
682 ContactAddressArrayPtr addresss = m_abstractContact->getAddresses();
684 for(unsigned int i=0; i<child_count; i++)
686 contacts_record_h child_record = NULL;
688 errorCode = contacts_record_get_child_record_at_p(m_platformContact, _contacts_contact.address, i, &child_record);
689 if(errorCode != CONTACTS_ERROR_NONE && errorCode != CONTACTS_ERROR_NO_DATA)
692 ContactAddressPtr address(new ContactAddress());
694 char *charValue = NULL;
695 bool boolValue = false;
698 addresss->push_back(address);
700 contacts_record_get_str_p(child_record, _contacts_address.postal_code, &charValue);
702 address->setPostalCode(charValue);
704 contacts_record_get_str_p(child_record, _contacts_address.region, &charValue);
706 address->setRegion(charValue);
708 contacts_record_get_str_p(child_record, _contacts_address.locality, &charValue);
710 address->setCity(charValue);
712 contacts_record_get_str_p(child_record, _contacts_address.street, &charValue);
714 address->setStreetAddress(charValue);
716 contacts_record_get_str_p(child_record, _contacts_address.extended, &charValue);
718 address->setAdditionalInformation(charValue);
720 contacts_record_get_str_p(child_record, _contacts_address.country, &charValue);
722 address->setCountry(charValue);
724 contacts_record_get_bool(child_record, _contacts_address.is_default, &boolValue);
725 address->setIsDefault(boolValue);
727 contacts_record_get_int(child_record, _contacts_address.type, &intValue);
728 if(intValue & CONTACTS_ADDRESS_TYPE_HOME)
729 address->addType(CONTACT_ADDRESS_TYPE_HOME);
730 if(intValue & CONTACTS_ADDRESS_TYPE_WORK)
731 address->addType(CONTACT_ADDRESS_TYPE_WORK);
733 // TODO Will be added after type changed to string
734 // if(intValue & CONTACTS_ADDRESS_TYPE_CUSTOM)
736 // contacts_record_get_str_p(child_record, _contacts_address.label, &charValue);
738 // address->addType(CUSTOM);
743 void ContactObjectP2AConverter::exportWebAddrList()
746 unsigned int child_count = 0;
748 if(m_abstractContact->getUrlsNum() > 0)
749 m_abstractContact->clearUrls();
751 errorCode = contacts_record_get_child_record_count(m_platformContact, _contacts_contact.url, &child_count);
752 if(errorCode != CONTACTS_ERROR_NONE && errorCode != CONTACTS_ERROR_NO_DATA)
753 ThrowMsg(UnknownException, "getting address list (err:" << errorCode << ")");
755 if(child_count == 0 || errorCode == CONTACTS_ERROR_NO_DATA)
757 //LogDebug("Platform contact don't have address list");
761 ContactWebSiteArrayPtr urls = m_abstractContact->getUrls();
763 for(unsigned int i=0; i<child_count; i++)
765 contacts_record_h child_record = NULL;
767 errorCode = contacts_record_get_child_record_at_p(m_platformContact, _contacts_contact.url, i, &child_record);
768 if(errorCode != CONTACTS_ERROR_NONE && errorCode != CONTACTS_ERROR_NO_DATA)
771 ContactWebSitePtr url(new ContactWebSite());
773 char *charValue = NULL;
776 urls->push_back(url);
778 contacts_record_get_str_p(child_record, _contacts_url.url, &charValue);
780 url->setUrl(charValue);
782 contacts_record_get_int(child_record, _contacts_url.type, &intValue);
783 if(intValue == CONTACTS_URL_TYPE_HOME)
784 url->setType(WEBSITE_TYPE_HOMEPAGE);
785 else if(intValue == CONTACTS_URL_TYPE_WORK)
786 url->setType(WEBSITE_TYPE_BLOG);
788 // TODO Will be added after type changed to string
789 // if(intValue & CONTACTS_URL_TYPE_CUSTOM)
791 // contacts_record_get_int(child_record, _contacts_url.label, &intValue);
793 // url->setType(CUSTOM);
798 void ContactObjectP2AConverter::exportNicknameList()
801 unsigned int child_count = 0;
803 ContactNamePtr contactName = m_abstractContact->getName();
804 if(contactName == NULL)
806 contactName = ContactNamePtr(new ContactName());
807 m_abstractContact->setName(contactName);
810 if(contactName->getNicknamesNum() > 0)
811 contactName->clearNicknames();
813 errorCode = contacts_record_get_child_record_count(m_platformContact, _contacts_contact.nickname, &child_count);
814 if(errorCode != CONTACTS_ERROR_NONE && errorCode != CONTACTS_ERROR_NO_DATA)
815 ThrowMsg(UnknownException, "getting nickname list (err:" << errorCode << ")");
817 if(child_count == 0 || errorCode == CONTACTS_ERROR_NO_DATA)
819 //LogDebug("Platform contact don't have nickname list");
823 StringArrayPtr nicknames = contactName->getNicknames();
825 for(unsigned int i=0; i<child_count; i++)
827 contacts_record_h child_record = NULL;
829 errorCode = contacts_record_get_child_record_at_p(m_platformContact, _contacts_contact.nickname, i, &child_record);
830 if(errorCode != CONTACTS_ERROR_NONE && errorCode != CONTACTS_ERROR_NO_DATA)
833 char *charValue = NULL;
835 contacts_record_get_str_p(child_record, _contacts_nickname.name, &charValue);
837 nicknames->push_back(charValue);