libreport
2.1.3
A tool to inform users about various problems on the running system
|
00001 /* 00002 Copyright (C) 2009 Abrt team. 00003 Copyright (C) 2009 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 00022 #ifndef LIBREPORT_PROBLEM_DATA_H_ 00023 #define LIBREPORT_PROBLEM_DATA_H_ 00024 00025 #include <glib.h> 00026 00027 #ifdef __cplusplus 00028 extern "C" { 00029 #endif 00030 00031 struct dump_dir; 00032 00033 enum { 00034 CD_FLAG_BIN = (1 << 0), 00035 CD_FLAG_TXT = (1 << 1), 00036 CD_FLAG_ISEDITABLE = (1 << 2), 00037 CD_FLAG_ISNOTEDITABLE = (1 << 3), 00038 /* Show this element in "short" info (report-cli -l) */ 00039 CD_FLAG_LIST = (1 << 4), 00040 CD_FLAG_UNIXTIME = (1 << 5), 00041 }; 00042 00043 struct problem_item { 00044 char *content; 00045 unsigned flags; 00046 /* Used by UI for presenting "item allowed/not allowed" checkboxes: */ 00047 int selected_by_user; /* 0 "don't know", -1 "no", 1 "yes" */ 00048 int allowed_by_reporter; /* 0 "no", 1 "yes" */ 00049 int default_by_reporter; /* 0 "no", 1 "yes" */ 00050 int required_by_reporter; /* 0 "no", 1 "yes" */ 00051 }; 00052 typedef struct problem_item problem_item; 00053 00054 char *problem_item_format(struct problem_item *item); 00055 00056 00057 /* In-memory problem data structure and accessors */ 00058 00059 typedef GHashTable problem_data_t; 00060 00061 problem_data_t *problem_data_new(void); 00062 00063 static inline void problem_data_free(problem_data_t *problem_data) 00064 { 00065 //TODO: leaks problem item; 00066 if (problem_data) 00067 g_hash_table_destroy(problem_data); 00068 } 00069 00070 void problem_data_add_basics(problem_data_t *pd); 00071 00072 void problem_data_add_current_process_data(problem_data_t *pd); 00073 00074 void problem_data_add(problem_data_t *problem_data, 00075 const char *name, 00076 const char *content, 00077 unsigned flags); 00078 void problem_data_add_text_noteditable(problem_data_t *problem_data, 00079 const char *name, 00080 const char *content); 00081 void problem_data_add_text_editable(problem_data_t *problem_data, 00082 const char *name, 00083 const char *content); 00084 /* "name" can be NULL: */ 00085 void problem_data_add_file(problem_data_t *pd, const char *name, const char *path); 00086 00087 static inline struct problem_item *problem_data_get_item_or_NULL(problem_data_t *problem_data, const char *key) 00088 { 00089 return (struct problem_item *)g_hash_table_lookup(problem_data, key); 00090 } 00091 char *problem_data_get_content_or_NULL(problem_data_t *problem_data, const char *key); 00092 /* Aborts if key is not found: */ 00093 char *problem_data_get_content_or_die(problem_data_t *problem_data, const char *key); 00094 00095 int problem_data_send_to_abrt(problem_data_t* problem_data); 00096 00097 /* Conversions between in-memory and on-disk formats */ 00098 00099 void problem_data_load_from_dump_dir(problem_data_t *problem_data, struct dump_dir *dd, char **excluding); 00100 00101 problem_data_t *create_problem_data_from_dump_dir(struct dump_dir *dd); 00102 /* Helper for typical operation in reporters: */ 00103 problem_data_t *create_problem_data_for_reporting(const char *dump_dir_name); 00104 00111 struct dump_dir *create_dump_dir_from_problem_data(problem_data_t *problem_data, const char *base_dir_name); 00112 00113 #ifdef __cplusplus 00114 } 00115 #endif 00116 00117 #endif