/* * Copyright (c) 2022 Winsider Seminars & Solutions, Inc. All rights reserved. * * This file is part of System Informer. * * Authors: * * dmex 2016-2026 * */ #include "updater.h" /** * \brief Callback procedure for the Download Progress task dialog page. * \param WindowHandle Handle to the dialog window. * \param WindowMessage The window message. * \param wParam Additional message-specific information. * \param lParam Additional message-specific information. * \param dwRefData The updater context. * \return HRESULT Successful or errant status. */ HRESULT CALLBACK ShowProgressCallbackProc( _In_ HWND WindowHandle, _In_ UINT WindowMessage, _In_ WPARAM wParam, _In_ LPARAM lParam, _In_ LONG_PTR dwRefData ) { PPH_UPDATER_CONTEXT context = (PPH_UPDATER_CONTEXT)dwRefData; switch (WindowMessage) { case TDN_NAVIGATED: { SendMessage(WindowHandle, TDM_SET_MARQUEE_PROGRESS_BAR, TRUE, 0); SendMessage(WindowHandle, TDM_SET_PROGRESS_BAR_MARQUEE, TRUE, 1); context->ProgressMarquee = TRUE; #ifndef FORCE_NO_STATUS_TIMER if (!context->ProgressTimer) { PhSetTimer(WindowHandle, 9000, SETTING_NAME_STATUS_TIMER_INTERVAL, NULL); context->ProgressTimer = TRUE; } #endif PhReferenceObject(context); #if defined(PH_BUILD_MSIX) PhCreateThread2(UpdateMsixDownloadThread, context); #else PhCreateThread2(UpdateInstallerDownloadThreadStage1, context); #endif } break; case TDN_HYPERLINK_CLICKED: { TaskDialogLinkClicked(context); return S_FALSE; } break; } return S_OK; } /** * \brief Shows the Download Progress dialog page. * \param Context The updater context. */ VOID ShowProgressDialog( _In_ PPH_UPDATER_CONTEXT Context ) { TASKDIALOGCONFIG config; memset(&config, 0, sizeof(TASKDIALOGCONFIG)); config.cbSize = sizeof(TASKDIALOGCONFIG); config.dwFlags = TDF_USE_HICON_MAIN | TDF_ALLOW_DIALOG_CANCELLATION | TDF_CAN_BE_MINIMIZED | TDF_ENABLE_HYPERLINKS | TDF_SHOW_PROGRESS_BAR; config.dwCommonButtons = TDCBF_CANCEL_BUTTON; config.hMainIcon = PhGetApplicationIcon(FALSE, Context->WindowDpi); config.cxWidth = 200; config.lpCallbackData = (LONG_PTR)Context; config.pfCallback = ShowProgressCallbackProc; config.pszWindowTitle = L"System Informer - Updater"; if (Context->SwitchingChannel) { PCWSTR channelName; switch (Context->Channel) { case PhReleaseChannel: channelName = L" release"; break; //case PhPreviewChannel: // channelName = L" release"; // break; case PhCanaryChannel: channelName = L" canary"; break; //case PhDeveloperChannel: // channelName = L" developer"; // break; default: channelName = L""; break; } config.pszMainInstruction = PhaFormatString(L"Downloading%s channel %s...", channelName, PhGetStringOrEmpty(Context->Version))->Buffer; } else { config.pszMainInstruction = PhaFormatString(L"Downloading update %s...", PhGetStringOrEmpty(Context->Version))->Buffer; } config.pszContent = L"Downloaded: ~ of ~ (0%)\r\nSpeed: ~ KB/s"; PhTaskDialogNavigatePage(Context->DialogHandle, &config); }