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*/
12 #include "software_update.h"
14 #include "../epan/prefs.h"
17 * Version 0 of the update URI path has the following elements:
18 * - The update path prefix (fixed, "update")
19 * - The schema version (fixed, 0)
20 * - The application name (fixed, "Wireshark")
21 * - The application version ("<major>.<minor>.<micro>")
22 * - The operating system (varable, one of "windows" or "osx")
23 * - The architecture name (variable, one of "x86", "x86-64")
24 * - The locale (fixed, "en-US)
25 * - The update channel (variable, one of "development" or "stable") + .xml
27 * Based on https://wiki.mozilla.org/Software_Update:Checking_For_Updates
30 #ifdef HAVE_SOFTWARE_UPDATE
31 #define SU_SCHEMA_PREFIX "update"
32 #define SU_SCHEMA_VERSION 0
33 #define SU_APPLICATION "Wireshark"
34 #define SU_LOCALE "en-US"
35 #endif /* HAVE_SOFTWARE_UPDATE */
37 #if defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32)
41 #include <winsparkle.h>
43 #define SU_OSNAME "Windows"
45 static GString *update_url_str = NULL;
47 static const char *get_appcast_update_url(software_update_channel_e chan) {
48 const char *chan_name;
49 const char *arch = "x86";
51 if (!update_url_str) {
52 update_url_str = g_string_new("");
55 /* XXX Add WOW64 checks similar to version_info.c? */
56 if (sizeof(arch) != 4) {
61 case UPDATE_CHANNEL_DEVELOPMENT:
62 chan_name = "development";
68 g_string_printf(update_url_str, "https://www.wireshark.org/%s/%u/%s/%s/%s/%s/en-US/%s.xml",
76 return update_url_str->str;
79 /** Initialize software updates.
82 software_update_init(void) {
83 const char *update_url = get_appcast_update_url(prefs.gui_update_channel);
86 * According to the WinSparkle 0.5 documentation these must be called
87 * once, before win_sparkle_init. We can't update them dynamically when
88 * our preferences change.
90 win_sparkle_set_registry_path("Software\\Wireshark\\WinSparkle Settings");
91 win_sparkle_set_appcast_url(update_url);
92 win_sparkle_set_automatic_check_for_updates(prefs.gui_update_enabled ? 1 : 0);
93 win_sparkle_set_update_check_interval(prefs.gui_update_interval);
94 win_sparkle_set_can_shutdown_callback(software_update_can_shutdown_callback);
95 win_sparkle_set_shutdown_request_callback(software_update_shutdown_request_callback);
96 if ((language != NULL) && (strcmp(language, "system") != 0)) {
97 win_sparkle_set_lang(language);
102 /** Force a software update check.
105 software_update_check(void) {
106 win_sparkle_check_update_with_ui();
109 /** Clean up software update checking.
111 * Does nothing on platforms that don't support software updates.
113 extern void software_update_cleanup(void) {
114 win_sparkle_cleanup();
117 #else /* defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32) */
119 /** Initialize software updates.
122 software_update_init(void) {
125 /** Force a software update check.
128 software_update_check(void) {
131 /** Clean up software update checking.
133 void software_update_cleanup(void) {
136 /** Check to see if Wireshark can shut down safely (e.g. offer to save the
139 int software_update_can_shutdown_callback(void) {
143 /** Shut down Wireshark in preparation for an upgrade.
145 void software_update_shutdown_request_callback(void) {
148 #endif /* defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32) */
156 * indent-tabs-mode: nil
159 * ex: set shiftwidth=4 tabstop=8 expandtab:
160 * :indentSize=4:tabSize=8:noTabs=true: