summaryrefslogtreecommitdiffstats
path: root/seaudit/toplevel.h
blob: 448c8addf41b12d0f827e7500b77888357d70267 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
/**
 *  @file
 *  Declaration of the main toplevel window for seaudit.
 *
 *  @author Jeremy A. Mowery jmowery@tresys.com
 *  @author Jason Tang jtang@tresys.com
 *  @author Jeremy Solt jsolt@tresys.com
 *
 *  Copyright (C) 2003-2007 Tresys Technology, LLC
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef TOPLEVEL_H
#define TOPLEVEL_H

typedef struct toplevel toplevel_t;

#include "progress.h"
#include "seaudit.h"
#include <apol/policy-path.h>
#include <gtk/gtk.h>
#include <seaudit/message.h>

/**
 * Allocate and return an instance of the toplevel window object.
 * This will create the window, set up the menus and icons, create an
 * empty notebook, then display the window.
 *
 * @param s Main seaudit object that will control the toplevel.
 *
 * @return An initialized toplevel object, or NULL upon error.  The
 * caller must call toplevel_destroy() afterwards.
 */
toplevel_t *toplevel_create(seaudit_t * s);

/**
 * Destroy the toplevel window.  This function will recursively
 * destroy all other windows.  This does nothing if the pointer is set
 * to NULL.
 *
 * @param top Reference to a toplevel object.  Afterwards the pointer
 * will be set to NULL.
 */
void toplevel_destroy(toplevel_t ** top);

/**
 * Open a log file, destroying any existing logs and views first.
 * Afterwards, create a new view for the log.
 *
 * @param top Toplevel object, used for UI control.
 * @param filename Name of the log to open.
 */
void toplevel_open_log(toplevel_t * top, const char *filename);

/**
 * Open a policy file, destroying any existing policies upon success.
 *
 * @param top Toplevel object, used for UI control.
 * @param path Path to the policy to open.  This function takes
 * ownership of this object.
 *
 * @return 0 on successful open, < 0 on error.
 */
int toplevel_open_policy(toplevel_t * top, apol_policy_path_t * path);

/**
 * Update the status bar to show the current policy, number of log
 * messages in the current view, range of messages in current view,
 * and monitor status.
 *
 * @param top Toplevel whose status bar to update.
 */
void toplevel_update_status_bar(toplevel_t * top);

/**
 * Update the menu items whenever a message is selected/deselected.
 * Certain commands are legal only when one or more messages are
 * selected.
 *
 * @param top Toplevel whose menu to update.
 */
void toplevel_update_selection_menu_item(toplevel_t * top);

/**
 * Update the tab names for all views.
 *
 * @param top Toplevel whose notebook tabs to update.
 */
void toplevel_update_tabs(toplevel_t * top);

/**
 * Return the current preferences object for the toplevel object.
 *
 * @param top Toplevel containing preferences.
 *
 * @return Pointer to a preferences object.  Do not free() this pointer.
 */
preferences_t *toplevel_get_prefs(toplevel_t * top);

/**
 * Return a seaudit_log_t object used for error reporting by
 * libseaudit.
 *
 * @param top Toplevel containing seaudit log object.
 *
 * @return libseaudit reporting object, or NULL if no log exists yet.
 * Treat this as a const pointer.
 */
seaudit_log_t *toplevel_get_log(toplevel_t * top);

/**
 * Return a vector of strings corresponding to all users found within
 * the current log file.  The vector will be sorted alphabetically.
 *
 * @param top Toplevel containing seaudit log object.
 *
 * @return Vector of sorted users, or NULL if no log is loaded.  The
 * caller must call apol_vector_destroy() upon the return value.
 */
apol_vector_t *toplevel_get_log_users(toplevel_t * top);

/**
 * Return a vector of strings corresponding to all roles found within
 * the current log file.  The vector will be sorted alphabetically.
 *
 * @param top Toplevel containing seaudit log object.
 *
 * @return Vector of sorted roles, or NULL if no log is loaded.  The
 * caller must call apol_vector_destroy() upon the return value.
 */
