|
GnuCash 2.4.99
|
00001 /********************************************************************\ 00002 * This program is free software; you can redistribute it and/or * 00003 * modify it under the terms of the GNU General Public License as * 00004 * published by the Free Software Foundation; either version 2 of * 00005 * the License, or (at your option) any later version. * 00006 * * 00007 * This program is distributed in the hope that it will be useful, * 00008 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00009 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00010 * GNU General Public License for more details. * 00011 * * 00012 * You should have received a copy of the GNU General Public License* 00013 * along with this program; if not, contact: * 00014 * * 00015 * Free Software Foundation Voice: +1-617-542-5942 * 00016 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 * 00017 * Boston, MA 02110-1301, USA gnu@gnu.org * 00018 \********************************************************************/ 00027 #include "config.h" 00028 00029 #include <glib.h> 00030 00031 #include "import-settings.h" 00032 #include "gnc-gconf-utils.h" 00033 00034 /********************************************************************\ 00035 * Default values for user prefs (or values for unimplemented prefs.* 00036 * If you modify the value of any of these, you must do the same in * 00037 * generic-import.scm * 00038 \********************************************************************/ 00039 00040 static const int DEFAULT_ACTION_ADD_ENABLED = TRUE; 00041 static const int DEFAULT_ACTION_CLEAR_ENABLED = TRUE; 00042 00043 /********************************************************************\ 00044 * Structures passed between the functions * 00045 \********************************************************************/ 00046 00047 struct _genimportsettings 00048 { 00049 00050 gboolean action_skip_enabled; 00051 gboolean action_update_enabled; 00052 gboolean action_add_enabled; 00053 gboolean action_clear_enabled; 00054 00057 int clear_threshold; 00060 int add_threshold; 00065 int display_threshold; 00068 double fuzzy_amount; 00069 gint match_date_hardlimit; 00070 }; 00071 00072 00073 /************************************************************************ 00074 * Getter/Setter Functions for the Data Types. 00075 ************************************************************************/ 00076 /* Constructor */ 00077 GNCImportSettings * 00078 gnc_import_Settings_new (void) 00079 { 00080 GNCImportSettings * settings; 00081 00082 settings = g_new0 ( GNCImportSettings, 1); 00083 00084 00085 settings->action_skip_enabled = 00086 gnc_gconf_get_bool(GCONF_IMPORT_SECTION, "enable_skip", NULL); 00087 settings->action_update_enabled = 00088 gnc_gconf_get_bool(GCONF_IMPORT_SECTION, "enable_update", NULL); 00089 settings->action_add_enabled = DEFAULT_ACTION_ADD_ENABLED; 00090 settings->action_clear_enabled = DEFAULT_ACTION_CLEAR_ENABLED; 00091 settings->clear_threshold = 00092 (int)gnc_gconf_get_float(GCONF_IMPORT_SECTION, "auto_clear_threshold", NULL); 00093 settings->add_threshold = 00094 (int)gnc_gconf_get_float(GCONF_IMPORT_SECTION, "auto_add_threshold", NULL); 00095 settings->display_threshold = 00096 (int)gnc_gconf_get_float(GCONF_IMPORT_SECTION, "match_threshold", NULL); 00097 00098 settings->fuzzy_amount = 00099 gnc_gconf_get_float(GCONF_IMPORT_SECTION, "atm_fee_threshold", NULL); 00100 00101 settings->match_date_hardlimit = 42; /* 6 weeks */ 00102 return settings; 00103 } 00104 00105 /* Destructor */ 00106 void gnc_import_Settings_delete (GNCImportSettings *settings) 00107 { 00108 if (settings) 00109 { 00110 g_free(settings); 00111 } 00112 } 00113 00114 double 00115 gnc_import_Settings_get_fuzzy_amount (GNCImportSettings *settings) 00116 { 00117 g_assert (settings); 00118 return settings->fuzzy_amount; 00119 }; 00120 00121 gboolean gnc_import_Settings_get_action_skip_enabled (GNCImportSettings *settings) 00122 { 00123 g_assert (settings); 00124 return settings->action_skip_enabled; 00125 }; 00126 00127 gboolean gnc_import_Settings_get_action_add_enabled (GNCImportSettings *settings) 00128 { 00129 g_assert (settings); 00130 return settings->action_add_enabled; 00131 }; 00132 00133 gboolean gnc_import_Settings_get_action_update_enabled (GNCImportSettings *settings) 00134 { 00135 g_assert (settings); 00136 return settings->action_update_enabled; 00137 }; 00138 00139 gboolean gnc_import_Settings_get_action_clear_enabled (GNCImportSettings *settings) 00140 { 00141 g_assert (settings); 00142 return settings->action_clear_enabled; 00143 }; 00144 00145 gint gnc_import_Settings_get_clear_threshold (GNCImportSettings *settings) 00146 { 00147 g_assert (settings); 00148 return settings->clear_threshold; 00149 }; 00150 00151 gint gnc_import_Settings_get_add_threshold (GNCImportSettings *settings) 00152 { 00153 g_assert (settings); 00154 return settings->add_threshold; 00155 }; 00156 00157 gint gnc_import_Settings_get_display_threshold (GNCImportSettings *settings) 00158 { 00159 g_assert (settings); 00160 return settings->display_threshold; 00161 }; 00162 00163 void gnc_import_Settings_set_match_date_hardlimit (GNCImportSettings *s, gint m) 00164 { 00165 g_assert(s); 00166 s->match_date_hardlimit = m; 00167 } 00168 gint gnc_import_Settings_get_match_date_hardlimit (const GNCImportSettings *s) 00169 { 00170 g_assert(s); 00171 return s->match_date_hardlimit; 00172 } 00173
1.7.4