5 * Laurent Deniel <laurent.deniel@free.fr>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 2000 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
35 #include "epan/filesystem.h"
36 #include <epan/prefs.h>
38 #include "../simple_dialog.h"
40 #include "gtk/help_dlg.h"
41 #include "gtk/text_page_utils.h"
42 #include "gtk/gtkglobals.h"
43 #include "gtk/gui_utils.h"
44 #include "gtk/dlg_utils.h"
45 #include "gtk/webbrowser.h"
50 #include <wsutil/unicode-utils.h>
54 #define HELP_DIR "help"
57 #define NOTEBOOK_KEY "notebook_key"
60 * Keep a static pointer to the current "Help" window, if any, so that
61 * if somebody tries to do "Help->Help" while there's already a
62 * "Help" window up, we just pop up the existing one, rather than
65 static GtkWidget *help_w = NULL;
68 * Keep a list of text widgets and corresponding file names as well
69 * (for text format changes).
77 static GSList *help_text_pages = NULL;
81 * Open the help dialog and show a specific HTML help page.
83 void help_topic_html(const gchar *topic) {
86 /* try to open local .chm file */
90 url = g_string_new("");
92 g_string_append_printf(url, "%s\\user-guide.chm::/wsug_chm/%s>Wireshark Help",
93 get_datafile_dir(), topic);
99 g_string_free(url, TRUE /* free_segment */);
101 /* if the .chm file could be opened, stop here */
107 url = g_string_new("");
110 if (g_file_test(DOC_DIR "/guides/wsug_html_chunked", G_FILE_TEST_IS_DIR)) {
111 /* try to open the HTML page from wireshark.org instead */
112 g_string_append_printf(url, "file://" DOC_DIR "/guides/wsug_html_chunked/%s", topic);
114 #endif /* ifdef DOC_DIR */
115 /* try to open the HTML page from wireshark.org instead */
116 g_string_append_printf(url, "http://www.wireshark.org/docs/wsug_html_chunked/%s", topic);
119 #endif /* ifdef DOC_DIR */
121 browser_open_url(url->str);
123 g_string_free(url, TRUE /* free_segment */);
128 * Redraw all help pages, to use a new font.
130 void help_redraw(void)
132 GSList *help_page_ent;
133 help_page_t *help_page;
135 if (help_w != NULL) {
136 for (help_page_ent = help_text_pages; help_page_ent != NULL;
137 help_page_ent = g_slist_next(help_page_ent))
139 help_page = (help_page_t *)help_page_ent->data;
140 text_page_redraw(help_page->page, help_page->pathname);
147 topic_online_url(topic_action_e action)
150 case(ONLINEPAGE_HOME):
151 return "http://www.wireshark.org";
153 case(ONLINEPAGE_WIKI):
154 return "http://wiki.wireshark.org";
156 case(ONLINEPAGE_DOWNLOAD):
157 return "http://www.wireshark.org/download.html";
159 case(ONLINEPAGE_USERGUIDE):
160 return "http://www.wireshark.org/docs/wsug_html_chunked/";
162 case(ONLINEPAGE_FAQ):
163 return "http://www.wireshark.org/faq.html";
165 case(ONLINEPAGE_SAMPLE_FILES):
166 return "http://wiki.wireshark.org/SampleCaptures";
168 case(ONLINEPAGE_CAPTURE_SETUP):
169 return "http://wiki.wireshark.org/CaptureSetup";
171 case(ONLINEPAGE_NETWORK_MEDIA):
172 return "http://wiki.wireshark.org/CaptureSetup/NetworkMedia";
174 case(ONLINEPAGE_SAMPLE_CAPTURES):
175 return "http://wiki.wireshark.org/SampleCaptures";
177 case(ONLINEPAGE_SECURITY):
178 return "http://wiki.wireshark.org/Security";
180 case(ONLINEPAGE_CHIMNEY):
181 return "http://wiki.wireshark.org/CaptureSetup/Offloading#chimney";
190 topic_action(topic_action_e action)
192 const char *online_url;
195 /* pages online at www.wireshark.org */
196 online_url = topic_online_url(action);
197 if(online_url != NULL) {
198 browser_open_url (online_url);
203 /* local manual pages */
204 case(LOCALPAGE_MAN_WIRESHARK):
205 browser_open_data_file("wireshark.html");
207 case(LOCALPAGE_MAN_WIRESHARK_FILTER):
208 browser_open_data_file("wireshark-filter.html");
210 case(LOCALPAGE_MAN_TSHARK):
211 browser_open_data_file("tshark.html");
213 case(LOCALPAGE_MAN_RAWSHARK):
214 browser_open_data_file("rawshark.html");
216 case(LOCALPAGE_MAN_DUMPCAP):
217 browser_open_data_file("dumpcap.html");
219 case(LOCALPAGE_MAN_MERGECAP):
220 browser_open_data_file("mergecap.html");
222 case(LOCALPAGE_MAN_EDITCAP):
223 browser_open_data_file("editcap.html");
225 case(LOCALPAGE_MAN_TEXT2PCAP):
226 browser_open_data_file("text2pcap.html");
229 /* local help pages (User's Guide) */
231 help_topic_html( "index.html");
233 case(HELP_CAPTURE_OPTIONS_DIALOG):
234 help_topic_html("ChCapCaptureOptions.html");
236 case(HELP_CAPTURE_FILTERS_DIALOG):
237 help_topic_html("ChWorkDefineFilterSection.html");
239 case(HELP_DISPLAY_FILTERS_DIALOG):
240 help_topic_html("ChWorkDefineFilterSection.html");
242 case(HELP_COLORING_RULES_DIALOG):
243 help_topic_html("ChCustColorizationSection.html");
245 case(HELP_CONFIG_PROFILES_DIALOG):
246 help_topic_html("ChCustConfigProfilesSection.html");
248 case (HELP_MANUAL_ADDR_RESOLVE_DIALOG):
249 help_topic_html("ChManualAddressResolveSection.html");
251 case(HELP_PRINT_DIALOG):
252 help_topic_html("ChIOPrintSection.html");
254 case(HELP_FIND_DIALOG):
255 help_topic_html("ChWorkFindPacketSection.html");
257 case(HELP_FIREWALL_DIALOG):
258 help_topic_html("ChUseToolsMenuSection.html");
260 case(HELP_GOTO_DIALOG):
261 help_topic_html("ChWorkGoToPacketSection.html");
263 case(HELP_CAPTURE_INTERFACES_DIALOG):
264 help_topic_html("ChCapInterfaceSection.html");
266 case(HELP_CAPTURE_INFO_DIALOG):
267 help_topic_html("ChCapRunningSection.html");
269 case(HELP_ENABLED_PROTOCOLS_DIALOG):
270 help_topic_html("ChCustProtocolDissectionSection.html");
272 case(HELP_DECODE_AS_DIALOG):
273 help_topic_html("ChCustProtocolDissectionSection.html");
275 case(HELP_DECODE_AS_SHOW_DIALOG):
276 help_topic_html("ChCustProtocolDissectionSection.html");
278 case(HELP_FOLLOW_STREAM_DIALOG):
279 help_topic_html("ChAdvFollowTCPSection.html");
281 case(HELP_EXPERT_INFO_DIALOG):
282 help_topic_html("ChAdvExpert.html");
284 case(HELP_STATS_SUMMARY_DIALOG):
285 help_topic_html("ChStatSummary.html");
287 case(HELP_STATS_PROTO_HIERARCHY_DIALOG):
288 help_topic_html("ChStatHierarchy.html");
290 case(HELP_STATS_ENDPOINTS_DIALOG):
291 help_topic_html("ChStatEndpoints.html");
293 case(HELP_STATS_CONVERSATIONS_DIALOG):
294 help_topic_html("ChStatConversations.html");
296 case(HELP_STATS_IO_GRAPH_DIALOG):
297 help_topic_html("ChStatIOGraphs.html");
299 case(HELP_STATS_COMPARE_FILES_DIALOG):
300 help_topic_html("ChStatCompareCaptureFiles.html");
302 case(HELP_STATS_LTE_MAC_TRAFFIC_DIALOG):
303 help_topic_html("ChTelLTEMACTraffic.html");
305 case(HELP_STATS_LTE_RLC_TRAFFIC_DIALOG):
306 help_topic_html("ChTelLTERLCTraffic.html");
308 case(HELP_STATS_WLAN_TRAFFIC_DIALOG):
309 help_topic_html("ChStatWLANTraffic.html");
311 case(HELP_FILESET_DIALOG):
312 help_topic_html("ChIOFileSetSection.html");
314 case(HELP_CAPTURE_INTERFACE_OPTIONS_DIALOG):
315 help_topic_html("ChCustPreferencesSection.html#ChCustInterfaceOptionsSection");
317 case(HELP_CAPTURE_INTERFACES_DETAILS_DIALOG):
318 help_topic_html("ChCapInterfaceDetailsSection.html");
320 case(HELP_PREFERENCES_DIALOG):
321 help_topic_html("ChCustPreferencesSection.html");
323 case(HELP_EXPORT_FILE_DIALOG):
324 case(HELP_EXPORT_FILE_WIN32_DIALOG):
325 help_topic_html("ChIOExportSection.html");
327 case(HELP_EXPORT_BYTES_DIALOG):
328 case(HELP_EXPORT_BYTES_WIN32_DIALOG):
329 help_topic_html("ChIOExportSection.html#ChIOExportSelectedDialog");
331 case(HELP_EXPORT_OBJECT_LIST):
332 help_topic_html("ChIOExportSection.html#ChIOExportObjectsDialog");
334 case(HELP_OPEN_DIALOG):
335 case(HELP_OPEN_WIN32_DIALOG):
336 help_topic_html("ChIOOpenSection.html");
338 case(HELP_MERGE_DIALOG):
339 case(HELP_MERGE_WIN32_DIALOG):
340 help_topic_html("ChIOMergeSection.html");
342 case(HELP_IMPORT_DIALOG):
343 help_topic_html("ChIOImportSection.html");
345 case(HELP_SAVE_DIALOG):
346 case(HELP_SAVE_WIN32_DIALOG):
347 help_topic_html("ChIOSaveSection.html");
349 case(HELP_TIME_SHIFT_DIALOG):
350 help_topic_html("ChWorkShiftTimePacketSection.html");
352 case(HELP_FILTER_SAVE_DIALOG):
353 help_topic_html("ChWorkFilterSaveSection.html");
357 g_assert_not_reached();
363 topic_cb(GtkWidget *w _U_, topic_action_e action)
365 topic_action(action);
370 topic_menu_cb(GtkWidget *w _U_, GdkEventButton *event _U_, gpointer user_data)
372 topic_action((topic_action_e)GPOINTER_TO_INT(user_data));