• R/O
  • SSH
  • HTTPS

tortoisesvn: Commit


Commit MetaInfo

Revisão29182 (tree)
Hora2021-05-02 21:13:06
Autorstefankueng

Mensagem de Log

cleanup update check

Mudança Sumário

Diff

--- trunk/src/TortoiseProc/CheckForUpdatesDlg.cpp (revision 29181)
+++ trunk/src/TortoiseProc/CheckForUpdatesDlg.cpp (revision 29182)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2003-2015, 2017-2018 - TortoiseSVN
3+// Copyright (C) 2003-2015, 2017-2018, 2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -17,7 +17,6 @@
1717 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1818 //
1919 #include "stdafx.h"
20-#include "TortoiseProc.h"
2120 #include "../version.h"
2221 #include "CheckForUpdatesDlg.h"
2322 #include "registry.h"
@@ -24,13 +23,12 @@
2423 #include "AppUtils.h"
2524 #include "TempFile.h"
2625
27-
2826 IMPLEMENT_DYNAMIC(CCheckForUpdatesDlg, CStandAloneDialog)
2927 CCheckForUpdatesDlg::CCheckForUpdatesDlg(CWnd* pParent /*=NULL*/)
3028 : CStandAloneDialog(CCheckForUpdatesDlg::IDD, pParent)
29+ , m_bThreadRunning(FALSE)
3130 , m_bShowInfo(FALSE)
3231 , m_bVisible(FALSE)
33- , m_bThreadRunning(FALSE)
3432 {
3533 m_sUpdateDownloadLink = L"https://tortoisesvn.net";
3634 }
@@ -45,7 +43,6 @@
4543 DDX_Control(pDX, IDC_LINK, m_link);
4644 }
4745
48-
4946 BEGIN_MESSAGE_MAP(CCheckForUpdatesDlg, CStandAloneDialog)
5047 ON_STN_CLICKED(IDC_CHECKRESULT, OnStnClickedCheckresult)
5148 ON_WM_TIMER()
@@ -72,12 +69,12 @@
7269
7370 DialogEnableWindow(IDOK, FALSE);
7471
75- if (AfxBeginThread(CheckThreadEntry, this)==NULL)
72+ if (AfxBeginThread(CheckThreadEntry, this) == nullptr)
7673 {
77- TaskDialog(this->m_hWnd, AfxGetResourceHandle(), MAKEINTRESOURCE(IDS_APPNAME), MAKEINTRESOURCE(IDS_ERR_ERROROCCURED), MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED), TDCBF_OK_BUTTON, TD_ERROR_ICON, NULL);
74+ TaskDialog(this->m_hWnd, AfxGetResourceHandle(), MAKEINTRESOURCE(IDS_APPNAME), MAKEINTRESOURCE(IDS_ERR_ERROROCCURED), MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED), TDCBF_OK_BUTTON, TD_ERROR_ICON, nullptr);
7875 }
7976
80- SetTimer(100, 1000, NULL);
77+ SetTimer(100, 1000, nullptr);
8178 return TRUE;
8279 }
8380
@@ -97,8 +94,8 @@
9794
9895 UINT CCheckForUpdatesDlg::CheckThreadEntry(LPVOID pVoid)
9996 {
100- CCrashReportThread crashthread;
101- return ((CCheckForUpdatesDlg*)pVoid)->CheckThread();
97+ CCrashReportThread crashThread;
98+ return static_cast<CCheckForUpdatesDlg*>(pVoid)->CheckThread();
10299 }
103100
104101 UINT CCheckForUpdatesDlg::CheckThread()
@@ -106,52 +103,52 @@
106103 m_bThreadRunning = TRUE;
107104
108105 CString temp;
109- CString tempfile = CTempFiles::Instance().GetTempFilePath(true).GetWinPathString();
106+ CString tempFile = CTempFiles::Instance().GetTempFilePath(true).GetWinPathString();
110107
111- CRegString checkurluser = CRegString(L"Software\\TortoiseSVN\\UpdateCheckURL", L"");
112- CRegString checkurlmachine = CRegString(L"Software\\TortoiseSVN\\UpdateCheckURL", L"", FALSE, HKEY_LOCAL_MACHINE);
113- CString sCheckURL = checkurluser;
108+ CRegString checkUrlUser = CRegString(L"Software\\TortoiseSVN\\UpdateCheckURL", L"");
109+ CRegString checkUrlMachine = CRegString(L"Software\\TortoiseSVN\\UpdateCheckURL", L"", FALSE, HKEY_LOCAL_MACHINE);
110+ CString sCheckURL = checkUrlUser;
114111 if (sCheckURL.IsEmpty())
115112 {
116- sCheckURL = checkurlmachine;
113+ sCheckURL = checkUrlMachine;
117114 if (sCheckURL.IsEmpty())
118115 sCheckURL = L"https://tortoisesvn.net/version.txt";
119116 }
120- HRESULT res = URLDownloadToFile(NULL, sCheckURL, tempfile, 0, NULL);
117+ HRESULT res = URLDownloadToFile(nullptr, sCheckURL, tempFile, 0, nullptr);
121118 if (res == S_OK)
122119 {
123120 try
124121 {
125- CStdioFile file(tempfile, CFile::modeRead | CFile::shareDenyWrite);
126- CString ver;
122+ CStdioFile file(tempFile, CFile::modeRead | CFile::shareDenyWrite);
123+ CString ver;
127124 if (file.ReadString(ver))
128125 {
129- CString vertemp = ver;
130- int major = _wtoi(vertemp);
131- vertemp = vertemp.Mid(vertemp.Find('.')+1);
132- int minor = _wtoi(vertemp);
133- vertemp = vertemp.Mid(vertemp.Find('.')+1);
134- int micro = _wtoi(vertemp);
135- vertemp = vertemp.Mid(vertemp.Find('.')+1);
136- int build = _wtoi(vertemp);
137- BOOL bNewer = FALSE;
126+ CString verTemp = ver;
127+ int major = _wtoi(verTemp);
128+ verTemp = verTemp.Mid(verTemp.Find('.') + 1);
129+ int minor = _wtoi(verTemp);
130+ verTemp = verTemp.Mid(verTemp.Find('.') + 1);
131+ int micro = _wtoi(verTemp);
132+ verTemp = verTemp.Mid(verTemp.Find('.') + 1);
133+ int build = _wtoi(verTemp);
134+ BOOL bNewer = FALSE;
138135 if (major > TSVN_VERMAJOR)
139136 bNewer = TRUE;
140- else if ((minor > TSVN_VERMINOR)&&(major == TSVN_VERMAJOR))
137+ else if ((minor > TSVN_VERMINOR) && (major == TSVN_VERMAJOR))
141138 bNewer = TRUE;
142- else if ((micro > TSVN_VERMICRO)&&(minor == TSVN_VERMINOR)&&(major == TSVN_VERMAJOR))
139+ else if ((micro > TSVN_VERMICRO) && (minor == TSVN_VERMINOR) && (major == TSVN_VERMAJOR))
143140 bNewer = TRUE;
144- else if ((build > TSVN_VERBUILD)&&(micro == TSVN_VERMICRO)&&(minor == TSVN_VERMINOR)&&(major == TSVN_VERMAJOR))
141+ else if ((build > TSVN_VERBUILD) && (micro == TSVN_VERMICRO) && (minor == TSVN_VERMINOR) && (major == TSVN_VERMAJOR))
145142 bNewer = TRUE;
146143
147- if (_wtoi(ver)!=0)
144+ if (_wtoi(ver) != 0)
148145 {
149- temp.Format(IDS_CHECKNEWER_CURRENTVERSION, (LPCTSTR)ver);
146+ temp.Format(IDS_CHECKNEWER_CURRENTVERSION, static_cast<LPCWSTR>(ver));
150147 SetDlgItemText(IDC_CURRENTVERSION, temp);
151148 temp.Format(L"%d.%d.%d.%d", TSVN_VERMAJOR, TSVN_VERMINOR, TSVN_VERMICRO, TSVN_VERBUILD);
152149 }
153150
154- if (_wtoi(ver)==0)
151+ if (_wtoi(ver) == 0)
155152 {
156153 temp.LoadString(IDS_CHECKNEWER_NETERROR);
157154 SetDlgItemText(IDC_CHECKRESULT, temp);
@@ -158,15 +155,15 @@
158155 }
159156 else if (bNewer)
160157 {
161- if(file.ReadString(temp) && !temp.IsEmpty())
162- { // Read the next line, it could contain a message for the user
163- CString tempLink;
158+ if (file.ReadString(temp) && !temp.IsEmpty())
159+ { // Read the next line, it could contain a message for the user
160+ CString tempLink;
164161 CRegString regDownLink(L"Software\\TortoiseSVN\\NewVersionLink");
165162 regDownLink = tempLink;
166- if(file.ReadString(tempLink) && !tempLink.IsEmpty())
167- { // Read another line to find out the download link-URL, if any
163+ if (file.ReadString(tempLink) && !tempLink.IsEmpty())
164+ { // Read another line to find out the download link-URL, if any
168165 m_sUpdateDownloadLink = tempLink;
169- regDownLink = m_sUpdateDownloadLink;
166+ regDownLink = m_sUpdateDownloadLink;
170167 }
171168 }
172169 else
@@ -178,7 +175,7 @@
178175 SetDlgItemText(IDC_CHECKRESULT, temp);
179176 // only show the dialog for newer versions if the 'old style' update check
180177 // is requested. The current update check shows the info in the commit dialog.
181- if (DWORD(CRegDWORD(L"Software\\TortoiseSVN\\OldVersionCheck")))
178+ if (static_cast<DWORD>(CRegDWORD(L"Software\\TortoiseSVN\\OldVersionCheck")))
182179 m_bShowInfo = TRUE;
183180 CRegString regVer(L"Software\\TortoiseSVN\\NewVersion");
184181 regVer = ver;
@@ -187,10 +184,10 @@
187184 {
188185 temp.LoadString(IDS_CHECKNEWER_YOURUPTODATE);
189186 SetDlgItemText(IDC_CHECKRESULT, temp);
190- if(file.ReadString(temp) && !temp.IsEmpty())
187+ if (file.ReadString(temp) && !temp.IsEmpty())
191188 {
192189 // Read the next line, it could contain a message for the user
193- if(file.ReadString(temp) && !temp.IsEmpty())
190+ if (file.ReadString(temp) && !temp.IsEmpty())
194191 {
195192 // Read another line to find out the download link-URL, if any
196193 m_sUpdateDownloadLink = temp;
@@ -203,7 +200,7 @@
203200 }
204201 }
205202 }
206- catch (CException * e)
203+ catch (CException* e)
207204 {
208205 e->Delete();
209206 temp.LoadString(IDS_CHECKNEWER_NETERROR);
@@ -221,19 +218,20 @@
221218 m_link.SetURL(m_sUpdateDownloadLink);
222219 }
223220
224- DeleteFile(tempfile);
221+ DeleteFile(tempFile);
225222 m_bThreadRunning = FALSE;
226223 DialogEnableWindow(IDOK, TRUE);
227224 return 0;
228225 }
229226
227+// ReSharper disable once CppMemberFunctionMayBeConst
230228 void CCheckForUpdatesDlg::OnStnClickedCheckresult()
231229 {
232230 // user clicked on the label, start the browser with our web page
233- HINSTANCE result = ShellExecute(NULL, L"opennew", m_sUpdateDownloadLink, NULL,NULL, SW_SHOWNORMAL);
234- if ((INT_PTR)result <= HINSTANCE_ERROR)
231+ HINSTANCE result = ShellExecute(nullptr, L"opennew", m_sUpdateDownloadLink, nullptr, nullptr, SW_SHOWNORMAL);
232+ if (reinterpret_cast<INT_PTR>(result) <= HINSTANCE_ERROR)
235233 {
236- ShellExecute(NULL, L"open", m_sUpdateDownloadLink, NULL,NULL, SW_SHOWNORMAL);
234+ ShellExecute(nullptr, L"open", m_sUpdateDownloadLink, nullptr, nullptr, SW_SHOWNORMAL);
237235 }
238236 }
239237
@@ -266,14 +264,14 @@
266264
267265 BOOL CCheckForUpdatesDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
268266 {
269- if ((!m_sUpdateDownloadLink.IsEmpty())&&(pWnd)&&(pWnd == GetDlgItem(IDC_CHECKRESULT)))
267+ if ((!m_sUpdateDownloadLink.IsEmpty()) && (pWnd) && (pWnd == GetDlgItem(IDC_CHECKRESULT)))
270268 {
271- HCURSOR hCur = LoadCursor(NULL, IDC_HAND);
269+ HCURSOR hCur = LoadCursor(nullptr, IDC_HAND);
272270 SetCursor(hCur);
273271 return TRUE;
274272 }
275273
276- HCURSOR hCur = LoadCursor(NULL, IDC_ARROW);
274+ HCURSOR hCur = LoadCursor(nullptr, IDC_ARROW);
277275 SetCursor(hCur);
278276 return CStandAloneDialogTmpl<CDialog>::OnSetCursor(pWnd, nHitTest, message);
279277 }
\ No newline at end of file
--- trunk/src/TortoiseProc/CheckForUpdatesDlg.h (revision 29181)
+++ trunk/src/TortoiseProc/CheckForUpdatesDlg.h (revision 29182)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2003-2010 - TortoiseSVN
3+// Copyright (C) 2003-2010, 2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -31,10 +31,13 @@
3131 DECLARE_DYNAMIC(CCheckForUpdatesDlg)
3232
3333 public:
34- CCheckForUpdatesDlg(CWnd* pParent = NULL); // standard constructor
35- virtual ~CCheckForUpdatesDlg();
34+ CCheckForUpdatesDlg(CWnd* pParent = nullptr); // standard constructor
35+ ~CCheckForUpdatesDlg() override;
3636
37- enum { IDD = IDD_CHECKFORUPDATES };
37+ enum
38+ {
39+ IDD = IDD_CHECKFORUPDATES
40+ };
3841
3942 protected:
4043 afx_msg void OnStnClickedCheckresult();
@@ -41,10 +44,10 @@
4144 afx_msg void OnTimer(UINT_PTR nIDEvent);
4245 afx_msg void OnWindowPosChanging(WINDOWPOS* lpwndpos);
4346 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
44- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
45- virtual BOOL OnInitDialog();
46- virtual void OnOK();
47- virtual void OnCancel();
47+ void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support
48+ BOOL OnInitDialog() override;
49+ void OnOK() override;
50+ void OnCancel() override;
4851
4952 DECLARE_MESSAGE_MAP()
5053
@@ -53,12 +56,11 @@
5356 UINT CheckThread();
5457
5558 public:
56- BOOL m_bThreadRunning;
57- BOOL m_bShowInfo;
58- BOOL m_bVisible;
59+ BOOL m_bThreadRunning;
60+ BOOL m_bShowInfo;
61+ BOOL m_bVisible;
5962
6063 private:
61- CString m_sUpdateDownloadLink; ///< Where to send a user looking to download a update
62- CHyperLink m_link;
64+ CString m_sUpdateDownloadLink; ///< Where to send a user looking to download a update
65+ CHyperLink m_link;
6366 };
64-
--- trunk/src/TortoiseProc/Commands/UpdateCheckCommand.h (revision 29181)
+++ trunk/src/TortoiseProc/Commands/UpdateCheckCommand.h (revision 29182)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2007, 2011-2012 - TortoiseSVN
3+// Copyright (C) 2007, 2011-2012, 2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -29,8 +29,6 @@
2929 /**
3030 * Executes the command.
3131 */
32- virtual bool Execute() override;
33- virtual bool CheckPaths() override {return true;}
32+ bool Execute() override;
33+ bool CheckPaths() override { return true; }
3434 };
35-
36-
Show on old repository browser