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