nexmon – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* software_update.h |
2 | * Wrappers and routines to check for software updates. |
||
3 | * |
||
4 | * Wireshark - Network traffic analyzer |
||
5 | * By Gerald Combs <gerald@wireshark.org> |
||
6 | * Copyright 1998 Gerald Combs |
||
7 | * |
||
8 | * This program is free software; you can redistribute it and/or |
||
9 | * modify it under the terms of the GNU General Public License |
||
10 | * as published by the Free Software Foundation; either version 2 |
||
11 | * of the License, or (at your option) any later version. |
||
12 | * |
||
13 | * This program is distributed in the hope that it will be useful, |
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
16 | * GNU General Public License for more details. |
||
17 | * |
||
18 | * You should have received a copy of the GNU General Public License |
||
19 | * along with this program; if not, write to the Free Software |
||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||
21 | */ |
||
22 | |||
23 | #include "config.h" |
||
24 | |||
25 | #include "software_update.h" |
||
26 | #include "../epan/prefs.h" |
||
27 | |||
28 | /* |
||
29 | * Version 0 of the update URI path has the following elements: |
||
30 | * - The update path prefix (fixed, "update") |
||
31 | * - The schema version (fixed, 0) |
||
32 | * - The application name (fixed, "Wireshark") |
||
33 | * - The application version ("<major>.<minor>.<micro>") |
||
34 | * - The operating system (varable, one of "windows" or "osx") |
||
35 | * - The architecture name (variable, one of "x86", "x86-64") |
||
36 | * - The locale (fixed, "en-US) |
||
37 | * - The update channel (variable, one of "development" or "stable") + .xml |
||
38 | * |
||
39 | * Based on https://wiki.mozilla.org/Software_Update:Checking_For_Updates |
||
40 | */ |
||
41 | |||
42 | #ifdef HAVE_SOFTWARE_UPDATE |
||
43 | #define SU_SCHEMA_PREFIX "update" |
||
44 | #define SU_SCHEMA_VERSION 0 |
||
45 | #define SU_APPLICATION "Wireshark" |
||
46 | #define SU_LOCALE "en-US" |
||
47 | #endif /* HAVE_SOFTWARE_UPDATE */ |
||
48 | |||
49 | #if defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32) |
||
50 | |||
51 | #include "glib.h" |
||
52 | |||
53 | #include <winsparkle.h> |
||
54 | |||
55 | #define SU_OSNAME "Windows" |
||
56 | |||
57 | static GString *update_url_str = NULL; |
||
58 | |||
59 | static const char *get_appcast_update_url(software_update_channel_e chan) { |
||
60 | const char *chan_name; |
||
61 | const char *arch = "x86"; |
||
62 | |||
63 | if (!update_url_str) { |
||
64 | update_url_str = g_string_new(""); |
||
65 | } |
||
66 | |||
67 | /* XXX Add WOW64 checks similar to version_info.c? */ |
||
68 | if (sizeof(arch) != 4) { |
||
69 | arch = "x86-64"; |
||
70 | } |
||
71 | |||
72 | switch (chan) { |
||
73 | case UPDATE_CHANNEL_DEVELOPMENT: |
||
74 | chan_name = "development"; |
||
75 | break; |
||
76 | default: |
||
77 | chan_name = "stable"; |
||
78 | break; |
||
79 | } |
||
80 | g_string_printf(update_url_str, "https://www.wireshark.org/%s/%u/%s/%s/%s/%s/en-US/%s.xml", |
||
81 | SU_SCHEMA_PREFIX, |
||
82 | SU_SCHEMA_VERSION, |
||
83 | SU_APPLICATION, |
||
84 | VERSION, |
||
85 | SU_OSNAME, |
||
86 | arch, |
||
87 | chan_name); |
||
88 | return update_url_str->str; |
||
89 | } |
||
90 | |||
91 | /** Initialize software updates. |
||
92 | */ |
||
93 | void |
||
94 | software_update_init(void) { |
||
95 | const char *update_url = get_appcast_update_url(prefs.gui_update_channel); |
||
96 | |||
97 | /* |
||
98 | * According to the WinSparkle 0.5 documentation these must be called |
||
99 | * once, before win_sparkle_init. We can't update them dynamically when |
||
100 | * our preferences change. |
||
101 | */ |
||
102 | win_sparkle_set_registry_path("Software\\Wireshark\\WinSparkle Settings"); |
||
103 | win_sparkle_set_appcast_url(update_url); |
||
104 | win_sparkle_set_automatic_check_for_updates(prefs.gui_update_enabled ? 1 : 0); |
||
105 | win_sparkle_set_update_check_interval(prefs.gui_update_interval); |
||
106 | /* Todo: Fix bugs 9687 and 12989. |
||
107 | * win_sparkle_set_can_shutdown_callback(...); |
||
108 | * win_sparkle_set_shutdown_request_callback(...); |
||
109 | */ |
||
110 | win_sparkle_init(); |
||
111 | } |
||
112 | |||
113 | /** Force a software update check. |
||
114 | */ |
||
115 | void |
||
116 | software_update_check(void) { |
||
117 | win_sparkle_check_update_with_ui(); |
||
118 | } |
||
119 | |||
120 | /** Clean up software update checking. |
||
121 | * |
||
122 | * Does nothing on platforms that don't support software updates. |
||
123 | */ |
||
124 | extern void software_update_cleanup(void) { |
||
125 | win_sparkle_cleanup(); |
||
126 | } |
||
127 | |||
128 | #else /* defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32) */ |
||
129 | |||
130 | /** Initialize software updates. |
||
131 | */ |
||
132 | void |
||
133 | software_update_init(void) { |
||
134 | } |
||
135 | |||
136 | /** Force a software update check. |
||
137 | */ |
||
138 | void |
||
139 | software_update_check(void) { |
||
140 | } |
||
141 | |||
142 | /** Clean up software update checking. |
||
143 | * |
||
144 | * Does nothing on platforms that don't support software updates. |
||
145 | */ |
||
146 | extern void software_update_cleanup(void) { |
||
147 | } |
||
148 | |||
149 | #endif /* defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32) */ |
||
150 | |||
151 | /* |
||
152 | * Editor modelines |
||
153 | * |
||
154 | * Local Variables: |
||
155 | * c-basic-offset: 4 |
||
156 | * tab-width: 8 |
||
157 | * indent-tabs-mode: nil |
||
158 | * End: |
||
159 | * |
||
160 | * ex: set shiftwidth=4 tabstop=8 expandtab: |
||
161 | * :indentSize=4:tabSize=8:noTabs=true: |
||
162 | */ |
||
163 |