libreport  2.13.1.12.g180e
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
28 extern "C" {
29 #endif
30 
31 typedef 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  */
52 typedef 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  */
71 typedef struct
72 {
73  char *invopt_name;
74  char *invopt_error;
76 
77 event_option_t *new_event_option(void);
78 void free_event_option(event_option_t *p);
79 
80 //structure to hold the option data
81 typedef struct
82 {
83  config_item_info_t *info;
84 
85  char *ec_requires_items;
86  char *ec_exclude_items_by_default;
87  char *ec_include_items_by_default;
88  char *ec_exclude_items_always;
89  bool ec_exclude_binary_items;
90  long ec_minimal_rating;
91  bool ec_skip_review;
92  bool ec_sending_sensitive_data;
93  bool ec_supports_restricted_access;
94  char *ec_restricted_access_option;
95  bool ec_requires_details;
96 
97  GList *ec_imported_event_names;
98  GList *options;
100 
101 event_config_t *new_event_config(const char *name);
102 config_item_info_t *ec_get_config_info(event_config_t * ec);
103 const char *ec_get_screen_name(event_config_t *ec);
104 void ec_set_screen_name(event_config_t *ec, const char *screen_name);
105 
106 const char *ec_get_description(event_config_t *ec);
107 void ec_set_description(event_config_t *ec, const char *description);
108 
109 const char *ec_get_name(event_config_t *ec);
110 const char *ec_get_long_desc(event_config_t *ec);
111 void ec_set_long_desc(event_config_t *ec, const char *long_desc);
112 bool ec_is_configurable(event_config_t* ec);
113 
114 /* Returns True if the event is configured to create ticket with restricted
115  * access.
116  */
117 bool ec_restricted_access_enabled(event_config_t *ec);
118 
119 void free_event_config(event_config_t *p);
120 
121 invalid_option_t *new_invalid_option(void);
122 void free_invalid_options(invalid_option_t* p);
123 
124 void load_event_description_from_file(event_config_t *event_config, const char* filename);
125 
126 // (Re)loads data from /etc/abrt/events/*.{conf,xml}
127 GHashTable *load_event_config_data(void);
128 /* Frees all loaded data */
129 void free_event_config_data(void);
130 event_config_t *get_event_config(const char *event_name);
131 event_option_t *get_event_option_from_list(const char *option_name, GList *event_options);
132 
133 /* for debugging */
134 void ec_print(event_config_t *ec);
135 
136 extern GHashTable *g_event_config_list; // for iterating through entire list of all loaded configs
137 
138 GList *export_event_config(const char *event_name);
139 void unexport_event_config(GList *env_list);
140 
141 GList *get_options_with_err_msg(const char *event_name);
142 
143 /*
144  * Checks usability of problem's backtrace rating against required rating level
145  * from event configuration.
146  *
147  * @param cfg an event configuration
148  * @param pd a checked problem data
149  * @param description an output parameter for a description of rating
150  * usability. If the variable holds NULL after function call no description is
151  * available. The description can be provided even if backtrace rating is
152  * acceptable. Can be NULL.
153  * @param detail an output parameter for a more details about rating usability.
154  * If the variable holds NULL after function call no description is available.
155  * The detail can be provided even if backtrace rating is acceptable. Can be
156  * NULL.
157  * @returns true if rating is usable or above usable; otherwise false
158  */
159 bool check_problem_rating_usability(const event_config_t *cfg,
160  problem_data_t *pd,
161  char **description,
162  char **detail);
163 
171 GList *expand_event_wildcard(const gchar *event_name, gsize event_len);
172 
178 GList *expand_event_chain_wildcards(GList *chain);
179 
180 #ifdef __cplusplus
181 }
182 #endif
183 
184 #endif