private static void ShowUpdateDialogPriv(List <UpdateComponentInfo> lInst, bool bModal) { try { UpdateCheckForm dlg = new UpdateCheckForm(); dlg.InitEx(lInst, bModal); UIUtil.ShowDialogAndDestroy(dlg); } catch (Exception) { Debug.Assert(false); } }
private static void ShowUpdateDialogPriv(List<UpdateComponentInfo> lInst, bool bModal) { try { // Do not show the update dialog while auto-typing; // https://sourceforge.net/p/keepass/bugs/1265/ if(SendInputEx.IsSending) return; UpdateCheckForm dlg = new UpdateCheckForm(); dlg.InitEx(lInst, bModal); UIUtil.ShowDialogAndDestroy(dlg); } catch(Exception) { Debug.Assert(false); } }
private static void RunPriv(object o) { UpdateCheckParams p = (o as UpdateCheckParams); if (p == null) { Debug.Assert(false); return; } IStatusLogger sl = null; try { if (p.ForceUI) { Form fStatusDialog; sl = StatusUtil.CreateStatusDialog(p.Parent, out fStatusDialog, KPRes.UpdateCheck, KPRes.CheckingForUpd + "...", true, true); } List <UpdateComponentInfo> lInst = GetInstalledComponents(); List <string> lUrls = GetUrls(lInst); Dictionary <string, List <UpdateComponentInfo> > dictAvail = DownloadInfoFiles(lUrls, sl); if (dictAvail == null) { return; // User cancelled } MergeInfo(lInst, dictAvail); bool bUpdAvail = false; foreach (UpdateComponentInfo uc in lInst) { if (uc.Status == UpdateComponentStatus.NewVerAvailable) { bUpdAvail = true; break; } } if (sl != null) { sl.EndLogging(); sl = null; } if (bUpdAvail || p.ForceUI) { UpdateCheckForm dlg = new UpdateCheckForm(); dlg.InitEx(lInst, p.ForceUI); UIUtil.ShowDialogAndDestroy(dlg); } } catch (Exception) { Debug.Assert(false); } finally { try { if (sl != null) { sl.EndLogging(); } } catch (Exception) { Debug.Assert(false); } } }
private void UpdateCheckBackground() { List <string> lMsg = new List <string>(); string sBackup = KeePass.Program.Config.Application.LastUpdateCheck; KeePass.Program.Config.Application.LastUpdateCheck = TimeUtil.SerializeUtc(DateTime.UtcNow); bool bOK = true; MethodInfo miGetInstalledComponents = typeof(UpdateCheckEx).GetMethod("GetInstalledComponents", BindingFlags.Static | BindingFlags.NonPublic); if (miGetInstalledComponents == null) { bOK = false; lMsg.Add("Could not locate UpdateCheckEx.GetInstalledComponents"); } MethodInfo miGetUrls = typeof(UpdateCheckEx).GetMethod("GetUrls", BindingFlags.Static | BindingFlags.NonPublic); if (miGetUrls == null) { bOK = false; lMsg.Add("Could not locate UpdateCheckEx.GetUrls"); } MethodInfo miDownloadInfoFiles = typeof(UpdateCheckEx).GetMethod("DownloadInfoFiles", BindingFlags.Static | BindingFlags.NonPublic); if (miDownloadInfoFiles == null) { bOK = false; lMsg.Add("Could not locate UpdateCheckEx.DownloadInfoFiles"); } MethodInfo miMergeInfo = typeof(UpdateCheckEx).GetMethod("MergeInfo", BindingFlags.Static | BindingFlags.NonPublic); if (miMergeInfo == null) { bOK = false; lMsg.Add("Could not locate UpdateCheckEx.MergeInfo"); } try { m_bRestartInvoke = true; KeePassLib.Delegates.GAction actUpdateCheck = new KeePassLib.Delegates.GAction(() => { //taken from UpdateCheckExt.RunPriv //MainForm.InvokeRequired is not true on Mono :( try { lock (m_lock) { m_UpdateCheckStatus = UpdateCheckStatus.Checking; } List <UpdateComponentInfo> lInst = (List <UpdateComponentInfo>)miGetInstalledComponents.Invoke(null, null); List <string> lUrls = (List <string>)miGetUrls.Invoke(null, new object[] { lInst }); Dictionary <string, List <UpdateComponentInfo> > dictAvail = (Dictionary <string, List <UpdateComponentInfo> >)miDownloadInfoFiles.Invoke(null, new object[] { lUrls, null /* m_slUpdateCheck */ }); if (dictAvail == null) { return; // User cancelled } miMergeInfo.Invoke(null, new object[] { lInst, dictAvail }); bool bUpdAvail = false; foreach (UpdateComponentInfo uc in lInst) { if (uc.Status == UpdateComponentStatus.NewVerAvailable) { bUpdAvail = true; break; } } if (m_slUpdateCheck != null) { m_host.MainWindow.Invoke(new KeePassLib.Delegates.GAction(() => { m_slUpdateCheck.EndLogging(); })); m_slUpdateCheck = null; } KeePassLib.Delegates.GAction actShowUpdateForm_UIThread = new KeePassLib.Delegates.GAction(() => { try { // Do not show the update dialog while auto-typing; // https://sourceforge.net/p/keepass/bugs/1265/ if (SendInputEx.IsSending) { return; } UpdateCheckForm dlg = new UpdateCheckForm(); dlg.InitEx(lInst, false); var dr = UIUtil.ShowDialogAndDestroy(dlg); } catch (Exception ex) { bOK = false; lMsg.Add(ex.Message); } }); if (bUpdAvail) { m_host.MainWindow.BeginInvoke(actShowUpdateForm_UIThread); } } catch (Exception ex) { bOK = false; lMsg.Add(ex.Message); } finally { try { if (m_slUpdateCheck != null) { m_slUpdateCheck.EndLogging(); } } catch (Exception) { } if (bOK) { lock (m_lock) { m_UpdateCheckStatus = UpdateCheckStatus.Checked; } } else { lock (m_lock) { m_UpdateCheckStatus = UpdateCheckStatus.Error; } } } }); if (bOK) { try { m_slUpdateCheck = CreateUpdateCheckLogger(); lMsg.Add("Initialising StatusLogger create: " + DebugPrint); } catch (Exception ex) { lMsg.Add("Initialising StatusLogger failed:\n" + ex.Message + "\n" + DebugPrint); } ThreadPool.QueueUserWorkItem(new WaitCallback((object o) => { actUpdateCheck(); })); } while (true) { if ((m_slUpdateCheck != null) && !m_slUpdateCheck.ContinueWork()) { break; } lock (m_lock) { if (m_UpdateCheckStatus == UpdateCheckStatus.Checked) { break; } if (m_UpdateCheckStatus == UpdateCheckStatus.Error) { break; } } } if (m_slUpdateCheck != null) { m_slUpdateCheck.EndLogging(); } if (bOK) { return; } } catch (Exception ex) { bOK = false; lMsg.Add(ex.Message); } finally { lMsg.Insert(0, "Successful: " + bOK.ToString()); if (bOK) { PluginDebug.AddSuccess("Run updatecheck in background", 0, lMsg.ToArray()); } else { PluginDebug.AddError("Run updatecheck in background", 0, lMsg.ToArray()); } } }