def parseEIMML(view, peer, matchingAddresses, eimml): if isMeAddress(peer): # If the Chandler EIMML message is from me then # ignore it. return (0, None) try: item = inbound(matchingAddresses, eimml) mailStamp = MailStamp(item) mailStamp.fromEIMML = True return (1, mailStamp) except sharingErrors.MalformedData, e: # The eimml records contained bogus # syntax and will not be processed # Raising an error here would result # in the entire mail download being # terminated so we log the error # instead logging.exception(e) return (-1, None)
def addMaiStamp(item): ms = MailStamp(item) ms.add() ms.subject = uw("Test Mail") ms.body = uw("Test ") * 60 toAddr = EmailAddress.getEmailAddress(view, "*****@*****.**") ms.toAddress.append(toAddr) ms.fromAddress = EmailAddress.getEmailAddress(view, "*****@*****.**") ms.ccAddress.append(ms.fromAddress) org = EmailAddress.getEmailAddress(view, "The Management") ms.originators.append(org) return ms
def addDisplayWhos(self, whos): """ Add tuples to the "whos" list: (priority, "text", source name) """ commState = CommunicationStatus.getItemCommState(self.itsItem) lastModifiedBy = self.itsItem.lastModifiedBy stamp_types = Stamp(self.itsItem).stamp_types isMessage = stamp_types and MailStamp in stamp_types if lastModifiedBy is not None: lastModifiedBy = lastModifiedBy.getLabel() # (bug 10927: We only want to include ed/up if the item is either not # a message, or not read) if (commState & (CommunicationStatus.EDITED | CommunicationStatus.UPDATE)) and \ (not isMessage or not (commState & CommunicationStatus.READ)): lastMod = self.itsItem.lastModification if lastMod == Modification.edited: whos.append((1, lastModifiedBy, 'editor')) else: whos.append((1, lastModifiedBy, 'updater')) else: whos.append((1000, lastModifiedBy, 'creator')) if isMessage: msg = MailStamp(self.itsItem) preferFrom = (commState & CommunicationStatus.OUT) == 0 toAddress = getattr(msg, 'toAddress', schema.Nil) toText = u", ".join(x.getLabel() for x in toAddress) whos.append((preferFrom and 4 or 2, toText, 'to')) originators = getattr(msg, 'originators', schema.Nil) if len(originators) > 0: originatorsText = u", ".join(x.getLabel() for x in originators) if len(originatorsText) > 0: whos.append((preferFrom and 2 or 3, originatorsText, 'from')) fromAddress = getattr(msg, 'fromAddress', None) if fromAddress is not None: fromText = fromAddress.getLabel() if len(fromText) > 0: whos.append((preferFrom and 3 or 4, fromText, 'from'))
for case in INCOMING_TEST_CASES: try: action = None if len(case) == 3: file, logName, action = case else: file, logName = case mailText = loadMailFile(file) logger.Start(logName) item = messageTextToKind(view, mailText) ms = MailStamp(item) if action: if action == "E": parseEventInfo(ms) elif action == "T": parseTaskInfo(ms) ms.incomingMessage() # Commiting of a parsed message is # part of the performance metrics. view.commit() logger.Stop() # Test Phase: Verification
# use the master, if a modification happens to be the first item item = getattr(item, 'inheritFrom', item) if item.displayName and len(item.displayName.strip()): # The displayName will contain the ics summary icsSummary = item.displayName if item.body and len(item.displayName.strip()): # The body will contain the ics description icsDesc = item.body if not has_stamp(item, MailStamp): if has_stamp(item, EventStamp): EventStamp(item).addStampToAll(MailStamp) else: ms = MailStamp(item) ms.add() mailStamp = MailStamp(item) mailStamp.fromEIMML = False return (mailStamp, icsDesc, icsSummary) return None def buildBody(bodyBuffer): if len(bodyBuffer.get('plain')): body = removeCarriageReturn(u"\n".join(bodyBuffer.get('plain'))) elif len(bodyBuffer.get('html')): htmlBuffer = bodyBuffer.get('html')
# use the master, if a modification happens to be the first item item = getattr(item, 'inheritFrom', item) if item.displayName and len(item.displayName.strip()): # The displayName will contain the ics summary icsSummary = item.displayName if item.body and len(item.displayName.strip()): # The body will contain the ics description icsDesc = item.body if not has_stamp(item, MailStamp): if has_stamp(item, EventStamp): EventStamp(item).addStampToAll(MailStamp) else: ms = MailStamp(item) ms.add() mailStamp = MailStamp(item) mailStamp.fromEIMML = False return (mailStamp, icsDesc, icsSummary) return None def buildBody(bodyBuffer): if len(bodyBuffer.get('plain')): body = removeCarriageReturn(u"\n".join(bodyBuffer.get('plain'))) elif len(bodyBuffer.get('html')):