libreport  2.9.0.8.g946c
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  bool ec_supports_restricted_access;
84  char *ec_restricted_access_option;
85  bool ec_requires_details;
86 
87  GList *ec_imported_event_names;
88  GList *options;
90 
91 event_config_t *new_event_config(const char *name);
92 config_item_info_t *ec_get_config_info(event_config_t * ec);
93 const char *ec_get_screen_name(event_config_t *ec);
94 void ec_set_screen_name(event_config_t *ec, const char *screen_name);
95 
96 const char *ec_get_description(event_config_t *ec);
97 void ec_set_description(event_config_t *ec, const char *description);
98 
99 const char *ec_get_name(event_config_t *ec);
100 const char *ec_get_long_desc(event_config_t *ec);
101 void ec_set_long_desc(event_config_t *ec, const char *long_desc);
102 bool ec_is_configurable(event_config_t* ec);
103 
104 /* Returns True if the event is configured to create ticket with restricted
105  * access.
106  */
107 bool ec_restricted_access_enabled(event_config_t *ec);
108 
109 void free_event_config(event_config_t *p);
110 
111 
112 void load_event_description_from_file(event_config_t *event_config, const char* filename);
113 
114 // (Re)loads data from /etc/abrt/events/*.{conf,xml}
115 GHashTable *load_event_config_data(void);
116 /* Frees all loaded data */
117 void free_event_config_data(void);
118 event_config_t *get_event_config(const char *event_name);
119 event_option_t *get_event_option_from_list(const char *option_name, GList *event_options);
120 
121 /* for debugging */
122 void ec_print(event_config_t *ec);
123 
124 extern GHashTable *g_event_config_list; // for iterating through entire list of all loaded configs
125 
126 GList *export_event_config(const char *event_name);
127 void unexport_event_config(GList *env_list);
128 
129 GHashTable *validate_event(const char *event_name);
130 
131 /*
132  * Checks usability of problem's backtrace rating against required rating level
133  * from event configuration.
134  *
135  * @param cfg an event configuration
136  * @param pd a checked problem data
137  * @param description an output parameter for a description of rating
138  * usability. If the variable holds NULL after function call no description is
139  * available. The description can be provided even if backtrace rating is
140  * acceptable. Can be NULL.
141  * @param detail an output parameter for a more details about rating usability.
142  * If the variable holds NULL after function call no description is available.
143  * The detail can be provided even if backtrace rating is acceptable. Can be
144  * NULL.
145  * @returns true if rating is usable or above usable; otherwise false
146  */
147 bool check_problem_rating_usability(const event_config_t *cfg,
148  problem_data_t *pd,
149  char **description,
150  char **detail);
151 
152 #ifdef __cplusplus
153 }
154 #endif
155 
156 #endif