apol_vector_t *toplevel_get_log_roles(toplevel_t * top);

/**
 * Return a vector of strings corresponding to all types found within
 * the current log file.  The vector will be sorted alphabetically.
 *
 * @param top Toplevel containing seaudit log object.
 *
 * @return Vector of sorted types, or NULL if no log is loaded.  The
 * caller must call apol_vector_destroy() upon the return value.
 */
apol_vector_t *toplevel_get_log_types(toplevel_t * top);

/**
 * Return a vector of strings corresponding to all mls
 * levels found within the current log file.  
 * The vector will be sorted alphabetically.
 *
 * @param top Toplevel containing seaudit log object.
 *
 * @return Vector of sorted types, or NULL if no log is loaded.  The
 * caller must call apol_vector_destroy() upon the return value.
 */
apol_vector_t *toplevel_get_log_mls_lvl(toplevel_t * top);

/**
 * Return a vector of strings corresponding to all mls
 * clearance found within the current log file.  
 * The vector will be sorted alphabetically.
 *
 * @param top Toplevel containing seaudit log object.
 *
 * @return Vector of sorted types, or NULL if no log is loaded.  The
 * caller must call apol_vector_destroy() upon the return value.
 */
apol_vector_t *toplevel_get_log_mls_clr(toplevel_t * top);

/**
 * Return a vector of strings corresponding to all object classes
 * found within the current log file.  The vector will be sorted
 * alphabetically.
 *
 * @param top Toplevel containing seaudit log object.
 *
 * @return Vector of sorted classes, or NULL if no log is loaded.  The
 * caller must call apol_vector_destroy() upon the return value.
 */
apol_vector_t *toplevel_get_log_classes(toplevel_t * top);

/**
 * Return the currently loaded policy.
 *
 * @param top Toplevel containing policy.
 *
 * @return Current policy, or NULL if no policy is loaded yet.  Treat
 * this as a const pointer.
 */
apol_policy_t *toplevel_get_policy(toplevel_t * top);

/**
 * Return the filename containing seaudit's glade file.
 *
 * @param top Toplevel containing glade XML declarations.
 *
 * @return Name of the glade file.  Do not modify this string.
 */
char *toplevel_get_glade_xml(toplevel_t * top);

/**
 * Return the progress object, so that sub-windows may also show the
 * threaded progress object.
 *
 * @param top Toplevel containing progress object.
 *
 * @return Progress object.  Do not free() this pointer.
 */
progress_t *toplevel_get_progress(toplevel_t * top);

/**
 * Return the main application window.  Sub-windows should be set
 * transient to this window.
 *
 * @param top Toplevel containing main window.
 *
 * @return Main window.
 */
GtkWindow *toplevel_get_window(toplevel_t * top);

/**
 * (Re)open a dialog that allows the user to search for TE rules in
 * the currently opened policy.  If message is not NULL then set the
 * query's initial parameters to the message's source type, target
 * type, and object class.
 *
 * @param top Toplevel containing policy.
 * @param message If non-NULL, the initial parameters for query.
 */
void toplevel_find_terules(toplevel_t * top, seaudit_message_t * message);

/**
 * Pop-up an error dialog with a line of text and wait for the user to
 * dismiss the dialog.
 *
 * @param top Toplevel window; this message dialog will be centered
 * upon it.
 * @param format Format string to print, using syntax of printf(3).
 */
void toplevel_ERR(toplevel_t * top, const char *format, ...) __attribute__ ((format(printf, 2, 3)));

/**
 * Pop-up a warning dialog with a line of text and wait for the user
 * to dismiss the dialog.
 *
 * @param top Toplevel window; this message dialog will be centered
 * upon it.
 * @param format Format string to print, using syntax of printf(3).
 */
void toplevel_WARN(toplevel_t * top, const char *format, ...) __attribute__ ((format(printf, 2, 3)));

#endif