コード例 #1
0
ファイル: BlobFileSystem.cs プロジェクト: mo5h/omeo
        /// <summary>
        /// Resturns list of handles of all available files.
        /// </summary>
        /// <returns></returns>
        public IntArrayList GetAllFiles(bool idle)
        {
            int        handle;
            IntHashSet deletedFiles = new IntHashSet();

            handle = _stream.GetFirstFreeFileHandle();
            while (IsValidHandle(handle) && Core.State != CoreState.ShuttingDown &&
                   (!idle || Core.IsSystemIdle))
            {
                deletedFiles.Add(handle);
                ClusteredCachedStream.Cluster cluster = _stream.GetCluster(handle);
                handle = _stream.OffsetToHandle(cluster.NextOffset);
            }
            IntArrayList result = new IntArrayList();

            for (long off = ClusteredCachedStream.BLOB_FILE_SYSTEM_HEADER_SIZE; off < _stream.Length;)
            {
                if (Core.State == CoreState.ShuttingDown || (idle && !Core.IsSystemIdle))
                {
                    break;
                }
                handle = _stream.OffsetToHandle(off);
                ClusteredCachedStream.Cluster cluster = _stream.GetCluster(handle);
                if (cluster.PrevOffset == ClusteredCachedStream.NOT_SET && !deletedFiles.Contains(handle))
                {
                    result.Add(handle);
                }
                off += cluster.Length;
                off += ClusteredCachedStream.CLUSTER_HEADER_SIZE;
            }
            return(result);
        }
コード例 #2
0
ファイル: ResourceList.cs プロジェクト: mo5h/omeo
        public void IndexedSort(int propID)
        {
            lock (this)
            {
                if (_list == null)
                {
                    Instantiate();
                }

                IntHashSet hashSet = new IntHashSet();
                for (int i = 0; i < _list.Count; i++)
                {
                    hashSet.Add(_list [i]);
                }
                int        destIndex = 0;
                IResultSet rs        = MyPalStorage.Storage.SelectResourcesWithProp(propID);
                foreach (IRecord rec in rs)
                {
                    int id = rec.GetIntValue(0);
                    if (hashSet.Contains(id))
                    {
                        _list [destIndex++] = id;
                    }
                }
            }
        }
コード例 #3
0
ファイル: ViewConstructors.cs プロジェクト: mo5h/omeo
        private static void  CollectResources(string resType, IntHashSet result, IntHashSet source, int level)
        {
            IntHashSet temp = new IntHashSet();

            foreach (IntHashSet.Entry e in source)
            {
                IResourceList children = Core.ResourceStore.LoadResource(e.Key).GetLinksTo(resType, Core.Props.Reply);
                for (int i = 0; i < children.Count; i++)
                {
                    int chid = children[i].Id;
                    if (!source.Contains(chid) && !result.Contains(chid))
                    {
                        temp.Add(chid);
                    }
                }
            }

            foreach (IntHashSet.Entry e in temp)
            {
                result.Add(e.Key);
            }

            if (temp.Count > 0)
            {
                CollectResources(resType, result, temp, level + 1);
            }
        }
コード例 #4
0
 static public int Contains(IntPtr l)
 {
     try {
         IntHashSet   self = (IntHashSet)checkSelf(l);
         System.Int32 a1;
         checkType(l, 2, out a1);
         var ret = self.Contains(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #5
0
ファイル: TasksPlugin.cs プロジェクト: mo5h/omeo
        /// <summary>
        /// Called to return the drop effect when the specified data object is dragged over the
        /// specified resource.
        /// </summary>
        /// <param name="targetResource">The resource over which the drag happens.</param>
        /// <param name="data">The <see cref="IDataObject"/> containing the dragged data.</param>
        /// <param name="allowedEffect">The drag-and-drop operations which are allowed by the
        /// originator (or source) of the drag event.</param>
        /// <param name="keyState">The current state of the SHIFT, CTRL, and ALT keys,
        /// as well as the state of the mouse buttons.</param>
        /// <returns>The target drop effect.</returns>
        public DragDropEffects DragOver(IResource targetResource, IDataObject data, DragDropEffects allowedEffect, int keyState)
        {
            if (data.GetDataPresent(typeof(IResourceList)))            // Dragging resources over
            {
                // The resources we're dragging
                IResourceList dragResources = (IResourceList)data.GetData(typeof(IResourceList));

                // Restrict the allowed target res-types
                if (!((targetResource.Type == "Task") || (targetResource == Core.ResourceTreeManager.GetRootForType("Task"))))
                {
                    return(DragDropEffects.None);
                }

                // Collect all the direct and indirect parents of the droptarget; then we'll check to avoid dropping parent on its children
                IntHashSet ancestors = new IntHashSet();
                IResource  parent    = targetResource;
                while (parent != null)
                {
                    ancestors.Add(parent.Id);
                    parent = parent.GetLinkProp(TasksPlugin._linkSuperTask);
                }

                // Measure some metrics on the dragged resources, don't allow mixing tasks/resources and prohibit the internal resources
                bool bAllTasks   = true;
                bool bNoTasks    = true;
                bool bNoInternal = true;
                foreach (IResource res in dragResources)
                {
                    bAllTasks   = bAllTasks && (res.Type == "Task");
                    bNoTasks    = bNoTasks && (res.Type != "Task");
                    bNoInternal = bNoInternal && (!Core.ResourceStore.ResourceTypes[res.Type].HasFlag(ResourceTypeFlags.Internal));
                    if (ancestors.Contains(res.Id))
                    {
                        return(DragDropEffects.None);                           // Dropping parent on a child
                    }
                }
                if (((!bAllTasks) && (!bNoTasks)) || (!bNoInternal))
                {
                    return(DragDropEffects.None);
                }

                // Link attachments, move the tasks
                return(bAllTasks ? DragDropEffects.Move : DragDropEffects.Link);
            }
            return(DragDropEffects.None);
        }
コード例 #6
0
        protected override string GetItemText(object item)
        {
            IResource res     = (IResource)item;
            string    context = _highlightDataProvider.GetContext(res);

            if (context != null)
            {
                return(context);
            }
            lock ( _contextsRequested )
            {
                if (!_contextsRequested.Contains(res.Id))
                {
                    _contextsRequested.Add(res.Id);
                    _highlightDataProvider.RequestContexts(new int[] { res.Id });
                }
            }
            return("Calculating context...");
        }
コード例 #7
0
ファイル: FormattingForm.cs プロジェクト: mo5h/omeo
        private static void  DeleteRulesUnderTheRoot(IResource root, IntHashSet hashDone)
        {
            if (!hashDone.Contains(root.Id))
            {
                hashDone.Add(root.Id);

                IResourceList children = root.GetLinksTo(null, Core.Props.Reply);
                foreach (IResource res in children)
                {
                    string ruleName = ConstructRuleName(res);
                    if (Core.FormattingRuleManager.IsRuleRegistered(ruleName))
                    {
                        Core.FormattingRuleManager.UnregisterRule(ruleName);
                    }
                }

                foreach (IResource res in children)
                {
                    DeleteRulesUnderTheRoot(res, hashDone);
                }
            }
        }
コード例 #8
0
ファイル: ViewConstructors.cs プロジェクト: mo5h/omeo
        public bool MatchResource(IResource res)
        {
            if (res.Type == NntpPlugin._newsArticle)
            {
                IntHashSet childs = new IntHashSet();
                do
                {
                    if (childs.Contains(res.Id))     // cycle found
                    {
                        break;
                    }

                    childs.Add(res.Id);
                    res = res.GetLinkProp(Core.Props.Reply);
                    if (res != null && res.HasProp("Flag"))
                    {
                        return(true);
                    }
                }while(res != null);
            }
            return(false);
        }
コード例 #9
0
ファイル: ViewConstructors.cs プロジェクト: mo5h/omeo
 public bool MatchResource(IResource res)
 {
     if (res.Type == NntpPlugin._newsArticle)
     {
         IntHashSet childs = new IntHashSet();
         do
         {
             if (childs.Contains(res.Id))
             {
                 break; // cycle found
             }
             childs.Add(res.Id);
             IResource author = res.GetLinkProp(Core.ContactManager.Props.LinkFrom);
             if (author != null && author.HasProp("Myself"))
             {
                 return(true);
             }
             res = res.GetLinkProp(Core.Props.Reply);
         }while(res != null);
     }
     return(false);
 }
コード例 #10
0
 private static void SetReply(IResource child, IResource article)
 {
     try
     {
         _convsParents.Add(child.Id);
         IResource res = article;
         while (res != null)
         {
             int id = res.Id;
             if (_convsParents.Contains(id))
             {
                 return;
             }
             _convsParents.Add(id);
             res = res.GetLinkProp(NntpPlugin._propReply);
         }
         child.SetProp(NntpPlugin._propReply, article);
     }
     finally
     {
         _convsParents.Clear();
     }
 }
コード例 #11
0
        private void RepairUniqueRestrictions()
        {
            IResourceStore store            = MyPalStorage.Storage;
            IResourceList  restrictionsList = store.GetAllResources("UniqueRestriction");
            HashSet        involvedResTypes = new HashSet();

            PropTypeCollection propTypes = (PropTypeCollection)MyPalStorage.Storage.PropTypes;

            foreach (IResource lr in restrictionsList)
            {
                int uniquePropId = lr.GetIntProp("UniquePropId");
                if (!propTypes.IsValidType(uniquePropId))
                {
                    lr.Delete();
                }
                else
                {
                    string fromResourceType = lr.GetStringProp("fromResourceType");
                    if (fromResourceType != null)
                    {
                        involvedResTypes.Add(fromResourceType);
                    }
                }
            }

            restrictionsList = store.GetAllResources("UniqueRestriction");

            foreach (HashSet.Entry E in involvedResTypes)
            {
                string resType = (string)E.Key;
                ShowProgress("Checking unique restrictions for resources of type '{0}'...", resType);

                IResourceList resources  = store.GetAllResources(resType);
                HashMap       propValues = new HashMap();

                foreach (IResource resource in resources)
                {
                    IntHashSet propIds = new IntHashSet();
                    foreach (IResource ur in restrictionsList)
                    {
                        if (ur.GetStringProp("fromResourceType") == resType)
                        {
                            int propId = ur.GetIntProp("UniquePropId");
                            if (propIds.Contains(propId))      // do not process duplicate restrictions
                            {
                                continue;
                            }
                            propIds.Add(propId);
                            object propValue = resource.GetProp(propId);
                            if (propValue != null)
                            {
                                HashSet propValueSet = (HashSet)propValues [propId];
                                if (propValueSet == null)
                                {
                                    propValueSet        = new HashSet();
                                    propValues [propId] = propValueSet;
                                }
                                if (propValueSet.Contains(propValue))
                                {
                                    ReportError("Unique property value restriction violated: resource ID="
                                                + resource.Id + " property " + store.PropTypes [propId].Name + ", value " + propValue);
                                    if (_fixErrors && IsSafeToDeleteResource(resource))
                                    {
                                        resource.Delete();
                                        ++_fixCount;
                                    }
                                }
                                propValueSet.Add(propValue);
                            }
                        }
                    }
                }
            }
        }
コード例 #12
0
ファイル: JetTextBox.cs プロジェクト: mo5h/omeo
 /// <summary>
 /// Checks if the key passed in should not be submitted to action processor due to being a text editor key.
 /// </summary>
 public static bool IsEditorKey(Keys key)
 {
     lock (_hashEditorKeys)
         return(_hashEditorKeys.Contains((int)key));
 }
コード例 #13
0
ファイル: ResourceTreeSelectPane.cs プロジェクト: mo5h/omeo
 public bool AcceptNode(IResource res, int level)
 {
     return(_filterSet.Contains(res.Id));
 }
コード例 #14
0
ファイル: UserResourceOrder.cs プロジェクト: mo5h/omeo
        /// <summary>
        /// Inserts a set of the resources into the user sort order sequence.
        /// </summary>
        /// <param name="idPoint">ID of the resource that marks out the insertion point. <c>0</c> to insert without the insertion point (beginning/end of the list).</param>
        /// <param name="ids">A list of IDSs of the resources that should be inserted, in the <b>direct</b> order.</param>
        /// <param name="bInsertAfter"><c>False</c> to insert before the marker resource <paramref name="idPoint"/>, and <c>True</c> to insert after it. If the <paramref name="idPoint"/> is <c>0</c>, the new resources go to the beginning/end of the list, respectively.</param>
        /// <param name="existingids">An optional list of IDs of the existing resources we're inserting between, in the <b>direct</b> order; useful in case there's no user-order list yet.</param>
        public void Insert(int idPoint, ICollection ids, bool bInsertAfter, ICollection existingids)
        {
            if (ids == null)
            {
                throw new ArgumentNullException();
            }

            // Create a hash to check quickly whether the particular resource is being inserted and has to be removed from the old list
            IntHashSet hashNewcomers = new IntHashSet(ids.Count);

            foreach (int id in ids)
            {
                hashNewcomers.Add(id);
            }
            IntArrayList arNewcomers = new IntArrayList(ids);               // A reverse list of the newly-coming resources

            arNewcomers.Reverse();

            // Get the list of the resources as they were ordered previously (reversed)
            IntArrayList arOld   = ReadOrder();
            IntHashSet   hashOld = new IntHashSet(arOld.Count);

            foreach (int id in arOld)
            {
                hashOld.Add(id);
            }

            // Special case: there's no list yet, so it should be created using the resources we have in the current sort order (if provided)
            if (existingids != null)
            {
                if (arOld.Count == 0)
                {
                    arOld.AddRange(existingids);
                    arOld.Reverse();                     // Reverse the order to make it agree with the other sets
                }
                else
                {                 // If the list exists, but some entries reported as existing are missing from it, they should be explicidly added also
                    // They should be added to the end, thus to the beginning of the reverse array in the reverse order
                    IntArrayList arOldOld = arOld;
                    arOld = new IntArrayList(existingids.Count);
                    foreach (int id in existingids)
                    {
                        if ((!hashOld.Contains(id)) && (!hashNewcomers.Contains(id)))                                   // Don't add the items that are being dragged
                        {
                            arOld.Add(id);
                        }
                    }
                    arOld.Reverse();
                    arOld.AddRange(arOldOld);
                }
            }

            // Here the new order will be stored; allocate to the maximum possible size
            IntArrayList arNew = new IntArrayList(arOld.Count + ids.Count);

            // Special check: if the droptarget is not present in the list, add all the resources either to the beginning or to the end
            if ((idPoint == 0) || (arOld.IndexOf(idPoint) < 0))
            {             // Droptarget not found
                if (bInsertAfter)
                {
                    arNew.AddRange(arNewcomers);
                    arNew.AddRange(arOld);
                }
                else
                {
                    arNew.AddRange(arOld);
                    arNew.AddRange(arNewcomers);
                }
            }
            else
            {             // Droptarget is there, go on inserting
                foreach (int idOld in arOld)
                {
                    // Take along the current resource (if it's not excluded due to being in the inserted resources, and if it's not a droptarget in case the insertion should go before (=added after) the target)
                    if ((!hashNewcomers.Contains(idOld)) && (!((idOld == idPoint) && (bInsertAfter))))
                    {
                        arNew.Add(idOld);
                    }

                    // Copy the newcomers if we're on the droptarget
                    if (idOld == idPoint)
                    {
                        arNew.AddRange(arNewcomers);
                    }

                    // Take along the current resource in case it's the droptarget, and the insertion is to go after (=added before) it, and it has not been already included in the newcomers list
                    if ((idOld == idPoint) && (bInsertAfter) && (!hashNewcomers.Contains(idPoint)))
                    {
                        arNew.Add(idPoint);
                    }
                }
            }

            // Commit
            WriteSortOrder(arNew);
        }