r20163 - gnucash/trunk/src - Re-indentation of source code.
Christian Stimming
cstim at code.gnucash.org
Mon Jan 24 09:10:10 EST 2011
Author: cstim
Date: 2011-01-24 09:10:09 -0500 (Mon, 24 Jan 2011)
New Revision: 20163
Trac: http://svn.gnucash.org/trac/changeset/20163
Modified:
gnucash/trunk/src/app-utils/gnc-ui-util.c
gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c
gnucash/trunk/src/backend/dbi/test/test-dbi-basic.c
gnucash/trunk/src/backend/dbi/test/test-dbi-stuff.c
gnucash/trunk/src/backend/sql/gnc-backend-sql.c
gnucash/trunk/src/business/business-gnome/gnc-plugin-page-invoice.c
gnucash/trunk/src/business/business-ledger/gncEntryLedgerControl.c
gnucash/trunk/src/engine/Transaction.c
gnucash/trunk/src/engine/gnc-budget.c
gnucash/trunk/src/engine/gnc-commodity.c
gnucash/trunk/src/gnome-utils/dialog-book-close.c
gnucash/trunk/src/gnome-utils/gnc-entry-quickfill.c
gnucash/trunk/src/gnome-utils/gnc-file.c
gnucash/trunk/src/gnome-utils/gnc-main-window.c
gnucash/trunk/src/import-export/aqbanking/gnc-ab-getbalance.c
gnucash/trunk/src/import-export/aqbanking/gnc-ab-gettrans.c
gnucash/trunk/src/import-export/aqbanking/gnc-ab-utils.c
gnucash/trunk/src/import-export/aqbanking/gnc-plugin-aqbanking.c
gnucash/trunk/src/import-export/import-backend.c
gnucash/trunk/src/import-export/import-main-matcher.c
gnucash/trunk/src/import-export/qif-import/druid-qif-import.c
gnucash/trunk/src/libqof/qof/gnc-date.c
gnucash/trunk/src/libqof/qof/qofbook.c
gnucash/trunk/src/libqof/qof/qofsession.c
gnucash/trunk/src/libqof/qof/qofsession.h
gnucash/trunk/src/libqof/qof/test/test-qofbackend.c
gnucash/trunk/src/libqof/qof/test/test-qofsession.c
gnucash/trunk/src/optional/python-bindings/sqlite3test.c
gnucash/trunk/src/plugins/bi_import/bi_import.c
gnucash/trunk/src/plugins/bi_import/bi_import.h
gnucash/trunk/src/plugins/bi_import/gnc-plugin-bi_import.c
gnucash/trunk/src/plugins/bi_import/gnc-plugin-bi_import.h
gnucash/trunk/src/plugins/bi_import/gncmod-bi_import.c
gnucash/trunk/src/plugins/bi_import/gui.c
gnucash/trunk/src/plugins/bi_import/helpers.c
Log:
Re-indentation of source code.
This re-indentation was done using astyle-1.24 using the following options:
astyle --indent=spaces=4 --brackets=break --pad-oper --pad-header --suffix=none
Modified: gnucash/trunk/src/app-utils/gnc-ui-util.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-ui-util.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/app-utils/gnc-ui-util.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -479,28 +479,28 @@
account_descendants = gnc_account_get_descendants (account);
if (account_descendants)
{
- gint sub_acct_tax_number = 0;
- for (descendant = account_descendants; descendant;
- descendant = g_list_next(descendant))
- {
+ gint sub_acct_tax_number = 0;
+ for (descendant = account_descendants; descendant;
+ descendant = g_list_next(descendant))
+ {
if (xaccAccountGetTaxRelated (descendant->data))
- sub_acct_tax_number++;
- }
- /* Translators: This and the following strings appear on
- * the account tab if the Tax Info column is displayed,
- * i.e. if the user wants to record the tax form number
- * and location on that tax form which corresponds to this
- * gnucash account. For the US Income Tax support in
- * gnucash, each tax code that can be assigned to an
- * account generally corresponds to a specific line number
- * on a paper form and each form has a unique
- * identification (e.g., Form 1040, Schedule A). */
- descendant_txt = (sub_acct_tax_number == 0) ? "" :
- g_strdup_printf (_("(Tax-related subaccounts: %d)"),
- sub_acct_tax_number);
+ sub_acct_tax_number++;
+ }
+ /* Translators: This and the following strings appear on
+ * the account tab if the Tax Info column is displayed,
+ * i.e. if the user wants to record the tax form number
+ * and location on that tax form which corresponds to this
+ * gnucash account. For the US Income Tax support in
+ * gnucash, each tax code that can be assigned to an
+ * account generally corresponds to a specific line number
+ * on a paper form and each form has a unique
+ * identification (e.g., Form 1040, Schedule A). */
+ descendant_txt = (sub_acct_tax_number == 0) ? "" :
+ g_strdup_printf (_("(Tax-related subaccounts: %d)"),
+ sub_acct_tax_number);
}
else
- descendant_txt = "";
+ descendant_txt = "";
tax_related = xaccAccountGetTaxRelated (account);
code = xaccAccountGetTaxUSCode (account);
@@ -509,19 +509,19 @@
{
if (!tax_related)
{
- if (safe_strcmp (descendant_txt, "") == 0)
- return NULL;
- else
- return g_strdup_printf ("%s", descendant_txt);
+ if (safe_strcmp (descendant_txt, "") == 0)
+ return NULL;
+ else
+ return g_strdup_printf ("%s", descendant_txt);
}
/* tax_related && !code */
else
{
- if (safe_strcmp (descendant_txt, "") == 0)
- return g_strdup (_("Tax-related but has no tax code"));
- else
- return g_strdup_printf
- (_("Tax-related but has no tax code; %s"), descendant_txt);
+ if (safe_strcmp (descendant_txt, "") == 0)
+ return g_strdup (_("Tax-related but has no tax code"));
+ else
+ return g_strdup_printf
+ (_("Tax-related but has no tax code; %s"), descendant_txt);
}
}
else /* with tax code */
@@ -532,11 +532,11 @@
tax_type = gnc_get_current_book_tax_type ();
if (tax_type == NULL || (safe_strcmp (tax_type, "") == 0))
{
- if (safe_strcmp (descendant_txt, "") == 0)
- return g_strdup (_("Tax entity type not specified"));
- else
- return g_strdup_printf
- (_("Tax entity type not specified; %s"), descendant_txt);
+ if (safe_strcmp (descendant_txt, "") == 0)
+ return g_strdup (_("Tax entity type not specified"));
+ else
+ return g_strdup_printf
+ (_("Tax entity type not specified; %s"), descendant_txt);
}
atype = xaccAccountGetType (account);
/* tax_entity_type = scm_from_locale_string (tax_type); <- requires guile 1.8*/
@@ -603,25 +603,25 @@
{
if (tax_related)
{
- if (safe_strcmp (descendant_txt, "") == 0)
- return g_strdup_printf
- (_("Tax type %s: invalid code %s for account type"),
- tax_type, num_code);
- else
- return g_strdup_printf
- (_("Tax type %s: invalid code %s for account type; %s"),
- tax_type, num_code, descendant_txt);
+ if (safe_strcmp (descendant_txt, "") == 0)
+ return g_strdup_printf
+ (_("Tax type %s: invalid code %s for account type"),
+ tax_type, num_code);
+ else
+ return g_strdup_printf
+ (_("Tax type %s: invalid code %s for account type; %s"),
+ tax_type, num_code, descendant_txt);
}
else
{
- if (safe_strcmp (descendant_txt, "") == 0)
- return g_strdup_printf
- (_("Not tax-related; tax type %s: invalid code %s for account type"),
- tax_type, num_code);
- else
- return g_strdup_printf
- (_("Not tax-related; tax type %s: invalid code %s for account type; %s"),
- tax_type, num_code, descendant_txt);
+ if (safe_strcmp (descendant_txt, "") == 0)
+ return g_strdup_printf
+ (_("Not tax-related; tax type %s: invalid code %s for account type"),
+ tax_type, num_code);
+ else
+ return g_strdup_printf
+ (_("Not tax-related; tax type %s: invalid code %s for account type; %s"),
+ tax_type, num_code, descendant_txt);
}
}
@@ -631,25 +631,25 @@
{
if (tax_related)
{
- if (safe_strcmp (descendant_txt, "") == 0)
- return g_strdup_printf
- (_("Invalid code %s for tax type %s"),
- num_code, tax_type);
- else
- return g_strdup_printf
- (_("Invalid code %s for tax type %s; %s"),
- num_code, tax_type, descendant_txt);
+ if (safe_strcmp (descendant_txt, "") == 0)
+ return g_strdup_printf
+ (_("Invalid code %s for tax type %s"),
+ num_code, tax_type);
+ else
+ return g_strdup_printf
+ (_("Invalid code %s for tax type %s; %s"),
+ num_code, tax_type, descendant_txt);
}
else
{
- if (safe_strcmp (descendant_txt, "") == 0)
- return g_strdup_printf
- (_("Not tax-related; invalid code %s for tax type %s"),
- num_code, tax_type);
- else
- return g_strdup_printf
- (_("Not tax-related; invalid code %s for tax type %s; %s"),
- num_code, tax_type, descendant_txt);
+ if (safe_strcmp (descendant_txt, "") == 0)
+ return g_strdup_printf
+ (_("Not tax-related; invalid code %s for tax type %s"),
+ num_code, tax_type);
+ else
+ return g_strdup_printf
+ (_("Not tax-related; invalid code %s for tax type %s; %s"),
+ num_code, tax_type, descendant_txt);
}
}
@@ -658,24 +658,24 @@
{
if (tax_related)
{
- if (safe_strcmp (descendant_txt, "") == 0)
- return g_strdup_printf
- (_("No form: code %s, tax type %s"), num_code, tax_type);
- else
- return g_strdup_printf
- (_("No form: code %s, tax type %s; %s"),
- num_code, tax_type, descendant_txt);
+ if (safe_strcmp (descendant_txt, "") == 0)
+ return g_strdup_printf
+ (_("No form: code %s, tax type %s"), num_code, tax_type);
+ else
+ return g_strdup_printf
+ (_("No form: code %s, tax type %s; %s"),
+ num_code, tax_type, descendant_txt);
}
else
{
- if (safe_strcmp (descendant_txt, "") == 0)
- return g_strdup_printf
- (_("Not tax-related; no form: code %s, tax type %s"),
- num_code, tax_type);
- else
- return g_strdup_printf
- (_("Not tax-related; no form: code %s, tax type %s; %s"),
- num_code, tax_type, descendant_txt);
+ if (safe_strcmp (descendant_txt, "") == 0)
+ return g_strdup_printf
+ (_("Not tax-related; no form: code %s, tax type %s"),
+ num_code, tax_type);
+ else
+ return g_strdup_printf
+ (_("Not tax-related; no form: code %s, tax type %s; %s"),
+ num_code, tax_type, descendant_txt);
}
}
@@ -684,25 +684,25 @@
{
if (tax_related)
{
- if (safe_strcmp (descendant_txt, "") == 0)
- return g_strdup_printf
- (_("No description: form %s, code %s, tax type %s"),
- form, num_code, tax_type);
- else
- return g_strdup_printf
- (_("No description: form %s, code %s, tax type %s; %s"),
- form, num_code, tax_type, descendant_txt);
+ if (safe_strcmp (descendant_txt, "") == 0)
+ return g_strdup_printf
+ (_("No description: form %s, code %s, tax type %s"),
+ form, num_code, tax_type);
+ else
+ return g_strdup_printf
+ (_("No description: form %s, code %s, tax type %s; %s"),
+ form, num_code, tax_type, descendant_txt);
}
else
{
- if (safe_strcmp (descendant_txt, "") == 0)
- return g_strdup_printf
- (_("Not tax-related; no description: form %s, code %s, tax type %s"),
- form, num_code, tax_type);
- else
- return g_strdup_printf
- (_("Not tax-related; no description: form %s, code %s, tax type %s; %s"),
- form, num_code, tax_type, descendant_txt);
+ if (safe_strcmp (descendant_txt, "") == 0)
+ return g_strdup_printf
+ (_("Not tax-related; no description: form %s, code %s, tax type %s"),
+ form, num_code, tax_type);
+ else
+ return g_strdup_printf
+ (_("Not tax-related; no description: form %s, code %s, tax type %s; %s"),
+ form, num_code, tax_type, descendant_txt);
}
}
@@ -711,25 +711,25 @@
{
if (tax_related)
{
- if (safe_strcmp (descendant_txt, "") == 0)
- return g_strdup_printf
- (_("No description: form %s, code %s, tax type %s"),
- form, num_code, tax_type);
- else
- return g_strdup_printf
- (_("No description: form %s, code %s, tax type %s; %s"),
- form, num_code, tax_type, descendant_txt);
+ if (safe_strcmp (descendant_txt, "") == 0)
+ return g_strdup_printf
+ (_("No description: form %s, code %s, tax type %s"),
+ form, num_code, tax_type);
+ else
+ return g_strdup_printf
+ (_("No description: form %s, code %s, tax type %s; %s"),
+ form, num_code, tax_type, descendant_txt);
}
else
{
- if (safe_strcmp (descendant_txt, "") == 0)
- return g_strdup_printf
- (_("Not tax-related; no description: form %s, code %s, tax type %s"),
- form, num_code, tax_type);
- else
- return g_strdup_printf
- (_("Not tax-related; no description: form %s, code %s, tax type %s; %s"),
- form, num_code, tax_type, descendant_txt);
+ if (safe_strcmp (descendant_txt, "") == 0)
+ return g_strdup_printf
+ (_("Not tax-related; no description: form %s, code %s, tax type %s"),
+ form, num_code, tax_type);
+ else
+ return g_strdup_printf
+ (_("Not tax-related; no description: form %s, code %s, tax type %s; %s"),
+ form, num_code, tax_type, descendant_txt);
}
}
@@ -741,31 +741,31 @@
{
if (safe_strcmp (form, "") == 0)
{
- if (safe_strcmp (descendant_txt, "") == 0)
- return g_strdup_printf ("%s", desc);
- else
- return g_strdup_printf ("%s; %s", desc, descendant_txt);
+ if (safe_strcmp (descendant_txt, "") == 0)
+ return g_strdup_printf ("%s", desc);
+ else
+ return g_strdup_printf ("%s; %s", desc, descendant_txt);
}
else
{
- if (safe_strcmp (descendant_txt, "") == 0)
- return g_strdup_printf ("%s%s: %s", form, copy_txt, desc);
- else
- return g_strdup_printf ("%s%s: %s; %s",
- form, copy_txt, desc, descendant_txt);
+ if (safe_strcmp (descendant_txt, "") == 0)
+ return g_strdup_printf ("%s%s: %s", form, copy_txt, desc);
+ else
+ return g_strdup_printf ("%s%s: %s; %s",
+ form, copy_txt, desc, descendant_txt);
}
}
else
- {
- if (safe_strcmp (descendant_txt, "") == 0)
- return g_strdup_printf
- (_("Not tax-related; %s%s: %s (code %s, tax type %s)"),
- form, copy_txt, desc, num_code, tax_type);
- else
- return g_strdup_printf
- (_("Not tax-related; %s%s: %s (code %s, tax type %s); %s"),
- form, copy_txt, desc, num_code, tax_type, descendant_txt);
- }
+ {
+ if (safe_strcmp (descendant_txt, "") == 0)
+ return g_strdup_printf
+ (_("Not tax-related; %s%s: %s (code %s, tax type %s)"),
+ form, copy_txt, desc, num_code, tax_type);
+ else
+ return g_strdup_printf
+ (_("Not tax-related; %s%s: %s (code %s, tax type %s); %s"),
+ form, copy_txt, desc, num_code, tax_type, descendant_txt);
+ }
}
}
Modified: gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c
===================================================================
--- gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -153,9 +153,9 @@
gnc_table_slist_free( GSList *table_list )
{
GSList *list;
- for ( list = table_list; list !=NULL; list = g_slist_next( list ))
+ for ( list = table_list; list != NULL; list = g_slist_next( list ))
{
- g_free( list->data );
+ g_free( list->data );
}
g_slist_free( table_list );
}
@@ -252,19 +252,19 @@
/* Remove uri type if present */
filepath = gnc_uri_get_path ( book_id );
file_exists = g_file_test( filepath,
- G_FILE_TEST_IS_REGULAR | G_FILE_TEST_EXISTS );
+ G_FILE_TEST_IS_REGULAR | G_FILE_TEST_EXISTS );
if ( !create && !file_exists )
{
qof_backend_set_error( qbe, ERR_FILEIO_FILE_NOT_FOUND );
qof_backend_set_message(qbe, "Sqlite3 file %s not found", filepath);
- goto exit;
+ goto exit;
}
if ( create && !force && file_exists )
{
qof_backend_set_error (qbe, ERR_BACKEND_STORE_EXISTS);
msg = "Might clobber, no force";
- goto exit;
+ goto exit;
}
@@ -277,7 +277,7 @@
{
PERR( "Unable to create sqlite3 dbi connection\n" );
qof_backend_set_error( qbe, ERR_BACKEND_BAD_URL );
- goto exit;
+ goto exit;
}
dirname = g_path_get_dirname( filepath );
@@ -289,21 +289,21 @@
{
PERR( "Error setting 'host' option\n" );
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
- goto exit;
+ goto exit;
}
result = dbi_conn_set_option( be->conn, "dbname", basename );
if ( result < 0 )
{
PERR( "Error setting 'dbname' option\n" );
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
- goto exit;
+ goto exit;
}
result = dbi_conn_set_option( be->conn, "sqlite3_dbdir", dirname );
if ( result < 0 )
{
PERR( "Error setting 'sqlite3_dbdir' option\n" );
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
- goto exit;
+ goto exit;
}
result = dbi_conn_connect( be->conn );
@@ -311,26 +311,28 @@
{
PERR( "Unable to connect to %s: %d\n", book_id, result );
qof_backend_set_error( qbe, ERR_BACKEND_BAD_URL );
- goto exit;
+ goto exit;
}
- if ( !conn_test_dbi_library( be->conn ) ) {
- qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
- qof_backend_set_message( qbe, "DBI library fails large number test" );
- if ( create && !file_exists ) /* File didn't exist before, but it */
- { /* does now, and we don't want to */
- dbi_conn_close( be->conn );/* leave it lying around. */
- be->conn = NULL;
- g_unlink( filepath );
- }
- msg = "Bad DBI Library";
- goto exit;
+ if ( !conn_test_dbi_library( be->conn ) )
+ {
+ qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
+ qof_backend_set_message( qbe, "DBI library fails large number test" );
+ if ( create && !file_exists ) /* File didn't exist before, but it */
+ {
+ /* does now, and we don't want to */
+ dbi_conn_close( be->conn );/* leave it lying around. */
+ be->conn = NULL;
+ g_unlink( filepath );
+ }
+ msg = "Bad DBI Library";
+ goto exit;
}
if ( !gnc_dbi_lock_database( qbe, ignore_lock ) )
{
qof_backend_set_error( qbe, ERR_BACKEND_LOCKED );
msg = "Locked";
- goto exit;
+ goto exit;
}
if ( be->sql_be.conn != NULL )
@@ -354,8 +356,8 @@
dbi_result result = dbi_conn_query( conn, "SELECT name FROM sqlite_master WHERE type = 'index' AND name NOT LIKE 'sqlite_autoindex%'" );
if ( dbi_conn_error( conn, &errmsg ) != DBI_ERROR_NONE )
{
- g_print( "Index Table Retrieval Error: %s\n", errmsg );
- return NULL;
+ g_print( "Index Table Retrieval Error: %s\n", errmsg );
+ return NULL;
}
while ( dbi_result_next_row( result ) != 0 )
{
@@ -761,12 +763,13 @@
result = dbi_conn_connect( be->conn );
if ( result == 0 )
{
- if ( !conn_test_dbi_library( be->conn ) ) {
- qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
- qof_backend_set_message( qbe,
- "DBI library fails large number test" );
- goto exit;
- }
+ if ( !conn_test_dbi_library( be->conn ) )
+ {
+ qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
+ qof_backend_set_message( qbe,
+ "DBI library fails large number test" );
+ goto exit;
+ }
if (create && !force && save_may_clobber_data( qbe ) )
{
qof_backend_set_error ( qbe, ERR_BACKEND_STORE_EXISTS );
@@ -833,13 +836,14 @@
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
goto exit;
}
- if ( !conn_test_dbi_library( be->conn ) ) {
- qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
- qof_backend_set_message( qbe,
- "DBI library fails large number test" );
- dbi_conn_queryf( be->conn, "DROP DATABASE %s", dbname );
- goto exit;
- }
+ if ( !conn_test_dbi_library( be->conn ) )
+ {
+ qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
+ qof_backend_set_message( qbe,
+ "DBI library fails large number test" );
+ dbi_conn_queryf( be->conn, "DROP DATABASE %s", dbname );
+ goto exit;
+ }
success = gnc_dbi_lock_database ( qbe, ignore_lock );
}
else
@@ -891,28 +895,28 @@
table_list = dbi_conn_get_table_list( conn, dbname, NULL );
if ( dbi_conn_error( conn, &errmsg ) != DBI_ERROR_NONE )
{
- g_print( "Table Retrieval Error: %s\n", errmsg );
- return NULL;
+ g_print( "Table Retrieval Error: %s\n", errmsg );
+ return NULL;
}
while ( dbi_result_next_row( table_list ) != 0 )
{
- dbi_result result;
- const gchar *table_name = dbi_result_get_string_idx( table_list, 1 );
- result = dbi_conn_queryf( conn,
- "SHOW INDEXES IN %s WHERE Key_name != 'PRIMARY'",
- table_name );
- if ( dbi_conn_error( conn, &errmsg ) != DBI_ERROR_NONE )
- {
- g_print( "Index Table Retrieval Error: %s\n", errmsg );
- continue;
- }
+ dbi_result result;
+ const gchar *table_name = dbi_result_get_string_idx( table_list, 1 );
+ result = dbi_conn_queryf( conn,
+ "SHOW INDEXES IN %s WHERE Key_name != 'PRIMARY'",
+ table_name );
+ if ( dbi_conn_error( conn, &errmsg ) != DBI_ERROR_NONE )
+ {
+ g_print( "Index Table Retrieval Error: %s\n", errmsg );
+ continue;
+ }
- while ( dbi_result_next_row( result ) != 0 )
- {
- const gchar* index_name = dbi_result_get_string_idx( result, 3 );
- index_list = g_slist_prepend( index_list, strdup( index_name ) );
- }
- dbi_result_free( result );
+ while ( dbi_result_next_row( result ) != 0 )
+ {
+ const gchar* index_name = dbi_result_get_string_idx( result, 3 );
+ index_list = g_slist_prepend( index_list, strdup( index_name ) );
+ }
+ dbi_result_free( result );
}
return index_list;
@@ -1027,12 +1031,13 @@
result = dbi_conn_connect( be->conn );
if ( result == 0 )
{
- if ( !conn_test_dbi_library( be->conn ) ) {
- qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
- qof_backend_set_message( qbe,
- "DBI library fails large number test" );
- goto exit;
- }
+ if ( !conn_test_dbi_library( be->conn ) )
+ {
+ qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
+ qof_backend_set_message( qbe,
+ "DBI library fails large number test" );
+ goto exit;
+ }
if (create && !force && save_may_clobber_data( qbe ) )
{
qof_backend_set_error ( qbe, ERR_BACKEND_STORE_EXISTS );
@@ -1100,14 +1105,15 @@
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
goto exit;
}
- if ( !conn_test_dbi_library( be->conn ) ) {
- qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
- qof_backend_set_message( qbe,
- "DBI library fails large number test" );
- dbi_conn_select_db( be->conn, "template1" );
- dbi_conn_queryf( be->conn, "DROP DATABASE %s", dbnamelc );
- goto exit;
- }
+ if ( !conn_test_dbi_library( be->conn ) )
+ {
+ qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
+ qof_backend_set_message( qbe,
+ "DBI library fails large number test" );
+ dbi_conn_select_db( be->conn, "template1" );
+ dbi_conn_queryf( be->conn, "DROP DATABASE %s", dbnamelc );
+ goto exit;
+ }
success = gnc_dbi_lock_database ( qbe, ignore_lock );
}
else
@@ -1146,8 +1152,8 @@
result = dbi_conn_query( conn, "SELECT relname FROM pg_class AS a INNER JOIN pg_index AS b ON (b.indexrelid = a.oid) INNER JOIN pg_namespace AS c ON (a.relnamespace = c.oid) WHERE reltype = '0' AND indisprimary = 'f' AND nspname = 'public'" );
if ( dbi_conn_error( conn, &errmsg ) != DBI_ERROR_NONE )
{
- g_print( "Index Table Retrieval Error: %s\n", errmsg );
- return NULL;
+ g_print( "Index Table Retrieval Error: %s\n", errmsg );
+ return NULL;
}
while ( dbi_result_next_row( result ) != 0 )
{
@@ -1226,19 +1232,19 @@
if ( GNC_RESAVE_VERSION > gnc_sql_get_table_version( &be->sql_be, "Gnucash" ) )
{
- /* The database was loaded with an older database schema or
- * data semantics. In order to ensure consistency, the whole
- * thing needs to be saved anew. */
- qof_backend_set_error( qbe, ERR_SQL_DB_TOO_OLD );
+ /* The database was loaded with an older database schema or
+ * data semantics. In order to ensure consistency, the whole
+ * thing needs to be saved anew. */
+ qof_backend_set_error( qbe, ERR_SQL_DB_TOO_OLD );
}
else if ( GNC_RESAVE_VERSION < gnc_sql_get_table_version( &be->sql_be,
- "Gnucash-Resave"))
+ "Gnucash-Resave"))
{
- /* Worse, the database was created with a newer version. We
- * can't safely write to this database, so the user will have
- * to do a "save as" to make one that we can write to.
- */
- qof_backend_set_error( qbe, ERR_SQL_DB_TOO_NEW );
+ /* Worse, the database was created with a newer version. We
+ * can't safely write to this database, so the user will have
+ * to do a "save as" to make one that we can write to.
+ */
+ qof_backend_set_error( qbe, ERR_SQL_DB_TOO_NEW );
}
@@ -1268,26 +1274,26 @@
static dbi_result
conn_table_manage_backup (GncDbiSqlConnection *conn,
- gchar *table_name, TableOpType op )
+ gchar *table_name, TableOpType op )
{
gchar *new_name = g_strdup_printf( "%s_%s", table_name, "back" );
dbi_result result;
switch ( op )
{
case backup:
- result = dbi_conn_queryf( conn->conn, "ALTER TABLE %s RENAME TO %s",
- table_name, new_name );
- break;
+ result = dbi_conn_queryf( conn->conn, "ALTER TABLE %s RENAME TO %s",
+ table_name, new_name );
+ break;
case rollback:
- result = dbi_conn_queryf( conn->conn,
- "ALTER TABLE %s RENAME TO %s",
- new_name, table_name );
- break;
+ result = dbi_conn_queryf( conn->conn,
+ "ALTER TABLE %s RENAME TO %s",
+ new_name, table_name );
+ break;
case drop_backup:
- result = dbi_conn_queryf( conn->conn, "DROP TABLE %s",
- new_name );
+ result = dbi_conn_queryf( conn->conn, "DROP TABLE %s",
+ new_name );
default:
- break;
+ break;
}
g_free( new_name );
return result;
@@ -1320,7 +1326,7 @@
static gboolean
conn_table_operation( GncSqlConnection *sql_conn, GSList *table_name_list,
- TableOpType op )
+ TableOpType op )
{
GSList* node;
gboolean result = TRUE;
@@ -1330,55 +1336,56 @@
g_return_val_if_fail( table_name_list != NULL, FALSE );
if ( op == rollback )
- full_table_name_list =
- conn->provider->get_table_list( conn->conn, dbname );
+ full_table_name_list =
+ conn->provider->get_table_list( conn->conn, dbname );
for ( node = table_name_list; node != NULL && result; node = node->next )
{
- gchar* table_name = (gchar*)node->data;
- dbi_result result;
- /* Ignore the lock table */
- if ( g_strcmp0(table_name, lock_table) == 0)
- {
- continue;
- }
- do
- {
- gnc_dbi_init_error( conn );
- switch( op ) {
- case rollback:
- if (g_slist_find(full_table_name_list, table_name))
- {
- result = dbi_conn_queryf( conn->conn, "DROP TABLE %s",
- table_name );
- if ( result )
- break;
- }
- /* Note fall-through */
- case backup:
- case drop_backup:
- result = conn_table_manage_backup( conn, table_name, op );
- break;
- case empty:
- result = dbi_conn_queryf( conn->conn, "DELETE FROM TABLE %s",
- table_name );
- break;
- case drop:
- default:
- result = dbi_conn_queryf( conn->conn, "DROP TABLE %s",
- table_name );
- break;
- }
- }
- while ( conn->retry );
- if ( result != NULL )
- {
- if ( dbi_result_free( result ) < 0 )
- {
- PERR( "Error in dbi_result_free() result\n" );
- result = FALSE;
- }
- }
+ gchar* table_name = (gchar*)node->data;
+ dbi_result result;
+ /* Ignore the lock table */
+ if ( g_strcmp0(table_name, lock_table) == 0)
+ {
+ continue;
+ }
+ do
+ {
+ gnc_dbi_init_error( conn );
+ switch ( op )
+ {
+ case rollback:
+ if (g_slist_find(full_table_name_list, table_name))
+ {
+ result = dbi_conn_queryf( conn->conn, "DROP TABLE %s",
+ table_name );
+ if ( result )
+ break;
+ }
+ /* Note fall-through */
+ case backup:
+ case drop_backup:
+ result = conn_table_manage_backup( conn, table_name, op );
+ break;
+ case empty:
+ result = dbi_conn_queryf( conn->conn, "DELETE FROM TABLE %s",
+ table_name );
+ break;
+ case drop:
+ default:
+ result = dbi_conn_queryf( conn->conn, "DROP TABLE %s",
+ table_name );
+ break;
+ }
+ }
+ while ( conn->retry );
+ if ( result != NULL )
+ {
+ if ( dbi_result_free( result ) < 0 )
+ {
+ PERR( "Error in dbi_result_free() result\n" );
+ result = FALSE;
+ }
+ }
}
gnc_table_slist_free( full_table_name_list );
return result;
@@ -1409,7 +1416,7 @@
dbname = dbi_conn_get_option( be->conn, "dbname" );
table_name_list = conn->provider->get_table_list( conn->conn, dbname );
if ( !conn_table_operation( (GncSqlConnection*)conn, table_name_list,
- drop ) )
+ drop ) )
{
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
return;
@@ -1448,33 +1455,33 @@
dbname = dbi_conn_get_option( be->conn, "dbname" );
table_list = conn->provider->get_table_list( conn->conn, dbname );
if ( !conn_table_operation( (GncSqlConnection*)conn, table_list,
- backup ) )
+ backup ) )
{
- qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
- conn_table_operation( (GncSqlConnection*)conn, table_list,
- rollback );
- LEAVE( "Failed to rename tables" );
- gnc_table_slist_free( table_list );
- return;
+ qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
+ conn_table_operation( (GncSqlConnection*)conn, table_list,
+ rollback );
+ LEAVE( "Failed to rename tables" );
+ gnc_table_slist_free( table_list );
+ return;
}
index_list = conn->provider->get_index_list( conn->conn );
for ( iter = index_list; iter != NULL; iter = g_slist_next( iter) )
{
- const char *errmsg;
- dbi_result result =
- dbi_conn_queryf( conn->conn, "DROP INDEX %s", iter->data );
- if ( result )
- dbi_result_free( result );
- if ( DBI_ERROR_NONE != dbi_conn_error( conn->conn, &errmsg ) )
- {
- qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
- gnc_table_slist_free( index_list );
- conn_table_operation( (GncSqlConnection*)conn, table_list,
- rollback );
- gnc_table_slist_free( table_list );
- LEAVE( "Failed to drop indexes %s", errmsg );
- return;
- }
+ const char *errmsg;
+ dbi_result result =
+ dbi_conn_queryf( conn->conn, "DROP INDEX %s", iter->data );
+ if ( result )
+ dbi_result_free( result );
+ if ( DBI_ERROR_NONE != dbi_conn_error( conn->conn, &errmsg ) )
+ {
+ qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
+ gnc_table_slist_free( index_list );
+ conn_table_operation( (GncSqlConnection*)conn, table_list,
+ rollback );
+ gnc_table_slist_free( table_list );
+ LEAVE( "Failed to drop indexes %s", errmsg );
+ return;
+ }
}
gnc_table_slist_free( index_list );
@@ -1484,13 +1491,13 @@
gnc_sql_sync_all( &be->sql_be, book );
if ( ERR_BACKEND_NO_ERR != qof_backend_get_error( qbe ) )
{
- conn_table_operation( (GncSqlConnection*)conn, table_list,
- rollback );
- LEAVE( "Failed to create new database tables" );
- return;
+ conn_table_operation( (GncSqlConnection*)conn, table_list,
+ rollback );
+ LEAVE( "Failed to create new database tables" );
+ return;
}
conn_table_operation( (GncSqlConnection*)conn, table_list,
- drop_backup );
+ drop_backup );
gnc_table_slist_free( table_list );
LEAVE("book=%p", book);
}
@@ -2860,58 +2867,58 @@
gboolean retval = TRUE;
result = dbi_conn_query( conn, "CREATE TEMPORARY TABLE numtest "
- "( test_int BIGINT, test_unsigned BIGINT,"
- " test_double FLOAT8 )" );
+ "( test_int BIGINT, test_unsigned BIGINT,"
+ " test_double FLOAT8 )" );
if ( result == NULL )
{
- PWARN("Test_DBI_Library: Create table failed");
- return FALSE;
+ PWARN("Test_DBI_Library: Create table failed");
+ return FALSE;
}
dbi_result_free( result );
result = dbi_conn_queryf( conn,
- "INSERT INTO numtest VALUES (%lld, %llu, %17e)",
- testlonglong, testulonglong, testdouble );
+ "INSERT INTO numtest VALUES (%lld, %llu, %17e)",
+ testlonglong, testulonglong, testdouble );
if ( result == NULL )
{
- PWARN("Test_DBI_Library: Failed to insert test row into table" );
- return FALSE;
+ PWARN("Test_DBI_Library: Failed to insert test row into table" );
+ return FALSE;
}
dbi_result_free( result );
result = dbi_conn_query( conn, "SELECT * FROM numtest" );
if ( result == NULL )
{
- const char *errmsg;
- dbi_conn_error( conn, &errmsg );
- PWARN("Test_DBI_Library: Failed to retrieve test row into table: %s",
- errmsg );
- result = dbi_conn_query( conn, "DROP TABLE numtest" );
- return FALSE;
+ const char *errmsg;
+ dbi_conn_error( conn, &errmsg );
+ PWARN("Test_DBI_Library: Failed to retrieve test row into table: %s",
+ errmsg );
+ result = dbi_conn_query( conn, "DROP TABLE numtest" );
+ return FALSE;
}
while ( dbi_result_next_row( result ))
{
- resultlonglong = dbi_result_get_longlong( result, "test_int" );
- resultulonglong = dbi_result_get_ulonglong( result, "test_unsigned" );
- resultdouble = dbi_result_get_double( result, "test_double" );
+ resultlonglong = dbi_result_get_longlong( result, "test_int" );
+ resultulonglong = dbi_result_get_ulonglong( result, "test_unsigned" );
+ resultdouble = dbi_result_get_double( result, "test_double" );
}
if ( testlonglong != resultlonglong )
{
- PWARN( "Test_DBI_Library: LongLong Failed %" G_GINT64_FORMAT " != % " G_GINT64_FORMAT,
- testlonglong, resultlonglong );
- retval = FALSE;
+ PWARN( "Test_DBI_Library: LongLong Failed %" G_GINT64_FORMAT " != % " G_GINT64_FORMAT,
+ testlonglong, resultlonglong );
+ retval = FALSE;
}
if ( testulonglong != resultulonglong )
{
- PWARN( "Test_DBI_Library: Unsigned longlong Failed %" G_GUINT64_FORMAT " != %" G_GUINT64_FORMAT,
- testulonglong, resultulonglong );
- retval = FALSE;
+ PWARN( "Test_DBI_Library: Unsigned longlong Failed %" G_GUINT64_FORMAT " != %" G_GUINT64_FORMAT,
+ testulonglong, resultulonglong );
+ retval = FALSE;
}
/* A bug in libdbi stores only 7 digits of precision */
if ( testdouble >= resultdouble + 0.000001e307 ||
- testdouble <= resultdouble - 0.000001e307 )
+ testdouble <= resultdouble - 0.000001e307 )
{
- PWARN( "Test_DBI_Library: Double Failed %17e != %17e",
- testdouble, resultdouble );
- retval = FALSE;
+ PWARN( "Test_DBI_Library: Double Failed %17e != %17e",
+ testdouble, resultdouble );
+ retval = FALSE;
}
return retval;
}
Modified: gnucash/trunk/src/backend/dbi/test/test-dbi-basic.c
===================================================================
--- gnucash/trunk/src/backend/dbi/test/test-dbi-basic.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/backend/dbi/test/test-dbi-basic.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -121,9 +121,9 @@
{
session_1 = create_session();
test_dbi_store_and_reload( "mysql", session_1, TEST_MYSQL_URL );
- session_1 = create_session();
- test_dbi_safe_save( "mysql", filename );
- test_dbi_version_control( "mysql", filename );
+ session_1 = create_session();
+ test_dbi_safe_save( "mysql", filename );
+ test_dbi_version_control( "mysql", filename );
}
#endif
#ifdef TEST_PGSQL_URL
@@ -132,9 +132,9 @@
{
session_1 = create_session();
test_dbi_store_and_reload( "pgsql", session_1, TEST_PGSQL_URL );
- session_1 = create_session();
- test_dbi_safe_save( "pgsql", filename );
- test_dbi_version_control( "pgsql", filename );
+ session_1 = create_session();
+ test_dbi_safe_save( "pgsql", filename );
+ test_dbi_version_control( "pgsql", filename );
}
#endif
print_test_results();
Modified: gnucash/trunk/src/backend/dbi/test/test-dbi-stuff.c
===================================================================
--- gnucash/trunk/src/backend/dbi/test/test-dbi-stuff.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/backend/dbi/test/test-dbi-stuff.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -141,8 +141,8 @@
g_print ( "Returned from index list\n");
if ( index_list == NULL )
{
- do_test( FALSE, "Index List Test -- No List" );
- return;
+ do_test( FALSE, "Index List Test -- No List" );
+ return;
}
do_test( g_slist_length( index_list ) == 4, "Index List Test" );
g_slist_free( index_list );
@@ -177,16 +177,16 @@
if (session_2 && qof_session_get_error(session_2) != ERR_BACKEND_NO_ERR)
{
g_warning("Session Error: %d, %s", qof_session_get_error(session_2), qof_session_get_error_message(session_2));
- do_test( FALSE, "First DB Session Creation Failed");
- return;
+ do_test( FALSE, "First DB Session Creation Failed");
+ return;
}
qof_session_swap_data( session_1, session_2 );
qof_session_save( session_2, NULL );
if (session_2 && qof_session_get_error(session_2) != ERR_BACKEND_NO_ERR)
{
g_warning("Session Error: %s", qof_session_get_error_message(session_2));
- do_test( FALSE, "First DB Session Save Failed");
- return;
+ do_test( FALSE, "First DB Session Save Failed");
+ return;
}
// Reload the session data
@@ -195,15 +195,15 @@
if (session_3 && qof_session_get_error(session_3) != ERR_BACKEND_NO_ERR)
{
g_warning("Session Error: %s", qof_session_get_error_message(session_3));
- do_test( FALSE, "Second DB Session Creation Failed");
- return;
+ do_test( FALSE, "Second DB Session Creation Failed");
+ return;
}
qof_session_load( session_3, NULL );
- if (session_3 && qof_session_get_error(session_3) != ERR_BACKEND_NO_ERR)
+ if (session_3 && qof_session_get_error(session_3) != ERR_BACKEND_NO_ERR)
{
g_warning("Session Error: %s", qof_session_get_error_message(session_3));
- do_test( FALSE, "Second DBI Session Load Failed");
- return;
+ do_test( FALSE, "Second DBI Session Load Failed");
+ return;
}
// Compare with the original data
compare_books( qof_session_get_book( session_2 ), qof_session_get_book( session_3 ) );
@@ -236,18 +236,18 @@
if (session_1 && qof_session_get_error(session_1) != ERR_BACKEND_NO_ERR)
{
g_warning("Session Error: %d, %s", qof_session_get_error(session_1),
- qof_session_get_error_message(session_1));
- do_test( FALSE, "DB Session Creation Failed");
- goto cleanup;
+ qof_session_get_error_message(session_1));
+ do_test( FALSE, "DB Session Creation Failed");
+ goto cleanup;
}
qof_session_load( session_1, NULL );
- /* Do a safe save */
+ /* Do a safe save */
qof_session_safe_save( session_1, NULL );
if (session_1 && qof_session_get_error(session_1) != ERR_BACKEND_NO_ERR)
{
g_warning("Session Error: %s", qof_session_get_error_message(session_1));
- do_test( FALSE, "DB Session Safe Save Failed");
- goto cleanup;
+ do_test( FALSE, "DB Session Safe Save Failed");
+ goto cleanup;
}
/* Destroy the session and reload it */
@@ -256,13 +256,13 @@
if (session_2 && qof_session_get_error(session_2) != ERR_BACKEND_NO_ERR)
{
g_warning("Session Error: %d, %s", qof_session_get_error(session_2),
- qof_session_get_error_message(session_2));
- do_test( FALSE, "DB Session re-creation Failed");
- goto cleanup;
+ qof_session_get_error_message(session_2));
+ do_test( FALSE, "DB Session re-creation Failed");
+ goto cleanup;
}
qof_session_load( session_2, NULL );
- compare_books( qof_session_get_book( session_1 ),
- qof_session_get_book( session_2 ) );
+ compare_books( qof_session_get_book( session_1 ),
+ qof_session_get_book( session_2 ) );
cleanup:
qof_session_end( session_2 );
@@ -294,16 +294,16 @@
if (sess && qof_session_get_error(sess) != ERR_BACKEND_NO_ERR)
{
g_warning("Session Error: %d, %s", qof_session_get_error(sess),
- qof_session_get_error_message(sess));
- do_test( FALSE, "DB Session Creation Failed");
- goto cleanup;
+ qof_session_get_error_message(sess));
+ do_test( FALSE, "DB Session Creation Failed");
+ goto cleanup;
}
qof_session_load( sess, NULL );
qbe = qof_session_get_backend( sess );
book = qof_session_get_book( sess );
qof_book_begin_edit( book );
gnc_sql_set_table_version( (GncSqlBackend*)qbe,
- "Gnucash", GNC_RESAVE_VERSION - 1 );
+ "Gnucash", GNC_RESAVE_VERSION - 1 );
qof_book_commit_edit( book );
qof_session_end( sess );
qof_session_destroy( sess );
@@ -316,9 +316,9 @@
book = qof_session_get_book( sess );
qof_book_begin_edit( book );
gnc_sql_set_table_version( (GncSqlBackend*)qbe,
- "Gnucash", ourversion );
+ "Gnucash", ourversion );
gnc_sql_set_table_version( (GncSqlBackend*)qbe,
- "Gnucash-Resave", ourversion + 1 );
+ "Gnucash-Resave", ourversion + 1 );
qof_book_commit_edit( book );
qof_session_end( sess );
qof_session_destroy( sess );
Modified: gnucash/trunk/src/backend/sql/gnc-backend-sql.c
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-backend-sql.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/backend/sql/gnc-backend-sql.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -161,7 +161,7 @@
if ( pData->create_tables != NULL )
{
- update_progress( be );
+ update_progress( be );
(pData->create_tables)( be );
}
}
@@ -194,14 +194,14 @@
// Don't need to load anything if it has already been loaded with the fixed order
for ( i = 0; fixed_load_order[i] != NULL; i++ )
{
- update_progress( be );
+ update_progress( be );
if ( g_ascii_strcasecmp( type, fixed_load_order[i] ) == 0 ) return;
}
if ( other_load_order != NULL )
{
for ( i = 0; other_load_order[i] != NULL; i++ )
{
- update_progress( be );
+ update_progress( be );
if ( g_ascii_strcasecmp( type, other_load_order[i] ) == 0 ) return;
}
}
@@ -237,7 +237,7 @@
pData = qof_object_lookup_backend( fixed_load_order[i], GNC_SQL_BACKEND );
if ( pData->initial_load != NULL )
{
- update_progress( be );
+ update_progress( be );
(pData->initial_load)( be );
}
}
@@ -248,7 +248,7 @@
pData = qof_object_lookup_backend( other_load_order[i], GNC_SQL_BACKEND );
if ( pData->initial_load != NULL )
{
- update_progress( be );
+ update_progress( be );
(pData->initial_load)( be );
}
}
@@ -350,7 +350,7 @@
{
is_ok = gnc_sql_save_account( be, QOF_INSTANCE(GNC_ACCOUNT(node->data)) );
if ( !is_ok ) break;
- }
+ }
g_list_free( descendants );
}
update_progress( be );
@@ -369,7 +369,7 @@
is_ok = write_account_tree( be, gnc_book_get_root_account( be->primary_book ) );
if ( is_ok )
{
- update_progress( be );
+ update_progress( be );
is_ok = write_account_tree( be, gnc_book_get_template_root( be->primary_book ) );
}
@@ -407,7 +407,7 @@
data.be = be;
data.is_ok = TRUE;
(void)xaccAccountTreeForEachTransaction(
- gnc_book_get_root_account( be->primary_book ), write_tx, &data );
+ gnc_book_get_root_account( be->primary_book ), write_tx, &data );
update_progress( be );
return data.is_ok;
}
@@ -426,7 +426,7 @@
if ( gnc_account_n_descendants( ra ) > 0 )
{
(void)xaccAccountTreeForEachTransaction( ra, write_tx, &data );
- update_progress( be );
+ update_progress( be );
}
return data.is_ok;
@@ -465,7 +465,7 @@
if ( pData->write != NULL )
{
(void)(pData->write)( be );
- update_progress( be );
+ update_progress( be );
}
}
@@ -549,7 +549,7 @@
}
else
{
- qof_backend_set_error( (QofBackend*)be, ERR_BACKEND_SERVER_ERR );
+ qof_backend_set_error( (QofBackend*)be, ERR_BACKEND_SERVER_ERR );
is_ok = gnc_sql_connection_rollback_transaction( be->conn );
}
finish_progress( be );
@@ -616,9 +616,9 @@
if ( qof_book_is_readonly( be->primary_book ) )
{
- qof_backend_set_error( (QofBackend*)be, ERR_BACKEND_READONLY );
+ qof_backend_set_error( (QofBackend*)be, ERR_BACKEND_READONLY );
(void)gnc_sql_connection_rollback_transaction( be->conn );
- return;
+ return;
}
/* During initial load where objects are being created, don't commit
anything, but do mark the object as clean. */
@@ -665,7 +665,7 @@
be_data.is_ok = TRUE;
/* Set/update the application version in the database */
if ( gnc_sql_get_table_version( be, "Gnucash") != gnc_version )
- gnc_sql_set_table_version( be, "Gnucash", gnc_version );
+ gnc_sql_set_table_version( be, "Gnucash", gnc_version );
qof_object_foreach_backend( GNC_SQL_BACKEND, commit_cb, &be_data );
Modified: gnucash/trunk/src/business/business-gnome/gnc-plugin-page-invoice.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/gnc-plugin-page-invoice.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/business/business-gnome/gnc-plugin-page-invoice.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -705,7 +705,7 @@
static void
gnc_plugin_page_invoice_cmd_duplicateInvoice (GtkAction *action,
- GncPluginPageInvoice *plugin_page)
+ GncPluginPageInvoice *plugin_page)
{
GncPluginPageInvoicePrivate *priv;
@@ -828,7 +828,7 @@
static void
gnc_plugin_page_invoice_cmd_duplicateEntry (GtkAction *action,
- GncPluginPageInvoice *plugin_page)
+ GncPluginPageInvoice *plugin_page)
{
GncPluginPageInvoicePrivate *priv;
Modified: gnucash/trunk/src/business/business-ledger/gncEntryLedgerControl.c
===================================================================
--- gnucash/trunk/src/business/business-ledger/gncEntryLedgerControl.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/business/business-ledger/gncEntryLedgerControl.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -276,7 +276,7 @@
/* For invoice entries, Entry->Bill must be NULL, and vice versa */
qof_query_add_guid_match (query,
qof_query_build_param_list (should_be_null,
- QOF_PARAM_GUID, NULL),
+ QOF_PARAM_GUID, NULL),
NULL, QOF_QUERY_AND);
/* Set the sort order: By DATE_ENTERED, increasing, and returning
@@ -494,9 +494,9 @@
auto_entry =
/* Use this for book-wide auto-completion of the invoice entries */
find_entry_in_book_by_desc(ledger, desc);
-/* #else */
-/* gnc_find_entry_in_reg_by_desc(ledger, desc); */
-/* #endif */
+ /* #else */
+ /* gnc_find_entry_in_reg_by_desc(ledger, desc); */
+ /* #endif */
if (auto_entry == NULL)
return FALSE;
Modified: gnucash/trunk/src/engine/Transaction.c
===================================================================
--- gnucash/trunk/src/engine/Transaction.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/engine/Transaction.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -1805,9 +1805,9 @@
xaccTransBeginEdit(trans);
if (is_closing)
- kvp_frame_set_gint64 (trans->inst.kvp_data, trans_is_closing_str, 1);
+ kvp_frame_set_gint64 (trans->inst.kvp_data, trans_is_closing_str, 1);
else
- kvp_frame_replace_value_nc (trans->inst.kvp_data, trans_is_closing_str, NULL);
+ kvp_frame_replace_value_nc (trans->inst.kvp_data, trans_is_closing_str, NULL);
qof_instance_set_dirty(QOF_INSTANCE(trans));
xaccTransCommitEdit(trans);
}
@@ -1873,8 +1873,8 @@
xaccTransGetIsClosingTxn (const Transaction *trans)
{
return trans ?
- kvp_frame_get_gint64 (trans->inst.kvp_data, trans_is_closing_str)
- : FALSE;
+ kvp_frame_get_gint64 (trans->inst.kvp_data, trans_is_closing_str)
+ : FALSE;
}
/********************************************************************\
Modified: gnucash/trunk/src/engine/gnc-budget.c
===================================================================
--- gnucash/trunk/src/engine/gnc-budget.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/engine/gnc-budget.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -326,7 +326,7 @@
if ( gnc_budget_is_account_period_value_set(data->old_b, a, i) )
{
gnc_budget_set_account_period_value(data->new_b, a, i,
- gnc_budget_get_account_period_value(data->old_b, a, i));
+ gnc_budget_get_account_period_value(data->old_b, a, i));
}
}
}
Modified: gnucash/trunk/src/engine/gnc-commodity.c
===================================================================
--- gnucash/trunk/src/engine/gnc-commodity.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/engine/gnc-commodity.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -1354,10 +1354,10 @@
priv = GET_PRIVATE(cm);
- if (tz == priv->quote_tz)
+ if (tz == priv->quote_tz)
{
- LEAVE("Already correct TZ");
- return;
+ LEAVE("Already correct TZ");
+ return;
}
gnc_commodity_begin_edit(cm);
Modified: gnucash/trunk/src/gnome-utils/dialog-book-close.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-book-close.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/gnome-utils/dialog-book-close.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -104,7 +104,7 @@
xaccTransSetDatePostedSecs(txn->txn, cacb->cbw->close_date);
xaccTransSetDescription(txn->txn, cacb->cbw->desc);
xaccTransSetCurrency(txn->txn, cmdty);
- xaccTransSetIsClosingTxn(txn->txn, TRUE);
+ xaccTransSetIsClosingTxn(txn->txn, TRUE);
g_hash_table_insert(cacb->txns, cmdty, txn);
}
Modified: gnucash/trunk/src/gnome-utils/gnc-entry-quickfill.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-entry-quickfill.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/gnome-utils/gnc-entry-quickfill.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -55,8 +55,8 @@
if (0 == (event_type & (QOF_EVENT_MODIFY | QOF_EVENT_DESTROY)))
return;
-/* g_warning("entity %p, entity type %s, event type %s, user data %p, ecent data %p", */
-/* entity, entity->e_type, qofeventid_to_string(event_type), user_data, event_data); */
+ /* g_warning("entity %p, entity type %s, event type %s, user data %p, ecent data %p", */
+ /* entity, entity->e_type, qofeventid_to_string(event_type), user_data, event_data); */
desc = gncEntryGetDescription(GNC_ENTRY(entity));
if (event_type & QOF_EVENT_MODIFY)
@@ -124,7 +124,7 @@
QofQuery *query = new_query_for_entrys(book);
GList *entries = qof_query_run(query);
-/* g_warning("Found %d GncEntry items", g_list_length (entries)); */
+ /* g_warning("Found %d GncEntry items", g_list_length (entries)); */
result = g_new0(EntryQF, 1);
Modified: gnucash/trunk/src/gnome-utils/gnc-file.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-file.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/gnome-utils/gnc-file.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -412,18 +412,18 @@
case ERR_SQL_DB_TOO_OLD:
fmt = _("This database is from an older version of GnuCash. "
"Select OK to upgrade it to the current version, Cancel "
- "to mark it read-only.");
+ "to mark it read-only.");
response = gnc_ok_cancel_dialog(parent, GTK_RESPONSE_CANCEL, "%s", fmt);
- uh_oh = (response == GTK_RESPONSE_CANCEL);
+ uh_oh = (response == GTK_RESPONSE_CANCEL);
break;
case ERR_SQL_DB_TOO_NEW:
fmt = _("This database is from a newer version of GnuCash. "
"This version can read it, but cannot safely save to it. "
- "It will be marked read-only until you do File>Save As.");
+ "It will be marked read-only until you do File>Save As.");
gnc_warning_dialog (parent, "%s", fmt);
- uh_oh = TRUE;
+ uh_oh = TRUE;
break;
case ERR_SQL_DB_BUSY:
@@ -437,15 +437,15 @@
case ERR_SQL_BAD_DBI:
- fmt = _("The library \"libdbi\" installed on your system doesn't correctly "
+ fmt = _("The library \"libdbi\" installed on your system doesn't correctly "
"store large numbers. This means GnuCash cannot use SQL databases "
"correctly. Gnucash will not open or save to SQL databases until this is "
"fixed by installing a different version of \"libdbi\". Please see "
"https://bugzilla.gnome.org/show_bug.cgi?id=611936 for more "
"information.");
- gnc_error_dialog (parent, "%s", fmt);
- break;
+ gnc_error_dialog (parent, "%s", fmt);
+ break;
default:
PERR("FIXME: Unhandled error %d", io_error);
@@ -766,8 +766,8 @@
* don't bother with the message, just die. */
io_err = qof_session_get_error (new_session);
if ((ERR_BACKEND_LOCKED == io_err) ||
- (ERR_BACKEND_READONLY == io_err) ||
- (ERR_BACKEND_NO_SUCH_DB == io_err))
+ (ERR_BACKEND_READONLY == io_err) ||
+ (ERR_BACKEND_NO_SUCH_DB == io_err))
{
uh_oh = TRUE;
}
@@ -815,24 +815,24 @@
}
uh_oh = show_session_error (io_err, newfile, GNC_FILE_DIALOG_OPEN);
- /* Attempt to update the database if it's too old */
- if ( !uh_oh && io_err == ERR_SQL_DB_TOO_OLD )
- {
- gnc_window_show_progress(_("Re-saving user data..."), 0.0);
- qof_session_safe_save(new_session, gnc_window_show_progress);
- io_err = qof_session_get_error(new_session);
- uh_oh = show_session_error(io_err, newfile, GNC_FILE_DIALOG_SAVE);
- }
- /* Database is either too old and couldn't (or user didn't
- * want it to) be updated or it's too new. Mark it as
- * read-only
- */
- if (uh_oh && (io_err == ERR_SQL_DB_TOO_OLD ||
+ /* Attempt to update the database if it's too old */
+ if ( !uh_oh && io_err == ERR_SQL_DB_TOO_OLD )
+ {
+ gnc_window_show_progress(_("Re-saving user data..."), 0.0);
+ qof_session_safe_save(new_session, gnc_window_show_progress);
+ io_err = qof_session_get_error(new_session);
+ uh_oh = show_session_error(io_err, newfile, GNC_FILE_DIALOG_SAVE);
+ }
+ /* Database is either too old and couldn't (or user didn't
+ * want it to) be updated or it's too new. Mark it as
+ * read-only
+ */
+ if (uh_oh && (io_err == ERR_SQL_DB_TOO_OLD ||
io_err == ERR_SQL_DB_TOO_NEW))
- {
- qof_book_mark_readonly(qof_session_get_book(new_session));
- uh_oh = FALSE;
- }
+ {
+ qof_book_mark_readonly(qof_session_get_book(new_session));
+ uh_oh = FALSE;
+ }
new_root = gnc_book_get_root_account (qof_session_get_book (new_session));
if (uh_oh) new_root = NULL;
Modified: gnucash/trunk/src/gnome-utils/gnc-main-window.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-main-window.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/gnome-utils/gnc-main-window.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -2353,13 +2353,13 @@
GtkWidget* dialog;
gchar *reason = ".";
if ( errcode == ERR_BACKEND_READONLY )
- reason = _(": Book is marked read-only.");
+ reason = _(": Book is marked read-only.");
dialog = gtk_message_dialog_new( GTK_WINDOW(window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
_("Unable to save to database%s"),
- reason );
+ reason );
gtk_dialog_run(GTK_DIALOG (dialog));
gtk_widget_destroy(dialog);
Modified: gnucash/trunk/src/import-export/aqbanking/gnc-ab-getbalance.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-ab-getbalance.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-ab-getbalance.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -128,8 +128,8 @@
{
g_warning("gnc_ab_getbalance: Error on executing job");
gnc_error_dialog(parent, _("Error on executing job.\n\nStatus: %s - %s")
- , AB_Job_Status2Char(job_status)
- , AB_Job_GetResultText(job));
+ , AB_Job_Status2Char(job_status)
+ , AB_Job_GetResultText(job));
goto cleanup;
}
Modified: gnucash/trunk/src/import-export/aqbanking/gnc-ab-gettrans.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-ab-gettrans.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-ab-gettrans.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -193,8 +193,8 @@
{
g_warning("gnc_ab_gettrans: Error on executing job");
gnc_error_dialog(parent, _("Error on executing job.\n\nStatus: %s - %s")
- , AB_Job_Status2Char(job_status)
- , AB_Job_GetResultText(job));
+ , AB_Job_Status2Char(job_status)
+ , AB_Job_GetResultText(job));
goto cleanup;
}
Modified: gnucash/trunk/src/import-export/aqbanking/gnc-ab-utils.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-ab-utils.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-ab-utils.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -435,11 +435,11 @@
{
retval = g_strdup_printf("%s %s %s %s",
have_accountid ? _("Account") : "",
- have_accountid ? ab_other_accountid : "",
- have_bankcode ? _("Bank") : "",
- have_bankcode ? ab_other_bankcode : ""
- );
- g_strstrip(retval);
+ have_accountid ? ab_other_accountid : "",
+ have_bankcode ? _("Bank") : "",
+ have_bankcode ? ab_other_bankcode : ""
+ );
+ g_strstrip(retval);
}
else
{
Modified: gnucash/trunk/src/import-export/aqbanking/gnc-plugin-aqbanking.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-plugin-aqbanking.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-plugin-aqbanking.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -325,15 +325,15 @@
gnc_plugin_update_actions(action_group, need_account_actions,
"sensitive",
- (account && bankcode && *bankcode
- && accountid && *accountid));
+ (account && bankcode && *bankcode
+ && accountid && *accountid));
gnc_plugin_update_actions(action_group, need_account_actions,
- "visible",TRUE);
+ "visible", TRUE);
}
else
{
gnc_plugin_update_actions(action_group, need_account_actions,
- "sensitive",FALSE);
+ "sensitive", FALSE);
gnc_plugin_update_actions(action_group, need_account_actions,
"visible", FALSE);
}
Modified: gnucash/trunk/src/import-export/import-backend.c
===================================================================
--- gnucash/trunk/src/import-export/import-backend.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/import-export/import-backend.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -946,8 +946,8 @@
xaccTransBeginEdit(selected_match->trans);
xaccTransSetDatePostedSecs(selected_match->trans,
- xaccTransGetDate(xaccSplitGetParent(
- gnc_import_TransInfo_get_fsplit(trans_info))));
+ xaccTransGetDate(xaccSplitGetParent(
+ gnc_import_TransInfo_get_fsplit(trans_info))));
xaccSplitSetAmount(selected_match->split,
xaccSplitGetAmount(
@@ -988,7 +988,7 @@
if (gnc_import_split_has_online_id(trans_info->first_split))
{
gnc_import_set_split_online_id(selected_match->split,
- gnc_import_get_split_online_id(trans_info->first_split));
+ gnc_import_get_split_online_id(trans_info->first_split));
}
/* Done editing. */
@@ -1231,8 +1231,8 @@
trans_info->action = GNCImport_ADD;
}
if (best_match &&
- trans_info->action == GNCImport_CLEAR &&
- gnc_import_Settings_get_action_update_enabled(settings))
+ trans_info->action == GNCImport_CLEAR &&
+ gnc_import_Settings_get_action_update_enabled(settings))
{
if (best_match->update_proposed)
{
Modified: gnucash/trunk/src/import-export/import-main-matcher.c
===================================================================
--- gnucash/trunk/src/import-export/import-main-matcher.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/import-export/import-main-matcher.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -331,8 +331,8 @@
static void
gnc_gen_trans_update_toggled_cb (GtkCellRendererToggle *cell_renderer,
- gchar *path,
- GNCImportMainMatcher *gui)
+ gchar *path,
+ GNCImportMainMatcher *gui)
{
GtkTreeModel *model;
GtkTreeIter iter;
Modified: gnucash/trunk/src/import-export/qif-import/druid-qif-import.c
===================================================================
--- gnucash/trunk/src/import-export/qif-import/druid-qif-import.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/import-export/qif-import/druid-qif-import.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -2645,7 +2645,7 @@
wind->memo_map_info,
wind->security_hash,
scm_makfrom0str(currname),
- wind->transaction_status,
+ wind->transaction_status,
progress),
SCM_EOL);
gnc_progress_dialog_pop(wind->convert_progress);
@@ -3239,18 +3239,21 @@
/* Clear / Reconcile transaction if not specified in QIF file. */
status_pref = gnc_gconf_get_string(
- GCONF_SECTION, GCONF_NAME_DEFAULT_TRANSACTION_STATUS, &err);
+ GCONF_SECTION, GCONF_NAME_DEFAULT_TRANSACTION_STATUS, &err);
if (err != NULL)
{
g_warning("QIF import: gnc_gconf_get_string error: %s", err->message);
g_error_free(err);
g_warning("QIF import: Couldn't get %s setting from gconf.",
GCONF_NAME_DEFAULT_TRANSACTION_STATUS);
- } else {
+ }
+ else
+ {
if (g_strcmp0(status_pref, "cleared") == 0)
{
tmp_transaction_status = 'c';
- } else if (g_strcmp0(status_pref, "reconciled") == 0)
+ }
+ else if (g_strcmp0(status_pref, "reconciled") == 0)
{
tmp_transaction_status = 'y';
}
Modified: gnucash/trunk/src/libqof/qof/gnc-date.c
===================================================================
--- gnucash/trunk/src/libqof/qof/gnc-date.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/libqof/qof/gnc-date.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -373,7 +373,7 @@
void qof_date_completion_set(QofDateCompletion dc, int backmonths)
{
if (dc == QOF_DATE_COMPLETION_THISYEAR ||
- dc == QOF_DATE_COMPLETION_SLIDING)
+ dc == QOF_DATE_COMPLETION_SLIDING)
{
dateCompletion = dc;
}
@@ -655,7 +655,7 @@
}
else
{
- return - ((-a-1) / b) - 1;
+ return - ((-a - 1) / b) - 1;
}
}
Modified: gnucash/trunk/src/libqof/qof/qofbook.c
===================================================================
--- gnucash/trunk/src/libqof/qof/qofbook.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/libqof/qof/qofbook.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -470,7 +470,7 @@
/* Check if an error occured */
if (counter < 0)
- return NULL;
+ return NULL;
/* Increment the counter */
counter++;
@@ -480,8 +480,8 @@
if (!kvp)
{
- PWARN ("Book has no KVP_Frame");
- return NULL;
+ PWARN ("Book has no KVP_Frame");
+ return NULL;
}
/* Save off the new counter */
@@ -576,10 +576,10 @@
/* Skip two adjacent percent marks, which are literal percent
* marks */
if (p[0] == '%' && p[1] == '%')
- {
+ {
p += 2;
- continue;
- }
+ continue;
+ }
/* Break on a single percent mark, which is the start of the
* conversion specification */
if (*p == '%')
@@ -621,7 +621,9 @@
if (tmp == NULL)
{
return g_strdup_printf("Invalid length modifier and/or conversion specifier ('%.2s'), it should be: " G_GINT64_FORMAT, p);
- } else if (tmp != p) {
+ }
+ else if (tmp != p)
+ {
return g_strdup_printf("Garbage before length modifier and/or conversion specifier: '%*s'", (int)(tmp - p), p);
}
@@ -634,10 +636,10 @@
/* Skip two adjacent percent marks, which are literal percent
* marks */
if (p[0] == '%' && p[1] == '%')
- {
+ {
p += 2;
- continue;
- }
+ continue;
+ }
/* Break on a single percent mark, which is the start of the
* conversion specification */
if (*p == '%')
Modified: gnucash/trunk/src/libqof/qof/qofsession.c
===================================================================
--- gnucash/trunk/src/libqof/qof/qofsession.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/libqof/qof/qofsession.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -1250,10 +1250,10 @@
*/
err = qof_session_get_error(session);
if ((err != ERR_BACKEND_NO_ERR) &&
- (err != ERR_FILEIO_FILE_TOO_OLD) &&
- (err != ERR_FILEIO_NO_ENCODING) &&
- (err != ERR_SQL_DB_TOO_OLD) &&
- (err != ERR_SQL_DB_TOO_NEW))
+ (err != ERR_FILEIO_FILE_TOO_OLD) &&
+ (err != ERR_FILEIO_NO_ENCODING) &&
+ (err != ERR_SQL_DB_TOO_OLD) &&
+ (err != ERR_SQL_DB_TOO_NEW))
{
/* Something broke, put back the old stuff */
qof_book_set_backend (newbook, NULL);
@@ -1464,9 +1464,9 @@
msg = qof_backend_get_message(session->backend);
if (err != ERR_BACKEND_NO_ERR)
{
- g_free(session->book_id);
- session->book_id = NULL;
- qof_session_push_error (session, err, msg);
+ g_free(session->book_id);
+ session->book_id = NULL;
+ qof_session_push_error (session, err, msg);
}
}
Modified: gnucash/trunk/src/libqof/qof/qofsession.h
===================================================================
--- gnucash/trunk/src/libqof/qof/qofsession.h 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/libqof/qof/qofsession.h 2011-01-24 14:10:09 UTC (rev 20163)
@@ -243,7 +243,7 @@
* the new tables back.
*/
void qof_session_safe_save (QofSession *session,
- QofPercentageFunc percentage_func);
+ QofPercentageFunc percentage_func);
/**
* The qof_session_end() method will release the session lock. For the
Modified: gnucash/trunk/src/libqof/qof/test/test-qofbackend.c
===================================================================
--- gnucash/trunk/src/libqof/qof/test/test-qofbackend.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/libqof/qof/test/test-qofbackend.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -27,5 +27,5 @@
GTestSuite*
test_suite_qofbackend ( void )
{
-
+
}
Modified: gnucash/trunk/src/libqof/qof/test/test-qofsession.c
===================================================================
--- gnucash/trunk/src/libqof/qof/test/test-qofsession.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/libqof/qof/test/test-qofsession.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -65,8 +65,8 @@
test_session_safe_save( Fixture *fixture, gconstpointer pData )
{
qof_session_safe_save( fixture->session, percentage_fn );
- g_assert_cmpint( ERR_BACKEND_DATA_CORRUPT, ==,
- qof_session_get_error( fixture->session ));
+ g_assert_cmpint( ERR_BACKEND_DATA_CORRUPT, == ,
+ qof_session_get_error( fixture->session ));
g_assert( NULL == qof_session_get_url( fixture->session ));
}
Modified: gnucash/trunk/src/optional/python-bindings/sqlite3test.c
===================================================================
--- gnucash/trunk/src/optional/python-bindings/sqlite3test.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/optional/python-bindings/sqlite3test.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -3,16 +3,16 @@
int main()
{
- qof_log_init();
- qof_init();
- gnc_module_system_init();
- char * no_args[1] = { NULL };
- gnc_engine_init(0, no_args);
+ qof_log_init();
+ qof_init();
+ gnc_module_system_init();
+ char * no_args[1] = { NULL };
+ gnc_engine_init(0, no_args);
- QofSession * s = qof_session_new();
- qof_session_begin(s, "sqlite3:///tmp/blah.gnucash", 0, 1, 0);
- qof_session_load(s, NULL);
- qof_session_save(s, NULL);
- qof_session_end(s);
- return 0;
+ QofSession * s = qof_session_new();
+ qof_session_begin(s, "sqlite3:///tmp/blah.gnucash", 0, 1, 0);
+ qof_session_load(s, NULL);
+ qof_session_save(s, NULL);
+ qof_session_end(s);
+ return 0;
}
Modified: gnucash/trunk/src/plugins/bi_import/bi_import.c
===================================================================
--- gnucash/trunk/src/plugins/bi_import/bi_import.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/plugins/bi_import/bi_import.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -82,142 +82,142 @@
bi_import_result
gnc_bi_import_read_file (const gchar * filename, const gchar * parser_regexp,
- GtkListStore * store, guint max_rows,
- bi_import_stats * stats)
+ GtkListStore * store, guint max_rows,
+ bi_import_stats * stats)
{
- // some statistics
- bi_import_stats stats_fallback;
- FILE *f;
+ // some statistics
+ bi_import_stats stats_fallback;
+ FILE *f;
- // regexp
- char *line;
- gchar *line_utf8, *temp;
- GMatchInfo *match_info;
- GError *err;
- GRegex *regexpat;
+ // regexp
+ char *line;
+ gchar *line_utf8, *temp;
+ GMatchInfo *match_info;
+ GError *err;
+ GRegex *regexpat;
- // model
- GtkTreeIter iter;
+ // model
+ GtkTreeIter iter;
- f = g_fopen (filename, "rt");
- if (!f)
+ f = g_fopen (filename, "rt");
+ if (!f)
{
- //gnc_error_dialog( 0, _("File %s cannot be opened."), filename );
- return RESULT_OPEN_FAILED;
+ //gnc_error_dialog( 0, _("File %s cannot be opened."), filename );
+ return RESULT_OPEN_FAILED;
}
- // set up statistics
- if (!stats)
- stats = &stats_fallback;
+ // set up statistics
+ if (!stats)
+ stats = &stats_fallback;
- // compile the regular expression and check for errors
- err = NULL;
- regexpat =
- g_regex_new (parser_regexp, G_REGEX_EXTENDED | G_REGEX_OPTIMIZE, 0, &err);
- if (err != NULL)
+ // compile the regular expression and check for errors
+ err = NULL;
+ regexpat =
+ g_regex_new (parser_regexp, G_REGEX_EXTENDED | G_REGEX_OPTIMIZE, 0, &err);
+ if (err != NULL)
{
- GtkWidget *dialog;
- gchar *errmsg;
+ GtkWidget *dialog;
+ gchar *errmsg;
- errmsg = g_strdup_printf (_("Error in regular expression '%s':\n%s"),
- parser_regexp, err->message);
- g_error_free (err);
- err = NULL;
+ errmsg = g_strdup_printf (_("Error in regular expression '%s':\n%s"),
+ parser_regexp, err->message);
+ g_error_free (err);
+ err = NULL;
- dialog = gtk_message_dialog_new (NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK, "%s", errmsg);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- g_free (errmsg);
- errmsg = 0;
+ dialog = gtk_message_dialog_new (NULL,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK, "%s", errmsg);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ g_free (errmsg);
+ errmsg = 0;
- fclose (f);
- return RESULT_ERROR_IN_REGEXP;
+ fclose (f);
+ return RESULT_ERROR_IN_REGEXP;
}
- // start the import
- stats->n_imported = 0;
- stats->n_ignored = 0;
- stats->ignored_lines = g_string_new (NULL);
+ // start the import
+ stats->n_imported = 0;
+ stats->n_ignored = 0;
+ stats->ignored_lines = g_string_new (NULL);
#define buffer_size 1000
- line = g_malloc0 (buffer_size);
- while (!feof (f)
- && ((max_rows == 0)
- || (stats->n_imported + stats->n_ignored < max_rows)))
+ line = g_malloc0 (buffer_size);
+ while (!feof (f)
+ && ((max_rows == 0)
+ || (stats->n_imported + stats->n_ignored < max_rows)))
{
- int l;
- // read one line
- if (!fgets (line, buffer_size, f))
- break; // eof
- // now strip the '\n' from the end of the line
- l = strlen (line);
- if ((l > 0) && (line[l - 1] == '\n'))
- line[l - 1] = 0;
+ int l;
+ // read one line
+ if (!fgets (line, buffer_size, f))
+ break; // eof
+ // now strip the '\n' from the end of the line
+ l = strlen (line);
+ if ((l > 0) && (line[l - 1] == '\n'))
+ line[l - 1] = 0;
- // convert line from locale into utf8
- line_utf8 = g_locale_to_utf8 (line, -1, NULL, NULL, NULL);
+ // convert line from locale into utf8
+ line_utf8 = g_locale_to_utf8 (line, -1, NULL, NULL, NULL);
- // parse the line
- match_info = NULL; // it seems, that in contrast to documentation, match_info is not alsways set -> g_match_info_free will segfault
- if (g_regex_match (regexpat, line_utf8, 0, &match_info))
- {
- // match found
- stats->n_imported++;
+ // parse the line
+ match_info = NULL; // it seems, that in contrast to documentation, match_info is not alsways set -> g_match_info_free will segfault
+ if (g_regex_match (regexpat, line_utf8, 0, &match_info))
+ {
+ // match found
+ stats->n_imported++;
- // fill in the values
- gtk_list_store_append (store, &iter);
- FILL_IN_HELPER (_("id"), ID);
- FILL_IN_HELPER ("date_opened", DATE_OPENED);
- FILL_IN_HELPER ("owner_id", OWNER_ID);
- FILL_IN_HELPER ("biing_id", BILLING_ID);
- FILL_IN_HELPER ("notes", NOTES);
+ // fill in the values
+ gtk_list_store_append (store, &iter);
+ FILL_IN_HELPER (_("id"), ID);
+ FILL_IN_HELPER ("date_opened", DATE_OPENED);
+ FILL_IN_HELPER ("owner_id", OWNER_ID);
+ FILL_IN_HELPER ("biing_id", BILLING_ID);
+ FILL_IN_HELPER ("notes", NOTES);
- FILL_IN_HELPER ("date", DATE);
- FILL_IN_HELPER ("desc", DESC);
- FILL_IN_HELPER ("action", ACTION);
- FILL_IN_HELPER ("account", ACCOUNT);
- FILL_IN_HELPER ("quantity", QUANTITY);
- FILL_IN_HELPER ("price", PRICE);
- FILL_IN_HELPER ("disc_type", DISC_TYPE);
- FILL_IN_HELPER ("disc_how", DISC_HOW);
- FILL_IN_HELPER ("discount", DISCOUNT);
- FILL_IN_HELPER ("taxable", TAXABLE);
- FILL_IN_HELPER ("taxincluded", TAXINCLUDED);
- FILL_IN_HELPER ("tax_table", TAX_TABLE);
+ FILL_IN_HELPER ("date", DATE);
+ FILL_IN_HELPER ("desc", DESC);
+ FILL_IN_HELPER ("action", ACTION);
+ FILL_IN_HELPER ("account", ACCOUNT);
+ FILL_IN_HELPER ("quantity", QUANTITY);
+ FILL_IN_HELPER ("price", PRICE);
+ FILL_IN_HELPER ("disc_type", DISC_TYPE);
+ FILL_IN_HELPER ("disc_how", DISC_HOW);
+ FILL_IN_HELPER ("discount", DISCOUNT);
+ FILL_IN_HELPER ("taxable", TAXABLE);
+ FILL_IN_HELPER ("taxincluded", TAXINCLUDED);
+ FILL_IN_HELPER ("tax_table", TAX_TABLE);
- FILL_IN_HELPER ("date_posted", DATE_POSTED);
- FILL_IN_HELPER ("due_date", DUE_DATE);
- FILL_IN_HELPER ("account_posted", ACCOUNT_POSTED);
- FILL_IN_HELPER ("memo_posted", MEMO_POSTED);
- FILL_IN_HELPER ("accu_splits", ACCU_SPLITS);
- }
- else
- {
- // ignore line
- stats->n_ignored++;
- g_string_append (stats->ignored_lines, line_utf8);
- g_string_append_c (stats->ignored_lines, '\n');
- }
+ FILL_IN_HELPER ("date_posted", DATE_POSTED);
+ FILL_IN_HELPER ("due_date", DUE_DATE);
+ FILL_IN_HELPER ("account_posted", ACCOUNT_POSTED);
+ FILL_IN_HELPER ("memo_posted", MEMO_POSTED);
+ FILL_IN_HELPER ("accu_splits", ACCU_SPLITS);
+ }
+ else
+ {
+ // ignore line
+ stats->n_ignored++;
+ g_string_append (stats->ignored_lines, line_utf8);
+ g_string_append_c (stats->ignored_lines, '\n');
+ }
- g_match_info_free (match_info);
- match_info = 0;
- g_free (line_utf8);
- line_utf8 = 0;
+ g_match_info_free (match_info);
+ match_info = 0;
+ g_free (line_utf8);
+ line_utf8 = 0;
}
- g_free (line);
- line = 0;
+ g_free (line);
+ line = 0;
- g_regex_unref (regexpat);
- regexpat = 0;
- fclose (f);
+ g_regex_unref (regexpat);
+ regexpat = 0;
+ fclose (f);
- if (stats == &stats_fallback)
- // stats are not requested -> free the string
- g_string_free (stats->ignored_lines, TRUE);
+ if (stats == &stats_fallback)
+ // stats are not requested -> free the string
+ g_string_free (stats->ignored_lines, TRUE);
- return RESULT_OK;
+ return RESULT_OK;
}
@@ -229,231 +229,231 @@
//! * if price is unset, delete row
void
gnc_bi_import_fix_bis (GtkListStore * store, guint * fixed, guint * deleted,
- GString * info)
+ GString * info)
{
- GtkTreeIter iter;
- gboolean valid, row_deleted, row_fixed;
- gchar *id, *date_opened, *date_posted, *owner_id, *date, *quantity, *price;
- GString *prev_id, *prev_date_opened, *prev_date_posted, *prev_owner_id, *prev_date; // needed to fix multi line invoices
- guint dummy;
+ GtkTreeIter iter;
+ gboolean valid, row_deleted, row_fixed;
+ gchar *id, *date_opened, *date_posted, *owner_id, *date, *quantity, *price;
+ GString *prev_id, *prev_date_opened, *prev_date_posted, *prev_owner_id, *prev_date; // needed to fix multi line invoices
+ guint dummy;
- // allow the call to this function with only GtkListeStore* specified
- if (!fixed)
- fixed = &dummy;
- if (!deleted)
- deleted = &dummy;
+ // allow the call to this function with only GtkListeStore* specified
+ if (!fixed)
+ fixed = &dummy;
+ if (!deleted)
+ deleted = &dummy;
- *fixed = 0;
- *deleted = 0;
+ *fixed = 0;
+ *deleted = 0;
- // init strings
- prev_id = g_string_new ("");
- prev_date_opened = g_string_new ("");
- prev_date_posted = g_string_new ("");
- prev_owner_id = g_string_new ("");
- prev_date = g_string_new ("");
+ // init strings
+ prev_id = g_string_new ("");
+ prev_date_opened = g_string_new ("");
+ prev_date_posted = g_string_new ("");
+ prev_owner_id = g_string_new ("");
+ prev_date = g_string_new ("");
- valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
- while (valid)
+ valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
+ while (valid)
{
- row_deleted = FALSE;
- row_fixed = FALSE;
+ row_deleted = FALSE;
+ row_fixed = FALSE;
- // Walk through the list, reading each row
- gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
- ID, &id,
- DATE_OPENED, &date_opened,
- DATE_POSTED, &date_posted,
- OWNER_ID, &owner_id,
- DATE, &date,
- QUANTITY, &quantity, PRICE, &price, -1);
+ // Walk through the list, reading each row
+ gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
+ ID, &id,
+ DATE_OPENED, &date_opened,
+ DATE_POSTED, &date_posted,
+ OWNER_ID, &owner_id,
+ DATE, &date,
+ QUANTITY, &quantity, PRICE, &price, -1);
- if (strlen (price) == 0)
- {
- // invalid row (no price given)
- // no fix possible -> delete row
- gtk_list_store_remove (store, &iter);
- row_deleted = TRUE;
- g_string_append_printf (info,
- _("ROW DELETED, PRICE_NOT_SET: id=%s\n"),
- id);
- }
- else if (strlen (quantity) == 0)
- {
- // invalid row (no quantity given)
- // no fix possible -> delete row
- gtk_list_store_remove (store, &iter);
- row_deleted = TRUE;
- g_string_append_printf (info, _("ROW DELETED, QTY_NOT_SET: id=%s\n"),
- id);
- }
- else
- {
- if (strlen (id) == 0)
- {
- // no invoice id specified
- if (prev_id->len == 0)
- {
- // cannot fix -> delete row
- gtk_list_store_remove (store, &iter);
- row_deleted = TRUE;
- g_string_append_printf (info,
- _("ROW DELETED, ID_NOT_SET\n"));
- }
- else
- {
- // this is a fixable multi line invoice
- gtk_list_store_set (store, &iter, ID, prev_id->str, -1);
- row_fixed = TRUE;
- }
- }
- else
- {
- // remember invoice id (to be able to fix multi line invoices)
- g_string_assign (prev_id, id);
- // new invoice => reset all other fixable entries
- g_string_assign (prev_date_opened, "");
- g_string_assign (prev_date_posted, "");
- g_string_assign (prev_owner_id, "");
- g_string_assign (prev_date, "");
- }
- }
+ if (strlen (price) == 0)
+ {
+ // invalid row (no price given)
+ // no fix possible -> delete row
+ gtk_list_store_remove (store, &iter);
+ row_deleted = TRUE;
+ g_string_append_printf (info,
+ _("ROW DELETED, PRICE_NOT_SET: id=%s\n"),
+ id);
+ }
+ else if (strlen (quantity) == 0)
+ {
+ // invalid row (no quantity given)
+ // no fix possible -> delete row
+ gtk_list_store_remove (store, &iter);
+ row_deleted = TRUE;
+ g_string_append_printf (info, _("ROW DELETED, QTY_NOT_SET: id=%s\n"),
+ id);
+ }
+ else
+ {
+ if (strlen (id) == 0)
+ {
+ // no invoice id specified
+ if (prev_id->len == 0)
+ {
+ // cannot fix -> delete row
+ gtk_list_store_remove (store, &iter);
+ row_deleted = TRUE;
+ g_string_append_printf (info,
+ _("ROW DELETED, ID_NOT_SET\n"));
+ }
+ else
+ {
+ // this is a fixable multi line invoice
+ gtk_list_store_set (store, &iter, ID, prev_id->str, -1);
+ row_fixed = TRUE;
+ }
+ }
+ else
+ {
+ // remember invoice id (to be able to fix multi line invoices)
+ g_string_assign (prev_id, id);
+ // new invoice => reset all other fixable entries
+ g_string_assign (prev_date_opened, "");
+ g_string_assign (prev_date_posted, "");
+ g_string_assign (prev_owner_id, "");
+ g_string_assign (prev_date, "");
+ }
+ }
- if (!row_deleted)
- {
- // the row is valid (price and id are valid)
+ if (!row_deleted)
+ {
+ // the row is valid (price and id are valid)
- if (strlen (date_opened) == 0)
- {
- if (prev_date_opened->len == 0)
- {
- // fix this by using the current date (why is this so complicated?)
- gchar temp[20];
- GDate *date;
- time_t secs;
- struct tm now;
- time (&secs);
- localtime_r (&secs, &now);
- date =
- g_date_new_dmy (now.tm_mday, now.tm_mon + 1,
- now.tm_year + 1900);
- g_date_strftime (temp, 20, "%x", date); // create a locale specific date string
- g_string_assign (prev_date_opened, temp);
- g_date_free (date);
- }
- // fix this by using the previous date_opened value (multi line invoice)
- gtk_list_store_set (store, &iter, DATE_OPENED,
- prev_date_opened->str, -1);
- row_fixed = TRUE;
- }
- else
- {
- // remember date_opened (to be able to fix multi line invoices)
- g_string_assign (prev_date_opened, date_opened);
- }
+ if (strlen (date_opened) == 0)
+ {
+ if (prev_date_opened->len == 0)
+ {
+ // fix this by using the current date (why is this so complicated?)
+ gchar temp[20];
+ GDate *date;
+ time_t secs;
+ struct tm now;
+ time (&secs);
+ localtime_r (&secs, &now);
+ date =
+ g_date_new_dmy (now.tm_mday, now.tm_mon + 1,
+ now.tm_year + 1900);
+ g_date_strftime (temp, 20, "%x", date); // create a locale specific date string
+ g_string_assign (prev_date_opened, temp);
+ g_date_free (date);
+ }
+ // fix this by using the previous date_opened value (multi line invoice)
+ gtk_list_store_set (store, &iter, DATE_OPENED,
+ prev_date_opened->str, -1);
+ row_fixed = TRUE;
+ }
+ else
+ {
+ // remember date_opened (to be able to fix multi line invoices)
+ g_string_assign (prev_date_opened, date_opened);
+ }
- // date_opened is valid
+ // date_opened is valid
- if (strlen (date_posted) == 0)
- {
- if (prev_date_posted->len == 0)
- {
- // this invoice will have to get posted manually
- }
- else
- {
- // multi line invoice => fix it
- gtk_list_store_set (store, &iter, DATE_POSTED,
- prev_date_posted->str, -1);
- row_fixed = TRUE;
- }
- }
- else
- {
- // remember date_opened (to be able to fix multi line invoices)
- g_string_assign (prev_date_posted, date_posted);
- }
+ if (strlen (date_posted) == 0)
+ {
+ if (prev_date_posted->len == 0)
+ {
+ // this invoice will have to get posted manually
+ }
+ else
+ {
+ // multi line invoice => fix it
+ gtk_list_store_set (store, &iter, DATE_POSTED,
+ prev_date_posted->str, -1);
+ row_fixed = TRUE;
+ }
+ }
+ else
+ {
+ // remember date_opened (to be able to fix multi line invoices)
+ g_string_assign (prev_date_posted, date_posted);
+ }
- // date_posted is valid
+ // date_posted is valid
- if (strlen (quantity) == 0)
- {
- // quantity is unset => set to 1
- gtk_list_store_set (store, &iter, QUANTITY, "1", -1);
- row_fixed = TRUE;
- }
+ if (strlen (quantity) == 0)
+ {
+ // quantity is unset => set to 1
+ gtk_list_store_set (store, &iter, QUANTITY, "1", -1);
+ row_fixed = TRUE;
+ }
- // quantity is valid
+ // quantity is valid
- if (strlen (owner_id) == 0)
- {
- if (prev_owner_id->len == 0)
- {
- // no customer given and not fixable => delete row
- gtk_list_store_remove (store, &iter);
- row_deleted = TRUE;
- g_string_append_printf (info,
- _("ROW DELETED, VENDOR_NOT_SET: id=%s\n"),
- id);
- }
- else
- {
- gtk_list_store_set (store, &iter, owner_id,
- prev_owner_id->str, -1);
- row_fixed = TRUE;
- }
- }
- else
- {
- // remember owner_id
- g_string_assign (prev_owner_id, owner_id);
- }
- // now check, if customer exists
- if (!gnc_search_vendor_on_id
- (gnc_get_current_book (), prev_owner_id->str))
- {
- // customer not found => delete row
- gtk_list_store_remove (store, &iter);
- row_deleted = TRUE;
- g_string_append_printf (info,
- _("ROW DELETED, VENDOR_DOES_NOT_EXIST: id=%s\n"),
- id);
- }
+ if (strlen (owner_id) == 0)
+ {
+ if (prev_owner_id->len == 0)
+ {
+ // no customer given and not fixable => delete row
+ gtk_list_store_remove (store, &iter);
+ row_deleted = TRUE;
+ g_string_append_printf (info,
+ _("ROW DELETED, VENDOR_NOT_SET: id=%s\n"),
+ id);
+ }
+ else
+ {
+ gtk_list_store_set (store, &iter, owner_id,
+ prev_owner_id->str, -1);
+ row_fixed = TRUE;
+ }
+ }
+ else
+ {
+ // remember owner_id
+ g_string_assign (prev_owner_id, owner_id);
+ }
+ // now check, if customer exists
+ if (!gnc_search_vendor_on_id
+ (gnc_get_current_book (), prev_owner_id->str))
+ {
+ // customer not found => delete row
+ gtk_list_store_remove (store, &iter);
+ row_deleted = TRUE;
+ g_string_append_printf (info,
+ _("ROW DELETED, VENDOR_DOES_NOT_EXIST: id=%s\n"),
+ id);
+ }
- // owner_id is valid
- }
+ // owner_id is valid
+ }
- g_free (id);
- g_free (date_opened);
- g_free (date_posted);
- g_free (owner_id);
- g_free (date);
- g_free (quantity);
- g_free (price);
- if (row_deleted)
- {
- (*deleted)++;
- // reset all remembered values
- g_string_assign (prev_id, "");
- g_string_assign (prev_date_opened, "");
- g_string_assign (prev_date_posted, "");
- g_string_assign (prev_owner_id, "");
- g_string_assign (prev_date, "");
- }
- else if (row_fixed)
- (*fixed)++;
- valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter);
+ g_free (id);
+ g_free (date_opened);
+ g_free (date_posted);
+ g_free (owner_id);
+ g_free (date);
+ g_free (quantity);
+ g_free (price);
+ if (row_deleted)
+ {
+ (*deleted)++;
+ // reset all remembered values
+ g_string_assign (prev_id, "");
+ g_string_assign (prev_date_opened, "");
+ g_string_assign (prev_date_posted, "");
+ g_string_assign (prev_owner_id, "");
+ g_string_assign (prev_date, "");
+ }
+ else if (row_fixed)
+ (*fixed)++;
+ valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter);
}
- // deallocate strings
- g_string_free (prev_id, TRUE);
- g_string_free (prev_date_opened, TRUE);
- g_string_free (prev_date_posted, TRUE);
- g_string_free (prev_owner_id, TRUE);
- g_string_free (prev_date, TRUE);
+ // deallocate strings
+ g_string_free (prev_id, TRUE);
+ g_string_free (prev_date_opened, TRUE);
+ g_string_free (prev_date_posted, TRUE);
+ g_string_free (prev_owner_id, TRUE);
+ g_string_free (prev_date, TRUE);
- if (info && (info->len > 0))
- g_string_prepend (info, _("These rows were deleted:\n\n"));
+ if (info && (info->len > 0))
+ g_string_prepend (info, _("These rows were deleted:\n\n"));
}
@@ -467,248 +467,265 @@
***********************************************************************/
void
gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
- guint * n_invoices_created,
- guint * n_invoices_updated, gchar * type)
+ guint * n_invoices_created,
+ guint * n_invoices_updated, gchar * type)
{
- gboolean valid;
- GtkTreeIter iter;
- gchar *id, *date_opened, *owner_id, *biing_id, *notes;
- gchar *date, *desc, *action, *account, *quantity, *price, *disc_type,
- *disc_how, *discount, *taxable, *taxincluded, *tax_table;
- gchar *date_posted, *due_date, *account_posted, *memo_posted,
- *accumulatesplits;
- guint dummy;
- GncInvoice *invoice;
- GncOrder *order;
- GncEntry *entry;
- gint day, month, year;
- gnc_numeric n;
- GncOwner *owner;
- Account *acc;
- enum update{YES = GTK_RESPONSE_YES, NO = GTK_RESPONSE_NO}update;
- GtkWidget *dialog;
- Timespec today;
+ gboolean valid;
+ GtkTreeIter iter;
+ gchar *id, *date_opened, *owner_id, *biing_id, *notes;
+ gchar *date, *desc, *action, *account, *quantity, *price, *disc_type,
+ *disc_how, *discount, *taxable, *taxincluded, *tax_table;
+ gchar *date_posted, *due_date, *account_posted, *memo_posted,
+ *accumulatesplits;
+ guint dummy;
+ GncInvoice *invoice;
+ GncOrder *order;
+ GncEntry *entry;
+ gint day, month, year;
+ gnc_numeric n;
+ GncOwner *owner;
+ Account *acc;
+ enum update {YES = GTK_RESPONSE_YES, NO = GTK_RESPONSE_NO} update;
+ GtkWidget *dialog;
+ Timespec today;
- // these arguments are needed
- g_return_if_fail (store && book);
+ // these arguments are needed
+ g_return_if_fail (store && book);
- // allow to call this function without statistics
- if (!n_invoices_created)
- n_invoices_created = &dummy;
- if (!n_invoices_updated)
- n_invoices_updated = &dummy;
- *n_invoices_created = 0;
- *n_invoices_updated = 0;
+ // allow to call this function without statistics
+ if (!n_invoices_created)
+ n_invoices_created = &dummy;
+ if (!n_invoices_updated)
+ n_invoices_updated = &dummy;
+ *n_invoices_created = 0;
+ *n_invoices_updated = 0;
- invoice = NULL;
- order = NULL;
- update = NO;
+ invoice = NULL;
+ order = NULL;
+ update = NO;
- valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
- while (valid)
+ valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
+ while (valid)
{
- // Walk through the list, reading each row
- gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, ID, &id, DATE_OPENED, &date_opened, DATE_POSTED, &date_posted, // if autoposting requested
- DUE_DATE, &due_date, // if autoposting requested
- ACCOUNT_POSTED, &account_posted, // if autoposting requested
- MEMO_POSTED, &memo_posted, // if autoposting requested
- ACCU_SPLITS, &accumulatesplits, // if autoposting requested
- OWNER_ID, &owner_id,
- BILLING_ID, &biing_id,
- NOTES, ¬es,
- DATE, &date,
- DESC, &desc,
- ACTION, &action,
- ACCOUNT, &account,
- QUANTITY, &quantity,
- PRICE, &price,
- DISC_TYPE, &disc_type,
- DISC_HOW, &disc_how,
- DISCOUNT, &discount,
- TAXABLE, &taxable,
- TAXINCLUDED, &taxincluded,
- TAX_TABLE, &tax_table, -1);
+ // Walk through the list, reading each row
+ gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, ID, &id, DATE_OPENED, &date_opened, DATE_POSTED, &date_posted, // if autoposting requested
+ DUE_DATE, &due_date, // if autoposting requested
+ ACCOUNT_POSTED, &account_posted, // if autoposting requested
+ MEMO_POSTED, &memo_posted, // if autoposting requested
+ ACCU_SPLITS, &accumulatesplits, // if autoposting requested
+ OWNER_ID, &owner_id,
+ BILLING_ID, &biing_id,
+ NOTES, ¬es,
+ DATE, &date,
+ DESC, &desc,
+ ACTION, &action,
+ ACCOUNT, &account,
+ QUANTITY, &quantity,
+ PRICE, &price,
+ DISC_TYPE, &disc_type,
+ DISC_HOW, &disc_how,
+ DISCOUNT, &discount,
+ TAXABLE, &taxable,
+ TAXINCLUDED, &taxincluded,
+ TAX_TABLE, &tax_table, -1);
- // TODO: Assign a new invoice number if one is absent. BUT we don't want to assign a new invoice for every line!!
- // so we'd have to flag this up somehow or add an option in the import GUI. The former implies that we make
- // an assumption about what the importer (person) wants to do. It seems resonable that a CSV file full of items with
- // If an invoice exists then we add to it in this current schema.
- // no predefined invoice number is a new invoice that's in need of a new number.
- // This was not designed to satisfy the need for repeat invoices however, so maybe we need a another method for this, after all
- // It should be easier to copy an invoice with a new ID than to go through all this malarky.
- if (g_ascii_strcasecmp (type, "BILL"))
- invoice = gnc_search_bill_on_id (book, id);
- else if (g_ascii_strcasecmp (type, "INVOICE"))
- invoice = gnc_search_invoice_on_id (book, id);
+ // TODO: Assign a new invoice number if one is absent. BUT we don't want to assign a new invoice for every line!!
+ // so we'd have to flag this up somehow or add an option in the import GUI. The former implies that we make
+ // an assumption about what the importer (person) wants to do. It seems resonable that a CSV file full of items with
+ // If an invoice exists then we add to it in this current schema.
+ // no predefined invoice number is a new invoice that's in need of a new number.
+ // This was not designed to satisfy the need for repeat invoices however, so maybe we need a another method for this, after all
+ // It should be easier to copy an invoice with a new ID than to go through all this malarky.
+ if (g_ascii_strcasecmp (type, "BILL"))
+ invoice = gnc_search_bill_on_id (book, id);
+ else if (g_ascii_strcasecmp (type, "INVOICE"))
+ invoice = gnc_search_invoice_on_id (book, id);
- if (!invoice)
- {
- // new invoice
- invoice = gncInvoiceCreate (book);
- gncInvoiceSetID (invoice, id);
- owner = gncOwnerCreate ();
- if (g_ascii_strcasecmp (type, "BILL") == 0)
- gncOwnerInitVendor (owner,
- gnc_search_vendor_on_id (book, owner_id));
- else if (g_ascii_strcasecmp (type, "INVOICE") == 0)
- gncOwnerInitCustomer (owner,
- gnc_search_customer_on_id (book, owner_id));
- gncInvoiceSetOwner (invoice, owner);
- gncInvoiceSetCurrency (invoice, gncOwnerGetCurrency (owner)); // Set the invoice currency based on the owner
- if (!(g_ascii_strcasecmp (type, ""))) // If a date is specified in CSV
- {
- qof_scan_date (date_opened, &day, &month, &year);
- gncInvoiceSetDateOpened (invoice,
- gnc_dmy2timespec (day, month, year));
- }
- else // If no date in CSV
- {
- time_t now = time (NULL);
- Timespec now_timespec;
- timespecFromTime_t (&now_timespec, now);
- gncInvoiceSetDateOpened (invoice, now_timespec);
- }
- gncInvoiceSetBillingID (invoice, biing_id);
- gncInvoiceSetNotes (invoice, notes);
- gncInvoiceSetActive (invoice, TRUE);
- //if (g_ascii_strcasecmp(type,"INVOICE"))gncInvoiceSetBillTo( invoice, billto );
- (*n_invoices_created)++;
- update = YES;
- }
+ if (!invoice)
+ {
+ // new invoice
+ invoice = gncInvoiceCreate (book);
+ gncInvoiceSetID (invoice, id);
+ owner = gncOwnerCreate ();
+ if (g_ascii_strcasecmp (type, "BILL") == 0)
+ gncOwnerInitVendor (owner,
+ gnc_search_vendor_on_id (book, owner_id));
+ else if (g_ascii_strcasecmp (type, "INVOICE") == 0)
+ gncOwnerInitCustomer (owner,
+ gnc_search_customer_on_id (book, owner_id));
+ gncInvoiceSetOwner (invoice, owner);
+ gncInvoiceSetCurrency (invoice, gncOwnerGetCurrency (owner)); // Set the invoice currency based on the owner
+ if (!(g_ascii_strcasecmp (type, ""))) // If a date is specified in CSV
+ {
+ qof_scan_date (date_opened, &day, &month, &year);
+ gncInvoiceSetDateOpened (invoice,
+ gnc_dmy2timespec (day, month, year));
+ }
+ else // If no date in CSV
+ {
+ time_t now = time (NULL);
+ Timespec now_timespec;
+ timespecFromTime_t (&now_timespec, now);
+ gncInvoiceSetDateOpened (invoice, now_timespec);
+ }
+ gncInvoiceSetBillingID (invoice, biing_id);
+ gncInvoiceSetNotes (invoice, notes);
+ gncInvoiceSetActive (invoice, TRUE);
+ //if (g_ascii_strcasecmp(type,"INVOICE"))gncInvoiceSetBillTo( invoice, billto );
+ (*n_invoices_created)++;
+ update = YES;
+ }
// I want to warn the user that an existing billvoice exists, but not every
// time.
// An import can contain many lines usually referring to the same invoice.
// NB: Posted invoices are NEVER updated.
- else // if invoice exists
- {
- if (gncInvoiceIsPosted (invoice)) // Is it already posted?
- {
- valid =
- gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter);
- continue; // If already posted then never import
- }
- if (update != YES) // Pop up a dialog to ask if updates are the expected action
- {
- dialog = gtk_message_dialog_new (NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_YES_NO,
- "%s",
- _("Are you sure you have bills/invoices to update?"));
- update = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- if (update == NO)
- { // Cleanup and leave
- g_free (id); g_free (date_opened); g_free (owner_id); g_free (biing_id);
- g_free (notes); g_free (date); g_free (desc); g_free (action);
- g_free (account); g_free (quantity); g_free (price); g_free (disc_type);
- g_free (disc_how); g_free (discount); g_free (taxable); g_free (taxincluded);
- g_free (tax_table); g_free (date_posted); g_free (due_date); g_free (account_posted);
- g_free (memo_posted); g_free (accumulatesplits);
- return;
- }
- }
- (*n_invoices_updated)++;
- }
+ else // if invoice exists
+ {
+ if (gncInvoiceIsPosted (invoice)) // Is it already posted?
+ {
+ valid =
+ gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter);
+ continue; // If already posted then never import
+ }
+ if (update != YES) // Pop up a dialog to ask if updates are the expected action
+ {
+ dialog = gtk_message_dialog_new (NULL,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_YES_NO,
+ "%s",
+ _("Are you sure you have bills/invoices to update?"));
+ update = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ if (update == NO)
+ {
+ // Cleanup and leave
+ g_free (id);
+ g_free (date_opened);
+ g_free (owner_id);
+ g_free (biing_id);
+ g_free (notes);
+ g_free (date);
+ g_free (desc);
+ g_free (action);
+ g_free (account);
+ g_free (quantity);
+ g_free (price);
+ g_free (disc_type);
+ g_free (disc_how);
+ g_free (discount);
+ g_free (taxable);
+ g_free (taxincluded);
+ g_free (tax_table);
+ g_free (date_posted);
+ g_free (due_date);
+ g_free (account_posted);
+ g_free (memo_posted);
+ g_free (accumulatesplits);
+ return;
+ }
+ }
+ (*n_invoices_updated)++;
+ }
- // add entry to invoice/bill
- entry = gncEntryCreate (book);
- qof_scan_date (date, &day, &month, &year);
- gncEntrySetDate (entry, gnc_dmy2timespec (day, month, year));
- timespecFromTime_t (&today, time (NULL)); // set today to the current date
- gncEntrySetDateEntered (entry, today);
- gncEntrySetDescription (entry, desc);
- gncEntrySetAction (entry, action);
+ // add entry to invoice/bill
+ entry = gncEntryCreate (book);
+ qof_scan_date (date, &day, &month, &year);
+ gncEntrySetDate (entry, gnc_dmy2timespec (day, month, year));
+ timespecFromTime_t (&today, time (NULL)); // set today to the current date
+ gncEntrySetDateEntered (entry, today);
+ gncEntrySetDescription (entry, desc);
+ gncEntrySetAction (entry, action);
- n = gnc_numeric_zero ();
- gnc_exp_parser_parse (quantity, &n, NULL);
- gncEntrySetQuantity (entry, n);
- acc = gnc_account_lookup_for_register (gnc_get_current_root_account (),
- account);
- if (g_ascii_strcasecmp (type, "BILL") == 0)
- {
- gncEntrySetBillAccount (entry, acc);
- n = gnc_numeric_zero ();
- gnc_exp_parser_parse (price, &n, NULL);
- gncEntrySetBillPrice (entry, n);
- gncEntrySetBillTaxable (entry, text2bool (taxable));
- gncEntrySetBillTaxIncluded (entry, text2bool (taxincluded));
- gncEntrySetBillTaxTable (entry,
- gncTaxTableLookupByName (book, tax_table));
- n = gnc_numeric_zero ();
- gnc_exp_parser_parse (discount, &n, NULL);
- gncBillAddEntry (invoice, entry);
- }
- else if (g_ascii_strcasecmp (type, "INVOICE") == 0)
- {
- gncEntrySetNotes (entry, notes);
- gncEntrySetInvAccount (entry, acc);
- n = gnc_numeric_zero ();
- gnc_exp_parser_parse (price, &n, NULL);
- gncEntrySetInvPrice (entry, n);
- gncEntrySetInvTaxable (entry, text2bool (taxable));
- gncEntrySetInvTaxIncluded (entry, text2bool (taxincluded));
- gncEntrySetInvTaxTable (entry,
- gncTaxTableLookupByName (book, tax_table));
- n = gnc_numeric_zero ();
- gnc_exp_parser_parse (discount, &n, NULL);
- gncEntrySetInvDiscount (entry, n);
- gncEntrySetInvDiscountType (entry, text2disc_type (disc_type));
- gncEntrySetInvDiscountHow (entry, text2disc_how (disc_how));
- gncInvoiceAddEntry (invoice, entry);
- }
- valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter);
+ n = gnc_numeric_zero ();
+ gnc_exp_parser_parse (quantity, &n, NULL);
+ gncEntrySetQuantity (entry, n);
+ acc = gnc_account_lookup_for_register (gnc_get_current_root_account (),
+ account);
+ if (g_ascii_strcasecmp (type, "BILL") == 0)
+ {
+ gncEntrySetBillAccount (entry, acc);
+ n = gnc_numeric_zero ();
+ gnc_exp_parser_parse (price, &n, NULL);
+ gncEntrySetBillPrice (entry, n);
+ gncEntrySetBillTaxable (entry, text2bool (taxable));
+ gncEntrySetBillTaxIncluded (entry, text2bool (taxincluded));
+ gncEntrySetBillTaxTable (entry,
+ gncTaxTableLookupByName (book, tax_table));
+ n = gnc_numeric_zero ();
+ gnc_exp_parser_parse (discount, &n, NULL);
+ gncBillAddEntry (invoice, entry);
+ }
+ else if (g_ascii_strcasecmp (type, "INVOICE") == 0)
+ {
+ gncEntrySetNotes (entry, notes);
+ gncEntrySetInvAccount (entry, acc);
+ n = gnc_numeric_zero ();
+ gnc_exp_parser_parse (price, &n, NULL);
+ gncEntrySetInvPrice (entry, n);
+ gncEntrySetInvTaxable (entry, text2bool (taxable));
+ gncEntrySetInvTaxIncluded (entry, text2bool (taxincluded));
+ gncEntrySetInvTaxTable (entry,
+ gncTaxTableLookupByName (book, tax_table));
+ n = gnc_numeric_zero ();
+ gnc_exp_parser_parse (discount, &n, NULL);
+ gncEntrySetInvDiscount (entry, n);
+ gncEntrySetInvDiscountType (entry, text2disc_type (disc_type));
+ gncEntrySetInvDiscountHow (entry, text2disc_how (disc_how));
+ gncInvoiceAddEntry (invoice, entry);
+ }
+ valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter);
- // handle auto posting of invoices
- {
- gchar *new_id = NULL;
- Transaction *tnx;
- if (valid)
- gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, ID, &new_id, -1);
- if (g_strcmp0 (id, new_id) != 0)
- {
- // the next invoice id is different => try to autopost this invoice
- if (qof_scan_date (date_posted, &day, &month, &year))
- {
- // autopost this invoice
- Timespec d1, d2;
- d1 = gnc_dmy2timespec (day, month, year);
- qof_scan_date (due_date, &day, &month, &year); // obtains the due date, or leaves it at date_posted
- d2 = gnc_dmy2timespec (day, month, year);
- acc = gnc_account_lookup_for_register
- (gnc_get_current_root_account (), account_posted);
- tnx = gncInvoicePostToAccount (invoice, acc, &d1, &d2,
- memo_posted,
- text2bool (accumulatesplits));
- }
- }
- g_free (new_id);
- }
+ // handle auto posting of invoices
+ {
+ gchar *new_id = NULL;
+ Transaction *tnx;
+ if (valid)
+ gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, ID, &new_id, -1);
+ if (g_strcmp0 (id, new_id) != 0)
+ {
+ // the next invoice id is different => try to autopost this invoice
+ if (qof_scan_date (date_posted, &day, &month, &year))
+ {
+ // autopost this invoice
+ Timespec d1, d2;
+ d1 = gnc_dmy2timespec (day, month, year);
+ qof_scan_date (due_date, &day, &month, &year); // obtains the due date, or leaves it at date_posted
+ d2 = gnc_dmy2timespec (day, month, year);
+ acc = gnc_account_lookup_for_register
+ (gnc_get_current_root_account (), account_posted);
+ tnx = gncInvoicePostToAccount (invoice, acc, &d1, &d2,
+ memo_posted,
+ text2bool (accumulatesplits));
+ }
+ }
+ g_free (new_id);
+ }
- // cleanup
- g_free (id);
- g_free (date_opened);
- g_free (owner_id);
- g_free (biing_id);
- g_free (notes);
- g_free (date);
- g_free (desc);
- g_free (action);
- g_free (account);
- g_free (quantity);
- g_free (price);
- g_free (disc_type);
- g_free (disc_how);
- g_free (discount);
- g_free (taxable);
- g_free (taxincluded);
- g_free (tax_table);
- g_free (date_posted);
- g_free (due_date);
- g_free (account_posted);
- g_free (memo_posted);
- g_free (accumulatesplits);
+ // cleanup
+ g_free (id);
+ g_free (date_opened);
+ g_free (owner_id);
+ g_free (biing_id);
+ g_free (notes);
+ g_free (date);
+ g_free (desc);
+ g_free (action);
+ g_free (account);
+ g_free (quantity);
+ g_free (price);
+ g_free (disc_type);
+ g_free (disc_how);
+ g_free (discount);
+ g_free (taxable);
+ g_free (taxincluded);
+ g_free (tax_table);
+ g_free (date_posted);
+ g_free (due_date);
+ g_free (account_posted);
+ g_free (memo_posted);
+ g_free (accumulatesplits);
}
}
Modified: gnucash/trunk/src/plugins/bi_import/bi_import.h
===================================================================
--- gnucash/trunk/src/plugins/bi_import/bi_import.h 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/plugins/bi_import/bi_import.h 2011-01-24 14:10:09 UTC (rev 20163)
@@ -37,23 +37,26 @@
G_BEGIN_DECLS
// model
-enum bi_import_model_columns {
- ID, DATE_OPENED, OWNER_ID, BILLING_ID, NOTES, // invoice settings
- DATE, DESC, ACTION, ACCOUNT, QUANTITY, PRICE, DISC_TYPE, DISC_HOW, DISCOUNT, TAXABLE, TAXINCLUDED, TAX_TABLE, // entry settings
- DATE_POSTED, DUE_DATE, ACCOUNT_POSTED, MEMO_POSTED, ACCU_SPLITS, // autopost settings
- N_COLUMNS
+enum bi_import_model_columns
+{
+ ID, DATE_OPENED, OWNER_ID, BILLING_ID, NOTES, // invoice settings
+ DATE, DESC, ACTION, ACCOUNT, QUANTITY, PRICE, DISC_TYPE, DISC_HOW, DISCOUNT, TAXABLE, TAXINCLUDED, TAX_TABLE, // entry settings
+ DATE_POSTED, DUE_DATE, ACCOUNT_POSTED, MEMO_POSTED, ACCU_SPLITS, // autopost settings
+ N_COLUMNS
};
-enum _bi_import_result {
- RESULT_OK,
- RESULT_OPEN_FAILED,
- RESULT_ERROR_IN_REGEXP,
+enum _bi_import_result
+{
+ RESULT_OK,
+ RESULT_OPEN_FAILED,
+ RESULT_ERROR_IN_REGEXP,
};
typedef enum _bi_import_result bi_import_result;
-struct _bi_import_stats {
- int n_imported, n_ignored;
- GString *ignored_lines;
+struct _bi_import_stats
+{
+ int n_imported, n_ignored;
+ GString *ignored_lines;
};
typedef struct _bi_import_stats bi_import_stats;
Modified: gnucash/trunk/src/plugins/bi_import/gnc-plugin-bi_import.c
===================================================================
--- gnucash/trunk/src/plugins/bi_import/gnc-plugin-bi_import.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/plugins/bi_import/gnc-plugin-bi_import.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -51,9 +51,10 @@
#define PLUGIN_ACTIONS_NAME "gnc-plugin-bi_import-actions"
#define PLUGIN_UI_FILENAME "gnc-plugin-bi_import-ui.xml"
-static GtkActionEntry gnc_plugin_actions [] = {
+static GtkActionEntry gnc_plugin_actions [] =
+{
/* Menu Items */
- { "ImportMenuAction", NULL, N_("_Import"), NULL, NULL, NULL },
+ { "ImportMenuAction", NULL, N_("_Import"), NULL, NULL, NULL },
{ "bi_importAction", NULL, N_("Import Bills & Invoices..."), NULL, N_("bi_import tooltip"), G_CALLBACK(gnc_plugin_bi_import_cmd_test) },
};
static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions);
Modified: gnucash/trunk/src/plugins/bi_import/gnc-plugin-bi_import.h
===================================================================
--- gnucash/trunk/src/plugins/bi_import/gnc-plugin-bi_import.h 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/plugins/bi_import/gnc-plugin-bi_import.h 2011-01-24 14:10:09 UTC (rev 20163)
@@ -47,11 +47,13 @@
#define GNC_PLUGIN_bi_import_NAME "gnc-plugin-bi_import"
/* typedefs & structures */
-typedef struct {
+typedef struct
+{
GncPlugin gnc_plugin;
} GncPluginbi_import;
-typedef struct {
+typedef struct
+{
GncPluginClass gnc_plugin;
} GncPluginbi_importClass;
Modified: gnucash/trunk/src/plugins/bi_import/gncmod-bi_import.c
===================================================================
--- gnucash/trunk/src/plugins/bi_import/gncmod-bi_import.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/plugins/bi_import/gncmod-bi_import.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -66,24 +66,29 @@
int
libgncmod_bi_import_gnc_module_init (int refcount)
{
- if (!gnc_module_load ("gnucash/app-utils", 0)) {
+ if (!gnc_module_load ("gnucash/app-utils", 0))
+ {
return FALSE;
}
- if (!gnc_module_load ("gnucash/gnome-utils", 0)) {
+ if (!gnc_module_load ("gnucash/gnome-utils", 0))
+ {
return FALSE;
}
- if (!gnc_module_load ("gnucash/business-core", 0)) {
+ if (!gnc_module_load ("gnucash/business-core", 0))
+ {
return FALSE;
}
- if (!gnc_module_load ("gnucash/engine", 0)) {
+ if (!gnc_module_load ("gnucash/engine", 0))
+ {
return FALSE;
}
- if (refcount == 0) {
+ if (refcount == 0)
+ {
/* this is the first time the module is loaded */
gnc_plugin_manager_add_plugin ( gnc_plugin_manager_get (),
- gnc_plugin_bi_import_new ());
+ gnc_plugin_bi_import_new ());
}
return TRUE;
@@ -92,7 +97,8 @@
int
libgncmod_bi_import_gnc_module_end (int refcount)
{
- if (refcount == 0) {
+ if (refcount == 0)
+ {
/* this is the last time the module is unloaded */
}
Modified: gnucash/trunk/src/plugins/bi_import/gui.c
===================================================================
--- gnucash/trunk/src/plugins/bi_import/gui.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/plugins/bi_import/gui.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -43,15 +43,16 @@
#include "bi_import.h"
#include "gui.h"
-struct _bi_import_gui {
- GtkWidget *dialog;
- GtkWidget *tree_view;
- GtkWidget *entryFilename;
- GtkListStore *store;
- gint component_id;
- GString *regexp;
- QofBook *book;
- gchar *type;
+struct _bi_import_gui
+{
+ GtkWidget *dialog;
+ GtkWidget *tree_view;
+ GtkWidget *entryFilename;
+ GtkListStore *store;
+ gint component_id;
+ GString *regexp;
+ QofBook *book;
+ gchar *type;
};
@@ -81,251 +82,257 @@
BillImportGui *
gnc_plugin_bi_import_showGUI(void)
{
- BillImportGui *gui;
- GladeXML *xml;
- GList *glist;
- GtkTreeIter iter;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
+ BillImportGui *gui;
+ GladeXML *xml;
+ GList *glist;
+ GtkTreeIter iter;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
- // if window exists already, activate it
- glist = gnc_find_gui_components ("dialog-bi_import_gui", NULL, NULL);
- if (glist) {
- // window found
- gui = g_list_nth_data (glist,0);
- g_list_free (glist);
- gtk_window_present (GTK_WINDOW(gui->dialog));
- return gui;
- }
+ // if window exists already, activate it
+ glist = gnc_find_gui_components ("dialog-bi_import_gui", NULL, NULL);
+ if (glist)
+ {
+ // window found
+ gui = g_list_nth_data (glist, 0);
+ g_list_free (glist);
+ gtk_window_present (GTK_WINDOW(gui->dialog));
+ return gui;
+ }
- // create new window
- gui = g_new0 (BillImportGui, 1);
- gui->type = "BILL"; // Set default type to match gui. really shouldn't be here TODO change me
+ // create new window
+ gui = g_new0 (BillImportGui, 1);
+ gui->type = "BILL"; // Set default type to match gui. really shouldn't be here TODO change me
xml = gnc_glade_xml_new ("bi_import.glade", "bi_import Dialog");
- gui->dialog = glade_xml_get_widget (xml, "bi_import Dialog");
+ gui->dialog = glade_xml_get_widget (xml, "bi_import Dialog");
gui->tree_view = glade_xml_get_widget (xml, "treeview1");
- gui->entryFilename = glade_xml_get_widget (xml, "entryFilename");
+ gui->entryFilename = glade_xml_get_widget (xml, "entryFilename");
- gui->book = gnc_get_current_book();
+ gui->book = gnc_get_current_book();
- gui->regexp = g_string_new ( "^(?<id>[^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*)(;?(?<disc_type>[^;]*)(;?(?<disc_how>[^;]*)(;?(?<discount>[^;]*)(;?(?<taxable>[^;]*)(;?(?<taxincluded>[^;]*)(;?(?<tax_table>[^;]*)(;(?<date_posted>[^;]*)(;(?<due_date>[^;]*)(;(?<account_posted>[^;]*)(;(?<memo_posted>[^;]*)(;(?<accu_splits>[^;]*))?)?)?)?)?)?)?)?)?)?)?");
+ gui->regexp = g_string_new ( "^(?<id>[^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*)(;?(?<disc_type>[^;]*)(;?(?<disc_how>[^;]*)(;?(?<discount>[^;]*)(;?(?<taxable>[^;]*)(;?(?<taxincluded>[^;]*)(;?(?<tax_table>[^;]*)(;(?<date_posted>[^;]*)(;(?<due_date>[^;]*)(;(?<account_posted>[^;]*)(;(?<memo_posted>[^;]*)(;(?<accu_splits>[^;]*))?)?)?)?)?)?)?)?)?)?)?");
// create model and bind to view
gui->store = gtk_list_store_new (N_COLUMNS,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, // invoice settings
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, // entry settings
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); // autopost settings
- gtk_tree_view_set_model( GTK_TREE_VIEW(gui->tree_view), GTK_TREE_MODEL(gui->store) );
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, // invoice settings
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, // entry settings
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); // autopost settings
+ gtk_tree_view_set_model( GTK_TREE_VIEW(gui->tree_view), GTK_TREE_MODEL(gui->store) );
#define CREATE_COLUMN(description,column_id) \
renderer = gtk_cell_renderer_text_new (); \
column = gtk_tree_view_column_new_with_attributes (description, renderer, "text", column_id, NULL); \
gtk_tree_view_column_set_resizable (column, TRUE); \
gtk_tree_view_append_column (GTK_TREE_VIEW (gui->tree_view), column);
- CREATE_COLUMN ("id", ID);
- CREATE_COLUMN ("date__opened", DATE_OPENED);
- CREATE_COLUMN ("owner__id", OWNER_ID);
- CREATE_COLUMN ("billing_id", BILLING_ID);
- CREATE_COLUMN ("notes", NOTES);
+ CREATE_COLUMN ("id", ID);
+ CREATE_COLUMN ("date__opened", DATE_OPENED);
+ CREATE_COLUMN ("owner__id", OWNER_ID);
+ CREATE_COLUMN ("billing_id", BILLING_ID);
+ CREATE_COLUMN ("notes", NOTES);
- CREATE_COLUMN ("date", DATE);
- CREATE_COLUMN ("desc", DESC);
- CREATE_COLUMN ("action", ACTION);
- CREATE_COLUMN ("account", ACCOUNT);
- CREATE_COLUMN ("quantity", QUANTITY);
- CREATE_COLUMN ("price", PRICE);
- CREATE_COLUMN ("disc__type", DISC_TYPE);
- CREATE_COLUMN ("disc__how", DISC_HOW);
- CREATE_COLUMN ("discount", DISCOUNT);
- CREATE_COLUMN ("taxable", TAXABLE);
- CREATE_COLUMN ("taxincluded", TAXINCLUDED);
- CREATE_COLUMN ("tax__table", TAX_TABLE);
+ CREATE_COLUMN ("date", DATE);
+ CREATE_COLUMN ("desc", DESC);
+ CREATE_COLUMN ("action", ACTION);
+ CREATE_COLUMN ("account", ACCOUNT);
+ CREATE_COLUMN ("quantity", QUANTITY);
+ CREATE_COLUMN ("price", PRICE);
+ CREATE_COLUMN ("disc__type", DISC_TYPE);
+ CREATE_COLUMN ("disc__how", DISC_HOW);
+ CREATE_COLUMN ("discount", DISCOUNT);
+ CREATE_COLUMN ("taxable", TAXABLE);
+ CREATE_COLUMN ("taxincluded", TAXINCLUDED);
+ CREATE_COLUMN ("tax__table", TAX_TABLE);
- CREATE_COLUMN ("date__posted", DATE_POSTED);
- CREATE_COLUMN ("due__date", DUE_DATE);
- CREATE_COLUMN ("account__posted", ACCOUNT_POSTED);
- CREATE_COLUMN ("memo__posted", MEMO_POSTED);
- CREATE_COLUMN ("accu__splits", ACCU_SPLITS);
+ CREATE_COLUMN ("date__posted", DATE_POSTED);
+ CREATE_COLUMN ("due__date", DUE_DATE);
+ CREATE_COLUMN ("account__posted", ACCOUNT_POSTED);
+ CREATE_COLUMN ("memo__posted", MEMO_POSTED);
+ CREATE_COLUMN ("accu__splits", ACCU_SPLITS);
gui->component_id = gnc_register_gui_component ("dialog-bi_import_gui",
- NULL,
- gnc_bi_import_gui_close_handler,
- gui);
+ NULL,
+ gnc_bi_import_gui_close_handler,
+ gui);
- /* Setup signals */
- glade_xml_signal_autoconnect_full( xml, gnc_glade_autoconnect_full_func, gui );
+ /* Setup signals */
+ glade_xml_signal_autoconnect_full( xml, gnc_glade_autoconnect_full_func, gui );
gtk_widget_show_all ( gui->dialog );
- return gui;
+ return gui;
}
static gchar *
gnc_plugin_bi_import_getFilename(void)
{
- // prepare file import dialog
- gchar *filename;
- GList *filters;
- GtkFileFilter *filter;
- filters = NULL;
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, "comma separated values (*.csv)");
- gtk_file_filter_add_pattern (filter, "*.csv");
- filters = g_list_append( filters, filter );
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, "text files (*.txt)");
- gtk_file_filter_add_pattern (filter, "*.txt");
- filters = g_list_append( filters, filter );
- filename = gnc_file_dialog(_("Import Bills or Invoices from csv"), filters, NULL, GNC_FILE_DIALOG_IMPORT);
+ // prepare file import dialog
+ gchar *filename;
+ GList *filters;
+ GtkFileFilter *filter;
+ filters = NULL;
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, "comma separated values (*.csv)");
+ gtk_file_filter_add_pattern (filter, "*.csv");
+ filters = g_list_append( filters, filter );
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, "text files (*.txt)");
+ gtk_file_filter_add_pattern (filter, "*.txt");
+ filters = g_list_append( filters, filter );
+ filename = gnc_file_dialog(_("Import Bills or Invoices from csv"), filters, NULL, GNC_FILE_DIALOG_IMPORT);
- return filename;
+ return filename;
}
void
gnc_bi_import_gui_ok_cb (GtkWidget *widget, gpointer data)
{
- BillImportGui *gui = data;
- gchar *filename = g_strdup( gtk_entry_get_text( GTK_ENTRY(gui->entryFilename) ) );
- bi_import_stats stats;
- bi_import_result res;
- guint n_fixed, n_deleted, n_invoices_created, n_invoices_updated;
- GString *info;
+ BillImportGui *gui = data;
+ gchar *filename = g_strdup( gtk_entry_get_text( GTK_ENTRY(gui->entryFilename) ) );
+ bi_import_stats stats;
+ bi_import_result res;
+ guint n_fixed, n_deleted, n_invoices_created, n_invoices_updated;
+ GString *info;
- // import
- info = g_string_new("");
+ // import
+ info = g_string_new("");
- gtk_list_store_clear (gui->store);
- res = gnc_bi_import_read_file (filename, gui->regexp->str, gui->store, 0, &stats);
- if (res == RESULT_OK) {
- gnc_bi_import_fix_bis (gui->store, &n_fixed, &n_deleted, info);
- if (info->len > 0)
- gnc_info_dialog (gui->dialog, "%s", info->str);
- g_string_free( info, TRUE );
- gnc_bi_import_create_bis (gui->store, gui->book, &n_invoices_created, &n_invoices_updated, gui->type);
- gnc_info_dialog (gui->dialog, _("Import results:\n%i lines were ignored\n%i lines imported:\n %u fixes\n %u ignored (not fixable)\n\n %u created\n %u updated (based on id)"), stats.n_ignored, stats.n_imported, n_fixed, n_deleted, n_invoices_created, n_invoices_updated);
+ gtk_list_store_clear (gui->store);
+ res = gnc_bi_import_read_file (filename, gui->regexp->str, gui->store, 0, &stats);
+ if (res == RESULT_OK)
+ {
+ gnc_bi_import_fix_bis (gui->store, &n_fixed, &n_deleted, info);
+ if (info->len > 0)
+ gnc_info_dialog (gui->dialog, "%s", info->str);
+ g_string_free( info, TRUE );
+ gnc_bi_import_create_bis (gui->store, gui->book, &n_invoices_created, &n_invoices_updated, gui->type);
+ gnc_info_dialog (gui->dialog, _("Import results:\n%i lines were ignored\n%i lines imported:\n %u fixes\n %u ignored (not fixable)\n\n %u created\n %u updated (based on id)"), stats.n_ignored, stats.n_imported, n_fixed, n_deleted, n_invoices_created, n_invoices_updated);
- if (stats.n_ignored > 0)
- gnc_info2_dialog (gui->dialog, _("These lines were ignored during import"), stats.ignored_lines->str);
+ if (stats.n_ignored > 0)
+ gnc_info2_dialog (gui->dialog, _("These lines were ignored during import"), stats.ignored_lines->str);
- g_string_free (stats.ignored_lines,TRUE);
- gnc_close_gui_component (gui->component_id);
- } else
- if (res == RESULT_OPEN_FAILED) {
- gnc_error_dialog (gui->dialog, _("The input file can not be opened."));
- } else
- if (res == RESULT_ERROR_IN_REGEXP) {
- //gnc_error_dialog (gui->dialog, "The regular expression is faulty:\n\n%s", stats.err->str);
- }
+ g_string_free (stats.ignored_lines, TRUE);
+ gnc_close_gui_component (gui->component_id);
+ }
+ else if (res == RESULT_OPEN_FAILED)
+ {
+ gnc_error_dialog (gui->dialog, _("The input file can not be opened."));
+ }
+ else if (res == RESULT_ERROR_IN_REGEXP)
+ {
+ //gnc_error_dialog (gui->dialog, "The regular expression is faulty:\n\n%s", stats.err->str);
+ }
}
void
gnc_bi_import_gui_cancel_cb (GtkWidget *widget, gpointer data)
{
- BillImportGui *gui = data;
+ BillImportGui *gui = data;
- gnc_close_gui_component (gui->component_id);
+ gnc_close_gui_component (gui->component_id);
}
void
gnc_bi_import_gui_help_cb (GtkWidget *widget, gpointer data)
{
- gnc_gnome_help(HF_HELP, HL_USAGE);
+ gnc_gnome_help(HF_HELP, HL_USAGE);
}
static void
gnc_bi_import_gui_close_handler (gpointer user_data)
{
- BillImportGui *gui = user_data;
+ BillImportGui *gui = user_data;
- gtk_widget_destroy (gui->dialog);
- // gui has already been freed by this point.
- // gui->dialog = NULL;
+ gtk_widget_destroy (gui->dialog);
+ // gui has already been freed by this point.
+ // gui->dialog = NULL;
}
void
gnc_bi_import_gui_destroy_cb (GtkWidget *widget, gpointer data)
{
- BillImportGui *gui = data;
+ BillImportGui *gui = data;
- gnc_suspend_gui_refresh ();
- gnc_unregister_gui_component (gui->component_id);
- gnc_resume_gui_refresh ();
+ gnc_suspend_gui_refresh ();
+ gnc_unregister_gui_component (gui->component_id);
+ gnc_resume_gui_refresh ();
- g_object_unref (gui->store);
- g_string_free (gui->regexp, TRUE);
- g_free (gui);
+ g_object_unref (gui->store);
+ g_string_free (gui->regexp, TRUE);
+ g_free (gui);
}
void gnc_bi_import_gui_buttonOpen_cb (GtkWidget *widget, gpointer data)
{
- gchar *filename;
- BillImportGui *gui = data;
+ gchar *filename;
+ BillImportGui *gui = data;
- filename = gnc_plugin_bi_import_getFilename();
- if (filename) {
- //printf("Setting filename"); // debug
- gtk_entry_set_text( GTK_ENTRY(gui->entryFilename), filename );
- //printf("Set filename"); // debug
- g_free( filename );
- }
+ filename = gnc_plugin_bi_import_getFilename();
+ if (filename)
+ {
+ //printf("Setting filename"); // debug
+ gtk_entry_set_text( GTK_ENTRY(gui->entryFilename), filename );
+ //printf("Set filename"); // debug
+ g_free( filename );
+ }
}
void gnc_bi_import_gui_filenameChanged_cb (GtkWidget *widget, gpointer data)
{
- BillImportGui *gui = data;
- gchar *filename = g_strdup( gtk_entry_get_text( GTK_ENTRY(gui->entryFilename) ) );
+ BillImportGui *gui = data;
+ gchar *filename = g_strdup( gtk_entry_get_text( GTK_ENTRY(gui->entryFilename) ) );
- // generate preview
- gtk_list_store_clear (gui->store);
- gnc_bi_import_read_file (filename, gui->regexp->str, gui->store, 10, NULL);
+ // generate preview
+ gtk_list_store_clear (gui->store);
+ gnc_bi_import_read_file (filename, gui->regexp->str, gui->store, 10, NULL);
- g_free( filename );
+ g_free( filename );
}
void gnc_bi_import_gui_option1_cb (GtkWidget *widget, gpointer data)
{
- BillImportGui *gui = data;
- if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
- return;
- g_string_assign (gui->regexp, "^(?<id>[^!#+^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*);?(?<disc_type>[^;]*);?(?<disc_how>[^;]*);?(?<discount>[^;]*);?(?<taxable>[^;]*);?(?<taxincluded>[^;]*);?(?<tax_table>[^;]*);(?<date_posted>[^;]*);(?<due_date>[^;]*);(?<account_posted>[^;]*);(?<memo_posted>[^;]*);(?<accu_splits>[^;]*)");
- gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
+ BillImportGui *gui = data;
+ if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
+ return;
+ g_string_assign (gui->regexp, "^(?<id>[^!#+^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*);?(?<disc_type>[^;]*);?(?<disc_how>[^;]*);?(?<discount>[^;]*);?(?<taxable>[^;]*);?(?<taxincluded>[^;]*);?(?<tax_table>[^;]*);(?<date_posted>[^;]*);(?<due_date>[^;]*);(?<account_posted>[^;]*);(?<memo_posted>[^;]*);(?<accu_splits>[^;]*)");
+ gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
}
void gnc_bi_import_gui_option2_cb (GtkWidget *widget, gpointer data)
{
- BillImportGui *gui = data;
- if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
- return;
- g_string_assign (gui->regexp, "^(?<id>[^!#+^,]*),(?<date_opened>[^,]*),(?<owner_id>[^,]*),(?<billingid>[^,]*),?(?<notes>[^,]*),?(?<date>[^,]*),?(?<desc>[^,]*),?(?<action>[^,]*),?(?<account>[^,]*),?(?<quantity>[^,]*),?(?<price>[^,]*),?(?<disc_type>[^,]*),?(?<disc_how>[^,]*),?(?<discount>[^,]*),?(?<taxable>[^,]*),?(?<taxincluded>[^,]*),?(?<tax_table>[^,]*),(?<date_posted>[^,]*),(?<due_date>[^,]*),(?<account_posted>[^,]*),(?<memo_posted>[^,]*),(?<accu_splits>[^,]*)");
- gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
+ BillImportGui *gui = data;
+ if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
+ return;
+ g_string_assign (gui->regexp, "^(?<id>[^!#+^,]*),(?<date_opened>[^,]*),(?<owner_id>[^,]*),(?<billingid>[^,]*),?(?<notes>[^,]*),?(?<date>[^,]*),?(?<desc>[^,]*),?(?<action>[^,]*),?(?<account>[^,]*),?(?<quantity>[^,]*),?(?<price>[^,]*),?(?<disc_type>[^,]*),?(?<disc_how>[^,]*),?(?<discount>[^,]*),?(?<taxable>[^,]*),?(?<taxincluded>[^,]*),?(?<tax_table>[^,]*),(?<date_posted>[^,]*),(?<due_date>[^,]*),(?<account_posted>[^,]*),(?<memo_posted>[^,]*),(?<accu_splits>[^,]*)");
+ gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
}
void gnc_bi_import_gui_option3_cb (GtkWidget *widget, gpointer data)
{
- BillImportGui *gui = data;
- if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
- return;
- g_string_assign (gui->regexp, "^(?<id>[^!#+^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*);?(?<disc_type>[^;]*);?(?<disc_how>[^;]*);?(?<discount>[^;]*);?(?<taxable>[^;]*);?(?<taxincluded>[^;]*);?(?<tax_table>[^;]*);(?<date_posted>[^;]*);(?<due_date>[^;]*);(?<account_posted>[^;]*);(?<memo_posted>[^;]*);(?<accu_splits>[^;]*)");
- gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
+ BillImportGui *gui = data;
+ if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
+ return;
+ g_string_assign (gui->regexp, "^(?<id>[^!#+^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*);?(?<disc_type>[^;]*);?(?<disc_how>[^;]*);?(?<discount>[^;]*);?(?<taxable>[^;]*);?(?<taxincluded>[^;]*);?(?<tax_table>[^;]*);(?<date_posted>[^;]*);(?<due_date>[^;]*);(?<account_posted>[^;]*);(?<memo_posted>[^;]*);(?<accu_splits>[^;]*)");
+ gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
}
void gnc_bi_import_gui_option4_cb (GtkWidget *widget, gpointer data)
{
- BillImportGui *gui = data;
- if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
- return;
- g_string_assign (gui->regexp, "^(?<id>[^!#+^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*);?(?<disc_type>[^;]*);?(?<disc_how>[^;]*);?(?<discount>[^;]*);?(?<taxable>[^;]*);?(?<taxincluded>[^;]*);?(?<tax_table>[^;]*);(?<date_posted>[^;]*);(?<due_date>[^;]*);(?<account_posted>[^;]*);(?<memo_posted>[^;]*);(?<accu_splits>[^;]*)");
- gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
+ BillImportGui *gui = data;
+ if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
+ return;
+ g_string_assign (gui->regexp, "^(?<id>[^!#+^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*);?(?<disc_type>[^;]*);?(?<disc_how>[^;]*);?(?<discount>[^;]*);?(?<taxable>[^;]*);?(?<taxincluded>[^;]*);?(?<tax_table>[^;]*);(?<date_posted>[^;]*);(?<due_date>[^;]*);(?<account_posted>[^;]*);(?<memo_posted>[^;]*);(?<accu_splits>[^;]*)");
+ gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
}
void gnc_bi_import_gui_option5_cb (GtkWidget *widget, gpointer data)
{
- BillImportGui *gui = data;
- gchar *temp;
- if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
- return;
+ BillImportGui *gui = data;
+ gchar *temp;
+ if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
+ return;
temp = gnc_input_dialog (0, _("Adjust regular expression used for import"), _("This regular expression is used to parse the import file. Modify according to your needs.\n"), gui->regexp->str);
- if (temp) {
- g_string_assign (gui->regexp,temp);
- g_free (temp);
- gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
- }
+ if (temp)
+ {
+ g_string_assign (gui->regexp, temp);
+ g_free (temp);
+ gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
+ }
}
/*****************************************************************
* Set whether we are importing a bi, invoice, Customer or Vendor
@@ -333,12 +340,12 @@
void gnc_import_gui_type(GtkWidget *widget, gpointer data)
{
- BillImportGui *gui = data;
- if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
- return;
- if (g_ascii_strcasecmp(widget->name,"radiobuttonInvoice") == 0)gui->type="INVOICE";
- else if (g_ascii_strcasecmp(widget->name,"radiobuttonBill") == 0)gui->type="BILL";
- //printf ("TYPE set to, %s\n",gui->type);
+ BillImportGui *gui = data;
+ if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
+ return;
+ if (g_ascii_strcasecmp(widget->name, "radiobuttonInvoice") == 0)gui->type = "INVOICE";
+ else if (g_ascii_strcasecmp(widget->name, "radiobuttonBill") == 0)gui->type = "BILL";
+ //printf ("TYPE set to, %s\n",gui->type);
}
@@ -376,10 +383,10 @@
/* Create the widgets */
dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parent),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
- GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
- NULL);
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
+ NULL);
#ifdef HAVE_GTK_2_14
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
#else
@@ -403,11 +410,12 @@
if (result == GTK_RESPONSE_REJECT)
user_input = 0;
- else {
+ else
+ {
gtk_text_buffer_get_start_iter (buffer, &start);
gtk_text_buffer_get_end_iter (buffer, &end);
user_input = gtk_text_buffer_get_text (buffer,
- &start, &end, FALSE);
+ &start, &end, FALSE);
}
gtk_widget_destroy (dialog);
@@ -435,13 +443,13 @@
GtkTextBuffer *buffer;
gchar *user_input;
GtkTextIter start, end;
- gint width,height;
+ gint width, height;
/* Create the widgets */
dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parent),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
- NULL);
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+ NULL);
#ifdef HAVE_GTK_2_14
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
#else
@@ -449,22 +457,23 @@
#endif
// add a scroll area
- scrolledwindow = gtk_scrolled_window_new (NULL,NULL);
+ scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (content_area), scrolledwindow);
// add a textview
view = gtk_text_view_new ();
// gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD_CHAR);
- gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
gtk_text_buffer_set_text (buffer, msg, -1);
gtk_container_add (GTK_CONTAINER (scrolledwindow), view);
// run the dialog
- if (parent) {
- gtk_window_get_size (GTK_WINDOW(parent), &width, &height);
- gtk_window_set_default_size (GTK_WINDOW(dialog), width, height);
- }
+ if (parent)
+ {
+ gtk_window_get_size (GTK_WINDOW(parent), &width, &height);
+ gtk_window_set_default_size (GTK_WINDOW(dialog), width, height);
+ }
gtk_widget_show_all (dialog);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
Modified: gnucash/trunk/src/plugins/bi_import/helpers.c
===================================================================
--- gnucash/trunk/src/plugins/bi_import/helpers.c 2011-01-24 14:04:37 UTC (rev 20162)
+++ gnucash/trunk/src/plugins/bi_import/helpers.c 2011-01-24 14:10:09 UTC (rev 20163)
@@ -28,53 +28,53 @@
//! \brief helper function
gboolean text2bool( const gchar *text )
{
- gboolean erg = FALSE;
- gchar *temp;
+ gboolean erg = FALSE;
+ gchar *temp;
- if (!text)
- return erg;
+ if (!text)
+ return erg;
- temp = g_strdup( text );
- g_strstrip( temp );
- if ((g_ascii_strcasecmp( temp, "yes" ) == 0) || (g_ascii_strcasecmp( temp, "true" ) == 0) ||
- (g_ascii_strcasecmp( temp, "1" ) == 0) || (g_ascii_strcasecmp( temp, "x" ) == 0))
- erg = TRUE;
- g_free( temp );
- return erg;
+ temp = g_strdup( text );
+ g_strstrip( temp );
+ if ((g_ascii_strcasecmp( temp, "yes" ) == 0) || (g_ascii_strcasecmp( temp, "true" ) == 0) ||
+ (g_ascii_strcasecmp( temp, "1" ) == 0) || (g_ascii_strcasecmp( temp, "x" ) == 0))
+ erg = TRUE;
+ g_free( temp );
+ return erg;
}
//! \brief helper function
GncAmountType text2disc_type( const gchar *text )
{
- GncAmountType type = GNC_AMT_TYPE_PERCENT;
- gchar *temp;
+ GncAmountType type = GNC_AMT_TYPE_PERCENT;
+ gchar *temp;
- if (!text)
- return type;
+ if (!text)
+ return type;
- temp = g_strdup( text );
- g_strstrip( temp );
- if ((strlen(temp) > 0) && (g_ascii_strcasecmp( temp, "%" ) != 0))
- type = GNC_AMT_TYPE_VALUE;
- g_free( temp );
- return type;
+ temp = g_strdup( text );
+ g_strstrip( temp );
+ if ((strlen(temp) > 0) && (g_ascii_strcasecmp( temp, "%" ) != 0))
+ type = GNC_AMT_TYPE_VALUE;
+ g_free( temp );
+ return type;
}
//! \brief helper function
GncDiscountHow text2disc_how( const gchar *text )
{
- GncDiscountHow how = GNC_DISC_PRETAX;
- gchar *temp;
+ GncDiscountHow how = GNC_DISC_PRETAX;
+ gchar *temp;
- if (!text)
- return how;
+ if (!text)
+ return how;
- temp = g_strdup( text );
- g_strstrip( temp );
- if (g_ascii_strcasecmp( temp, "=" ) == 0)
- how = GNC_DISC_SAMETIME;
- else if (g_ascii_strcasecmp( temp, ">" ) == 0)
- how = GNC_DISC_POSTTAX;
- g_free( temp );
- return how;
+ temp = g_strdup( text );
+ g_strstrip( temp );
+ if (g_ascii_strcasecmp( temp, "=" ) == 0)
+ how = GNC_DISC_SAMETIME;
+ else if (g_ascii_strcasecmp( temp, ">" ) == 0)
+ how = GNC_DISC_POSTTAX;
+ g_free( temp );
+ return how;
}
More information about the gnucash-changes
mailing list