/usr/lib/python2.7/dist-packages/kopano/meetingrequest.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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 | """
Part of the high-level python bindings for Kopano
Copyright 2017 - Kopano and its licensors (see LICENSE file for details)
"""
from calendar import timegm
import datetime
import struct
import sys
import libfreebusy
from MAPI import (
MAPI_UNICODE, MODRECIP_MODIFY, KEEP_OPEN_READWRITE, RELOP_EQ,
MODRECIP_ADD, MAPI_TO, MAPI_BCC, SUPPRESS_RECEIPT, MSGFLAG_READ,
MSGFLAG_UNSENT, MODRECIP_REMOVE,
)
from MAPI.Tags import (
PT_BOOLEAN, PR_RECIPIENT_TRACKSTATUS, PR_MESSAGE_RECIPIENTS,
PR_MESSAGE_CLASS_W, PR_ENTRYID, PR_SENT_REPRESENTING_ENTRYID, PR_ROWID,
PR_ADDRTYPE_W, PR_EMAIL_ADDRESS_W, PR_SMTP_ADDRESS_W, PR_PROCESSED,
IID_IMAPITable, IID_IMessage, PR_RECIPIENT_TRACKSTATUS_TIME,
PR_RCVD_REPRESENTING_NAME_W, PR_DISPLAY_NAME_W, PR_RECIPIENT_ENTRYID,
PR_RECIPIENT_TYPE, PR_SEND_INTERNET_ENCODING, PR_SEND_RICH_INFO,
PR_RECIPIENT_DISPLAY_NAME, PR_DISPLAY_TYPE, PR_RECIPIENT_FLAGS,
PR_OBJECT_TYPE, PR_SEARCH_KEY, PR_PROPOSED_NEWTIME, PR_OWNER_APPT_ID,
PR_PROPOSED_NEWTIME_START, PR_PROPOSED_NEWTIME_END,
PR_SENT_REPRESENTING_NAME_W, PR_SENT_REPRESENTING_EMAIL_ADDRESS_W,
PR_RECIPIENT_DISPLAY_NAME_W, PR_SENT_REPRESENTING_ADDRTYPE_W,
PR_SENT_REPRESENTING_SEARCH_KEY, PR_ACCOUNT_W, PR_DISPLAY_TYPE_EX,
PR_SUBJECT_W, PR_MESSAGE_FLAGS, recipSendable, recipOrganizer,
recipOriginal, respTentative, respAccepted, respDeclined,
)
from MAPI.Defs import (
PpropFindProp,
)
from MAPI.Struct import (
SPropValue, SPropertyRestriction, MAPIErrorUnknownEntryid,
)
from .compat import repr as _repr
from .errors import Error
from .restriction import Restriction
if sys.hexversion >= 0x03000000:
try:
from . import utils as _utils
except ImportError:
_utils = sys.modules[__package__+'.utils']
from . import property_ as _prop
else:
import utils as _utils
import property_ as _prop
# XXX move all pidlids into separate definition file, plus short description of their meanings
PidLidReminderDelta = "PT_LONG:PSETID_Common:0x8501"
PidLidReminderSet = "PT_BOOLEAN:PSETID_Common:0x8503"
PidLidCommonStart = "PT_SYSTIME:PSETID_Common:0x8516"
PidLidCommonEnd ="PT_SYSTIME:PSETID_Common:0x8517"
PidLidUseTnef = "PT_BOOLEAN:PSETID_Common:0x8582"
PidLidAttendeeCriticalChange = "PT_SYSTIME:PSETID_Meeting:0x1"
PidLidWhere = "PT_STRING8:PSETID_Meeting:0x2"
PidLidGlobalObjectId = "PT_BINARY:PSETID_Meeting:0x3"
PidLidIsSilent = "PT_LONG:PSETID_Meeting:0x4"
PidLidIsRecurring = "PT_BOOLEAN:PSETID_Meeting:0x5"
PidLidIsException = "PT_BOOLEAN:PSETID_Meeting:0xA"
PidLidStartRecurrenceDate = "PT_LONG:PSETID_Meeting:0xD"
PidLidStartRecurrenceTime = "PT_LONG:PSETID_Meeting:0xE"
PidLidEndRecurrenceDate = "PT_LONG:PSETID_Meeting:0xF"
PidLidEndRecurrenceTime = "PT_LONG:PSETID_Meeting:0x10"
PidLidOwnerCriticalChange = "PT_SYSTIME:PSETID_Meeting:0x1A"
PidLidCleanGlobalObjectId = "PT_BINARY:PSETID_Meeting:0x23"
PidLidAppointmentMessageClass = "PT_STRING8:PSETID_Meeting:0x24"
PidLidMeetingType = "PT_LONG:PSETID_Meeting:0x26"
PidLidAppointmentSequence = "PT_LONG:PSETID_Appointment:0x8201"
PidLidAppointmentSequenceTime = "PT_LONG:PSETID_Appointment:0x8202"
PidLidAppointmentLastSequence = "PT_LONG:PSETID_Appointment:0x8203"
PidLidBusyStatus = "PT_LONG:PSETID_Appointment:0x8205"
PidLidLocation = "PT_STRING8:PSETID_Appointment:0x8208"
PidLidAppointmentStartWhole = "PT_SYSTIME:PSETID_Appointment:0x820D"
PidLidAppointmentEndWhole = "PT_SYSTIME:PSETID_Appointment:0x820E"
PidLidAppointmentRecur = "PT_BINARY:PSETID_Appointment:0x8216"
PidLidAppointmentStateFlags = "PT_LONG:PSETID_Appointment:0x8217"
PidLidResponseStatus = "PT_LONG:PSETID_Appointment:0x8218"
PidLidSendAsIcal = "PT_BOOLEAN:PSETID_Appointment:0x8200" # XXX undocumented?
PidLidAppointmentReplyTime = "PT_SYSTIME:PSETID_Appointment:0x8220"
PidLidRecurring = "PT_BOOLEAN:PSETID_Appointment:0x8223"
PidLidIntendedBusyStatus = "PT_LONG:PSETID_Appointment:0x8224"
PidLidExceptionReplaceTime = "PT_SYSTIME:PSETID_Appointment:0x8228"
PidLidFInvited = "PT_BOOLEAN:PSETID_Appointment:0x8229"
PidLidAppointmentReplyName = "PT_STRING8:PSETID_Appointment:0x8230"
PidLidRecurrencePattern = "PT_STRING8:PSETID_Appointment:0x8232"
PidLidTimeZoneStruct = "PT_BINARY:PSETID_Appointment:0x8233"
PidLidTimeZoneDescription = "PT_STRING8:PSETID_Appointment:0x8234"
PidLidClipStart = "PT_SYSTIME:PSETID_Appointment:0x8235"
PidLidClipEnd = "PT_SYSTIME:PSETID_Appointment:0x8236"
PidLidToAttendeesString = "PT_STRING8:PSETID_Appointment:0x823B"
PidLidCcAttendeesString = "PT_STRING8:PSETID_Appointment:0x823C"
PidLidAppointmentProposedStartWhole = "PT_SYSTIME:PSETID_Appointment:0x8250"
PidLidAppointmentProposedEndWhole = "PT_SYSTIME:PSETID_Appointment:0x8251"
PidLidAppointmentProposedDuration = "PT_LONG:PSETID_Appointment:0x8256"
PidLidAppointmentCounterProposal = "PT_BOOLEAN:PSETID_Appointment:0x8257"
# all of the above
PROPTAGS = [
PidLidReminderDelta, PidLidReminderSet, PidLidCommonStart, PidLidCommonEnd,
PidLidUseTnef, PidLidAttendeeCriticalChange, PidLidWhere,
PidLidGlobalObjectId, PidLidIsSilent, PidLidIsRecurring, PidLidIsException,
PidLidStartRecurrenceDate, PidLidStartRecurrenceTime,
PidLidEndRecurrenceDate, PidLidEndRecurrenceTime,
PidLidOwnerCriticalChange, PidLidCleanGlobalObjectId,
PidLidAppointmentMessageClass, PidLidMeetingType,
PidLidAppointmentSequence, PidLidAppointmentSequenceTime,
PidLidAppointmentLastSequence, PidLidBusyStatus, PidLidLocation,
PidLidAppointmentStartWhole, PidLidAppointmentEndWhole,
PidLidAppointmentRecur, PidLidAppointmentStateFlags, PidLidResponseStatus,
PidLidAppointmentReplyTime, PidLidRecurring, PidLidIntendedBusyStatus,
PidLidExceptionReplaceTime, PidLidFInvited, PidLidAppointmentReplyName,
PidLidRecurrencePattern, PidLidTimeZoneStruct, PidLidTimeZoneDescription,
PidLidClipStart, PidLidClipEnd, PidLidToAttendeesString,
PidLidCcAttendeesString, PidLidAppointmentProposedStartWhole,
PidLidAppointmentProposedEndWhole, PidLidAppointmentProposedDuration,
PidLidAppointmentCounterProposal, PidLidSendAsIcal,
]
RECIP_PROPS = [
PR_ENTRYID,
PR_DISPLAY_NAME_W,
PR_EMAIL_ADDRESS_W,
PR_RECIPIENT_ENTRYID,
PR_RECIPIENT_TYPE,
PR_SEND_INTERNET_ENCODING,
PR_SEND_RICH_INFO,
PR_RECIPIENT_DISPLAY_NAME, # XXX _W?
PR_ADDRTYPE_W,
PR_DISPLAY_TYPE,
PR_RECIPIENT_TRACKSTATUS,
PR_RECIPIENT_TRACKSTATUS_TIME,
PR_RECIPIENT_FLAGS,
PR_ROWID,
PR_OBJECT_TYPE,
PR_SEARCH_KEY,
]
def _organizer_props(cal_item, item):
has_organizer = False
table = cal_item.mapiobj.OpenProperty(PR_MESSAGE_RECIPIENTS, IID_IMAPITable, MAPI_UNICODE, 0)
for row in table.QueryRows(-1, 0):
recipient_flags = PpropFindProp(row, PR_RECIPIENT_FLAGS)
if recipient_flags and recipient_flags.Value == (recipOrganizer | recipSendable): # XXX
has_organizer = True
break
if not has_organizer:
return [
SPropValue(PR_ENTRYID, item.prop(PR_SENT_REPRESENTING_ENTRYID).value),
SPropValue(PR_DISPLAY_NAME_W, item.prop(PR_SENT_REPRESENTING_NAME_W).value),
SPropValue(PR_EMAIL_ADDRESS_W, item.prop(PR_SENT_REPRESENTING_EMAIL_ADDRESS_W).value),
SPropValue(PR_RECIPIENT_TYPE, MAPI_TO),
SPropValue(PR_RECIPIENT_DISPLAY_NAME_W, item.prop(PR_SENT_REPRESENTING_NAME_W).value),
SPropValue(PR_ADDRTYPE_W, item.prop(PR_SENT_REPRESENTING_ADDRTYPE_W).value), # XXX php
SPropValue(PR_RECIPIENT_TRACKSTATUS, 0),
SPropValue(PR_RECIPIENT_FLAGS, (recipOrganizer | recipSendable)),
SPropValue(PR_SEARCH_KEY, item.prop(PR_SENT_REPRESENTING_SEARCH_KEY).value),
]
class MeetingRequest(object):
"""MeetingRequest class"""
def __init__(self, item):
self.item = item
@property
def calendar(self):
""" Respective :class:`calendar <Folder>` (possibly in delegator store) """
delegator = self.item.get_prop(PR_RCVD_REPRESENTING_NAME_W)
if delegator:
store = self.item.server.user(delegator.value).store
else:
store = self.item.store # XXX pass to __init__
return store.calendar
@property
def calendar_item(self):
""" Global calendar item :class:`item <Item>` (possibly in delegator store) """
goid = self.item.get_prop(PidLidCleanGlobalObjectId)
if goid is not None:
restriction = Restriction(SPropertyRestriction(
RELOP_EQ, goid.proptag, SPropValue(goid.proptag, goid.mapiobj.Value))
)
return next(self.calendar.items(restriction), None)
@property
def basedate(self):
""" Exception date """
blob = self.item.get(PidLidGlobalObjectId)
if blob is not None:
y, m, d = struct.unpack_from('>HBB', blob, 16)
if (y, m, d) != (0, 0, 0):
ts = timegm(datetime.datetime(y, m, d).timetuple())
tz = self.item.get(PidLidTimeZoneStruct)
return _utils._to_gmt(datetime.datetime.fromtimestamp(ts), tz)
@property
def update_counter(self):
""" Update counter """
return self.item.get(PidLidAppointmentSequence)
@property
def track_status(self):
""" Track status """
return {
'IPM.Schedule.Meeting.Resp.Tent': respTentative,
'IPM.Schedule.Meeting.Resp.Pos': respAccepted,
'IPM.Schedule.Meeting.Resp.Neg': respDeclined,
}.get(self.item.message_class)
@property
def processed(self):
""" Has the request/response been processed """
processed = self.item.get(PR_PROCESSED) or False
@processed.setter
def processed(self, value):
self.item[PR_PROCESSED] = value
def _check_processed(self):
if self.processed:
return True
else:
self.processed = True
@property
def is_request(self):
return self.item.message_class == 'IPM.Schedule.Meeting.Request'
@property
def is_response(self):
return self.item.message_class.startswith('IPM.Schedule.Meeting.Resp.')
@property
def is_cancellation(self):
return self.item.message_class == 'IPM.Schedule.Meeting.Canceled'
def _respond(self, subject_prefix, message_class, message=None):
response = self.item.copy(self.item.store.outbox)
response.message_class = message_class
response.subject = subject_prefix + ': ' + self.item.subject
if message:
response.body = message
response.to = self.item.server.user(email=self.item.from_.email) # XXX
response.from_ = self.item.store.user # XXX slow?
response.send()
def _init_calitem(self, cal_item, tentative, merge=False): # XXX what about updating existing
cal_item.message_class = 'IPM.Appointment'
# busystatus
intended_busystatus = self.item.get(PidLidIntendedBusyStatus)
if intended_busystatus is not None:
if tentative and intended_busystatus != libfreebusy.fbFree: # XXX
busystatus = libfreebusy.fbTentative
else:
busystatus = intended_busystatus
cal_item[PidLidBusyStatus] = busystatus
# add organizer as recipient
organizer_props = _organizer_props(cal_item, self.item)
if organizer_props and not merge:
table = cal_item.mapiobj.OpenProperty(PR_MESSAGE_RECIPIENTS, IID_IMAPITable, MAPI_UNICODE, 0)
table.SetColumns(RECIP_PROPS, 0)
rows = table.QueryRows(-1, 0)
if tentative: # XXX php-compat: php checks 'move' flag, should we
cal_item.mapiobj.ModifyRecipients(MODRECIP_REMOVE, rows)
cal_item.mapiobj.ModifyRecipients(MODRECIP_ADD, [organizer_props] + rows)
else:
cal_item.mapiobj.ModifyRecipients(MODRECIP_ADD, [organizer_props])
cal_item.mapiobj.SaveChanges(KEEP_OPEN_READWRITE)
def accept(self, tentative=False, response=True, add_bcc=False):
""" Accept meeting request
:param tentative: accept tentatively?
:param response: send response message?
"""
if not self.is_request:
raise Error('item is not a meeting request')
if self._check_processed():
return
calendar = self.calendar
cal_item = self.calendar_item
basedate = self.basedate
self.item.mapiobj.SetReadFlag(SUPPRESS_RECEIPT)
merge = False
if basedate:
# update existing recurrence
if cal_item and cal_item.recurring:
recurrence = cal_item.recurrence
if recurrence.is_exception(basedate):
recurrence.modify_exception(basedate, self.item)
else:
recurrence.create_exception(basedate, self.item)
# otherwise replace calendar item
else:
if cal_item:
calendar.delete(cal_item)
cal_item = self.item.copy(calendar)
self._init_calitem(cal_item, tentative)
else:
# remove existing recurrence
if cal_item and cal_item.recurring:
mr_counter = self.update_counter
cal_counter = cal_item.meetingrequest.update_counter
if mr_counter is not None and cal_counter is not None and \
mr_counter <= cal_counter:
raise Error('trying to accept out-of-date meeting request')
calendar.delete(cal_item)
# determine existing exceptions
goid = self.item.get_prop(PidLidCleanGlobalObjectId)
if goid is not None:
restriction = Restriction(SPropertyRestriction(
RELOP_EQ, goid.proptag, SPropValue(goid.proptag, goid.mapiobj.Value))
)
existing_items = list(calendar.items(restriction))
existing_items.sort(key=lambda i: i.get(PidLidAppointmentStartWhole)) # XXX check php
else:
existing_items = []
# create new recurrence
cal_item = self.item.copy(calendar)
# merge existing exceptions
if cal_item.recurring and existing_items:
merge = True
rec = cal_item.recurrence
for item in existing_items:
rec.create_exception(item.meetingrequest.basedate, item, merge=True)
calendar.delete(existing_items)
self._init_calitem(cal_item, tentative, merge)
# XXX why filter recipients?
if merge or not add_bcc:
table = cal_item.mapiobj.OpenProperty(PR_MESSAGE_RECIPIENTS, IID_IMAPITable, MAPI_UNICODE, 0)
table.SetColumns(RECIP_PROPS, 0)
rows = table.QueryRows(-1, 0)
cal_item.mapiobj.ModifyRecipients(MODRECIP_MODIFY, rows)
cal_item.mapiobj.SaveChanges(KEEP_OPEN_READWRITE)
# add self as BCC for ZCP-9901 XXX still relevant?
proptags = [
PR_ACCOUNT_W,
PR_ADDRTYPE_W,
PR_DISPLAY_NAME_W,
PR_DISPLAY_TYPE,
PR_DISPLAY_TYPE_EX,
PR_EMAIL_ADDRESS_W,
PR_ENTRYID,
PR_OBJECT_TYPE,
PR_SEARCH_KEY,
PR_SMTP_ADDRESS_W,
]
user = self.item.store.user
props = user.mapiobj.GetProps(proptags, 0)
props.extend([
SPropValue(PR_RECIPIENT_ENTRYID, props[6].Value),
SPropValue(PR_RECIPIENT_FLAGS, (recipOriginal | recipSendable)),
SPropValue(PR_RECIPIENT_TRACKSTATUS, 0),
SPropValue(PR_RECIPIENT_TYPE, MAPI_BCC),
])
if add_bcc and not merge:
cal_item.mapiobj.ModifyRecipients(MODRECIP_ADD, [props])
cal_item.mapiobj.SaveChanges(KEEP_OPEN_READWRITE)
# send response
if response:
if tentative:
message_class ='IPM.Schedule.Meeting.Resp.Tent'
else:
message_class ='IPM.Schedule.Meeting.Resp.Pos'
self._respond('Accepted', message_class)
def decline(self, message=None, response=True):
""" Decline meeting request
:param response: send response message?
"""
message_class = 'IPM.Schedule.Meeting.Resp.Neg'
if response:
self._respond('Declined', message_class, message)
def process_cancellation(self, delete=False):
""" Process meeting request cancellation
:param delete: delete appointment from calendar
"""
if not self.is_cancellation:
raise Error('item is not a meeting request cancellation')
cal_item = self.calendar_item
if not cal_item:
return
basedate = self.basedate
if basedate:
if cal_item.recurring:
recurrence = cal_item.recurrence
copytags = [_prop._name_to_proptag(tag, cal_item.mapiobj)[0] for tag in PROPTAGS]
copytags.extend([
PR_SUBJECT_W,
PR_SENT_REPRESENTING_NAME_W,
PR_SENT_REPRESENTING_ADDRTYPE_W,
PR_SENT_REPRESENTING_EMAIL_ADDRESS_W,
PR_SENT_REPRESENTING_ENTRYID,
PR_SENT_REPRESENTING_SEARCH_KEY,
PR_RCVD_REPRESENTING_NAME_W,
])
if delete:
recurrence.delete_exception(basedate, self.item, copytags)
else:
if recurrence.is_exception(basedate):
recurrence.modify_exception(basedate, self.item, copytags)
else:
recurrence.create_exception(basedate, self.item, copytags)
message = recurrence.exception_message(basedate)
message[PidLidBusyStatus] = libfreebusy.fbFree
message[PR_MESSAGE_FLAGS] = MSGFLAG_UNSENT | MSGFLAG_READ
message._attobj.SaveChanges(KEEP_OPEN_READWRITE)
else:
if delete:
self.calendar.delete(cal_item)
else:
self.item.mapiobj.CopyTo([], [], 0, None, IID_IMessage, cal_item.mapiobj, 0)
cal_item.mapiobj.SetProps([SPropValue(PR_MESSAGE_CLASS_W, u'IPM.Appointment')])
if cal_item:
cal_item.mapiobj.SaveChanges(KEEP_OPEN_READWRITE)
def process_response(self):
""" Process meeting request response """
if not self.is_response:
raise Error('item is not a meeting request response')
if self._check_processed():
return
cal_item = self.calendar_item
basedate = self.basedate
# modify calendar item or embedded message (in case of exception)
attach = None
message = None
if basedate:
if cal_item.recurring:
recurrence = cal_item.recurrence
recurrence._update_calitem(self.item) # XXX via create/modify exception
if recurrence.is_exception(basedate):
message = recurrence.exception_message(basedate)
owner_appt_id = self.item.get(PR_OWNER_APPT_ID)
if owner_appt_id is not None:
message[PR_OWNER_APPT_ID] = owner_appt_id
attach = message._attobj
else:
message = cal_item
if not message:
return
# update recipient track status
table = message.mapiobj.OpenProperty(PR_MESSAGE_RECIPIENTS, IID_IMAPITable, MAPI_UNICODE, 0)
table.SetColumns(RECIP_PROPS, 0) # XXX why do things get lot witout this
rows = table.QueryRows(-1, 0)
for row in rows:
if self._compare_ab_entryids(PpropFindProp(row, PR_ENTRYID).Value,
self.item.prop(PR_SENT_REPRESENTING_ENTRYID).value):
trackstatus = PpropFindProp(row, PR_RECIPIENT_TRACKSTATUS)
trackstatus_time = PpropFindProp(row, PR_RECIPIENT_TRACKSTATUS_TIME)
attendee_crit_change = self.item.get_prop(PidLidAttendeeCriticalChange)
if trackstatus_time and attendee_crit_change and \
attendee_crit_change.mapiobj.Value <= trackstatus_time.Value:
continue
if trackstatus_time:
trackstatus_time.Value = attendee_crit_change.mapiobj.Value
else:
row.append(SPropValue(PR_RECIPIENT_TRACKSTATUS_TIME,
attendee_crit_change.mapiobj.Value))
if trackstatus:
trackstatus.Value = self.track_status
else:
row.append(SPropValue(PR_RECIPIENT_TRACKSTATUS, self.track_status))
if self.item.get(PidLidAppointmentCounterProposal) is True:
row.extend([
SPropValue(PR_PROPOSED_NEWTIME, True),
SPropValue(PR_PROPOSED_NEWTIME_START, self.item.prop(PidLidAppointmentProposedStartWhole).mapiobj.Value),
SPropValue(PR_PROPOSED_NEWTIME_END, self.item.prop(PidLidAppointmentProposedEndWhole).mapiobj.Value),
])
message.mapiobj.ModifyRecipients(MODRECIP_MODIFY, rows)
# counter proposal
if self.item.get(PidLidAppointmentCounterProposal):
message[PidLidAppointmentCounterProposal] = True
# save all the things
message.mapiobj.SaveChanges(KEEP_OPEN_READWRITE)
if attach:
attach.SaveChanges(KEEP_OPEN_READWRITE)
cal_item.mapiobj.SaveChanges(KEEP_OPEN_READWRITE)
def _compare_ab_entryids(self, entryid1, entryid2): # XXX shorten?
smtp1 = self._get_smtp_address(entryid1)
smtp2 = self._get_smtp_address(entryid2)
return smtp1 == smtp2
def _get_smtp_address(self, entryid):
ab = self.item.server.ab
try:
abitem = ab.OpenEntry(entryid, None, 0)
except MAPIErrorUnknownEntryid:
return u''
props = abitem.GetProps([PR_ADDRTYPE_W, PR_EMAIL_ADDRESS_W, PR_SMTP_ADDRESS_W], 0)
if props[0].Value == u'SMTP':
return props[1].Value
else:
return props[2].Value
def __unicode__(self):
return u'MeetingRequest()'
def __repr__(self):
return _repr(self)
|