Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions 3rdparty/wx-2015.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
<ClCompile Include="wxWidgets\src\common\bmpbase.cpp" />
<ClCompile Include="wxWidgets\src\common\btncmn.cpp" />
<ClCompile Include="wxWidgets\src\common\checkboxcmn.cpp" />
<ClCompile Include="wxWidgets\src\common\choiccmn.cpp" />
<ClCompile Include="wxWidgets\src\common\clntdata.cpp" />
<ClCompile Include="wxWidgets\src\common\cmdline.cpp" />
<ClCompile Include="wxWidgets\src\common\cmdproc.cpp" />
Expand Down Expand Up @@ -277,6 +278,7 @@
<ClCompile Include="wxWidgets\src\msw\brush.cpp" />
<ClCompile Include="wxWidgets\src\msw\button.cpp" />
<ClCompile Include="wxWidgets\src\msw\checkbox.cpp" />
<ClCompile Include="wxWidgets\src\msw\choice.cpp" />
<ClCompile Include="wxWidgets\src\msw\colour.cpp" />
<ClCompile Include="wxWidgets\src\msw\control.cpp" />
<ClCompile Include="wxWidgets\src\msw\cursor.cpp" />
Expand Down
8 changes: 7 additions & 1 deletion 3rdparty/wx-2015.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -514,5 +514,11 @@
<ClCompile Include="wxWidgets\src\msw\window.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="wxWidgets\src\msw\choice.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="wxWidgets\src\common\choiccmn.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion 3rdparty/wxWidgets_setup_h/wx/setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@
#define wxUSE_CALENDARCTRL 0 // wxCalendarCtrl
#define wxUSE_CHECKBOX 1 // wxCheckBox
#define wxUSE_CHECKLISTBOX 0 // wxCheckListBox (requires wxUSE_OWNER_DRAWN)
#define wxUSE_CHOICE 0 // wxChoice
#define wxUSE_CHOICE 1 // wxChoice
#define wxUSE_COLLPANE 0 // wxCollapsiblePane
#define wxUSE_COLOURPICKERCTRL 0 // wxColourPickerCtrl
#define wxUSE_COMBOBOX 0 // wxComboBox
Expand Down
9 changes: 9 additions & 0 deletions include/winsparkle.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,15 @@ WIN_SPARKLE_API int __cdecl win_sparkle_get_update_check_interval();
*/
WIN_SPARKLE_API time_t __cdecl win_sparkle_get_last_check_time();

/**
Sets the time for the last update check.

@param time Set the time for the last update check.

@since 2.4 - CE-specific version
*/
WIN_SPARKLE_API void __cdecl win_sparkle_set_last_check_time(time_t time);

/// Callback type for win_sparkle_error_callback()
typedef void (__cdecl *win_sparkle_error_callback_t)();

Expand Down
18 changes: 13 additions & 5 deletions src/dll_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,13 @@ WIN_SPARKLE_API int __cdecl win_sparkle_get_automatic_check_for_updates()

