Ejemplo n.º 1
0
        public bool DecorateNode(IResource res, RichText nodeText)
        {
            if (res.Type == NntpPlugin._newsGroup)
            {
                int count = 0;

                if (_groups2watchedHeads.ContainsKey(res))
                {
                    IResourceList groupItems = NntpPlugin.CollectArticles(res, false);
                    groupItems = groupItems.Intersect(_unreadArticles);

                    List <IResource> heads = _groups2watchedHeads[res];
                    foreach (IResource head in heads)
                    {
                        IResourceList thread = ConversationBuilder.UnrollConversationFromCurrent(head);
                        count += thread.Intersect(groupItems).Count;
                    }
                }

                if (count != 0)
                {
                    nodeText.Append(" !", _watchedTextStyle);
                }
                return(count != 0);
            }
            return(false);
        }
Ejemplo n.º 2
0
        bool IResourceTextProvider.ProcessResourceText(IResource res, IResourceTextConsumer consumer)
        {
            if (res != null)
            {
                int id = res.Id;
//                if (res.Type == NntpPlugin._newsArticle || res.Type == NntpPlugin._newsLocalArticle)
                if (NntpPlugin.IsNntpType(res.Type))
                {
                    string text = res.GetPropText(Core.Props.LongBody);
                    if (text.Trim().Length > 0)
                    {
                        consumer.AddDocumentFragment(id, text);
                    }
                    else
                    {
                        HtmlIndexer.IndexHtml(res, res.GetPropText(NntpPlugin._propHtmlContent), consumer, DocumentSection.BodySection);
                    }
                    consumer.RestartOffsetCounting();
                    consumer.AddDocumentHeading(id, res.GetPropText(Core.Props.Subject));

                    IResource author  = res.GetLinkProp(Core.ContactManager.Props.LinkFrom);
                    IResource account = res.GetLinkProp(Core.ContactManager.Props.LinkEmailAcctFrom);
                    if (author != null)
                    {
                        //  Construct [From] section out of contact name and its account
                        string fromText = author.DisplayName;
                        if (account != null)
                        {
                            fromText += " " + account.DisplayName;
                        }
                        consumer.AddDocumentFragment(id, fromText + " ", DocumentSection.SourceSection);
                    }
                    IResourceList groups = res.GetLinksOfType(NntpPlugin._newsGroup, NntpPlugin._propTo);
                    foreach (IResource group in groups)
                    {
                        consumer.AddDocumentFragment(id, group.GetPropText(Core.Props.Name) + " ", DocumentSection.SourceSection);
                    }
                }
                else
                {
                    IResource article = res.GetLinkProp(NntpPlugin._propAttachment);
                    if (article != null && NntpPlugin.IsNntpType(article.Type))
                    {
                        consumer.AddDocumentHeading(id, res.GetPropText(Core.Props.Name));
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 3
0
        private static void Subscribe2Groups(IResource article, string newsgroups)
        {
            IResource server = article.GetLinkProp(NntpPlugin._propTo);

            if (server != null)
            {
                article.DeleteLink(NntpPlugin._propTo, server);
                string[] groups = newsgroups.Split(',');
                foreach (string group in groups)
                {
                    NntpPlugin.Subscribe2Group(group, server);
                    foreach (IResource groupRes in new ServerResource(server).Groups)
                    {
                        if (String.Compare(groupRes.GetPropText(Core.Props.Name), group, true) == 0)
                        {
                            article.AddLink(NntpPlugin._propTo, groupRes);
                            break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public void RegisterViewsFirstRun()
        {
            IResource res;

            string[] _applTypes = new string[] { NntpPlugin._newsArticle };

            //-----------------------------------------------------------------
            //  All conditions, templates and actions must have their deep names
            //-----------------------------------------------------------------
            res = Core.ResourceStore.FindUniqueResource(FilterManagerProps.ConditionResName, Core.Props.Name, NewsViewsConstructor.AuthorPostedArticleName);
            if (res != null)
            {
                res.SetProp("DeepName", NewsViewsConstructor.AuthorPostedArticleDeep);
            }

            res = Core.ResourceStore.FindUniqueResource(FilterManagerProps.ConditionResName, Core.Props.Name, NewsViewsConstructor.PostInMyThreadName);
            if (res != null)
            {
                res.SetProp("DeepName", NewsViewsConstructor.PostInMyThreadDeep);
            }

            res = Core.ResourceStore.FindUniqueResource(FilterManagerProps.ConditionTemplateResName, Core.Props.Name, NewsViewsConstructor.AppearedInNewsgroupName);
            if (res != null)
            {
                res.SetProp("DeepName", NewsViewsConstructor.AppearedInNewsgroupDeep);
            }

            res = Core.ResourceStore.FindUniqueResource(FilterManagerProps.ConditionTemplateResName, Core.Props.Name, NewsViewsConstructor.AppearedInThreadName);
            if (res != null)
            {
                res.SetProp("DeepName", NewsViewsConstructor.AppearedInThreadDeep);
            }

            //  Tray icon rules.
            Core.TrayIconManager.RegisterTrayIconRule("Unread News Articles", _applTypes,
                                                      new IResource[] { Core.FilterRegistry.Std.ResourceIsUnread },
                                                      null, NntpPlugin.LoadNewsIcon("article.ico"));
        }
Ejemplo n.º 5
0
        public bool DecorateNode(IResource res, RichText nodeText)
        {
            if (res.Type == NntpPlugin._newsFolder || res.Type == NntpPlugin._newsServer)
            {
                int count;
                if (NewsFolders.IsDefaultFolder(res))
                {
                    IResourceList folderItems = NntpPlugin.CollectArticles(res, false);
                    IResource     wsp         = Core.WorkspaceManager.ActiveWorkspace;
                    if (wsp != null)
                    {
                        folderItems = folderItems.Intersect(wsp.GetLinksOfType(null, "WorkspaceVisible"), true);
                    }
                    if (NewsFolders.IsSentItems(res))
                    {
                        folderItems = folderItems.Intersect(_allUnread, true);
                    }
                    else
                    {
                        folderItems = folderItems.Minus(Core.ResourceStore.FindResourcesWithProp(null, Core.Props.IsDeleted));
                    }
                    count = folderItems.Count;
                }
                else
                {
                    IResourceList groups = new NewsTreeNode(res).Groups;
                    IResource     wsp    = Core.WorkspaceManager.ActiveWorkspace;
                    if (wsp != null)
                    {
                        groups = groups.Intersect(wsp.GetLinksOfType(null, "WorkspaceVisible"), true);
                    }
                    IResourceList articles = Core.ResourceStore.EmptyResourceList;
                    foreach (IResource group in groups.ValidResources)
                    {
                        articles = articles.Union(
                            group.GetLinksTo(null, NntpPlugin._propTo).Intersect(_allUnread), true);
                    }
                    count = articles.Count;
                }
                if (count != 0)
                {
                    nodeText.Append(" ");
                    nodeText.SetStyle(FontStyle.Bold, 0, res.DisplayName.Length);

                    /////////////////////////////////////////////////////////////////////
                    /// NewsFolders.IsDefaultFolder doesn't synchronously create folders,
                    /// so the check is necessary to avoid RunJobs to resource thread
                    /////////////////////////////////////////////////////////////////////
                    if (NewsFolders.IsDrafts(res))
                    {
                        nodeText.Append("[" + count + "]", _draftsTextStyle);
                    }
                    else
                    {
                        nodeText.Append("(" + count + ")", _unreadTextStyle);
                    }
                }
                return(true);
            }
            return(false);
        }