Description: Allow disabling of online version check
 Gives a build-time option to disable curl-based check for new version.  Patch
 was submitted by author to upstream but it has not been merged.
Author: Andrey Kuznetsov (pm-kan on github), with modifications/additions by Bill Blough <bblough@debian.org>
Origin: https://github.com/pwsafe/pwsafe/commit/2a0f595edf83fe8d1433645e27dc444767fff315.diff
Forwarded: not-needed
Last-Update: 2019-08-19
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
Index: passwordsafe/CMakeLists.txt
===================================================================
--- passwordsafe.orig/CMakeLists.txt	2025-04-03 21:21:05.052297440 -0400
+++ passwordsafe/CMakeLists.txt	2025-04-03 21:21:05.048297395 -0400
@@ -54,6 +54,7 @@
 option (NO_YUBI "Set ON to disable YubiKey support" OFF)
 option (NO_GTEST "Set ON to disable gtest unit testing" OFF)
 option (GTEST_BUILD "Set OFF to disable gtest download and build on-fly" ON)
+option (NO_VERCHECK "Set ON to disable online version check" OFF)
 
 if (WIN32)
   option (WX_WINDOWS "Build wxWidget under Windows" OFF)
@@ -103,11 +104,13 @@
                )
      endif (NOT PWSHINT_wxconfig)
   endif (NOT WIN32)
-  find_package(wxWidgets COMPONENTS adv aui base core html net REQUIRED)
+  find_package(wxWidgets COMPONENTS adv aui base core html REQUIRED)
   include(${wxWidgets_USE_FILE})
 
+if (NOT NO_VERCHECK)
   find_package(OpenSSL REQUIRED)
   include_directories(${OPENSSL_INCLUDE_DIR})
+endif(NOT NO_VERCHECK)
 
   if (NOT APPLE)
     find_package(Magic REQUIRED)
@@ -191,6 +194,11 @@
   $<$<NOT:$<CONFIG:DEBUG>>:NDEBUG>
 )
 
+if (NO_VERCHECK)
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNO_VERCHECK")
+  message(STATUS "Online version check disabled")
+endif (NO_VERCHECK)
+
 # Assume that we're either MSVC or a Unix-like
 if (MSVC)
 # Debug build looks for dlls with _D postfix, this provides it:
@@ -318,9 +326,14 @@
 
 target_link_libraries(pwsafe pws_version)
 
+if (NOT NO_VERCHECK)
+ set (CURL_LIBS "curl ${OPENSSL_SSL_LIBRARY}")
+endif ()
+
+
 if (APPLE)
   FIND_LIBRARY(QUARTZCORE_LIBS QuartzCore)
-  target_link_libraries(pwsafe ${wxWidgets_LIBRARIES} ${CMAKE_REQUIRED_LIBRARIES} ${QUARTZCORE_LIBS} curl ${OPENSSL_SSL_LIBRARY})
+  target_link_libraries(pwsafe ${wxWidgets_LIBRARIES} ${CMAKE_REQUIRED_LIBRARIES} ${QUARTZCORE_LIBS} ${CURL_LIBS})
 elseif (WIN32)
   if (NOT NO_YUBI)
     set (YUBILIB "YkLib22")
@@ -332,8 +345,7 @@
   if (NOT NO_QR)
     target_link_libraries(pwsafe qrencode  ${CMAKE_REQUIRED_LIBRARIES})
   endif (NOT NO_QR)
-  target_link_libraries(pwsafe ${wxWidgets_LIBRARIES} uuid Xtst X11 curl ${OPENSSL_SSL_LIBRARY} ${MAGIC_LIBRARIES}
-  ${CMAKE_REQUIRED_LIBRARIES})
+  target_link_libraries(pwsafe ${wxWidgets_LIBRARIES} uuid Xtst X11 ${CURL_LIBS} ${MAGIC_LIBRARIES} ${CMAKE_REQUIRED_LIBRARIES})
 endif()
 
 # Installation stuff (for 'make install', but mainly for 'make package')
Index: passwordsafe/src/ui/wxWidgets/AboutDlg.cpp
===================================================================
--- passwordsafe.orig/src/ui/wxWidgets/AboutDlg.cpp	2025-04-03 21:21:05.052297440 -0400
+++ passwordsafe/src/ui/wxWidgets/AboutDlg.cpp	2025-04-03 21:21:05.048297395 -0400
@@ -50,14 +50,20 @@
   EVT_HYPERLINK( ID_CHECKNEW     , AboutDlg::OnCheckNewClicked   )
   EVT_HYPERLINK( ID_SITEHYPERLINK, AboutDlg::OnVisitSiteClicked  )
   EVT_BUTTON(    wxID_CLOSE      , AboutDlg::OnCloseClick        )
