Пример #1
0
        private void AddSecLine(PwGroup pgContainer, SecLine line, bool bIsContainer,
                                PwDatabase pwParent)
        {
            if (!bIsContainer)
            {
                if (line.SubLines.Count > 0)
                {
                    PwGroup pg = new PwGroup(true, true);
                    pg.Name = line.Text;

                    pgContainer.AddGroup(pg, true);

                    pgContainer = pg;
                }
                else
                {
                    PwEntry pe = new PwEntry(true, true);
                    pgContainer.AddEntry(pe, true);

                    pe.Strings.Set(PwDefs.TitleField, new ProtectedString(
                                       pwParent.MemoryProtection.ProtectTitle, line.Text));
                }
            }

            foreach (SecLine subLine in line.SubLines)
            {
                AddSecLine(pgContainer, subLine, false, pwParent);
            }
        }
Пример #2
0
        public override void Import(PwDatabase pwStorage, Stream sInput,
                                    IStatusLogger slLogger)
        {
            StreamReader sr = new StreamReader(sInput, Encoding.Default);

            Stack <SecLine> vGroups = new Stack <SecLine>();
            SecLine         secRoot = new SecLine();

            vGroups.Push(secRoot);

            char[] vTrim = new char[] { '\t', '\n', '\r', ' ' };

            while (true)
            {
                string str = sr.ReadLine();
                if (str == null)
                {
                    break;
                }
                if (str.Length == 0)
                {
                    continue;
                }

                SecLine line = new SecLine();
                line.Text = str.Trim(vTrim);

                int nTabs = CountTabs(str);

                if (nTabs == vGroups.Count)
                {
                    vGroups.Peek().SubLines.Add(line);
                    vGroups.Push(line);
                }
                else
                {
                    while (nTabs < (vGroups.Count - 1))
                    {
                        vGroups.Pop();
                    }

                    vGroups.Peek().SubLines.Add(line);
                    vGroups.Push(line);
                }
            }

            AddSecLine(pwStorage.RootGroup, secRoot, true, pwStorage);

            sr.Close();
        }
Пример #3
0
        public override void Import(PwDatabase pwStorage, Stream sInput,
			IStatusLogger slLogger)
        {
            StreamReader sr = new StreamReader(sInput, Encoding.Default);

            Stack<SecLine> vGroups = new Stack<SecLine>();
            SecLine secRoot = new SecLine();
            vGroups.Push(secRoot);

            char[] vTrim = new char[]{ '\t', '\n', '\r', ' ' };

            while(true)
            {
                string str = sr.ReadLine();
                if(str == null) break;
                if(str.Length == 0) continue;

                SecLine line = new SecLine();
                line.Text = str.Trim(vTrim);

                int nTabs = CountTabs(str);

                if(nTabs == vGroups.Count)
                {
                    vGroups.Peek().SubLines.Add(line);
                    vGroups.Push(line);
                }
                else
                {
                    while(nTabs < (vGroups.Count - 1))
                        vGroups.Pop();

                    vGroups.Peek().SubLines.Add(line);
                    vGroups.Push(line);
                }
            }

            AddSecLine(pwStorage.RootGroup, secRoot, true, pwStorage);

            sr.Close();
        }
Пример #4
0
        private void AddSecLine(PwGroup pgContainer, SecLine line, bool bIsContainer,
			PwDatabase pwParent)
        {
            if(!bIsContainer)
            {
                if(line.SubLines.Count > 0)
                {
                    PwGroup pg = new PwGroup(true, true);
                    pg.Name = line.Text;

                    pgContainer.AddGroup(pg, true);

                    pgContainer = pg;
                }
                else
                {
                    PwEntry pe = new PwEntry(true, true);
                    pgContainer.AddEntry(pe, true);

                    pe.Strings.Set(PwDefs.TitleField, new ProtectedString(
                        pwParent.MemoryProtection.ProtectTitle, line.Text));
                }
            }

            foreach(SecLine subLine in line.SubLines)
                AddSecLine(pgContainer, subLine, false, pwParent);
        }