예제 #1
0
        /// <summary>
        /// When new article comes check whether it is linked to the thread
        /// which was paused for updates. In such case, simply delete the
        /// article (non-permanently, through registered IResourceDeleter).
        /// </summary>
        private static void CheckArticleInIgnoredThreads(IResource article)
        {
            IResource root;
            bool      ignore = ConversationBuilder.CheckPropOnParents(article,
                                                                      NntpPlugin._propIsIgnoredThread,
                                                                      out root);

            if (ignore)
            {
                //  We have not only to delete this article, but also check
                //  downwards the thread because it is possible for replies
                //  to be downloaded before the source article.

                IResourceDeleter deleter = Core.PluginLoader.GetResourceDeleter(article.Type);
                deleter.DeleteResource(article);

                DateTime      ignoreStartDate = root.GetDateProp(NntpPlugin._propThreadVisibilityToggleDate);
                IResourceList thread          = ConversationBuilder.UnrollConversation(article);
                foreach (IResource res in thread)
                {
                    DateTime dateTime = res.GetDateProp(Core.Props.Date);
                    if (!res.HasProp(Core.Props.IsDeleted) && dateTime > ignoreStartDate)
                    {
                        deleter.UndeleteResource(res);
                    }
                }
            }
        }
예제 #2
0
        public void Drop(IResource targetResource, IDataObject data, DragDropEffects allowedEffect, int keyState)
        {
            if (data.GetDataPresent(typeof(IResourceList)))
            {
                // The resources we're dragging
                IResourceList dragResources = (IResourceList)data.GetData(typeof(IResourceList));

                // Currently, only the Deleted Resources view has a drop handler
                if (FilterRegistry.IsDeletedResourcesView(targetResource))
                {
                    // Delete the resources dropped onto the deleted items view
                    foreach (IResource res in dragResources)
                    {
                        IResourceDeleter deleter = Core.PluginLoader.GetResourceDeleter(res.Type);
                        if (deleter != null)
                        {
                            try
                            {
                                Core.ResourceAP.RunJob(new ResourceDelegate(deleter.DeleteResource), res);
//								deleter.DeleteResource( res );
                            }
                            catch (NotImplementedException)
                            {
                            }
                        }
                    }
                }
                else
                {
                    return;
                }
            }
        }
예제 #3
0
        public void Update(IActionContext context, ref ActionPresentation presentation)
        {
            presentation.Visible = presentation.Enabled =
                (context.Instance == Core.LeftSidebar.DefaultViewPane) &&
                (context.SelectedResources.Count == 1) &&
                (context.SelectedResources[0].Type == FilterManagerProps.ViewResName) &&
                (context.SelectedResources[0].GetStringProp("DeepName") == FilterManagerProps.ViewDeletedItemsDeepName);

            //  Resources of some types can not be deleted permanently, e.g.
            //  Contacts and IM conversations. Thus this menu must be forbidden
            //  for the view in the corresponding tabs.
            if (presentation.Visible)
            {
                string[] types = Core.TabManager.CurrentTab.GetResourceTypes();

                //  "All Resources" tab always returns NULL
                if (types != null)
                {
                    bool canDelete = false;
                    foreach (string type in types)
                    {
                        if (type.Length > 0 && Core.ResourceStore.ResourceTypes.Exist(type))
                        {
                            IResourceDeleter deleter = Core.PluginLoader.GetResourceDeleter(type);
                            if (deleter != null)
                            {
                                canDelete = canDelete || deleter.CanDeleteResource(null, true);
                            }
                        }
                    }
                    presentation.Visible = canDelete;
                }
            }
        }
예제 #4
0
파일: Plugins.cs 프로젝트: mo5h/omeo
        public void RegisterResourceDeleter(string resType, IResourceDeleter deleter)
        {
            if (!Core.ResourceStore.ResourceTypes.Exist(resType))
            {
                throw new ArgumentException("Resource type '" + resType + "' does not exist", "resType");
            }

            _resourceDeleters [resType] = deleter;
        }
예제 #5
0
        public void  Exec(IResource res, IActionParameterStore actionStore)
        {
            IResourceDeleter deleter = Core.PluginLoader.GetResourceDeleter(res.Type);

            if (deleter != null)
            {
                deleter.DeleteResourcePermanent(res);
            }
        }
