Пример #1
0
 protected override void FireFinished()
 {
     if (_error == null)
     {
         NewsFolders.PlaceResourceToFolder(_draftArticle, NewsFolders.SentItems);
     }
     Core.UIManager.GetStatusWriter(_server.Name, StatusPane.Network).ClearStatus();
     base.FireFinished();
 }
Пример #2
0
 public bool CanRenameResource(IResource res, ref string editText)
 {
     if (res.Type == NntpPlugin._newsGroup || res.Type == NntpPlugin._newsServer ||
         (res.Type == NntpPlugin._newsFolder && !NewsFolders.IsDefaultFolder(res)))
     {
         editText = res.GetStringProp("_DisplayName");
         return(true);
     }
     return(false);
 }
Пример #3
0
        private static void CleanLocalArticle(string articleId, IResource articleRes)
        {
            IResource localArticle = Core.ResourceStore.FindUniqueResource(
                NntpPlugin._newsLocalArticle, NntpPlugin._propArticleId, articleId);

            if (localArticle != null)
            {
                foreach (IResource wsp in localArticle.GetLinksOfType("Workspace", "WorkspaceVisible"))
                {
                    Core.WorkspaceManager.AddResourceToWorkspace(wsp, articleRes);
                }
                Core.ContactManager.UnlinkContactInformation(localArticle);
                localArticle.Delete();
                NewsFolders.PlaceResourceToFolder(articleRes, NewsFolders.SentItems);
            }
        }
Пример #4
0
 private void PreparePosting()
 {
     if (NewsFolders.IsInFolder(_draftArticle, NewsFolders.SentItems))
     {
         Core.NetworkAP.QueueJob(
             JobPriority.Immediate, "Finish posting", new MethodInvoker(FireFinished));
     }
     else
     {
         NewsFolders.PlaceResourceToFolder(_draftArticle, NewsFolders.Outbox);
         _nntpBody = _draftArticle.GetPropText(NntpPlugin._propNntpText);
         if (!_draftArticle.HasProp(NntpPlugin._propArticleId))
         {
             StringBuilder builder = new StringBuilder(_nntpBody.Length + 64);
             builder.Append("Date: ");
             DateTime postTime = DateTime.UtcNow;
             builder.Append(_daysOfTheWeek[(int)postTime.DayOfWeek]);
             builder.Append(", ");
             builder.Append(postTime.Day);
             builder.Append(' ');
             builder.Append(_months[postTime.Month - 1]);
             builder.Append(' ');
             builder.Append(postTime.Year);
             builder.Append(' ');
             builder.Append(postTime.Hour.ToString().PadLeft(2, '0'));
             builder.Append(':');
             builder.Append(postTime.Minute.ToString().PadLeft(2, '0'));
             builder.Append(':');
             builder.Append(postTime.Second.ToString().PadLeft(2, '0'));
             builder.Append(" +0000 (UTC)");
             builder.Append("\r\nMessage-ID: ");
             string message_id = ParseTools.GenerateArticleId(_draftArticle, _server.Name);
             builder.Append(message_id);
             builder.Append("\r\n");
             builder.Append(_nntpBody);
             _nntpBody = builder.ToString();
             _draftArticle.SetProp(NntpPlugin._propArticleId, message_id);
         }
         AsciiSendLineGetLineUnit initPostUnit = new AsciiSendLineGetLineUnit("post");
         initPostUnit.Finished += new AsciiProtocolUnitDelegate(initPostUnit_Finished);
         Core.NetworkAP.QueueJob(JobPriority.Immediate, "Posting articles",
                                 new StartUnitDelegate(StartUnit), initPostUnit, _connection);
     }
 }
Пример #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);
        }
Пример #6
0
 public bool AcceptNode(IResource res, int level)
 {
     return(!NewsFolders.IsDefaultFolder(res));
 }