+#ifndef NO_VERCHECK
   EVT_THREAD(    wxID_ANY        , AboutDlg::OnDownloadCompleted )
+#endif
 
 END_EVENT_TABLE()
 
+#ifndef NO_VERCHECK
 wxString AboutDlg::s_VersionData = wxEmptyString;
-
-const wstringT AboutDlg::s_URL_HOME      = L"https://pwsafe.org";
 const cstringT AboutDlg::s_URL_VERSION   =  "https://pwsafe.org/latest.xml";
+#else
+const cstringT AboutDlg::s_URL_VERSION   =  "https://pwsafe.org/news.shtml";
+#endif
+
+const wstringT AboutDlg::s_URL_HOME      =  L"https://pwsafe.org";
 
 /*!
  * AboutDlg constructors
@@ -69,7 +75,9 @@
 
   // Print version information on standard output which might be useful for error reports.
   pws_os::Trace(GetLibWxVersion().wc_str());
+#ifndef NO_VERCHECK
   pws_os::Trace(GetLibCurlVersion().wc_str());
+#endif //NO_VERCHECK
 
   SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
   wxDialog::Create( parent, id, caption, pos, size, style );
@@ -146,9 +154,11 @@
   wxStaticText* copyrightStaticText = new wxStaticText(aboutDialog, wxID_STATIC, _("Copyright (c) 2003-2025 Rony Shapiro"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
   rightSizer->Add(copyrightStaticText, 0, wxALIGN_LEFT|wxALL, 5);
 
+#ifndef NO_VERCHECK
   m_VersionStatus = new wxTextCtrl(aboutDialog, ID_TEXTCTRL, wxT("\n\n"), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxNO_BORDER);
   rightSizer->Add(m_VersionStatus, 0, wxALIGN_LEFT|wxALL|wxEXPAND|wxRESERVE_SPACE_EVEN_IF_HIDDEN, 5);
   m_VersionStatus->Hide();
+#endif // NO_VERCHECK
 
   wxButton* closeButton = new wxButton(aboutDialog, wxID_CLOSE, _("&Close"), wxDefaultPosition, wxDefaultSize, 0);
   rightSizer->Add(closeButton, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
@@ -201,7 +211,9 @@
 
 void AboutDlg::OnCloseWindow( wxCloseEvent& WXUNUSED(event) )
 {
+#ifndef NO_VERCHECK
   Cleanup();
+#endif // NO_VERCHECK
   EndModal(wxID_CLOSE);
 }
 
@@ -211,10 +223,13 @@
 
 void AboutDlg::OnCloseClick( wxCommandEvent& WXUNUSED(event) )
 {
+#ifndef NO_VERCHECK
   Cleanup();
+#endif // NO_VERCHECK
   EndModal(wxID_CLOSE);
 }
 
+#ifndef NO_VERCHECK
 /**
  * Returns a <code>wxCriticalSection</code> object that is used to protect
  * the shared data <code>s_VersionData</code>, which is accessed by worker
@@ -379,14 +394,6 @@
 }
 
 /**
- * Provides version information about wxWidgets framework.
- */
-wxString AboutDlg::GetLibWxVersion()
-{
-  return wxString::Format("[wx] Wx Version:\n%s\n", wxGetLibraryVersionInfo().ToString());
-}
-
-/**
  * Checks whether database is closed.
  *
  * If database is open user is prompted to close the database.
@@ -666,6 +673,15 @@
     s_VersionData.Empty();
   }
 }
+#endif // NO_VERCHECK
+
+/**
+ * Provides version information about wxWidgets framework.
+ */
+wxString AboutDlg::GetLibWxVersion()
+{
+  return wxString::Format("[wx] Wx Version:\n%s\n", wxGetLibraryVersionInfo().ToString());
+}
 
 /**
  * wxEVT_HYPERLINK event handler for ID_SITEHYPERLINK
@@ -676,6 +692,19 @@
 
 
 int AboutDlg::ShowAndCheckForUpdate() {
+#ifndef NO_VERCHECK
   CallAfter(&AboutDlg::CheckNewVersion);
+#endif
   return ShowModal();
 }
+
+/**
+ * wxEVT_HYPERLINK event handler for ID_CHECKNEW
+ */
+void AboutDlg::OnCheckNewClicked(wxHyperlinkEvent& WXUNUSED(event)) {
+#ifndef NO_VERCHECK
+  CheckNewVersion();
+#else
+  wxLaunchDefaultBrowser(s_URL_VERSION);
+#endif // NO_VERCHECK
+}
Index: passwordsafe/src/ui/wxWidgets/Makefile
===================================================================
--- passwordsafe.orig/src/ui/wxWidgets/Makefile	2025-04-03 21:21:05.052297440 -0400
+++ passwordsafe/src/ui/wxWidgets/Makefile	2025-04-03 21:21:05.048297395 -0400
@@ -33,6 +33,12 @@
 YBPERS_LIBS=core
 endif
 
