diff options
author | Gerald Combs <gerald@wireshark.org> | 2013-02-19 22:21:17 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2013-02-19 22:21:17 +0000 |
commit | e48236a43635f9f0e695a25199bf3ab959774590 (patch) | |
tree | c6438499bad89c7f47eda54dc4e5c9bd2bcadb89 | |
parent | 9736ff7cb5f2ba971202a3472707aa96380d16de (diff) | |
download | wireshark-e48236a43635f9f0e695a25199bf3ab959774590.tar.gz |
Add automatic software update checks for Win32 using WinSparkle. Add
preferences (currently hidden) to disable updates, set the update
frequency, and set the update "channel" (stable vs development). Add a
"Help" menu item to manually check for updates.
svn path=/trunk/; revision=47748
-rw-r--r-- | Makefile.nmake | 13 | ||||
-rw-r--r-- | config.h.win32 | 3 | ||||
-rw-r--r-- | config.nmake | 19 | ||||
-rw-r--r-- | epan/prefs.c | 18 | ||||
-rw-r--r-- | epan/prefs.h | 10 | ||||
-rw-r--r-- | packaging/nsis/Makefile.nmake | 3 | ||||
-rw-r--r-- | packaging/nsis/wireshark.nsi | 3 | ||||
-rwxr-xr-x | tools/win32-setup.sh | 2 | ||||
-rw-r--r-- | ui/Makefile.common | 2 | ||||
-rw-r--r-- | ui/Makefile.nmake | 2 | ||||
-rw-r--r-- | ui/gtk/main.c | 5 | ||||
-rw-r--r-- | ui/gtk/main_menubar.c | 18 | ||||
-rwxr-xr-x | ui/software_update.c | 157 | ||||
-rwxr-xr-x | ui/software_update.h | 68 |
14 files changed, 319 insertions, 4 deletions
diff --git a/Makefile.nmake b/Makefile.nmake index bf2b5888c7..507a925668 100644 --- a/Makefile.nmake +++ b/Makefile.nmake @@ -45,7 +45,7 @@ GENERATED_CFLAGS=\ /I. /Iwiretap $(GLIB_CFLAGS) \ $(ZLIB_CFLAGS) /I$(PCAP_DIR)\include $(AIRPCAP_CFLAGS) \ $(C_ARES_CFLAGS) $(ADNS_CFLAGS) $(GNUTLS_CFLAGS) \ - $(PYTHON_CFLAGS) $(SMI_CFLAGS) $(GEOIP_CFLAGS) + $(PYTHON_CFLAGS) $(SMI_CFLAGS) $(GEOIP_CFLAGS) $(WINSPARKLE_CFLAGS) CFLAGS=$(WARNINGS_ARE_ERRORS) $(GENERATED_CFLAGS) @@ -80,6 +80,7 @@ wireshark_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \ $(GNUTLS_LIBS) \ $(PYTHON_LIBS) \ $(ZLIB_LIBS) \ + $(WINSPARKLE_LIBS) \ !IFDEF ENABLE_LIBWIRESHARK epan\libwireshark.lib \ !ELSE @@ -440,6 +441,7 @@ config.h : config.h.win32 config.nmake -e "s/@HAVE_SMI@/$(SMI_CONFIG)/" \ -e "s/@HAVE_GEOIP@/$(GEOIP_CONFIG)/" \ -e "s/@HAVE_GEOIP_V6@/$(GEOIP_V6_CONFIG)/" \ + -e "s/@HAVE_SOFTWARE_UPDATE@/$(WINSPARKLE_CONFIG)/" \ -e "s/@INET6@/$(INET6_CONFIG)/" \ -e "s/@HAVE_NTDDNDIS_H@/$(NTDDNDIS_CONFIG)/" \ -e "s/@PCAP_NG_DEFAULT@/$(PCAP_NG_DEFAULT)/" \ @@ -471,6 +473,7 @@ KFW_DIR = $(KFW_DIR:\=/) LUA_DIR = $(LUA_DIR:\=/) PORTAUDIO_DIR = $(PORTAUDIO_DIR:\=/) GEOIP_DIR = $(GEOIP_DIR:\=/) +WINSPARKLE_DIR = $(WINSPARKLE_DIR:\=/) INTL_DLL = $(INTL_DLL) @@ -939,6 +942,10 @@ process_libs: @$(SH) $(WIN_SETUP) "$(WIN_SETUP_OPT)" "$(WIRESHARK_LIB_DIR)" \ GeoIP-$(GEOIP_PKG)-$(WIRESHARK_TARGET_PLATFORM)ws GeoIP-$(GEOIP_PKG)-$(WIRESHARK_TARGET_PLATFORM)ws.zip !ENDIF +!IFDEF WINSPARKLE_DIR + @$(SH) $(WIN_SETUP) "$(WIN_SETUP_OPT)" "$(WIRESHARK_LIB_DIR)" \ + . WinSparkle-$(WINSPARKLE_PKG).zip +!ENDIF !IFDEF HHC_DIR @$(SH) $(WIN_SETUP) "$(WIN_SETUP_OPT)" "$(WIRESHARK_LIB_DIR)" \ user-guide user-guide-46501.zip @@ -1015,6 +1022,7 @@ clean_setup: rm -r -f GeoIP-1.4.6-win??ws rm -r -f GeoIP-1.4.8-win??ws rm -r -f GeoIP-1.4.8-*-win??ws + rm -r -f WinSparkle-0.3-44-g2c8d9d3-win??ws rm -r -f WpdPack cd "$(MAKEDIR)" @@ -1261,6 +1269,9 @@ install-all: install-generated-files !IFDEF GEOIP_DIR xcopy "$(GEOIP_DIR)\bin\libGeoip-1.dll" $(INSTALL_DIR) /d !ENDIF +!IFDEF WINSPARKLE_DIR + xcopy "$(WINSPARKLE_DIR)\WinSparkle.dll" $(INSTALL_DIR) /d +!ENDIF cd $(INSTALL_DIR) peflags --dynamicbase=true --nxcompat=true *.dll !IF "$(GTK_INST_VERSION)" == "3.4" diff --git a/config.h.win32 b/config.h.win32 index 67d7eeec71..835d4d9df2 100644 --- a/config.h.win32 +++ b/config.h.win32 @@ -222,6 +222,9 @@ /* Define if GeoIP supports IPv6 (GeoIP 1.4.5 and later) */ @HAVE_GEOIP_V6@ +/* Define to enable WinSparkle software updates */ +@HAVE_SOFTWARE_UPDATE@ + /* Define for IPv6 */ @INET6@ diff --git a/config.nmake b/config.nmake index 3032deb05d..c07bf44a86 100644 --- a/config.nmake +++ b/config.nmake @@ -445,6 +445,13 @@ SMI_PKG=svn-40773 # GEOIP_PKG=1.4.8-2 +# +# Optional: WinSparkle, software updates +# +# Used for automatic software updates +# +WINSPARKLE_PKG=0.3-44-g2c8d9d3-win32ws + !else ##### Win64 Libraries ##### # @@ -1481,6 +1488,18 @@ GEOIP_CONFIG= GEOIP_V6_CONFIG= !ENDIF +!IFDEF WINSPARKLE_PKG +WINSPARKLE_DIR=$(WIRESHARK_LIB_DIR)\WinSparkle-$(WINSPARKLE_PKG) +WINSPARKLE_CONFIG=^#define HAVE_SOFTWARE_UPDATE 1 +WINSPARKLE_CFLAGS=/I$(WINSPARKLE_DIR) +WINSPARKLE_LIBS=$(WINSPARKLE_DIR)\WinSparkle.lib +!ELSE +WINSPARKLE_DIR= +WINSPARKLE_CONFIG= +WINSPARKLE_CFLAGS= +WINSPARKLE_LIBS= +!ENDIF + !IFDEF ENABLE_LIBWIRESHARK LIBWIRESHARK_CONFIG=^#define HAVE_LIBWIRESHARKDLL 1 # Link plugins with the import library of libwireshark.dll diff --git a/epan/prefs.c b/epan/prefs.c index 8e0c3feaa4..d8a56109d0 100644 --- a/epan/prefs.c +++ b/epan/prefs.c @@ -151,6 +151,11 @@ static enum_val_t gui_layout_content[] = { {NULL, NULL, -1} }; +static enum_val_t gui_update_channel[] = { + {"DEVELOPMENT", "DEVELOPMENT", UPDATE_CHANNEL_DEVELOPMENT}, + {"STABLE", "STABLE", UPDATE_CHANNEL_STABLE}, + {NULL, NULL, -1} + }; /* * List of all modules with preference settings. */ @@ -2067,6 +2072,16 @@ prefs_register_modules(void) prefs_register_string_preference(gui_module, "webbrowser", "The path to the webbrowser", "The path to the webbrowser (Ex: mozilla)", (const char**)(&prefs.gui_webbrowser)); + prefs_register_bool_preference(gui_module, "update.enabled", + "Check for updates", + "Check for updates (Windows only)", + &prefs.gui_update_enabled); + + prefs_register_enum_preference(gui_module, "update.channel", + "Update channel", + "The type of update to fetch", + (gint*)(void*)(&prefs.gui_update_channel), gui_version_placement_type, FALSE); + prefs_register_string_preference(gui_module, "window_title", "Custom window title", "Custom window title. (Appended to existing titles.)", (const char**)(&prefs.gui_window_title)); @@ -2641,6 +2656,9 @@ pre_init_prefs(void) prefs.gui_ask_unsaved = TRUE; prefs.gui_find_wrap = TRUE; prefs.gui_use_pref_save = FALSE; + prefs.gui_update_enabled = TRUE; + prefs.gui_update_channel = UPDATE_CHANNEL_STABLE; + prefs.gui_update_interval = 60*60*24; /* Seconds */ /* This can be g_freed, so it must be g_mallocated. */ prefs.gui_webbrowser = g_strdup(HTML_VIEWER " %s"); /* This can be g_freed, so it must be g_mallocated. */ diff --git a/epan/prefs.h b/epan/prefs.h index a2d569fadc..8249bc42ce 100644 --- a/epan/prefs.h +++ b/epan/prefs.h @@ -119,6 +119,13 @@ typedef enum { pref_current } pref_source_t; +/* + * Update channel. + */ +typedef enum { + UPDATE_CHANNEL_DEVELOPMENT, + UPDATE_CHANNEL_STABLE +} software_update_channel_e; typedef struct _e_prefs { gint pr_format; @@ -183,6 +190,9 @@ typedef struct _e_prefs { guint tap_update_interval; gboolean display_hidden_proto_items; gpointer filter_expressions; /* Actually points to &head */ + gboolean gui_update_enabled; + software_update_channel_e gui_update_channel; + gint gui_update_interval; } e_prefs; WS_VAR_IMPORT e_prefs prefs; diff --git a/packaging/nsis/Makefile.nmake b/packaging/nsis/Makefile.nmake index 881f0bccaf..fa132703e1 100644 --- a/packaging/nsis/Makefile.nmake +++ b/packaging/nsis/Makefile.nmake @@ -208,6 +208,9 @@ NSIS_FLAGS=\ !IFDEF GEOIP_DIR /DGEOIP_DIR=$(GEOIP_DIR) \ !ENDIF +!IFDEF WINSPARKLE_DIR + /DWINSPARKLE_DIR=$(WINSPARKLE_DIR) \ +!ENDIF !IFDEF HHC_DIR /DHHC_DIR="$(HHC_DIR)" \ !ENDIF diff --git a/packaging/nsis/wireshark.nsi b/packaging/nsis/wireshark.nsi index e974bb9886..d432933e1b 100644 --- a/packaging/nsis/wireshark.nsi +++ b/packaging/nsis/wireshark.nsi @@ -342,6 +342,9 @@ File "${STAGING_DIR}\libsmi-2.dll" !ifdef GEOIP_DIR File "${STAGING_DIR}\libGeoIP-1.dll" !endif +!ifdef WINSPARKLE_DIR +File "${STAGING_DIR}\WinSparkle.dll" +!endif File "${STAGING_DIR}\COPYING.txt" File "${STAGING_DIR}\NEWS.txt" File "${STAGING_DIR}\README.txt" diff --git a/tools/win32-setup.sh b/tools/win32-setup.sh index 58886a18e7..1cf97c66a6 100755 --- a/tools/win32-setup.sh +++ b/tools/win32-setup.sh @@ -4,7 +4,7 @@ # 32-bit wrapper for win-setup.sh. -export DOWNLOAD_TAG="2012-12-18" +export DOWNLOAD_TAG="2013-02-19" export WIRESHARK_TARGET_PLATFORM="win32" WIN_SETUP=`echo $0 | sed -e s/win32/win/` diff --git a/ui/Makefile.common b/ui/Makefile.common index efd5a15b34..d7d4381d5f 100644 --- a/ui/Makefile.common +++ b/ui/Makefile.common @@ -54,6 +54,7 @@ WIRESHARK_UI_SRC = \ preference_utils.c \ profile.c \ recent.c \ + software_update.c \ ssl_key_export.c \ text_import.c \ time_shift.c \ @@ -74,6 +75,7 @@ noinst_HEADERS = \ recent.h \ recent_utils.h \ simple_dialog.h \ + software_update.h \ ssl_key_export.h \ text_import.h \ text_import_scanner.h \ diff --git a/ui/Makefile.nmake b/ui/Makefile.nmake index a7d339ad25..98736423e8 100644 --- a/ui/Makefile.nmake +++ b/ui/Makefile.nmake @@ -16,7 +16,7 @@ GENERATED_CFLAGS=\ /I$(PCAP_DIR)\WPCAP\LIBPCAP /I$(PCAP_DIR)\WPCAP\LIBPCAP\bpf \ /I$(PCAP_DIR)\WPCAP\LIBPCAP\lbl \ /I$(PCAP_DIR)\include $(AIRPCAP_CFLAGS) \ - $(PORTAUDIO_CFLAGS) $(GEOIP_CFLAGS) \ + $(PORTAUDIO_CFLAGS) $(GEOIP_CFLAGS) $(WINSPARKLE_CFLAGS) \ $(HHC_CFLAGS) CFLAGS=$(WARNINGS_ARE_ERRORS) $(GENERATED_CFLAGS) diff --git a/ui/gtk/main.c b/ui/gtk/main.c index 4773863cee..acc69e4ff1 100644 --- a/ui/gtk/main.c +++ b/ui/gtk/main.c @@ -109,6 +109,7 @@ #include "ui/preference_utils.h" #include "ui/recent.h" #include "ui/recent_utils.h" +#include "ui/software_update.h" #include "ui/simple_dialog.h" #include "ui/ui_util.h" @@ -3215,6 +3216,8 @@ main(int argc, char *argv[]) gtk_iface_mon_start(); #endif + software_update_init(); + /* we'll enter the GTK loop now and hand the control over to GTK ... */ gtk_main(); /* ... back from GTK, we're going down now! */ @@ -3238,6 +3241,8 @@ main(int argc, char *argv[]) g_object_unref(theApp); #endif + software_update_cleanup(); + /* Shutdown windows sockets */ WSACleanup(); diff --git a/ui/gtk/main_menubar.c b/ui/gtk/main_menubar.c index 5c2eb91e4a..7fecaa684b 100644 --- a/ui/gtk/main_menubar.c +++ b/ui/gtk/main_menubar.c @@ -57,6 +57,7 @@ #include "ui/preference_utils.h" #include "ui/recent.h" #include "ui/simple_dialog.h" +#include "ui/software_update.h" #include "ui/ui_util.h" #include "ui/utf8_entities.h" @@ -926,6 +927,14 @@ help_menu_SampleCaptures_cb(GtkAction *action _U_, gpointer user_data _U_) topic_menu_cb( NULL/* widget_U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(ONLINEPAGE_SAMPLE_FILES)); } +#ifdef HAVE_SOFTWARE_UPDATE +static void +check_for_updates_cb(GtkAction *action _U_, gpointer user_data _U_) +{ + software_update_check(); +} +#endif /* HAVE_SOFTWARE_UPDATE */ + static const char *ui_desc_menubar = "<ui>\n" " <menubar name ='Menubar'>\n" @@ -1307,6 +1316,10 @@ static const char *ui_desc_menubar = " <separator/>\n" " <menuitem name='Wiki' action='/Help/Wiki'/>\n" " <menuitem name='SampleCaptures' action='/Help/SampleCaptures'/>\n" +#ifdef HAVE_SOFTWARE_UPDATE +" <separator/>\n" +" <menuitem name='CheckForUpdates' action='/Help/CheckForUpdates'/>\n" +#endif /* HAVE_SOFTWARE_UPDATE */ " <separator/>\n" " <menuitem name='AboutWireshark' action='/Help/AboutWireshark'/>\n" " </menu>\n" @@ -1754,10 +1767,13 @@ static const GtkActionEntry main_menu_bar_entries[] = { { "/Help/Website", GTK_STOCK_HOME, "Website", NULL, NULL, G_CALLBACK(help_menu_Website_cb) }, { "/Help/FAQs", NULL, "FAQ's", NULL, NULL, G_CALLBACK(help_menu_faq_cb) }, - { "/Help/ASK", NULL, "Ask (Q&A)", NULL, NULL, G_CALLBACK(help_menu_ask_cb) }, + { "/Help/ASK", NULL, "Ask (Q&A)", NULL, NULL, G_CALLBACK(help_menu_ask_cb) }, { "/Help/Downloads", NULL, "Downloads", NULL, NULL, G_CALLBACK(help_menu_Downloads_cb) }, { "/Help/Wiki", WIRESHARK_STOCK_WIKI, "Wiki", NULL, NULL, G_CALLBACK(help_menu_Wiki_cb) }, { "/Help/SampleCaptures", NULL, "Sample Captures", NULL, NULL, G_CALLBACK(help_menu_SampleCaptures_cb) }, +#ifdef HAVE_SOFTWARE_UPDATE + { "/Help/CheckForUpdates", NULL, "Check for Updates...", NULL, NULL, G_CALLBACK(check_for_updates_cb) }, +#endif /* HAVE_SOFTWARE_UPDATE */ { "/Help/AboutWireshark", WIRESHARK_STOCK_ABOUT, "_About Wireshark", NULL, NULL, G_CALLBACK(about_wireshark_cb) }, }; diff --git a/ui/software_update.c b/ui/software_update.c new file mode 100755 index 0000000000..7e6c366050 --- /dev/null +++ b/ui/software_update.c @@ -0,0 +1,157 @@ +/* software_update.h + * Wrappers and routines to check for software updates. + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config.h" + +#include "software_update.h" +#include "../epan/prefs.h" + +/* + * Version 0 of the update URI path has the following elements: + * - The update path prefix (fixed, "update") + * - The schema version (fixed, 0) + * - The application name (fixed, "Wireshark") + * - The application version ("<major>.<minor>.<micro>") + * - The operating system (varable, one of "windows" or "osx") + * - The architecture name (variable, one of "x86", "x86-64") + * - The locale (fixed, "en-US) + * - The update channel (variable, one of "development" or "stable") + .xml + * + * Based on https://wiki.mozilla.org/Software_Update:Checking_For_Updates + */ + +#ifdef HAVE_SOFTWARE_UPDATE +#define SU_SCHEMA_PREFIX "update" +#define SU_SCHEMA_VERSION 0 +#define SU_APPLICATION "Wireshark" +#define SU_LOCALE "en-US" +#endif /* HAVE_SOFTWARE_UPDATE */ + +#if defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32) + +#include "glib.h" + +#include <winsparkle.h> + +#define SU_OSNAME "Windows" + +static GString *update_url_str = NULL; + +static const char *get_appcast_update_url(software_update_channel_e chan) { + const char *chan_name; + const char *arch = "x86"; + + if (!update_url_str) { + update_url_str = g_string_new(""); + } + +#if 0 + /* XXX Add WOW64 checks similar to version_info.c? */ + if (sizeof(arch) != 4) { + arch = "x86-64"; + } +#endif + + 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, + SU_APPLICATION, + VERSION, + SU_OSNAME, + arch, + chan_name); + return update_url_str->str; +} + +/** Initialize software updates. + */ +void +software_update_init(void) { + const char *update_url = get_appcast_update_url(UPDATE_CHANNEL_DEVELOPMENT); + + 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); + win_sparkle_init(); +} + +/** Force a software update check. + */ +void +software_update_check(void) { + win_sparkle_check_update_with_ui(); +} + +/** Clean up software update checking. + * + * Does nothing on platforms that don't support software updates. + */ +extern void software_update_cleanup(void) { + win_sparkle_cleanup(); +} + +#else /* defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32) */ + +/** Initialize software updates. + */ +void +software_update_init(void) { +} + +/** Force a software update check. + */ +void +software_update_check(void) { +} + +/** Clean up software update checking. + * + * Does nothing on platforms that don't support software updates. + */ +extern void software_update_cleanup(void) { +} + +#endif /* defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32) */ + +/* + * Editor modelines + * + * Local Variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * ex: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ + diff --git a/ui/software_update.h b/ui/software_update.h new file mode 100755 index 0000000000..b78ee00663 --- /dev/null +++ b/ui/software_update.h @@ -0,0 +1,68 @@ +/* software_update.h + * Wrappers and routines to check for software updates. + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __SOFTWARE_UPDATE_H__ +#define __SOFTWARE_UPDATE_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** Initialize software updates. + * + * Does nothing on platforms that don't support software updates. + */ +extern void software_update_init(void); + +/** Force a software update check. + * + * Does nothing on platforms that don't support software updates. + */ +extern void software_update_check(void); + +/** Clean up software update checking. + * + * Does nothing on platforms that don't support software updates. + */ +extern void software_update_cleanup(void); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __SOFTWARE_UPDATE_H__ */ + +/* + * Editor modelines + * + * Local Variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * ex: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ |