2 * Wrappers and routines to check for software updates.
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
13 #include "software_update.h"
15 #include "../epan/prefs.h"
18 * Version 0 of the update URI path has the following elements:
19 * - The update path prefix (fixed, "update")
20 * - The schema version (fixed, 0)
21 * - The application name (fixed, "Wireshark")
22 * - The application version ("<major>.<minor>.<micro>")
23 * - The operating system (varable, one of "windows" or "osx")
24 * - The architecture name (variable, one of "x86", "x86-64")
25 * - The locale (fixed, "en-US)
26 * - The update channel (variable, one of "development" or "stable") + .xml
28 * Based on https://wiki.mozilla.org/Software_Update:Checking_For_Updates
31 #ifdef HAVE_SOFTWARE_UPDATE
32 #define SU_SCHEMA_PREFIX "update"
33 #define SU_SCHEMA_VERSION 0
34 #define SU_APPLICATION "Wireshark"
35 #define SU_LOCALE "en-US"
36 #endif /* HAVE_SOFTWARE_UPDATE */
38 #if defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32)
42 #include <winsparkle.h>
44 #define SU_OSNAME "Windows"
46 static GString *update_url_str = NULL;
48 static const char *get_appcast_update_url(software_update_channel_e chan) {
49 const char *chan_name;
50 const char *arch = "x86";
52 if (!update_url_str) {
53 update_url_str = g_string_new("");
56 /* XXX Add WOW64 checks similar to version_info.c? */
57 if (sizeof(arch) != 4) {
62 case UPDATE_CHANNEL_DEVELOPMENT:
63 chan_name = "development";
69 g_string_printf(update_url_str, "https://www.wireshark.org/%s/%u/%s/%s/%s/%s/en-US/%s.xml",
77 return update_url_str->str;
80 /** Initialize software updates.
83 software_update_init(void) {
84 const char *update_url = get_appcast_update_url(prefs.gui_update_channel);
87 * According to the WinSparkle 0.5 documentation these must be called
88 * once, before win_sparkle_init. We can't update them dynamically when
89 * our preferences change.
91 win_sparkle_set_registry_path("Software\\Wireshark\\WinSparkle Settings");
92 win_sparkle_set_appcast_url(update_url);
93 win_sparkle_set_automatic_check_for_updates(prefs.gui_update_enabled ? 1 : 0);
94 win_sparkle_set_update_check_interval(prefs.gui_update_interval);
95 win_sparkle_set_can_shutdown_callback(software_update_can_shutdown_callback);
96 win_sparkle_set_shutdown_request_callback(software_update_shutdown_request_callback);
97 if ((language != NULL) && (strcmp(language, "system") != 0)) {
98 win_sparkle_set_lang(language);
103 /** Force a software update check.
106 software_update_check(void) {
107 win_sparkle_check_update_with_ui();
110 /** Clean up software update checking.
112 * Does nothing on platforms that don't support software updates.
114 extern void software_update_cleanup(void) {
115 win_sparkle_cleanup();
118 #else /* defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32) */
120 /** Initialize software updates.
123 software_update_init(void) {
126 /** Force a software update check.
129 software_update_check(void) {
132 /** Clean up software update checking.
134 void software_update_cleanup(void) {
137 /** Check to see if Wireshark can shut down safely (e.g. offer to save the
140 int software_update_can_shutdown_callback(void) {
144 /** Shut down Wireshark in preparation for an upgrade.
146 void software_update_shutdown_request_callback(void) {
149 #endif /* defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32) */
157 * indent-tabs-mode: nil
160 * ex: set shiftwidth=4 tabstop=8 expandtab:
161 * :indentSize=4:tabSize=8:noTabs=true: