{% macro contact_entry(ab_id, ctc, detail, now) %}
{{ ctc.head.uuid }}
{% if ctc.detail.personal_email or ctc.detail.work_phone or ctc.detail.im_email or ctc.detail.other_email %}
{% if ctc.detail.work_email %}
{{ email_entry('ContactEmailBusiness', ctc.detail.work_email) }}
{% endif %}
{% if ctc.detail.im_email %}
{{ email_entry('ContactEmailMessenger', ctc.detail.im_email) }}
{% endif %}
{% if ctc.detail.other_email %}
{{ email_entry('ContactEmailOther', ctc.detail.other_email) }}
{% endif %}
{% if ctc.detail.personal_email %}
{{ email_entry('ContactEmailPersonal', ctc.detail.personal_email) }}
{% endif %}
{% endif %}
{% if ctc.detail.home_phone or ctc.detail.work_phone or ctc.detail.fax_phone or ctc.detail.pager_phone or ctc.detail.mobile_phone or ctc.detail.other_phone %}
{% if ctc.detail.work_phone %}
{{ phone_entry('ContactPhoneBusiness', contact.work_phone) }}
{% endif %}
{% if ctc.detail.fax_phone %}
{{ phone_entry('ContactPhoneFax', ctc.detail.fax_phone) }}
{% endif %}
{% if ctc.detail.pager_phone %}
{{ phone_entry('ContactPhonePager', ctc.detail.pager_phone) }}
{% endif %}
{% if ctc.detail.mobile_phone %}
{{ phone_entry('ContactPhoneMobile', ctc.detail.mobile_phone) }}
{% endif %}
{% if ctc.detail.other_phone %}
{{ phone_entry('ContactPhoneOther', ctc.detail.other_phone) }}
{% endif %}
{% if ctc.detail.home_phone %}
{{ phone_entry('ContactPhonePersonal', ctc.detail.home_phone) }}
{% endif %}
{% endif %}
{% if ctc.detail.locations %}
{% for location in ctc.detail.locations.values() %}
{% if location.street or location.city or location.state or location.country or location.zip_code %}
{{ location.type }}
{% if location.street %}
{{ location.street }}
{% endif %}
{% if location.city %}
{{ location.city }}
{% endif %}
{% if location.state %}
{{ location.state }}
{% endif %}
{% if location.country %}
{{ location.country }}
{% endif %}
{% if location.zip_code %}
{{ location.zip_code }}
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% if ctc.detail.personal_website or ctc.detail.business_website %}
{% if ctc.detail.business_website %}
{{ website_entry('ContactWebSiteBusiness', ctc.detail.business_website) }}
{% endif %}
{% if ctc.detail.personal_website %}
{{ website_entry('ContactWebSitePersonal', ctc.detail.personal_website) }}
{% endif %}
{% endif %}
{% if ctc.detail.nickname %}
{{ annotation('AB.NickName', ctc.detail.nickname) }}
{% endif %}
Regular
{{ ctc.status.name }}
{% if ctc.detail.first_name %}
{{ ctc.detail.first_name }}
{% endif %}
{% if ctc.detail.middle_name %}
{{ ctc.detail.middle_name }}
{% endif %}
{% if ctc.detail.last_name %}
{{ ctc.detail.last_name }}
{% endif %}
{{ ctc.head.email }}
false
{{ ctc.status.name }}
{{ puid_format(ctc.head.uuid) }}
{% if ctc._groups %}
{% for group in ctc._groups.copy() %}
{{ group.uuid }}
{% endfor %}
{% endif %}
{{ cid_format(ctc.head.uuid, decimal = True) }}
false
false
{{ bool_to_str(ctc.is_messenger_user) }}
{% if ab_id == '00000000-0000-0000-0000-000000000000' %}{{ bool_to_str(contact_is_favorite(detail, ctc)) }}{% else %}false{% endif %}
false
false
NoDevice
{% if ctc.detail.birthdate %}{{ date_format(ctc.detail.birthdate) }}{% else %}0001-01-01T00:00:00{% endif %}
{% if ctc.detail.anniversary %}
{{ ctc.detail.anniversary.strftime('%Y/%m/%d') }}
{% endif %}
{% if ctc.detail.notes %}
{{ ctc.detail.notes }}
{% endif %}
{% if ctc.detail.primary_email_type %}{{ ctc.detail.primary_email_type }}{% else %}ContactEmailPersonal{% endif %}
ContactLocationPersonal
ContactPhonePersonal
false
Unspecified
None
false
{{ now }}
{% endmacro %}
{% macro phone_entry(type, phone) %}
{{ type }}
{{ phone }}
false
{% endmacro %}
{% macro email_entry(type, email) %}
{{ type }}
{{ email }}
false
0
false
{% endmacro %}
{% macro website_entry(type, url) %}
{{ type }}
{{ url }}
{% endmacro %}
{% macro annotation(name, value) %}
{{ name }}
{{ value }}
{% endmacro %}
{% macro generate_me_entry(user, now) %}
{{ user.uuid }}
MSN.IM.MBEA
0
MSN.IM.GTC
{% if user.settings.get('GTC') == 'A' %}1{% elif user.settings.get('GTC') == 'N' %}2{% else %}0{% endif %}
MSN.IM.BLP
{% if user.settings.get('BLP') == 'AL' %}1{% elif user.settings.get('BLP') == 'BL' %}2{% else %}0{% endif %}
{% if user.settings.get('MPOP') %}
MSN.IM.MPOP
{{ user.settings.get('MPOP') }}
{% endif %}
{% if user.settings.get('RLP') %}
MSN.IM.RoamLiveProperties
{{ user.settings.get('RLP') }}
{% endif %}
Me
{{ user.status.name }}
{{ user.email }}
false
{{ user.status.name }}
{{ puid_format(user.uuid) }}
{{ cid_format(user.uuid, decimal = True) }}
false
false
false
false
false
false
NoDevice
0001-01-01T00:00:00
ContactEmailPersonal
ContactLocationPersonal
ContactPhonePersonal
false
Unspecified
None
false
{{ now }}
{% endmacro %}
{% macro group_entry(group, now) %}
{{ group.uuid }}
MSN.IM.Display
1
c8529ce2-6ead-434d-881f-341e17db3ff8
{{ group.name }}
false
false
{{ bool_to_str(group.is_favorite) }}
false
{{ now }}
{% endmacro %}