Beispiel #1
0
        private void GetAppComponents()
        {
            ListViewItem lvi = new ListViewItem(KPRes.KeePassLibCLong);

            if (!Kdb3File.IsLibraryInstalled())
            {
                lvi.SubItems.Add(KPRes.NotInstalled);
            }
            else
            {
                lvi.SubItems.Add(Kdb3Manager.KeePassVersionString + " (0x" +
                                 Kdb3Manager.LibraryBuild.ToString("X4") + ")");
            }
            m_lvComponents.Items.Add(lvi);

            lvi = new ListViewItem(KPRes.XslStylesheets);
            string strPath = WinUtil.GetExecutable();

            strPath = UrlUtil.GetFileDirectory(strPath, true);
            bool bInstalled = File.Exists(strPath + AppDefs.XslFileHtmlLite);

            bInstalled &= File.Exists(strPath + AppDefs.XslFileHtmlFull);
            bInstalled &= File.Exists(strPath + AppDefs.XslFileHtmlTabular);

            if (!bInstalled)
            {
                lvi.SubItems.Add(KPRes.NotInstalled);
            }
            else
            {
                lvi.SubItems.Add(PwDefs.VersionString);
            }
            m_lvComponents.Items.Add(lvi);
        }
Beispiel #2
0
        public override bool Export(PwExportInfo pwExportInfo, Stream sOutput,
                                    IStatusLogger slLogger)
        {
            PwDatabase pd = (pwExportInfo.ContextDatabase ?? new PwDatabase());

            string strTempFile = Program.TempFilesPool.GetTempFileName(false);

            try
            {
                Kdb3File kdb = new Kdb3File(pd, slLogger);
                kdb.Save(strTempFile, pwExportInfo.DataGroup);

                byte[] pbKdb = File.ReadAllBytes(strTempFile);
                sOutput.Write(pbKdb, 0, pbKdb.Length);
                Array.Clear(pbKdb, 0, pbKdb.Length);
            }
            catch (Exception exKdb)
            {
                if (slLogger != null)
                {
                    slLogger.SetText(exKdb.Message, LogStatusType.Error);
                }

                return(false);
            }

            Program.TempFilesPool.Delete(strTempFile);
            return(true);
        }
Beispiel #3
0
        public override bool TryBeginImport()
        {
            Exception exLib;

            if (!Kdb3File.IsLibraryInstalled(out exLib))
            {
                MessageService.ShowWarning(KPRes.KeePassLibCNotFound,
                                           KPRes.Kdb3KeePassLibC, exLib);

                return(false);
            }

            return(true);
        }
Beispiel #4
0
        public override void Import(PwDatabase pwStorage, Stream sInput,
                                    IStatusLogger slLogger)
        {
            string strTempFile = Program.TempFilesPool.GetTempFileName();

            BinaryReader br = new BinaryReader(sInput);

            byte[] pb = br.ReadBytes((int)sInput.Length);
            br.Close();
            File.WriteAllBytes(strTempFile, pb);

            Kdb3File kdb3 = new Kdb3File(pwStorage, slLogger);

            kdb3.Load(strTempFile);

            Program.TempFilesPool.Delete(strTempFile);
        }
Beispiel #5
0
        public override bool Export(PwExportInfo pwExportInfo, Stream sOutput,
            IStatusLogger slLogger)
        {
            PwDatabase pd = (pwExportInfo.ContextDatabase ?? new PwDatabase());

            string strTempFile = Program.TempFilesPool.GetTempFileName(false);

            try
            {
                Kdb3File kdb = new Kdb3File(pd, slLogger);
                kdb.Save(strTempFile, pwExportInfo.DataGroup);

                byte[] pbKdb = File.ReadAllBytes(strTempFile);
                sOutput.Write(pbKdb, 0, pbKdb.Length);
                Array.Clear(pbKdb, 0, pbKdb.Length);
            }
            catch(Exception exKdb)
            {
                if(slLogger != null) slLogger.SetText(exKdb.Message, LogStatusType.Error);

                return false;
            }

            Program.TempFilesPool.Delete(strTempFile);
            return true;
        }
Beispiel #6
0
        public override void Import(PwDatabase pwStorage, Stream sInput,
            IStatusLogger slLogger)
        {
            string strTempFile = Program.TempFilesPool.GetTempFileName();

            BinaryReader br = new BinaryReader(sInput);
            byte[] pb = br.ReadBytes((int)sInput.Length);
            br.Close();
            File.WriteAllBytes(strTempFile, pb);

            Kdb3File kdb3 = new Kdb3File(pwStorage, slLogger);
            kdb3.Load(strTempFile);

            Program.TempFilesPool.Delete(strTempFile);
        }