libreport  2.1.3
A tool to inform users about various problems on the running system
event_config.h
00001 /*
00002     Copyright (C) 2011  ABRT team
00003     Copyright (C) 2010  RedHat Inc
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License along
00016     with this program; if not, write to the Free Software Foundation, Inc.,
00017     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018 */
00019 #ifndef LIBREPORT_EVENT_CONFIG_H
00020 #define LIBREPORT_EVENT_CONFIG_H
00021 
00022 #include <stdbool.h>
00023 #include <glib.h>
00024 #include "problem_data.h"
00025 #include "config_item_info.h"
00026 
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030 
00031 typedef enum
00032 {
00033     OPTION_TYPE_TEXT,
00034     OPTION_TYPE_BOOL,
00035     OPTION_TYPE_PASSWORD,
00036     OPTION_TYPE_NUMBER,
00037     OPTION_TYPE_HINT_HTML,
00038     OPTION_TYPE_INVALID,
00039 } option_type_t;
00040 
00041 /*
00042  * struct to hold information about config options
00043  * it's supposed to hold information about:
00044  *   type -> which designates the widget used to display it and we can do some test based on the type
00045  *   label
00046  *   allowed value(s) -> regexp?
00047  *   name -> env variable name
00048  *   value -> value retrieved from the gui, so when we want to set the env
00049  *            evn variables, we can just traverse the list of the options
00050  *            and set the env variables according to name:value in this structure
00051  */
00052 typedef struct
00053 {
00054     char *eo_name; //name of the value which should be used for env variable
00055     char *eo_value;
00056     char *eo_label;
00057     char *eo_note_html;
00058     option_type_t eo_type;
00059     int eo_allow_empty;
00060     //char *description; //can be used as tooltip in gtk app
00061     //char *allowed_value;
00062     //int required;
00063     bool is_advanced;
00064 } event_option_t;
00065 
00066 event_option_t *new_event_option(void);
00067 void free_event_option(event_option_t *p);
00068 
00069 //structure to hold the option data
00070 typedef struct
00071 {
00072     config_item_info_t *info;
00073 
00074     char *ec_creates_items;
00075     char *ec_requires_items;
00076     char *ec_exclude_items_by_default;
00077     char *ec_include_items_by_default;
00078     char *ec_exclude_items_always;
00079     bool  ec_exclude_binary_items;
00080     long  ec_minimal_rating;
00081     bool  ec_skip_review;
00082     bool  ec_sending_sensitive_data;
00083 
00084     GList *options;
00085 } event_config_t;
00086 
00087 event_config_t *new_event_config(const char *name);
00088 config_item_info_t *ec_get_config_info(event_config_t * ec);
00089 const char *ec_get_screen_name(event_config_t *ec);
00090 void ec_set_screen_name(event_config_t *ec, const char *screen_name);
00091 
00092 const char *ec_get_description(event_config_t *ec);
00093 void ec_set_description(event_config_t *ec, const char *description);
00094 
00095 const char *ec_get_name(event_config_t *ec);
00096 const char *ec_get_long_desc(event_config_t *ec);
00097 void ec_set_long_desc(event_config_t *ec, const char *long_desc);
00098 bool ec_is_configurable(event_config_t* ec);
00099 
00100 void free_event_config(event_config_t *p);
00101 
00102 
00103 void load_event_description_from_file(event_config_t *event_config, const char* filename);
00104 
00105 // (Re)loads data from /etc/abrt/events/*.{conf,xml}
00106 GHashTable *load_event_config_data(void);
00107 /* Frees all loaded data */
00108 void free_event_config_data(void);
00109 event_config_t *get_event_config(const char *event_name);
00110 event_option_t *get_event_option_from_list(const char *option_name, GList *event_options);
00111 
00112 /* for debugging */
00113 void ec_print(event_config_t *ec);
00114 
00115 extern GHashTable *g_event_config_list;   // for iterating through entire list of all loaded configs
00116 
00117 GList *export_event_config(const char *event_name);
00118 void unexport_event_config(GList *env_list);
00119 
00120 GHashTable *validate_event(const char *event_name);
00121 
00122 /*
00123  * Checks usability of problem's backtrace rating against required rating level
00124  * from event configuration.
00125  *
00126  * @param cfg an event configuration
00127  * @param pd a checked problem data
00128  * @param description an output parameter for a description of rating
00129  * usability. If the variable holds NULL after function call no description is
00130  * available. The description can be provided even if backtrace rating is
00131  * acceptable. Can be NULL.
00132  * @param detail an output parameter for a more details about rating usability.
00133  * If the variable holds NULL after function call no description is available.
00134  * The detail can be provided even if backtrace rating is acceptable. Can be
00135  * NULL.
00136  * @returns true if rating is usable or above usable; otherwise false
00137  */
00138 bool check_problem_rating_usability(const event_config_t *cfg,
00139                                     problem_data_t       *pd,
00140                                     char                 **description,
00141                                     char                 **detail);
00142 
00143 #ifdef __cplusplus
00144 }
00145 #endif
00146 
00147 #endif