[grisbi-devel] [PATCH 1/2] update the anonymize module for the new data
Rémi Cardona
remi at gentoo.org
Mon Apr 15 22:25:37 CEST 2013
Commentaires en inline.
À part ces quelques petits détails, RAS.
Rémi
Le dimanche 14 avril 2013 à 21:21 +0200, pbiava a écrit :
> ---
> src/bet_data.c | 43 +++++++++
> src/bet_data.h | 1 +
> src/file_obfuscate.c | 244 ++++++++++++++++++++++++++++++++-------------------
> 3 files changed, 199 insertions(+), 89 deletions(-)
>
> diff --git a/src/bet_data.c b/src/bet_data.c
> index 390708a..2c4d87f 100644
> --- a/src/bet_data.c
> +++ b/src/bet_data.c
> @@ -2187,12 +2187,55 @@ void struct_free_bet_transaction_current_fyear ( TransactionCurrentFyear *self )
>
>
> /**
> + * met à 0 tous les montants retenus pour les données historiques
Sets to 0 all the amounts selected for historical data (ou "archival")
> + *
> + * \param account_number
> + *
> + * \return
> + * */
> +void bet_data_hist_set_all_retened_amount_null ( gint account_number )
void bet_data_hist_reset_all_amounts()
> +{
> + GHashTableIter iter;
> + gpointer key, value;
> +
> + if ( g_hash_table_size ( bet_hist_div_list ) == 0 )
> + return;
> +
> + g_hash_table_iter_init ( &iter, bet_hist_div_list );
> + while ( g_hash_table_iter_next ( &iter, &key, &value ) )
> + {
> + struct_hist_div *shd = ( struct_hist_div* ) value;
> +
> + if ( g_hash_table_size ( shd -> sub_div_list ) == 0 )
> + {
> + if ( shd -> div_edited )
> + bet_data_set_div_amount ( account_number, shd -> div_number, 0, null_real );
> + }
> + else
> + {
> + GHashTableIter new_iter;
> +
> + g_hash_table_iter_init ( &new_iter, shd -> sub_div_list );
> + while ( g_hash_table_iter_next ( &new_iter, &key, &value ) )
> + {
> + struct_hist_div *sub_shd = ( struct_hist_div* ) value;
> +
> + if ( sub_shd->div_edited )
> + bet_data_set_div_amount ( account_number, shd->div_number, sub_shd->div_number, null_real );
> + }
> + }
> + }
> +}
> +
> +
> +/**
> *
> *
> * \param
> *
> * \return
> * */
> +
> /* Local Variables: */
> /* c-basic-offset: 4 */
> /* End: */
> diff --git a/src/bet_data.h b/src/bet_data.h
> index 57cc3b3..9447d8c 100644
> --- a/src/bet_data.h
> +++ b/src/bet_data.h
> @@ -174,6 +174,7 @@ gboolean bet_data_hist_add_div ( gint account_number,
> gint div_number,
> gint sub_div_nb );
> gsb_real bet_data_hist_get_div_amount ( gint account_nb, gint div_number, gint sub_div_nb );
> +void bet_data_hist_set_all_retened_amount_null ( gint account_number );
> gboolean bet_data_init_variables ( void );
> void bet_data_insert_div_hist ( struct_hist_div *shd, struct_hist_div *sub_shd );
> gboolean bet_data_populate_div ( gint transaction_number,
> diff --git a/src/file_obfuscate.c b/src/file_obfuscate.c
> index b62bbb6..6352ff3 100644
> --- a/src/file_obfuscate.c
> +++ b/src/file_obfuscate.c
> @@ -35,12 +35,14 @@
>
> /*START_INCLUDE*/
> #include "file_obfuscate.h"
> +#include "bet_data.h"
> #include "dialog.h"
> #include "gsb_assistant.h"
> #include "gsb_data_account.h"
> #include "gsb_data_bank.h"
> #include "gsb_data_budget.h"
> #include "gsb_data_category.h"
> +#include "gsb_data_partial_balance.h"
> #include "gsb_data_payee.h"
> #include "gsb_data_reconcile.h"
> #include "gsb_data_report.h"
> @@ -125,30 +127,89 @@ gboolean file_obfuscate_run ( void )
> /* remove the swp file */
> gsb_file_util_modify_lock (FALSE);
>
> - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_accounts_details)))
> - {
> - /* hide the details of account but not the names */
> - tmp_list = gsb_data_account_get_list_accounts ();
> - while (tmp_list)
> - {
> - gint account_number = gsb_data_account_get_no_account (tmp_list -> data);
> -
> - gsb_data_account_set_id (account_number,
> - g_strdup_printf ("id account %d", account_number));
> - gsb_data_account_set_comment (account_number, NULL);
> - gsb_data_account_set_holder_name (account_number, NULL);
> - gsb_data_account_set_holder_address (account_number, NULL);
> - gsb_data_account_set_init_balance (account_number, null_real);
> - gsb_data_account_set_mini_balance_wanted (account_number, null_real);
> - gsb_data_account_set_mini_balance_authorized (account_number, null_real);
> - gsb_data_account_set_bank_branch_code (account_number, NULL);
> - gsb_data_account_set_bank_account_number (account_number, NULL);
> - gsb_data_account_set_bank_account_key (account_number, NULL);
> + /* hide the accounts data */
> + tmp_list = gsb_data_account_get_list_accounts ();
> + while ( tmp_list )
> + {
> + gint account_number = gsb_data_account_get_no_account ( tmp_list -> data );
Il reste de l'indentation avec des tabs.
> +
> + /* hide the IBAN number */
> + gsb_data_account_set_bank_account_iban ( account_number, NULL );
> +
> + if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( button_accounts_details ) ) )
> + {
> + /* hide the details of account but not the names */
> + gchar *tmp_str;
> +
> + tmp_str = g_strdup_printf ( "id account %d", account_number );
> + gsb_data_account_set_id ( account_number, tmp_str );
> + g_free ( tmp_str );
> +
> + gsb_data_account_set_comment (account_number, NULL);
> + gsb_data_account_set_holder_name (account_number, NULL);
> + gsb_data_account_set_holder_address (account_number, NULL);
> + gsb_data_account_set_init_balance (account_number, null_real);
> + gsb_data_account_set_mini_balance_wanted (account_number, null_real);
> + gsb_data_account_set_mini_balance_authorized (account_number, null_real);
> + gsb_data_account_set_bank_branch_code (account_number, NULL);
> + gsb_data_account_set_bank_account_number (account_number, NULL);
> + gsb_data_account_set_bank_account_key (account_number, NULL);
> + }
> +
> + if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( button_accounts_names ) ) )
> + {
> + /* hide the accounts names */
> + gchar *tmp_str;
> +
> + tmp_str = g_strdup_printf ( "Account n°%d", account_number );
> + gsb_data_account_set_name ( account_number, tmp_str );
> + g_free ( tmp_str );
>
> - tmp_list = tmp_list -> next;
> }
À réindenter avec des espaces.
> +
> + /* hide the budgetary data */
> + if ( gsb_data_account_get_bet_use_budget ( account_number ) )
> + {
> + /* hide the historiques data */
> + gint bet_hist_data;
> +
> + bet_hist_data = gsb_data_account_get_bet_hist_data ( account_number );
> +
> + if ( bet_hist_data == 0 && gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( button_categories ) ) )
> + {
> + bet_data_hist_set_all_retened_amount_null ( account_number );
> + }
> + if ( bet_hist_data == 1 && gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( button_budgets ) ) )
> + {
> + bet_data_hist_set_all_retened_amount_null ( account_number );
> + }
> + gsb_data_account_set_bet_finance_capital ( account_number, 0.0 );
> + gsb_data_account_set_bet_finance_taux_annuel ( account_number, 0.0 );
> + gsb_data_account_set_bet_finance_frais ( account_number, 0.0 );
> + gsb_data_account_set_bet_finance_capital ( account_number, 0.0 );
> + gsb_data_account_set_bet_months ( account_number, 0 );
> + }
> +
> + tmp_list = tmp_list -> next;
> }
Idem, reste des tabs sur les deux lignes ci-dessus.
> + if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( button_accounts_names ) ) )
> + {
> + /* hide the partial balance accounts names */
> + tmp_list = gsb_data_partial_balance_get_list ();
> + while ( tmp_list )
> + {
> + gint partial_balance_number = gsb_data_partial_balance_get_number ( tmp_list->data );
> + gchar *tmp_str;
> +
> + tmp_str = g_strdup_printf ( "Partial balance n°%d", partial_balance_number );
> + gsb_data_partial_balance_set_name ( partial_balance_number, tmp_str );
> + g_free ( tmp_str );
> +
> + tmp_list = tmp_list->next;
> + }
> + }
> +
> if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_amount)))
> {
> /* hide the amounts of transactions */
> @@ -175,32 +236,21 @@ gboolean file_obfuscate_run ( void )
> }
> }
>
> - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_accounts_names)))
> - {
> - /* hide the accounts names */
> - tmp_list = gsb_data_account_get_list_accounts ();
> - while (tmp_list)
> - {
> - gint account_number = gsb_data_account_get_no_account (tmp_list -> data);
> -
> - gsb_data_account_set_name (account_number,
> - g_strdup_printf ("Account n°%d", account_number));
> -
> - tmp_list = tmp_list -> next;
> - }
> - }
> -
> if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_payee)))
> {
> /* hide the payees names */
> tmp_list = gsb_data_payee_get_payees_list ();
> while (tmp_list)
> {
> - gint payee_number = gsb_data_payee_get_no_payee (tmp_list -> data);
> + gint payee_number = gsb_data_payee_get_no_payee (tmp_list -> data);
> + gchar *tmp_str;
>
> - gsb_data_payee_set_name (payee_number,
> - g_strdup_printf ( "Payee n°%d", payee_number));
> - gsb_data_payee_set_description (payee_number, NULL);
> + tmp_str = g_strdup_printf ( "Payee n°%d", payee_number );
> + gsb_data_payee_set_name ( payee_number, tmp_str );
> + g_free ( tmp_str );
> +
> + gsb_data_payee_set_description (payee_number, NULL);
> + gsb_data_payee_set_search_string ( payee_number, NULL );
>
> tmp_list = tmp_list -> next;
> }
> @@ -212,21 +262,25 @@ gboolean file_obfuscate_run ( void )
> tmp_list = gsb_data_category_get_categories_list ();
> while (tmp_list)
> {
> - GSList *list_sub_categ;
> - gint category_number = gsb_data_category_get_no_category (tmp_list -> data);
> + GSList *list_sub_categ;
> + gint category_number = gsb_data_category_get_no_category (tmp_list -> data);
> + gchar *tmp_str;
> +
> + tmp_str = g_strdup_printf ( "Category n°%d", category_number );
> + gsb_data_category_set_name ( category_number, tmp_str );
> + g_free ( tmp_str );
>
> - gsb_data_category_set_name (category_number,
> - g_strdup_printf ( "Category n°%d", category_number));
> + list_sub_categ = gsb_data_category_get_sub_category_list (category_number);
> + while (list_sub_categ)
> + {
> + gint sub_categ_number = gsb_data_category_get_no_sub_category (list_sub_categ -> data);
>
> - list_sub_categ = gsb_data_category_get_sub_category_list (category_number);
> - while (list_sub_categ)
> - {
> - gint sub_categ_number = gsb_data_category_get_no_sub_category (list_sub_categ -> data);
> + tmp_str = g_strdup_printf ("Sub-category n°%d", sub_categ_number);
> + gsb_data_category_set_sub_category_name ( category_number, sub_categ_number, tmp_str );
> + g_free ( tmp_str );
>
> - gsb_data_category_set_sub_category_name (category_number, sub_categ_number,
> - g_strdup_printf ("Sub-category n°%d", sub_categ_number));
> - list_sub_categ = list_sub_categ -> next;
> - }
> + list_sub_categ = list_sub_categ -> next;
> + }
> tmp_list = tmp_list -> next;
> }
> }
> @@ -237,22 +291,26 @@ gboolean file_obfuscate_run ( void )
> tmp_list = gsb_data_budget_get_budgets_list ();
> while (tmp_list)
> {
> - GSList *list_sub_budget;
> - gint budget_number = gsb_data_budget_get_no_budget (tmp_list -> data);
> -
> - gsb_data_budget_set_name (budget_number,
> - g_strdup_printf ( "Budget n°%d", budget_number));
> -
> - list_sub_budget = gsb_data_budget_get_sub_budget_list (budget_number);
> - while (list_sub_budget)
> - {
> - gint sub_budget_number = gsb_data_budget_get_no_sub_budget (list_sub_budget -> data);
> -
> - gsb_data_budget_set_sub_budget_name (budget_number, sub_budget_number,
> - g_strdup_printf ("Sub-budget n°%d", sub_budget_number));
> - list_sub_budget = list_sub_budget -> next;
> - }
> - tmp_list = tmp_list -> next;
> + GSList *list_sub_budget;
> + gint budget_number = gsb_data_budget_get_no_budget (tmp_list -> data);
> + gchar *tmp_str;
> +
> + tmp_str = g_strdup_printf ( "Budget n°%d", budget_number );
> + gsb_data_budget_set_name ( budget_number, tmp_str );
> + g_free ( tmp_str );
> +
> + list_sub_budget = gsb_data_budget_get_sub_budget_list (budget_number);
> + while (list_sub_budget)
> + {
> + gint sub_budget_number = gsb_data_budget_get_no_sub_budget (list_sub_budget -> data);
> +
> + tmp_str = g_strdup_printf ( "Sub-budget n°%d", sub_budget_number );
> + gsb_data_budget_set_sub_budget_name ( budget_number, sub_budget_number, tmp_str );
> + g_free ( tmp_str );
> +
> + list_sub_budget = list_sub_budget -> next;
> + }
> + tmp_list = tmp_list -> next;
> }
> }
>
> @@ -286,25 +344,27 @@ gboolean file_obfuscate_run ( void )
> tmp_list = gsb_data_bank_get_bank_list ();
> while (tmp_list)
> {
> - gint bank_number = gsb_data_bank_get_no_bank (tmp_list -> data);
> -
> - gsb_data_bank_set_name (bank_number,
> - g_strdup_printf ("Bank n°%d", bank_number));
> - gsb_data_bank_set_code (bank_number, NULL);
> - gsb_data_bank_set_bank_address (bank_number, NULL);
> - gsb_data_bank_set_bank_tel (bank_number, NULL);
> - gsb_data_bank_set_bank_mail (bank_number, NULL);
> - gsb_data_bank_set_bank_web (bank_number, NULL);
> - gsb_data_bank_set_bank_note (bank_number, NULL);
> - gsb_data_bank_set_correspondent_name (bank_number, NULL);
> - gsb_data_bank_set_correspondent_tel (bank_number, NULL);
> - gsb_data_bank_set_correspondent_mail (bank_number, NULL);
> - gsb_data_bank_set_correspondent_fax (bank_number, NULL);
> -
> - tmp_list = tmp_list -> next;
> + gint bank_number = gsb_data_bank_get_no_bank (tmp_list -> data);
> + gchar *tmp_str;
> +
> + tmp_str = g_strdup_printf ( "Bank n°%d", bank_number );
> + gsb_data_bank_set_name ( bank_number, tmp_str );
> + g_free ( tmp_str );
> +
> + gsb_data_bank_set_code (bank_number, NULL);
> + gsb_data_bank_set_bic ( bank_number, NULL );
> + gsb_data_bank_set_bank_address (bank_number, NULL);
> + gsb_data_bank_set_bank_tel (bank_number, NULL);
> + gsb_data_bank_set_bank_mail (bank_number, NULL);
> + gsb_data_bank_set_bank_web (bank_number, NULL);
> + gsb_data_bank_set_bank_note (bank_number, NULL);
> + gsb_data_bank_set_correspondent_name (bank_number, NULL);
> + gsb_data_bank_set_correspondent_tel (bank_number, NULL);
> + gsb_data_bank_set_correspondent_mail (bank_number, NULL);
> + gsb_data_bank_set_correspondent_fax (bank_number, NULL);
> +
> + tmp_list = tmp_list -> next;
> }
> -
> -
> }
>
> if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_reports)))
> @@ -313,12 +373,14 @@ gboolean file_obfuscate_run ( void )
> tmp_list = gsb_data_report_get_report_list ();
> while (tmp_list)
> {
> - gint report_number = gsb_data_report_get_report_number (tmp_list -> data);
> + gint report_number = gsb_data_report_get_report_number (tmp_list -> data);
> + gchar *tmp_str;
>
> - gsb_data_report_set_report_name ( report_number,
> - g_strdup_printf ( "Report n°%d", report_number));
> + tmp_str = g_strdup_printf ( "Report n°%d", report_number );
> + gsb_data_report_set_report_name ( report_number, tmp_str );
> + g_free ( tmp_str );
>
> - tmp_list = tmp_list -> next;
> + tmp_list = tmp_list -> next;
> }
> }
>
> @@ -354,6 +416,8 @@ gboolean file_obfuscate_run ( void )
> dialogue_error_hint (g_strdup_printf (_("Grisbi couldn't save the file\n'%s'"), filename ),
> _("Obfuscation failed") );
>
> + g_free ( filename );
> +
> /* bye bye */
> exit (0);
> }
> @@ -450,6 +514,8 @@ GtkWidget *file_obfuscate_page_1 ( void )
> FALSE, FALSE, 0);
> register_button_as_linked ( button_everything, button_reconcile );
>
> + gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( button_everything ), TRUE );
> +
> gtk_widget_show_all (vbox);
> return vbox;
> }
More information about the devel
mailing list