private bool CheckArgument(string category, MAPINtf ntf) { Guard.NullArgument(ntf, "ntf"); if (_bTrace) { Trace(category, ntf); } if (ntf.EntryID != null && ntf.EntryID.Length > 0) { bool ret = OutlookSession.IsMailExported(ntf.EntryID); if (ret) { Trace(category + ": event is ignored"); } return(!ret); } return(true); }
private void ProcessMailModifyImpl(MAPIFullNtf ntf, IEMessage message, FolderDescriptor folderDescriptor) { string messageClass = MessageType.GetMessageClass(message); if (MessageType.InterpretAsMail(messageClass)) { string entryId = OutlookSession.GetMessageID(message); if (OutlookSession.IsMailExported(entryId)) { return; } new MailDescriptor(folderDescriptor, entryId, message, MailDescriptor.UpdateState).QueueJob(JobPriority.AboveNormal); } else if (MessageType.InterpretAsContact(messageClass)) { string realEntryId = message.GetBinProp(MAPIConst.PR_ENTRYID); if (OutlookSession.IsMailExported(realEntryId)) { return; } ContactDescriptorWrapper.Do(folderDescriptor, realEntryId, realEntryId); } else if (MessageType.InterpretAsTask(messageClass)) { _tracer.Trace("Task was modified"); string realEntryId = message.GetBinProp(MAPIConst.PR_ENTRYID); if (OutlookSession.IsMailExported(realEntryId)) { return; } TaskDescriptor.Do(JobPriority.AboveNormal, folderDescriptor, message, realEntryId); } else { ntf = ntf; // _tracer.Trace( "Unknown item of class " + messageClass + " was modified" ); } }
private void OnMailMoveImpl(MAPIFullNtf ntf) { if (CheckStorageIgnored(_storeID)) { return; } FolderDescriptor folderDescriptor = FolderDescriptor.Get(ntf.ParentID, _storeID); if (folderDescriptor == null) { return; } try { IEMessage message = OutlookSession.OpenMessage(ntf.EntryID, _storeID); if (message == null) { return; } using ( message ) { string realID = message.GetBinProp(MAPIConst.PR_ENTRYID); if (realID == null) { realID = ntf.EntryID; } else { if (OutlookSession.IsMailExported(realID)) { return; } } string messageClass = MessageType.GetMessageClass(message); if (MessageType.InterpretAsMail(messageClass)) { Core.ResourceAP.QueueJob(JobPriority.AboveNormal, new MailMovedDescriptor(ntf, _storeID)); } else if (MessageType.InterpretAsContact(messageClass)) { if (folderDescriptor.ContainerClass != FolderType.Contact) { _tracer.Trace("Contact was moved to deleted items"); IResource contact = Core.ResourceStore.FindUniqueResource(STR.Contact, PROP.EntryID, realID); string entryID = realID; if (contact == null && ntf.OldEntryID != null) { _tracer.Trace("contact not found"); contact = Core.ResourceStore.FindUniqueResource(STR.Contact, PROP.EntryID, ntf.OldEntryID); entryID = ntf.EntryID; } if (contact != null) { _tracer.Trace("contact found"); _tracer.Trace("RemoveFromSync"); Contact.RemoveFromSync(contact, entryID); } else { _tracer.Trace("ClearInvalidEntryIDFromContacts"); _jobStrategy.QueueJob(new MethodInvoker(REGISTRY.ClearInvalidEntryIDFromContacts)); } } else { string searchEntryID = realID; if (realID != ntf.OldEntryID) { searchEntryID = ntf.OldEntryID; } _tracer.Trace("ContactDescriptorWrapper process moving"); ContactDescriptorWrapper.Do(_jobStrategy.JobPriority, folderDescriptor, realID, searchEntryID); } //OutlookSession.OutlookProcessor.QueueJob( new ContactDescriptorWrapper( folderDescriptor, ntf.EntryID ) ); } else if (MessageType.InterpretAsTask(messageClass)) { _tracer.Trace("Task was moved"); if (Core.ResourceStore.FindUniqueResource(STR.Task, PROP.EntryID, realID) != null) { TaskDescriptor.Do(JobPriority.AboveNormal, folderDescriptor, message, realID); } else { RefreshTaskFolder(folderDescriptor); FolderDescriptor oldFolderDescriptor = FolderDescriptor.Get(ntf.OldParentID, _storeID); if (oldFolderDescriptor != null) { RefreshTaskFolder(oldFolderDescriptor); } } } else { _tracer.Trace("Unknown item of class " + messageClass + " was moved"); } } } catch (System.Threading.ThreadAbortException ex) { Tracer._TraceException(ex); } catch (Exception exception) { Core.ReportBackgroundException(exception); } }
private void OnNewMailImpl(MAPINtf ntf) { Trace("[New] *Email* - OnNewMailImpl"); if (CheckStorageIgnored(_storeID)) { Trace("OnNewMailImpl: storage is ignored"); return; } FolderDescriptor folderDescriptor = FolderDescriptor.Get(ntf.ParentID, _storeID); if (folderDescriptor == null) { Trace("OnNewMailImpl: folderDescriptor == null"); return; } if (folderDescriptor.ContainerClass == FolderType.IMAP) { IEFolder folder = OutlookSession.OpenFolder(ntf.ParentID, _storeID); if (folder == null) { return; } using ( folder ) { if (!ProcessMailAddNtf.ProcessIMAPMessage(folder, ntf.EntryID)) { return; } } } IEMessage message = OutlookSession.OpenMessage(ntf.EntryID, _storeID); if (message == null) { Trace("OnNewMailImpl: cannot open mapi message"); return; } using ( message ) { try { string entryId = OutlookSession.GetMessageID(message); if (OutlookSession.IsMailExported(entryId)) { Trace("OnNewMailImpl: mail is exported at the moment"); return; } new NewMailDescriptor(folderDescriptor, entryId, message).QueueJob(JobPriority.AboveNormal); } catch (System.Threading.ThreadAbortException ex) { Tracer._TraceException(ex); } catch (Exception exception) { Core.ReportBackgroundException(exception); } } }