/usr/lib/python2.7/dist-packages/kopano/contact.py is in python-kopano 8.5.5-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | """
Part of the high-level python bindings for Kopano
Copyright 2005 - 2016 Zarafa and its licensors (see LICENSE file)
Copyright 2016 - Kopano and its licensors (see LICENSE file)
"""
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
from MAPI import (
KEEP_OPEN_READWRITE,
)
from MAPI.Tags import (
PR_ATTACHMENT_CONTACTPHOTO,
)
from .address import Address
PidLidEmail1AddressType = 'PT_UNICODE:PSETID_Address:0x8082'
PidLidEmail1DisplayName = 'PT_UNICODE:PSETID_Address:0x8080'
PidLidEmail1EmailAddress = 'PT_UNICODE:PSETID_Address:0x8083'
PidLidEmail1OriginalEntryId = 'PT_BINARY:PSETID_Address:0x8085'
#PidLidEmail1OriginalDisplayName = 'PT_UNICODE:PSETID_Address:0x8084'
class Contact(object):
"""Contact mixin class"""
@property
def email(self):
return self.email1
@email.setter
def email(self, addr):
self.email1 = addr
@property
def email1(self):
if self.address1:
return self.address1.email
@email1.setter
def email1(self, addr):
self.address1 = addr
@property
def address1(self):
return Address(
self.server,
self.get(PidLidEmail1AddressType),
self.get(PidLidEmail1DisplayName),
self.get(PidLidEmail1EmailAddress),
self.get(PidLidEmail1OriginalEntryId),
)
@address1.setter
def address1(self, addr):
pr_addrtype, pr_dispname, pr_email, pr_entryid = \
self._addr_props(addr)
self[PidLidEmail1AddressType] = _unicode(pr_addrtype)
self[PidLidEmail1DisplayName] = pr_dispname
self[PidLidEmail1EmailAddress] = pr_email
self[PidLidEmail1OriginalEntryId] = pr_entryid
@property
def photo(self):
for attachment in self.attachments():
if attachment.get(PR_ATTACHMENT_CONTACTPHOTO):
s = StringIO(attachment.data)
s.name = attachment.name
return s
@photo.setter
def photo(self, f):
name, data = f.name, f.read()
for attachment in self.attachments():
if attachment.get(PR_ATTACHMENT_CONTACTPHOTO):
self.delete(attachment)
attachment = self.create_attachment(name, data)
attachment[PR_ATTACHMENT_CONTACTPHOTO] = True
# XXX shouldn't be needed?
self.mapiobj.SaveChanges(KEEP_OPEN_READWRITE)
|