Ejemplo n.º 1
0
        public static bool?Synchronize(PwDatabase pwStorage, IUIOperations uiOps,
                                       bool bOpenFromUrl, Form fParent)
        {
            if (pwStorage == null)
            {
                throw new ArgumentNullException("pwStorage");
            }
            if (!pwStorage.IsOpen)
            {
                return(null);
            }
            if (!AppPolicy.Try(AppPolicyId.Import))
            {
                return(null);
            }

            List <IOConnectionInfo> vConnections = new List <IOConnectionInfo>();

            if (bOpenFromUrl == false)
            {
                OpenFileDialogEx ofd = UIUtil.CreateOpenFileDialog(KPRes.Synchronize,
                                                                   UIUtil.CreateFileTypeFilter(AppDefs.FileExtension.FileExt,
                                                                                               KPRes.KdbxFiles, true), 1, null, true,
                                                                   AppDefs.FileDialogContext.Sync);

                if (ofd.ShowDialog() != DialogResult.OK)
                {
                    return(null);
                }

                foreach (string strSelFile in ofd.FileNames)
                {
                    vConnections.Add(IOConnectionInfo.FromPath(strSelFile));
                }
            }
            else             // Open URL
            {
                IOConnectionForm iocf = new IOConnectionForm();
                iocf.InitEx(false, null, true, true);

                if (UIUtil.ShowDialogNotValue(iocf, DialogResult.OK))
                {
                    return(null);
                }

                vConnections.Add(iocf.IOConnectionInfo);
                UIUtil.DestroyForm(iocf);
            }

            return(Import(pwStorage, new KeePassKdb2x(), vConnections.ToArray(),
                          true, uiOps, false, fParent));
        }
Ejemplo n.º 2
0
        public static bool Synchronize(PwDatabase pwStorage, IUIOperations uiOps,
                                       bool bOpenFromUrl)
        {
            if (pwStorage == null)
            {
                throw new ArgumentNullException("pwStorage");
            }
            if (!pwStorage.IsOpen)
            {
                return(false);
            }
            if (!AppPolicy.Try(AppPolicyId.Import))
            {
                return(false);
            }

            List <IOConnectionInfo> vConnections = new List <IOConnectionInfo>();

            if (bOpenFromUrl == false)
            {
                OpenFileDialog ofd = UIUtil.CreateOpenFileDialog(KPRes.Synchronize,
                                                                 UIUtil.CreateFileTypeFilter(null, null, true), 1, null, true, true);

                if (ofd.ShowDialog() != DialogResult.OK)
                {
                    return(true);
                }

                foreach (string strSelFile in ofd.FileNames)
                {
                    vConnections.Add(IOConnectionInfo.FromPath(strSelFile));
                }
            }
            else             // Open URL
            {
                IOConnectionForm iocf = new IOConnectionForm();
                iocf.InitEx(false, new IOConnectionInfo(), false, true);

                if (iocf.ShowDialog() != DialogResult.OK)
                {
                    return(true);
                }

                vConnections.Add(iocf.IOConnectionInfo);
            }

            return(PerformImport(pwStorage, new KeePassKdb2x(), vConnections.ToArray(),
                                 true, uiOps, false));
        }
Ejemplo n.º 3
0
        // Start of modification by B.L

        //Shamir Synchronize
        public static bool?ShamirSynchronize(PwDatabase pwStorage, IUIOperations uiOps,
                                             bool bOpenFromUrl, Form fParent, List <string> paths)
        {
            if (pwStorage == null)
            {
                throw new ArgumentNullException("pwStorage");
            }
            if (!pwStorage.IsOpen)
            {
                return(null);
            }
            if (!AppPolicy.Try(AppPolicyId.Import))
            {
                return(null);
            }

            List <IOConnectionInfo> vConnections = new List <IOConnectionInfo>();

            if (bOpenFromUrl == false)
            {
                foreach (string s in paths)
                {
                    vConnections.Add(IOConnectionInfo.FromPath(s));
                }
            }
            else // Open URL
            {
                IOConnectionForm iocf = new IOConnectionForm();
                iocf.InitEx(false, null, true, true);

                if (UIUtil.ShowDialogNotValue(iocf, DialogResult.OK))
                {
                    return(null);
                }

                vConnections.Add(iocf.IOConnectionInfo);
                UIUtil.DestroyForm(iocf);
            }

            return(Import(pwStorage, new KeePassKdb2x(), vConnections.ToArray(),
                          true, uiOps, false, fParent));
        }