Skip to content

Commit

Permalink
Disabled check for updates if poEdit is part of the JAWS localization…
Browse files Browse the repository at this point in the history
… kit.

Freedom Scientific has requested that the check for updates feature be
disabled for the build that is part of the JAWS localization kit.
  • Loading branch information
BenKeyFSI committed Mar 7, 2016
1 parent 6ddbd1a commit 75052df
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 17 deletions.
71 changes: 54 additions & 17 deletions src/edapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <wx/intl.h>
#include <wx/ipc.h>
#include <wx/translation.h>
#include <wx/filefn.h>

#ifdef __WXOSX__
#include "osx_helpers.h"
Expand Down Expand Up @@ -307,6 +308,39 @@ bool PoeditApp::CheckForBetaUpdates() const
wxConfigBase::Get()->ReadBool("check_for_beta_updates", false);
}

bool PoeditApp::IsFSVersion() const
{
wxString v = GetAppVersion();
return v.Contains("FS") || v.Contains("fs");
}

bool PoeditApp::EnableCheckForUpdates() const
{
if (!IsFSVersion())
{
return true;
}
#if defined(__WXMSW__)
/* Freedom Scientific has requested that the check for updates be disabled for the build that is
part of the localization kit. */
auto exe = wxStandardPaths::Get().GetExecutablePath();
wxString t;
wxFileName::SplitPath(exe, &t, nullptr, nullptr);
auto fn = wxFileName::DirName(t);
if (fn.GetDirCount() > 2)
{
fn.RemoveLastDir();
fn.RemoveLastDir();
t = fn.GetFullPath();
wxFileName buildLockit(t, "BuildLockit.exe");
if (buildLockit.Exists())
{
return false;
}
}
#endif
return true;
}

static wxArrayString gs_filesToOpen;

Expand Down Expand Up @@ -480,28 +514,31 @@ bool PoeditApp::OnInit()
}
#endif // !__WXOSX__

if (EnableCheckForUpdates())
{
#ifdef USE_SPARKLE
Sparkle_Initialize(CheckForBetaUpdates());
Sparkle_Initialize(CheckForBetaUpdates());
#endif // USE_SPARKLE

#ifdef __WXMSW__
wxString appcast = "https://poedit.net/updates/win/appcast";
if ( CheckForBetaUpdates() )
{
// Beta versions use unstable feed.
appcast = "https://poedit.net/updates/win/appcast/beta";
}
if (!wxPlatformInfo().CheckOSVersion(6,0)) // XP doesn't support SNI
appcast.Replace("https://", "http://");

win_sparkle_set_appcast_url(appcast.utf8_str());
win_sparkle_set_can_shutdown_callback(&PoeditApp::WinSparkle_CanShutdown);
win_sparkle_set_shutdown_request_callback(&PoeditApp::WinSparkle_Shutdown);
auto buildnum = GetAppBuildNumber();
if (!buildnum.empty())
win_sparkle_set_app_build_version(buildnum.wc_str());
win_sparkle_init();
wxString appcast = "https://poedit.net/updates/win/appcast";
if ( CheckForBetaUpdates() )
{
// Beta versions use unstable feed.
appcast = "https://poedit.net/updates/win/appcast/beta";
}
if (!wxPlatformInfo().CheckOSVersion(6,0)) // XP doesn't support SNI
appcast.Replace("https://", "http://");

win_sparkle_set_appcast_url(appcast.utf8_str());
win_sparkle_set_can_shutdown_callback(&PoeditApp::WinSparkle_CanShutdown);
win_sparkle_set_shutdown_request_callback(&PoeditApp::WinSparkle_Shutdown);
auto buildnum = GetAppBuildNumber();
if (!buildnum.empty())
win_sparkle_set_app_build_version(buildnum.wc_str());
win_sparkle_init();
#endif
}

#ifndef __WXOSX__
// If we failed to open any window during startup (e.g. because the user
Expand Down
2 changes: 2 additions & 0 deletions src/edapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class PoeditApp : public wxApp
wxString GetAppBuildNumber() const;
bool IsBetaVersion() const;
bool CheckForBetaUpdates() const;
bool IsFSVersion() const;
bool EnableCheckForUpdates() const;

// opens files in new frame
void OpenFiles(const wxArrayString& filenames);
Expand Down

0 comments on commit 75052df

Please sign in to comment.