+ifndef NO_VERCHECK
+CURL_LDFLAGS=-lcurl -lssl
+else
+CURL_CPPFLAGS=-DNO_VERCHECK
+endif
+
 ifndef NO_QR
 ifeq ($(findstring Linux, $(shell uname -s)), Linux)
 QR_SRC=QRCodeDlg.cpp QREncode.cpp
@@ -59,7 +65,7 @@
 OBJECTPATH=GCCDebug
 BUILDPATHS=$(OBJECTPATH)
 PROGRAM=pwsafe
-LIBS=`$(WX_CONFIG) --debug=yes --unicode=no --libs std,aui` -lcore -los -lcore -luuid -lXtst -lX11  -lcurl -lssl -lmagic -l$(YBPERS_LIBS) ${LIBCXX_LD_EXTRA_FLAGS}
+LIBS=`$(WX_CONFIG) --debug=yes --unicode=no --libs std,aui` -lcore -los -lcore -luuid -lXtst -lX11 $(CURL_LDFLAGS) -lmagic -l$(YBPERS_LIBS) ${LIBCXX_LD_EXTRA_FLAGS}
 LINKERFLAGS=
 WARNINGFLAGS=-Wall
 OPTFLAGS=-O0
@@ -86,7 +92,7 @@
 OBJECTPATH=GCCRelease
 BUILDPATHS=$(OBJECTPATH)
 PROGRAM=pwsafe
-LIBS=`$(WX_CONFIG) --debug=no --unicode=no --inplace --libs std,aui` -lcore -los -lcore -luuid -lXtst -lX11 -lcurl -lssl -lmagic -l$(YBPERS_LIBS)
+LIBS=`$(WX_CONFIG) --debug=no --unicode=no --inplace --libs std,aui` -lcore -los -lcore -luuid -lXtst -lX11 $(CURL_LDFLAGS) -lmagic -l$(YBPERS_LIBS)
 LINKERFLAGS=
 WARNINGFLAGS=-Wall
 OPTFLAGS=-O
@@ -115,7 +121,7 @@
 PROGRAM=pwsafe
 LIBS=`$(WX_CONFIG) --debug=yes --unicode=yes --inplace --libs std,aui` -lcore -los -lcore -l$(YBPERS_LIBS)
 ifneq ($(findstring Darwin, $(shell uname -s)), Darwin)
-		LIBS += -luuid -lXtst -lX11 -lcurl -lssl -lmagic
+		LIBS += -luuid -lXtst -lX11 $(CURL_LDFLAGS) -lmagic
 		XERCESLIBFLAGS=-lxerces-c
 		XERCESCPPFLAGS=-DUSE_XML_LIBRARY=XERCES -DWCHAR_INCOMPATIBLE_XMLCH
 endif
@@ -146,7 +152,7 @@
 PROGRAM=pwsafe
 LIBS=`$(WX_CONFIG) --debug=no --unicode=yes --inplace --libs std,aui` -lcore -los -lcore -l$(YBPERS_LIBS)
 ifneq ($(findstring Darwin, $(shell uname -s)), Darwin)
-		LIBS += -luuid -lXtst -lX11 -lcurl -lssl -lmagic
+		LIBS += -luuid -lXtst -lX11 $(CURL_LDFLAGS) -lmagic
 		XERCESLIBFLAGS=-lxerces-c
 		XERCESCPPFLAGS=-DUSE_XML_LIBRARY=XERCES -DWCHAR_INCOMPATIBLE_XMLCH
 endif
@@ -184,7 +190,7 @@
 		override LIBS += -framework QuartzCore
 endif
 override LDFLAGS:=$(LIBS) -L$(LIBPATH) $(LINKERFLAGS) $(XERCESLIBFLAGS) $(YBPERS_LIBPATH_FLAGS) $(LDFLAGS)
