From dbdff8722eb781bcb8fe452cc0d894101f207fd0 Mon Sep 17 00:00:00 2001 From: Takashi Sawanaka Date: Tue, 7 Jun 2016 01:01:57 +0900 Subject: [PATCH] Make URL of Check For Updates configurable --- Src/MainFrm.cpp | 10 ++++++++-- Src/MainFrm.h | 1 + Src/OptionsDef.h | 4 ++++ Src/OptionsInit.cpp | 3 +++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Src/MainFrm.cpp b/Src/MainFrm.cpp index aa34f00fde4..ce8b722cb5f 100644 --- a/Src/MainFrm.cpp +++ b/Src/MainFrm.cpp @@ -236,6 +236,7 @@ BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText) ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText) ON_COMMAND(ID_HELP_CHECKFORUPDATES, OnHelpCheckForUpdates) + ON_UPDATE_COMMAND_UI(ID_HELP_CHECKFORUPDATES, OnUpdateHelpCheckForUpdates) ON_COMMAND(ID_FILE_OPENCONFLICT, OnFileOpenConflict) ON_COMMAND(ID_PLUGINS_LIST, OnPluginsList) ON_UPDATE_COMMAND_UI(ID_STATUS_PLUGIN, OnUpdatePluginName) @@ -2319,7 +2320,7 @@ void CMainFrame::OnHelpCheckForUpdates() CInternetSession session; try { - CHttpFile *file = (CHttpFile *)session.OpenURL(CurrentVersionURL); + CHttpFile *file = (CHttpFile *)session.OpenURL(GetOptionsMgr()->GetString(OPT_CURRENT_VERSION_URL).c_str()); if (!file) return; char buf[256] = { 0 }; @@ -2355,7 +2356,7 @@ void CMainFrame::OnHelpCheckForUpdates() { String msg = string_format_string2(_("A new version of WinMerge is available.\n%1 is now available (you have %2). Would you like to download it now?"), current_version, version.GetProductVersion()); if (AfxMessageBox(msg.c_str(), MB_ICONINFORMATION | MB_YESNO) == IDYES) - ShellExecute(NULL, _T("open"), DownloadUrl, NULL, NULL, SW_SHOWNORMAL); + ShellExecute(NULL, _T("open"), GetOptionsMgr()->GetString(OPT_DOWNLOAD_URL).c_str(), NULL, NULL, SW_SHOWNORMAL); break; } } @@ -2368,6 +2369,11 @@ void CMainFrame::OnHelpCheckForUpdates() } } +void CMainFrame::OnUpdateHelpCheckForUpdates(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(!GetOptionsMgr()->GetString(OPT_CURRENT_VERSION_URL).empty()); +} + /** * @brief Called when user selects File/Open Conflict... */ diff --git a/Src/MainFrm.h b/Src/MainFrm.h index 84f3370b31e..adeb4f111c8 100644 --- a/Src/MainFrm.h +++ b/Src/MainFrm.h @@ -261,6 +261,7 @@ class CMainFrame : public CMDIFrameWnd afx_msg void OnUpdateToolbarBig(CCmdUI* pCmdUI); afx_msg BOOL OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult); afx_msg void OnHelpCheckForUpdates(); + afx_msg void OnUpdateHelpCheckForUpdates(CCmdUI* pCmdUI); afx_msg void OnFileOpenConflict(); afx_msg void OnPluginsList(); afx_msg void OnUpdatePluginName(CCmdUI* pCmdUI); diff --git a/Src/OptionsDef.h b/Src/OptionsDef.h index 96694748397..0e090a9b6d3 100644 --- a/Src/OptionsDef.h +++ b/Src/OptionsDef.h @@ -207,6 +207,10 @@ extern const String OPT_TABBAR_AUTO_MAXWIDTH OP("Settings/TabBarAutoMaxWidth"); // MRU extern const String OPT_MRU_MAX OP("Settings/MRUMax"); +// Check For Updates +extern const String OPT_CURRENT_VERSION_URL OP("CheckForUpdates/CurrentVersionURL"); +extern const String OPT_DOWNLOAD_URL OP("CheckForUpdates/DownloadURL"); + // Font options extern const String OPT_FONT_FILECMP OP("Font/"); extern const String OPT_FONT_DIRCMP OP("FontDirCompare/"); diff --git a/Src/OptionsInit.cpp b/Src/OptionsInit.cpp index 2cf1ff2113e..0855e440c1e 100644 --- a/Src/OptionsInit.cpp +++ b/Src/OptionsInit.cpp @@ -181,6 +181,9 @@ void Init(COptionsMgr *pOptions) pOptions->InitOption(OPT_MRU_MAX, 9); + pOptions->InitOption(OPT_CURRENT_VERSION_URL, CurrentVersionURL); + pOptions->InitOption(OPT_DOWNLOAD_URL, DownloadUrl); + Options::DiffOptions::SetDefaults(pOptions); Options::DiffColors::SetDefaults(pOptions); Options::Font::SetDefaults(pOptions);