summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2013-02-19 22:21:17 +0000
committerGerald Combs <gerald@wireshark.org>2013-02-19 22:21:17 +0000
commite48236a43635f9f0e695a25199bf3ab959774590 (patch)
treec6438499bad89c7f47eda54dc4e5c9bd2bcadb89 /ui
parent9736ff7cb5f2ba971202a3472707aa96380d16de (diff)
downloadwireshark-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
Diffstat (limited to 'ui')
-rw-r--r--ui/Makefile.common2
-rw-r--r--ui/Makefile.nmake2
-rw-r--r--ui/gtk/main.c5
-rw-r--r--ui/gtk/main_menubar.c18
-rwxr-xr-xui/software_update.c157
-rwxr-xr-xui/software_update.h68
6 files changed, 250 insertions, 2 deletions
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:
+ */