Пример #1
0
        public Icon[] GetOverlayIcons(IResource res)
        {
            int val = res.GetIntProp("PR_ICON_INDEX");

            if (val == 261)
            {
                return(_replied);
            }
            else
            if (val == 262)
            {
                return(_forwarded);
            }
            else
            {
                IResource folder = Mail.GetParentFolder(res);
                if (folder != null)
                {
                    return(FolderIconProvider.GetOverlayIcon(folder));
                }
            }
            return(null);
        }
Пример #2
0
        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");
        }