private void StartNextArticle() { if (_articleIndex >= _emptyArticles.Count || _articleIndex >= _group.CountToDownloadAtTime) { StartNextGroup(); } else { IResource article; try { article = _emptyArticles[_articleIndex++]; } catch (InvalidResourceIdException) { article = null; } if (article == null || article.IsDeleted || article.IsDeleting) { StartNextArticle(); } else { NntpDownloadArticleUnit downloadArticleUnit = new NntpDownloadArticleUnit(article, _group.Resource, JobPriority.Normal, false); downloadArticleUnit.Finished += new AsciiProtocolUnitDelegate(downloadArticleUnit_Finished); StartUnit(downloadArticleUnit, _connection); } } }
private void downloadUnit_OnProgress(NntpDownloadArticleUnit sender, string progress) { if (!Core.UserInterfaceAP.IsOwnerThread) { Core.UserInterfaceAP.QueueJob(new NntpDownloadArticleUnit.ProgressDelegate(downloadUnit_OnProgress), sender, progress); } else { IResource article = null; try { if (_articleListener != null) { article = _articleListener[0]; } if (article != null && article == sender.Article && article.HasProp(NntpPlugin._propHasNoBody)) { ShowHtml("<pre>Downloading article: " + progress + "%</pre>", _ctxRestricted, null); } } catch (InvalidResourceIdException) {} } }
public override void DisplayResource(IResource article, WordPtr[] wordsToHighlight) { if (_downloadLabel == null) { _downloadLabel = new JetLinkLabel(); _downloadLabel.Text = "Click here or press F5 to download the article"; _downloadLabel.BackColor = Color.Transparent; _downloadLabel.ClickableLink = true; _downloadLabel.Click += _downloadLabel_Click; Controls.Add(_downloadLabel); } _downloadLabel.Visible = false; _ieBrowser.Visible = true; bool redisplayed = _articleIsRedisplayed; _articleIsRedisplayed = false; DisposeArticleListener(); // Set the subject, highlight if needed ShowSubject(article.GetPropText(Core.Props.Subject), wordsToHighlight); try { // The content being indexed (plaintext) is not the same that is // displayed (autogenerated HTML), so the offsets are updated by // this method to correspond to the new formatting. string sFormattedArticle = ArticleBody2Html(article, ref wordsToHighlight); ShowHtml(sFormattedArticle, _ctxRestricted, wordsToHighlight); } catch (Exception e) { Utils.DisplayException(e, "Error"); return; } /** * set last selected article for article's owner */ IResource owner = _rbrowser.OwnerResource; if (owner != null && (owner.Type == NntpPlugin._newsGroup || owner.Type == NntpPlugin._newsFolder || owner.Type == NntpPlugin._newsServer)) { ResourceProxy proxy = new ResourceProxy(owner); proxy.AsyncPriority = JobPriority.AboveNormal; proxy.SetPropAsync(NntpPlugin._propLastSelectedArticle, article.Id); } _articleListener = article.ToResourceListLive(); _articleListener.ResourceChanged += _articleListener_ResourceChanged; bool hasNoBody = article.HasProp(NntpPlugin._propHasNoBody); if (!hasNoBody) { Core.UIManager.GetStatusWriter(this, StatusPane.Network).ClearStatus(); } else { if (!Utils.IsNetworkConnectedLight()) { ShowHtml("<pre>" + NntpPlugin._networkUnavailable + ".</pre>", WebSecurityContext.Internet, null); return; } IResourceList groups = article.GetLinksOfType(NntpPlugin._newsGroup, NntpPlugin._propTo); if (groups.Count > 0) { foreach (IResource groupRes in groups.ValidResources) { IResource server = new NewsgroupResource(groupRes).Server; if (server != null) { ServerResource serverRes = new ServerResource(server); if (redisplayed || serverRes.DownloadBodiesOnDeliver || serverRes.DownloadBodyOnSelection) { Core.UIManager.GetStatusWriter(this, StatusPane.Network).ShowStatus("Downloading article..."); NntpConnection articlesConnection = NntpConnectionPool.GetConnection(server, "foreground"); NntpDownloadArticleUnit downloadUnit = new NntpDownloadArticleUnit(article, groupRes, JobPriority.Immediate, true); downloadUnit.OnProgress += downloadUnit_OnProgress; ShowHtml("<pre>Downloading article: 0%</pre>", WebSecurityContext.Internet, null); articlesConnection.StartUnit(Int32.MaxValue - 1, downloadUnit); return; } } } if (!redisplayed) { Point location = _ieBrowser.Location; _downloadLabel.Location = new Point(location.X + 8, location.Y + 8); _downloadLabel.Visible = true; _ieBrowser.Visible = false; } } } }