예제 #6
0
파일: CoreActions.cs 프로젝트: mo5h/omeo
 private static void DoUndelete(IResourceList resList)
 {
     for (int i = 0; i < resList.Count; i++)
     {
         IResource res = Core.ResourceStore.TryLoadResource(resList.ResourceIds [i]);
         if (res != null)
         {
             IResourceDeleter deleter = Core.PluginLoader.GetResourceDeleter(res.Type);
             deleter.UndeleteResource(res);
         }
     }
 }
예제 #7
0
 private void  _btnDelete_Click(object sender, EventArgs e)
 {
     //  OM-12575, releasing mouse button may be with huge (enough)
     //  lag, during which the resource might have been deleted.
     if (_lastResource != null)
     {
         IResourceDeleter deleter = Core.PluginLoader.GetResourceDeleter(_lastResource.Type);
         if (deleter != null)
         {
             Core.ResourceAP.QueueJob(new ResourceDelegate(deleter.DeleteResource), _lastResource);
             Core.UIManager.QueueUIJob(new MethodInvoker(HideBalloon));
         }
     }
 }
예제 #8
0
파일: CoreActions.cs 프로젝트: mo5h/omeo
 private static void DoDelete(IResourceList resList)
 {
     foreach (IResource res in resList.ValidResources)
     {
         string           type    = res.Type;
         IResourceDeleter deleter = Core.PluginLoader.GetResourceDeleter(type);
         if (ResourceDeleterOptions.GetDeleteAlwaysPermanently(type))
         {
             deleter.DeleteResourcePermanent(res);
         }
         else
         {
             deleter.DeleteResource(res);
         }
     }
 }
예제 #9
0
        public override AbstractJob GetNextJob()
        {
            //  test anchor.
            if (Index >= ResourceIds.Count)
            {
                return(null);
            }

            IResource res = Core.ResourceStore.TryLoadResource(ResourceIds[Index++]);

            if (res != null)
            {
                IResourceDeleter deleter = Core.PluginLoader.GetResourceDeleter(res.Type);
                if (deleter != null)
                {
                    return(new DelegateJob(new ResourceDelegate(deleter.DeleteResourcePermanent), new object[] { res }));
                }
            }
            return(GetNextJob());
        }
