libreport 2.13.1
A tool to inform users about various problems on the running system
event_config.h
1/*
2 Copyright (C) 2011 ABRT team
3 Copyright (C) 2010 RedHat Inc
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18*/
19#ifndef LIBREPORT_EVENT_CONFIG_H
20#define LIBREPORT_EVENT_CONFIG_H
21
22#include <stdbool.h>
23#include <glib.h>
24#include "problem_data.h"
25#include "config_item_info.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31typedef enum
32{
33 OPTION_TYPE_TEXT,
34 OPTION_TYPE_BOOL,
35 OPTION_TYPE_PASSWORD,
36 OPTION_TYPE_NUMBER,
37 OPTION_TYPE_HINT_HTML,
38 OPTION_TYPE_INVALID,
39} option_type_t;
40
41/*
42 * struct to hold information about config options
43 * it's supposed to hold information about:
44 * type -> which designates the widget used to display it and we can do some test based on the type
45 * label
46 * allowed value(s) -> regexp?
47 * name -> env variable name
48 * value -> value retrieved from the gui, so when we want to set the env
49 * evn variables, we can just traverse the list of the options
50 * and set the env variables according to name:value in this structure
51 */
52typedef struct
53{
54 char *eo_name; //name of the value which should be used for env variable
55 char *eo_value;
56 char *eo_label;
57 char *eo_note_html;
58 option_type_t eo_type;
59 int eo_allow_empty;
60 //char *description; //can be used as tooltip in gtk app
61 //char *allowed_value;
62 //int required;
63 bool is_advanced;
65
66/*
67 * struct holds
68 * invopt_name = name of the option with invalid value
69 * invopt_error = string of the error message
70 */
71typedef struct
72{
73 char *invopt_name;
74 char *invopt_error;
76
77event_option_t *new_event_option(void);
78void free_event_option(event_option_t *p);
79
80//structure to hold the option data
81typedef struct
82{
83 config_item_info_t *info;
84
85 char *ec_creates_items;
86 char *ec_requires_items;
87 char *ec_exclude_items_by_default;
88 char *ec_include_items_by_default;
89 char *ec_exclude_items_always;
90 bool ec_exclude_binary_items;
91 long ec_minimal_rating;
92 bool ec_skip_review;
93 bool ec_sending_sensitive_data;
94 bool ec_supports_restricted_access;
95 char *ec_restricted_access_option;
96 bool ec_requires_details;
97
98 GList *ec_imported_event_names;
99 GList *options;
101
102event_config_t *new_event_config(const char *name);
103config_item_info_t *ec_get_config_info(event_config_t * ec);
104const char *ec_get_screen_name(event_config_t *ec);
105void ec_set_screen_name(event_config_t *ec, const char *screen_name);
106
107const char *ec_get_description(event_config_t *ec);
108void ec_set_description(event_config_t *ec, const char *description);
109
110const char *ec_get_name(event_config_t *ec);
111const char *ec_get_long_desc(event_config_t *ec);
112void ec_set_long_desc(event_config_t *ec, const char *long_desc);
113bool ec_is_configurable(event_config_t* ec);
114
115/* Returns True if the event is configured to create ticket with restricted
116 * access.
117 */
118bool ec_restricted_access_enabled(event_config_t *ec);
119
120void free_event_config(event_config_t *p);
121
122invalid_option_t *new_invalid_option(void);
123void free_invalid_options(invalid_option_t* p);
124
125void load_event_description_from_file(event_config_t *event_config, const char* filename);
126
127// (Re)loads data from /etc/abrt/events/*.{conf,xml}
128GHashTable *load_event_config_data(void);
129/* Frees all loaded data */
130void free_event_config_data(void);
131event_config_t *get_event_config(const char *event_name);
132event_option_t *get_event_option_from_list(const char *option_name, GList *event_options);
133
134/* for debugging */
135void ec_print(event_config_t *ec);
136
137extern GHashTable *g_event_config_list; // for iterating through entire list of all loaded configs
138
139GList *export_event_config(const char *event_name);
140void unexport_event_config(GList *env_list);
141
142GList *get_options_with_err_msg(const char *event_name);
143
144/*
145 * Checks usability of problem's backtrace rating against required rating level
146 * from event configuration.
147 *
148 * @param cfg an event configuration
149 * @param pd a checked problem data
150 * @param description an output parameter for a description of rating
151 * usability. If the variable holds NULL after function call no description is
152 * available. The description can be provided even if backtrace rating is
153 * acceptable. Can be NULL.
154 * @param detail an output parameter for a more details about rating usability.
155 * If the variable holds NULL after function call no description is available.
156 * The detail can be provided even if backtrace rating is acceptable. Can be
157 * NULL.
158 * @returns true if rating is usable or above usable; otherwise false
159 */
160bool check_problem_rating_usability(const event_config_t *cfg,
161 problem_data_t *pd,
162 char **description,
163 char **detail);
164
172GList *expand_event_wildcard(const gchar *event_name, gsize event_len);
173
179GList *expand_event_chain_wildcards(GList *chain);
180
181#ifdef __cplusplus
182}
183#endif
184
185#endif