public override void Import(PwDatabase pwStorage, Stream sInput,
			IStatusLogger slLogger)
		{
			Kdb4File kdb4 = new Kdb4File(pwStorage);
			// CappedByteStream s = new CappedByteStream(sInput, 64);

			kdb4.RepairMode = true;

			try { kdb4.Load(sInput, Kdb4Format.Default, slLogger); }
			catch(Exception) { }
		}
Example #2
0
        /// <summary>
        /// Read entries from a stream.
        /// </summary>
        /// <param name="msData">Input stream to read the entries from.</param>
        /// <returns>Extracted entries.</returns>
        public static List <PwEntry> ReadEntries(Stream msData)
        {
            /* Kdb4File f = new Kdb4File(pwDatabase);
             * f.m_format = Kdb4Format.PlainXml;
             *
             * XmlDocument doc = new XmlDocument();
             * doc.Load(msData);
             *
             * XmlElement el = doc.DocumentElement;
             * if(el.Name != ElemRoot) throw new FormatException();
             *
             * List<PwEntry> vEntries = new List<PwEntry>();
             *
             * foreach(XmlNode xmlChild in el.ChildNodes)
             * {
             *      if(xmlChild.Name == ElemEntry)
             *      {
             *              PwEntry pe = f.ReadEntry(xmlChild);
             *              pe.Uuid = new PwUuid(true);
             *
             *              foreach(PwEntry peHistory in pe.History)
             *                      peHistory.Uuid = pe.Uuid;
             *
             *              vEntries.Add(pe);
             *      }
             *      else { Debug.Assert(false); }
             * }
             *
             * return vEntries; */

            PwDatabase pd = new PwDatabase();
            Kdb4File   f  = new Kdb4File(pd);

            f.Load(msData, Kdb4Format.PlainXml, null);

            List <PwEntry> vEntries = new List <PwEntry>();

            foreach (PwEntry pe in pd.RootGroup.Entries)
            {
                pe.SetUuid(new PwUuid(true), true);
                vEntries.Add(pe);
            }

            return(vEntries);
        }
Example #3
0
		public override void Import(PwDatabase pwStorage, Stream sInput,
			IStatusLogger slLogger)
		{
			Kdb4File kdb4 = new Kdb4File(pwStorage);
			kdb4.Load(sInput, Kdb4Format.PlainXml, slLogger);
		}
Example #4
0
        /// <summary>
        /// Open a database. The URL may point to any supported data source.
        /// </summary>
        /// <param name="ioSource">IO connection to load the database from.</param>
        /// <param name="pwKey">Key used to open the specified database.</param>
        /// <param name="slLogger">Logger, which gets all status messages.</param>
        public void Open(IOConnectionInfo ioSource, CompositeKey pwKey,
            IStatusLogger slLogger)
        {
            Debug.Assert(ioSource != null);
            if(ioSource == null) throw new ArgumentNullException("ioSource");
            Debug.Assert(pwKey != null);
            if(pwKey == null) throw new ArgumentNullException("pwKey");

            this.Close();

            try
            {
                m_pgRootGroup = new PwGroup(true, true, UrlUtil.StripExtension(
                    UrlUtil.GetFileName(ioSource.Path)), PwIcon.FolderOpen);
                m_pgRootGroup.IsExpanded = true;

                m_pwUserKey = pwKey;

                m_bModified = false;

                Kdb4File kdb4 = new Kdb4File(this);
                Stream s = IOConnection.OpenRead(ioSource);
                kdb4.Load(s, Kdb4Format.Default, slLogger);
                s.Close();

                m_pbHashOfLastIO = kdb4.HashOfFileOnDisk;
                m_pbHashOfFileOnDisk = kdb4.HashOfFileOnDisk;
                Debug.Assert(m_pbHashOfFileOnDisk != null);

                m_bDatabaseOpened = true;
                m_ioSource = ioSource;
            }
            catch(Exception)
            {
                this.Clear();
                throw;
            }
        }
Example #5
0
        /// <summary>
        /// Read entries from a stream.
        /// </summary>
        /// <param name="msData">Input stream to read the entries from.</param>
        /// <returns>Extracted entries.</returns>
        public static List<PwEntry> ReadEntries(Stream msData)
        {
            /* Kdb4File f = new Kdb4File(pwDatabase);
            f.m_format = Kdb4Format.PlainXml;

            XmlDocument doc = new XmlDocument();
            doc.Load(msData);

            XmlElement el = doc.DocumentElement;
            if(el.Name != ElemRoot) throw new FormatException();

            List<PwEntry> vEntries = new List<PwEntry>();

            foreach(XmlNode xmlChild in el.ChildNodes)
            {
                if(xmlChild.Name == ElemEntry)
                {
                    PwEntry pe = f.ReadEntry(xmlChild);
                    pe.Uuid = new PwUuid(true);

                    foreach(PwEntry peHistory in pe.History)
                        peHistory.Uuid = pe.Uuid;

                    vEntries.Add(pe);
                }
                else { Debug.Assert(false); }
            }

            return vEntries; */

            PwDatabase pd = new PwDatabase();
            Kdb4File f = new Kdb4File(pd);
            f.Load(msData, Kdb4Format.PlainXml, null);

            List<PwEntry> vEntries = new List<PwEntry>();
            foreach(PwEntry pe in pd.RootGroup.Entries)
            {
                pe.SetUuid(new PwUuid(true), true);
                vEntries.Add(pe);
            }

            return vEntries;
        }