Changeset 2318
- Timestamp:
- 07/12/07 08:07:53 (1 year ago)
- Files:
-
- plugins/moto-sync/motosync.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/moto-sync/motosync.py
r2255 r2318 105 105 # reverse of the above (almost): mapping from vcard to phone's contact type 106 106 VCARD_CONTACT_TYPES = { 107 ' Work': 0,108 ' Home': 1,109 ' Voice': 2,110 ' Cellular': 3,111 ' Car': 3,112 ' Message': 5,113 ' Fax': 4,114 ' Pager': 5,107 'work': 0, 108 'home': 1, 109 'voice': 2, 110 'cellular': 3, 111 'car': 3, 112 'message': 5, 113 'fax': 4, 114 'pager': 5, 115 115 } 116 116 … … 118 118 # can also have dom/intl/postal/parcel... these don't really make sense here 119 119 VCARD_ADDRESS_TYPES = { 120 ' Work': 0,121 ' Home': 1,120 'work': 0, 121 'home': 1, 122 122 } 123 123 … … 1713 1713 last = self.name[self.firstlast_index:].strip() 1714 1714 if self.firstlast_enabled: 1715 appendXMLTag(doc, e, 'LastName', first) 1715 1716 appendXMLTag(doc, e, 'FirstName', last) 1716 appendXMLTag(doc, e, 'LastName', first)1717 1717 else: 1718 appendXMLTag(doc, e, 'LastName', last) 1718 1719 appendXMLTag(doc, e, 'FirstName', first) 1719 appendXMLTag(doc, e, 'LastName', last)1720 1720 top.appendChild(e) 1721 1721 … … 1821 1821 # filter out any illegal characters from the phone number 1822 1822 content = filter(lambda c: c in TEL_NUM_DIGITS, content) 1823 ical_types = elt.getAttribute('Type').split(';') 1823 ical_types = elt.getAttribute('Location').split(';') 1824 ical_types.extend(elt.getAttribute('Type').split(';')) 1824 1825 is_pref = elt.hasAttribute('Preferred') and elt.getAttribute('Preferred') in ['1', 'true'] 1825 1826 moto_type = MOTO_CONTACT_DEFAULT 1826 1827 for t in ical_types: 1828 t = t.lower() 1827 1829 if VCARD_CONTACT_TYPES.has_key(t): 1828 1830 moto_type = VCARD_CONTACT_TYPES[t] … … 1854 1856 ical_types = adr.getAttribute('Location').split(';') 1855 1857 for t in ical_types: 1858 t = t.lower() 1856 1859 if VCARD_ADDRESS_TYPES.has_key(t): 1857 1860 moto_type = VCARD_ADDRESS_TYPES[t] … … 1964 1967 else: 1965 1968 e = doc.createElement('Telephone') 1966 if MOTO_PHONE_CONTACT_TYPES.has_key(self.contacttype): 1969 if MOTO_PHONE_CONTACT_LOCATIONS.has_key(self.contacttype): 1970 e.setAttribute('Location', MOTO_PHONE_CONTACT_LOCATIONS[self.contacttype]) 1971 elif MOTO_PHONE_CONTACT_TYPES.has_key(self.contacttype): 1967 1972 e.setAttribute('Type', MOTO_PHONE_CONTACT_TYPES[self.contacttype]) 1968 elif MOTO_PHONE_CONTACT_LOCATIONS.has_key(self.contacttype):1969 e.setAttribute('Location', MOTO_PHONE_CONTACT_LOCATIONS[self.contacttype])1970 1973 if self.primaryflag: 1971 1974 e.setAttribute('Preferred', 'true')
