Пример #1
0
            public string CheckMergeAllowed(IResourceList contacts)
            {
                int entryIdCount = 0;

                foreach (IResource contact in contacts)
                {
                    REGISTRY.ClearNeeded(contact);
                    if (contact.HasProp(PROP.EntryID) && !contact.HasProp("UserCreated"))
                    {
                        ++entryIdCount;
                        if (entryIdCount > 1)
                        {
                            return("Please select only one contact which is synchronized with Outlook");
                        }
                    }
                }
                return(null);
            }
Пример #2
0
        private IContact FindOrCreateRegularContact(string entryID)
        {
            IContact  contactBO = null;
            IResource resource  = Contact.FindByEntryID(entryID);

            if (resource != null)
            {
                contactBO = Core.ContactManager.GetContact(resource);
                UpdateFields(contactBO);
                contactBO.AddAccount(_emailAddress);
            }
            else
            {
                contactBO = TryGettingLastExportedContact();
                if (contactBO != null)
                {
                    UpdateFields(contactBO);
                    contactBO.AddAccount(_emailAddress);
                    return(contactBO);
                }
                IResourceList contacts = _namesExist
                    ? Core.ContactManager.FindContactList(_namePrefix, _firstName, _middleName, _lastName, _suffix)
                    : Core.ContactManager.FindContactList(_fullName);

                IResourceList contactsWithEmail = null;
                IResource     accntRes          = Core.ContactManager.FindOrCreateEmailAccount(_emailAddress);
                if (accntRes != null)
                {
                    contactsWithEmail = accntRes.GetLinksOfType("Contact", "EmailAcct");
                    contacts          = contacts.Intersect(contactsWithEmail, true);
                }
                IResource candidat = null;
                foreach (IResource res in contacts)
                {
                    if (res.HasProp(PROP.EntryID))
                    {
                        REGISTRY.ClearNeeded(res);
                    }
                }
                foreach (IResource res in contacts)
                {
                    if (!res.HasProp(PROP.EntryID))
                    {
                        candidat = res;
                        break;
                    }
                }

                if (candidat != null)
                {
                    contactBO = Core.ContactManager.GetContact(candidat);
                    UpdateFields(contactBO);
                    contactBO.AddAccount(_emailAddress);
                }
                else
                {
                    IResource blankContact = null;
                    if (contactsWithEmail != null)
                    {
                        foreach (IResource res in contactsWithEmail)
                        {
                            if (ContactManager.IsEmptyContact(res))
                            {
                                blankContact = res;
                                break;
                            }
                        }
                    }
                    bool updateContact = false;
                    if (blankContact != null)
                    {
                        string strEntryID = blankContact.GetStringProp(PROP.EntryID);
                        if (strEntryID == null || strEntryID == entryID)
                        {
                            updateContact = true;
                        }
                    }
                    if (updateContact)
                    {
                        contactBO = Core.ContactManager.GetContact(blankContact);
                        UpdateFields(contactBO);
                        contactBO.AddAccount(_emailAddress);
                    }
                    else
                    {
                        contactBO = CreateContact( );
                        contactBO.AddAccount(_emailAddress);
                    }
                }
            }
            return(contactBO);
        }
Пример #3
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");
        }