-CPPFLAGS:=$(CXXFLAGS) $(CPPINC) $(GCCFLAGS) $(DEBUGFLAGS) $(OPTFLAGS) $(WARNINGFLAGS) $(XERCESCPPFLAGS) $(YUBIFLAGS) $(QRFLAGS) $(CPPFLAGS)
+CPPFLAGS:=$(CXXFLAGS) $(CPPINC) $(GCCFLAGS) $(DEBUGFLAGS) $(OPTFLAGS) $(WARNINGFLAGS) $(XERCESCPPFLAGS) $(YUBIFLAGS) $(QRFLAGS) $(CURL_CPPFLAGS) $(CPPFLAGS)
 
 SOURCES= PasswordSafeFrame.cpp \
 	PWSafeApp.cpp SafeCombinationEntryDlg.cpp \
Index: passwordsafe/src/ui/wxWidgets/AboutDlg.h
===================================================================
--- passwordsafe.orig/src/ui/wxWidgets/AboutDlg.h	2025-04-03 21:21:05.052297440 -0400
+++ passwordsafe/src/ui/wxWidgets/AboutDlg.h	2025-04-03 21:21:05.048297395 -0400
@@ -20,11 +20,12 @@
 ////@begin includes
 #include <wx/hyperlink.h>
 #include <wx/event.h>
-#include <wx/thread.h>
-////@end includes
 
 #include "os/typedefs.h"
 
+#ifndef NO_VERCHECK
+#include <wx/thread.h>
+
 #ifndef __WINDOWS__
 #define HAS_CURL
 #endif // !__WINDOWS__
@@ -33,6 +34,10 @@
 #include <curl/curl.h>
 #endif // HAS_CURL
 
+#endif // NO_VERCHECK
+////@end includes
+
+
 /*!
  * Forward declarations
  */
@@ -61,19 +66,26 @@
  * AboutDlg class declaration
  */
 
-class AboutDlg : public wxDialog, public wxThreadHelper
+class AboutDlg : public wxDialog
+#ifndef NO_VERCHECK
+              , public wxThreadHelper
+#endif // NO_VERCHECK
 {
   DECLARE_CLASS( AboutDlg )
   DECLARE_EVENT_TABLE()
 
+#ifndef NO_VERCHECK
   void CompareVersionData();
   bool CheckDatabaseStatus();
   bool SetupConnection();
   void Cleanup();
   wxString GetLibCurlVersion();
+#endif // NO_VERCHECK
   wxString GetLibWxVersion();
+#ifndef NO_VERCHECK
   static wxCriticalSection& CriticalSection();
   static size_t WriteCallback(char *receivedData, size_t size, size_t bytes, void *userData);
+#endif // NO_VERCHECK
 
 public:
   /// Creation
@@ -84,7 +96,9 @@
 
   int ShowAndCheckForUpdate();
 protected:
+#ifndef NO_VERCHECK
   virtual wxThread::ExitCode Entry();
+#endif // NO_VERCHECK
 
   /// Constructors
   AboutDlg(wxWindow *parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style );
@@ -92,12 +106,14 @@
   /// Creates the controls and sizers
   void CreateControls();
 
+#ifndef NO_VERCHECK
   void CheckNewVersion();
+#endif // NO_VERCHECK
 
 ////@begin AboutDlg event handler declarations
 
   /// event handler for ID_CHECKNEW
-  void OnCheckNewClicked(wxHyperlinkEvent& WXUNUSED(event)) { CheckNewVersion(); }
+  void OnCheckNewClicked(wxHyperlinkEvent& WXUNUSED(event));
 
   /// event handler for ID_SITEHYPERLINK
   void OnVisitSiteClicked(wxHyperlinkEvent& event);
@@ -108,8 +124,11 @@
   /// wxEVT_CLOSE_WINDOW event handler
   void OnCloseWindow( wxCloseEvent& event );
 
+#ifndef NO_VERCHECK
   /// wxEVT_THREAD event handler for wxID_ANY
   void OnDownloadCompleted(wxThreadEvent& event);
+#endif // NO_VERCHECK
+
 ////@end AboutDlg event handler declarations
 
 ////@begin AboutDlg member function declarations
@@ -126,7 +145,9 @@
 
 private:
 ////@begin AboutDlg member variables
+#ifndef NO_VERCHECK
   wxTextCtrl* m_VersionStatus = nullptr;
+#endif
 ////@end AboutDlg member variables
 
   /// The CURL handle with connection specific options for request of version data
@@ -136,8 +157,10 @@
   void *m_CurlHandle = nullptr;
 #endif // HAS_CURL
 
+#ifndef NO_VERCHECK
   /// Set to downloaded data by worker thread, resp. WriteCallback, and read by main thread for final version check
   static wxString s_VersionData;
+#endif
 
   static const wstringT s_URL_HOME;
   static const cstringT s_URL_VERSION;
