packet-smb2: fix lease epoch fields
[metze/wireshark/wip.git] / ui / software_update.c
1 /* software_update.h
2  * Wrappers and routines to check for software updates.
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
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.
14  *
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.
19  *
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.
23  */
24
25 #include "config.h"
26
27 #include "software_update.h"
28 #include "../epan/prefs.h"
29
30 /*
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
40  *
41  * Based on https://wiki.mozilla.org/Software_Update:Checking_For_Updates
42  */
43
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 */
50
51 #if defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32)
52
53 #include "glib.h"
54
55 #include <winsparkle.h>
56
57 #define SU_OSNAME "Windows"
58
59 static GString *update_url_str = NULL;
60
61 static const char *get_appcast_update_url(software_update_channel_e chan) {
62     const char *chan_name;
63     const char *arch = "x86";
64
65     if (!update_url_str) {
66         update_url_str = g_string_new("");
67     }
68
69     /* XXX Add WOW64 checks similar to version_info.c? */
70     if (sizeof(arch) != 4) {
71         arch = "x86-64";
72     }
73
74     switch (chan) {
75         case UPDATE_CHANNEL_DEVELOPMENT:
76             chan_name = "development";
77             break;
78         default:
79             chan_name = "stable";
80             break;
81     }
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;
91 }
92
93 /** Initialize software updates.
94  */
95 void
96 software_update_init(void) {
97     const char *update_url = get_appcast_update_url(prefs.gui_update_channel);
98
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();
104 }
105
106 /** Force a software update check.
107  */
108 void
109 software_update_check(void) {
110     win_sparkle_check_update_with_ui();
111 }
112
113 /** Clean up software update checking.
114  *
115  * Does nothing on platforms that don't support software updates.
116  */
117 extern void software_update_cleanup(void) {
118     win_sparkle_cleanup();
119 }
120
121 #else /* defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32) */
122
123 /** Initialize software updates.
124  */
125 void
126 software_update_init(void) {
127 }
128
129 /** Force a software update check.
130  */
131 void
132 software_update_check(void) {
133 }
134
135 /** Clean up software update checking.
136  *
137  * Does nothing on platforms that don't support software updates.
138  */
139 extern void software_update_cleanup(void) {
140 }
141
142 #endif /* defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32) */
143
144 /*
145  * Editor modelines
146  *
147  * Local Variables:
148  * c-basic-offset: 4
149  * tab-width: 8
150  * indent-tabs-mode: nil
151  * End:
152  *
153  * ex: set shiftwidth=4 tabstop=8 expandtab:
154  * :indentSize=4:tabSize=8:noTabs=true:
155  */
156