Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add update closed event #272

Closed
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
17 changes: 17 additions & 0 deletions include/winsparkle.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,23 @@ typedef void (__cdecl *win_sparkle_update_cancelled_callback_t)();
*/
WIN_SPARKLE_API void __cdecl win_sparkle_set_update_cancelled_callback(win_sparkle_update_cancelled_callback_t callback);

/// Callback type for win_sparkle_update_closed_callback_t()
typedef void(__cdecl *win_sparkle_update_closed_callback_t)();

/**
Set callback to be called when the download dialog is closed
even by the user or at the end of the process.

This is useful in combination with
win_sparkle_check_update_with_ui_and_install() as it allows you to perform
some action when the update download process end (by user action or installation starts).

@since 8.2

@see win_sparkle_check_update_with_ui_and_install()
*/
WIN_SPARKLE_API void __cdecl win_sparkle_set_update_closed_callback(win_sparkle_update_closed_callback_t callback);

/// Callback type for win_sparkle_update_skipped_callback()
typedef void(__cdecl* win_sparkle_update_skipped_callback_t)();

Expand Down
12 changes: 12 additions & 0 deletions src/appcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ win_sparkle_shutdown_request_callback_t ApplicationController::ms_cbRequestSh
win_sparkle_did_find_update_callback_t ApplicationController::ms_cbDidFindUpdate = NULL;
win_sparkle_did_not_find_update_callback_t ApplicationController::ms_cbDidNotFindUpdate = NULL;
win_sparkle_update_cancelled_callback_t ApplicationController::ms_cbUpdateCancelled = NULL;
win_sparkle_update_closed_callback_t ApplicationController::ms_cbUpdateClosed = NULL;
win_sparkle_update_skipped_callback_t ApplicationController::ms_cbUpdateSkipped = NULL;
win_sparkle_update_postponed_callback_t ApplicationController::ms_cbUpdatePostponed = NULL;
win_sparkle_update_dismissed_callback_t ApplicationController::ms_cbUpdateDismissed = NULL;
Expand Down Expand Up @@ -119,6 +120,17 @@ void ApplicationController::NotifyUpdateCancelled()
}
}

void ApplicationController::NotifyUpdateClosed() {
{
CriticalSectionLocker lock(ms_csVars);
if (ms_cbUpdateClosed)
{
(*ms_cbUpdateClosed)();
return;
}
}
}

void ApplicationController::NotifyUpdateSkipped()
{
{
Expand Down
11 changes: 11 additions & 0 deletions src/appcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ class ApplicationController
/// Notify that an update was cancelled.
static void NotifyUpdateCancelled();

/// Notify that an update was close.
static void NotifyUpdateClosed();

/// Notify that an update was skipped
static void NotifyUpdateSkipped();

Expand Down Expand Up @@ -130,6 +133,13 @@ class ApplicationController
ms_cbUpdateCancelled = callback;
}

/// Set the win_sparkle_update_closed_callback_t function
static void SetUpdateClosedCallback(win_sparkle_update_closed_callback_t callback)
{
CriticalSectionLocker lock(ms_csVars);
ms_cbUpdateClosed = callback;
}

/// Set the win_sparkle_update_skipped_callback_t function
static void SetUpdateSkippedCallback(win_sparkle_update_skipped_callback_t callback)
{
Expand Down Expand Up @@ -171,6 +181,7 @@ class ApplicationController
static win_sparkle_did_find_update_callback_t ms_cbDidFindUpdate;
static win_sparkle_did_not_find_update_callback_t ms_cbDidNotFindUpdate;
static win_sparkle_update_cancelled_callback_t ms_cbUpdateCancelled;
static win_sparkle_update_closed_callback_t ms_cbUpdateClosed;
static win_sparkle_update_skipped_callback_t ms_cbUpdateSkipped;
static win_sparkle_update_postponed_callback_t ms_cbUpdatePostponed;
static win_sparkle_update_dismissed_callback_t ms_cbUpdateDismissed;
Expand Down
9 changes: 9 additions & 0 deletions src/dll_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,15 @@ WIN_SPARKLE_API void __cdecl win_sparkle_set_update_cancelled_callback(win_spark
CATCH_ALL_EXCEPTIONS
}

WIN_SPARKLE_API void __cdecl win_sparkle_set_update_closed_callback(win_sparkle_update_closed_callback_t callback)
{
try
{
ApplicationController::SetUpdateClosedCallback(callback);
}
CATCH_ALL_EXCEPTIONS
}

WIN_SPARKLE_API void __cdecl win_sparkle_set_update_skipped_callback(win_sparkle_update_skipped_callback_t callback)
{
try
Expand Down
2 changes: 2 additions & 0 deletions src/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@ void UpdateDialog::OnClose(wxCloseEvent&)
// window-close event wasn't initiated by the user.
if ( m_appcast.IsValid() && m_updateFile.IsEmpty() && !m_errorOccurred )
ApplicationController::NotifyUpdateCancelled();

ApplicationController::NotifyUpdateClosed();
}


Expand Down
Loading