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 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include "software_update.h"
27 #include "../epan/prefs.h"
30 * Version 0 of the update URI path has the following elements:
31 * - The update path prefix (fixed, "update")
32 * - The schema version (fixed, 0)
33 * - The application name (fixed, "Wireshark")
34 * - The application version ("<major>.<minor>.<micro>")
35 * - The operating system (varable, one of "windows" or "osx")
36 * - The architecture name (variable, one of "x86", "x86-64")
37 * - The locale (fixed, "en-US)
38 * - The update channel (variable, one of "development" or "stable") + .xml
40 * Based on https://wiki.mozilla.org/Software_Update:Checking_For_Updates
43 #ifdef HAVE_SOFTWARE_UPDATE
44 #define SU_SCHEMA_PREFIX "update"
45 #define SU_SCHEMA_VERSION 0
46 #define SU_APPLICATION "Wireshark"
47 #define SU_LOCALE "en-US"
48 #endif /* HAVE_SOFTWARE_UPDATE */
50 #if defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32)
54 #include <winsparkle.h>
56 #define SU_OSNAME "Windows"
58 static GString *update_url_str = NULL;
60 static const char *get_appcast_update_url(software_update_channel_e chan) {
61 const char *chan_name;
62 const char *arch = "x86";
64 if (!update_url_str) {
65 update_url_str = g_string_new("");
68 /* XXX Add WOW64 checks similar to version_info.c? */
69 if (sizeof(arch) != 4) {
74 case UPDATE_CHANNEL_DEVELOPMENT:
75 chan_name = "development";
81 g_string_printf(update_url_str, "https://www.wireshark.org/%s/%u/%s/%s/%s/%s/en-US/%s.xml",
89 return update_url_str->str;
92 /** Initialize software updates.
95 software_update_init(void) {
96 const char *update_url = get_appcast_update_url(prefs.gui_update_channel);
99 * According to the WinSparkle 0.5 documentation these must be called
100 * once, before win_sparkle_init. We can't update them dynamically when
101 * our preferences change.
103 win_sparkle_set_registry_path("Software\\Wireshark\\WinSparkle Settings");
104 win_sparkle_set_appcast_url(update_url);
105 win_sparkle_set_automatic_check_for_updates(prefs.gui_update_enabled ? 1 : 0);
106 win_sparkle_set_update_check_interval(prefs.gui_update_interval);
107 win_sparkle_set_can_shutdown_callback(software_update_can_shutdown_callback);
108 win_sparkle_set_shutdown_request_callback(software_update_shutdown_request_callback);
109 if ((language != NULL) && (strcmp(language, "system") != 0)) {
110 win_sparkle_set_lang(language);
115 /** Force a software update check.
118 software_update_check(void) {
119 win_sparkle_check_update_with_ui();
122 /** Clean up software update checking.
124 * Does nothing on platforms that don't support software updates.
126 extern void software_update_cleanup(void) {
127 win_sparkle_cleanup();
130 #else /* defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32) */
132 /** Initialize software updates.
135 software_update_init(void) {
138 /** Force a software update check.
141 software_update_check(void) {
144 /** Clean up software update checking.
146 void software_update_cleanup(void) {
149 /** Check to see if Wireshark can shut down safely (e.g. offer to save the
152 int software_update_can_shutdown_callback(void) {
156 /** Shut down Wireshark in preparation for an upgrade.
158 void software_update_shutdown_request_callback(void) {
161 #endif /* defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32) */
169 * indent-tabs-mode: nil
172 * ex: set shiftwidth=4 tabstop=8 expandtab:
173 * :indentSize=4:tabSize=8:noTabs=true: