Exemplo n.º 1
0
        /// <summary>
        /// Finds and removes duplicate proxy entry in a PwGroup. (ca happen if the user shares
        /// a folder more than once)
        /// </summary>
        /// <returns>True if made changes.</returns>
        private Changes RemoveDuplicateProxies()
        {
            PwObjectList <PwEntry> allProxies = m_database.GetAllProxyNodes();

            allProxies.Sort(new PwProxyComparer());
            PwEntry lastEntry  = null;
            Changes changeFlag = Changes.None;

            foreach (PwEntry proxy in allProxies)
            {
                //we only have to compare the last and the actual pwEntry because they are sorted alphabetically
                if (AreEqualProxies(proxy, lastEntry))
                {
                    proxy.DeleteFrom(proxy.ParentGroup);
                    changeFlag |= Changes.EntryDeleted;
                }
                lastEntry = proxy;
            }
            return(changeFlag);
        }
Exemplo n.º 2
0
        /// <summary>
        /// a fuction which returns a list of all folder which are shared to a specified user
        /// </summary>
        /// <param name="userRoot">The rootNode of the user you want to export you data to.</param>
        /// <returns>A <c>PwObjectList<PwGroup></c> which contains all PwGroups which are shared to
        /// the given user.</returns>
        public PwObjectList <PwGroup> GetSharedFolders(PwDatabase database, PwEntry userRoot)
        {
            PwObjectList <PwGroup> sharedFolders = new PwObjectList <PwGroup>();

            foreach (PwEntry proxy in database.GetAllProxyNodes())
            {
                if (userRoot.Uuid.ToHexString() == proxy.Strings.ReadSafe(KeeShare.UuidLinkField))
                {
                    PwGroup group = proxy.ParentGroup;
                    //we don't want to share the "Users"-folder, so if we find it, we skip it!
                    if (group == database.GetUsersGroup())
                    {
                        continue;
                    }
                    sharedFolders.Add(group);
                    //include all subfolders
                    sharedFolders.Add(group.GetGroups(true));
                }
            }
            //find the homeFolder and add it to the sharedList
            sharedFolders.Add(database.GetUserHomeFor(userRoot));
            return(sharedFolders);
        }