Skip to content

Commit

Permalink
Make URL of Check For Updates configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
sdottaka committed Jun 6, 2016
1 parent 719709e commit dbdff87
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Src/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 };
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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...
*/
Expand Down
1 change: 1 addition & 0 deletions Src/MainFrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions Src/OptionsDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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/");
Expand Down
3 changes: 3 additions & 0 deletions Src/OptionsInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit dbdff87

Please sign in to comment.