### Install CMake Configuration Files Source: https://github.com/vslavik/winsparkle/blob/master/cmake/CMakeLists.txt This CMake script installs the generated configuration files, including the main configuration file and the version configuration file, to the specified installation directory. ```cmake install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake DESTINATION "${CONFIG_INSTALL_DIR}") ``` -------------------------------- ### Implement Custom Installer Execution Source: https://context7.com/vslavik/winsparkle/llms.txt Overrides the default installer handling with custom logic. This allows developers to handle specific file types like MSI with custom command-line arguments. ```c #include "winsparkle.h" int __cdecl CustomInstallerCallback(const wchar_t* installerPath) { if (wcsstr(installerPath, L".msi") != NULL) { wchar_t cmdLine[MAX_PATH * 2]; swprintf(cmdLine, MAX_PATH * 2, L"msiexec /i \"%s\" /qb TARGETDIR=\"C:\\MyApp\"", installerPath); _wsystem(cmdLine); return 1; } return 0; } void ConfigureCustomInstaller() { win_sparkle_set_user_run_installer_callback(CustomInstallerCallback); win_sparkle_init(); } ``` -------------------------------- ### Custom Installer Callback Source: https://context7.com/vslavik/winsparkle/llms.txt Sets a callback to handle the downloaded update file with custom logic instead of WinSparkle's default handling. ```APIDOC ## win_sparkle_set_user_run_installer_callback ### Description Allows you to provide a custom function to handle the execution of the downloaded installer. This is useful for scenarios where you need to pass specific arguments to the installer or perform additional actions. ### Method `win_sparkle_set_user_run_installer_callback(callback)` ### Parameters - `callback` (function pointer) - A function that takes the installer path as input and returns an integer indicating how the file was handled. - Returns `1` if the installer was handled by the callback. - Returns `0` to let WinSparkle handle the installer using its default logic. - Returns `WINSPARKLE_RETURN_ERROR` on error. ### Request Example ```c int __cdecl CustomInstallerCallback(const wchar_t* installerPath) { if (wcsstr(installerPath, L".msi") != NULL) { wchar_t cmdLine[MAX_PATH * 2]; swprintf(cmdLine, MAX_PATH * 2, L"msiexec /i \"%s\" /qb TARGETDIR=\"C:\\MyApp\"", installerPath); _wsystem(cmdLine); return 1; // We handled it } return 0; // Let WinSparkle handle it } win_sparkle_set_user_run_installer_callback(CustomInstallerCallback); ``` ### Response N/A ### Error Handling N/A ``` -------------------------------- ### winsparkle-tool CLI Reference Source: https://context7.com/vslavik/winsparkle/llms.txt Command-line utility for managing EdDSA keys and signing installer files for secure distribution. ```APIDOC ## winsparkle-tool CLI ### Description A command-line tool used to generate EdDSA key pairs and sign binary installers to ensure update integrity. ### Commands - **generate-key**: Creates a new private key file and outputs the public key for the resource file. - **sign**: Signs an installer file using a private key and generates the required `sparkle:edSignature` attribute. ### Example Usage ```bash # Generate keys winsparkle-tool generate-key --file private.key # Sign an installer winsparkle-tool sign --private-key-file private.key MyApp-Setup.exe ``` ``` -------------------------------- ### Initialize and Start WinSparkle Source: https://context7.com/vslavik/winsparkle/llms.txt Initializes the WinSparkle library to begin automatic update checks. This should be called after the main application window is visible to ensure the update UI displays correctly. ```c #include "winsparkle.h" int main(int argc, char *argv[]) { ShowWindow(hwndMain, nCmdShow); win_sparkle_set_appcast_url("https://example.com/appcast.xml"); win_sparkle_set_eddsa_public_key("pXAx0wfi8kGbeQln11+V4R3tCepSuLXeo7LkOeudc/U="); win_sparkle_init(); MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0; } ``` -------------------------------- ### Install CMake Export Targets Source: https://github.com/vslavik/winsparkle/blob/master/cmake/CMakeLists.txt This CMake command installs the export targets for the project. It creates a file that allows other CMake projects to find and link against this project's targets. ```cmake install(EXPORT ${PROJECT_NAME}-export DESTINATION "${CONFIG_INSTALL_DIR}" FILE ${PROJECT_NAME}Targets.cmake) ``` -------------------------------- ### Manual Update Check and Install Source: https://context7.com/vslavik/winsparkle/llms.txt Checks for updates and automatically installs the latest version if available, bypassing the usual update prompt dialog. This is useful for enforcing the use of the latest version. ```APIDOC ## win_sparkle_check_update_with_ui_and_install ### Description Checks for updates and immediately installs if one is available, skipping the update prompt dialog. ### Method `void win_sparkle_check_update_with_ui_and_install()` ### Endpoint N/A (This is a library function) ### Parameters None ### Request Example ```c #include "winsparkle.h" void ForceUpdateCheck() { // Check and auto-install any available update // Skips the "update available" prompt dialog // Useful when users must always use latest version win_sparkle_check_update_with_ui_and_install(); } ``` ### Response N/A (This is a void function) #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Manage Updates with winsparkle-tool Source: https://context7.com/vslavik/winsparkle/llms.txt Commands for generating EdDSA key pairs and signing installer files. These tools ensure secure update verification for WinSparkle clients. ```bash # Generate a new EdDSA key pair winsparkle-tool generate-key --file private.key # Sign an update file winsparkle-tool sign --private-key-file private.key MyApp-Setup.exe # Sign with verbose output (includes file length) winsparkle-tool sign --verbose --private-key-file private.key MyApp-Setup.exe # Show help winsparkle-tool --help ``` -------------------------------- ### CMake Build Configuration for Qt with WinSparkle Source: https://github.com/vslavik/winsparkle/blob/master/cmake/qt-example/CMakeLists.txt This CMake script sets up the build environment for a Qt application. It ensures the correct build type is set, finds and includes WinSparkle and Qt5 libraries, defines source and header files, and configures the executable target with necessary link libraries. It's designed for a specific project structure where example sources are located in a subdirectory. ```cmake if(NOT DEFINED CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") endif() project(QtExampleApp) cmake_minimum_required(VERSION 2.8.12) find_package(WinSparkle REQUIRED) find_package(Qt5Core REQUIRED) find_package(Qt5Gui REQUIRED) find_package(Qt5Widgets REQUIRED) include_directories(${Qt5Core_INCLUDE_DIRS}) include_directories(${Qt5Gui_INCLUDE_DIRS}) include_directories(${Qt5Widgets_INCLUDE_DIRS}) add_definitions(${Qt5Core_DEFINITIONS}) add_definitions(${Qt5Gui_DEFINITIONS}) add_definitions(${Qt5Widgets_DEFINITIONS}) get_filename_component(ROOT_DIR ${CMAKE_SOURCE_DIR}/../.. REALPATH) set(SOURCE_DIR ${ROOT_DIR}/examples/qt) include_directories(${SOURCE_DIR} ${CMAKE_BINARY_DIR}) set(SOURCES ${SOURCE_DIR}/main.cpp ${SOURCE_DIR}/mainwindow.cpp) set(HEADERS ${SOURCE_DIR}/mainwindow.h) set(FORMS ${SOURCE_DIR}/mainwindow.ui) qt5_wrap_cpp(MOC_SOURCES ${HEADERS}) qt5_wrap_ui(UI_SOURCES ${FORMS}) add_executable(${PROJECT_NAME} WIN32 ${SOURCES} ${MOC_SOURCES} ${UI_SOURCES}) target_link_libraries(${PROJECT_NAME} WinSparkle Qt5::Core Qt5::Gui Qt5::Widgets) ``` -------------------------------- ### Configure WinSparkle Shutdown Callback Source: https://context7.com/vslavik/winsparkle/llms.txt Sets a callback function to gracefully terminate the application when an update is ready to be installed. This function is typically triggered from a background thread. ```c #include "winsparkle.h" extern HWND g_hwndMain; void __cdecl ShutdownRequestCallback() { PostMessage(g_hwndMain, WM_CLOSE, 0, 0); } void ConfigureShutdownCallback() { win_sparkle_set_can_shutdown_callback(CanShutdownCallback); win_sparkle_set_shutdown_request_callback(ShutdownRequestCallback); win_sparkle_init(); } ``` -------------------------------- ### Configure Application Shutdown Callback Source: https://context7.com/vslavik/winsparkle/llms.txt Sets a callback function that WinSparkle will invoke to determine if the application can safely shut down before proceeding with an update installation. The callback should return TRUE if shutdown is safe, and FALSE otherwise. ```c #include "winsparkle.h" // Callback: return TRUE if app can shut down, FALSE otherwise int __cdecl CanShutdownCallback() { // Check for unsaved documents, pending operations, etc. if (HasUnsavedDocuments()) { return FALSE; // Cannot shut down now } return TRUE; // OK to shut down } void ConfigureShutdownCallback() { win_sparkle_set_can_shutdown_callback(CanShutdownCallback); win_sparkle_init(); } ``` -------------------------------- ### Shutdown Request Callback Source: https://context7.com/vslavik/winsparkle/llms.txt Sets a callback to gracefully terminate the application when an update is ready to install. ```APIDOC ## win_sparkle_set_shutdown_request_callback ### Description Sets a callback function that will be invoked when WinSparkle requests the application to shut down to install an update. ### Method `win_sparkle_set_shutdown_request_callback` ### Parameters - `callback` (function pointer) - The function to call when a shutdown is requested. ### Request Example ```c void __cdecl ShutdownRequestCallback() { // Gracefully close the application PostMessage(g_hwndMain, WM_CLOSE, 0, 0); } win_sparkle_set_shutdown_request_callback(ShutdownRequestCallback); ``` ### Response N/A (This is a configuration function) ### Error Handling N/A ``` -------------------------------- ### Check for Updates and Auto-Install Source: https://context7.com/vslavik/winsparkle/llms.txt Checks for available updates and automatically installs the latest version without prompting the user. This is useful for enforcing the use of the latest software version. It bypasses the standard update available dialog. ```c #include "winsparkle.h" void ForceUpdateCheck() { // Check and auto-install any available update // Skips the "update available" prompt dialog // Useful when users must always use latest version win_sparkle_check_update_with_ui_and_install(); } ``` -------------------------------- ### Shutdown Callback Configuration Source: https://context7.com/vslavik/winsparkle/llms.txt Sets a callback function that WinSparkle will invoke to determine if the application can safely shut down before proceeding with an update installation. ```APIDOC ## win_sparkle_set_can_shutdown_callback ### Description Sets a callback to query whether the application can safely shut down before installing an update. ### Method `void win_sparkle_set_can_shutdown_callback(WinSparkleCanShutdownCallback callback)` ### Endpoint N/A (This is a library function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c #include "winsparkle.h" // Callback: return TRUE if app can shut down, FALSE otherwise int __cdecl CanShutdownCallback() { // Check for unsaved documents, pending operations, etc. if (HasUnsavedDocuments()) { return FALSE; // Cannot shut down now } return TRUE; // OK to shut down } void ConfigureShutdownCallback() { win_sparkle_set_can_shutdown_callback(CanShutdownCallback); win_sparkle_init(); } ``` ### Response N/A (This is a void function) #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Configure Package Configuration File with CMake Source: https://github.com/vslavik/winsparkle/blob/master/cmake/CMakeLists.txt This snippet configures the package configuration file for the project using CMake's `configure_package_config_file` function. It takes an input template file and generates a CMake configuration file, specifying installation destinations and path variables. ```cmake include(CMakePackageConfigHelpers) configure_package_config_file( ${PROJECT_NAME}Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" INSTALL_DESTINATION "${CONFIG_INSTALL_DIR}" PATH_VARS BIN_INSTALL_DIR LIB_INSTALL_DIR INCLUDE_INSTALL_DIR) ``` -------------------------------- ### Define WinSparkle Appcast Feed Source: https://context7.com/vslavik/winsparkle/llms.txt An example of an RSS 2.0 feed structure using Sparkle extensions. It includes item definitions for different Windows architectures and system version requirements. ```xml My Application Updates Most recent updates for My Application en Version 2.1.0 2.1.0 2.1 https://myapp.example.com/releases/2.1.0/notes.html Mon, 15 Jan 2024 12:00:00 +0000 10.0 ``` -------------------------------- ### Using Windows Resources for Configuration Source: https://context7.com/vslavik/winsparkle/llms.txt Demonstrates how to configure WinSparkle using Windows resource files (.rc) instead of API calls. ```APIDOC ## Using Windows Resources ### Description WinSparkle can read certain configuration parameters, such as the appcast URL and EdDSA public key, directly from the application's Windows resource file (.rc). This simplifies configuration by centralizing it within the project's resources. ### Method Define specific resource types within your `.rc` file. ### Parameters - `FeedURL` (APPCAST): Specifies the URL of the application's appcast feed. - `EdDSAPub` (EDDSA): Provides the EdDSA public key for signature verification of the appcast. - `appicon` (ICON): Defines the application's icon, which may be used in the WinSparkle UI. - `VERSIONINFO`: Standard Windows version information, including `FILEVERSION` and `PRODUCTVERSION`, which WinSparkle may use. ### Request Example ```rc // app.rc - Windows resource file #include // Appcast URL as resource FeedURL APPCAST {"https://myapp.example.com/appcast.xml"} // EdDSA public key as resource EdDSAPub EDDSA {"pXAx0wfi8kGbeQln11+V4R3tCepSuLXeo7LkOeudc/U="} // Application icon (used in WinSparkle UI) appicon ICON "myapp.ico" // Version information used by WinSparkle 1 VERSIONINFO FILEVERSION 2,1,0,0 PRODUCTVERSION 2,1,0,0 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGS 0 FILEOS VOS_NT_WINDOWS32 FILETYPE VFT_APP FILESUBTYPE VFT2_UNKNOWN BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904B0" // US English, Unicode BEGIN VALUE "CompanyName", "My Company\0" VALUE "FileDescription", "My Application\0" VALUE "FileVersion", "2.1.0\0" VALUE "ProductName", "My Application\0" VALUE "ProductVersion", "2.1.0\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x0409, 0x04B0 END END ``` ### Response N/A ### Error Handling N/A ``` -------------------------------- ### Install Library DLL for Clang Compiler Source: https://github.com/vslavik/winsparkle/blob/master/cmake/CMakeLists.txt This conditional CMake block installs the Webview2 loader library DLL. It checks if the C++ compiler ID is 'Clang' before proceeding with the installation to the library directory. ```cmake if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") install(FILES ${WEBVIEW2_LOADER_LIB_DLL} DESTINATION "${LIB_INSTALL_DIR}") endif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") ``` -------------------------------- ### Integrate WinSparkle in Qt C++ Source: https://context7.com/vslavik/winsparkle/llms.txt Shows how to integrate WinSparkle into a Qt MainWindow class. It includes delaying initialization until the window is shown and connecting UI actions to update checks. ```cpp #include "winsparkle.h" void MainWindow::initWinSparkle() { win_sparkle_set_appcast_url("https://myapp.example.com/appcast.xml"); win_sparkle_set_app_details(L"My Company", L"My Qt App", L"1.0.0"); win_sparkle_set_eddsa_public_key("pXAx0wfi8kGbeQln11+V4R3tCepSuLXeo7LkOeudc/U="); win_sparkle_init(); } void MainWindow::checkForUpdates() { win_sparkle_check_update_with_ui(); } MainWindow::~MainWindow() { win_sparkle_cleanup(); } ``` -------------------------------- ### Initialize and Manage WinSparkle Lifecycle Source: https://github.com/vslavik/winsparkle/wiki/Basic-Setup Demonstrates how to initialize the WinSparkle library, trigger manual update checks via UI events, and clean up resources upon application closure. This implementation assumes the WinSparkle wrapper is available in the project. ```csharp public Form1() { InitializeComponent(); WinSparkle.win_sparkle_set_appcast_url("https:////appdescriptor.rss"); WinSparkle.win_sparkle_init(); } private void Form1_button1_click(object sender, EventArgs e) { WinSparkle.win_sparkle_check_update_with_ui(); } private void Form1_Closed(object sender, EventArgs e) { WinSparkle.win_sparkle_cleanup(); } ``` -------------------------------- ### Initialize and Cleanup WinSparkle Source: https://github.com/vslavik/winsparkle/wiki/Basic-Setup Set the appcast URL and initialize the WinSparkle library during application startup, and perform cleanup upon application exit. ```c win_sparkle_set_appcast_url("https://winsparkle.org/example/appcast.xml"); win_sparkle_init(); // On application exit win_sparkle_cleanup(); ``` -------------------------------- ### Define WinSparkle Settings in Windows Resource File Source: https://context7.com/vslavik/winsparkle/llms.txt Demonstrates how to configure update URLs, public keys, and version information directly within a Windows .rc file instead of using API calls. ```rc #include FeedURL APPCAST {"https://myapp.example.com/appcast.xml"} EdDSAPub EDDSA {"pXAx0wfi8kGbeQln11+V4R3tCepSuLXeo7LkOeudc/U="} appicon ICON "myapp.ico" 1 VERSIONINFO FILEVERSION 2,1,0,0 PRODUCTVERSION 2,1,0,0 BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904B0" BEGIN VALUE "CompanyName", "My Company\0" VALUE "FileDescription", "My Application\0" VALUE "FileVersion", "2.1.0\0" END END END ``` -------------------------------- ### Initialize WinSparkle Repository Source: https://github.com/vslavik/winsparkle/blob/master/README.md Commands to clone the WinSparkle source code repository and initialize necessary git submodules for building. ```bash git clone https://github.com/vslavik/winsparkle.git cd winsparkle git submodule init git submodule update ``` -------------------------------- ### GET /appcast.xml Source: https://context7.com/vslavik/winsparkle/llms.txt The appcast feed is an RSS 2.0 file with Sparkle extensions that informs the client about available application updates. ```APIDOC ## GET /appcast.xml ### Description Provides a list of available application updates using the RSS 2.0 format with Sparkle-specific namespaces. ### Method GET ### Endpoint /appcast.xml ### Response #### Success Response (200) - **channel** (object) - The root container for update items. - **item** (array) - List of available versions. - **sparkle:version** (string) - The version number of the release. - **enclosure** (object) - Contains the download URL, file size, OS target, and EdDSA signature. ``` -------------------------------- ### Initialization and Cleanup Source: https://context7.com/vslavik/winsparkle/llms.txt Functions for initializing and cleaning up WinSparkle resources. ```APIDOC ## win_sparkle_init ### Description Starts WinSparkle and begins checking for updates. Must be called after the main window is shown to ensure update UI appears correctly. This call is non-blocking and returns immediately. ### Method `void` (This is a C function, not an HTTP method) ### Endpoint N/A ### Parameters None ### Request Example ```c #include "winsparkle.h" int main(int argc, char *argv[]) { // Create and show your main window first ShowWindow(hwndMain, nCmdShow); // Configure WinSparkle before init (optional) win_sparkle_set_appcast_url("https://example.com/appcast.xml"); win_sparkle_set_eddsa_public_key("pXAx0wfi8kGbeQln11+V4R3tCepSuLXeo7LkOeudc/U="); // Initialize WinSparkle - checks for updates automatically win_sparkle_init(); // Run your application's event loop MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0; } ``` ### Response #### Success Response (N/A) N/A #### Response Example N/A ## win_sparkle_cleanup ### Description Cleans up WinSparkle resources and cancels pending operations. Should be called when the application is shutting down, while the main window is still visible. ### Method `void` (This is a C function, not an HTTP method) ### Endpoint N/A ### Parameters None ### Request Example ```c #include "winsparkle.h" void OnDestroy(HWND hwnd) { // Perform cleanup while main window is still visible win_sparkle_cleanup(); PostQuitMessage(0); } ``` ### Response #### Success Response (N/A) N/A #### Response Example N/A ``` -------------------------------- ### Integrate WinSparkle in C# .NET Source: https://context7.com/vslavik/winsparkle/llms.txt Demonstrates how to use P/Invoke to call WinSparkle.dll functions within a .NET WinForms application. It covers initialization, configuration of update details, and manual update checks. ```csharp using System; using System.Runtime.InteropServices; using System.Windows.Forms; namespace MyApp { static class WinSparkle { [DllImport("WinSparkle.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void win_sparkle_init(); [DllImport("WinSparkle.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void win_sparkle_cleanup(); [DllImport("WinSparkle.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern void win_sparkle_set_appcast_url(string url); [DllImport("WinSparkle.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern int win_sparkle_set_eddsa_public_key(string pubkey); [DllImport("WinSparkle.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] public static extern void win_sparkle_set_app_details(string company_name, string app_name, string app_version); [DllImport("WinSparkle.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void win_sparkle_check_update_with_ui(); } public partial class MainForm : Form { public MainForm() { WinSparkle.win_sparkle_set_appcast_url("https://myapp.example.com/appcast.xml"); WinSparkle.win_sparkle_init(); } } } ``` -------------------------------- ### Configure Automatic Update Checks Source: https://context7.com/vslavik/winsparkle/llms.txt Enables or disables automatic update checking when the application starts. The function win_sparkle_get_automatic_check_for_updates() can be used to query the current status. Call win_sparkle_init() after configuring. ```c #include "winsparkle.h" void ConfigureAutoUpdates(int enableAutoUpdate) { // Enable (1) or disable (0) automatic update checks win_sparkle_set_automatic_check_for_updates(enableAutoUpdate); win_sparkle_init(); } void CheckAutoUpdateStatus() { // Query current setting int autoUpdateEnabled = win_sparkle_get_automatic_check_for_updates(); // Returns 1 if enabled, 0 if disabled } ``` -------------------------------- ### Create C# Wrapper for WinSparkle DLL Source: https://github.com/vslavik/winsparkle/wiki/Basic-Setup Use P/Invoke to create a C# wrapper class that allows managed .NET applications to call native WinSparkle DLL functions. ```csharp using System; using System.Runtime.InteropServices; class WinSparkle { [DllImport("WinSparkle.dll", CallingConvention=CallingConvention.Cdecl)] public static extern void win_sparkle_init(); [DllImport("WinSparkle.dll", CallingConvention=CallingConvention.Cdecl)] public static extern void win_sparkle_cleanup(); [DllImport("WinSparkle.dll", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl)] public static extern void win_sparkle_set_appcast_url(String url); [DllImport("WinSparkle.dll", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.Cdecl)] public static extern void win_sparkle_set_app_details(String company_name, String app_name, String app_version); [DllImport("WinSparkle.dll", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl)] public static extern void win_sparkle_set_registry_path(String path); [DllImport("WinSparkle.dll", CallingConvention=CallingConvention.Cdecl)] public static extern void win_sparkle_check_update_with_ui(); } ``` -------------------------------- ### Automatic Update Check Configuration Source: https://context7.com/vslavik/winsparkle/llms.txt Enables or disables automatic update checking when the application starts. This function controls whether WinSparkle will automatically check for new versions upon launch. ```APIDOC ## win_sparkle_set_automatic_check_for_updates ### Description Enables or disables automatic update checking on startup. ### Method `void win_sparkle_set_automatic_check_for_updates(int enable)` ### Endpoint N/A (This is a library function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c #include "winsparkle.h" void ConfigureAutoUpdates(int enableAutoUpdate) { // Enable (1) or disable (0) automatic update checks win_sparkle_set_automatic_check_for_updates(enableAutoUpdate); win_sparkle_init(); } void CheckAutoUpdateStatus() { // Query current setting int autoUpdateEnabled = win_sparkle_get_automatic_check_for_updates(); // Returns 1 if enabled, 0 if disabled } ``` ### Response N/A (This is a void function) #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Configure Expat Library Options (CMake) Source: https://github.com/vslavik/winsparkle/blob/master/cmake/expat/CMakeLists.txt This snippet configures build options for the expat library within the WinSparkle project using CMake. It sets options for XML context bytes, DTD, and Namespaces, and includes configuration checks. ```cmake set(XML_CONTEXT_BYTES 1024 CACHE STRING "Define to specify how much context to retain around the current parse point") option(XML_DTD "Define to make parameter entity parsing functionality available" ON) option(XML_NS "Define to make XML Namespaces functionality available" ON) if(XML_DTD) set(XML_DTD 1) else(XML_DTD) set(XML_DTD 0) endif(XML_DTD) if(XML_NS) set(XML_NS 1) else(XML_NS) set(XML_NS 0) endif(XML_NS) include(${SOURCE_DIR}/ConfigureChecks.cmake) ``` -------------------------------- ### WinSparkle Integration Pattern Source: https://context7.com/vslavik/winsparkle/llms.txt This section details the typical steps for integrating WinSparkle into a Windows application. ```APIDOC ## WinSparkle Integration Pattern ### Description This outlines the standard workflow for incorporating WinSparkle into your Windows application to provide automatic software updates. ### Steps 1. **Configuration**: Set the appcast URL and EdDSA public key. This can be done via API calls or by embedding them in Windows resources. 2. **Initialization**: Call `win_sparkle_init()` after your application's main window has been displayed. 3. **Update Check (Optional)**: Add a menu item or button that, when clicked, calls `win_sparkle_check_update_with_ui()` to initiate an update check. 4. **Cleanup**: Call `win_sparkle_cleanup()` just before your application exits to release resources. ### Advanced Usage WinSparkle supports callbacks for advanced scenarios such as: - Handling shutdown requests gracefully. - Implementing custom installer logic. - Receiving notifications about update statuses. ### Installer and Platform Support - **Installers**: Compatible with MSI, InnoSetup, NSIS, and other installer formats. - **Platforms**: Supports platform-specific updates for x86, x64, and ARM64 Windows architectures. ### Security - **Signature Verification**: Updates are securely verified using EdDSA signatures to ensure authenticity and prevent tampering. ### Configuration - **Storage**: By default, WinSparkle stores settings in the Windows registry. - **Custom Backends**: Supports custom configuration backends for more flexibility. ### Availability - **Distribution**: Available as a NuGet package or prebuilt binaries. ``` -------------------------------- ### Sign Update Binary with winsparkle-tool Source: https://github.com/vslavik/winsparkle/blob/master/README.md This command signs an update executable using a private key. The resulting signature must be added as the sparkle:edSignature attribute in the appcast enclosure node. ```bash winsparkle-tool sign -f private.key Updater.exe winsparkle-tool sign --verbose --private-key-file private.key Updater.exe ``` -------------------------------- ### Configure WebView2 SDK Dependency Source: https://github.com/vslavik/winsparkle/blob/master/cmake/wxWidgets/CMakeLists.txt This script reads the project's packages.config file to determine the required WebView2 version, attempts to locate the SDK locally, and downloads it from NuGet if not found. It sets the necessary include directories and library paths for the build process. ```cmake file(READ "${CMAKE_CURRENT_SOURCE_DIR}/../../packages.config" PACKAGES_CONFIG_FILE) string(REGEX MATCH "package id=\"Microsoft.Web.WebView2\" version=\"([^\"]+)\"" WEBVIEW_MATCH "${PACKAGES_CONFIG_FILE}") set(WEBVIEW2_VERSION ${CMAKE_MATCH_1}) set(WEBVIEW2_URL "https://www.nuget.org/api/v2/package/Microsoft.Web.WebView2/${WEBVIEW2_VERSION}") find_path(WEBVIEW2_PACKAGE_DIR NAMES build/native/include/WebView2.h PATHS "${PROJECT_SOURCE_DIR}/3rdparty/webview2" ${WEBVIEW2_DEFAULT_PACKAGE_DIR}) if (NOT WEBVIEW2_PACKAGE_DIR) file(DOWNLOAD ${WEBVIEW2_URL} ${CMAKE_CURRENT_BINARY_DIR}/webview2.nuget) execute_process(COMMAND "${CMAKE_COMMAND}" -E tar x "${CMAKE_CURRENT_BINARY_DIR}/webview2.nuget" WORKING_DIRECTORY "${WEBVIEW2_PACKAGE_DIR}") endif() ``` -------------------------------- ### Configuration Functions Source: https://context7.com/vslavik/winsparkle/llms.txt Functions to configure WinSparkle's behavior, such as appcast URL, security keys, and application details. ```APIDOC ## win_sparkle_set_appcast_url ### Description Sets the URL for the application's appcast feed. Must be called before `win_sparkle_init()`. Only HTTPS and HTTP schemes are supported, but HTTPS is strongly recommended for security. ### Method `void` (This is a C function, not an HTTP method) ### Endpoint N/A ### Parameters - **url** (const wchar_t *) - Required - The URL of the appcast feed. ### Request Example ```c #include "winsparkle.h" void ConfigureWinSparkle() { // Set appcast URL - must use HTTPS for security win_sparkle_set_appcast_url("https://myapp.example.com/updates/appcast.xml"); // Then initialize win_sparkle_init(); } ``` ### Response #### Success Response (N/A) N/A #### Response Example N/A ## win_sparkle_set_eddsa_public_key ### Description Sets the EdDSA public key for verifying update signatures. The key must be in base64-encoded format. Must be called before `win_sparkle_init()`. ### Method `int` (This is a C function, not an HTTP method) ### Endpoint N/A ### Parameters - **public_key** (const wchar_t *) - Required - The base64-encoded EdDSA public key. ### Returns `1` if the key was set successfully, `0` otherwise. ### Request Example ```c #include "winsparkle.h" void ConfigureUpdateSecurity() { // Set EdDSA public key for signature verification int result = win_sparkle_set_eddsa_public_key("pXAx0wfi8kGbeQln11+V4R3tCepSuLXeo7LkOeudc/U="); if (result == 1) { // Valid key was set win_sparkle_init(); } else { // Invalid key format MessageBox(NULL, "Invalid public key", "Error", MB_OK); } } ``` ### Response #### Success Response (N/A) N/A #### Response Example N/A ## win_sparkle_set_app_details ### Description Sets application metadata programmatically instead of using VERSIONINFO resources. Useful for applications that don't use Win32 resources. ### Method `void` (This is a C function, not an HTTP method) ### Endpoint N/A ### Parameters - **company_name** (const wchar_t *) - Required - The name of the company. - **app_name** (const wchar_t *) - Required - The name of the application. - **version** (const wchar_t *) - Required - The version string of the application. ### Request Example ```c #include "winsparkle.h" void ConfigureAppMetadata() { // Set company name, app name, and version // These are used for registry path and HTTP User-Agent win_sparkle_set_app_details( L"My Company", // Company name L"My Application", // App name L"2.1.0" // Version string ); win_sparkle_init(); } ``` ### Response #### Success Response (N/A) N/A #### Response Example N/A ## win_sparkle_set_app_build_version ### Description Sets an internal build version number for finer-grained version comparison, separate from the display version. ### Method `void` (This is a C function, not an HTTP method) ### Endpoint N/A ### Parameters - **build_version** (const wchar_t *) - Required - The internal build version string. ### Request Example ```c #include "winsparkle.h" void ConfigureVersioning() { // Set display version via app details win_sparkle_set_app_details(L"Company", L"MyApp", L"2.1.0"); // Set internal build number for precise version comparison // This is compared against sparkle:version in appcast // The display version corresponds to sparkle:shortVersionString win_sparkle_set_app_build_version(L"2.1.0.1547"); win_sparkle_init(); } ``` ### Response #### Success Response (N/A) N/A #### Response Example N/A ## win_sparkle_set_http_header ### Description Adds custom HTTP headers to appcast requests and update downloads. Useful for authentication or passing license information. ### Method `void` (This is a C function, not an HTTP method) ### Endpoint N/A ### Parameters - **name** (const wchar_t *) - Required - The name of the HTTP header. - **value** (const wchar_t *) - Required - The value of the HTTP header. ### Request Example ```c #include "winsparkle.h" void ConfigureHttpHeaders() { // Add custom headers for appcast and download requests win_sparkle_set_http_header("Authorization", "Bearer mytoken123"); win_sparkle_set_http_header("X-Product-License", "Pro"); win_sparkle_set_http_header("X-Machine-ID", "abc123def456"); win_sparkle_init(); } void ResetHeaders() { // Clear all custom headers win_sparkle_clear_http_headers(); } ``` ### Response #### Success Response (N/A) N/A #### Response Example N/A ``` -------------------------------- ### Language Configuration (ISO Code) Source: https://context7.com/vslavik/winsparkle/llms.txt Sets the user interface language for WinSparkle using standard ISO language codes. This must be called before initializing WinSparkle. ```APIDOC ## win_sparkle_set_lang ### Description Sets the UI language using an ISO language code. Must be called before `win_sparkle_init()`. ### Method `void win_sparkle_set_lang(const char* lang)` ### Endpoint N/A (This is a library function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c #include "winsparkle.h" void ConfigureLanguage() { // Set UI language using ISO 639 code win_sparkle_set_lang("de"); // German // Or with country code: win_sparkle_set_lang("pt-BR"); // Brazilian Portuguese win_sparkle_set_lang("zh_CN"); // Simplified Chinese win_sparkle_init(); } ``` ### Response N/A (This is a void function) #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Configure UI Language using ISO Codes Source: https://context7.com/vslavik/winsparkle/llms.txt Sets the user interface language for WinSparkle using standard ISO 639 language codes or codes with country specifiers (e.g., 'de', 'pt-BR', 'zh_CN'). This must be called before win_sparkle_init(). ```c #include "winsparkle.h" void ConfigureLanguage() { // Set UI language using ISO 639 code win_sparkle_set_lang("de"); // German // Or with country code: win_sparkle_set_lang("pt-BR"); // Brazilian Portuguese win_sparkle_set_lang("zh_CN"); // Simplified Chinese win_sparkle_init(); } ``` -------------------------------- ### CMake Configuration for WinSparkle Crypto Module Source: https://github.com/vslavik/winsparkle/blob/master/cmake/crypto/CMakeLists.txt This CMake script sets up the build environment for the crypto module of the WinSparkle project. It defines the minimum required CMake version, project name, source directory, include paths, and preprocessor definitions specific to the Windows platform and OpenSSL. ```cmake cmake_minimum_required(VERSION 2.6) project(crypto) set(SOURCE_DIR ${ROOT_DIR}/3rdparty/openssl/crypto) include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${SOURCE_DIR}/../../openssl-win32 ${SOURCE_DIR}/../../openssl-win32/openssl ) add_definitions( -D_CRT_SECURE_NO_DEPRECATE -DDSO_WIN32 -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DOPENSSL_NO_ASM -DOPENSSL_NO_INLINE_ASM -DNO_WINDOWS_BRAINDEATH -DMK1MF_BUILD -DMK1MF_PLATFORM_VC_WIN32 -D_LIB ) # _CRT_SECURE_NO_WARNINGS; ``` -------------------------------- ### Configure Appcast URL Source: https://context7.com/vslavik/winsparkle/llms.txt Sets the source URL for the application's update feed. Must be invoked prior to calling win_sparkle_init(). ```c #include "winsparkle.h" void ConfigureWinSparkle() { win_sparkle_set_appcast_url("https://myapp.example.com/updates/appcast.xml"); win_sparkle_init(); } ``` -------------------------------- ### Configure Application Version for WinSparkle Source: https://github.com/vslavik/winsparkle/wiki/Basic-Setup Explains how to define the application version used by WinSparkle for update comparisons by modifying the AssemblyFileVersion attribute within the AssemblyInfo.cs file. ```csharp [assembly: AssemblyFileVersion("1.0.7.0")] ``` -------------------------------- ### Configure Compiler-Specific WebView2 Libraries Source: https://github.com/vslavik/winsparkle/blob/master/cmake/wxWidgets/CMakeLists.txt Handles the selection of static or dynamic WebView2 loader libraries based on the detected C++ compiler. It specifically accounts for Clang limitations by linking against the DLL version when necessary. ```cmake if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") set(WEBVIEW2_LOADER_LIB "${WEBVIEW2_PACKAGE_DIR}/build/native/${WEBVIEW2_LOADER_ARCH}/WebView2Loader.dll.lib") else() set(WEBVIEW2_LOADER_LIB "${WEBVIEW2_PACKAGE_DIR}/build/native/${WEBVIEW2_LOADER_ARCH}/WebView2LoaderStatic.lib") endif() ``` -------------------------------- ### Include WinSparkle Header Source: https://github.com/vslavik/winsparkle/wiki/Basic-Setup Include the WinSparkle header file in your C/C++ project to access the library's native API. ```c #include ``` -------------------------------- ### Set Application Metadata Source: https://context7.com/vslavik/winsparkle/llms.txt Manually defines application details such as company name, app name, and version string, bypassing the need for Win32 VERSIONINFO resources. ```c #include "winsparkle.h" void ConfigureAppMetadata() { win_sparkle_set_app_details( L"My Company", L"My Application", L"2.1.0" ); win_sparkle_init(); } ``` -------------------------------- ### Configure WinSparkle Registry Path Source: https://context7.com/vslavik/winsparkle/llms.txt Customizes the registry location where WinSparkle stores its settings. This function should be called before win_sparkle_init(). The default path is HKCU\Software\\\WinSparkle. ```c #include "winsparkle.h" void ConfigureRegistryPath() { // Change registry path from default // Default: HKCU\Software\\\WinSparkle win_sparkle_set_registry_path("Software\MyCompany\MyApp\Updates"); win_sparkle_init(); } ``` -------------------------------- ### Configure UI Language using Win32 LANGID Source: https://context7.com/vslavik/winsparkle/llms.txt Sets the user interface language for WinSparkle using a Win32 LANGID code. This allows setting the language based on the system's current UI language or explicitly defining it using MAKELANGID. Call win_sparkle_init() afterwards. ```c #include "winsparkle.h" #include void ConfigureLanguageFromSystem() { // Use system's UI language LANGID langid = GetThreadUILanguage(); win_sparkle_set_langid(langid); // Or set explicitly (e.g., French) win_sparkle_set_langid(MAKELANGID(LANG_FRENCH, SUBLANG_FRENCH)); win_sparkle_init(); } ``` -------------------------------- ### Set C++ Standard and Preprocessor Definitions (CMake) Source: https://github.com/vslavik/winsparkle/blob/master/cmake/wxWidgets/CMakeLists.txt This CMake configuration sets the C++ standard to C++11 and defines several preprocessor macros required for building the wxWidgets library. These definitions include security warnings suppression, precompiled header usage, and platform-specific flags for Unicode and release builds. ```cmake set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") add_definitions( -D_CRT_SECURE_NO_WARNINGS -DWX_PRECOMP -DWXBUILDING -DWIN32 -DNDEBUG -D_LIB -DUNICODE -D_UNICODE) ``` -------------------------------- ### Initialize WinSparkle Update Check Source: https://context7.com/vslavik/winsparkle/llms.txt Initializes the WinSparkle update checking mechanism. This should be called after the application's main window is displayed. It sets up the necessary components for checking and applying updates. ```c #include int main() { // ... initialize application window ... win_sparkle_init(); // ... rest of application logic ... return 0; } ``` -------------------------------- ### Generate Basic Config Version File with CMake Source: https://github.com/vslavik/winsparkle/blob/master/cmake/CMakeLists.txt This CMake code generates a basic configuration version file. It uses the `write_basic_config_version_file` function to create a file that specifies the version and compatibility of the package. ```cmake write_basic_config_version_file(WinSparkleConfigVersion.cmake VERSION ${LIB_VERSION_STRING} COMPATIBILITY AnyNewerVersion) ``` -------------------------------- ### Define Expat Library Sources and Build Target (CMake) Source: https://github.com/vslavik/winsparkle/blob/master/cmake/expat/CMakeLists.txt This CMake code defines the source files for the expat library and creates a static library target named 'expat'. It also includes platform-specific definitions for MSVC and general definitions for Win32 and static XML parsing. ```cmake include_directories(${CMAKE_CURRENT_BINARY_DIR} ${SOURCE_DIR}/lib) if(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS -wd4996) endif(MSVC) add_definitions(-DWIN32) add_definitions(-DXML_STATIC) set(expat_SRCS ${SOURCE_DIR}/lib/xmlparse.c ${SOURCE_DIR}/lib/xmlrole.c ${SOURCE_DIR}/lib/xmltok.c ${SOURCE_DIR}/lib/xmltok_impl.c ${SOURCE_DIR}/lib/xmltok_ns.c ) add_library(expat OBJECT ${expat_SRCS}) ``` -------------------------------- ### Generate and Configure EdDSA Keys Source: https://github.com/vslavik/winsparkle/blob/master/README.md Commands and API usage for generating EdDSA keys and configuring the public key within a WinSparkle-enabled application. ```bash winsparkle-tool generate-key --file private.key ``` ```c win_sparkle_set_eddsa_public_key("pXAx0wfi8kGbeQln11+V4R3tCepSuLXeo7LkOeudc/U="); ``` ```resource EdDSAPub EDDSA {"pXAx0wfi8kGbeQln11+V4R3tCepSuLXeo7LkOeudc/U="} ```