예제 #1
0
        protected override void Execute()
        {
            Tracer._Trace("DoEnum()");
            if (Settings.IdleModeManager.CheckIdleAndSyncComplete())
            {
                Tracer._Trace("IsSyncComplete()");
                return;
            }
            Settings.IdleModeManager.SetIdleFlag();
            MailSync mailSync = new MailSync(_computeCount, _indexStartDate, _idle);

            mailSync.PrepareMailResources();

            foreach (IEMsgStore msgStore in OutlookSession.GetMsgStores())
            {
                if (msgStore == null)
                {
                    continue;
                }
                if (OutlookProcessor.IsIgnoredInfoStore(msgStore))
                {
                    continue;
                }

                string storeID = msgStore.GetBinProp(MAPIConst.PR_STORE_ENTRYID);
                string name    = msgStore.GetStringProp(MAPIConst.PR_DISPLAY_NAME);
                FolderDescriptorEnumerator.Do(msgStore, storeID, name, mailSync);
                if (Settings.IdleModeManager.Interrupted)
                {
                    if (Settings.IdleIndexing)
                    {
                        Settings.IdleModeManager.DropInterrupted();
                        OutlookSession.OutlookProcessor.QueueIdleJob(this);
                    }
                    break;
                }
            }
            if (Settings.IdleModeManager.CompletedIdle)
            {
                OutlookSession.OutlookProcessor.SetSyncComplete();
                mailSync.RemoveDeletedMailsFromIndex();
            }
            else if (!Settings.IdleModeManager.Idle)
            {
                if (mailSync.IndexStartDate == DateTime.MinValue)
                {
                    OutlookSession.OutlookProcessor.SetSyncComplete();
                }
                mailSync.RemoveDeletedMailsFromIndex();
            }
            return;
        }
예제 #2
0
 static bool ProcessResourceTextImpl(IResource res, IResourceTextConsumer consumer)
 {
     OutlookProcessor.CheckState();
     try
     {
         OutlookProcessor processor = OutlookSession.OutlookProcessor;
         if (processor != null)
         {
             MailBodyDescriptorDelegate myDelegate = CreateMailBodyDescriptor;
             MailBodyDescriptor         mailBody   = (MailBodyDescriptor)processor.RunUniqueJob(myDelegate, res);
             if (mailBody != null && Core.State != CoreState.ShuttingDown)
             {
                 //  Order of sections: Source, Subject, Body.
                 IResource resPerson  = res.GetLinkProp(Core.ContactManager.Props.LinkFrom);
                 IResource resAccount = res.GetLinkProp(PROP.EmailAccountFrom);
                 if (resPerson != null)
                 {
                     //  Construct [From] section out of contact name and its account
                     string fromText = resPerson.DisplayName;
                     if (resAccount != null)
                     {
                         fromText += " " + resAccount.DisplayName;
                     }
                     consumer.AddDocumentFragment(res.Id, fromText, DocumentSection.SourceSection);
                 }
                 consumer.AddDocumentHeading(res.Id, mailBody.Subject);
                 consumer.RestartOffsetCounting();
                 if (mailBody.IsHTML)
                 {
                     HtmlIndexer.IndexHtml(res, mailBody.Body, consumer, DocumentSection.BodySection);
                 }
                 else
                 {
                     consumer.AddDocumentFragment(res.Id, mailBody.Body.Replace("\r\n", "\n"));
                 }
             }
         }
     }
     catch (OutlookThreadTimeoutException)
     {
         if (consumer.Purpose == TextRequestPurpose.Indexing)
         {
             // retry indexing of the email later
             Guard.QueryIndexingWithCheckId(res);
         }
         return(false);
     }
     return(true);
 }
예제 #3
0
        protected override void Execute()
        {
            if (OutlookSession.OutlookProcessor.ShuttingDown)
            {
                return;
            }

            IStatusWriter statusWriter = Core.UIManager.GetStatusWriter(this, StatusPane.Network);

            statusWriter.ShowStatus("Performing background mail synchronization...");
            Tracer._Trace("MailSyncBackground is executed");
            foreach (IEMsgStore msgStore in OutlookSession.GetMsgStores())
            {
                if (OutlookSession.OutlookProcessor.ShuttingDown)
                {
                    break;
                }

                OutlookSession.ProcessJobs();

                if (msgStore == null)
                {
                    continue;
                }
                if (OutlookProcessor.IsIgnoredInfoStore(msgStore))
                {
                    continue;
                }

                string storeID = msgStore.GetBinProp(MAPIConst.PR_STORE_ENTRYID);
                string name    = msgStore.GetStringProp(MAPIConst.PR_DISPLAY_NAME);
                FolderDescriptorEnumerator.Do(msgStore, storeID, name, this);
            }
            statusWriter.ClearStatus();
            ProcessedFolders.DecRef();
        }