WIN_SPARKLE_API void __cdecl win_sparkle_set_update_check_interval(int interval)
{
static const int MIN_CHECK_INTERVAL = 3600; // one hour

try
{
if ( interval < MIN_CHECK_INTERVAL )
// Remove this limitation so QA can easily test
if ( interval < Settings::MIN_CHECK_INTERVAL )
{
winsparkle::LogError("Invalid update interval (min: 3600 seconds)");
interval = MIN_CHECK_INTERVAL;
winsparkle::LogError("Invalid update interval (min: 300 seconds)");
interval = Settings::MIN_CHECK_INTERVAL;
}

Settings::WriteConfigValue("UpdateInterval", interval);
Expand Down Expand Up @@ -261,6 +260,15 @@ WIN_SPARKLE_API time_t __cdecl win_sparkle_get_last_check_time()
return DEFAULT_LAST_CHECK_TIME;
}

WIN_SPARKLE_API void __cdecl win_sparkle_set_last_check_time(time_t lastCheckTime)
{
try
{
Settings::WriteConfigValue("LastCheckTime", lastCheckTime);
}
CATCH_ALL_EXCEPTIONS
}

WIN_SPARKLE_API void __cdecl win_sparkle_set_error_callback(win_sparkle_error_callback_t callback)
{
try
Expand Down
3 changes: 0 additions & 3 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,6 @@ std::string Settings::GetCustomResource(const char *name, const char *type)
std::string Settings::GetDefaultRegistryPath()
{
std::string s("Software\\");
std::wstring vendor = Settings::GetCompanyName();
if ( !vendor.empty() )
s += WideToAnsi(vendor) + "\\";
s += WideToAnsi(Settings::GetAppName());
s += "\\WinSparkle";

Expand Down
2 changes: 2 additions & 0 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ class Settings
// Deletes value from registry.
static void DeleteConfigValue(const char *name);

static const int MIN_CHECK_INTERVAL = 300; // 5 minutes

//@}

private:
Expand Down
138 changes: 66 additions & 72 deletions src/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <wx/intl.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/choice.h>
#include <wx/filename.h>
#include <wx/gauge.h>
#include <wx/statbmp.h>
Expand All @@ -69,6 +70,11 @@
#define ERROR_RESOURCE_ENUM_USER_STOP 15106
#endif

const int DOWNLOAD_NOW = 0;
const int REMIND_ONE_HOUR = 1;
const int REMIND_ONE_DAY = 2;
const int REMIND_ONE_WEEK = 3;

namespace winsparkle
{

Expand Down Expand Up @@ -329,8 +335,6 @@ WinSparkleDialog::WinSparkleDialog()
wxSize dpi = wxClientDC(this).GetPPI();
m_scaleFactor = dpi.y / 96.0;

SetIcon(LoadNamedIcon(UI::GetDllHINSTANCE(), L"UpdateAvailable", GetSystemMetrics(SM_CXSMICON)));

wxSizer *topSizer = new wxBoxSizer(wxHORIZONTAL);

// Load the dialog box icon: the first 48x48 application icon will be loaded, if available,
Expand Down Expand Up @@ -392,7 +396,6 @@ void WinSparkleDialog::SetHeadingFont(wxWindow *win)
// 9pt is base font, 12pt is for "Main instructions". See
// http://msdn.microsoft.com/en-us/library/aa511282%28v=MSDN.10%29.aspx
f.SetPointSize(f.GetPointSize() + 3);
win->SetForegroundColour(wxColour(0x00, 0x33, 0x99));
}
else // Windows XP/2000
{
Expand All @@ -408,9 +411,8 @@ void WinSparkleDialog::SetHeadingFont(wxWindow *win)
Window for communicating with the user
*--------------------------------------------------------------------------*/

const int ID_SKIP_VERSION = wxNewId();
const int ID_REMIND_LATER = wxNewId();
const int ID_INSTALL = wxNewId();
const int ID_REMIND_OPTIONS = wxNewId();
const int ID_DOWNLOAD = wxNewId();
const int ID_RUN_INSTALLER = wxNewId();

class UpdateDialog : public WinSparkleDialog
Expand Down Expand Up @@ -439,9 +441,7 @@ class UpdateDialog : public WinSparkleDialog
void OnCloseButton(wxCommandEvent& event);
void OnClose(wxCloseEvent& event);

void OnSkipVersion(wxCommandEvent&);
void OnRemindLater(wxCommandEvent&);
void OnInstall(wxCommandEvent&);
void OnDownload(wxCommandEvent&);

void OnRunInstaller(wxCommandEvent&);

Expand All @@ -465,6 +465,7 @@ class UpdateDialog : public WinSparkleDialog
wxSizer *m_updateButtonsSizer;
wxSizer *m_releaseNotesSizer;
wxPanel *m_browserParent;
wxChoice *m_remindChoiceList;

wxAutoOleInterface<IWebBrowser2> m_webBrowser;

Expand All @@ -474,7 +475,7 @@ class UpdateDialog : public WinSparkleDialog
wxString m_updateFile;
// space separated arguments to update file (only valid after StateUpdateDownloaded)
std::string m_installerArguments;
// downloader (only valid between OnInstall and OnUpdateDownloaded)
// downloader (only valid between OnDownload and OnUpdateDownloaded)
UpdateDownloader* m_downloader;
// whether the update should be installed without prompting the user
bool m_installAutomatically;
Expand Down Expand Up @@ -533,21 +534,16 @@ UpdateDialog::UpdateDialog()

m_buttonSizer = new wxBoxSizer(wxHORIZONTAL);

const wxString REMIND_OPTIONS[] = { L"Download now", L"Remind me in an hour", L"Remind me tomorrow", L"Remind me in a week" };
m_remindChoiceList = new wxChoice(this, ID_REMIND_OPTIONS, wxDefaultPosition, wxDefaultSize, sizeof(REMIND_OPTIONS)/sizeof(REMIND_OPTIONS[0]), REMIND_OPTIONS);
m_remindChoiceList->SetSelection(DOWNLOAD_NOW);

m_updateButtonsSizer = new wxBoxSizer(wxHORIZONTAL);
m_updateButtonsSizer->Add
(
new wxButton(this, ID_SKIP_VERSION, _("Skip this version")),
wxSizerFlags().Border(wxRIGHT, PX(20))
);
m_updateButtonsSizer->AddStretchSpacer(1);
m_updateButtonsSizer->Add(m_remindChoiceList, wxSizerFlags().Border(wxRIGHT, PX(20)));
m_updateButtonsSizer->Add
(
new wxButton(this, ID_REMIND_LATER, _("Remind me later")),
wxSizerFlags().Border(wxRIGHT, PX(10))
);
m_updateButtonsSizer->Add
(
m_installButton = new wxButton(this, ID_INSTALL, _("Install update")),
m_installButton = new wxButton(this, ID_DOWNLOAD, _("OK")),
wxSizerFlags()
);
m_buttonSizer->Add(m_updateButtonsSizer, wxSizerFlags(1));
Expand Down Expand Up @@ -576,9 +572,7 @@ UpdateDialog::UpdateDialog()
Bind(wxEVT_CLOSE_WINDOW, &UpdateDialog::OnClose, this);
Bind(wxEVT_TIMER, &UpdateDialog::OnTimer, this);
Bind(wxEVT_COMMAND_BUTTON_CLICKED, &UpdateDialog::OnCloseButton, this, wxID_CANCEL);
Bind(wxEVT_COMMAND_BUTTON_CLICKED, &UpdateDialog::OnSkipVersion, this, ID_SKIP_VERSION);
Bind(wxEVT_COMMAND_BUTTON_CLICKED, &UpdateDialog::OnRemindLater, this, ID_REMIND_LATER);
Bind(wxEVT_COMMAND_BUTTON_CLICKED, &UpdateDialog::OnInstall, this, ID_INSTALL);
Bind(wxEVT_COMMAND_BUTTON_CLICKED, &UpdateDialog::OnDownload, this, ID_DOWNLOAD);
Bind(wxEVT_COMMAND_BUTTON_CLICKED, &UpdateDialog::OnRunInstaller, this, ID_RUN_INSTALLER);
}

Expand Down Expand Up @@ -633,36 +627,47 @@ void UpdateDialog::OnClose(wxCloseEvent&)
}


void UpdateDialog::OnSkipVersion(wxCommandEvent&)
void UpdateDialog::OnDownload(wxCommandEvent&)
{
Settings::WriteConfigValue("SkipThisVersion", m_appcast.Version);
Close();
}

static const int ONE_HOUR_IN_SECONDS = 3600;
static const int ONE_DAY_IN_SECONDS = 86400;
static const int ONE_WEEK_IN_SECONDS = 604800;
int currentSelection = m_remindChoiceList->GetCurrentSelection();

void UpdateDialog::OnRemindLater(wxCommandEvent&)
{
// Just abort the update. Next time it's scheduled to run,
// the user will be prompted.
Close();
}


void UpdateDialog::OnInstall(wxCommandEvent&)
{
if ( !m_appcast.HasDownload() )
{
wxLaunchDefaultBrowser(m_appcast.WebBrowserURL, wxBROWSER_NEW_WINDOW);
Close();
}
else if ( m_downloader == NULL )
int updateInterval = ONE_DAY_IN_SECONDS;
switch (currentSelection)
{
StateDownloading();
case DOWNLOAD_NOW:
if (!m_appcast.HasDownload())
{
wxLaunchDefaultBrowser(m_appcast.WebBrowserURL, wxBROWSER_NEW_WINDOW);
Close();
}
else if (m_downloader == NULL)
{
StateDownloading();

// Run the download in background.
m_downloader = new UpdateDownloader(m_appcast);
m_downloader->Start();
// Run the download in background.
m_downloader = new UpdateDownloader(m_appcast);
m_downloader->Start();
}
return;
case REMIND_ONE_HOUR:
updateInterval = ONE_HOUR_IN_SECONDS;
break;
case REMIND_ONE_DAY:
updateInterval = ONE_DAY_IN_SECONDS;
break;
case REMIND_ONE_WEEK:
updateInterval = ONE_WEEK_IN_SECONDS;
break;
default:
updateInterval = ONE_DAY_IN_SECONDS;
break;
}

Settings::WriteConfigValue("UpdateInterval", updateInterval);
Close();
}

void UpdateDialog::OnRunInstaller(wxCommandEvent&)
Expand Down Expand Up @@ -757,27 +762,12 @@ void UpdateDialog::StateNoUpdateFound(bool installAutomatically)

LayoutChangesGuard guard(this);

m_heading->SetLabel(_("You're up to date!"));

wxString msg;
try
{
msg = wxString::Format
(
_("%s %s is currently the newest version available."),
Settings::GetAppName(),
Settings::GetAppVersion()
);
}
catch ( std::exception& )
{
// GetAppVersion() may fail
msg = "Error: Updates checking not properly configured.";
}
m_heading->SetLabel(_("You are up to date!"));

wxString msg = _("There are no new versions available at this time.");
SetMessage(msg);

m_closeButton->SetLabel(_("Close"));
m_closeButton->SetLabel(_("OK"));
m_closeButton->SetDefault();
EnablePulsing(false);

Expand Down Expand Up @@ -812,7 +802,7 @@ void UpdateDialog::StateUpdateError(ErrorCode err)
}
SetMessage(msg);

m_closeButton->SetLabel(_("Cancel"));
m_closeButton->SetLabel(_("OK"));
m_closeButton->SetDefault();
EnablePulsing(false);

Expand All @@ -836,7 +826,7 @@ void UpdateDialog::StateUpdateAvailable(const Appcast& info, bool installAutomat
if ( installAutomatically )
{
wxCommandEvent nullEvent;
OnInstall(nullEvent);
OnDownload(nullEvent);
return;
}

Expand Down Expand Up @@ -867,8 +857,8 @@ void UpdateDialog::StateUpdateAvailable(const Appcast& info, bool installAutomat
(
wxString::Format
(
_("%s %s is now available (you have %s). Would you like to download it now?"),
appname, ver_new, ver_my
_("You are currently using %s version %s.\nWould you like to download our new version (%s) now?"),
appname, ver_my, ver_new
),
showRelnotes ? RELNOTES_WIDTH : MESSAGE_AREA_WIDTH
);
Expand Down Expand Up @@ -1030,10 +1020,14 @@ void UpdateDialog::ShowReleaseNotes(const Appcast& info)

if( !info.ReleaseNotesURL.empty() )
{
VARIANT varFlags;
varFlags.vt = VT_I4;
varFlags.llVal = (navNoHistory | navNoReadFromCache | navNoWriteToCache);

m_webBrowser->Navigate
(
wxBasicString(info.ReleaseNotesURL),
NULL, // Flags
&varFlags, // Flags
NULL, // TargetFrameName
NULL, // PostData
NULL // Headers
Expand Down
Loading