nexmon – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /* alert_box.c
2 * Routines to put up various "standard" alert boxes used in multiple
3 * places
4 *
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 */
23  
24 #include "config.h"
25  
26 #include <string.h>
27  
28  
29 #include <wiretap/wtap.h>
30 #include <wsutil/filesystem.h>
31  
32 #include "ui/alert_box.h"
33  
34 #include "ui/simple_dialog.h"
35  
36 /*
37 * Alert box for general errors.
38 */
39 void
40 failure_alert_box(const char *msg_format, ...)
41 {
42 va_list ap;
43  
44 va_start(ap, msg_format);
45 vsimple_error_message_box(msg_format, ap);
46 va_end(ap);
47 }
48  
49 void
50 vfailure_alert_box(const char *msg_format, va_list ap)
51 {
52 vsimple_error_message_box(msg_format, ap);
53 }
54  
55 /*
56 * Alert box for a failed attempt to open or create a file.
57 * "err" is assumed to be a UNIX-style errno; "for_writing" is TRUE if
58 * the file is being opened for writing and FALSE if it's being opened
59 * for reading.
60 *
61 * XXX - add explanatory secondary text for at least some of the errors;
62 * various HIGs suggest that you should, for example, suggest that the
63 * user remove files if the file system is full. Perhaps that's because
64 * they're providing guidelines for people less sophisticated than the
65 * typical Wireshark user is, but....
66 */
67 void
68 open_failure_alert_box(const char *filename, int err, gboolean for_writing)
69 {
70 gchar *display_basename;
71  
72 display_basename = g_filename_display_basename(filename);
73 simple_message_box(ESD_TYPE_ERROR, NULL, NULL,
74 file_open_error_message(err, for_writing),
75 display_basename);
76 g_free(display_basename);
77 }
78  
79 /*
80 * Alert box for a failed attempt to read a file.
81 * "err" is assumed to be a UNIX-style errno.
82 */
83 void
84 read_failure_alert_box(const char *filename, int err)
85 {
86 gchar *display_basename;
87  
88 display_basename = g_filename_display_basename(filename);
89 simple_message_box(ESD_TYPE_ERROR, NULL, NULL,
90 "An error occurred while reading from the file \"%s\": %s.",
91 display_basename, g_strerror(err));
92 g_free(display_basename);
93 }
94  
95 /*
96 * Alert box for a failed attempt to write to a file.
97 * "err" is assumed to be a UNIX-style errno if positive and a
98 * Wiretap error if negative.
99 *
100 * XXX - add explanatory secondary text for at least some of the errors;
101 * various HIGs suggest that you should, for example, suggest that the
102 * user remove files if the file system is full. Perhaps that's because
103 * they're providing guidelines for people less sophisticated than the
104 * typical Wireshark user is, but....
105 */
106 void
107 write_failure_alert_box(const char *filename, int err)
108 {
109 gchar *display_basename;
110  
111 display_basename = g_filename_display_basename(filename);
112 if (err < 0) {
113 switch (err) {
114  
115 case WTAP_ERR_SHORT_WRITE:
116 simple_message_box(ESD_TYPE_ERROR, NULL, NULL,
117 "A full write couldn't be done to the file \"%s\".",
118 display_basename);
119 break;
120  
121 default:
122 simple_message_box(ESD_TYPE_ERROR, NULL, NULL,
123 "An error occurred while writing to the file \"%s\": %s.",
124 display_basename, wtap_strerror(err));
125 break;
126 }
127 } else {
128 simple_message_box(ESD_TYPE_ERROR, NULL, NULL,
129 file_write_error_message(err), display_basename);
130 }
131 g_free(display_basename);
132 }
133  
134 /*
135 * Editor modelines
136 *
137 * Local Variables:
138 * c-basic-offset: 4
139 * tab-width: 8
140 * indent-tabs-mode: nil
141 * End:
142 *
143 * ex: set shiftwidth=4 tabstop=8 expandtab:
144 * :indentSize=4:tabSize=8:noTabs=true:
145 */