public static void PostArticle(IResource draftArticle, AsciiProtocolUnitDelegate finishedMethod, bool invokedByUser) { Guard.NullArgument(draftArticle, "draftArticle"); if (!Utils.IsNetworkConnectedLight()) { return; } lock ( _articlesBeenPosted ) { if (_articlesBeenPosted.Contains(draftArticle)) { return; } _articlesBeenPosted.Add(draftArticle); } IResourceList groups = draftArticle.GetLinksFrom(NntpPlugin._newsGroup, NntpPlugin._propTo); if (groups.Count > 0) { IResource server = new NewsgroupResource(groups[0]).Server; if (server != null) { NntpConnection postConnection = NntpConnectionPool.GetConnection(server, "foreground"); NntpPostArticleUnit postUnit = new NntpPostArticleUnit(draftArticle, server, finishedMethod, invokedByUser); postUnit.Finished += postUnit_Finished; postConnection.StartUnit(invokedByUser ? Int32.MaxValue - 2 : 0, postUnit); return; } } ArticlePostedOrFailed(draftArticle); if (finishedMethod != null) { finishedMethod(null); } }
private static void postUnit_Finished(AsciiProtocolUnit unit) { NntpPostArticleUnit postUnit = (NntpPostArticleUnit)unit; ArticlePostedOrFailed(postUnit.DraftArticle); }