libreport  2.2.3.38.ge4d4
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 event_option_t *new_event_option(void);
67 void free_event_option(event_option_t *p);
68 
69 //structure to hold the option data
70 typedef struct
71 {
72  config_item_info_t *info;
73 
74  char *ec_creates_items;
75  char *ec_requires_items;
76  char *ec_exclude_items_by_default;
77  char *ec_include_items_by_default;
78  char *ec_exclude_items_always;
79  bool ec_exclude_binary_items;
80  long ec_minimal_rating;
81  bool ec_skip_review;
82  bool ec_sending_sensitive_data;
83 
84  GList *ec_imported_event_names;
85  GList *options;
87 
88 event_config_t *new_event_config(const char *name);
89 config_item_info_t *ec_get_config_info(event_config_t * ec);
90 const char *ec_get_screen_name(event_config_t *ec);
91 void ec_set_screen_name(event_config_t *ec, const char *screen_name);
92 
93 const char *ec_get_description(event_config_t *ec);
94 void ec_set_description(event_config_t *ec, const char *description);
95 
96 const char *ec_get_name(event_config_t *ec);
97 const char *ec_get_long_desc(event_config_t *ec);
98 void ec_set_long_desc(event_config_t *ec, const char *long_desc);
99 bool ec_is_configurable(event_config_t* ec);
100 
101 void free_event_config(event_config_t *p);
102 
103 
104 void load_event_description_from_file(event_config_t *event_config, const char* filename);
105 
106 // (Re)loads data from /etc/abrt/events/*.{conf,xml}
107 GHashTable *load_event_config_data(void);
108 /* Frees all loaded data */
109 void free_event_config_data(void);
110 event_config_t *get_event_config(const char *event_name);
111 event_option_t *get_event_option_from_list(const char *option_name, GList *event_options);
112 
113 /* for debugging */
114 void ec_print(event_config_t *ec);
115 
116 extern GHashTable *g_event_config_list; // for iterating through entire list of all loaded configs
117 
118 GList *export_event_config(const char *event_name);
119 void unexport_event_config(GList *env_list);
120 
121 GHashTable *validate_event(const char *event_name);
122 
123 /*
124  * Checks usability of problem's backtrace rating against required rating level
125  * from event configuration.
126  *
127  * @param cfg an event configuration
128  * @param pd a checked problem data
129  * @param description an output parameter for a description of rating
130  * usability. If the variable holds NULL after function call no description is
131  * available. The description can be provided even if backtrace rating is
132  * acceptable. Can be NULL.
133  * @param detail an output parameter for a more details about rating usability.
134  * If the variable holds NULL after function call no description is available.
135  * The detail can be provided even if backtrace rating is acceptable. Can be
136  * NULL.
137  * @returns true if rating is usable or above usable; otherwise false
138  */
139 bool check_problem_rating_usability(const event_config_t *cfg,
140  problem_data_t *pd,
141  char **description,
142  char **detail);
143 
144 #ifdef __cplusplus
145 }
146 #endif
147 
148 #endif