예제 #4
0
 public static void Init(OutlookProcessor outlookProcessor)
 {
     _outlookProcessor = outlookProcessor;
 }
예제 #5
0
파일: OutlookPlugin.cs 프로젝트: mo5h/omeo
        public void Register()
        {
            _plugin = this;
            _tracer.Trace("Start registering...");
            Core.AddExceptionReportData("\nOutlookPlugin is enabled");
            Settings.LoadSettings();

            REGISTRY.RegisterTypes(this, Core.ContactManager);

            _tracer.Trace("Start OutlookProcessor...");
            _outlookProcessor = new OutlookProcessor();

            _outlookUIHandler = new OutlookUIHandler();

            if (!_outlookProcessor.IsStarted)
            {
                _tracer.Trace("OutlookProcessor failed to start");
                Core.AddExceptionReportData("\nOutlookProcessor failed to start");
                Core.AddExceptionReportData("\nOutlook plugin cannot be loaded.\n" + _outlookProcessor.LastException.Message);
                MsgBox.Error("Outlook plugin", "Outlook plugin cannot be loaded.\n" + _outlookProcessor.LastException.Message);

                _startupStatus = false;
                Core.ActionManager.DisableXmlActionConfiguration(Assembly.GetExecutingAssembly());
                return;
            }
            _tracer.Trace("Start OutlookProcessor OK");
            _outlookProcessor.SynchronizeMAPIInfoStores();

            if (Settings.ExportTasks)
            {
                _tracer.Trace("prepare ExportTasks");
                _outlookProcessor.ExportTasks();
            }

            Core.PluginLoader.RegisterResourceUIHandler(STR.MAPIFolder, _outlookUIHandler);
            Core.PluginLoader.RegisterResourceDragDropHandler(STR.MAPIFolder, _outlookUIHandler);
            Core.PluginLoader.RegisterResourceDragDropHandler(Core.ResourceTreeManager.GetRootForType(STR.MAPIFolder).Type, new OutlookRootDragDropHandler());

            IUIManager uiManager = Core.UIManager;

            Core.TabManager.RegisterResourceTypeTab("Email", "Mail", new[] { STR.Email, STR.MAPIFolder }, PROP.Attachment, 1);

            Image             img            = Utils.TryGetEmbeddedResourceImageFromAssembly(Assembly.GetExecutingAssembly(), "OutlookPlugin.Icons.Folders24.png");
            IResourceTreePane outlookFolders =
                Core.LeftSidebar.RegisterResourceStructureTreePane("MAPIFolders", "Email", "Outlook Folders", img, STR.MAPIFolder);

            if (outlookFolders != null)
            {
                outlookFolders.AddNodeFilter(new OutlookFoldersFilter());
                ((ResourceTreePaneBase)outlookFolders).AddNodeDecorator(new TotalCountDecorator(STR.MAPIFolder, PROP.MAPIFolder));
                outlookFolders.ToolTipCallback = GetMAPIFolderToolTip;
                Settings.OutlookFolders        = outlookFolders;

                Core.LeftSidebar.RegisterViewPaneShortcut("MAPIFolders", Keys.Control | Keys.Alt | Keys.O);
            }

            uiManager.RegisterResourceLocationLink(STR.Email, PROP.MAPIFolder, STR.MAPIFolder);

            CorrespondentCtrl correspondentPane = new CorrespondentCtrl {
                IniSection = "Outlook"
            };

            img = Utils.TryGetEmbeddedResourceImageFromAssembly(Assembly.GetExecutingAssembly(), "OutlookPlugin.Icons.Correspondents24.png");
            Core.LeftSidebar.RegisterViewPane("Correspondents", "Email", "Correspondents", img, correspondentPane);

            img = Utils.TryGetEmbeddedResourceImageFromAssembly(Assembly.GetExecutingAssembly(), "OutlookPlugin.Icons.Attachments24.png");
            Core.LeftSidebar.RegisterViewPane("Attachments", "Email", "Attachments", img, new AttachmentsCtrl());
            Core.LeftSidebar.RegisterViewPaneShortcut("Attachments", Keys.Control | Keys.Alt | Keys.T);

            RegisterCustomColumns();
            RegisterOptionsPanes();

            uiManager.RegisterResourceSelectPane(STR.MAPIFolder, typeof(MAPIFoldersTreeSelectPane));

            IWorkspaceManager workspaceMgr = Core.WorkspaceManager;

            if (workspaceMgr != null)
            {
                workspaceMgr.RegisterWorkspaceType(STR.MAPIFolder, new[] { PROP.MAPIFolder }, WorkspaceResourceType.Container);
                workspaceMgr.RegisterWorkspaceType(STR.Email, new[] { -PROP.Attachment }, WorkspaceResourceType.None);
                workspaceMgr.RegisterWorkspaceSelectorFilter(STR.MAPIFolder, new OutlookFoldersFilter());
            }

            ResourceTextProvider textProvider = new ResourceTextProvider();

            Core.PluginLoader.RegisterResourceTextProvider(STR.Email, textProvider);
            Core.PluginLoader.RegisterResourceTextProvider(STR.EmailFile, textProvider);

            ResourceDisplayer displayer = new ResourceDisplayer();

            Core.PluginLoader.RegisterResourceDisplayer(STR.Email, displayer);
            Core.PluginLoader.RegisterResourceDisplayer(STR.EmailFile, displayer);
            Core.PluginLoader.RegisterStreamProvider(STR.Email, new StreamProvider());

            Core.PluginLoader.RegisterViewsConstructor(new OutlookUpgrade1ViewsInitializer());
            Core.PluginLoader.RegisterViewsConstructor(new OutlookViewsInitializer());
            Core.PluginLoader.RegisterViewsConstructor(new OutlookUpgrade2ViewsInitializer());

            //-----------------------------------------------------------------
            //  Register Search Extensions to narrow the list of results using
            //  simple phrases in search queries: for restricting the resource
            //  type to emails (three synonyms).
            //-----------------------------------------------------------------
            Core.SearchQueryExtensions.RegisterResourceTypeRestriction("in", "mail", STR.Email);
            Core.SearchQueryExtensions.RegisterResourceTypeRestriction("in", "mails", STR.Email);
            Core.SearchQueryExtensions.RegisterResourceTypeRestriction("in", "email", STR.Email);

            Core.ExpirationRuleManager.RegisterResourceType(PROP.MAPIFolder, STR.MAPIFolder, STR.Email);

            //-----------------------------------------------------------------
            Core.PluginLoader.RegisterPluginService(this);

            Core.ResourceIconManager.RegisterPropTypeIcon(PROP.Attachment,
                                                          LoadIconFromAssembly("OutlookPlugin.Icons.attachment.ico"));

            Core.ResourceBrowser.RegisterLinksPaneFilter(STR.Email, new OutlookLinksPaneFilter());
            Core.ResourceBrowser.RegisterLinksPaneFilter(STR.Task, new OutlookLinksPaneFilterForTasks());

            Core.ContactManager.RegisterContactMergeFilter(new EntryIdMergeFilter());
            Core.ResourceBrowser.RegisterLinksPaneFilter("Email", new ItemRecipientsFilter());

            FolderIconProvider folderIconProvider = new FolderIconProvider();

            Core.ResourceIconManager.RegisterResourceIconProvider(STR.MAPIFolder, folderIconProvider);
            Core.ResourceIconManager.RegisterOverlayIconProvider(STR.MAPIFolder, folderIconProvider);
            Core.ResourceIconManager.RegisterOverlayIconProvider(STR.Email, new MailIconProvider());

            if (Core.ResourceStore.GetAllResources("SentItemsEnumSign").Count == 0)
            {
                OutlookSession.OutlookProcessor.RunJob("Detect owner e-mail", new MethodInvoker(OwnerEmailDetector.Detect));
            }
            ResourceDeleters.Register();

            EmailThreadingHandler threadingHandler = new EmailThreadingHandler();

            Core.PluginLoader.RegisterResourceThreadingHandler("Email", threadingHandler);
            Core.PluginLoader.RegisterResourceThreadingHandler(PROP.Attachment, threadingHandler);
            Core.StateChanged += Core_StateChanged;

            Core.ResourceBrowser.SetDefaultViewSettings("Email", AutoPreviewMode.UnreadItems, true);

            _tracer.Trace("End of Register");
        }