예제 #10
0
파일: CoreActions.cs 프로젝트: mo5h/omeo
        private static bool AllHaveEnabledDeleters(IResourceList selectedResources)
        {
            if (selectedResources.Count == 0)
            {
                return(false);
            }

            foreach (IResource res in selectedResources.ValidResources)
            {
                IResourceDeleter deleter = Core.PluginLoader.GetResourceDeleter(res.Type);
                if (deleter == null)
                {
                    return(false);
                }
                if (!deleter.CanDeleteResource(res, res.HasProp(Core.Props.IsDeleted)))
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #11
0
파일: CoreActions.cs 프로젝트: mo5h/omeo
        public void Execute(IActionContext context)
        {
            IResourceList resourcesToDelete = null;
            IResourceList selResources      = context.SelectedResourcesExpanded;

            string[]       selTypes     = selResources.GetAllTypes();
            IResourceStore store        = Core.ResourceStore;
            IResourceList  allDeleted   = store.FindResourcesWithProp(null, Core.Props.IsDeleted);
            bool           shiftPressed = Control.ModifierKeys == Keys.Shift;

            foreach (string resType in selTypes)
            {
                IResourceList typedResources = selResources.Intersect(store.GetAllResources(resType));
                IResourceList deletedTypedResources;
                bool          deletePermanent = shiftPressed;
                if (deletePermanent || ResourceDeleterOptions.GetDeleteAlwaysPermanently(resType))
                {
                    deletedTypedResources = typedResources;
                    typedResources        = store.EmptyResourceList;
                    deletePermanent       = true;
                }
                else
                {
                    deletedTypedResources = typedResources.Intersect(allDeleted);
                    typedResources        = typedResources.Minus(deletedTypedResources);
                }
                IResourceDeleter deleter = Core.PluginLoader.GetResourceDeleter(resType);
                DialogResult     result  = DialogResult.No;
                if (typedResources.Count > 0)
                {
                    if (!ResourceDeleterOptions.GetConfirmDeleteToRecycleBin(resType))
                    {
                        result = DialogResult.Yes;
                    }
                    else
                    {
                        result = deleter.ConfirmDeleteResources(typedResources, deletePermanent, (selTypes.Length > 1));
                    }
                    if (result == DialogResult.Cancel)
                    {
                        return;
                    }
                    if (result == DialogResult.Yes)
                    {
                        resourcesToDelete = typedResources.Union(resourcesToDelete);
                    }
                }
                if (deletedTypedResources.Count > 0)
                {
                    if (!ResourceDeleterOptions.GetConfirmDeletePermanently(resType))
                    {
                        result = DialogResult.Yes;
                    }
                    else
                    {
                        result = deleter.ConfirmDeleteResources(deletedTypedResources, true, (selTypes.Length > 1));
                    }
                    if (result == DialogResult.Cancel)
                    {
                        return;
                    }
                    if (result == DialogResult.Yes)
                    {
                        resourcesToDelete = deletedTypedResources.Union(resourcesToDelete);
                    }
                }
            }

            if (resourcesToDelete != null)
            {
                Core.ResourceAP.QueueJob(JobPriority.Immediate, "Deleting resources",
                                         new ResourceListDelegate(DoDelete), resourcesToDelete);
            }
        }
예제 #12
0
파일: DeletersPane.cs 프로젝트: mo5h/omeo
        private void ShowPaneImpl()
        {
            if (!Core.UserInterfaceAP.IsOwnerThread)
            {
                Core.UserInterfaceAP.QueueJob(new MethodInvoker(ShowPaneImpl));
                return;
            }
            _deletersListView.Nodes.Clear();
            IResourceList resTypes = Core.ResourceStore.GetAllResources("ResourceType");

            foreach (IResource resType in resTypes.ValidResources)
            {
                if (resType.GetIntProp("Internal") != 0)
                {
                    continue;
                }
                string type = resType.GetPropText(Core.Props.Name);
                if (type.Length > 0 && Core.ResourceStore.ResourceTypes.Exist(type))
                {
                    IResourceDeleter deleter = Core.PluginLoader.GetResourceDeleter(type);
                    if (deleter != null)
                    {
                        _deletersListView.Nodes.Add(resType);
                        bool canDelete = deleter.CanDeleteResource(null, false);
                        if (!canDelete)
                        {
                            _confirmDeleteColumn.SetItemCheckState(resType, CheckBoxState.Grayed | CheckBoxState.Unchecked);
                        }
                        else
                        {
                            _confirmDeleteColumn.SetItemCheckState(resType,
                                                                   ResourceDeleterOptions.GetConfirmDeleteToRecycleBin(type) ? CheckBoxState.Checked : CheckBoxState.Unchecked);
                        }
                        bool canDeletePermanently = deleter.CanDeleteResource(null, true);
                        if (!canDeletePermanently)
                        {
                            _confirmPermanentDeleteColumn.SetItemCheckState(resType, CheckBoxState.Grayed | CheckBoxState.Unchecked);
                        }
                        else
                        {
                            _confirmPermanentDeleteColumn.SetItemCheckState(resType,
                                                                            ResourceDeleterOptions.GetConfirmDeletePermanently(type) ? CheckBoxState.Checked : CheckBoxState.Unchecked);
                        }

                        if (!deleter.CanIgnoreRecyclebin())
                        {
                            _alwaysDeletePermanentlyColumn.SetItemCheckState(resType, CheckBoxState.Grayed | CheckBoxState.Unchecked);
                        }
                        else
                        if (canDelete != canDeletePermanently)
                        {
                            _alwaysDeletePermanentlyColumn.SetItemCheckState(resType, CheckBoxState.Grayed |
                                                                             (canDelete ? CheckBoxState.Unchecked : CheckBoxState.Checked));
                        }
                        else
                        {
                            _alwaysDeletePermanentlyColumn.SetItemCheckState(resType,
                                                                             ResourceDeleterOptions.GetDeleteAlwaysPermanently(type) ? CheckBoxState.Checked : CheckBoxState.Unchecked);
                        }
                    }
                }
            }
        }
예제 #13
0
 public ResourceDeleter(IResourceRetriever <T> retriever, IResourceDeleter <T> deleter)
 {
     _retriever = retriever;
     _deleter   = deleter;
 }