2013-02-19 22:21:17 +00:00
|
|
|
/* software_update.h
|
|
|
|
* Wrappers and routines to check for software updates.
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-04-30 07:47:58 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2013-02-19 22:21:17 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "software_update.h"
|
2017-11-07 22:28:19 +00:00
|
|
|
#include "language.h"
|
2013-02-19 22:21:17 +00:00
|
|
|
#include "../epan/prefs.h"
|
2022-06-16 19:45:48 +00:00
|
|
|
#include "../wsutil/filesystem.h"
|
2013-02-19 22:21:17 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Version 0 of the update URI path has the following elements:
|
|
|
|
* - The update path prefix (fixed, "update")
|
|
|
|
* - The schema version (fixed, 0)
|
2022-06-30 16:45:49 +00:00
|
|
|
* - The application name (variable, "Wireshark" or "Logray")
|
2013-02-19 22:21:17 +00:00
|
|
|
* - The application version ("<major>.<minor>.<micro>")
|
2020-02-27 05:32:36 +00:00
|
|
|
* - The operating system (variable, one of "Windows" or "macOS")
|
2021-05-29 17:21:03 +00:00
|
|
|
* - The architecture name (variable, one of "x86", "x86-64", or "arm64")
|
2020-02-27 05:32:36 +00:00
|
|
|
* - The locale (fixed, "en-US")
|
2013-02-19 22:21:17 +00:00
|
|
|
* - The update channel (variable, one of "development" or "stable") + .xml
|
2013-11-08 03:33:01 +00:00
|
|
|
*
|
2013-02-19 22:21:17 +00:00
|
|
|
* Based on https://wiki.mozilla.org/Software_Update:Checking_For_Updates
|
2019-11-14 16:08:28 +00:00
|
|
|
*
|
|
|
|
* To do for version 1:
|
|
|
|
* - Distinguish between NSIS (.exe) and WiX (.msi) on Windows.
|
2013-02-19 22:21:17 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_SOFTWARE_UPDATE
|
|
|
|
#define SU_SCHEMA_PREFIX "update"
|
|
|
|
#define SU_SCHEMA_VERSION 0
|
|
|
|
#define SU_LOCALE "en-US"
|
|
|
|
#endif /* HAVE_SOFTWARE_UPDATE */
|
|
|
|
|
2019-11-14 16:08:28 +00:00
|
|
|
#ifdef HAVE_SOFTWARE_UPDATE
|
2013-02-19 22:21:17 +00:00
|
|
|
|
|
|
|
#include "glib.h"
|
|
|
|
|
2019-11-14 16:08:28 +00:00
|
|
|
#ifdef _WIN32
|
2013-02-19 22:21:17 +00:00
|
|
|
#include <winsparkle.h>
|
|
|
|
#define SU_OSNAME "Windows"
|
2019-11-14 16:08:28 +00:00
|
|
|
#elif defined(__APPLE__)
|
|
|
|
#include <macosx/sparkle_bridge.h>
|
|
|
|
#define SU_OSNAME "macOS"
|
|
|
|
#else
|
|
|
|
#error HAVE_SOFTWARE_UPDATE can only be defined for Windows or macOS.
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// https://sourceforge.net/p/predef/wiki/Architectures/
|
|
|
|
#if defined(__x86_64__) || defined(_M_X64)
|
|
|
|
#define SU_ARCH "x86-64"
|
2019-11-15 20:25:13 +00:00
|
|
|
#elif defined(__i386__) || defined(_M_IX86)
|
2019-11-14 16:08:28 +00:00
|
|
|
#define SU_ARCH "x86"
|
2021-05-29 17:21:03 +00:00
|
|
|
#elif defined(__arm64__)
|
|
|
|
#define SU_ARCH "arm64"
|
2019-11-15 21:39:12 +00:00
|
|
|
#else
|
2021-05-29 17:21:03 +00:00
|
|
|
#error HAVE_SOFTWARE_UPDATE can only be defined for x86-64 or x86 or arm64.
|
2019-11-14 16:08:28 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static char *get_appcast_update_url(software_update_channel_e chan) {
|
|
|
|
GString *update_url_str = g_string_new("");;
|
2013-02-19 22:21:17 +00:00
|
|
|
const char *chan_name;
|
2022-06-16 19:45:48 +00:00
|
|
|
const char *su_application = get_configuration_namespace();
|
|
|
|
const char *su_version = VERSION;
|
|
|
|
|
2022-06-17 22:22:26 +00:00
|
|
|
if (!is_packet_configuration_namespace()) {
|
2022-06-16 19:45:48 +00:00
|
|
|
su_version = LOG_VERSION;
|
|
|
|
}
|
2013-11-08 03:33:01 +00:00
|
|
|
|
2013-02-19 22:21:17 +00:00
|
|
|
switch (chan) {
|
|
|
|
case UPDATE_CHANNEL_DEVELOPMENT:
|
|
|
|
chan_name = "development";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
chan_name = "stable";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
g_string_printf(update_url_str, "https://www.wireshark.org/%s/%u/%s/%s/%s/%s/en-US/%s.xml",
|
|
|
|
SU_SCHEMA_PREFIX,
|
|
|
|
SU_SCHEMA_VERSION,
|
2022-06-16 19:45:48 +00:00
|
|
|
su_application,
|
|
|
|
su_version,
|
2013-02-19 22:21:17 +00:00
|
|
|
SU_OSNAME,
|
2019-11-14 16:08:28 +00:00
|
|
|
SU_ARCH,
|
2013-02-19 22:21:17 +00:00
|
|
|
chan_name);
|
2019-11-14 16:08:28 +00:00
|
|
|
return g_string_free(update_url_str, FALSE);
|
2013-02-19 22:21:17 +00:00
|
|
|
}
|
|
|
|
|
2019-11-14 16:08:28 +00:00
|
|
|
#ifdef _WIN32
|
2013-02-19 22:21:17 +00:00
|
|
|
/** Initialize software updates.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
software_update_init(void) {
|
2013-02-20 20:16:49 +00:00
|
|
|
const char *update_url = get_appcast_update_url(prefs.gui_update_channel);
|
2013-11-08 03:33:01 +00:00
|
|
|
|
2016-12-08 17:41:47 +00:00
|
|
|
/*
|
|
|
|
* According to the WinSparkle 0.5 documentation these must be called
|
|
|
|
* once, before win_sparkle_init. We can't update them dynamically when
|
|
|
|
* our preferences change.
|
|
|
|
*/
|
2013-03-05 18:46:50 +00:00
|
|
|
win_sparkle_set_registry_path("Software\\Wireshark\\WinSparkle Settings");
|
2013-02-19 22:21:17 +00:00
|
|
|
win_sparkle_set_appcast_url(update_url);
|
|
|
|
win_sparkle_set_automatic_check_for_updates(prefs.gui_update_enabled ? 1 : 0);
|
|
|
|
win_sparkle_set_update_check_interval(prefs.gui_update_interval);
|
2016-12-13 18:33:02 +00:00
|
|
|
win_sparkle_set_can_shutdown_callback(software_update_can_shutdown_callback);
|
|
|
|
win_sparkle_set_shutdown_request_callback(software_update_shutdown_request_callback);
|
2017-11-14 19:11:09 +00:00
|
|
|
if ((language != NULL) && (strcmp(language, "system") != 0)) {
|
2017-11-07 22:28:19 +00:00
|
|
|
win_sparkle_set_lang(language);
|
2017-11-14 19:11:09 +00:00
|
|
|
}
|
2013-02-19 22:21:17 +00:00
|
|
|
win_sparkle_init();
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Force a software update check.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
software_update_check(void) {
|
|
|
|
win_sparkle_check_update_with_ui();
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Clean up software update checking.
|
|
|
|
*
|
2013-11-08 03:33:01 +00:00
|
|
|
* Does nothing on platforms that don't support software updates.
|
2013-02-19 22:21:17 +00:00
|
|
|
*/
|
|
|
|
extern void software_update_cleanup(void) {
|
|
|
|
win_sparkle_cleanup();
|
|
|
|
}
|
|
|
|
|
2020-02-13 23:18:14 +00:00
|
|
|
const char *software_update_info(void) {
|
|
|
|
return "WinSparkle " WIN_SPARKLE_VERSION_STRING;
|
|
|
|
}
|
|
|
|
|
2019-11-14 16:08:28 +00:00
|
|
|
#elif defined (__APPLE__)
|
2013-02-19 22:21:17 +00:00
|
|
|
/** Initialize software updates.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
software_update_init(void) {
|
2019-11-14 16:08:28 +00:00
|
|
|
char *update_url = get_appcast_update_url(prefs.gui_update_channel);
|
|
|
|
|
|
|
|
sparkle_software_update_init(update_url, prefs.gui_update_enabled, prefs.gui_update_interval);
|
|
|
|
|
|
|
|
g_free(update_url);
|
2013-02-19 22:21:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Force a software update check.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
software_update_check(void) {
|
2019-11-14 16:08:28 +00:00
|
|
|
sparkle_software_update_check();
|
2013-02-19 22:21:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Clean up software update checking.
|
|
|
|
*/
|
2016-12-13 18:33:02 +00:00
|
|
|
void software_update_cleanup(void) {
|
2020-02-27 20:03:49 +00:00
|
|
|
sparkle_software_update_cleanup();
|
2016-12-13 18:33:02 +00:00
|
|
|
}
|
2020-02-13 23:18:14 +00:00
|
|
|
|
|
|
|
const char *software_update_info(void) {
|
|
|
|
return "Sparkle";
|
|
|
|
}
|
2019-11-14 16:08:28 +00:00
|
|
|
#endif
|
2016-12-13 18:33:02 +00:00
|
|
|
|
2019-11-14 16:08:28 +00:00
|
|
|
#else /* No updates */
|
|
|
|
|
|
|
|
/** Initialize software updates.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
software_update_init(void) {
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Force a software update check.
|
2016-12-13 18:33:02 +00:00
|
|
|
*/
|
2019-11-14 16:08:28 +00:00
|
|
|
void
|
|
|
|
software_update_check(void) {
|
2016-12-13 18:33:02 +00:00
|
|
|
}
|
|
|
|
|
2019-11-14 16:08:28 +00:00
|
|
|
/** Clean up software update checking.
|
2016-12-13 18:33:02 +00:00
|
|
|
*/
|
2019-11-14 16:08:28 +00:00
|
|
|
void software_update_cleanup(void) {
|
2013-02-19 22:21:17 +00:00
|
|
|
}
|
|
|
|
|
2020-02-13 23:18:14 +00:00
|
|
|
const char *software_update_info(void) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-02-19 22:21:17 +00:00
|
|
|
#endif /* defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32) */
|