def blocks(self, start=None, end=None): """ Freebusy blocks :param start: start of period :param end: end of period """ eid = _bdec(self.store.user.userid) if start: ftstart = datetime_to_filetime(start) else: ftstart = FileTime(0) if end: ftend = datetime_to_filetime(end) else: ftend = FileTime(0xFFFFFFFFFFFFFFFF) fb = libfreebusy.IFreeBusySupport() fb.Open(self.store.server.mapisession, self.store.mapiobj, False) fbdata = fb.LoadFreeBusyData([eid], None) if fbdata in (0, 1): # XXX what? return data, status = fbdata fb.Close() enum = data.EnumBlocks(ftstart, ftend) while True: blocks = enum.Next(100) if blocks: for block in blocks: yield FreeBusyBlock(block) else: break
def publish(self, start=None, end=None): """Publish freebusy information for the given period. :param start: start of period :param end: end of period """ eid = _bdec(self.store.user.userid) # TODO merge with blocks ftstart = datetime_to_filetime(start) # TODO tz? ftend = datetime_to_filetime(end) # TODO tz? fb = libfreebusy.IFreeBusySupport() fb.Open(self.store.server.mapisession, self.store.mapiobj, False) update, status = fb.LoadFreeBusyUpdate([eid], None) blocks = [] for occ in self.store.calendar.occurrences(start, end): start = datetime_to_rtime(occ.start) end = datetime_to_rtime(occ.end) # Fall back on busy, same as WebApp blocks.append( MAPI.Struct.FreeBusyBlock( start, end, STATUS_FB[occ.busystatus] if occ.busystatus else 2)) update.PublishFreeBusy(blocks) update.SaveChanges(ftstart, ftend) fb.Close()
def publish(self, start=None, end=None): """Publish freebusy information for the given period. :param start: start of period (must be localtime (naive) or non-naive datetime instance) :param end: end of period (must be localtime (naive) or non-naive datetime instance) """ eid = _bdec(self.store.user.userid) # TODO merge with blocks ftstart = _utils.datetime_to_filetime(start) ftend = _utils.datetime_to_filetime(end) fb = libfreebusy.IFreeBusySupport() try: fb.Open(self.store.server.mapisession, self.store.mapiobj, False) except MAPI.Struct.MAPIErrorNotFound: raise NotFoundError("public store not found") update, status = fb.LoadFreeBusyUpdate([eid], None) blocks = [] for occ in self.store.calendar.occurrences(start, end): start = datetime_to_rtime(occ.start) end = datetime_to_rtime(occ.end) # Fall back on busy, same as WebApp blocks.append( MAPI.Struct.FreeBusyBlock( start, end, STATUS_FB[occ.busystatus] if occ.busystatus else STATUS_FB['busy'])) update.PublishFreeBusy(blocks) update.SaveChanges(ftstart, ftend) fb.Close()
def publish(self, start=None, end=None): """ Publish freebusy data :param start: start of period :param end: end of period """ eid = _bdec(self.store.user.userid) # XXX merge with blocks ftstart, ftend = datetime_to_filetime(start), datetime_to_filetime( end) # XXX tz? fb = libfreebusy.IFreeBusySupport() fb.Open(self.store.server.mapisession, self.store.mapiobj, False) update, status = fb.LoadFreeBusyUpdate([eid], None) blocks = [] for occ in self.store.calendar.occurrences(start, end): start = datetime_to_rtime(occ.start) end = datetime_to_rtime(occ.end) blocks.append(MAPI.Struct.FreeBusyBlock(start, end, 2)) update.PublishFreeBusy(blocks) update.SaveChanges(ftstart, ftend) fb.Close()
def blocks(self, start=None, end=None): """Return all :class:`freebusy blocks <FreeBusyBlock>` for the given period. :param start: start of period (must be localtime (naive) or non-naive datetime instance) :param end: end of period (must be localtime (naive) or non-naive datetime instance) """ eid = _bdec(self.store.user.userid) if start: ftstart = _utils.datetime_to_filetime(start) else: ftstart = FileTime(0) if end: ftend = _utils.datetime_to_filetime(end) else: ftend = FileTime(0xFFFFFFFFFFFFFFFF) fb = libfreebusy.IFreeBusySupport() try: fb.Open(self.store.server.mapisession, self.store.mapiobj, False) except MAPI.Struct.MAPIErrorNotFound: raise NotFoundError("public store not found") fbdata = fb.LoadFreeBusyData([eid], None) if fbdata in (0, 1): # TODO what? return data, status = fbdata fb.Close() enum = data.EnumBlocks(ftstart, ftend) while True: blocks = enum.Next(100) if blocks: for block in blocks: yield FreeBusyBlock(block) else: break
def freebusy_user(session, store): fb = libfreebusy.IFreeBusySupport() fb.Open(session, store, False) yield fb fb.Close()