public MailDescriptor(FolderDescriptor folderDescriptor, string entryID, IEMessage message, MDState state) { _state = state; Init(folderDescriptor, entryID, message, null); _longBody = message.GetPlainBody(_longBodyMaxSize); }
private bool IsClearNeededImpl(IResource contact) { IEFolder folder = GetContactFolder(contact, false); if (folder == null) { return(false); } bool newCreated; IEMAPIProp message = OpenMessage(folder, contact, false, false, false, out newCreated); if (message == null) { return(true); } using ( message ) { string folderID = message.GetBinProp(MAPIConst.PR_PARENT_ENTRYID); FolderDescriptor folderDescriptor = FolderDescriptor.Get(folderID, message.GetBinProp(MAPIConst.PR_STORE_ENTRYID)); if (folderDescriptor == null || folderDescriptor.ContainerClass != FolderType.Contact) { return(true); } return(false); } }
private static void AddMail(string messageClass, string entryID, FolderDescriptor folderDescriptor, IEFolder mapiFolder, string longBody) { Guard.NullArgument(messageClass, "messageClass"); if (MessageType.InterpretAsMail(messageClass)) { IEMessage message = null; try { message = OutlookSession.OpenMessage(mapiFolder, entryID); } catch (COMException exception) { if (exception.ErrorCode == MapiError.MAPI_E_SUBMITTED) { Core.NetworkAP.QueueJobAt(DateTime.Now.AddSeconds(10), new DelegateTryAgainToAddMail(TryAgainToAddMail), folderDescriptor, entryID, longBody); } } if (message == null) { return; } using ( message ) { Core.ResourceAP.QueueJob(new MailDescriptor(folderDescriptor, entryID, message, longBody)); } } }
private string ProcessRow(IERowSet row, FolderDescriptor folder, IEFolder mapiFolder, ref int indexed) { string entryID = row.GetBinProp(1); if (entryID == null) { entryID = row.GetBinProp(0); } string messageClass = row.GetStringProp(3); if (messageClass == null) { messageClass = string.Empty; } IResource email = Core.ResourceStore.FindUniqueResource(STR.Email, PROP.EntryID, entryID); if (email != null) { _mailsInOldIndex.TestID(email.Id); UpdateMail(row, email, messageClass, entryID, folder, mapiFolder); indexed++; } else { AddMail(messageClass, entryID, folder, mapiFolder, row.GetStringProp(7)); indexed++; } OutlookSession.ProcessJobs(); return(entryID); }
//parentFolder can be null public FolderStructureDescriptor(FolderDescriptor parentFolder, FolderDescriptor folder) { Guard.NullArgument(folder, "folder"); _parentFolder = parentFolder; _folder = folder; }
private static void RefreshTaskFolder(FolderDescriptor folderDescriptor) { if (folderDescriptor.ContainerClass == FolderType.Task) { RefreshFolderDescriptor.Do(JobPriority.AboveNormal, folderDescriptor.FolderIDs, DateTime.MinValue); } }
public FolderModifiedDescriptor(MAPINtf ntf, string storeID, bool isMovedFolder) { Guard.NullArgument(ntf, "ntf"); _isMovedFolder = isMovedFolder; IEFolder folder = OutlookSession.OpenFolder(ntf.EntryID, storeID); if (folder != null) { using ( folder ) { _folder = FolderDescriptor.Get(folder); if (ntf.ParentID != null && ntf.ParentID.Length > 0) { IEFolder parentFolder = OutlookSession.OpenFolder(ntf.ParentID, storeID); if (parentFolder != null) { using ( parentFolder ) { _parentFolder = FolderDescriptor.Get(parentFolder); } } } } } }
protected override void Execute() { DateTime minDate = Settings.LastExecutionTime; if (minDate != DateTime.MinValue) { minDate = minDate.AddDays(-14); } IResourceList folders = Core.ResourceStore.FindResourcesInRange(STR.MAPIFolder, PROP.LastMailDate, minDate, DateTime.Now); for (int i = folders.Count - 1; i >= 0; --i) { IResource folder = Core.ResourceStore.TryLoadResource(folders.ResourceIds[i]); if (folder == null) { continue; } PairIDs folderIDs = PairIDs.Get(folder); if (folderIDs == null) { continue; } FolderDescriptor folderDescriptor = FolderDescriptor.Get(folderIDs); if (folderDescriptor != null) { ProcessFolder(folderDescriptor, _dtRestrict); } } }
private void EnumerateTasks(FolderDescriptor folder, IEFolder mapiFolder) { OnFolderFetched(folder.Name); IEMessages messages = mapiFolder.GetMessages(); if (messages != null) { using ( messages ) { int count = messages.GetCount(); for (int i = 0; i < count; i++) { IEMessage message = messages.OpenMessage(i); if (message != null) { using ( message ) { string entryID = OutlookSession.GetMessageID(message); TaskDescriptor.Do(folder, message, entryID); } } } } } }
private void EnumerateInternal(IEFolder folder, FolderDescriptor parentTag) { IEFolders folders = OutlookSession.GetFolders(folder); if (folders == null) { return; } using ( folders ) { for (int i = 0; i < folders.GetCount(); ++i) { OutlookSession.ProcessJobs(); IEFolder subFolder = OutlookSession.OpenFolder(folders, i); if (subFolder == null) { continue; } using ( subFolder ) { FolderDescriptor tag = null; FolderDescriptor folderDescriptor = FolderDescriptor.Get(_storeID, subFolder); bool continueEnumerate = _enumListener.FolderFetched(parentTag, folderDescriptor, out tag); if (continueEnumerate) { EnumerateInternal(subFolder, tag); } } } } }
public NewMailDescriptor(FolderDescriptor folderDescriptor, string entryID, IEMessage message) : base(folderDescriptor, entryID, message) { if (Settings.TraceOutlookListeners) { _tracer.Trace("NewMailDescriptor was created"); } }
public static void Do(JobPriority jobPriority, FolderDescriptor folderDescriptor, DateTime dateRestriction) { IResource folder; if (IsDataCorrect(out folder, folderDescriptor)) { OutlookSession.OutlookProcessor.QueueJob(jobPriority, new RefreshFolderDescriptor(folderDescriptor, dateRestriction)); } }
public static void Do(JobPriority jobPriority, FolderDescriptor folder, string entryID, string searchEntryID) { Guard.NullArgument(folder, "folder"); if (IsDataCorrect(folder)) { OutlookSession.OutlookProcessor.QueueJob(jobPriority, new ContactDescriptorWrapper(folder, entryID, searchEntryID)); } }
protected override void Execute() { if (OutlookSession.OutlookProcessor.ShuttingDown) { return; } IEFolder folder = OutlookSession.OpenFolder(_ntf.ParentID, _storeID); if (folder != null) { using ( folder ) { FolderDescriptor folderDescriptor = FolderDescriptor.Get(folder); if (folderDescriptor == null) { return; } IResource resFolder = Folder.Find(folderDescriptor.FolderIDs.EntryId); if (resFolder == null) { return; } bool ignoredFolder = Folder.IsIgnored(resFolder); IEMessage message = OutlookSession.OpenMessage(_ntf.EntryID, _storeID); if (message == null) { return; } using ( message ) { string entryId = OutlookSession.GetMessageID(message); IResource mail = Core.ResourceStore.FindUniqueResource("Email", PROP.EntryID, _ntf.EntryID); if (mail == null && _ntf.OldEntryID != null) { mail = Core.ResourceStore.FindUniqueResource("Email", PROP.EntryID, _ntf.OldEntryID); } if (ignoredFolder && mail != null) { Trace.WriteLine("Moved mail ID=" + mail.Id + " to ignored folder"); Mail.ForceDelete(mail); return; } if (mail == null) { ProcessMailAddNtf.DoJob(_ntf, _storeID); return; } mail.SetProp(PROP.EntryID, entryId); Folder.LinkMail(resFolder, mail); } } } }
public static void Do(JobPriority jobPriority, FolderDescriptor folder, IEMessage message, string entryID) { if (folder == null || folder.FolderIDs == null) { Tracer._Trace("Cannot locate folder"); return; } Core.ResourceAP.QueueJob(jobPriority, new TaskDescriptor(folder, message, entryID)); }
public static IResource FindOrCreate(FolderDescriptor folderDescriptor, IResource parentFolder) { Guard.NullArgument(folderDescriptor, "folderDescriptor"); IResource MAPIStore = FindOrCreateMAPIStore(folderDescriptor.FolderIDs.StoreId); IResource resFolder = Core.ResourceStore.FindUniqueResource(STR.MAPIFolder, PROP.EntryID, folderDescriptor.FolderIDs.EntryId); if (resFolder != null) { resFolder.BeginUpdate(); } else { resFolder = Core.ResourceStore.BeginNewResource(STR.MAPIFolder); Core.WorkspaceManager.AddToActiveWorkspaceRecursive(resFolder); resFolder.SetProp("EntryID", folderDescriptor.FolderIDs.EntryId); resFolder.SetProp("OwnerStore", MAPIStore); if (OutlookSession.IsDeletedItemsFolder(folderDescriptor.FolderIDs.EntryId)) { resFolder.SetProp(Core.Props.ShowDeletedItems, true); resFolder.SetProp(PROP.DeletedItemsFolder, true); resFolder.SetProp(PROP.DefaultDeletedItems, true); } if (parentFolder != null) { SetIgnored(resFolder, IsIgnored(parentFolder)); } } SetName(resFolder, folderDescriptor.Name); string containerClass = folderDescriptor.ContainerClass; resFolder.SetProp(PROP.PR_STORE_SUPPORT_MASK, folderDescriptor.StoreSupportMask); resFolder.SetProp(PROP.PR_CONTENT_COUNT, folderDescriptor.ContentCount); if (containerClass.Length > 0) { resFolder.SetProp(PROP.ContainerClass, containerClass); } containerClass = resFolder.GetPropText(PROP.ContainerClass); bool visible = (containerClass.Length == 0 || containerClass == FolderType.Mail || containerClass == FolderType.Post || containerClass == FolderType.IMAP || containerClass == FolderType.Dav); resFolder.SetProp(PROP.MAPIVisible, visible); if (parentFolder != null) { SetParent(resFolder, parentFolder); } else { Folder.SetAsRoot(resFolder); } resFolder.EndUpdate(); _resourceTreeManager.SetResourceNodeSort(resFolder, STR.Name); return(resFolder); }
public static void UpdateContactFolder(FolderDescriptor folder) { if (folder.ContainerClass == FolderType.Contact) { IResource resAB = Core.ResourceStore.FindUniqueResource("AddressBook", PROP.EntryID, folder.FolderIDs.EntryId); if (resAB != null) { OutlookAddressBook.SetName(resAB, OutlookAddressBook.GetProposedName(folder.Name, folder.FolderIDs.EntryId)); } } }
private static bool IsDataCorrect(FolderDescriptor folder) { IResource resource = Folder.Find(folder.FolderIDs.EntryId); if (resource == null || !Folder.IsFolderOfType(resource, FolderType.Contact) || Folder.IsIgnoreImport(resource)) { return(false); } return(true); }
public static bool IsIgnored(FolderDescriptor folder) { IResource resFolder = Find(folder.FolderIDs.EntryId); if (resFolder == null) { return(true); } return(IsIgnored(resFolder)); }
public bool FolderFetched(FolderDescriptor parent, FolderDescriptor folder, out FolderDescriptor folderTag) { folderTag = null; if (OutlookSession.OutlookProcessor.ShuttingDown) { return(false); } if (!Folder.IsIgnored(folder)) { ProcessedFolders.RegisterFolder(folder.FolderIDs.EntryId); RefreshFolderDescriptor.Do(JobPriority.BelowNormal, folder.FolderIDs, _dateRestrict); } return(true); }
private void RefreshFolder(PairIDs folderIDs, IResource folder) { Guard.NullArgument(folderIDs, "folderIDs"); Guard.NullArgument(folder, "folder"); FolderDescriptor descriptor = FolderDescriptor.Get(folderIDs); if (descriptor != null) { if (!ProcessedFolders.IsFolderProcessed(folder.GetStringProp(PROP.EntryID))) { RefreshFolderDescriptor.Do(JobPriority.Normal, descriptor, Settings.IndexStartDate); } } }
public static void AddSubFolder(FolderDescriptor folder, FolderDescriptor subFolder) { IResource parentFolder = null; if (folder != null) { parentFolder = Find(folder.FolderIDs.EntryId); } IResource resFolder = FindOrCreate(subFolder, parentFolder); if (Folder.IsParentRoot(resFolder) || Folder.IsParentParentRoot(resFolder)) { SetDefault(resFolder, true); } }
public static void DoJob(MAPINtf ntf, string storeID) { if (ntf == null) { return; } try { IEFolder folder = OutlookSession.OpenFolder(ntf.ParentID, storeID); if (folder == null) { return; } FolderDescriptor folderDescriptor = FolderDescriptor.Get(folder); if (folderDescriptor == null) { return; } using ( folder ) { if (folderDescriptor.ContainerClass == FolderType.IMAP) { if (!ProcessIMAPMessage(folder, ntf.EntryID)) { return; } } IEMessage message = OutlookSession.OpenMessage(ntf.EntryID, storeID); if (message == null) { return; } using ( message ) { DoJobImpl(ntf, message, folderDescriptor); } } } catch (System.Threading.ThreadAbortException exception) { Tracer._TraceException(exception); } catch (Exception exception) { Core.ReportException(exception, ExceptionReportFlags.AttachLog); } }
private void UpdateMail(IERowSet row, IResource email, string messageClass, string entryId, FolderDescriptor folder, IEFolder mapiFolder) { Guard.NullArgument(messageClass, "messageClass"); bool checkForDateTimeNeeded = false; bool bWereChanges = false; bool interpretAsMail = MessageType.InterpretAsMail(messageClass); if (interpretAsMail) { bWereChanges = WereChanges(row, email, out checkForDateTimeNeeded); } if (bWereChanges) { IEMessage message = OutlookSession.OpenMessage(folder.FolderIDs.EntryId, mapiFolder, entryId); if (message == null) { return; } using ( message ) { if (checkForDateTimeNeeded) { DateTime lastModifiedDate = message.GetDateTimeProp(MAPIConst.PR_LAST_MODIFICATION_TIME); lastModifiedDate = lastModifiedDate.ToUniversalTime(); if (lastModifiedDate.Equals(email.GetProp(PROP.LastModifiedTime))) { bWereChanges = false; } } if (bWereChanges) { Core.ResourceAP.QueueJob(new MailDescriptor(folder, entryId, message, MailDescriptor.UpdateState, row.GetStringProp(7))); } else { Core.ResourceAP.QueueJob(new SyncOnlyMailDescriptor(folder, entryId, message)); } } } else { MailSyncToFolder.LinkOrDelete(folder, email); } }
public bool FolderFetched(FolderDescriptor parent, FolderDescriptor folder, out FolderDescriptor folderTag) { folderTag = null; _tracer.Trace(folder.Name); if (Settings.IdleModeManager.Interrupted) { return(false); } if (!Folder.IsIgnored(folder)) { EnumerateMessageItems(folder); } return(true); }
public static IEFolders GetFolders(IEFolder folder, FolderDescriptor folderDescriptor) { try { if (folderDescriptor == null) { folderDescriptor = FolderDescriptor.Get(folder); } return(folder.GetFolders()); } catch (COMException exception) { _tracer.TraceException(exception); OutlookSession.ProblemWithOpeningFolder(folderDescriptor.FolderIDs.EntryId); } return(null); }
public static void LinkOrDelete(FolderDescriptor folder, IResource email) { Guard.NullArgument(email, "email"); if (folder != null) { IResource resFolder = Folder.Find(folder.FolderIDs.EntryId); if (!Folder.IsIgnored(resFolder)) { if (email.GetLinkProp(PROP.MAPIFolder) != resFolder) { Core.ResourceAP.QueueJob("Link Email To Folder", new LinkMailDelegate(LinkMail), resFolder, email); } return; } } DeleteMail(email); }
private void SynchronizeFolderRecursive(IEFolder folder, string name, string storeID, FolderDescriptor parentDescriptor) { if (folder == null) { return; } using ( folder ) { FolderDescriptor folderDescriptor = FolderDescriptor.Get(folder); if (name != null) { folderDescriptor.Name = name; _tracer.Trace("Folder name = " + name); } else { _tracer.Trace("Folder name is unknown"); } _folders.Remove(folderDescriptor.FolderIDs.EntryId); FolderStructureDescriptor folderStruct = new FolderStructureDescriptor(parentDescriptor, folderDescriptor); Core.ResourceAP.QueueJob(folderStruct); IEFolders folders = OutlookSession.GetFolders(folder, folderDescriptor); if (folders == null) { return; } using ( folders ) { for (int i = 0; i < folders.GetCount(); ++i) { try { SynchronizeFolderRecursive(folders.OpenFolder(i), null, storeID, folderDescriptor); } catch (COMException exception) { _tracer.TraceException(exception); OutlookSession.ProblemWithOpeningFolder(folderDescriptor.FolderIDs.EntryId); break; } } } } }
private void OnMailModifyImpl(MAPIFullNtf ntf) { if (CheckStorageIgnored(_storeID)) { return; } try { IEFolder folder = OutlookSession.OpenFolder(ntf.ParentID, _storeID); if (folder == null) { return; } using ( folder ) { FolderDescriptor folderDescriptor = FolderDescriptor.Get(folder); if (folderDescriptor.ContainerClass == FolderType.IMAP) { if (!ProcessMailAddNtf.ProcessIMAPMessage(folder, ntf.EntryID)) { return; } } IEMessage message = OutlookSession.OpenMessage(ntf.EntryID, _storeID); if (message == null) { return; } using ( message ) { ProcessMailModifyImpl(ntf, message, folderDescriptor); } } } catch (System.Threading.ThreadAbortException ex) { Tracer._TraceException(ex); } catch (Exception exception) { Core.ReportBackgroundException(exception); } }
public void Enumerate() { IEFolder folder = _msgStore.GetRootFolder(); if (folder != null) { using ( folder ) { FolderDescriptor tag = null; FolderDescriptor folderDescriptor = FolderDescriptor.Get(_storeID, folder); folderDescriptor.Name = _storeName; bool continueEnumerate = _enumListener.FolderFetched(null, folderDescriptor, out tag); if (continueEnumerate) { OutlookSession.ProcessJobs(); EnumerateInternal(folder, tag); } } } }