Beispiel #1
0
 def _convert_to_smtp(self, props, tag_data):
     if not hasattr(self.server, '_smtp_cache'): # XXX speed hack, discuss
         self.server._smtp_cache = {}
     for addrtype, email, entryid, name, searchkey in ADDR_PROPS:
         if addrtype not in tag_data or entryid not in tag_data or name not in tag_data:
             continue
         if tag_data[addrtype][1] in (u'SMTP', u'MAPIPDL'): # XXX MAPIPDL==distlist.. can we just dump this?
             continue
         eid = tag_data[entryid][1]
         if eid in self.server._smtp_cache:
             email_addr = self.server._smtp_cache[eid]
         else:
             try:
                 mailuser = self.server.ab.OpenEntry(eid, IID_IMailUser, 0)
                 email_addr = HrGetOneProp(mailuser, PR_SMTP_ADDRESS_W).Value
             except MAPIErrorUnknownEntryid: # XXX corrupt data? keep going but log problem
                 continue
             except MAPIErrorNotFound: # XXX deleted user, or no email address? or user with multiple entryids..heh?
                 continue
             except MAPIErrorInterfaceNotSupported: # XXX ZARAFA group?
                 continue
             self.server._smtp_cache[eid] = email_addr
         tag_data[addrtype][1] = u'SMTP'
         if email in tag_data:
             tag_data[email][1] = email_addr
         else:
             props.append([email, email_addr, None])
         tag_data[entryid][1] = self.server.ab.CreateOneOff(tag_data[name][1], u'SMTP', email_addr, MAPI_UNICODE)
         key = b'SMTP:' + email_addr.upper().encode('ascii')
         if searchkey in tag_data: # XXX probably need to create, also email
             tag_data[searchkey][1] = key
         else:
             props.append([searchkey, key, None])