sec_vt_header: dissect cont_id + opnum
[wireshark-wip.git] / ui / software_update.c
blobb027ed0f49c7761d101290d5458bb6077a4848a4
1 /* software_update.h
2 * Wrappers and routines to check for software updates.
4 * $Id$
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include "config.h"
27 #include "software_update.h"
28 #include "../epan/prefs.h"
31 * Version 0 of the update URI path has the following elements:
32 * - The update path prefix (fixed, "update")
33 * - The schema version (fixed, 0)
34 * - The application name (fixed, "Wireshark")
35 * - The application version ("<major>.<minor>.<micro>")
36 * - The operating system (varable, one of "windows" or "osx")
37 * - The architecture name (variable, one of "x86", "x86-64")
38 * - The locale (fixed, "en-US)
39 * - The update channel (variable, one of "development" or "stable") + .xml
41 * Based on https://wiki.mozilla.org/Software_Update:Checking_For_Updates
44 #ifdef HAVE_SOFTWARE_UPDATE
45 #define SU_SCHEMA_PREFIX "update"
46 #define SU_SCHEMA_VERSION 0
47 #define SU_APPLICATION "Wireshark"
48 #define SU_LOCALE "en-US"
49 #endif /* HAVE_SOFTWARE_UPDATE */
51 #if defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32)
53 #include "glib.h"
55 #include <winsparkle.h>
57 #define SU_OSNAME "Windows"
59 static GString *update_url_str = NULL;
61 static const char *get_appcast_update_url(software_update_channel_e chan) {
62 const char *chan_name;
63 const char *arch = "x86";
65 if (!update_url_str) {
66 update_url_str = g_string_new("");
69 /* XXX Add WOW64 checks similar to version_info.c? */
70 if (sizeof(arch) != 4) {
71 arch = "x86-64";
74 switch (chan) {
75 case UPDATE_CHANNEL_DEVELOPMENT:
76 chan_name = "development";
77 break;
78 default:
79 chan_name = "stable";
80 break;
82 g_string_printf(update_url_str, "https://www.wireshark.org/%s/%u/%s/%s/%s/%s/en-US/%s.xml",
83 SU_SCHEMA_PREFIX,
84 SU_SCHEMA_VERSION,
85 SU_APPLICATION,
86 VERSION,
87 SU_OSNAME,
88 arch,
89 chan_name);
90 return update_url_str->str;
93 /** Initialize software updates.
95 void
96 software_update_init(void) {
97 const char *update_url = get_appcast_update_url(prefs.gui_update_channel);
99 win_sparkle_set_registry_path("Software\\Wireshark\\WinSparkle Settings");
100 win_sparkle_set_appcast_url(update_url);
101 win_sparkle_set_automatic_check_for_updates(prefs.gui_update_enabled ? 1 : 0);
102 win_sparkle_set_update_check_interval(prefs.gui_update_interval);
103 win_sparkle_init();
106 /** Force a software update check.
108 void
109 software_update_check(void) {
110 win_sparkle_check_update_with_ui();
113 /** Clean up software update checking.
115 * Does nothing on platforms that don't support software updates.
117 extern void software_update_cleanup(void) {
118 win_sparkle_cleanup();
121 #else /* defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32) */
123 /** Initialize software updates.
125 void
126 software_update_init(void) {
129 /** Force a software update check.
131 void
132 software_update_check(void) {
135 /** Clean up software update checking.
137 * Does nothing on platforms that don't support software updates.
139 extern void software_update_cleanup(void) {
142 #endif /* defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32) */
145 * Editor modelines
147 * Local Variables:
148 * c-basic-offset: 4
149 * tab-width: 8
150 * indent-tabs-mode: nil
151 * End:
153 * ex: set shiftwidth=4 tabstop=8 expandtab:
154 * :indentSize=4:tabSize=8:noTabs=true: